Translation update done using Pootle.
[phpmyadmin/crack.git] / tbl_operations.php
blob8b25c8c42d18a8cf3f79886eec4b76b47d7bf93c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
11 require_once './libraries/common.inc.php';
13 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
15 /**
16 * Runs common work
18 require './libraries/tbl_common.php';
19 $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
20 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
22 /**
23 * Gets relation settings
25 $cfgRelation = PMA_getRelationsParam();
27 /**
28 * Gets available MySQL charsets and storage engines
30 require_once './libraries/mysql_charsets.lib.php';
31 require_once './libraries/StorageEngine.class.php';
33 /**
34 * Class for partition management
36 require_once './libraries/Partition.class.php';
38 // reselect current db (needed in some cases probably due to
39 // the calling of relation.lib.php)
40 PMA_DBI_select_db($GLOBALS['db']);
42 /**
43 * Gets tables informations
46 require './libraries/tbl_info.inc.php';
48 // define some globals here, for improved syntax in the conditionals
49 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
50 // set initial value of these globals, based on the current table engine
51 PMA_set_global_variables_for_engine($tbl_type);
53 if ($is_aria) {
54 // the value for transactional can be implicit
55 // (no create option found, in this case it means 1)
56 // or explicit (option found with a value of 0 or 1)
57 // ($transactional may have been set by libraries/tbl_info.inc.php,
58 // from the $create_options)
59 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
60 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
63 $reread_info = false;
64 $table_alters = array();
66 /**
67 * Updates table comment, type and options if required
69 if (isset($_REQUEST['submitoptions'])) {
70 $_message = '';
71 $warning_messages = array();
73 if (isset($_REQUEST['new_name'])) {
74 if ($pma_table->rename($_REQUEST['new_name'])) {
75 $_message .= $pma_table->getLastMessage();
76 $result = true;
77 $GLOBALS['table'] = $pma_table->getName();
78 $reread_info = true;
79 $reload = true;
80 } else {
81 $_message .= $pma_table->getLastError();
82 $result = false;
85 if (isset($_REQUEST['comment'])
86 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
87 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
89 if (! empty($_REQUEST['new_tbl_type'])
90 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
91 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
92 $tbl_type = $_REQUEST['new_tbl_type'];
93 // reset the globals for the new engine
94 PMA_set_global_variables_for_engine($tbl_type);
95 if ($is_aria) {
96 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
97 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
101 if (! empty($_REQUEST['tbl_collation'])
102 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
103 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
106 if (($is_myisam_or_aria || $is_isam)
107 && isset($_REQUEST['new_pack_keys'])
108 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
109 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
112 $checksum = empty($checksum) ? '0' : '1';
113 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
114 if ($is_myisam_or_aria
115 && $_REQUEST['new_checksum'] !== $checksum) {
116 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
119 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
120 if ($is_aria
121 && $_REQUEST['new_transactional'] !== $transactional) {
122 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
125 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
126 if ($is_aria
127 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
128 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
131 $delay_key_write = empty($delay_key_write) ? '0' : '1';
132 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
133 if ($is_myisam_or_aria
134 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
135 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
138 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
139 && ! empty($_REQUEST['new_auto_increment'])
140 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
141 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
144 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
145 && ! empty($_REQUEST['new_row_format'])
146 && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
147 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
150 if (count($table_alters) > 0) {
151 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
152 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
153 $result .= PMA_DBI_query($sql_query) ? true : false;
154 $reread_info = true;
155 unset($table_alters);
156 foreach (PMA_DBI_get_warnings() as $warning) {
157 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
158 // and if TRANSACTIONAL was set, the system reports an error;
159 // I discussed with a Maria developer and he agrees that this
160 // should not be reported with a Level of Error, so here
161 // I just ignore it. But there are other 1478 messages
162 // that it's better to show.
163 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
164 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
165 . ' ' . $warning['Message'];
171 * Reordering the table has been requested by the user
173 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
174 $sql_query = '
175 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
176 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
177 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
178 $sql_query .= ' DESC';
180 $result = PMA_DBI_query($sql_query);
181 } // end if
184 * A partition operation has been requested by the user
186 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
187 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
188 $result = PMA_DBI_query($sql_query);
189 } // end if
191 if ($reread_info) {
192 // to avoid showing the old value (for example the AUTO_INCREMENT) after
193 // a change, clear the cache
194 PMA_Table::$cache = array();
195 $page_checksum = $checksum = $delay_key_write = 0;
196 require './libraries/tbl_info.inc.php';
198 unset($reread_info);
201 * Displays top menu links
203 require_once './libraries/tbl_links.inc.php';
205 if (isset($result) && empty($message_to_show)) {
206 // set to success by default, because result set could be empty
207 // (for example, a table rename)
208 $_type = 'success';
209 if (empty($_message)) {
210 $_message = $result ? __('Your SQL query has been executed successfully') : __('Error');
211 // $result should exist, regardless of $_message
212 $_type = $result ? 'success' : 'error';
214 if (! empty($warning_messages)) {
215 $_message = new PMA_Message;
216 $_message->addMessages($warning_messages);
217 $_message->isWarning(true);
218 unset($warning_messages);
220 PMA_showMessage($_message, $sql_query, $_type);
221 unset($_message, $_type);
224 $url_params['goto'] = 'tbl_operations.php';
225 $url_params['back'] = 'tbl_operations.php';
228 * Get columns names
230 $local_query = '
231 SHOW COLUMNS
232 FROM ' . PMA_backquote($GLOBALS['table']) . '
233 FROM ' . PMA_backquote($GLOBALS['db']);
234 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
235 unset($local_query);
238 * Displays the page
241 <!-- Order the table -->
242 <div id="div_table_order">
243 <form method="post" action="tbl_operations.php">
244 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
245 <fieldset id="fieldset_table_order">
246 <legend><?php echo __('Alter table order by'); ?></legend>
247 <select name="order_field">
248 <?php
249 foreach ($columns as $fieldname) {
250 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
251 . htmlspecialchars($fieldname) . '</option>' . "\n";
253 unset($columns);
255 </select> <?php echo __('(singly)'); ?>
256 <select name="order_order">
257 <option value="asc"><?php echo __('Ascending'); ?></option>
258 <option value="desc"><?php echo __('Descending'); ?></option>
259 </select>
260 </fieldset>
261 <fieldset class="tblFooters">
262 <input type="submit" name="submitorderby" value="<?php echo __('Go'); ?>" />
263 </fieldset>
264 </form>
265 </div>
267 <!-- Move table -->
268 <div id="div_table_rename">
269 <form method="post" action="tbl_move_copy.php"
270 onsubmit="return emptyFormElements(this, 'new_name')">
271 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
272 <input type="hidden" name="reload" value="1" />
273 <input type="hidden" name="what" value="data" />
274 <fieldset id="fieldset_table_rename">
275 <legend><?php echo __('Move table to (database<b>.</b>table):'); ?></legend>
276 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
278 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
279 <?php
280 } else {
282 <select name="target_db">
283 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
284 </select>
285 <?php
286 } // end if
288 &nbsp;<strong>.</strong>&nbsp;
289 <input type="text" size="20" name="new_name" onfocus="this.select()"
290 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
291 <?php
292 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
293 // next value but users can decide if they want it or not for the operation
295 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
296 <label for="checkbox_auto_increment_mv"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
297 </fieldset>
298 <fieldset class="tblFooters">
299 <input type="submit" name="submit_move" value="<?php echo __('Go'); ?>" />
300 </fieldset>
301 </form>
302 </div>
304 <?php
305 if (strstr($show_comment, '; InnoDB free') === false) {
306 if (strstr($show_comment, 'InnoDB free') === false) {
307 // only user entered comment
308 $comment = $show_comment;
309 } else {
310 // here we have just InnoDB generated part
311 $comment = '';
313 } else {
314 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
315 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
318 // PACK_KEYS: MyISAM or ISAM
319 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
320 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
322 // Here should be version check for InnoDB, however it is supported
323 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
324 // check for version
327 <!-- Table options -->
328 <div id="div_table_options">
329 <form method="post" action="tbl_operations.php">
330 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
331 <input type="hidden" name="reload" value="1" />
332 <fieldset>
333 <legend><?php echo __('Table options'); ?></legend>
335 <table>
336 <!-- Change table name -->
337 <tr><td><?php echo __('Rename table to'); ?></td>
338 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
339 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
340 </td>
341 </tr>
343 <!-- Table comments -->
344 <tr><td><?php echo __('Table comments'); ?></td>
345 <td><input type="text" name="comment" maxlength="60" size="30"
346 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
347 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
348 </td>
349 </tr>
351 <!-- Storage engine -->
352 <tr><td><?php echo __('Storage Engine'); ?>
353 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
354 </td>
355 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
356 </td>
357 </tr>
359 <!-- Table character set -->
360 <tr><td><?php echo __('Collation'); ?></td>
361 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
362 'tbl_collation', null, $tbl_collation, false, 3); ?>
363 </td>
364 </tr>
365 <?php
366 if ($is_myisam_or_aria || $is_isam) {
368 <tr>
369 <td><label for="new_pack_keys">PACK_KEYS</label></td>
370 <td><select name="new_pack_keys" id="new_pack_keys">
371 <option value="DEFAULT"
372 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
373 >DEFAULT</option>
374 <option value="0"
375 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
376 >0</option>
377 <option value="1"
378 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
379 >1</option>
380 </select>
381 </td>
382 </tr>
383 <?php
384 } // end if (MYISAM|ISAM)
386 if ($is_myisam_or_aria) {
388 <tr><td><label for="new_checksum">CHECKSUM</label></td>
389 <td><input type="checkbox" name="new_checksum" id="new_checksum"
390 value="1"
391 <?php echo (isset($checksum) && $checksum == 1)
392 ? ' checked="checked"'
393 : ''; ?> />
394 </td>
395 </tr>
397 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
398 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
399 value="1"
400 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
401 ? ' checked="checked"'
402 : ''; ?> />
403 </td>
404 </tr>
406 <?php
407 } // end if (MYISAM)
409 if ($is_aria) {
411 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
412 <td><input type="checkbox" name="new_transactional" id="new_transactional"
413 value="1"
414 <?php echo (isset($transactional) && $transactional == 1)
415 ? ' checked="checked"'
416 : ''; ?> />
417 </td>
418 </tr>
420 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
421 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
422 value="1"
423 <?php echo (isset($page_checksum) && $page_checksum == 1)
424 ? ' checked="checked"'
425 : ''; ?> />
426 </td>
427 </tr>
429 <?php
430 } // end if (ARIA)
432 if (isset($auto_increment) && strlen($auto_increment) > 0
433 && ($is_myisam_or_aria || $is_innodb || $is_pbxt)) {
435 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
436 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
437 value="<?php echo $auto_increment; ?>" /></td>
438 </tr>
439 <?php
440 } // end if (MYISAM|INNODB)
442 // the outer array is for engines, the inner array contains the dropdown
443 // option values as keys then the dropdown option labels
445 $possible_row_formats = array(
446 'ARIA' => array(
447 'FIXED' => 'FIXED',
448 'DYNAMIC' => 'DYNAMIC',
449 'PAGE' => 'PAGE'
451 'MARIA' => array(
452 'FIXED' => 'FIXED',
453 'DYNAMIC' => 'DYNAMIC',
454 'PAGE' => 'PAGE'
456 'MYISAM' => array(
457 'FIXED' => 'FIXED',
458 'DYNAMIC' => 'DYNAMIC'
460 'PBXT' => array(
461 'FIXED' => 'FIXED',
462 'DYNAMIC' => 'DYNAMIC'
464 'INNODB' => array(
465 'COMPACT' => 'COMPACT',
466 'REDUNDANT' => 'REDUNDANT')
469 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
470 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
471 if (!empty($innodb_plugin_version)) {
472 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
473 } else {
474 $innodb_file_format = '';
476 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
477 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
478 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
480 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
482 // for MYISAM there is also COMPRESSED but it can be set only by the
483 // myisampack utility, so don't offer here the choice because if we
484 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
485 // does not return a warning
486 // (if the table was compressed, it can be seen on the Structure page)
488 if (isset($possible_row_formats[$tbl_type])) {
489 $current_row_format = strtoupper($showtable['Row_format']);
490 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
491 echo '<td>';
492 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
493 unset($possible_row_formats, $current_row_format);
494 echo '</td>';
495 echo '</tr>';
498 </table>
499 </fieldset>
500 <fieldset class="tblFooters">
501 <input type="submit" name="submitoptions" value="<?php echo __('Go'); ?>" />
502 </fieldset>
503 </form>
504 </div>
506 <!-- Copy table -->
507 <div id="div_table_copy">
508 <form method="post" action="tbl_move_copy.php"
509 onsubmit="return emptyFormElements(this, 'new_name')">
510 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
511 <input type="hidden" name="reload" value="1" />
512 <fieldset>
513 <legend><?php echo __('Copy table to (database<b>.</b>table):'); ?></legend>
514 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
516 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
517 <?php
518 } else {
520 <select name="target_db">
521 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
522 </select>
523 <?php
524 } // end if
526 &nbsp;<strong>.</strong>&nbsp;
527 <input type="text" size="20" name="new_name" onfocus="this.select()" value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br />
528 <?php
529 $choices = array(
530 'structure' => __('Structure only'),
531 'data' => __('Structure and data'),
532 'dataonly' => __('Data only'));
533 PMA_display_html_radio('what', $choices, 'data', true);
534 unset($choices);
537 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
538 <label for="checkbox_drop"><?php echo sprintf(__('Add %s'), 'DROP TABLE'); ?></label><br />
539 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
540 <label for="checkbox_auto_increment_cp"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
541 <?php
542 // display "Add constraints" choice only if there are
543 // foreign keys
544 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
546 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
547 <label for="checkbox_constraints"><?php echo __('Add constraints'); ?></label><br />
548 <?php
549 } // endif
550 if (isset($_COOKIE['pma_switch_to_new'])
551 && $_COOKIE['pma_switch_to_new'] == 'true') {
552 $pma_switch_to_new = 'true';
555 <input type="checkbox" name="switch_to_new" value="true"
556 id="checkbox_switch"<?php echo
557 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
558 ? ' checked="checked"'
559 : ''; ?> />
560 <label for="checkbox_switch"><?php echo __('Switch to copied table'); ?></label>
561 </fieldset>
562 <fieldset class="tblFooters">
563 <input type="submit" name="submit_copy" value="<?php echo __('Go'); ?>" />
564 </fieldset>
565 </form>
566 </div>
568 <br class="clearfloat"/>
570 <div id="div_table_maintenance">
571 <fieldset>
572 <legend><?php echo __('Table maintenance'); ?></legend>
574 <ul>
575 <?php
576 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
577 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
578 if ($is_myisam_or_aria || $is_innodb) {
579 $this_url_params = array_merge($url_params,
580 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
582 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
583 <?php echo __('Check table'); ?></a>
584 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
585 </li>
586 <?php
588 if ($is_innodb) {
589 $this_url_params = array_merge($url_params,
590 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
592 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
593 <?php echo __('Defragment table'); ?></a>
594 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
595 </li>
596 <?php
598 if ($is_myisam_or_aria || $is_berkeleydb) {
599 $this_url_params = array_merge($url_params,
600 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
602 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
603 <?php echo __('Analyze table'); ?></a>
604 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
605 </li>
606 <?php
608 if ($is_myisam_or_aria) {
609 $this_url_params = array_merge($url_params,
610 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
612 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
613 <?php echo __('Repair table'); ?></a>
614 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
615 </li>
616 <?php
618 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
619 $this_url_params = array_merge($url_params,
620 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
622 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
623 <?php echo __('Optimize table'); ?></a>
624 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
625 </li>
626 <?php
628 } // end MYISAM or BERKELEYDB case
629 $this_url_params = array_merge($url_params,
630 array(
631 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
632 'message_to_show' => sprintf(__('Table %s has been flushed'),
633 htmlspecialchars($GLOBALS['table'])),
634 'reload' => 1,
637 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
638 <?php echo __('Flush the table (FLUSH)'); ?></a>
639 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
640 </li>
641 </ul>
642 </fieldset>
643 </div>
644 <?php if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?>
645 <div id="div_table_removal">
646 <fieldset class="caution">
647 <legend><?php echo __('Delete data or table'); ?></legend>
649 <ul>
650 <?php
651 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
652 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
653 $this_url_params = array_merge($url_params,
654 array(
655 'sql_query' => $this_sql_query,
656 'goto' => 'tbl_structure.php',
657 'reload' => '1',
658 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
661 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
662 <?php echo __('Empty the table (TRUNCATE)'); ?></a>
663 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
664 </li>
665 <?php
667 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
668 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
669 $this_url_params = array_merge($url_params,
670 array(
671 'sql_query' => $this_sql_query,
672 'goto' => 'db_operations.php',
673 'reload' => '1',
674 'purge' => '1',
675 'message_to_show' => sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
676 // table name is needed to avoid running
677 // PMA_relationsCleanupDatabase() on the whole db later
678 'table' => $GLOBALS['table'],
681 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
682 <?php echo __('Delete the table (DROP)'); ?></a>
683 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
684 </li>
685 <?php
688 </ul>
689 </fieldset>
690 </div>
691 <?php
694 <?php if (PMA_Partition::havePartitioning()) {
695 $partition_names = PMA_Partition::getPartitionNames($db, $table);
696 // show the Partition maintenance section only if we detect a partition
697 if (! is_null($partition_names[0])) {
699 <div id="div_partition_maintenance">
700 <form method="post" action="tbl_operations.php">
701 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
702 <fieldset>
703 <legend><?php echo __('Partition maintenance'); ?></legend>
704 <?php
705 $html_select = '<select name="partition_name">' . "\n";
706 foreach($partition_names as $one_partition) {
707 $one_partition = htmlspecialchars($one_partition);
708 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
710 $html_select .= '</select>' . "\n";
711 printf(__('Partition %s'), $html_select);
712 unset($partition_names, $one_partition, $html_select);
713 $choices = array(
714 'ANALYZE' => __('Analyze'),
715 'CHECK' => __('Check'),
716 'OPTIMIZE' => __('Optimize'),
717 'REBUILD' => __('Rebuild'),
718 'REPAIR' => __('Repair'));
719 PMA_display_html_radio('partition_operation', $choices, '', false);
720 unset($choices);
721 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
722 // I'm not sure of the best way to display that; this link does
723 // not depend on the Go button
724 $this_url_params = array_merge($url_params,
725 array(
726 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
729 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
730 <?php echo __('Remove partitioning'); ?></a>
731 </fieldset>
732 <fieldset class="tblFooters">
733 <input type="submit" name="submit_partition" value="<?php echo __('Go'); ?>" />
734 </fieldset>
735 </form>
736 </div>
737 <?php
738 } // end if
739 } // end if
741 // Referential integrity check
742 // The Referential integrity check was intended for the non-InnoDB
743 // tables for which the relations are defined in pmadb
744 // so I assume that if the current table is InnoDB, I don't display
745 // this choice (InnoDB maintains integrity by itself)
747 if ($cfgRelation['relwork'] && ! $is_innodb) {
748 PMA_DBI_select_db($GLOBALS['db']);
749 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
751 if ($foreign) {
753 <!-- Referential integrity check -->
754 <div id="div_referential_integrity">
755 <fieldset>
756 <legend><?php echo __('Check referential integrity:'); ?></legend>
757 <ul>
758 <?php
759 echo "\n";
760 foreach ($foreign AS $master => $arr) {
761 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
762 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
763 . PMA_backquote($arr['foreign_table']);
764 if ($arr['foreign_table'] == $GLOBALS['table']) {
765 $foreign_table = $GLOBALS['table'] . '1';
766 $join_query .= ' AS ' . PMA_backquote($foreign_table);
767 } else {
768 $foreign_table = $arr['foreign_table'];
770 $join_query .= ' ON '
771 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
772 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
773 . ' WHERE '
774 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
775 . ' IS NULL AND '
776 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
777 . ' IS NOT NULL';
778 $this_url_params = array_merge($url_params,
779 array('sql_query' => $join_query));
780 echo ' <li>'
781 . '<a href="sql.php'
782 . PMA_generate_common_url($this_url_params)
783 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
784 . '</a></li>' . "\n";
785 } // foreach $foreign
786 unset($foreign_table, $join_query);
788 </ul>
789 </fieldset>
790 </div>
791 <?php
792 } // end if ($foreign)
794 } // end if (!empty($cfg['Server']['relation']))
798 * Displays the footer
800 require './libraries/footer.inc.php';
803 function PMA_set_global_variables_for_engine($tbl_type)
805 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
807 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
808 $upper_tbl_type = strtoupper($tbl_type);
810 //Options that apply to MYISAM usually apply to ARIA
811 $is_myisam_or_aria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'ARIA' || $upper_tbl_type == 'MARIA');
812 $is_aria = ($upper_tbl_type == 'ARIA');
814 $is_isam = ($upper_tbl_type == 'ISAM');
815 $is_innodb = ($upper_tbl_type == 'INNODB');
816 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
817 $is_pbxt = ($upper_tbl_type == 'PBXT');