BLOB streaming clarification
[phpmyadmin/crack.git] / tbl_operations.php
blobab61cc0439f84defafa85ecd3635ee4edf9f58e0
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) || strtolower($_REQUEST['new_row_format']) !== strtolower($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 // to avoid showing the old value (for example the AUTO_INCREMENT) after
184 // a change, clear the cache
185 PMA_Table::$cache = array();
186 $page_checksum = $checksum = $delay_key_write = 0;
187 require './libraries/tbl_info.inc.php';
189 unset($reread_info);
192 * Displays top menu links
194 require_once './libraries/tbl_links.inc.php';
196 if (isset($result)) {
197 // set to success by default, because result set could be empty
198 // (for example, a table rename)
199 $_type = 'success';
200 if (empty($_message)) {
201 $_message = $result ? $strSuccess : $strError;
202 // $result should exist, regardless of $_message
203 $_type = $result ? 'success' : 'error';
205 if (! empty($warning_messages)) {
206 $_message = new PMA_Message;
207 $_message->addMessages($warning_messages);
208 $_message->isWarning(true);
209 unset($warning_messages);
211 PMA_showMessage($_message, $sql_query, $_type);
212 unset($_message, $_type);
215 $url_params['goto'] = 'tbl_operations.php';
216 $url_params['back'] = 'tbl_operations.php';
219 * Get columns names
221 $local_query = '
222 SHOW COLUMNS
223 FROM ' . PMA_backquote($GLOBALS['table']) . '
224 FROM ' . PMA_backquote($GLOBALS['db']);
225 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
226 unset($local_query);
229 * Displays the page
232 <!-- Order the table -->
233 <div id="div_table_order">
234 <form method="post" action="tbl_operations.php">
235 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
236 <fieldset id="fieldset_table_order">
237 <legend><?php echo $strAlterOrderBy; ?></legend>
238 <select name="order_field">
239 <?php
240 foreach ($columns as $fieldname) {
241 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
242 . htmlspecialchars($fieldname) . '</option>' . "\n";
244 unset($columns);
246 </select> <?php echo $strSingly; ?>
247 <select name="order_order">
248 <option value="asc"><?php echo $strAscending; ?></option>
249 <option value="desc"><?php echo $strDescending; ?></option>
250 </select>
251 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" />
252 </fieldset>
253 </form>
254 </div>
256 <!-- Move table -->
257 <div id="div_table_rename">
258 <form method="post" action="tbl_move_copy.php"
259 onsubmit="return emptyFormElements(this, 'new_name')">
260 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
261 <input type="hidden" name="reload" value="1" />
262 <input type="hidden" name="what" value="data" />
263 <fieldset id="fieldset_table_rename">
264 <legend><?php echo $strMoveTable; ?></legend>
265 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
267 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
268 <?php
269 } else {
271 <select name="target_db">
272 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
273 </select>
274 <?php
275 } // end if
277 &nbsp;<strong>.</strong>&nbsp;
278 <input type="text" size="20" name="new_name" onfocus="this.select()"
279 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
280 <?php
281 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
282 // next value but users can decide if they want it or not for the operation
284 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
285 <label for="checkbox_auto_increment_mv"><?php echo $strAddAutoIncrement; ?></label><br />
286 </fieldset>
287 <fieldset class="tblFooters">
288 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
289 </fieldset>
290 </form>
291 </div>
293 <?php
294 if (strstr($show_comment, '; InnoDB free') === false) {
295 if (strstr($show_comment, 'InnoDB free') === false) {
296 // only user entered comment
297 $comment = $show_comment;
298 } else {
299 // here we have just InnoDB generated part
300 $comment = '';
302 } else {
303 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
304 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
307 // PACK_KEYS: MyISAM or ISAM
308 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
309 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
311 // nijel: Here should be version check for InnoDB, however it is supported
312 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
313 // check for version
316 <!-- Table options -->
317 <div id="div_table_options">
318 <form method="post" action="tbl_operations.php">
319 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
320 <input type="hidden" name="reload" value="1" />
321 <fieldset>
322 <legend><?php echo $strTableOptions; ?></legend>
324 <table>
325 <!-- Change table name -->
326 <tr><td><?php echo $strRenameTable; ?></td>
327 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
328 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
329 </td>
330 </tr>
332 <!-- Table comments -->
333 <tr><td><?php echo $strTableComments; ?></td>
334 <td><input type="text" name="comment" maxlength="60" size="30"
335 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
336 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
337 </td>
338 </tr>
340 <!-- Storage engine -->
341 <tr><td><?php echo $strStorageEngine; ?>
342 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
343 </td>
344 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
345 </td>
346 </tr>
348 <!-- Table character set -->
349 <tr><td><?php echo $strCollation; ?></td>
350 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
351 'tbl_collation', null, $tbl_collation, false, 3); ?>
352 </td>
353 </tr>
354 <?php
355 if ($is_myisam_or_maria || $is_isam) {
357 <tr>
358 <td><label for="new_pack_keys">PACK_KEYS</label></td>
359 <td><select name="new_pack_keys" id="new_pack_keys">
360 <option value="DEFAULT"
361 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
362 >DEFAULT</option>
363 <option value="0"
364 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
365 >0</option>
366 <option value="1"
367 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
368 >1</option>
369 </select>
370 </td>
371 </tr>
372 <?php
373 } // end if (MYISAM|ISAM)
375 if ($is_myisam_or_maria) {
377 <tr><td><label for="new_checksum">CHECKSUM</label></td>
378 <td><input type="checkbox" name="new_checksum" id="new_checksum"
379 value="1"
380 <?php echo (isset($checksum) && $checksum == 1)
381 ? ' checked="checked"'
382 : ''; ?> />
383 </td>
384 </tr>
386 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
387 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
388 value="1"
389 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
390 ? ' checked="checked"'
391 : ''; ?> />
392 </td>
393 </tr>
395 <?php
396 } // end if (MYISAM)
398 if ($is_maria) {
400 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
401 <td><input type="checkbox" name="new_transactional" id="new_transactional"
402 value="1"
403 <?php echo (isset($transactional) && $transactional == 1)
404 ? ' checked="checked"'
405 : ''; ?> />
406 </td>
407 </tr>
409 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
410 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
411 value="1"
412 <?php echo (isset($page_checksum) && $page_checksum == 1)
413 ? ' checked="checked"'
414 : ''; ?> />
415 </td>
416 </tr>
418 <?php
419 } // end if (MARIA)
421 if (isset($auto_increment) && strlen($auto_increment) > 0
422 && ($is_myisam_or_maria || $is_innodb || $is_pbxt)) {
424 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
425 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
426 value="<?php echo $auto_increment; ?>" /></td>
427 </tr>
428 <?php
429 } // end if (MYISAM|INNODB)
431 $possible_row_formats = array(
432 'MARIA' => array('FIXED','DYNAMIC','PAGE'),
433 'MYISAM' => array('FIXED','DYNAMIC'),
434 'PBXT' => array('FIXED','DYNAMIC'),
435 'INNODB' => array('COMPACT','REDUNDANT')
437 // for MYISAM there is also COMPRESSED but it can be set only by the
438 // myisampack utility, so don't offer here the choice because if we
439 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
440 // does not return a warning
441 // (if the table was compressed, it can be seen on the Structure page)
443 if (isset($possible_row_formats[$tbl_type])) {
444 $current_row_format = strtoupper($showtable['Row_format']);
445 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
446 echo '<td>';
447 PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format);
448 unset($possible_row_formats, $current_row_format);
449 echo '</td>';
450 echo '</tr>';
453 </table>
454 </fieldset>
455 <fieldset class="tblFooters">
456 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
457 </fieldset>
458 </form>
459 </div>
461 <!-- Copy table -->
462 <div id="div_table_copy">
463 <form method="post" action="tbl_move_copy.php"
464 onsubmit="return emptyFormElements(this, 'new_name')">
465 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
466 <input type="hidden" name="reload" value="1" />
467 <fieldset>
468 <legend><?php echo $strCopyTable; ?></legend>
469 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
471 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
472 <?php
473 } else {
475 <select name="target_db">
476 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
477 </select>
478 <?php
479 } // end if
481 &nbsp;<strong>.</strong>&nbsp;
482 <input type="text" size="20" name="new_name" onfocus="this.select()" /><br />
483 <?php
484 $choices = array(
485 'structure' => $strStrucOnly,
486 'data' => $strStrucData,
487 'dataonly' => $strDataOnly);
488 PMA_generate_html_radio('what', $choices, 'data', true);
489 unset($choices);
492 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
493 <label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
494 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
495 <label for="checkbox_auto_increment_cp"><?php echo $strAddAutoIncrement; ?></label><br />
496 <?php
497 // display "Add constraints" choice only if there are
498 // foreign keys
499 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
501 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
502 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
503 <?php
504 } // endif
505 if (isset($_COOKIE['pma_switch_to_new'])
506 && $_COOKIE['pma_switch_to_new'] == 'true') {
507 $pma_switch_to_new = 'true';
510 <input type="checkbox" name="switch_to_new" value="true"
511 id="checkbox_switch"<?php echo
512 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
513 ? ' checked="checked"'
514 : ''; ?> />
515 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>
516 </fieldset>
517 <fieldset class="tblFooters">
518 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
519 </fieldset>
520 </form>
521 </div>
523 <br class="clearfloat"/>
525 <div id="div_table_maintenance">
526 <fieldset>
527 <legend><?php echo $strTableMaintenance; ?></legend>
529 <ul>
530 <?php
531 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
532 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
533 if ($is_myisam_or_maria || $is_innodb) {
534 $this_url_params = array_merge($url_params,
535 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
537 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
538 <?php echo $strCheckTable; ?></a>
539 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
540 </li>
541 <?php
543 if ($is_innodb) {
544 $this_url_params = array_merge($url_params,
545 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
547 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
548 <?php echo $strDefragment; ?></a>
549 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
550 </li>
551 <?php
553 if ($is_myisam_or_maria || $is_berkeleydb) {
554 $this_url_params = array_merge($url_params,
555 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
557 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
558 <?php echo $strAnalyzeTable; ?></a>
559 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
560 </li>
561 <?php
563 if ($is_myisam_or_maria) {
564 $this_url_params = array_merge($url_params,
565 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
567 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
568 <?php echo $strRepairTable; ?></a>
569 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
570 </li>
571 <?php
573 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
574 $this_url_params = array_merge($url_params,
575 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
577 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
578 <?php echo $strOptimizeTable; ?></a>
579 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
580 </li>
581 <?php
583 } // end MYISAM or BERKELEYDB case
584 $this_url_params = array_merge($url_params,
585 array(
586 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
587 'zero_rows' => sprintf($strTableHasBeenFlushed,
588 htmlspecialchars($GLOBALS['table'])),
589 'reload' => 1,
592 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
593 <?php echo $strFlushTable; ?></a>
594 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
595 </li>
596 </ul>
597 </fieldset>
598 </div>
599 <?php if (PMA_Partition::havePartitioning()) {
600 $partition_names = PMA_Partition::getPartitionNames($db, $table);
601 // show the Partition maintenance section only if we detect a partition
602 if (! is_null($partition_names[0])) {
604 <div id="div_partition_maintenance">
605 <form method="post" action="tbl_operations.php">
606 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
607 <fieldset>
608 <legend><?php echo $strPartitionMaintenance; ?></legend>
609 <?php
610 $html_select = '<select name="partition_name">' . "\n";
611 foreach($partition_names as $one_partition) {
612 $one_partition = htmlspecialchars($one_partition);
613 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
615 $html_select .= '</select>' . "\n";
616 printf($GLOBALS['strPartition'], $html_select);
617 unset($partition_names, $one_partition, $html_select);
618 $choices = array(
619 'ANALYZE' => $strAnalyze,
620 'CHECK' => $strCheck,
621 'OPTIMIZE' => $strOptimize,
622 'REBUILD' => $strRebuild,
623 'REPAIR' => $strRepair);
624 PMA_generate_html_radio('partition_operation', $choices, '', false);
625 unset($choices);
626 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
627 // I'm not sure of the best way to display that; this link does
628 // not depend on the Go button
629 $this_url_params = array_merge($url_params,
630 array(
631 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
634 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
635 <?php echo $strRemovePartitioning; ?></a>
636 </fieldset>
637 <fieldset class="tblFooters">
638 <input type="submit" name="submit_partition" value="<?php echo $strGo; ?>" />
639 </fieldset>
640 </form>
641 </div>
642 <?php
643 } // end if
644 } // end if
646 // Referential integrity check
647 // The Referential integrity check was intended for the non-InnoDB
648 // tables for which the relations are defined in pmadb
649 // so I assume that if the current table is InnoDB, I don't display
650 // this choice (InnoDB maintains integrity by itself)
652 if ($cfgRelation['relwork'] && ! $is_innodb) {
653 PMA_DBI_select_db($GLOBALS['db']);
654 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
656 if ($foreign) {
658 <!-- Referential integrity check -->
659 <div id="div_referential_integrity">
660 <fieldset>
661 <legend><?php echo $strReferentialIntegrity; ?></legend>
662 <ul>
663 <?php
664 echo "\n";
665 foreach ($foreign AS $master => $arr) {
666 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
667 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
668 . PMA_backquote($arr['foreign_table']);
669 if ($arr['foreign_table'] == $GLOBALS['table']) {
670 $foreign_table = $GLOBALS['table'] . '1';
671 $join_query .= ' AS ' . PMA_backquote($foreign_table);
672 } else {
673 $foreign_table = $arr['foreign_table'];
675 $join_query .= ' ON '
676 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
677 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
678 . ' WHERE '
679 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
680 . ' IS NULL AND '
681 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
682 . ' IS NOT NULL';
683 $this_url_params = array_merge($url_params,
684 array('sql_query' => $join_query));
685 echo ' <li>'
686 . '<a href="sql.php'
687 . PMA_generate_common_url($this_url_params)
688 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
689 . '</a></li>' . "\n";
690 } // foreach $foreign
691 unset($foreign_table, $join_query);
693 </ul>
694 </fieldset>
695 </div>
696 <?php
697 } // end if ($foreign)
699 } // end if (!empty($cfg['Server']['relation']))
703 * Displays the footer
705 require_once './libraries/footer.inc.php';
708 function PMA_set_global_variables_for_engine($tbl_type)
710 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
712 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
713 $upper_tbl_type = strtoupper($tbl_type);
715 //Options that apply to MYISAM usually apply to MARIA
716 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
717 $is_maria = ($upper_tbl_type == 'MARIA');
719 $is_isam = ($upper_tbl_type == 'ISAM');
720 $is_innodb = ($upper_tbl_type == 'INNODB');
721 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
722 $is_pbxt = ($upper_tbl_type == 'PBXT');