This has been fixed in PHP 5.1.0, we support 5.2+.
[phpmyadmin/crack.git] / tbl_operations.php
blobde58c27001d5fd9214b03a81fb5fc4c543f5b400
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 require_once './libraries/common.inc.php';
12 require_once './libraries/Table.class.php';
14 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
16 /**
17 * Runs common work
19 require './libraries/tbl_common.php';
20 $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
21 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
23 /**
24 * Gets relation settings
26 require_once './libraries/relation.lib.php';
27 $cfgRelation = PMA_getRelationsParam();
29 /**
30 * Gets available MySQL charsets and storage engines
32 require_once './libraries/mysql_charsets.lib.php';
33 require_once './libraries/StorageEngine.class.php';
35 /**
36 * Class for partition management
38 require_once './libraries/Partition.class.php';
40 // reselect current db (needed in some cases probably due to
41 // the calling of relation.lib.php)
42 PMA_DBI_select_db($GLOBALS['db']);
44 /**
45 * Gets tables informations
48 require './libraries/tbl_info.inc.php';
50 // define some globals here, for improved syntax in the conditionals
51 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
52 // set initial value of these globals, based on the current table engine
53 PMA_set_global_variables_for_engine($tbl_type);
55 if ($is_maria) {
56 // the value for transactional can be implicit
57 // (no create option found, in this case it means 1)
58 // or explicit (option found with a value of 0 or 1)
59 // ($transactional may have been set by libraries/tbl_info.inc.php,
60 // from the $create_options)
61 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
62 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
65 $reread_info = false;
66 $table_alters = array();
68 /**
69 * Updates table comment, type and options if required
71 if (isset($_REQUEST['submitoptions'])) {
72 $_message = '';
73 $warning_messages = array();
75 if (isset($_REQUEST['new_name'])) {
76 if ($pma_table->rename($_REQUEST['new_name'])) {
77 $_message .= $pma_table->getLastMessage();
78 $result = true;
79 $GLOBALS['table'] = $pma_table->getName();
80 $reread_info = true;
81 $reload = true;
82 } else {
83 $_message .= $pma_table->getLastError();
84 $result = false;
87 if (isset($_REQUEST['comment'])
88 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
89 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
91 if (! empty($_REQUEST['new_tbl_type'])
92 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
93 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
94 $tbl_type = $_REQUEST['new_tbl_type'];
95 // reset the globals for the new engine
96 PMA_set_global_variables_for_engine($tbl_type);
99 if (! empty($_REQUEST['tbl_collation'])
100 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
101 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
104 if (($is_myisam_or_maria || $is_isam)
105 && isset($_REQUEST['new_pack_keys'])
106 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
107 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
110 $checksum = empty($checksum) ? '0' : '1';
111 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
112 if ($is_myisam_or_maria
113 && $_REQUEST['new_checksum'] !== $checksum) {
114 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
117 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
118 if ($is_maria
119 && $_REQUEST['new_transactional'] !== $transactional) {
120 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
123 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
124 if ($is_maria
125 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
126 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
129 $delay_key_write = empty($delay_key_write) ? '0' : '1';
130 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
131 if ($is_myisam_or_maria
132 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
133 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
136 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
137 && ! empty($_REQUEST['new_auto_increment'])
138 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
139 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
142 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
143 && ! empty($_REQUEST['new_row_format'])
144 && (! isset($row_format) || $_REQUEST['new_row_format'] !== $row_format)) {
145 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
148 if (count($table_alters) > 0) {
149 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
150 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
151 $result .= PMA_DBI_query($sql_query) ? true : false;
152 $reread_info = true;
153 unset($table_alters);
154 foreach (PMA_DBI_get_warnings() as $warning) {
155 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
156 . ' ' . $warning['Message'];
161 * Reordering the table has been requested by the user
163 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
164 $sql_query = '
165 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
166 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
167 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
168 $sql_query .= ' DESC';
170 $result = PMA_DBI_query($sql_query);
171 } // end if
174 * A partition operation has been requested by the user
176 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
177 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
178 $result = PMA_DBI_query($sql_query);
179 } // end if
181 if ($reread_info) {
182 $page_checksum = $checksum = $delay_key_write = 0;
183 require './libraries/tbl_info.inc.php';
185 unset($reread_info);
188 * Displays top menu links
190 require_once './libraries/tbl_links.inc.php';
192 if (isset($result)) {
193 // set to success by default, because result set could be empty
194 // (for example, a table rename)
195 $_type = 'success';
196 if (empty($_message)) {
197 $_message = $result ? $strSuccess : $strError;
198 // $result should exist, regardless of $_message
199 $_type = $result ? 'success' : 'error';
201 if (! empty($warning_messages)) {
202 $_message = new PMA_Message;
203 $_message->addMessages($warning_messages);
204 $_message->isWarning(true);
205 unset($warning_messages);
207 PMA_showMessage($_message, $sql_query, $_type);
208 unset($_message, $_type);
211 $url_params['goto'] = 'tbl_operations.php';
212 $url_params['back'] = 'tbl_operations.php';
215 * Get columns names
217 $local_query = '
218 SHOW COLUMNS
219 FROM ' . PMA_backquote($GLOBALS['table']) . '
220 FROM ' . PMA_backquote($GLOBALS['db']);
221 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
222 unset($local_query);
225 * Displays the page
228 <!-- Order the table -->
229 <div id="div_table_order">
230 <form method="post" action="tbl_operations.php">
231 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
232 <fieldset id="fieldset_table_order">
233 <legend><?php echo $strAlterOrderBy; ?></legend>
234 <select name="order_field">
235 <?php
236 foreach ($columns as $fieldname) {
237 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
238 . htmlspecialchars($fieldname) . '</option>' . "\n";
240 unset($columns);
242 </select> <?php echo $strSingly; ?>
243 <select name="order_order">
244 <option value="asc"><?php echo $strAscending; ?></option>
245 <option value="desc"><?php echo $strDescending; ?></option>
246 </select>
247 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" />
248 </fieldset>
249 </form>
250 </div>
252 <!-- Move table -->
253 <div id="div_table_rename">
254 <form method="post" action="tbl_move_copy.php"
255 onsubmit="return emptyFormElements(this, 'new_name')">
256 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
257 <input type="hidden" name="reload" value="1" />
258 <input type="hidden" name="what" value="data" />
259 <fieldset id="fieldset_table_rename">
260 <legend><?php echo $strMoveTable; ?></legend>
261 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
263 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
264 <?php
265 } else {
267 <select name="target_db">
268 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
269 </select>
270 <?php
271 } // end if
273 &nbsp;<b>.</b>&nbsp;
274 <input type="text" size="20" name="new_name" onfocus="this.select()"
275 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
276 <?php
277 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
278 // next value but users can decide if they want it or not for the operation
280 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
281 <label for="checkbox_auto_increment_mv"><?php echo $strAddAutoIncrement; ?></label><br />
282 </fieldset>
283 <fieldset class="tblFooters">
284 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
285 </fieldset>
286 </form>
287 </div>
289 <?php
290 if (strstr($show_comment, '; InnoDB free') === false) {
291 if (strstr($show_comment, 'InnoDB free') === false) {
292 // only user entered comment
293 $comment = $show_comment;
294 } else {
295 // here we have just InnoDB generated part
296 $comment = '';
298 } else {
299 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
300 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
303 // PACK_KEYS: MyISAM or ISAM
304 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
305 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
307 // nijel: Here should be version check for InnoDB, however it is supported
308 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
309 // check for version
312 <!-- Table options -->
313 <div id="div_table_options">
314 <form method="post" action="tbl_operations.php">
315 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
316 <input type="hidden" name="reload" value="1" />
317 <fieldset>
318 <legend><?php echo $strTableOptions; ?></legend>
320 <table>
321 <!-- Change table name -->
322 <tr><td><?php echo $strRenameTable; ?></td>
323 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
324 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
325 </td>
326 </tr>
328 <!-- Table comments -->
329 <tr><td><?php echo $strTableComments; ?></td>
330 <td><input type="text" name="comment" maxlength="60" size="30"
331 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
332 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
333 </td>
334 </tr>
336 <!-- Storage engine -->
337 <tr><td><?php echo $strStorageEngine; ?>
338 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
339 </td>
340 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
341 </td>
342 </tr>
344 <!-- Table character set -->
345 <tr><td><?php echo $strCollation; ?></td>
346 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
347 'tbl_collation', null, $tbl_collation, false, 3); ?>
348 </td>
349 </tr>
350 <?php
351 if ($is_myisam_or_maria || $is_isam) {
353 <tr>
354 <td><label for="new_pack_keys">PACK_KEYS</label></td>
355 <td><select name="new_pack_keys" id="new_pack_keys">
356 <option value="DEFAULT"
357 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
358 >DEFAULT</option>
359 <option value="0"
360 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
361 >0</option>
362 <option value="1"
363 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
364 >1</option>
365 </select>
366 </td>
367 </tr>
368 <?php
369 } // end if (MYISAM|ISAM)
371 if ($is_myisam_or_maria) {
373 <tr><td><label for="new_checksum">CHECKSUM</label></td>
374 <td><input type="checkbox" name="new_checksum" id="new_checksum"
375 value="1"
376 <?php echo (isset($checksum) && $checksum == 1)
377 ? ' checked="checked"'
378 : ''; ?> />
379 </td>
380 </tr>
382 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
383 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
384 value="1"
385 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
386 ? ' checked="checked"'
387 : ''; ?> />
388 </td>
389 </tr>
391 <?php
392 } // end if (MYISAM)
394 if ($is_maria) {
396 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
397 <td><input type="checkbox" name="new_transactional" id="new_transactional"
398 value="1"
399 <?php echo (isset($transactional) && $transactional == 1)
400 ? ' checked="checked"'
401 : ''; ?> />
402 </td>
403 </tr>
405 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
406 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
407 value="1"
408 <?php echo (isset($page_checksum) && $page_checksum == 1)
409 ? ' checked="checked"'
410 : ''; ?> />
411 </td>
412 </tr>
414 <?php
415 } // end if (MARIA)
417 if (isset($auto_increment) && strlen($auto_increment) > 0
418 && ($is_myisam_or_maria || $is_innodb || $is_pbxt)) {
420 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
421 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
422 value="<?php echo $auto_increment; ?>" /></td>
423 </tr>
424 <?php
425 } // end if (MYISAM|INNODB)
427 $possible_row_formats = array(
428 'MARIA' => array('FIXED','DYNAMIC','PAGE'),
429 'MYISAM' => array('FIXED','DYNAMIC'),
430 'PBXT' => array('FIXED','DYNAMIC'),
431 'INNODB' => array('COMPACT','REDUNDANT')
433 // for MYISAM there is also COMPRESSED but it can be set only by the
434 // myisampack utility, so don't offer here the choice because if we
435 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
436 // does not return a warning
437 // (if the table was compressed, it can be seen on the Structure page)
439 if (isset($possible_row_formats[$tbl_type])) {
440 $current_row_format = strtoupper($showtable['Row_format']);
441 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
442 echo '<td>';
443 PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format);
444 unset($possible_row_formats, $current_row_format);
445 echo '</td>';
446 echo '</tr>';
449 </table>
450 </fieldset>
451 <fieldset class="tblFooters">
452 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
453 </fieldset>
454 </form>
455 </div>
457 <!-- Copy table -->
458 <div id="div_table_copy">
459 <form method="post" action="tbl_move_copy.php"
460 onsubmit="return emptyFormElements(this, 'new_name')">
461 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
462 <input type="hidden" name="reload" value="1" />
463 <fieldset>
464 <legend><?php echo $strCopyTable; ?></legend>
465 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
467 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
468 <?php
469 } else {
471 <select name="target_db">
472 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
473 </select>
474 <?php
475 } // end if
477 &nbsp;<b>.</b>&nbsp;
478 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
479 <?php
480 $choices = array(
481 'structure' => $strStrucOnly,
482 'data' => $strStrucData,
483 'dataonly' => $strDataOnly);
484 PMA_generate_html_radio('what', $choices, 'data', true);
485 unset($choices);
488 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
489 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
490 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
491 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
492 <?php
493 // display "Add constraints" choice only if there are
494 // foreign keys
495 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
497 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
498 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
499 <?php
500 } // endif
501 if (isset($_COOKIE['pma_switch_to_new'])
502 && $_COOKIE['pma_switch_to_new'] == 'true') {
503 $pma_switch_to_new = 'true';
506 <input type="checkbox" name="switch_to_new" value="true"
507 id="checkbox_switch"<?php echo
508 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
509 ? ' checked="checked"'
510 : ''; ?> />
511 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
512 </fieldset>
513 <fieldset class="tblFooters">
514 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
515 </fieldset>
516 </form>
517 </div>
519 <br class="clearfloat"/>
521 <div id="div_table_maintenance">
522 <fieldset>
523 <legend><?php echo $strTableMaintenance; ?></legend>
525 <ul>
526 <?php
527 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
528 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
529 if ($is_myisam_or_maria || $is_innodb) {
530 $this_url_params = array_merge($url_params,
531 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
533 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
534 <?php echo $strCheckTable; ?></a>
535 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
536 </li>
537 <?php
539 if ($is_innodb) {
540 $this_url_params = array_merge($url_params,
541 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
543 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
544 <?php echo $strDefragment; ?></a>
545 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
546 </li>
547 <?php
549 if ($is_myisam_or_maria || $is_berkeleydb) {
550 $this_url_params = array_merge($url_params,
551 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
553 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
554 <?php echo $strAnalyzeTable; ?></a>
555 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
556 </li>
557 <?php
559 if ($is_myisam_or_maria) {
560 $this_url_params = array_merge($url_params,
561 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
563 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
564 <?php echo $strRepairTable; ?></a>
565 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
566 </li>
567 <?php
569 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
570 $this_url_params = array_merge($url_params,
571 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
573 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
574 <?php echo $strOptimizeTable; ?></a>
575 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
576 </li>
577 <?php
579 } // end MYISAM or BERKELEYDB case
580 $this_url_params = array_merge($url_params,
581 array(
582 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
583 'zero_rows' => sprintf($strTableHasBeenFlushed,
584 htmlspecialchars($GLOBALS['table'])),
585 'reload' => 1,
588 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
589 <?php echo $strFlushTable; ?></a>
590 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
591 </li>
592 </ul>
593 </fieldset>
594 </div>
595 <?php if (PMA_Partition::havePartitioning()) {
596 $partition_names = PMA_Partition::getPartitionNames($db, $table);
597 // show the Partition maintenance section only if we detect a partition
598 if (! is_null($partition_names[0])) {
600 <div id="div_partition_maintenance">
601 <form method="post" action="tbl_operations.php">
602 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
603 <fieldset>
604 <legend><?php echo $strPartitionMaintenance; ?></legend>
605 <?php
606 $html_select = '<select name="partition_name">' . "\n";
607 foreach($partition_names as $one_partition) {
608 $one_partition = htmlspecialchars($one_partition);
609 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
611 $html_select .= '</select>' . "\n";
612 printf($GLOBALS['strPartition'], $html_select);
613 unset($partition_names, $one_partition, $html_select);
614 $choices = array(
615 'ANALYZE' => $strAnalyze,
616 'CHECK' => $strCheck,
617 'OPTIMIZE' => $strOptimize,
618 'REBUILD' => $strRebuild,
619 'REPAIR' => $strRepair);
620 PMA_generate_html_radio('partition_operation', $choices, '', false);
621 unset($choices);
622 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
623 // I'm not sure of the best way to display that; this link does
624 // not depend on the Go button
625 $this_url_params = array_merge($url_params,
626 array(
627 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
630 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
631 <?php echo $strRemovePartitioning; ?></a>
632 </fieldset>
633 <fieldset class="tblFooters">
634 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
635 </fieldset>
636 </form>
637 </div>
638 <?php
639 } // end if
640 } // end if
642 // Referential integrity check
643 // The Referential integrity check was intended for the non-InnoDB
644 // tables for which the relations are defined in pmadb
645 // so I assume that if the current table is InnoDB, I don't display
646 // this choice (InnoDB maintains integrity by itself)
648 if ($cfgRelation['relwork'] && ! $is_innodb) {
649 PMA_DBI_select_db($GLOBALS['db']);
650 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
652 if ($foreign) {
654 <!-- Referential integrity check -->
655 <div id="div_referential_integrity">
656 <fieldset>
657 <legend><?php echo $strReferentialIntegrity; ?></legend>
658 <ul>
659 <?php
660 echo "\n";
661 foreach ($foreign AS $master => $arr) {
662 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
663 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
664 . PMA_backquote($arr['foreign_table']);
665 if ($arr['foreign_table'] == $GLOBALS['table']) {
666 $foreign_table = $GLOBALS['table'] . '1';
667 $join_query .= ' AS ' . PMA_backquote($foreign_table);
668 } else {
669 $foreign_table = $arr['foreign_table'];
671 $join_query .= ' ON '
672 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
673 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
674 . ' WHERE '
675 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
676 . ' IS NULL AND '
677 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
678 . ' IS NOT NULL';
679 $this_url_params = array_merge($url_params,
680 array('sql_query' => $join_query));
681 echo ' <li>'
682 . '<a href="sql.php'
683 . PMA_generate_common_url($this_url_params)
684 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
685 . '</a></li>' . "\n";
686 } // foreach $foreign
687 unset($foreign_table, $join_query);
689 </ul>
690 </fieldset>
691 </div>
692 <?php
693 } // end if ($foreign)
695 } // end if (!empty($cfg['Server']['relation']))
699 * Displays the footer
701 require_once './libraries/footer.inc.php';
704 function PMA_set_global_variables_for_engine($tbl_type)
706 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
708 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
709 $upper_tbl_type = strtoupper($tbl_type);
711 //Options that apply to MYISAM usually apply to MARIA
712 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
713 $is_maria = ($upper_tbl_type == 'MARIA');
715 $is_isam = ($upper_tbl_type == 'ISAM');
716 $is_innodb = ($upper_tbl_type == 'INNODB');
717 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
718 $is_pbxt = ($upper_tbl_type == 'PBXT');