Allow adding and editing partitions

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2015-09-30 14:49:42 +10:00
parent 015eb63166
commit d0efeac744
13 changed files with 576 additions and 281 deletions

View File

@ -2742,9 +2742,7 @@ AJAX.registerTeardown('functions.js', function () {
$(document).off('submit', "form.create_table_form.ajax");
$(document).off('click', "form.create_table_form.ajax input[name=submit_num_fields]");
$(document).off('keyup', "form.create_table_form.ajax input");
$(document).off('change', "form.create_table_form.ajax input[name=partition_count]," +
"form.create_table_form.ajax input[name=subpartition_count]," +
"form.create_table_form.ajax select[name=partition_by]");
$(document).off('change', "input[name=partition_count],input[name=subpartition_count],select[name=partition_by]");
});
/**
@ -2913,10 +2911,14 @@ AJAX.registerOnload('functions.js', function () {
/**
* Attach event handler to manage changes in number of partitions and subpartitions
*/
$(document).on('change', "form.create_table_form.ajax input[name=partition_count]," +
"form.create_table_form.ajax input[name=subpartition_count]," +
"form.create_table_form.ajax select[name=partition_by]", function (event) {
submitChangesInCreateTableForm('submit_partition_change=1');
$(document).on('change', "input[name=partition_count],input[name=subpartition_count],select[name=partition_by]", function (event) {
$this = $(this);
$form = $this.parents('form');
if ($form.is(".create_table_form.ajax")) {
submitChangesInCreateTableForm('submit_partition_change=1');
} else {
$form.submit();
}
});
$("input[value=AUTO_INCREMENT]").change(function(){

View File

@ -63,6 +63,7 @@ $js_messages['strDeleteCentralColumnWarning'] = __('Do you really want to delete
$js_messages['strDropRTEitems'] = __('Do you really want to delete the selected items?');
$js_messages['strDropPartitionWarning'] = __('Do you really want to DROP the selected partition(s)? This will also DELETE the data related to the selected partition(s)!');
$js_messages['strTruncatePartitionWarning'] = __('Do you really want to TRUNCATE the selected partition(s)?');
$js_messages['strRemovePartitioningWarning'] = __('Do you really want to remove partitioning?');
$js_messages['strChangeColumnCollation'] = __(
'This operation will attempt to convert your data to the new collation. In '
. 'rare cases, especially where a character doesn\'t exist in the new '

View File

@ -86,6 +86,7 @@ AJAX.registerTeardown('tbl_structure.js', function () {
$(document).off('submit', ".append_fields_form.ajax");
$('body').off('click', '#fieldsForm.ajax button[name="submit_mult"], #fieldsForm.ajax input[name="submit_mult"]');
$(document).off('click', 'a[name^=partition_action].ajax');
$(document).off('click', '#remove_partitioning.ajax');
});
AJAX.registerOnload('tbl_structure.js', function () {
@ -462,6 +463,21 @@ AJAX.registerOnload('tbl_structure.js', function () {
submitPartitionAction($link.attr('href'));
}
});
/**
* Handles remove partitioning
*/
$(document).on('click', '#remove_partitioning.ajax', function (e) {
e.preventDefault();
var $link = $(this);
var question = PMA_messages.strRemovePartitioningWarning;
$link.PMA_confirm(question, $link.attr('href'), function (url) {
var submitData = '&ajax_request=true&ajax_page_request=true';
PMA_ajaxShowMessage();
AJAX.source = $link;
$.post(url, submitData, AJAX.responseHandler);
});
});
});
/** Handler for "More" dropdown in structure table rows */

View File

@ -180,6 +180,16 @@ class TableStructureController extends TableController
return;
}
/**
* Adding or editing partitioning of the table
*/
if (isset($_REQUEST['edit_partitioning'])
&& ! isset($_REQUEST['save_partitioning'])
) {
$this->displayHtmlForPartitionChange();
return;
}
/**
* handle multiple field commands if required
*
@ -271,6 +281,13 @@ class TableStructureController extends TableController
}
}
/**
* Modifications to the partitioning have been submitted -> updates the table
*/
if (isset($_REQUEST['save_partitioning'])) {
$this->updatePartitioning();
}
/**
* Adding indexes
*/
@ -516,6 +533,224 @@ class TableStructureController extends TableController
include 'libraries/tbl_columns_definition_form.inc.php';
}
/**
* Displays HTML for partition change
*
* @return string HTML for partition change
*/
protected function displayHtmlForPartitionChange()
{
$partitionDetails = null;
if (! isset($_REQUEST['partition_by'])) {
$partitionDetails = $this->_extractPartitionDetails();
}
include_once 'libraries/StorageEngine.class.php';
$this->response->addHTML(
\PMA\Template::get('table/structure/partition_definition_form')
->render(
array(
'db' => $this->db,
'table' => $this->table,
'partitionDetails' => $partitionDetails
)
)
);
}
/**
* Extracts partition details from CREATE TABLE statement
*
* @return array[] array of partition details
*/
private function _extractPartitionDetails()
{
$createTable = (new \PMA_Table($this->table, $this->db))->showCreate();
if (! $createTable) {
return null;
}
$parser = new SqlParser\Parser($createTable);
/**
* @var $stmt SqlParser\Statements\CreateStatement
*/
$stmt = $parser->statements[0];
$partitionDetails = array();
$partitionDetails['partition_by'] = '';
$partitionDetails['partition_expr'] = '';
$partitionDetails['partition_count'] = '';
if (! empty($stmt->partitionBy)) {
$openPos = strpos($stmt->partitionBy, "(");
$closePos = strrpos($stmt->partitionBy, ")");
$partitionDetails['partition_by']
= trim(substr($stmt->partitionBy, 0, $openPos));
$partitionDetails['partition_expr']
= trim(substr($stmt->partitionBy, $openPos + 1, $closePos - ($openPos + 1)));
if (isset($stmt->partitionsNum)) {
$count = $stmt->partitionsNum;
} else {
$count = count($stmt->partitions);
}
$partitionDetails['partition_count'] = $count;
}
$partitionDetails['subpartition_by'] = '';
$partitionDetails['subpartition_expr'] = '';
$partitionDetails['subpartition_count'] = '';
if (! empty($stmt->subpartitionBy)) {
$openPos = strpos($stmt->subpartitionBy, "(");
$closePos = strrpos($stmt->subpartitionBy, ")");
$partitionDetails['subpartition_by']
= trim(substr($stmt->subpartitionBy, 0, $openPos));
$partitionDetails['subpartition_expr']
= trim(substr($stmt->subpartitionBy, $openPos + 1, $closePos - ($openPos + 1)));
if (isset($stmt->subpartitionsNum)) {
$count = $stmt->subpartitionsNum;
} else {
$count = count($stmt->partitions[0]->subpartitions);
}
$partitionDetails['subpartition_count'] = $count;
}
// Only LIST and RANGE type parameters allow subpartitioning
$partitionDetails['can_have_subpartitions']
= $partitionDetails['partition_count'] > 1
&& ($partitionDetails['partition_by'] == 'RANGE'
|| $partitionDetails['partition_by'] == 'LIST');
$partitionDetails['partitions'] = array();
for ($i = 0; $i < intval($partitionDetails['partition_count']); $i++) {
if (! isset($stmt->partitions[$i])) {
$partitionDetails['partitions'][$i] = array(
'value_type' => '',
'value' => '',
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
} else {
$p = $stmt->partitions[$i];
$type = $p->type;
$expr = trim($p->expr, '()');
if ($expr == 'MAXVALUE') {
$type .= ' MAXVALUE';
$expr = '';
}
$partitionDetails['partitions'][$i] = array(
'value_type' => $type,
'value' => $expr,
'engine' => $p->options->has('ENGINE', true),
'comment' => trim($p->options->has('COMMENT', true), "'"),
'data_directory' => trim($p->options->has('DATA DIRECTORY', true), "'"),
'index_directory' => trim($p->options->has('INDEX_DIRECTORY', true), "'"),
'max_rows' => $p->options->has('MAX_ROWS', true),
'min_rows' => $p->options->has('MIN_ROWS', true),
'tablespace' => $p->options->has('TABLESPACE', true),
'node_group' => $p->options->has('NODEGROUP', true),
);
}
$partition =& $partitionDetails['partitions'][$i];
$partition['name'] = 'p' . $i;
$partition['prefix'] = 'partitions[' . $i . ']';
// Values are specified only for LIST and RANGE type partitions
$partition['value_enabled'] = isset($partitionDetails['partition_by'])
&& ($partitionDetails['partition_by'] == 'RANGE'
|| $partitionDetails['partition_by'] == 'LIST');
if (! $partition['value_enabled']) {
$partition['value_type'] = '';
$partition['value'] = '';
}
if ($partitionDetails['subpartition_count'] > 1) {
$partition['subpartition_count'] = $partitionDetails['subpartition_count'];
$partition['subpartitions'] = array();
for ($j = 0; $j < intval($partitionDetails['subpartition_count']); $j++) {
if (! isset($stmt->partitions[$i]->subpartitions[$j])) {
$partition['subpartitions'][$j] = array(
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
} else {
$sp = $stmt->partitions[$i]->subpartitions[$j];
$partition['subpartitions'][$j] = array(
'engine' => $sp->options->has('ENGINE', true),
'comment' => trim($sp->options->has('COMMENT', true), "'"),
'data_directory' => trim($sp->options->has('DATA DIRECTORY', true), "'"),
'index_directory' => trim($sp->options->has('INDEX_DIRECTORY', true), "'"),
'max_rows' => $sp->options->has('MAX_ROWS', true),
'min_rows' => $sp->options->has('MIN_ROWS', true),
'tablespace' => $sp->options->has('TABLESPACE', true),
'node_group' => $sp->options->has('NODEGROUP', true),
);
}
$subpartition =& $partition['subpartitions'][$j];
$subpartition['name'] = 'p' . $i . 's' . $j;
$subpartition['prefix'] = 'partitions[' . $i . ']'
. '[subpartitions][' . $j . ']';
}
}
}
return $partitionDetails;
}
/**
* Update the table's partitioning based on $_REQUEST
*
* @return void
*/
protected function updatePartitioning()
{
require_once 'libraries/create_addfield.lib.php';
$sql_query = "ALTER TABLE " . \PMA_Util::backquote($this->table) . " "
. PMA_getPartitionsDefinition();
// Execute alter query
$result = $this->dbi->tryQuery($sql_query);
if ($result !== false) {
$message = PMA_Message::success(
__('Table %1$s has been altered successfully.')
);
$message->addParam($this->table);
$this->response->addHTML(
PMA_Util::getMessage($message, $sql_query, 'success')
);
} else {
$this->response->isSuccess(false);
$this->response->addJSON(
'message',
PMA_Message::rawError(
__('Query error') . ':<br />' . $this->dbi->getError()
)
);
}
}
/**
* Function to get the type of command for multiple field handling
*

View File

@ -409,7 +409,6 @@ $html = PMA\Template::get('columns_definitions/column_definitions_form')->render
'action' => $action,
'form_params' => $form_params,
'content_cells' => $content_cells,
'partitionDetails' => isset($partitionDetails) ? $partitionDetails : array()
)
);

View File

@ -0,0 +1,105 @@
<?php
if (!isset($partitionDetails)) {
$partitionDetails = array();
// Extract some partitioning and subpartitioning parameters from the request
$partitionParams = array(
'partition_by', 'partition_expr', 'partition_count',
'subpartition_by', 'subpartition_expr', 'subpartition_count'
);
foreach ($partitionParams as $partitionParam) {
$partitionDetails[$partitionParam] = isset($_REQUEST[$partitionParam])
? $_REQUEST[$partitionParam] : '';
}
// Only LIST and RANGE type parameters allow subpartitioning
$partitionDetails['can_have_subpartitions'] = isset($_REQUEST['partition_count'])
&& $_REQUEST['partition_count'] > 1
&& isset($_REQUEST['partition_by'])
&& ($_REQUEST['partition_by'] == 'RANGE' || $_REQUEST['partition_by'] == 'LIST');
if (PMA_isValid($_REQUEST['partition_count'], 'numeric')
&& $_REQUEST['partition_count'] > 1
) { // Has partitions
$partitions = isset($_REQUEST['partitions']) ? $_REQUEST['partitions'] : array();
// Remove details of the additional partitions
// when number of partitions have been reduced
array_splice($partitions, $_REQUEST['partition_count']);
for ($i = 0; $i < $_REQUEST['partition_count']; $i++) {
if (! isset($partitions[$i])) { // Newly added partition
$partitions[$i] = array(
'value_type' => '',
'value' => '',
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
}
$partition =& $partitions[$i];
$partition['name'] = 'p' . $i;
$partition['prefix'] = 'partitions[' . $i . ']';
// Values are specified only for LIST and RANGE type partitions
$partition['value_enabled'] = isset($_REQUEST['partition_by'])
&& ($_REQUEST['partition_by'] == 'RANGE'
|| $_REQUEST['partition_by'] == 'LIST');
if (! $partition['value_enabled']) {
$partition['value_type'] = '';
$partition['value'] = '';
}
if (PMA_isValid($_REQUEST['subpartition_count'], 'numeric')
&& $_REQUEST['subpartition_count'] > 1
&& $partitionDetails['can_have_subpartitions'] == true
) { // Has subpartitions
$partition['subpartition_count'] = $_REQUEST['subpartition_count'];
if (! isset($partition['subpartitions'])) {
$partition['subpartitions'] = array();
}
$subpartitions =& $partition['subpartitions'];
// Remove details of the additional subpartitions
// when number of subpartitions have been reduced
array_splice($subpartitions, $_REQUEST['subpartition_count']);
for ($j = 0; $j < $_REQUEST['subpartition_count']; $j++) {
if (! isset($subpartitions[$j])) { // Newly added subpartition
$subpartitions[$j] = array(
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
}
$subpartition =& $subpartitions[$j];
$subpartition['name'] = 'p' . $i . 's' . $j;
$subpartition['prefix'] = 'partitions[' . $i . ']'
. '[subpartitions][' . $j . ']';
}
} else { // No subpartitions
unset($partition['subpartitions']);
unset($partition['subpartition_count']);
}
}
$partitionDetails['partitions'] = $partitions;
}
}
echo PMA\Template::get('columns_definitions/partitions')
->render(array('partitionDetails' => $partitionDetails));

View File

@ -100,104 +100,6 @@ if (isset($_REQUEST['do_save_data'])) {
//This global variable needs to be reset for the headerclass to function properly
$GLOBAL['table'] = '';
$partitionDetails = array();
// Extract some partitioning and subpartitioning parameters from the request
$partitionParams = array(
'partition_by', 'partition_expr', 'partition_count',
'subpartition_by', 'subpartition_expr', 'subpartition_count'
);
foreach ($partitionParams as $partitionParam) {
$partitionDetails[$partitionParam] = isset($_REQUEST[$partitionParam])
? $_REQUEST[$partitionParam] : '';
}
// Only LIST and RANGE type parameters allow subpartitioning
$partitionDetails['can_have_subpartitions'] = isset($_REQUEST['partition_count'])
&& $_REQUEST['partition_count'] > 1
&& isset($_REQUEST['partition_by'])
&& ($_REQUEST['partition_by'] == 'RANGE' || $_REQUEST['partition_by'] == 'LIST');
if (PMA_isValid($_REQUEST['partition_count'], 'numeric')
&& $_REQUEST['partition_count'] > 1
) { // Has partitions
$partitions = isset($_REQUEST['partitions']) ? $_REQUEST['partitions'] : array();
// Remove details of the additional partitions
// when number of partitions have been reduced
array_splice($partitions, $_REQUEST['partition_count']);
for ($i = 0; $i < $_REQUEST['partition_count']; $i++) {
if (! isset($partitions[$i])) { // Newly added partition
$partitions[$i] = array(
'value_type' => '',
'value' => '',
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
}
$partition =& $partitions[$i];
$partition['name'] = 'p' . $i;
$partition['prefix'] = 'partitions[' . $i . ']';
// Values are specified only for LIST and RANGE type partitions
$partition['value_enabled'] = isset($_REQUEST['partition_by'])
&& ($_REQUEST['partition_by'] == 'RANGE'
|| $_REQUEST['partition_by'] == 'LIST');
if (! $partition['value_enabled']) {
$partition['value_type'] = '';
$partition['value'] = '';
}
if (PMA_isValid($_REQUEST['subpartition_count'], 'numeric')
&& $_REQUEST['subpartition_count'] > 1
&& $partitionDetails['can_have_subpartitions'] == true
) { // Has subpartitions
$partition['subpartition_count'] = $_REQUEST['subpartition_count'];
if (! isset($partition['subpartitions'])) {
$partition['subpartitions'] = array();
}
$subpartitions =& $partition['subpartitions'];
// Remove details of the additional subpartitions
// when number of subpartitions have been reduced
array_splice($subpartitions, $_REQUEST['subpartition_count']);
for ($j = 0; $j < $_REQUEST['subpartition_count']; $j++) {
if (! isset($subpartitions[$j])) { // Newly added subpartition
$subpartitions[$j] = array(
'engine' => '',
'comment' => '',
'data_directory' => '',
'index_directory' => '',
'max_rows' => '',
'min_rows' => '',
'tablespace' => '',
'node_group' => '',
);
}
$subpartition =& $subpartitions[$j];
$subpartition['name'] = 'p' . $i . 's' . $j;
$subpartition['prefix'] = 'partitions[' . $i . ']'
. '[subpartitions][' . $j . ']';
}
} else { // No subpartitions
unset($partition['subpartitions']);
unset($partition['subpartition_count']);
}
}
$partitionDetails['partitions'] = $partitions;
}
/**
* Displays the form used to define the structure of the table
*/

View File

@ -141,8 +141,7 @@
</tr>
<tr>
<td colspan="5">
<?php echo PMA\Template::get('columns_definitions/partitions_form')
->render(array('partitionDetails' => $partitionDetails)); ?>
<?php include 'libraries/tbl_partition_definition.inc.php'; ?>
</td>
</tr>
<?php endif; ?>

View File

@ -3,123 +3,139 @@
<legend><?php echo __('Partitions')
. PMA_Util::showMySQLDocu('partitioning'); ?>
</legend>
<p>
<?php echo __('Partitioned by:');?>
<code><?php echo $partitionMethod . '(' . $partitionExpression . ' )'; ?></code>
</p>
<?php if ($hasSubPartitions): ?>
<?php if (empty($partitions)): ?>
<?php echo PMA_Message::notice(__('No partitioning defined!'))->getDisplay(); ?>
<?php else: ?>
<p>
<?php echo __('Sub partitioned by:'); ?>
<code><?php echo $subPartitionMethod . '(' . $subPartitionExpression . ' )'; ?></code>
<p>
<?php endif; ?>
<table>
<thead>
<tr>
<th colspan="2">#</th>
<th><?php echo __('Name'); ?></th>
<?php if ($hasDescription): ?>
<th><?php echo __('Expression'); ?></th>
<?php endif; ?>
<th><?php echo __('Rows'); ?></th>
<th><?php echo __('Data length'); ?></th>
<th><?php echo __('Index length'); ?></th>
<th><?php echo __('Comment'); ?></th>
<th colspan="<?php echo $rangeOrList ? '7' : '6'; ?>">
<?php echo __('Action'); ?>
</th>
</tr>
</thead>
<tbody>
<?php $odd = true; ?>
<?php foreach ($partitions as $partition): ?>
<tr class="noclick <?php echo $odd ? 'odd' : 'even'; echo $hasSubPartitions ? ' marked' : '';?>">
<?php if ($hasSubPartitions): ?>
<td><?php echo $partition->getOrdinal(); ?></td>
<td></td>
<?php else: ?>
<td colspan="2"><?php echo $partition->getOrdinal(); ?></td>
<?php endif; ?>
<th><?php echo htmlspecialchars($partition->getName()); ?></th>
<?php if ($hasDescription): ?>
<td>
<code>
<?php
echo htmlspecialchars($partition->getExpression())
. ($partition->getMethod() == 'LIST' ? ' IN (' : ' < ')
. htmlspecialchars($partition->getDescription())
. ($partition->getMethod() == 'LIST' ? ')' : '');
?>
</code>
</td>
<?php endif; ?>
<td class="value"><?php echo $partition->getRows(); ?></td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$partition->getDataLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$partition->getIndexLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td><?php echo $partition->getComment(); ?></td>
<?php foreach ($actionIcons as $action => $icon): ?>
<td>
<a href="tbl_structure.php<?php echo $url_query; ?>&amp;partition_maintenance=1&amp;sql_query=<?php echo urlencode(
"ALTER TABLE " . PMA_Util::backquote($table) . $action . " PARTITION " . $partition->getName()
) ?>"
id="partition_action_<?php echo $action; ?>"
name="partition_action_<?php echo $action; ?>"
class="ajax"
>
<?php echo $icon; ?>
</a>
</td>
<?php endforeach; ?>
<?php if ($hasSubPartitions): ?>
<?php foreach ($partition->getSubPartitions() as $subParition): ?>
<tr class="noclick <?php echo $odd ? 'odd' : 'even' ?>">
<td></td>
<td><?php echo $subParition->getOrdinal(); ?></td>
<td><?php echo htmlspecialchars($subParition->getName()); ?></td>
<?php if ($hasDescription): ?>
<td></td>
<?php endif; ?>
<td class="value"><?php echo $subParition->getRows(); ?></td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$subParition->getDataLength(), 3, 1
);
<?php echo __('Partitioned by:');?>
<code><?php echo $partitionMethod . '(' . $partitionExpression . ' )'; ?></code>
</p>
<?php if ($hasSubPartitions): ?>
<p>
<?php echo __('Sub partitioned by:'); ?>
<code><?php echo $subPartitionMethod . '(' . $subPartitionExpression . ' )'; ?></code>
<p>
<?php endif; ?>
<table>
<thead>
<tr>
<th colspan="2">#</th>
<th><?php echo __('Name'); ?></th>
<?php if ($hasDescription): ?>
<th><?php echo __('Expression'); ?></th>
<?php endif; ?>
<th><?php echo __('Rows'); ?></th>
<th><?php echo __('Data length'); ?></th>
<th><?php echo __('Index length'); ?></th>
<th><?php echo __('Comment'); ?></th>
<th colspan="<?php echo $rangeOrList ? '7' : '6'; ?>">
<?php echo __('Action'); ?>
</th>
</tr>
</thead>
<tbody>
<?php $odd = true; ?>
<?php foreach ($partitions as $partition): ?>
<tr class="noclick <?php echo $odd ? 'odd' : 'even'; echo $hasSubPartitions ? ' marked' : '';?>">
<?php if ($hasSubPartitions): ?>
<td><?php echo $partition->getOrdinal(); ?></td>
<td></td>
<?php else: ?>
<td colspan="2"><?php echo $partition->getOrdinal(); ?></td>
<?php endif; ?>
<th><?php echo htmlspecialchars($partition->getName()); ?></th>
<?php if ($hasDescription): ?>
<td>
<code>
<?php
echo htmlspecialchars($partition->getExpression())
. ($partition->getMethod() == 'LIST' ? ' IN (' : ' < ')
. htmlspecialchars($partition->getDescription())
. ($partition->getMethod() == 'LIST' ? ')' : '');
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$subParition->getIndexLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td><?php echo $subParition->getComment(); ?></td>
<td colspan="<?php echo $rangeOrList ? '7' : '6'; ?>"></td>
</tr>
</code>
</td>
<?php endif; ?>
<td class="value"><?php echo $partition->getRows(); ?></td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$partition->getDataLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$partition->getIndexLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td><?php echo $partition->getComment(); ?></td>
<?php foreach ($actionIcons as $action => $icon): ?>
<td>
<a href="tbl_structure.php<?php echo $url_query; ?>&amp;partition_maintenance=1&amp;sql_query=<?php echo urlencode(
"ALTER TABLE " . PMA_Util::backquote($table) . $action . " PARTITION " . $partition->getName()
) ?>"
id="partition_action_<?php echo $action; ?>"
name="partition_action_<?php echo $action; ?>"
class="ajax"
>
<?php echo $icon; ?>
</a>
</td>
<?php endforeach; ?>
<?php endif; ?>
</tr>
<?php $odd = ! $odd; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($hasSubPartitions): ?>
<?php foreach ($partition->getSubPartitions() as $subParition): ?>
<tr class="noclick <?php echo $odd ? 'odd' : 'even' ?>">
<td></td>
<td><?php echo $subParition->getOrdinal(); ?></td>
<td><?php echo htmlspecialchars($subParition->getName()); ?></td>
<?php if ($hasDescription): ?>
<td></td>
<?php endif; ?>
<td class="value"><?php echo $subParition->getRows(); ?></td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$subParition->getDataLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td class="value"><?php
list($value, $unit) = PMA_Util::formatByteDown(
$subParition->getIndexLength(), 3, 1
);
?>
<span><?php echo $value; ?></span>
<span class="unit"><?php echo $unit; ?></span>
</td>
<td><?php echo $subParition->getComment(); ?></td>
<td colspan="<?php echo $rangeOrList ? '7' : '6'; ?>"></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tr>
<?php $odd = ! $odd; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</fieldset>
<fieldset class="tblFooters print_ignore">
<form action="tbl_structure.php" method="post">
<?php echo PMA_URL_getHiddenInputs($db, $table); ?>
<input type="hidden" name="edit_partitioning" value="true" />
<?php if (empty($partitions)): ?>
<input type="submit" name="edit_partitioning" value="<?php echo __('Partition table'); ?>" />
<?php else: ?>
<?php echo PMA_Util::linkOrButton($removeUrl, __('Remove partitioning'), ['class' => 'button ajax', 'id' => 'remove_partitioning'])?>
<input type="submit" name="edit_partitioning" value="<?php echo __('Edit partitioning'); ?>" />
<?php endif; ?>
</form>
</fieldset>
</div>

View File

@ -162,58 +162,72 @@
<?php endif; ?>
<!--Display partition details-->
<?php
$partition_names = PMA_Partition::getPartitionNames($db, $table);
// detect partitioning
if (! empty($partition_names) && ! is_null($partition_names[0])) {
<?php if (PMA_Partition::havePartitioning()):
$partition_names = PMA_Partition::getPartitionNames($db, $table);
$partitions = PMA_Partition::getPartitions($db, $table);
$firstPartition = $partitions[0];
$rangeOrList = $firstPartition->getMethod() == 'RANGE'
|| $firstPartition->getMethod() == 'LIST';
$subParitions = $firstPartition->getSubPartitions();
$hasSubPartitions = $firstPartition->hasSubPartitions();
if ($hasSubPartitions) {
$firstSubPartition = $subParitions[0];
}
// detect partitioning
if (! empty($partition_names) && ! is_null($partition_names[0])):
$actionIcons = array(
'ANALYZE' => PMA_Util::getIcon('b_search.png', __('Analyze')),
'CHECK' => PMA_Util::getIcon('eye.png', __('Check')),
'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')),
'REBUILD' => PMA_Util::getIcon('s_tbl.png', __('Rebuild')),
'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')),
'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')),
);
if ($rangeOrList) {
$actionIcons['DROP'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
}
$partitions = PMA_Partition::getPartitions($db, $table);
$firstPartition = $partitions[0];
$rangeOrList = $firstPartition->getMethod() == 'RANGE'
|| $firstPartition->getMethod() == 'LIST';
$subParitions = $firstPartition->getSubPartitions();
$hasSubPartitions = $firstPartition->hasSubPartitions();
if ($hasSubPartitions) {
$firstSubPartition = $subParitions[0];
}
echo PMA_Util::getDivForSliderEffect(
'partitions', __('Partitions')
);
$actionIcons = array(
'ANALYZE' => PMA_Util::getIcon('b_search.png', __('Analyze')),
'CHECK' => PMA_Util::getIcon('eye.png', __('Check')),
'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')),
'REBUILD' => PMA_Util::getIcon('s_tbl.png', __('Rebuild')),
'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')),
'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')),
);
if ($rangeOrList) {
$actionIcons['DROP'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
}
$tmp_partition_description = $firstPartition->getDescription();
echo PMA_Util::getDivForSliderEffect(
'partitions', __('Partitions')
);
echo PMA\Template::get('table/structure/display_partitions')->render(
array(
'table' => $table,
'url_query' => $url_query,
'partitions' => $partitions,
'partitionMethod' => $firstPartition->getMethod(),
'partitionExpression' => $firstPartition->getExpression(),
'hasDescription' => ! empty($tmp_partition_description),
'hasSubPartitions' => $hasSubPartitions,
'subPartitionMethod' => $hasSubPartitions ? $firstSubPartition->getMethod() : null,
'subPartitionExpression' => $hasSubPartitions ? $firstSubPartition->getExpression() : null,
'actionIcons' => $actionIcons,
'rangeOrList' => $rangeOrList,
)
);
?>
<!-- For closing Slider effect div-->
</div>
<?php } ?>
$tmp_partition_description = $firstPartition->getDescription();
$removeSQL = "ALTER TABLE " . PMA_Util::backquote($table) . " REMOVE PARTITIONING";
$removeUrl = 'sql.php' . $url_query . '&sql_query=' . urldecode($removeSQL);
echo PMA\Template::get('table/structure/display_partitions')->render(
array(
'db' => $db,
'table' => $table,
'url_query' => $url_query,
'partitions' => $partitions,
'partitionMethod' => $firstPartition->getMethod(),
'partitionExpression' => $firstPartition->getExpression(),
'hasDescription' => ! empty($tmp_partition_description),
'hasSubPartitions' => $hasSubPartitions,
'subPartitionMethod' => $hasSubPartitions ? $firstSubPartition->getMethod() : null,
'subPartitionExpression' => $hasSubPartitions ? $firstSubPartition->getExpression() : null,
'actionIcons' => $actionIcons,
'rangeOrList' => $rangeOrList,
'removeUrl' => $removeUrl,
)
);
else:
echo PMA\Template::get('table/structure/display_partitions')->render(
array(
'db' => $db,
'table' => $table,
)
);
endif;
?>
<!-- For closing Slider effect div-->
</div>
<?php endif; ?>
<!--Displays Space usage and row statistics-->
<?php if ($GLOBALS['cfg']['ShowStats']): ?>

