/** * returns array of partition names for a specific db/table * * @param string $db database name * @param string $table table name * * @access public * @return array of partition names */ public static function getPartitionNames($db, $table) { if (PMA_Partition::havePartitioning()) { return PMA_DBI_fetch_result("SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`" . " WHERE `TABLE_SCHEMA` = '" . $db . "' AND `TABLE_NAME` = '" . $table . "'"); } else { return array(); } }
/** * returns array of partition names for a specific db/table * * @access public * @uses PMA_DBI_fetch_result() * @return array of partition names */ static public function getPartitionNames($db, $table) { if (PMA_Partition::havePartitioning()) { return PMA_DBI_fetch_result("select `PARTITION_NAME` from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = '" . $db . "' and `TABLE_NAME` = '" . $table . "'"); } else { return array(); } }
/** * returns array of partition names for a specific db/table * * @param string $db database name * @param string $table table name * * @access public * @return array of partition names */ public static function getPartitionNames($db, $table) { if (PMA_Partition::havePartitioning()) { return $GLOBALS['dbi']->fetchResult("SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`" . " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db) . "' AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'"); } else { return array(); } }
/** * Function to get html for table comments, storage engine, collation and * partition definition * * @return string */ function PMA_getHtmlForTableConfigurations() { $html = '<table>' . '<tr class="vtop">' . '<th>' . __('Table comments:') . '</th>' . '<td width="25"> </td>' . '<th>' . __('Storage Engine:') . PMA_Util::showMySQLDocu('Storage_engines') . '</th>' . '<td width="25"> </td>' . '<th>' . __('Collation:') . '</th>' . '</tr>' . '<tr><td><input type="text" name="comment" size="40" maxlength="80"' . ' value="' . (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : '') . '" class="textfield" />' . '</td>' . '<td width="25"> </td>' . '<td>' . PMA_StorageEngine::getHtmlSelect('tbl_storage_engine', null, isset($_REQUEST['tbl_storage_engine']) ? $_REQUEST['tbl_storage_engine'] : null) . '</td>' . '<td width="25"> </td>' . '<td>' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null, false, 3) . '</td>' . '</tr>'; if (PMA_Partition::havePartitioning()) { $html .= '<tr class="vtop">' . '<th>' . __('PARTITION definition:') . ' ' . PMA_Util::showMySQLDocu('Partitioning') . '</th>' . '</tr>' . '<tr>' . '<td>' . '<textarea name="partition_definition" id="partitiondefinition"' . ' cols="' . $GLOBALS['cfg']['TextareaCols'] . '"' . ' rows="' . $GLOBALS['cfg']['TextareaRows'] . '"' . ' dir="' . $GLOBALS['text_dir'] . '">' . (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : '') . '</textarea>' . '</td>' . '</tr>'; } $html .= '</table>' . '<br />'; return $html; }
/** * returns the partition method used by the table. * * @param string $db database name * @param string $table table name * * @return string partition method */ public static function getPartitionMethod($db, $table) { if (PMA_Partition::havePartitioning()) { $partition_method = $GLOBALS['dbi']->fetchResult("SELECT `PARTITION_METHOD` FROM `information_schema`.`PARTITIONS`" . " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db) . "'" . " AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'"); if (!empty($partition_method)) { return $partition_method[0]; } } return null; }
/** * Function to get html for table comments, storage engine, collation and * partition definition * * @return string */ function PMA_getHtmlForTableConfigurations() { $html = '<table>'; $html .= '<tr class="vtop">' . '<th>' . __('Table comments:') . '</th>' . '<td width="25"> </td>' . '<th>' . __('Collation:') . '</th>' . '<td width="25"> </td>' . '<th>' . __('Storage Engine:') . PMA_Util::showMySQLDocu('Storage_engines') . '</th>' . '<td width="25"> </td>' . '<th>' . __('Connection:') . PMA_Util::showMySQLDocu('federated-create-connection') . '</th>' . '</tr>'; $commentLength = PMA_MYSQL_INT_VERSION >= 50503 ? 2048 : 60; $html .= '<tr>' . '<td><input type="text" name="comment"' . ' size="40" maxlength="' . $commentLength . '"' . ' value="' . (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : '') . '" class="textfield" />' . '</td>' . '<td width="25"> </td>' . '<td>' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null, false) . '</td>' . '<td width="25"> </td>' . '<td>' . PMA_StorageEngine::getHtmlSelect('tbl_storage_engine', null, isset($_REQUEST['tbl_storage_engine']) ? $_REQUEST['tbl_storage_engine'] : null) . '</td>' . '<td width="25"> </td>' . '<td><input type="text" name="connection" size="40"' . ' value="' . (isset($_REQUEST['connection']) ? htmlspecialchars($_REQUEST['connection']) : '') . '"' . ' placeholder="scheme://user_name[:password]@host_name[:port_num]/db_name/tbl_name"' . ' class="textfield" required="required" />' . '</td>' . '</tr>'; if (PMA_Partition::havePartitioning()) { $html .= '<tr class="vtop">' . '<th>' . __('PARTITION definition:') . ' ' . PMA_Util::showMySQLDocu('Partitioning') . '</th>' . '</tr>' . '<tr>' . '<td>' . '<textarea name="partition_definition" id="partitiondefinition"' . ' cols="' . $GLOBALS['cfg']['TextareaCols'] . '"' . ' rows="' . $GLOBALS['cfg']['TextareaRows'] . '"' . ' dir="' . $GLOBALS['text_dir'] . '">' . (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : '') . '</textarea>' . '</td>' . '</tr>'; } $html .= '</table>' . '<br />'; return $html; }
</td> <td width="25"> </td> <td> <?php echo PMA_StorageEngine::getHtmlSelect('tbl_type', null, isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null); ?> </td> <td width="25"> </td> <td> <?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null, false, 3); ?> </td> </tr> <?php if (PMA_Partition::havePartitioning()) { ?> <tr valign="top"> <th><?php echo __('PARTITION definition'); ?> : <?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?> </th> </tr> <tr> <td> <textarea name="partition_definition" id="partitiondefinition" cols="<?php echo $GLOBALS['cfg']['TextareaCols'];
/** * Get HTML snippet for partition maintenance * * @param array $partition_names array of partition names for a specific db/table * @param array $url_params url parameters * * @return string $html_output */ function PMA_getHtmlForPartitionMaintenance($partition_names, $url_params) { $choices = array('ANALYZE' => __('Analyze'), 'CHECK' => __('Check'), 'OPTIMIZE' => __('Optimize'), 'REBUILD' => __('Rebuild'), 'REPAIR' => __('Repair'), 'TRUNCATE' => __('Truncate')); $partition_method = PMA_Partition::getPartitionMethod($GLOBALS['db'], $GLOBALS['table']); // add COALESCE or DROP option to choices array depeding on Partition method if ($partition_method == 'RANGE' || $partition_method == 'LIST') { $choices['DROP'] = __('Drop'); } else { $choices['COALESCE'] = __('Coalesce'); } $html_output = '<div class="operations_half_width">' . '<form id="partitionsForm" class="ajax" ' . 'method="post" action="tbl_operations.php" >' . PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . '<fieldset>' . '<legend>' . __('Partition maintenance') . PMA_Util::showMySQLDocu('partitioning_maintenance') . '</legend>'; $html_select = '<select id="partition_name" name="partition_name[]"' . ' multiple="multiple" required="required">' . "\n"; $first = true; foreach ($partition_names as $one_partition) { $one_partition = htmlspecialchars($one_partition); $html_select .= '<option value="' . $one_partition . '"'; if ($first) { $html_select .= ' selected="selected"'; $first = false; } $html_select .= '>' . $one_partition . '</option>' . "\n"; } $html_select .= '</select>' . "\n"; $html_output .= sprintf(__('Partition %s'), $html_select); $html_output .= '<div class="clearfloat" />'; $html_output .= PMA_Util::getRadioFields('partition_operation', $choices, 'ANALYZE', false, true, 'floatleft'); $this_url_params = array_merge($url_params, array('sql_query' => 'ALTER TABLE ' . PMA_Util::backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;')); $html_output .= '<div class="clearfloat" /><br />'; $html_output .= '<a href="sql.php' . PMA_URL_getCommon($this_url_params) . '">' . __('Remove partitioning') . '</a>'; $html_output .= '</fieldset>' . '<fieldset class="tblFooters">' . '<input type="hidden" name="submit_partition" value="1">' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</form>' . '</div>'; return $html_output; }
$response->addHTML(PMA_getHtmlForTableMaintenance($is_myisam_or_aria, $is_innodb, $is_berkeleydb, $url_params)); if (!(isset($db_is_system_schema) && $db_is_system_schema)) { $truncate_table_url_params = array(); $drop_table_url_params = array(); if (!$tbl_is_view && !(isset($db_is_system_schema) && $db_is_system_schema)) { $this_sql_query = 'TRUNCATE TABLE ' . PMA_Util::backquote($GLOBALS['table']); $truncate_table_url_params = array_merge($url_params, array('sql_query' => $this_sql_query, 'goto' => 'tbl_structure.php', 'reload' => '1', 'message_to_show' => sprintf(__('Table %s has been emptied.'), htmlspecialchars($table)))); } if (!(isset($db_is_system_schema) && $db_is_system_schema)) { $this_sql_query = 'DROP TABLE ' . PMA_Util::backquote($GLOBALS['table']); $drop_table_url_params = array_merge($url_params, array('sql_query' => $this_sql_query, 'goto' => 'db_operations.php', 'reload' => '1', 'purge' => '1', 'message_to_show' => sprintf($tbl_is_view ? __('View %s has been dropped.') : __('Table %s has been dropped.'), htmlspecialchars($table)), 'table' => $GLOBALS['table'])); } $response->addHTML(PMA_getHtmlForDeleteDataOrTable($truncate_table_url_params, $drop_table_url_params)); } if (PMA_Partition::havePartitioning()) { $partition_names = PMA_Partition::getPartitionNames($db, $table); // show the Partition maintenance section only if we detect a partition if (!is_null($partition_names[0])) { $response->addHTML(PMA_getHtmlForPartitionMaintenance($partition_names, $url_params)); } // end if } // end if unset($partition_names); // Referential integrity check // The Referential integrity check was intended for the non-InnoDB // tables for which the relations are defined in pmadb // so I assume that if the current table is InnoDB, I don't display // this choice (InnoDB maintains integrity by itself) if ($cfgRelation['relwork'] && !$is_innodb) { $GLOBALS['dbi']->selectDb($GLOBALS['db']);