3.3.9
[phpmyadmin/mlewandow.git] / tbl_operations.php
blob10d7cd3c19ad63826ef60cd778aefe01fe50487d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
13 require_once './libraries/Table.class.php';
15 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
17 /**
18 * Runs common work
20 require './libraries/tbl_common.php';
21 $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
22 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
24 /**
25 * Gets relation settings
27 require_once './libraries/relation.lib.php';
28 $cfgRelation = PMA_getRelationsParam();
30 /**
31 * Gets available MySQL charsets and storage engines
33 require_once './libraries/mysql_charsets.lib.php';
34 require_once './libraries/StorageEngine.class.php';
36 /**
37 * Class for partition management
39 require_once './libraries/Partition.class.php';
41 // reselect current db (needed in some cases probably due to
42 // the calling of relation.lib.php)
43 PMA_DBI_select_db($GLOBALS['db']);
45 /**
46 * Gets tables informations
49 require './libraries/tbl_info.inc.php';
51 // define some globals here, for improved syntax in the conditionals
52 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
53 // set initial value of these globals, based on the current table engine
54 PMA_set_global_variables_for_engine($tbl_type);
56 if ($is_aria) {
57 // the value for transactional can be implicit
58 // (no create option found, in this case it means 1)
59 // or explicit (option found with a value of 0 or 1)
60 // ($transactional may have been set by libraries/tbl_info.inc.php,
61 // from the $create_options)
62 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
63 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
66 $reread_info = false;
67 $table_alters = array();
69 /**
70 * Updates table comment, type and options if required
72 if (isset($_REQUEST['submitoptions'])) {
73 $_message = '';
74 $warning_messages = array();
76 if (isset($_REQUEST['new_name'])) {
77 if ($pma_table->rename($_REQUEST['new_name'])) {
78 $_message .= $pma_table->getLastMessage();
79 $result = true;
80 $GLOBALS['table'] = $pma_table->getName();
81 $reread_info = true;
82 $reload = true;
83 } else {
84 $_message .= $pma_table->getLastError();
85 $result = false;
88 if (isset($_REQUEST['comment'])
89 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
90 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
92 if (! empty($_REQUEST['new_tbl_type'])
93 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
94 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
95 $tbl_type = $_REQUEST['new_tbl_type'];
96 // reset the globals for the new engine
97 PMA_set_global_variables_for_engine($tbl_type);
98 if ($is_aria) {
99 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
100 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
104 if (! empty($_REQUEST['tbl_collation'])
105 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
106 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
109 if (($is_myisam_or_aria || $is_isam)
110 && isset($_REQUEST['new_pack_keys'])
111 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
112 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
115 $checksum = empty($checksum) ? '0' : '1';
116 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
117 if ($is_myisam_or_aria
118 && $_REQUEST['new_checksum'] !== $checksum) {
119 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
122 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
123 if ($is_aria
124 && $_REQUEST['new_transactional'] !== $transactional) {
125 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
128 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
129 if ($is_aria
130 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
131 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
134 $delay_key_write = empty($delay_key_write) ? '0' : '1';
135 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
136 if ($is_myisam_or_aria
137 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
138 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
141 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
142 && ! empty($_REQUEST['new_auto_increment'])
143 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
144 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
147 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
148 && ! empty($_REQUEST['new_row_format'])
149 && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
150 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
153 if (count($table_alters) > 0) {
154 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
155 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
156 $result .= PMA_DBI_query($sql_query) ? true : false;
157 $reread_info = true;
158 unset($table_alters);
159 foreach (PMA_DBI_get_warnings() as $warning) {
160 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
161 // and if TRANSACTIONAL was set, the system reports an error;
162 // I discussed with a Maria developer and he agrees that this
163 // should not be reported with a Level of Error, so here
164 // I just ignore it. But there are other 1478 messages
165 // that it's better to show.
166 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
167 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
168 . ' ' . $warning['Message'];
174 * Reordering the table has been requested by the user
176 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
177 $sql_query = '
178 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
179 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
180 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
181 $sql_query .= ' DESC';
183 $result = PMA_DBI_query($sql_query);
184 } // end if
187 * A partition operation has been requested by the user
189 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
190 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
191 $result = PMA_DBI_query($sql_query);
192 } // end if
194 if ($reread_info) {
195 // to avoid showing the old value (for example the AUTO_INCREMENT) after
196 // a change, clear the cache
197 PMA_Table::$cache = array();
198 $page_checksum = $checksum = $delay_key_write = 0;
199 require './libraries/tbl_info.inc.php';
201 unset($reread_info);
204 * Displays top menu links
206 require_once './libraries/tbl_links.inc.php';
208 if (isset($result) && empty($zero_rows)) {
209 // set to success by default, because result set could be empty
210 // (for example, a table rename)
211 $_type = 'success';
212 if (empty($_message)) {
213 $_message = $result ? $strSuccess : $strError;
214 // $result should exist, regardless of $_message
215 $_type = $result ? 'success' : 'error';
217 if (! empty($warning_messages)) {
218 $_message = new PMA_Message;
219 $_message->addMessages($warning_messages);
220 $_message->isWarning(true);
221 unset($warning_messages);
223 PMA_showMessage($_message, $sql_query, $_type);
224 unset($_message, $_type);
227 $url_params['goto'] = 'tbl_operations.php';
228 $url_params['back'] = 'tbl_operations.php';
231 * Get columns names
233 $local_query = '
234 SHOW COLUMNS
235 FROM ' . PMA_backquote($GLOBALS['table']) . '
236 FROM ' . PMA_backquote($GLOBALS['db']);
237 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
238 unset($local_query);
241 * Displays the page
244 <!-- Order the table -->
245 <div id="div_table_order">
246 <form method="post" action="tbl_operations.php">
247 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
248 <fieldset id="fieldset_table_order">
249 <legend><?php echo $strAlterOrderBy; ?></legend>
250 <select name="order_field">
251 <?php
252 foreach ($columns as $fieldname) {
253 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
254 . htmlspecialchars($fieldname) . '</option>' . "\n";
256 unset($columns);
258 </select> <?php echo $strSingly; ?>
259 <select name="order_order">
260 <option value="asc"><?php echo $strAscending; ?></option>
261 <option value="desc"><?php echo $strDescending; ?></option>
262 </select>
263 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" />
264 </fieldset>
265 </form>
266 </div>
268 <!-- Move table -->
269 <div id="div_table_rename">
270 <form method="post" action="tbl_move_copy.php"
271 onsubmit="return emptyFormElements(this, 'new_name')">
272 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
273 <input type="hidden" name="reload" value="1" />
274 <input type="hidden" name="what" value="data" />
275 <fieldset id="fieldset_table_rename">
276 <legend><?php echo $strMoveTable; ?></legend>
277 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
279 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
280 <?php
281 } else {
283 <select name="target_db">
284 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
285 </select>
286 <?php
287 } // end if
289 &nbsp;<strong>.</strong>&nbsp;
290 <input type="text" size="20" name="new_name" onfocus="this.select()"
291 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
292 <?php
293 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
294 // next value but users can decide if they want it or not for the operation
296 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
297 <label for="checkbox_auto_increment_mv"><?php echo $strAddAutoIncrement; ?></label><br />
298 </fieldset>
299 <fieldset class="tblFooters">
300 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
301 </fieldset>
302 </form>
303 </div>
305 <?php
306 if (strstr($show_comment, '; InnoDB free') === false) {
307 if (strstr($show_comment, 'InnoDB free') === false) {
308 // only user entered comment
309 $comment = $show_comment;
310 } else {
311 // here we have just InnoDB generated part
312 $comment = '';
314 } else {
315 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
316 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
319 // PACK_KEYS: MyISAM or ISAM
320 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
321 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
323 // nijel: Here should be version check for InnoDB, however it is supported
324 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
325 // check for version
328 <!-- Table options -->
329 <div id="div_table_options">
330 <form method="post" action="tbl_operations.php">
331 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
332 <input type="hidden" name="reload" value="1" />
333 <fieldset>
334 <legend><?php echo $strTableOptions; ?></legend>
336 <table>
337 <!-- Change table name -->
338 <tr><td><?php echo $strRenameTable; ?></td>
339 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
340 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
341 </td>
342 </tr>
344 <!-- Table comments -->
345 <tr><td><?php echo $strTableComments; ?></td>
346 <td><input type="text" name="comment" maxlength="60" size="30"
347 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
348 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
349 </td>
350 </tr>
352 <!-- Storage engine -->
353 <tr><td><?php echo $strStorageEngine; ?>
354 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
355 </td>
356 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
357 </td>
358 </tr>
360 <!-- Table character set -->
361 <tr><td><?php echo $strCollation; ?></td>
362 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
363 'tbl_collation', null, $tbl_collation, false, 3); ?>
364 </td>
365 </tr>
366 <?php
367 if ($is_myisam_or_aria || $is_isam) {
369 <tr>
370 <td><label for="new_pack_keys">PACK_KEYS</label></td>
371 <td><select name="new_pack_keys" id="new_pack_keys">
372 <option value="DEFAULT"
373 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
374 >DEFAULT</option>
375 <option value="0"
376 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
377 >0</option>
378 <option value="1"
379 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
380 >1</option>
381 </select>
382 </td>
383 </tr>
384 <?php
385 } // end if (MYISAM|ISAM)
387 if ($is_myisam_or_aria) {
389 <tr><td><label for="new_checksum">CHECKSUM</label></td>
390 <td><input type="checkbox" name="new_checksum" id="new_checksum"
391 value="1"
392 <?php echo (isset($checksum) && $checksum == 1)
393 ? ' checked="checked"'
394 : ''; ?> />
395 </td>
396 </tr>
398 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
399 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
400 value="1"
401 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
402 ? ' checked="checked"'
403 : ''; ?> />
404 </td>
405 </tr>
407 <?php
408 } // end if (MYISAM)
410 if ($is_aria) {
412 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
413 <td><input type="checkbox" name="new_transactional" id="new_transactional"
414 value="1"
415 <?php echo (isset($transactional) && $transactional == 1)
416 ? ' checked="checked"'
417 : ''; ?> />
418 </td>
419 </tr>
421 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
422 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
423 value="1"
424 <?php echo (isset($page_checksum) && $page_checksum == 1)
425 ? ' checked="checked"'
426 : ''; ?> />
427 </td>
428 </tr>
430 <?php
431 } // end if (ARIA)
433 if (isset($auto_increment) && strlen($auto_increment) > 0
434 && ($is_myisam_or_aria || $is_innodb || $is_pbxt)) {
436 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
437 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
438 value="<?php echo $auto_increment; ?>" /></td>
439 </tr>
440 <?php
441 } // end if (MYISAM|INNODB)
443 // the outer array is for engines, the inner array contains the dropdown
444 // option values as keys then the dropdown option labels
446 $possible_row_formats = array(
447 'ARIA' => array(
448 'FIXED' => 'FIXED',
449 'DYNAMIC' => 'DYNAMIC',
450 'PAGE' => 'PAGE'
452 'MARIA' => array(
453 'FIXED' => 'FIXED',
454 'DYNAMIC' => 'DYNAMIC',
455 'PAGE' => 'PAGE'
457 'MYISAM' => array(
458 'FIXED' => 'FIXED',
459 'DYNAMIC' => 'DYNAMIC'
461 'PBXT' => array(
462 'FIXED' => 'FIXED',
463 'DYNAMIC' => 'DYNAMIC'
465 'INNODB' => array(
466 'COMPACT' => 'COMPACT',
467 'REDUNDANT' => 'REDUNDANT')
470 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
471 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
472 if (!empty($innodb_plugin_version)) {
473 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
474 } else {
475 $innodb_file_format = '';
477 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
478 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
479 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
481 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
483 // for MYISAM there is also COMPRESSED but it can be set only by the
484 // myisampack utility, so don't offer here the choice because if we
485 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
486 // does not return a warning
487 // (if the table was compressed, it can be seen on the Structure page)
489 if (isset($possible_row_formats[$tbl_type])) {
490 $current_row_format = strtoupper($showtable['Row_format']);
491 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
492 echo '<td>';
493 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
494 unset($possible_row_formats, $current_row_format);
495 echo '</td>';
496 echo '</tr>';
499 </table>
500 </fieldset>
501 <fieldset class="tblFooters">
502 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
503 </fieldset>
504 </form>
505 </div>
507 <!-- Copy table -->
508 <div id="div_table_copy">
509 <form method="post" action="tbl_move_copy.php"
510 onsubmit="return emptyFormElements(this, 'new_name')">
511 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
512 <input type="hidden" name="reload" value="1" />
513 <fieldset>
514 <legend><?php echo $strCopyTable; ?></legend>
515 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
517 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
518 <?php
519 } else {
521 <select name="target_db">
522 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
523 </select>
524 <?php
525 } // end if
527 &nbsp;<strong>.</strong>&nbsp;
528 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
529 <?php
530 $choices = array(
531 'structure' => $strStrucOnly,
532 'data' => $strStrucData,
533 'dataonly' => $strDataOnly);
534 PMA_display_html_radio('what', $choices, 'data', true);
535 unset($choices);
538 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
539 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
540 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
541 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
542 <?php
543 // display "Add constraints" choice only if there are
544 // foreign keys
545 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
547 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
548 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
549 <?php
550 } // endif
551 if (isset($_COOKIE['pma_switch_to_new'])
552 && $_COOKIE['pma_switch_to_new'] == 'true') {
553 $pma_switch_to_new = 'true';
556 <input type="checkbox" name="switch_to_new" value="true"
557 id="checkbox_switch"<?php echo
558 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
559 ? ' checked="checked"'
560 : ''; ?> />
561 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
562 </fieldset>
563 <fieldset class="tblFooters">
564 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
565 </fieldset>
566 </form>
567 </div>
569 <br class="clearfloat"/>
571 <div id="div_table_maintenance">
572 <fieldset>
573 <legend><?php echo $strTableMaintenance; ?></legend>
575 <ul>
576 <?php
577 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
578 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
579 if ($is_myisam_or_aria || $is_innodb) {
580 $this_url_params = array_merge($url_params,
581 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
583 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
584 <?php echo $strCheckTable; ?></a>
585 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
586 </li>
587 <?php
589 if ($is_innodb) {
590 $this_url_params = array_merge($url_params,
591 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
593 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
594 <?php echo $strDefragment; ?></a>
595 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
596 </li>
597 <?php
599 if ($is_myisam_or_aria || $is_berkeleydb) {
600 $this_url_params = array_merge($url_params,
601 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
603 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
604 <?php echo $strAnalyzeTable; ?></a>
605 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
606 </li>
607 <?php
609 if ($is_myisam_or_aria) {
610 $this_url_params = array_merge($url_params,
611 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
613 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
614 <?php echo $strRepairTable; ?></a>
615 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
616 </li>
617 <?php
619 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
620 $this_url_params = array_merge($url_params,
621 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
623 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
624 <?php echo $strOptimizeTable; ?></a>
625 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
626 </li>
627 <?php
629 } // end MYISAM or BERKELEYDB case
630 $this_url_params = array_merge($url_params,
631 array(
632 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
633 'zero_rows' => sprintf($strTableHasBeenFlushed,
634 htmlspecialchars($GLOBALS['table'])),
635 'reload' => 1,
638 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
639 <?php echo $strFlushTable; ?></a>
640 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
641 </li>
642 </ul>
643 </fieldset>
644 </div>
645 <?php if (PMA_Partition::havePartitioning()) {
646 $partition_names = PMA_Partition::getPartitionNames($db, $table);
647 // show the Partition maintenance section only if we detect a partition
648 if (! is_null($partition_names[0])) {
650 <div id="div_partition_maintenance">
651 <form method="post" action="tbl_operations.php">
652 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
653 <fieldset>
654 <legend><?php echo $strPartitionMaintenance; ?></legend>
655 <?php
656 $html_select = '<select name="partition_name">' . "\n";
657 foreach($partition_names as $one_partition) {
658 $one_partition = htmlspecialchars($one_partition);
659 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
661 $html_select .= '</select>' . "\n";
662 printf($GLOBALS['strPartition'], $html_select);
663 unset($partition_names, $one_partition, $html_select);
664 $choices = array(
665 'ANALYZE' => $strAnalyze,
666 'CHECK' => $strCheck,
667 'OPTIMIZE' => $strOptimize,
668 'REBUILD' => $strRebuild,
669 'REPAIR' => $strRepair);
670 PMA_display_html_radio('partition_operation', $choices, '', false);
671 unset($choices);
672 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
673 // I'm not sure of the best way to display that; this link does
674 // not depend on the Go button
675 $this_url_params = array_merge($url_params,
676 array(
677 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
680 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
681 <?php echo $strRemovePartitioning; ?></a>
682 </fieldset>
683 <fieldset class="tblFooters">
684 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
685 </fieldset>
686 </form>
687 </div>
688 <?php
689 } // end if
690 } // end if
692 // Referential integrity check
693 // The Referential integrity check was intended for the non-InnoDB
694 // tables for which the relations are defined in pmadb
695 // so I assume that if the current table is InnoDB, I don't display
696 // this choice (InnoDB maintains integrity by itself)
698 if ($cfgRelation['relwork'] && ! $is_innodb) {
699 PMA_DBI_select_db($GLOBALS['db']);
700 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
702 if ($foreign) {
704 <!-- Referential integrity check -->
705 <div id="div_referential_integrity">
706 <fieldset>
707 <legend><?php echo $strReferentialIntegrity; ?></legend>
708 <ul>
709 <?php
710 echo "\n";
711 foreach ($foreign AS $master => $arr) {
712 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
713 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
714 . PMA_backquote($arr['foreign_table']);
715 if ($arr['foreign_table'] == $GLOBALS['table']) {
716 $foreign_table = $GLOBALS['table'] . '1';
717 $join_query .= ' AS ' . PMA_backquote($foreign_table);
718 } else {
719 $foreign_table = $arr['foreign_table'];
721 $join_query .= ' ON '
722 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
723 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
724 . ' WHERE '
725 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
726 . ' IS NULL AND '
727 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
728 . ' IS NOT NULL';
729 $this_url_params = array_merge($url_params,
730 array('sql_query' => $join_query));
731 echo ' <li>'
732 . '<a href="sql.php'
733 . PMA_generate_common_url($this_url_params)
734 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
735 . '</a></li>' . "\n";
736 } // foreach $foreign
737 unset($foreign_table, $join_query);
739 </ul>
740 </fieldset>
741 </div>
742 <?php
743 } // end if ($foreign)
745 } // end if (!empty($cfg['Server']['relation']))
749 * Displays the footer
751 require_once './libraries/footer.inc.php';
754 function PMA_set_global_variables_for_engine($tbl_type)
756 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
758 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
759 $upper_tbl_type = strtoupper($tbl_type);
761 //Options that apply to MYISAM usually apply to ARIA
762 $is_myisam_or_aria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'ARIA' || $upper_tbl_type == 'MARIA');
763 $is_aria = ($upper_tbl_type == 'ARIA');
765 $is_isam = ($upper_tbl_type == 'ISAM');
766 $is_innodb = ($upper_tbl_type == 'INNODB');
767 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
768 $is_pbxt = ($upper_tbl_type == 'PBXT');