problem showing UNHEX function by default when editing a BLOB was not fixed correctly...
[phpmyadmin/sankalp_k.git] / tbl_operations.php
blob98e5f1bec63b118ca394153225ceacd6e59be6ff
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);
98 if ($is_maria) {
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_maria || $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_maria
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_maria
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_maria
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_maria
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_maria || $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_maria || $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_maria || $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_maria) {
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_maria) {
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 (MARIA)
433 if (isset($auto_increment) && strlen($auto_increment) > 0
434 && ($is_myisam_or_maria || $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 'MARIA' => array(
448 'FIXED' => 'FIXED',
449 'DYNAMIC' => 'DYNAMIC',
450 'PAGE' => 'PAGE'
452 'MYISAM' => array(
453 'FIXED' => 'FIXED',
454 'DYNAMIC' => 'DYNAMIC'
456 'PBXT' => array(
457 'FIXED' => 'FIXED',
458 'DYNAMIC' => 'DYNAMIC'
460 'INNODB' => array(
461 'COMPACT' => 'COMPACT',
462 'REDUNDANT' => 'REDUNDANT')
465 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
466 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
467 if (!empty($innodb_plugin_version)) {
468 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
469 } else {
470 $innodb_file_format = '';
472 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
473 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
474 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
476 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
478 // for MYISAM there is also COMPRESSED but it can be set only by the
479 // myisampack utility, so don't offer here the choice because if we
480 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
481 // does not return a warning
482 // (if the table was compressed, it can be seen on the Structure page)
484 if (isset($possible_row_formats[$tbl_type])) {
485 $current_row_format = strtoupper($showtable['Row_format']);
486 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
487 echo '<td>';
488 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
489 unset($possible_row_formats, $current_row_format);
490 echo '</td>';
491 echo '</tr>';
494 </table>
495 </fieldset>
496 <fieldset class="tblFooters">
497 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
498 </fieldset>
499 </form>
500 </div>
502 <!-- Copy table -->
503 <div id="div_table_copy">
504 <form method="post" action="tbl_move_copy.php"
505 onsubmit="return emptyFormElements(this, 'new_name')">
506 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
507 <input type="hidden" name="reload" value="1" />
508 <fieldset>
509 <legend><?php echo $strCopyTable; ?></legend>
510 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
512 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
513 <?php
514 } else {
516 <select name="target_db">
517 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
518 </select>
519 <?php
520 } // end if
522 &nbsp;<strong>.</strong>&nbsp;
523 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
524 <?php
525 $choices = array(
526 'structure' => $strStrucOnly,
527 'data' => $strStrucData,
528 'dataonly' => $strDataOnly);
529 PMA_display_html_radio('what', $choices, 'data', true);
530 unset($choices);
533 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
534 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
535 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
536 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
537 <?php
538 // display "Add constraints" choice only if there are
539 // foreign keys
540 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
542 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
543 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
544 <?php
545 } // endif
546 if (isset($_COOKIE['pma_switch_to_new'])
547 && $_COOKIE['pma_switch_to_new'] == 'true') {
548 $pma_switch_to_new = 'true';
551 <input type="checkbox" name="switch_to_new" value="true"
552 id="checkbox_switch"<?php echo
553 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
554 ? ' checked="checked"'
555 : ''; ?> />
556 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
557 </fieldset>
558 <fieldset class="tblFooters">
559 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
560 </fieldset>
561 </form>
562 </div>
564 <br class="clearfloat"/>
566 <div id="div_table_maintenance">
567 <fieldset>
568 <legend><?php echo $strTableMaintenance; ?></legend>
570 <ul>
571 <?php
572 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
573 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
574 if ($is_myisam_or_maria || $is_innodb) {
575 $this_url_params = array_merge($url_params,
576 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
578 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
579 <?php echo $strCheckTable; ?></a>
580 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
581 </li>
582 <?php
584 if ($is_innodb) {
585 $this_url_params = array_merge($url_params,
586 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
588 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
589 <?php echo $strDefragment; ?></a>
590 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
591 </li>
592 <?php
594 if ($is_myisam_or_maria || $is_berkeleydb) {
595 $this_url_params = array_merge($url_params,
596 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
598 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
599 <?php echo $strAnalyzeTable; ?></a>
600 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
601 </li>
602 <?php
604 if ($is_myisam_or_maria) {
605 $this_url_params = array_merge($url_params,
606 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
608 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
609 <?php echo $strRepairTable; ?></a>
610 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
611 </li>
612 <?php
614 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
615 $this_url_params = array_merge($url_params,
616 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
618 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
619 <?php echo $strOptimizeTable; ?></a>
620 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
621 </li>
622 <?php
624 } // end MYISAM or BERKELEYDB case
625 $this_url_params = array_merge($url_params,
626 array(
627 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
628 'zero_rows' => sprintf($strTableHasBeenFlushed,
629 htmlspecialchars($GLOBALS['table'])),
630 'reload' => 1,
633 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
634 <?php echo $strFlushTable; ?></a>
635 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
636 </li>
637 </ul>
638 </fieldset>
639 </div>
640 <?php if (PMA_Partition::havePartitioning()) {
641 $partition_names = PMA_Partition::getPartitionNames($db, $table);
642 // show the Partition maintenance section only if we detect a partition
643 if (! is_null($partition_names[0])) {
645 <div id="div_partition_maintenance">
646 <form method="post" action="tbl_operations.php">
647 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
648 <fieldset>
649 <legend><?php echo $strPartitionMaintenance; ?></legend>
650 <?php
651 $html_select = '<select name="partition_name">' . "\n";
652 foreach($partition_names as $one_partition) {
653 $one_partition = htmlspecialchars($one_partition);
654 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
656 $html_select .= '</select>' . "\n";
657 printf($GLOBALS['strPartition'], $html_select);
658 unset($partition_names, $one_partition, $html_select);
659 $choices = array(
660 'ANALYZE' => $strAnalyze,
661 'CHECK' => $strCheck,
662 'OPTIMIZE' => $strOptimize,
663 'REBUILD' => $strRebuild,
664 'REPAIR' => $strRepair);
665 PMA_display_html_radio('partition_operation', $choices, '', false);
666 unset($choices);
667 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
668 // I'm not sure of the best way to display that; this link does
669 // not depend on the Go button
670 $this_url_params = array_merge($url_params,
671 array(
672 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
675 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
676 <?php echo $strRemovePartitioning; ?></a>
677 </fieldset>
678 <fieldset class="tblFooters">
679 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
680 </fieldset>
681 </form>
682 </div>
683 <?php
684 } // end if
685 } // end if
687 // Referential integrity check
688 // The Referential integrity check was intended for the non-InnoDB
689 // tables for which the relations are defined in pmadb
690 // so I assume that if the current table is InnoDB, I don't display
691 // this choice (InnoDB maintains integrity by itself)
693 if ($cfgRelation['relwork'] && ! $is_innodb) {
694 PMA_DBI_select_db($GLOBALS['db']);
695 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
697 if ($foreign) {
699 <!-- Referential integrity check -->
700 <div id="div_referential_integrity">
701 <fieldset>
702 <legend><?php echo $strReferentialIntegrity; ?></legend>
703 <ul>
704 <?php
705 echo "\n";
706 foreach ($foreign AS $master => $arr) {
707 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
708 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
709 . PMA_backquote($arr['foreign_table']);
710 if ($arr['foreign_table'] == $GLOBALS['table']) {
711 $foreign_table = $GLOBALS['table'] . '1';
712 $join_query .= ' AS ' . PMA_backquote($foreign_table);
713 } else {
714 $foreign_table = $arr['foreign_table'];
716 $join_query .= ' ON '
717 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
718 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
719 . ' WHERE '
720 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
721 . ' IS NULL AND '
722 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
723 . ' IS NOT NULL';
724 $this_url_params = array_merge($url_params,
725 array('sql_query' => $join_query));
726 echo ' <li>'
727 . '<a href="sql.php'
728 . PMA_generate_common_url($this_url_params)
729 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
730 . '</a></li>' . "\n";
731 } // foreach $foreign
732 unset($foreign_table, $join_query);
734 </ul>
735 </fieldset>
736 </div>
737 <?php
738 } // end if ($foreign)
740 } // end if (!empty($cfg['Server']['relation']))
744 * Displays the footer
746 require_once './libraries/footer.inc.php';
749 function PMA_set_global_variables_for_engine($tbl_type)
751 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
753 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
754 $upper_tbl_type = strtoupper($tbl_type);
756 //Options that apply to MYISAM usually apply to MARIA
757 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
758 $is_maria = ($upper_tbl_type == 'MARIA');
760 $is_isam = ($upper_tbl_type == 'ISAM');
761 $is_innodb = ($upper_tbl_type == 'INNODB');
762 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
763 $is_pbxt = ($upper_tbl_type == 'PBXT');