Translation update done using Pootle.
[phpmyadmin/sankalp_k.git] / tbl_operations.php
blob04f1165fd18d9302d5747077798744597085cee5
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 * If the table has to be moved to some other database
69 if(isset($_REQUEST['submit_move']) || isset($_REQUEST['submit_copy'])) {
70 $_message = '';
71 require_once './tbl_move_copy.php';
73 /**
74 * If the table has to be maintained
76 if(isset($_REQUEST['table_maintenance'])) {
77 require_once './sql.php';
78 unset($result);
80 /**
81 * Updates table comment, type and options if required
83 if (isset($_REQUEST['submitoptions'])) {
84 $_message = '';
85 $warning_messages = array();
87 if (isset($_REQUEST['new_name'])) {
88 if ($pma_table->rename($_REQUEST['new_name'])) {
89 $_message .= $pma_table->getLastMessage();
90 $result = true;
91 $GLOBALS['table'] = $pma_table->getName();
92 $reread_info = true;
93 $reload = true;
94 } else {
95 $_message .= $pma_table->getLastError();
96 $result = false;
99 if (isset($_REQUEST['comment'])
100 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
101 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
103 if (! empty($_REQUEST['new_tbl_type'])
104 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
105 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
106 $tbl_type = $_REQUEST['new_tbl_type'];
107 // reset the globals for the new engine
108 PMA_set_global_variables_for_engine($tbl_type);
109 if ($is_aria) {
110 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
111 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
115 if (! empty($_REQUEST['tbl_collation'])
116 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
117 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
120 if (($is_myisam_or_aria || $is_isam)
121 && isset($_REQUEST['new_pack_keys'])
122 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
123 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
126 $checksum = empty($checksum) ? '0' : '1';
127 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
128 if ($is_myisam_or_aria
129 && $_REQUEST['new_checksum'] !== $checksum) {
130 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
133 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
134 if ($is_aria
135 && $_REQUEST['new_transactional'] !== $transactional) {
136 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
139 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
140 if ($is_aria
141 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
142 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
145 $delay_key_write = empty($delay_key_write) ? '0' : '1';
146 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
147 if ($is_myisam_or_aria
148 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
149 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
152 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
153 && ! empty($_REQUEST['new_auto_increment'])
154 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
155 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
158 if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
159 && ! empty($_REQUEST['new_row_format'])
160 && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
161 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
164 if (count($table_alters) > 0) {
165 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
166 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
167 $result .= PMA_DBI_query($sql_query) ? true : false;
168 $reread_info = true;
169 unset($table_alters);
170 foreach (PMA_DBI_get_warnings() as $warning) {
171 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
172 // and if TRANSACTIONAL was set, the system reports an error;
173 // I discussed with a Maria developer and he agrees that this
174 // should not be reported with a Level of Error, so here
175 // I just ignore it. But there are other 1478 messages
176 // that it's better to show.
177 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
178 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
179 . ' ' . $warning['Message'];
185 * Reordering the table has been requested by the user
187 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
188 $sql_query = '
189 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
190 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
191 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
192 $sql_query .= ' DESC';
194 $result = PMA_DBI_query($sql_query);
195 } // end if
198 * A partition operation has been requested by the user
200 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
201 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
202 $result = PMA_DBI_query($sql_query);
203 } // end if
205 if ($reread_info) {
206 // to avoid showing the old value (for example the AUTO_INCREMENT) after
207 // a change, clear the cache
208 PMA_Table::$cache = array();
209 $page_checksum = $checksum = $delay_key_write = 0;
210 require './libraries/tbl_info.inc.php';
212 unset($reread_info);
215 * Displays top menu links
217 require_once './libraries/tbl_links.inc.php';
219 if (isset($result) && empty($message_to_show)) {
220 // set to success by default, because result set could be empty
221 // (for example, a table rename)
222 $_type = 'success';
223 if (empty($_message)) {
224 $_message = $result ? __('Your SQL query has been executed successfully') : __('Error');
225 // $result should exist, regardless of $_message
226 $_type = $result ? 'success' : 'error';
228 if (! empty($warning_messages)) {
229 $_message = new PMA_Message;
230 $_message->addMessages($warning_messages);
231 $_message->isWarning(true);
232 unset($warning_messages);
234 PMA_showMessage($_message, $sql_query, $_type);
235 unset($_message, $_type);
238 $url_params['goto'] = 'tbl_operations.php';
239 $url_params['back'] = 'tbl_operations.php';
242 * Get columns names
244 $local_query = '
245 SHOW COLUMNS
246 FROM ' . PMA_backquote($GLOBALS['table']) . '
247 FROM ' . PMA_backquote($GLOBALS['db']);
248 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
249 unset($local_query);
252 * Displays the page
255 <!-- Order the table -->
256 <div class="operations_half_width">
257 <form method="post" action="tbl_operations.php">
258 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
259 <fieldset id="fieldset_table_order">
260 <legend><?php echo __('Alter table order by'); ?></legend>
261 <select name="order_field">
262 <?php
263 foreach ($columns as $fieldname) {
264 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
265 . htmlspecialchars($fieldname) . '</option>' . "\n";
267 unset($columns);
269 </select> <?php echo __('(singly)'); ?>
270 <select name="order_order">
271 <option value="asc"><?php echo __('Ascending'); ?></option>
272 <option value="desc"><?php echo __('Descending'); ?></option>
273 </select>
274 </fieldset>
275 <fieldset class="tblFooters">
276 <input type="submit" name="submitorderby" value="<?php echo __('Go'); ?>" />
277 </fieldset>
278 </form>
279 </div>
281 <!-- Move table -->
282 <div class="operations_half_width">
283 <form method="post" action="tbl_operations.php"
284 onsubmit="return emptyFormElements(this, 'new_name')">
285 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
286 <input type="hidden" name="reload" value="1" />
287 <input type="hidden" name="what" value="data" />
288 <fieldset id="fieldset_table_rename">
289 <legend><?php echo __('Move table to (database<b>.</b>table):'); ?></legend>
290 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
292 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
293 <?php
294 } else {
296 <select name="target_db">
297 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
298 </select>
299 <?php
300 } // end if
302 &nbsp;<strong>.</strong>&nbsp;
303 <input type="text" size="20" name="new_name" onfocus="this.select()"
304 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
305 <?php
306 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
307 // next value but users can decide if they want it or not for the operation
309 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
310 <label for="checkbox_auto_increment_mv"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
311 </fieldset>
312 <fieldset class="tblFooters">
313 <input type="submit" name="submit_move" value="<?php echo __('Go'); ?>" />
314 </fieldset>
315 </form>
316 </div>
318 <?php
319 if (strstr($show_comment, '; InnoDB free') === false) {
320 if (strstr($show_comment, 'InnoDB free') === false) {
321 // only user entered comment
322 $comment = $show_comment;
323 } else {
324 // here we have just InnoDB generated part
325 $comment = '';
327 } else {
328 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
329 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
332 // PACK_KEYS: MyISAM or ISAM
333 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
334 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
336 // Here should be version check for InnoDB, however it is supported
337 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
338 // check for version
341 <!-- Table options -->
342 <div class="operations_half_width clearfloat">
343 <form method="post" action="tbl_operations.php">
344 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
345 <input type="hidden" name="reload" value="1" />
346 <fieldset>
347 <legend><?php echo __('Table options'); ?></legend>
349 <table>
350 <!-- Change table name -->
351 <tr><td><?php echo __('Rename table to'); ?></td>
352 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
353 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
354 </td>
355 </tr>
357 <!-- Table comments -->
358 <tr><td><?php echo __('Table comments'); ?></td>
359 <td><input type="text" name="comment" maxlength="60" size="30"
360 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
361 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
362 </td>
363 </tr>
365 <!-- Storage engine -->
366 <tr><td><?php echo __('Storage Engine'); ?>
367 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
368 </td>
369 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
370 </td>
371 </tr>
373 <!-- Table character set -->
374 <tr><td><?php echo __('Collation'); ?></td>
375 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
376 'tbl_collation', null, $tbl_collation, false, 3); ?>
377 </td>
378 </tr>
379 <?php
380 if ($is_myisam_or_aria || $is_isam) {
382 <tr>
383 <td><label for="new_pack_keys">PACK_KEYS</label></td>
384 <td><select name="new_pack_keys" id="new_pack_keys">
385 <option value="DEFAULT"
386 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
387 >DEFAULT</option>
388 <option value="0"
389 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
390 >0</option>
391 <option value="1"
392 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
393 >1</option>
394 </select>
395 </td>
396 </tr>
397 <?php
398 } // end if (MYISAM|ISAM)
400 if ($is_myisam_or_aria) {
402 <tr><td><label for="new_checksum">CHECKSUM</label></td>
403 <td><input type="checkbox" name="new_checksum" id="new_checksum"
404 value="1"
405 <?php echo (isset($checksum) && $checksum == 1)
406 ? ' checked="checked"'
407 : ''; ?> />
408 </td>
409 </tr>
411 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
412 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
413 value="1"
414 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
415 ? ' checked="checked"'
416 : ''; ?> />
417 </td>
418 </tr>
420 <?php
421 } // end if (MYISAM)
423 if ($is_aria) {
425 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
426 <td><input type="checkbox" name="new_transactional" id="new_transactional"
427 value="1"
428 <?php echo (isset($transactional) && $transactional == 1)
429 ? ' checked="checked"'
430 : ''; ?> />
431 </td>
432 </tr>
434 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
435 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
436 value="1"
437 <?php echo (isset($page_checksum) && $page_checksum == 1)
438 ? ' checked="checked"'
439 : ''; ?> />
440 </td>
441 </tr>
443 <?php
444 } // end if (ARIA)
446 if (isset($auto_increment) && strlen($auto_increment) > 0
447 && ($is_myisam_or_aria || $is_innodb || $is_pbxt)) {
449 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
450 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
451 value="<?php echo $auto_increment; ?>" /></td>
452 </tr>
453 <?php
454 } // end if (MYISAM|INNODB)
456 // the outer array is for engines, the inner array contains the dropdown
457 // option values as keys then the dropdown option labels
459 $possible_row_formats = array(
460 'ARIA' => array(
461 'FIXED' => 'FIXED',
462 'DYNAMIC' => 'DYNAMIC',
463 'PAGE' => 'PAGE'
465 'MARIA' => array(
466 'FIXED' => 'FIXED',
467 'DYNAMIC' => 'DYNAMIC',
468 'PAGE' => 'PAGE'
470 'MYISAM' => array(
471 'FIXED' => 'FIXED',
472 'DYNAMIC' => 'DYNAMIC'
474 'PBXT' => array(
475 'FIXED' => 'FIXED',
476 'DYNAMIC' => 'DYNAMIC'
478 'INNODB' => array(
479 'COMPACT' => 'COMPACT',
480 'REDUNDANT' => 'REDUNDANT')
483 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
484 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
485 if (!empty($innodb_plugin_version)) {
486 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
487 } else {
488 $innodb_file_format = '';
490 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
491 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
492 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
494 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
496 // for MYISAM there is also COMPRESSED but it can be set only by the
497 // myisampack utility, so don't offer here the choice because if we
498 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
499 // does not return a warning
500 // (if the table was compressed, it can be seen on the Structure page)
502 if (isset($possible_row_formats[$tbl_type])) {
503 $current_row_format = strtoupper($showtable['Row_format']);
504 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
505 echo '<td>';
506 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
507 unset($possible_row_formats, $current_row_format);
508 echo '</td>';
509 echo '</tr>';
512 </table>
513 </fieldset>
514 <fieldset class="tblFooters">
515 <input type="submit" name="submitoptions" value="<?php echo __('Go'); ?>" />
516 </fieldset>
517 </form>
518 </div>
520 <!-- Copy table -->
521 <div class="operations_half_width">
522 <form method="post" action="tbl_operations.php"
523 onsubmit="return emptyFormElements(this, 'new_name')">
524 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
525 <input type="hidden" name="reload" value="1" />
526 <fieldset>
527 <legend><?php echo __('Copy table to (database<b>.</b>table):'); ?></legend>
528 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
530 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
531 <?php
532 } else {
534 <select name="target_db">
535 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
536 </select>
537 <?php
538 } // end if
540 &nbsp;<strong>.</strong>&nbsp;
541 <input type="text" size="20" name="new_name" onfocus="this.select()" value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br />
542 <?php
543 $choices = array(
544 'structure' => __('Structure only'),
545 'data' => __('Structure and data'),
546 'dataonly' => __('Data only'));
547 PMA_display_html_radio('what', $choices, 'data', true);
548 unset($choices);
551 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
552 <label for="checkbox_drop"><?php echo sprintf(__('Add %s'), 'DROP TABLE'); ?></label><br />
553 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
554 <label for="checkbox_auto_increment_cp"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
555 <?php
556 // display "Add constraints" choice only if there are
557 // foreign keys
558 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
560 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
561 <label for="checkbox_constraints"><?php echo __('Add constraints'); ?></label><br />
562 <?php
563 } // endif
564 if (isset($_COOKIE['pma_switch_to_new'])
565 && $_COOKIE['pma_switch_to_new'] == 'true') {
566 $pma_switch_to_new = 'true';
569 <input type="checkbox" name="switch_to_new" value="true"
570 id="checkbox_switch"<?php echo
571 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
572 ? ' checked="checked"'
573 : ''; ?> />
574 <label for="checkbox_switch"><?php echo __('Switch to copied table'); ?></label>
575 </fieldset>
576 <fieldset class="tblFooters">
577 <input type="submit" name="submit_copy" value="<?php echo __('Go'); ?>" />
578 </fieldset>
579 </form>
580 </div>
582 <br class="clearfloat"/>
584 <div class="operations_half_width">
585 <fieldset>
586 <legend><?php echo __('Table maintenance'); ?></legend>
588 <ul>
589 <?php
590 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
591 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
592 if ($is_myisam_or_aria || $is_innodb) {
593 $this_url_params = array_merge($url_params,
594 array(
595 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']),
596 'table_maintenance' => 'Go',
599 <li><a href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
600 <?php echo __('Check table'); ?></a>
601 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
602 </li>
603 <?php
605 if ($is_innodb) {
606 $this_url_params = array_merge($url_params,
607 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
609 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
610 <?php echo __('Defragment table'); ?></a>
611 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
612 </li>
613 <?php
615 if ($is_myisam_or_aria || $is_berkeleydb) {
616 $this_url_params = array_merge($url_params,
617 array(
618 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
619 'table_maintenance' => 'Go',
622 <li><a href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
623 <?php echo __('Analyze table'); ?></a>
624 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
625 </li>
626 <?php
628 if ($is_myisam_or_aria) {
629 $this_url_params = array_merge($url_params,
630 array(
631 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
632 'table_maintenance' => 'Go',
635 <li><a href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
636 <?php echo __('Repair table'); ?></a>
637 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
638 </li>
639 <?php
641 if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
642 $this_url_params = array_merge($url_params,
643 array(
644 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
645 'table_maintenance' => 'Go',
648 <li><a href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
649 <?php echo __('Optimize table'); ?></a>
650 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
651 </li>
652 <?php
654 } // end MYISAM or BERKELEYDB case
655 $this_url_params = array_merge($url_params,
656 array(
657 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
658 'message_to_show' => sprintf(__('Table %s has been flushed'),
659 htmlspecialchars($GLOBALS['table'])),
660 'reload' => 1,
663 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
664 <?php echo __('Flush the table (FLUSH)'); ?></a>
665 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
666 </li>
667 </ul>
668 </fieldset>
669 </div>
670 <?php if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?>
671 <div class="operations_half_width">
672 <fieldset class="caution">
673 <legend><?php echo __('Delete data or table'); ?></legend>
675 <ul>
676 <?php
677 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
678 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
679 $this_url_params = array_merge($url_params,
680 array(
681 'sql_query' => $this_sql_query,
682 'goto' => 'tbl_structure.php',
683 'reload' => '1',
684 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
687 <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); ?>')">
688 <?php echo __('Empty the table (TRUNCATE)'); ?></a>
689 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
690 </li>
691 <?php
693 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
694 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
695 $this_url_params = array_merge($url_params,
696 array(
697 'sql_query' => $this_sql_query,
698 'goto' => 'db_operations.php',
699 'reload' => '1',
700 'purge' => '1',
701 'message_to_show' => sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
702 // table name is needed to avoid running
703 // PMA_relationsCleanupDatabase() on the whole db later
704 'table' => $GLOBALS['table'],
707 <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); ?>')">
708 <?php echo __('Delete the table (DROP)'); ?></a>
709 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
710 </li>
711 <?php
714 </ul>
715 </fieldset>
716 </div>
717 <?php
720 <?php if (PMA_Partition::havePartitioning()) {
721 $partition_names = PMA_Partition::getPartitionNames($db, $table);
722 // show the Partition maintenance section only if we detect a partition
723 if (! is_null($partition_names[0])) {
725 <div class="operations_half_width">
726 <form method="post" action="tbl_operations.php">
727 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
728 <fieldset>
729 <legend><?php echo __('Partition maintenance'); ?></legend>
730 <?php
731 $html_select = '<select name="partition_name">' . "\n";
732 foreach($partition_names as $one_partition) {
733 $one_partition = htmlspecialchars($one_partition);
734 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
736 $html_select .= '</select>' . "\n";
737 printf(__('Partition %s'), $html_select);
738 unset($partition_names, $one_partition, $html_select);
739 $choices = array(
740 'ANALYZE' => __('Analyze'),
741 'CHECK' => __('Check'),
742 'OPTIMIZE' => __('Optimize'),
743 'REBUILD' => __('Rebuild'),
744 'REPAIR' => __('Repair'));
745 PMA_display_html_radio('partition_operation', $choices, '', false);
746 unset($choices);
747 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
748 // I'm not sure of the best way to display that; this link does
749 // not depend on the Go button
750 $this_url_params = array_merge($url_params,
751 array(
752 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
755 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
756 <?php echo __('Remove partitioning'); ?></a>
757 </fieldset>
758 <fieldset class="tblFooters">
759 <input type="submit" name="submit_partition" value="<?php echo __('Go'); ?>" />
760 </fieldset>
761 </form>
762 </div>
763 <?php
764 } // end if
765 } // end if
767 // Referential integrity check
768 // The Referential integrity check was intended for the non-InnoDB
769 // tables for which the relations are defined in pmadb
770 // so I assume that if the current table is InnoDB, I don't display
771 // this choice (InnoDB maintains integrity by itself)
773 if ($cfgRelation['relwork'] && ! $is_innodb) {
774 PMA_DBI_select_db($GLOBALS['db']);
775 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
777 if ($foreign) {
779 <!-- Referential integrity check -->
780 <div class="operations_half_width">
781 <fieldset>
782 <legend><?php echo __('Check referential integrity:'); ?></legend>
783 <ul>
784 <?php
785 echo "\n";
786 foreach ($foreign AS $master => $arr) {
787 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
788 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
789 . PMA_backquote($arr['foreign_table']);
790 if ($arr['foreign_table'] == $GLOBALS['table']) {
791 $foreign_table = $GLOBALS['table'] . '1';
792 $join_query .= ' AS ' . PMA_backquote($foreign_table);
793 } else {
794 $foreign_table = $arr['foreign_table'];
796 $join_query .= ' ON '
797 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
798 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
799 . ' WHERE '
800 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
801 . ' IS NULL AND '
802 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
803 . ' IS NOT NULL';
804 $this_url_params = array_merge($url_params,
805 array('sql_query' => $join_query));
806 echo ' <li>'
807 . '<a href="sql.php'
808 . PMA_generate_common_url($this_url_params)
809 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
810 . '</a></li>' . "\n";
811 } // foreach $foreign
812 unset($foreign_table, $join_query);
814 </ul>
815 </fieldset>
816 </div>
817 <?php
818 } // end if ($foreign)
820 } // end if (!empty($cfg['Server']['relation']))
824 * Displays the footer
826 require './libraries/footer.inc.php';
829 function PMA_set_global_variables_for_engine($tbl_type)
831 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
833 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
834 $upper_tbl_type = strtoupper($tbl_type);
836 //Options that apply to MYISAM usually apply to ARIA
837 $is_myisam_or_aria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'ARIA' || $upper_tbl_type == 'MARIA');
838 $is_aria = ($upper_tbl_type == 'ARIA');
840 $is_isam = ($upper_tbl_type == 'ISAM');
841 $is_innodb = ($upper_tbl_type == 'INNODB');
842 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
843 $is_pbxt = ($upper_tbl_type == 'PBXT');