rfe #1927189 strip ` from column names on import
[phpmyadmin/crack.git] / tbl_operations.php
blobb6dd060a0f1bcf37d8cb64962acd9da5d42d5f6f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
13 require_once './libraries/Table.class.php';
15 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
17 /**
18 * Runs common work
20 require './libraries/tbl_common.php';
21 $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
22 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
24 /**
25 * Gets relation settings
27 require_once './libraries/relation.lib.php';
28 $cfgRelation = PMA_getRelationsParam();
30 /**
31 * Gets available MySQL charsets and storage engines
33 require_once './libraries/mysql_charsets.lib.php';
34 require_once './libraries/StorageEngine.class.php';
36 /**
37 * Class for partition management
39 require_once './libraries/Partition.class.php';
41 // reselect current db (needed in some cases probably due to
42 // the calling of relation.lib.php)
43 PMA_DBI_select_db($GLOBALS['db']);
45 /**
46 * Gets tables informations
49 require './libraries/tbl_info.inc.php';
51 // define some globals here, for improved syntax in the conditionals
52 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
53 // set initial value of these globals, based on the current table engine
54 PMA_set_global_variables_for_engine($tbl_type);
56 if ($is_maria) {
57 // the value for transactional can be implicit
58 // (no create option found, in this case it means 1)
59 // or explicit (option found with a value of 0 or 1)
60 // ($transactional may have been set by libraries/tbl_info.inc.php,
61 // from the $create_options)
62 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
63 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
66 $reread_info = false;
67 $table_alters = array();
69 /**
70 * Updates table comment, type and options if required
72 if (isset($_REQUEST['submitoptions'])) {
73 $_message = '';
74 $warning_messages = array();
76 if (isset($_REQUEST['new_name'])) {
77 if ($pma_table->rename($_REQUEST['new_name'])) {
78 $_message .= $pma_table->getLastMessage();
79 $result = true;
80 $GLOBALS['table'] = $pma_table->getName();
81 $reread_info = true;
82 $reload = true;
83 } else {
84 $_message .= $pma_table->getLastError();
85 $result = false;
88 if (isset($_REQUEST['comment'])
89 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
90 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
92 if (! empty($_REQUEST['new_tbl_type'])
93 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
94 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
95 $tbl_type = $_REQUEST['new_tbl_type'];
96 // reset the globals for the new engine
97 PMA_set_global_variables_for_engine($tbl_type);
100 if (! empty($_REQUEST['tbl_collation'])
101 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
102 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
105 if (($is_myisam_or_maria || $is_isam)
106 && isset($_REQUEST['new_pack_keys'])
107 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
108 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
111 $checksum = empty($checksum) ? '0' : '1';
112 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
113 if ($is_myisam_or_maria
114 && $_REQUEST['new_checksum'] !== $checksum) {
115 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
118 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
119 if ($is_maria
120 && $_REQUEST['new_transactional'] !== $transactional) {
121 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
124 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
125 if ($is_maria
126 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
127 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
130 $delay_key_write = empty($delay_key_write) ? '0' : '1';
131 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
132 if ($is_myisam_or_maria
133 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
134 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
137 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
138 && ! empty($_REQUEST['new_auto_increment'])
139 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
140 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
143 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
144 && ! empty($_REQUEST['new_row_format'])
145 && (! isset($row_format) || $_REQUEST['new_row_format'] !== $row_format)) {
146 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
149 if (count($table_alters) > 0) {
150 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
151 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
152 $result .= PMA_DBI_query($sql_query) ? true : false;
153 $reread_info = true;
154 unset($table_alters);
155 foreach (PMA_DBI_get_warnings() as $warning) {
156 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
157 . ' ' . $warning['Message'];
162 * Reordering the table has been requested by the user
164 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
165 $sql_query = '
166 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
167 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
168 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
169 $sql_query .= ' DESC';
171 $result = PMA_DBI_query($sql_query);
172 } // end if
175 * A partition operation has been requested by the user
177 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
178 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
179 $result = PMA_DBI_query($sql_query);
180 } // end if
182 if ($reread_info) {
183 $page_checksum = $checksum = $delay_key_write = 0;
184 require './libraries/tbl_info.inc.php';
186 unset($reread_info);
189 * Displays top menu links
191 require_once './libraries/tbl_links.inc.php';
193 if (isset($result)) {
194 // set to success by default, because result set could be empty
195 // (for example, a table rename)
196 $_type = 'success';
197 if (empty($_message)) {
198 $_message = $result ? $strSuccess : $strError;
199 // $result should exist, regardless of $_message
200 $_type = $result ? 'success' : 'error';
202 if (! empty($warning_messages)) {
203 $_message = new PMA_Message;
204 $_message->addMessages($warning_messages);
205 $_message->isWarning(true);
206 unset($warning_messages);
208 PMA_showMessage($_message, $sql_query, $_type);
209 unset($_message, $_type);
212 $url_params['goto'] = 'tbl_operations.php';
213 $url_params['back'] = 'tbl_operations.php';
216 * Get columns names
218 $local_query = '
219 SHOW COLUMNS
220 FROM ' . PMA_backquote($GLOBALS['table']) . '
221 FROM ' . PMA_backquote($GLOBALS['db']);
222 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
223 unset($local_query);
226 * Displays the page
229 <!-- Order the table -->
230 <div id="div_table_order">
231 <form method="post" action="tbl_operations.php">
232 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
233 <fieldset id="fieldset_table_order">
234 <legend><?php echo $strAlterOrderBy; ?></legend>
235 <select name="order_field">
236 <?php
237 foreach ($columns as $fieldname) {
238 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
239 . htmlspecialchars($fieldname) . '</option>' . "\n";
241 unset($columns);
243 </select> <?php echo $strSingly; ?>
244 <select name="order_order">
245 <option value="asc"><?php echo $strAscending; ?></option>
246 <option value="desc"><?php echo $strDescending; ?></option>
247 </select>
248 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" />
249 </fieldset>
250 </form>
251 </div>
253 <!-- Move table -->
254 <div id="div_table_rename">
255 <form method="post" action="tbl_move_copy.php"
256 onsubmit="return emptyFormElements(this, 'new_name')">
257 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
258 <input type="hidden" name="reload" value="1" />
259 <input type="hidden" name="what" value="data" />
260 <fieldset id="fieldset_table_rename">
261 <legend><?php echo $strMoveTable; ?></legend>
262 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
264 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
265 <?php
266 } else {
268 <select name="target_db">
269 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
270 </select>
271 <?php
272 } // end if
274 &nbsp;<strong>.</strong>&nbsp;
275 <input type="text" size="20" name="new_name" onfocus="this.select()"
276 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
277 <?php
278 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
279 // next value but users can decide if they want it or not for the operation
281 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
282 <label for="checkbox_auto_increment_mv"><?php echo $strAddAutoIncrement; ?></label><br />
283 </fieldset>
284 <fieldset class="tblFooters">
285 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
286 </fieldset>
287 </form>
288 </div>
290 <?php
291 if (strstr($show_comment, '; InnoDB free') === false) {
292 if (strstr($show_comment, 'InnoDB free') === false) {
293 // only user entered comment
294 $comment = $show_comment;
295 } else {
296 // here we have just InnoDB generated part
297 $comment = '';
299 } else {
300 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
301 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
304 // PACK_KEYS: MyISAM or ISAM
305 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
306 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
308 // nijel: Here should be version check for InnoDB, however it is supported
309 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
310 // check for version
313 <!-- Table options -->
314 <div id="div_table_options">
315 <form method="post" action="tbl_operations.php">
316 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
317 <input type="hidden" name="reload" value="1" />
318 <fieldset>
319 <legend><?php echo $strTableOptions; ?></legend>
321 <table>
322 <!-- Change table name -->
323 <tr><td><?php echo $strRenameTable; ?></td>
324 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
325 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
326 </td>
327 </tr>
329 <!-- Table comments -->
330 <tr><td><?php echo $strTableComments; ?></td>
331 <td><input type="text" name="comment" maxlength="60" size="30"
332 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
333 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
334 </td>
335 </tr>
337 <!-- Storage engine -->
338 <tr><td><?php echo $strStorageEngine; ?>
339 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
340 </td>
341 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
342 </td>
343 </tr>
345 <!-- Table character set -->
346 <tr><td><?php echo $strCollation; ?></td>
347 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
348 'tbl_collation', null, $tbl_collation, false, 3); ?>
349 </td>
350 </tr>
351 <?php
352 if ($is_myisam_or_maria || $is_isam) {
354 <tr>
355 <td><label for="new_pack_keys">PACK_KEYS</label></td>
356 <td><select name="new_pack_keys" id="new_pack_keys">
357 <option value="DEFAULT"
358 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
359 >DEFAULT</option>
360 <option value="0"
361 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
362 >0</option>
363 <option value="1"
364 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
365 >1</option>
366 </select>
367 </td>
368 </tr>
369 <?php
370 } // end if (MYISAM|ISAM)
372 if ($is_myisam_or_maria) {
374 <tr><td><label for="new_checksum">CHECKSUM</label></td>
375 <td><input type="checkbox" name="new_checksum" id="new_checksum"
376 value="1"
377 <?php echo (isset($checksum) && $checksum == 1)
378 ? ' checked="checked"'
379 : ''; ?> />
380 </td>
381 </tr>
383 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
384 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
385 value="1"
386 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
387 ? ' checked="checked"'
388 : ''; ?> />
389 </td>
390 </tr>
392 <?php
393 } // end if (MYISAM)
395 if ($is_maria) {
397 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
398 <td><input type="checkbox" name="new_transactional" id="new_transactional"
399 value="1"
400 <?php echo (isset($transactional) && $transactional == 1)
401 ? ' checked="checked"'
402 : ''; ?> />
403 </td>
404 </tr>
406 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
407 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
408 value="1"
409 <?php echo (isset($page_checksum) && $page_checksum == 1)
410 ? ' checked="checked"'
411 : ''; ?> />
412 </td>
413 </tr>
415 <?php
416 } // end if (MARIA)
418 if (isset($auto_increment) && strlen($auto_increment) > 0
419 && ($is_myisam_or_maria || $is_innodb || $is_pbxt)) {
421 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
422 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
423 value="<?php echo $auto_increment; ?>" /></td>
424 </tr>
425 <?php
426 } // end if (MYISAM|INNODB)
428 $possible_row_formats = array(
429 'MARIA' => array('FIXED','DYNAMIC','PAGE'),
430 'MYISAM' => array('FIXED','DYNAMIC'),
431 'PBXT' => array('FIXED','DYNAMIC'),
432 'INNODB' => array('COMPACT','REDUNDANT')
434 // for MYISAM there is also COMPRESSED but it can be set only by the
435 // myisampack utility, so don't offer here the choice because if we
436 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
437 // does not return a warning
438 // (if the table was compressed, it can be seen on the Structure page)
440 if (isset($possible_row_formats[$tbl_type])) {
441 $current_row_format = strtoupper($showtable['Row_format']);
442 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
443 echo '<td>';
444 PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format);
445 unset($possible_row_formats, $current_row_format);
446 echo '</td>';
447 echo '</tr>';
450 </table>
451 </fieldset>
452 <fieldset class="tblFooters">
453 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
454 </fieldset>
455 </form>
456 </div>
458 <!-- Copy table -->
459 <div id="div_table_copy">
460 <form method="post" action="tbl_move_copy.php"
461 onsubmit="return emptyFormElements(this, 'new_name')">
462 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
463 <input type="hidden" name="reload" value="1" />
464 <fieldset>
465 <legend><?php echo $strCopyTable; ?></legend>
466 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
468 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
469 <?php
470 } else {
472 <select name="target_db">
473 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
474 </select>
475 <?php
476 } // end if
478 &nbsp;<strong>.</strong>&nbsp;
479 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
480 <?php
481 $choices = array(
482 'structure' => $strStrucOnly,
483 'data' => $strStrucData,
484 'dataonly' => $strDataOnly);
485 PMA_generate_html_radio('what', $choices, 'data', true);
486 unset($choices);
489 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
490 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
491 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
492 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
493 <?php
494 // display "Add constraints" choice only if there are
495 // foreign keys
496 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
498 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
499 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
500 <?php
501 } // endif
502 if (isset($_COOKIE['pma_switch_to_new'])
503 && $_COOKIE['pma_switch_to_new'] == 'true') {
504 $pma_switch_to_new = 'true';
507 <input type="checkbox" name="switch_to_new" value="true"
508 id="checkbox_switch"<?php echo
509 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
510 ? ' checked="checked"'
511 : ''; ?> />
512 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
513 </fieldset>
514 <fieldset class="tblFooters">
515 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
516 </fieldset>
517 </form>
518 </div>
520 <br class="clearfloat"/>
522 <div id="div_table_maintenance">
523 <fieldset>
524 <legend><?php echo $strTableMaintenance; ?></legend>
526 <ul>
527 <?php
528 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
529 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
530 if ($is_myisam_or_maria || $is_innodb) {
531 $this_url_params = array_merge($url_params,
532 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
534 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
535 <?php echo $strCheckTable; ?></a>
536 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
537 </li>
538 <?php
540 if ($is_innodb) {
541 $this_url_params = array_merge($url_params,
542 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
544 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
545 <?php echo $strDefragment; ?></a>
546 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
547 </li>
548 <?php
550 if ($is_myisam_or_maria || $is_berkeleydb) {
551 $this_url_params = array_merge($url_params,
552 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
554 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
555 <?php echo $strAnalyzeTable; ?></a>
556 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
557 </li>
558 <?php
560 if ($is_myisam_or_maria) {
561 $this_url_params = array_merge($url_params,
562 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
564 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
565 <?php echo $strRepairTable; ?></a>
566 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
567 </li>
568 <?php
570 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
571 $this_url_params = array_merge($url_params,
572 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
574 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
575 <?php echo $strOptimizeTable; ?></a>
576 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
577 </li>
578 <?php
580 } // end MYISAM or BERKELEYDB case
581 $this_url_params = array_merge($url_params,
582 array(
583 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
584 'zero_rows' => sprintf($strTableHasBeenFlushed,
585 htmlspecialchars($GLOBALS['table'])),
586 'reload' => 1,
589 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
590 <?php echo $strFlushTable; ?></a>
591 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
592 </li>
593 </ul>
594 </fieldset>
595 </div>
596 <?php if (PMA_Partition::havePartitioning()) {
597 $partition_names = PMA_Partition::getPartitionNames($db, $table);
598 // show the Partition maintenance section only if we detect a partition
599 if (! is_null($partition_names[0])) {
601 <div id="div_partition_maintenance">
602 <form method="post" action="tbl_operations.php">
603 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
604 <fieldset>
605 <legend><?php echo $strPartitionMaintenance; ?></legend>
606 <?php
607 $html_select = '<select name="partition_name">' . "\n";
608 foreach($partition_names as $one_partition) {
609 $one_partition = htmlspecialchars($one_partition);
610 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
612 $html_select .= '</select>' . "\n";
613 printf($GLOBALS['strPartition'], $html_select);
614 unset($partition_names, $one_partition, $html_select);
615 $choices = array(
616 'ANALYZE' => $strAnalyze,
617 'CHECK' => $strCheck,
618 'OPTIMIZE' => $strOptimize,
619 'REBUILD' => $strRebuild,
620 'REPAIR' => $strRepair);
621 PMA_generate_html_radio('partition_operation', $choices, '', false);
622 unset($choices);
623 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
624 // I'm not sure of the best way to display that; this link does
625 // not depend on the Go button
626 $this_url_params = array_merge($url_params,
627 array(
628 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
631 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
632 <?php echo $strRemovePartitioning; ?></a>
633 </fieldset>
634 <fieldset class="tblFooters">
635 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
636 </fieldset>
637 </form>
638 </div>
639 <?php
640 } // end if
641 } // end if
643 // Referential integrity check
644 // The Referential integrity check was intended for the non-InnoDB
645 // tables for which the relations are defined in pmadb
646 // so I assume that if the current table is InnoDB, I don't display
647 // this choice (InnoDB maintains integrity by itself)
649 if ($cfgRelation['relwork'] && ! $is_innodb) {
650 PMA_DBI_select_db($GLOBALS['db']);
651 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
653 if ($foreign) {
655 <!-- Referential integrity check -->
656 <div id="div_referential_integrity">
657 <fieldset>
658 <legend><?php echo $strReferentialIntegrity; ?></legend>
659 <ul>
660 <?php
661 echo "\n";
662 foreach ($foreign AS $master => $arr) {
663 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
664 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
665 . PMA_backquote($arr['foreign_table']);
666 if ($arr['foreign_table'] == $GLOBALS['table']) {
667 $foreign_table = $GLOBALS['table'] . '1';
668 $join_query .= ' AS ' . PMA_backquote($foreign_table);
669 } else {
670 $foreign_table = $arr['foreign_table'];
672 $join_query .= ' ON '
673 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
674 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
675 . ' WHERE '
676 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
677 . ' IS NULL AND '
678 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
679 . ' IS NOT NULL';
680 $this_url_params = array_merge($url_params,
681 array('sql_query' => $join_query));
682 echo ' <li>'
683 . '<a href="sql.php'
684 . PMA_generate_common_url($this_url_params)
685 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
686 . '</a></li>' . "\n";
687 } // foreach $foreign
688 unset($foreign_table, $join_query);
690 </ul>
691 </fieldset>
692 </div>
693 <?php
694 } // end if ($foreign)
696 } // end if (!empty($cfg['Server']['relation']))
700 * Displays the footer
702 require_once './libraries/footer.inc.php';
705 function PMA_set_global_variables_for_engine($tbl_type)
707 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
709 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
710 $upper_tbl_type = strtoupper($tbl_type);
712 //Options that apply to MYISAM usually apply to MARIA
713 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
714 $is_maria = ($upper_tbl_type == 'MARIA');
716 $is_isam = ($upper_tbl_type == 'ISAM');
717 $is_innodb = ($upper_tbl_type == 'INNODB');
718 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
719 $is_pbxt = ($upper_tbl_type == 'PBXT');