2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
13 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
18 require './libraries/tbl_common.php';
19 $url_query .= '&goto=tbl_operations.php&back=tbl_operations.php';
20 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
23 * Gets relation settings
25 $cfgRelation = PMA_getRelationsParam();
28 * Gets available MySQL charsets and storage engines
30 require_once './libraries/mysql_charsets.lib.php';
31 require_once './libraries/StorageEngine.class.php';
33 // add a javascript file for jQuery functions to handle Ajax actions
35 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
38 * Class for partition management
40 require_once './libraries/Partition.class.php';
42 // reselect current db (needed in some cases probably due to
43 // the calling of relation.lib.php)
44 PMA_DBI_select_db($GLOBALS['db']);
47 * Gets tables informations
50 require './libraries/tbl_info.inc.php';
52 // define some globals here, for improved syntax in the conditionals
53 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
54 // set initial value of these globals, based on the current table engine
55 PMA_set_global_variables_for_engine($tbl_type);
58 // the value for transactional can be implicit
59 // (no create option found, in this case it means 1)
60 // or explicit (option found with a value of 0 or 1)
61 // ($transactional may have been set by libraries/tbl_info.inc.php,
62 // from the $create_options)
63 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
64 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
68 $table_alters = array();
71 * If the table has to be moved to some other database
73 if (isset($_REQUEST['submit_move']) ||
isset($_REQUEST['submit_copy'])) {
75 require_once './tbl_move_copy.php';
78 * If the table has to be maintained
80 if (isset($_REQUEST['table_maintenance'])) {
81 require_once './sql.php';
85 * Updates table comment, type and options if required
87 if (isset($_REQUEST['submitoptions'])) {
89 $warning_messages = array();
91 if (isset($_REQUEST['new_name'])) {
92 if ($pma_table->rename($_REQUEST['new_name'])) {
93 $_message .= $pma_table->getLastMessage();
95 $GLOBALS['table'] = $pma_table->getName();
99 $_message .= $pma_table->getLastError();
103 if (isset($_REQUEST['comment'])
104 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
105 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddSlashes($_REQUEST['comment']) . '\'';
107 if (! empty($_REQUEST['new_tbl_type'])
108 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
109 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
110 $tbl_type = $_REQUEST['new_tbl_type'];
111 // reset the globals for the new engine
112 PMA_set_global_variables_for_engine($tbl_type);
114 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
115 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
119 if (! empty($_REQUEST['tbl_collation'])
120 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
121 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
124 if (($is_myisam_or_aria ||
$is_isam)
125 && isset($_REQUEST['new_pack_keys'])
126 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
127 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
130 $checksum = empty($checksum) ?
'0' : '1';
131 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ?
'0' : '1';
132 if ($is_myisam_or_aria
133 && $_REQUEST['new_checksum'] !== $checksum) {
134 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
137 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ?
'0' : '1';
139 && $_REQUEST['new_transactional'] !== $transactional) {
140 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
143 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ?
'0' : '1';
145 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
146 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
149 $delay_key_write = empty($delay_key_write) ?
'0' : '1';
150 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ?
'0' : '1';
151 if ($is_myisam_or_aria
152 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
153 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
156 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
157 && ! empty($_REQUEST['new_auto_increment'])
158 && (! isset($auto_increment) ||
$_REQUEST['new_auto_increment'] !== $auto_increment)) {
159 $table_alters[] = 'auto_increment = ' . PMA_sqlAddSlashes($_REQUEST['new_auto_increment']);
162 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
163 && ! empty($_REQUEST['new_row_format'])
164 && (! isset($row_format) ||
strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
165 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddSlashes($_REQUEST['new_row_format']);
168 if (count($table_alters) > 0) {
169 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
170 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
171 $result .= PMA_DBI_query($sql_query) ?
true : false;
173 unset($table_alters);
174 foreach (PMA_DBI_get_warnings() as $warning) {
175 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
176 // and if TRANSACTIONAL was set, the system reports an error;
177 // I discussed with a Maria developer and he agrees that this
178 // should not be reported with a Level of Error, so here
179 // I just ignore it. But there are other 1478 messages
180 // that it's better to show.
181 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
182 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
183 . ' ' . $warning['Message'];
189 * Reordering the table has been requested by the user
191 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
193 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
194 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
195 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
196 $sql_query .= ' DESC';
198 $result = PMA_DBI_query($sql_query);
202 * A partition operation has been requested by the user
204 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
205 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
206 $result = PMA_DBI_query($sql_query);
210 // to avoid showing the old value (for example the AUTO_INCREMENT) after
211 // a change, clear the cache
212 PMA_Table
::$cache = array();
213 $page_checksum = $checksum = $delay_key_write = 0;
214 require './libraries/tbl_info.inc.php';
219 * Displays top menu links in non ajax requests
221 if (!isset($_REQUEST['ajax_request'])) {
222 require_once './libraries/tbl_links.inc.php';
224 if (isset($result) && empty($message_to_show)) {
225 // set to success by default, because result set could be empty
226 // (for example, a table rename)
228 if (empty($_message)) {
229 $_message = $result ?
$message = PMA_Message
::success(__('Your SQL query has been executed successfully')) : PMA_Message
::error(__('Error'));
230 // $result should exist, regardless of $_message
231 $_type = $result ?
'success' : 'error';
232 if ( $_REQUEST['ajax_request'] == true) {
233 $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query);
234 PMA_ajaxResponse($_message,$_message->isSuccess() ,$extra_data);
237 if (! empty($warning_messages)) {
238 $_message = new PMA_Message
;
239 $_message->addMessages($warning_messages);
240 $_message->isError(true);
241 if ( $_REQUEST['ajax_request'] == true) {
242 PMA_ajaxResponse($_message, false);
244 unset($warning_messages);
247 PMA_showMessage($_message, $sql_query, $_type);
248 unset($_message, $_type);
251 $url_params['goto'] = 'tbl_operations.php';
252 $url_params['back'] = 'tbl_operations.php';
257 $columns = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']);
263 <!-- Order the table
-->
264 <div
class="operations_half_width">
265 <form method
="post" id
="alterTableOrderby" action
="tbl_operations.php" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
266 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
267 <fieldset id
="fieldset_table_order">
268 <legend
><?php
echo __('Alter table order by'); ?
></legend
>
269 <select name
="order_field">
271 foreach ($columns as $fieldname) {
272 echo ' <option value="' . htmlspecialchars($fieldname['Field']) . '">'
273 . htmlspecialchars($fieldname['Field']) . '</option>' . "\n";
277 </select
> <?php
echo __('(singly)'); ?
>
278 <select name
="order_order">
279 <option value
="asc"><?php
echo __('Ascending'); ?
></option
>
280 <option value
="desc"><?php
echo __('Descending'); ?
></option
>
283 <fieldset
class="tblFooters">
284 <input type
="submit" name
="submitorderby" value
="<?php echo __('Go'); ?>" />
290 <div
class="operations_half_width">
291 <form method
="post" action
="tbl_operations.php"
292 onsubmit
="return emptyFormElements(this, 'new_name')">
293 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
294 <input type
="hidden" name
="reload" value
="1" />
295 <input type
="hidden" name
="what" value
="data" />
296 <fieldset id
="fieldset_table_rename">
297 <legend
><?php
echo __('Move table to (database<b>.</b>table):'); ?
></legend
>
298 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
300 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
304 <select name
="target_db">
305 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
310  
;<strong
>.</strong
> 
;
311 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
312 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br
/>
314 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
315 // next value but users can decide if they want it or not for the operation
317 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_mv" checked
="checked" />
318 <label
for="checkbox_auto_increment_mv"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
320 <fieldset
class="tblFooters">
321 <input type
="submit" name
="submit_move" value
="<?php echo __('Go'); ?>" />
327 if (strstr($show_comment, '; InnoDB free') === false) {
328 if (strstr($show_comment, 'InnoDB free') === false) {
329 // only user entered comment
330 $comment = $show_comment;
332 // here we have just InnoDB generated part
336 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
337 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
340 // PACK_KEYS: MyISAM or ISAM
341 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
342 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
344 // Here should be version check for InnoDB, however it is supported
345 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
349 <!-- Table options
-->
350 <div
class="operations_half_width clearfloat">
351 <form method
="post" action
="tbl_operations.php">
352 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
353 <input type
="hidden" name
="reload" value
="1" />
355 <legend
><?php
echo __('Table options'); ?
></legend
>
358 <!-- Change table name
-->
359 <tr
><td
><?php
echo __('Rename table to'); ?
></td
>
360 <td
><input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
361 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
365 <!-- Table comments
-->
366 <tr
><td
><?php
echo __('Table comments'); ?
></td
>
367 <td
><input type
="text" name
="comment" maxlength
="60" size
="30"
368 value
="<?php echo htmlspecialchars($comment); ?>" onfocus
="this.select()" />
369 <input type
="hidden" name
="prev_comment" value
="<?php echo htmlspecialchars($comment); ?>" />
373 <!-- Storage engine
-->
374 <tr
><td
><?php
echo __('Storage Engine'); ?
>
375 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
377 <td
><?php
echo PMA_StorageEngine
::getHtmlSelect('new_tbl_type', null, $tbl_type); ?
>
381 <!-- Table character set
-->
382 <tr
><td
><?php
echo __('Collation'); ?
></td
>
383 <td
><?php
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
,
384 'tbl_collation', null, $tbl_collation, false, 3); ?
>
388 if ($is_myisam_or_aria ||
$is_isam) {
391 <td
><label
for="new_pack_keys">PACK_KEYS
</label
></td
>
392 <td
><select name
="new_pack_keys" id
="new_pack_keys">
393 <option value
="DEFAULT"
394 <?php
if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?
>
397 <?php
if ($pack_keys == '0') echo 'selected="selected"'; ?
>
400 <?php
if ($pack_keys == '1') echo 'selected="selected"'; ?
>
406 } // end if (MYISAM|ISAM)
408 if ($is_myisam_or_aria) {
410 <tr
><td
><label
for="new_checksum">CHECKSUM
</label
></td
>
411 <td
><input type
="checkbox" name
="new_checksum" id
="new_checksum"
413 <?php
echo (isset($checksum) && $checksum == 1)
414 ?
' checked="checked"'
419 <tr
><td
><label
for="new_delay_key_write">DELAY_KEY_WRITE
</label
></td
>
420 <td
><input type
="checkbox" name
="new_delay_key_write" id
="new_delay_key_write"
422 <?php
echo (isset($delay_key_write) && $delay_key_write == 1)
423 ?
' checked="checked"'
433 <tr
><td
><label
for="new_transactional">TRANSACTIONAL
</label
></td
>
434 <td
><input type
="checkbox" name
="new_transactional" id
="new_transactional"
436 <?php
echo (isset($transactional) && $transactional == 1)
437 ?
' checked="checked"'
442 <tr
><td
><label
for="new_page_checksum">PAGE_CHECKSUM
</label
></td
>
443 <td
><input type
="checkbox" name
="new_page_checksum" id
="new_page_checksum"
445 <?php
echo (isset($page_checksum) && $page_checksum == 1)
446 ?
' checked="checked"'
454 if (isset($auto_increment) && strlen($auto_increment) > 0
455 && ($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)) {
457 <tr
><td
><label
for="auto_increment_opt">AUTO_INCREMENT
</label
></td
>
458 <td
><input type
="text" name
="new_auto_increment" id
="auto_increment_opt"
459 value
="<?php echo $auto_increment; ?>" /></td
>
462 } // end if (MYISAM|INNODB)
464 // the outer array is for engines, the inner array contains the dropdown
465 // option values as keys then the dropdown option labels
467 $possible_row_formats = array(
470 'DYNAMIC' => 'DYNAMIC',
475 'DYNAMIC' => 'DYNAMIC',
480 'DYNAMIC' => 'DYNAMIC'
484 'DYNAMIC' => 'DYNAMIC'
487 'COMPACT' => 'COMPACT',
488 'REDUNDANT' => 'REDUNDANT')
491 $innodb_engine_plugin = PMA_StorageEngine
::getEngine('innodb');
492 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
493 if (!empty($innodb_plugin_version)) {
494 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
496 $innodb_file_format = '';
498 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
499 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
500 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
502 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
504 // for MYISAM there is also COMPRESSED but it can be set only by the
505 // myisampack utility, so don't offer here the choice because if we
506 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
507 // does not return a warning
508 // (if the table was compressed, it can be seen on the Structure page)
510 if (isset($possible_row_formats[$tbl_type])) {
511 $current_row_format = strtoupper($showtable['Row_format']);
512 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
514 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
515 unset($possible_row_formats, $current_row_format);
522 <fieldset
class="tblFooters">
523 <input type
="submit" name
="submitoptions" value
="<?php echo __('Go'); ?>" />
529 <div
class="operations_half_width">
530 <form method
="post" action
="tbl_operations.php" name
="copyTable" id
="copyTable" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>
531 onsubmit
="return emptyFormElements(this, 'new_name')">
532 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
533 <input type
="hidden" name
="reload" value
="1" />
535 <legend
><?php
echo __('Copy table to (database<b>.</b>table):'); ?
></legend
>
536 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
538 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
542 <select name
="target_db">
543 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
548  
;<strong
>.</strong
> 
;
549 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()" value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br
/>
552 'structure' => __('Structure only'),
553 'data' => __('Structure and data'),
554 'dataonly' => __('Data only'));
555 PMA_display_html_radio('what', $choices, 'data', true);
559 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
560 <label
for="checkbox_drop"><?php
echo sprintf(__('Add %s'), 'DROP TABLE'); ?
></label
><br
/>
561 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_cp" />
562 <label
for="checkbox_auto_increment_cp"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
564 // display "Add constraints" choice only if there are
566 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
568 <input type
="checkbox" name
="add_constraints" value
="1" id
="checkbox_constraints" />
569 <label
for="checkbox_constraints"><?php
echo __('Add constraints'); ?
></label
><br
/>
572 if (isset($_COOKIE['pma_switch_to_new'])
573 && $_COOKIE['pma_switch_to_new'] == 'true') {
574 $pma_switch_to_new = 'true';
577 <input type
="checkbox" name
="switch_to_new" value
="true"
578 id
="checkbox_switch"<?php
echo
579 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
580 ?
' checked="checked"'
582 <label
for="checkbox_switch"><?php
echo __('Switch to copied table'); ?
></label
>
584 <fieldset
class="tblFooters">
585 <input type
="submit" name
="submit_copy" value
="<?php echo __('Go'); ?>" />
590 <br
class="clearfloat"/>
592 <div
class="operations_half_width">
594 <legend
><?php
echo __('Table maintenance'); ?
></legend
>
596 <ul id
="tbl_maintenance" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
598 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
599 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
600 if ($is_myisam_or_aria ||
$is_innodb) {
601 $this_url_params = array_merge($url_params,
603 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']),
604 'table_maintenance' => 'Go',
607 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
608 <?php
echo __('Check table'); ?
></a
>
609 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?
>
614 $this_url_params = array_merge($url_params,
615 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
617 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
618 <?php
echo __('Defragment table'); ?
></a
>
619 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?
>
623 if ($is_myisam_or_aria ||
$is_berkeleydb) {
624 $this_url_params = array_merge($url_params,
626 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
627 'table_maintenance' => 'Go',
630 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
631 <?php
echo __('Analyze table'); ?
></a
>
632 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?
>
636 if ($is_myisam_or_aria) {
637 $this_url_params = array_merge($url_params,
639 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
640 'table_maintenance' => 'Go',
643 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
644 <?php
echo __('Repair table'); ?
></a
>
645 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?
>
649 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
650 $this_url_params = array_merge($url_params,
652 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
653 'table_maintenance' => 'Go',
656 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
657 <?php
echo __('Optimize table'); ?
></a
>
658 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?
>
662 } // end MYISAM or BERKELEYDB case
663 $this_url_params = array_merge($url_params,
665 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
666 'message_to_show' => sprintf(__('Table %s has been flushed'),
667 htmlspecialchars($GLOBALS['table'])),
671 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
672 <?php
echo __('Flush the table (FLUSH)'); ?
></a
>
673 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?
>
678 <?php
if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?
>
679 <div
class="operations_half_width">
680 <fieldset
class="caution">
681 <legend
><?php
echo __('Delete data or table'); ?
></legend
>
685 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
686 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
687 $this_url_params = array_merge($url_params,
689 'sql_query' => $this_sql_query,
690 'goto' => 'tbl_structure.php',
692 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
695 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'id="truncate_tbl_anchor" class="ajax"' : ''); ?
>>
696 <?php
echo __('Empty the table (TRUNCATE)'); ?
></a
>
697 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?
>
701 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
702 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
703 $this_url_params = array_merge($url_params,
705 'sql_query' => $this_sql_query,
706 'goto' => 'db_operations.php',
709 'message_to_show' => sprintf(($tbl_is_view ?
__('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
710 // table name is needed to avoid running
711 // PMA_relationsCleanupDatabase() on the whole db later
712 'table' => $GLOBALS['table'],
715 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'id="drop_tbl_anchor"' : ''); ?
>>
716 <?php
echo __('Delete the table (DROP)'); ?
></a
>
717 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?
>
728 <?php
if (PMA_Partition
::havePartitioning()) {
729 $partition_names = PMA_Partition
::getPartitionNames($db, $table);
730 // show the Partition maintenance section only if we detect a partition
731 if (! is_null($partition_names[0])) {
733 <div
class="operations_half_width">
734 <form method
="post" action
="tbl_operations.php">
735 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
737 <legend
><?php
echo __('Partition maintenance'); ?
></legend
>
739 $html_select = '<select name="partition_name">' . "\n";
740 foreach ($partition_names as $one_partition) {
741 $one_partition = htmlspecialchars($one_partition);
742 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
744 $html_select .= '</select>' . "\n";
745 printf(__('Partition %s'), $html_select);
746 unset($partition_names, $one_partition, $html_select);
748 'ANALYZE' => __('Analyze'),
749 'CHECK' => __('Check'),
750 'OPTIMIZE' => __('Optimize'),
751 'REBUILD' => __('Rebuild'),
752 'REPAIR' => __('Repair'));
753 PMA_display_html_radio('partition_operation', $choices, '', false);
755 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
756 // I'm not sure of the best way to display that; this link does
757 // not depend on the Go button
758 $this_url_params = array_merge($url_params,
760 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
763 <br
/><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
764 <?php
echo __('Remove partitioning'); ?
></a
>
766 <fieldset
class="tblFooters">
767 <input type
="submit" name
="submit_partition" value
="<?php echo __('Go'); ?>" />
775 // Referential integrity check
776 // The Referential integrity check was intended for the non-InnoDB
777 // tables for which the relations are defined in pmadb
778 // so I assume that if the current table is InnoDB, I don't display
779 // this choice (InnoDB maintains integrity by itself)
781 if ($cfgRelation['relwork'] && ! $is_innodb) {
782 PMA_DBI_select_db($GLOBALS['db']);
783 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
787 <!-- Referential integrity check
-->
788 <div
class="operations_half_width">
790 <legend
><?php
echo __('Check referential integrity:'); ?
></legend
>
794 foreach ($foreign AS $master => $arr) {
795 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
796 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
797 . PMA_backquote($arr['foreign_table']);
798 if ($arr['foreign_table'] == $GLOBALS['table']) {
799 $foreign_table = $GLOBALS['table'] . '1';
800 $join_query .= ' AS ' . PMA_backquote($foreign_table);
802 $foreign_table = $arr['foreign_table'];
804 $join_query .= ' ON '
805 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
806 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
808 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
810 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
812 $this_url_params = array_merge($url_params,
813 array('sql_query' => $join_query));
816 . PMA_generate_common_url($this_url_params)
817 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
818 . '</a></li>' . "\n";
819 } // foreach $foreign
820 unset($foreign_table, $join_query);
826 } // end if ($foreign)
828 } // end if (!empty($cfg['Server']['relation']))
832 * Displays the footer
834 require './libraries/footer.inc.php';
837 function PMA_set_global_variables_for_engine($tbl_type)
839 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
841 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
842 $upper_tbl_type = strtoupper($tbl_type);
844 //Options that apply to MYISAM usually apply to ARIA
845 $is_myisam_or_aria = ($upper_tbl_type == 'MYISAM' ||
$upper_tbl_type == 'ARIA' ||
$upper_tbl_type == 'MARIA');
846 $is_aria = ($upper_tbl_type == 'ARIA');
848 $is_isam = ($upper_tbl_type == 'ISAM');
849 $is_innodb = ($upper_tbl_type == 'INNODB');
850 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
851 $is_pbxt = ($upper_tbl_type == 'PBXT');