add locale to .gitignore for this branch too
[phpmyadmin/madhuracj.git] / tbl_operations.php
blobd0453070c93627edda00b5df291a750fd814c70c
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_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $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_maria) {
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);
100 if (! empty($_REQUEST['tbl_collation'])
101 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
102 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
105 if (($is_myisam_or_maria || $is_isam)
106 && isset($_REQUEST['new_pack_keys'])
107 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
108 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
111 $checksum = empty($checksum) ? '0' : '1';
112 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
113 if ($is_myisam_or_maria
114 && $_REQUEST['new_checksum'] !== $checksum) {
115 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
118 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
119 if ($is_maria
120 && $_REQUEST['new_transactional'] !== $transactional) {
121 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
124 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
125 if ($is_maria
126 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
127 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
130 $delay_key_write = empty($delay_key_write) ? '0' : '1';
131 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
132 if ($is_myisam_or_maria
133 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
134 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
137 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
138 && ! empty($_REQUEST['new_auto_increment'])
139 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
140 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
143 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
144 && ! empty($_REQUEST['new_row_format'])
145 && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
146 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
149 if (count($table_alters) > 0) {
150 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
151 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
152 $result .= PMA_DBI_query($sql_query) ? true : false;
153 $reread_info = true;
154 unset($table_alters);
155 foreach (PMA_DBI_get_warnings() as $warning) {
156 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
157 . ' ' . $warning['Message'];
162 * Reordering the table has been requested by the user
164 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
165 $sql_query = '
166 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
167 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
168 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
169 $sql_query .= ' DESC';
171 $result = PMA_DBI_query($sql_query);
172 } // end if
175 * A partition operation has been requested by the user
177 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
178 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
179 $result = PMA_DBI_query($sql_query);
180 } // end if
182 if ($reread_info) {
183 // to avoid showing the old value (for example the AUTO_INCREMENT) after
184 // a change, clear the cache
185 PMA_Table::$cache = array();
186 $page_checksum = $checksum = $delay_key_write = 0;
187 require './libraries/tbl_info.inc.php';
189 unset($reread_info);
192 * Displays top menu links
194 require_once './libraries/tbl_links.inc.php';
196 if (isset($result)) {
197 // set to success by default, because result set could be empty
198 // (for example, a table rename)
199 $_type = 'success';
200 if (empty($_message)) {
201 $_message = $result ? $strSuccess : $strError;
202 // $result should exist, regardless of $_message
203 $_type = $result ? 'success' : 'error';
205 if (! empty($warning_messages)) {
206 $_message = new PMA_Message;
207 $_message->addMessages($warning_messages);
208 $_message->isWarning(true);
209 unset($warning_messages);
211 PMA_showMessage($_message, $sql_query, $_type);
212 unset($_message, $_type);
215 $url_params['goto'] = 'tbl_operations.php';
216 $url_params['back'] = 'tbl_operations.php';
219 * Get columns names
221 $local_query = '
222 SHOW COLUMNS
223 FROM ' . PMA_backquote($GLOBALS['table']) . '
224 FROM ' . PMA_backquote($GLOBALS['db']);
225 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
226 unset($local_query);
229 * Displays the page
232 <!-- Order the table -->
233 <div id="div_table_order">
234 <form method="post" action="tbl_operations.php">
235 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
236 <fieldset id="fieldset_table_order">
237 <legend><?php echo $strAlterOrderBy; ?></legend>
238 <select name="order_field">
239 <?php
240 foreach ($columns as $fieldname) {
241 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
242 . htmlspecialchars($fieldname) . '</option>' . "\n";
244 unset($columns);
246 </select> <?php echo $strSingly; ?>
247 <select name="order_order">
248 <option value="asc"><?php echo $strAscending; ?></option>
249 <option value="desc"><?php echo $strDescending; ?></option>
250 </select>
251 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" />
252 </fieldset>
253 </form>
254 </div>
256 <!-- Move table -->
257 <div id="div_table_rename">
258 <form method="post" action="tbl_move_copy.php"
259 onsubmit="return emptyFormElements(this, 'new_name')">
260 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
261 <input type="hidden" name="reload" value="1" />
262 <input type="hidden" name="what" value="data" />
263 <fieldset id="fieldset_table_rename">
264 <legend><?php echo $strMoveTable; ?></legend>
265 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
267 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
268 <?php
269 } else {
271 <select name="target_db">
272 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
273 </select>
274 <?php
275 } // end if
277 &nbsp;<strong>.</strong>&nbsp;
278 <input type="text" size="20" name="new_name" onfocus="this.select()"
279 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
280 <?php
281 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
282 // next value but users can decide if they want it or not for the operation
284 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
285 <label for="checkbox_auto_increment_mv"><?php echo $strAddAutoIncrement; ?></label><br />
286 </fieldset>
287 <fieldset class="tblFooters">
288 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
289 </fieldset>
290 </form>
291 </div>
293 <?php
294 if (strstr($show_comment, '; InnoDB free') === false) {
295 if (strstr($show_comment, 'InnoDB free') === false) {
296 // only user entered comment
297 $comment = $show_comment;
298 } else {
299 // here we have just InnoDB generated part
300 $comment = '';
302 } else {
303 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
304 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
307 // PACK_KEYS: MyISAM or ISAM
308 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
309 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
311 // nijel: Here should be version check for InnoDB, however it is supported
312 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
313 // check for version
316 <!-- Table options -->
317 <div id="div_table_options">
318 <form method="post" action="tbl_operations.php">
319 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
320 <input type="hidden" name="reload" value="1" />
321 <fieldset>
322 <legend><?php echo $strTableOptions; ?></legend>
324 <table>
325 <!-- Change table name -->
326 <tr><td><?php echo $strRenameTable; ?></td>
327 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
328 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
329 </td>
330 </tr>
332 <!-- Table comments -->
333 <tr><td><?php echo $strTableComments; ?></td>
334 <td><input type="text" name="comment" maxlength="60" size="30"
335 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
336 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
337 </td>
338 </tr>
340 <!-- Storage engine -->
341 <tr><td><?php echo $strStorageEngine; ?>
342 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
343 </td>
344 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
345 </td>
346 </tr>
348 <!-- Table character set -->
349 <tr><td><?php echo $strCollation; ?></td>
350 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
351 'tbl_collation', null, $tbl_collation, false, 3); ?>
352 </td>
353 </tr>
354 <?php
355 if ($is_myisam_or_maria || $is_isam) {
357 <tr>
358 <td><label for="new_pack_keys">PACK_KEYS</label></td>
359 <td><select name="new_pack_keys" id="new_pack_keys">
360 <option value="DEFAULT"
361 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
362 >DEFAULT</option>
363 <option value="0"
364 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
365 >0</option>
366 <option value="1"
367 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
368 >1</option>
369 </select>
370 </td>
371 </tr>
372 <?php
373 } // end if (MYISAM|ISAM)
375 if ($is_myisam_or_maria) {
377 <tr><td><label for="new_checksum">CHECKSUM</label></td>
378 <td><input type="checkbox" name="new_checksum" id="new_checksum"
379 value="1"
380 <?php echo (isset($checksum) && $checksum == 1)
381 ? ' checked="checked"'
382 : ''; ?> />
383 </td>
384 </tr>
386 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
387 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
388 value="1"
389 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
390 ? ' checked="checked"'
391 : ''; ?> />
392 </td>
393 </tr>
395 <?php
396 } // end if (MYISAM)
398 if ($is_maria) {
400 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
401 <td><input type="checkbox" name="new_transactional" id="new_transactional"
402 value="1"
403 <?php echo (isset($transactional) && $transactional == 1)
404 ? ' checked="checked"'
405 : ''; ?> />
406 </td>
407 </tr>
409 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
410 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
411 value="1"
412 <?php echo (isset($page_checksum) && $page_checksum == 1)
413 ? ' checked="checked"'
414 : ''; ?> />
415 </td>
416 </tr>
418 <?php
419 } // end if (MARIA)
421 if (isset($auto_increment) && strlen($auto_increment) > 0
422 && ($is_myisam_or_maria || $is_innodb || $is_pbxt)) {
424 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
425 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
426 value="<?php echo $auto_increment; ?>" /></td>
427 </tr>
428 <?php
429 } // end if (MYISAM|INNODB)
431 // the outer array is for engines, the inner array contains the dropdown
432 // option values as keys then the dropdown option labels
434 $possible_row_formats = array(
435 'MARIA' => array(
436 'FIXED' => 'FIXED',
437 'DYNAMIC' => 'DYNAMIC',
438 'PAGE' => 'PAGE'
440 'MYISAM' => array(
441 'FIXED' => 'FIXED',
442 'DYNAMIC' => 'DYNAMIC'
444 'PBXT' => array(
445 'FIXED' => 'FIXED',
446 'DYNAMIC' => 'DYNAMIC'
448 'INNODB' => array(
449 'COMPACT' => 'COMPACT',
450 'REDUNDANT' => 'REDUNDANT')
453 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
454 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
455 if (!empty($innodb_plugin_version)) {
456 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
457 } else {
458 $innodb_file_format = '';
460 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
461 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
462 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
464 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
466 // for MYISAM there is also COMPRESSED but it can be set only by the
467 // myisampack utility, so don't offer here the choice because if we
468 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
469 // does not return a warning
470 // (if the table was compressed, it can be seen on the Structure page)
472 if (isset($possible_row_formats[$tbl_type])) {
473 $current_row_format = strtoupper($showtable['Row_format']);
474 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
475 echo '<td>';
476 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
477 unset($possible_row_formats, $current_row_format);
478 echo '</td>';
479 echo '</tr>';
482 </table>
483 </fieldset>
484 <fieldset class="tblFooters">
485 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
486 </fieldset>
487 </form>
488 </div>
490 <!-- Copy table -->
491 <div id="div_table_copy">
492 <form method="post" action="tbl_move_copy.php"
493 onsubmit="return emptyFormElements(this, 'new_name')">
494 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
495 <input type="hidden" name="reload" value="1" />
496 <fieldset>
497 <legend><?php echo $strCopyTable; ?></legend>
498 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
500 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
501 <?php
502 } else {
504 <select name="target_db">
505 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
506 </select>
507 <?php
508 } // end if
510 &nbsp;<strong>.</strong>&nbsp;
511 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
512 <?php
513 $choices = array(
514 'structure' => $strStrucOnly,
515 'data' => $strStrucData,
516 'dataonly' => $strDataOnly);
517 PMA_display_html_radio('what', $choices, 'data', true);
518 unset($choices);
521 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
522 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
523 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
524 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
525 <?php
526 // display "Add constraints" choice only if there are
527 // foreign keys
528 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
530 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
531 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
532 <?php
533 } // endif
534 if (isset($_COOKIE['pma_switch_to_new'])
535 && $_COOKIE['pma_switch_to_new'] == 'true') {
536 $pma_switch_to_new = 'true';
539 <input type="checkbox" name="switch_to_new" value="true"
540 id="checkbox_switch"<?php echo
541 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
542 ? ' checked="checked"'
543 : ''; ?> />
544 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
545 </fieldset>
546 <fieldset class="tblFooters">
547 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
548 </fieldset>
549 </form>
550 </div>
552 <br class="clearfloat"/>
554 <div id="div_table_maintenance">
555 <fieldset>
556 <legend><?php echo $strTableMaintenance; ?></legend>
558 <ul>
559 <?php
560 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
561 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
562 if ($is_myisam_or_maria || $is_innodb) {
563 $this_url_params = array_merge($url_params,
564 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
566 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
567 <?php echo $strCheckTable; ?></a>
568 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
569 </li>
570 <?php
572 if ($is_innodb) {
573 $this_url_params = array_merge($url_params,
574 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
576 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
577 <?php echo $strDefragment; ?></a>
578 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
579 </li>
580 <?php
582 if ($is_myisam_or_maria || $is_berkeleydb) {
583 $this_url_params = array_merge($url_params,
584 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
586 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
587 <?php echo $strAnalyzeTable; ?></a>
588 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
589 </li>
590 <?php
592 if ($is_myisam_or_maria) {
593 $this_url_params = array_merge($url_params,
594 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
596 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
597 <?php echo $strRepairTable; ?></a>
598 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
599 </li>
600 <?php
602 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
603 $this_url_params = array_merge($url_params,
604 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
606 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
607 <?php echo $strOptimizeTable; ?></a>
608 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
609 </li>
610 <?php
612 } // end MYISAM or BERKELEYDB case
613 $this_url_params = array_merge($url_params,
614 array(
615 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
616 'zero_rows' => sprintf($strTableHasBeenFlushed,
617 htmlspecialchars($GLOBALS['table'])),
618 'reload' => 1,
621 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
622 <?php echo $strFlushTable; ?></a>
623 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
624 </li>
625 </ul>
626 </fieldset>
627 </div>
628 <?php if (PMA_Partition::havePartitioning()) {
629 $partition_names = PMA_Partition::getPartitionNames($db, $table);
630 // show the Partition maintenance section only if we detect a partition
631 if (! is_null($partition_names[0])) {
633 <div id="div_partition_maintenance">
634 <form method="post" action="tbl_operations.php">
635 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
636 <fieldset>
637 <legend><?php echo $strPartitionMaintenance; ?></legend>
638 <?php
639 $html_select = '<select name="partition_name">' . "\n";
640 foreach($partition_names as $one_partition) {
641 $one_partition = htmlspecialchars($one_partition);
642 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
644 $html_select .= '</select>' . "\n";
645 printf($GLOBALS['strPartition'], $html_select);
646 unset($partition_names, $one_partition, $html_select);
647 $choices = array(
648 'ANALYZE' => $strAnalyze,
649 'CHECK' => $strCheck,
650 'OPTIMIZE' => $strOptimize,
651 'REBUILD' => $strRebuild,
652 'REPAIR' => $strRepair);
653 PMA_display_html_radio('partition_operation', $choices, '', false);
654 unset($choices);
655 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
656 // I'm not sure of the best way to display that; this link does
657 // not depend on the Go button
658 $this_url_params = array_merge($url_params,
659 array(
660 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
663 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
664 <?php echo $strRemovePartitioning; ?></a>
665 </fieldset>
666 <fieldset class="tblFooters">
667 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
668 </fieldset>
669 </form>
670 </div>
671 <?php
672 } // end if
673 } // end if
675 // Referential integrity check
676 // The Referential integrity check was intended for the non-InnoDB
677 // tables for which the relations are defined in pmadb
678 // so I assume that if the current table is InnoDB, I don't display
679 // this choice (InnoDB maintains integrity by itself)
681 if ($cfgRelation['relwork'] && ! $is_innodb) {
682 PMA_DBI_select_db($GLOBALS['db']);
683 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
685 if ($foreign) {
687 <!-- Referential integrity check -->
688 <div id="div_referential_integrity">
689 <fieldset>
690 <legend><?php echo $strReferentialIntegrity; ?></legend>
691 <ul>
692 <?php
693 echo "\n";
694 foreach ($foreign AS $master => $arr) {
695 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
696 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
697 . PMA_backquote($arr['foreign_table']);
698 if ($arr['foreign_table'] == $GLOBALS['table']) {
699 $foreign_table = $GLOBALS['table'] . '1';
700 $join_query .= ' AS ' . PMA_backquote($foreign_table);
701 } else {
702 $foreign_table = $arr['foreign_table'];
704 $join_query .= ' ON '
705 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
706 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
707 . ' WHERE '
708 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
709 . ' IS NULL AND '
710 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
711 . ' IS NOT NULL';
712 $this_url_params = array_merge($url_params,
713 array('sql_query' => $join_query));
714 echo ' <li>'
715 . '<a href="sql.php'
716 . PMA_generate_common_url($this_url_params)
717 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
718 . '</a></li>' . "\n";
719 } // foreach $foreign
720 unset($foreign_table, $join_query);
722 </ul>
723 </fieldset>
724 </div>
725 <?php
726 } // end if ($foreign)
728 } // end if (!empty($cfg['Server']['relation']))
732 * Displays the footer
734 require_once './libraries/footer.inc.php';
737 function PMA_set_global_variables_for_engine($tbl_type)
739 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
741 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
742 $upper_tbl_type = strtoupper($tbl_type);
744 //Options that apply to MYISAM usually apply to MARIA
745 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
746 $is_maria = ($upper_tbl_type == 'MARIA');
748 $is_isam = ($upper_tbl_type == 'ISAM');
749 $is_innodb = ($upper_tbl_type == 'INNODB');
750 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
751 $is_pbxt = ($upper_tbl_type == 'PBXT');