View File

@ -0,0 +1,13 @@
<form action="tbl_structure.php" method="post">
<?php echo PMA_URL_getHiddenInputs($db, $table); ?>
<input type="hidden" name="edit_partitioning" value="true" />
<fieldset>
<legend><?php echo __('Edit partitioning'); ?></legend>
<?php include 'libraries/tbl_partition_definition.inc.php'; ?>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" name="save_partitioning" value="<?php echo __('Save'); ?>">
</fieldset>
</form>

View File

@ -1596,32 +1596,25 @@ div#profilingchart {
#sectionlinks a,
.buttonlinks a,
a.button {
font-size: .88em;
font-weight: bold;
text-shadow: 0 1px 0 #fff;
line-height: 35px;
margin-<?php echo $left; ?>: 7px;
border: 1px solid #aaa;
padding: 5px 10px;
color: #111;
padding: 3px 7px;
color: #111 !important;
text-decoration: none;
background: #ddd;
white-space: nowrap;
border-radius: 20px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
box-shadow: <?php echo $GLOBALS['text_dir'] === 'rtl' ? '-' : ''; ?>1px 1px 2px rgba(0,0,0,.5);
/*
-webkit-box-shadow: <?php echo $GLOBALS['text_dir'] === 'rtl' ? '-' : ''; ?>1px 1px 2px rgba(0,0,0,.5);
-moz-box-shadow: <?php echo $GLOBALS['text_dir'] === 'rtl' ? '-' : ''; ?>1px 1px 2px rgba(0,0,0,.5);
text-shadow: #fff 0 1px 0;
*/
<?php echo $_SESSION['PMA_Theme']->getCssGradient('ffffff', 'cccccc'); ?>
<?php echo $_SESSION['PMA_Theme']->getCssGradient('f8f8f8', 'd8d8d8'); ?>
}
#sectionlinks a:hover,
.buttonlinks a:hover,
a.button:hover {
<?php echo $_SESSION['PMA_Theme']->getCssGradient('cccccc', 'dddddd'); ?>
<?php echo $_SESSION['PMA_Theme']->getCssGradient('ffffff', 'dddddd'); ?>
}
div#sqlquerycontainer {