From 4acdbebe18a3fd1bb172a5eb346c4f85bda0f317 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Aug 2015 18:26:15 +0530 Subject: [PATCH 01/11] Improve partition support Signed-off-by: Madhura Jayaratne --- libraries/Partition.class.php | 154 ++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index 387021be2f..3c064dc28f 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -16,6 +16,160 @@ if (! defined('PHPMYADMIN')) { */ class PMA_Partition { + /** + * @var string the database + */ + protected $db; + /** + * @var string the table + */ + protected $table; + /** + * @var string partition name + */ + protected $name; + /** + * @var int ordinal + */ + protected $ordinal; + /** + * @var string partition method + */ + protected $method; + /** + * @var string partition expression + */ + protected $expression; + /** + * @var string partition description + */ + protected $description; + /** + * @var integer no of table rows in the parition + */ + protected $rows; + /** + * @var PMA_Partition[] sub partitions + */ + protected $subPartitions = array(); + + /** + * Constructs a partition + * + * @param string $db database name + * @param string $table table name + * @param string $name parition name + * @param int $ordinal ordinal + * @param string $method partition method + * @param string $expression partition expression + */ + public function __construct($db, $table, $name, $ordinal, $method, $expression) + { + $this->db = $db; + $this->table = $table; + $this->name = $name; + $this->ordinal = $ordinal; + $this->method = $method; + $this->expression = $expression; + } + + /** + * Sets the partition description + * + * @param string $description parition description + * + * @return void + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * Sets the number of rows in the parition + * + * @param integer $rows number of rows + * + * @return void + */ + public function setRows($rows) + { + $this->rows = $rows; + } + + /** + * Add a sub parition + * + * @param PMA_Partition $parition + * + * @return void + */ + public function addSubPartition(PMA_Partition $parition) + { + $this->subPartitions[] = $parition; + } + + /** + * Returns array of partitions for a specific db/table + * + * @param string $db database name + * @param string $table table name + * + * @access public + * @return PMA_Partition[] + */ + static public function getParititions($db, $table) + { + if (PMA_Partition::havePartitioning()) { + $result = $GLOBALS['dbi']->fetchResult( + "SELECT * FROM `information_schema`.`PARTITIONS`" + . " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db) + . "' AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'" + ); + if ($result) { + $partitionMap = array(); + foreach ($result as $row) { + + if (isset($partitionMap[$row['PARTITION_NAME']])) { + $tempPartition = $partitionMap[$row['PARTITION_NAME']]; + } else { + $tempPartition = new PMA_Partition( + $db, + $table, + $row['PARTITION_NAME'], + $row['PARTITION_ORDINAL_POSITION'], + $row['PARTITION_METHOD'], + $row['PARTITION_EXPRESSION'] + ); + $tempPartition->setDescription($row['PARTITION_DESCRIPTION']); + $partitionMap[$row['PARTITION_NAME']] = $tempPartition; + } + + if (! empty($row['SUBPARTITION_NAME'])) { + $parentPartition = $tempPartition; + $partition = new PMA_Partition( + $db, + $table, + $row['SUBPARTITION_NAME'], + $row['SUBPARTITION_ORDINAL_POSITION'], + $row['SUBPARTITION_METHOD'], + $row['SUBPARTITION_EXPRESSION'] + ); + $parentPartition->addSubPartition($parition); + } else { + $partition = $tempPartition; + } + + $partition->setRows($row['TABLE_ROWS']); + } + return array_values($partitionMap); + } + return array(); + } else { + return array(); + } + } + /** * returns array of partition names for a specific db/table * From 049ecbcdf6d48161ee091c01731412589f71a9bb Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Aug 2015 21:30:39 +0530 Subject: [PATCH 02/11] Introduce SubPartition class Signed-off-by: Madhura Jayaratne --- libraries/Partition.class.php | 215 +++++++++++++++++++++++++--------- 1 file changed, 157 insertions(+), 58 deletions(-) diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index 3c064dc28f..75ee2f852b 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -10,11 +10,11 @@ if (! defined('PHPMYADMIN')) { } /** - * base Partition Class + * Represents a sub partition of a table * * @package PhpMyAdmin */ -class PMA_Partition +class PMA_SubPartition { /** * @var string the database @@ -29,7 +29,7 @@ class PMA_Partition */ protected $name; /** - * @var int ordinal + * @var integer ordinal */ protected $ordinal; /** @@ -40,75 +40,194 @@ class PMA_Partition * @var string partition expression */ protected $expression; - /** - * @var string partition description - */ - protected $description; /** * @var integer no of table rows in the parition */ protected $rows; /** - * @var PMA_Partition[] sub partitions + * @var integer data length */ - protected $subPartitions = array(); + protected $dataLength; + /** + * @var integer index length + */ + protected $indexLength; /** * Constructs a partition * - * @param string $db database name - * @param string $table table name - * @param string $name parition name - * @param int $ordinal ordinal - * @param string $method partition method - * @param string $expression partition expression + * @param array $row fetched row from information_schema.PARTITIONS */ - public function __construct($db, $table, $name, $ordinal, $method, $expression) + public function __construct($row) { - $this->db = $db; - $this->table = $table; - $this->name = $name; - $this->ordinal = $ordinal; - $this->method = $method; - $this->expression = $expression; + $this->db = $row['TABLE_SCHEMA']; + $this->table = $row['TABLE_NAME']; + $this->loadData($row); } /** - * Sets the partition description + * Loads data from the fetched row from information_schema.PARTITIONS * - * @param string $description parition description + * @param array $row fetched row * * @return void */ - public function setDescription($description) + protected function loadData($row) { - $this->description = $description; + $this->name = $row['SUBPARTITION_NAME']; + $this->ordinal = $row['SUBPARTITION_ORDINAL_POSITION']; + $this->method = $row['SUBPARTITION_METHOD']; + $this->expression = $row['SUBPARTITION_EXPRESSION']; + $this->loadCommonData($row); } /** - * Sets the number of rows in the parition + * Loads some data that is common to both partitions and sub partitions * - * @param integer $rows number of rows + * @param array $row fetched row * * @return void */ - public function setRows($rows) + protected function loadCommonData($row) { - $this->rows = $rows; + $this->rows = $row['TABLE_ROWS']; + $this->dataLength = $row['DATA_LENGTH']; + $this->indexLength = $row['INDEX_LENGTH']; + } + + /** + * Returns the number of data rows + * + * @return integer number of rows + */ + public function getRows() + { + return $this->rows; + } + + /** + * Returns the data length + * + * @return integer data length + */ + public function getDataLength() + { + return $this->dataLength; + } + + /** + * Returns the index length + * + * @return integer index length + */ + public function getIndexLength() + { + return $this->indexLength; + } +} + +/** + * base Partition Class + * + * @package PhpMyAdmin + */ +class PMA_Partition extends PMA_SubPartition +{ + /** + * @var string partition description + */ + protected $description; + /** + * @var PMA_SubPartition[] sub partitions + */ + protected $subPartitions = array(); + + /** + * Loads data from the fetched row from information_schema.PARTITIONS + * + * @param array $row fetched row + * + * @return void + */ + protected function loadData($row) + { + $this->name = $row['PARTITION_NAME']; + $this->ordinal = $row['PARTITION_ORDINAL_POSITION']; + $this->method = $row['PARTITION_METHOD']; + $this->expression = $row['PARTITION_EXPRESSION']; + $this->description = $row['PARTITION_DESCRIPTION']; + // no sub partitions, load all data to this object + if (empty($row['SUBPARTITION_NAME'])) { + $this->loadCommonData($row); + } } /** * Add a sub parition * - * @param PMA_Partition $parition + * @param PMA_SubPartition $parition * * @return void */ - public function addSubPartition(PMA_Partition $parition) + public function addSubPartition(PMA_SubPartition $parition) { $this->subPartitions[] = $parition; } + /** + * Returns the number of data rows + * + * @return integer number of rows + */ + public function getRows() + { + if (empty($this->subPartitions)) { + return $this->rows; + } else { + $rows = 0; + foreach ($this->subPartitions as $subPartition) { + $rows += $subPartition->rows; + } + return $rows; + } + } + + /** + * Returns the total data length + * + * @return integer data length + */ + public function getDataLength() + { + if (empty($this->subPartitions)) { + return $this->dataLength; + } else { + $dataLength = 0; + foreach ($this->subPartitions as $subPartition) { + $dataLength += $subPartition->dataLength; + } + return $dataLength; + } + } + + /** + * Returns the tatal index length + * + * @return integer index length + */ + public function getIndexLength() + { + if (empty($this->subPartitions)) { + return $this->indexLength; + } else { + $indexLength = 0; + foreach ($this->subPartitions as $subPartition) { + $indexLength += $subPartition->indexLength; + } + return $indexLength; + } + } + /** * Returns array of partitions for a specific db/table * @@ -129,38 +248,18 @@ class PMA_Partition if ($result) { $partitionMap = array(); foreach ($result as $row) { - if (isset($partitionMap[$row['PARTITION_NAME']])) { - $tempPartition = $partitionMap[$row['PARTITION_NAME']]; + $partition = $partitionMap[$row['PARTITION_NAME']]; } else { - $tempPartition = new PMA_Partition( - $db, - $table, - $row['PARTITION_NAME'], - $row['PARTITION_ORDINAL_POSITION'], - $row['PARTITION_METHOD'], - $row['PARTITION_EXPRESSION'] - ); - $tempPartition->setDescription($row['PARTITION_DESCRIPTION']); - $partitionMap[$row['PARTITION_NAME']] = $tempPartition; + $partition = new PMA_Partition($row); + $partitionMap[$row['PARTITION_NAME']] = $partition; } if (! empty($row['SUBPARTITION_NAME'])) { - $parentPartition = $tempPartition; - $partition = new PMA_Partition( - $db, - $table, - $row['SUBPARTITION_NAME'], - $row['SUBPARTITION_ORDINAL_POSITION'], - $row['SUBPARTITION_METHOD'], - $row['SUBPARTITION_EXPRESSION'] - ); + $parentPartition = $partition; + $partition = new PMA_SubPartition($row); $parentPartition->addSubPartition($parition); - } else { - $partition = $tempPartition; } - - $partition->setRows($row['TABLE_ROWS']); } return array_values($partitionMap); } @@ -250,4 +349,4 @@ class PMA_Partition } return $have_partitioning; } -} +} \ No newline at end of file From 6c28a7020f2aaba5e3ac2bda287bdc71974c2d47 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 00:07:39 +0530 Subject: [PATCH 03/11] Add partition table Signed-off-by: Madhura Jayaratne --- libraries/Partition.class.php | 42 +++++++++- .../TableStructureController.class.php | 2 + .../table/structure/display_partitions.phtml | 79 +++++++++++++++++++ .../table/structure/display_structure.phtml | 15 ++++ 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 templates/table/structure/display_partitions.phtml diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index 75ee2f852b..461fd80027 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -95,6 +95,26 @@ class PMA_SubPartition $this->indexLength = $row['INDEX_LENGTH']; } + /** + * Return the parition name + * + * @return string partition name + */ + public function getName() + { + return $this->name; + } + + /** + * Return the ordinal of the parition + * + * @return number the ordinal + */ + public function getOrdinal() + { + return $this->ordinal; + } + /** * Returns the number of data rows * @@ -174,6 +194,16 @@ class PMA_Partition extends PMA_SubPartition $this->subPartitions[] = $parition; } + /** + * Whether there are sub partitions + * + * @return boolean + */ + public function hasSubParitions() + { + return ! empty($this->subPartitions); + } + /** * Returns the number of data rows * @@ -228,6 +258,16 @@ class PMA_Partition extends PMA_SubPartition } } + /** + * Returns the list of sub partitions + * + * @return PMA_SubPartition[] + */ + public function getSubParitions() + { + return $this->subPartitions; + } + /** * Returns array of partitions for a specific db/table * @@ -258,7 +298,7 @@ class PMA_Partition extends PMA_SubPartition if (! empty($row['SUBPARTITION_NAME'])) { $parentPartition = $partition; $partition = new PMA_SubPartition($row); - $parentPartition->addSubPartition($parition); + $parentPartition->addSubPartition($partition); } } return array_values($partitionMap); diff --git a/libraries/controllers/TableStructureController.class.php b/libraries/controllers/TableStructureController.class.php index 3f14b01da2..cf58f2875b 100644 --- a/libraries/controllers/TableStructureController.class.php +++ b/libraries/controllers/TableStructureController.class.php @@ -11,6 +11,7 @@ namespace PMA\Controllers; use PMA\Template; use PMA_Index; +use PMA_Partition; use PMA_Table; use PMA_Message; use PMA_PageSettings; @@ -21,6 +22,7 @@ use SqlParser; require_once 'libraries/common.inc.php'; require_once 'libraries/tbl_info.inc.php'; require_once 'libraries/Index.class.php'; +require_once 'libraries/Partition.class.php'; require_once 'libraries/mysql_charsets.inc.php'; require_once 'libraries/config/page_settings.class.php'; require_once 'libraries/transformations.lib.php'; diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml new file mode 100644 index 0000000000..1d4f5f1f76 --- /dev/null +++ b/templates/table/structure/display_partitions.phtml @@ -0,0 +1,79 @@ +
+
+ + + + + + + + + + + + + + + + + + hasSubParitions()): ?> + + + + + + + + + + + hasSubParitions()): ?> + getSubParitions() as $subParition): ?> + + + + + + + + + + + + + + + +
#
getOrdinal(); ?>getOrdinal(); ?>getName()); ?>getRows(); ?>getDataLength(), 3, 1 + ); + ?> + + + getIndexLength(), 3, 1 + ); + ?> + + +
getOrdinal(); ?>getName()); ?>getRows(); ?>getDataLength(), 3, 1 + ); + ?> + + + getIndexLength(), 3, 1 + ); + ?> + + +
+
+
\ No newline at end of file diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index 0d9f17d61b..bc7b2b3f9b 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -154,11 +154,26 @@ array('columns_list' => $columns_list) ); ?> + + + +render( + array( + 'partitions' => PMA_Partition::getParititions($db, $table) + ) + ); +} +?> + From e6756427e4bc461d4e939460012929c2bafec7f9 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 01:14:58 +0530 Subject: [PATCH 04/11] Add partition maintenance actions Signed-off-by: Madhura Jayaratne --- .../TableStructureController.class.php | 4 ++- libraries/sql.lib.php | 4 ++- .../table/structure/display_partitions.phtml | 26 ++++++++++++++++--- .../table/structure/display_structure.phtml | 4 ++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/libraries/controllers/TableStructureController.class.php b/libraries/controllers/TableStructureController.class.php index cf58f2875b..85e5c1332c 100644 --- a/libraries/controllers/TableStructureController.class.php +++ b/libraries/controllers/TableStructureController.class.php @@ -276,7 +276,9 @@ class TableStructureController extends TableController /** * Adding indexes */ - if (isset($_REQUEST['add_key'])) { + if (isset($_REQUEST['add_key']) + || isset($_REQUEST['partition_maintenance']) + ) { //todo: set some variables for sql.php include, to be eliminated //after refactoring sql.php $db = $this->db; diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 52f94eea26..12c7998b3d 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -1234,7 +1234,9 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql_results) include_once 'libraries/transformations.lib.php'; $statement = $analyzed_sql_results['statement']; if ($statement instanceof SqlParser\Statements\AlterStatement) { - if ($statement->altered[0]->options->has('DROP')) { + if (!empty($statement->altered[0]) + && $statement->altered[0]->options->has('DROP') + ) { if (!empty($statement->altered[0]->field->column)) { PMA_clearTransformations( $db, diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index 1d4f5f1f76..1ea3a65044 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -11,11 +11,22 @@ - + + PMA_Util::getIcon('b_empty.png', __('Analyze')), + 'CHECK' => PMA_Util::getIcon('eye.png', __('Check')), + 'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')), + 'REBUILD' => PMA_Util::getIcon('b_empty.png', __('Rebuild')), + 'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')), + 'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')), + 'DROP' => PMA_Util::getIcon('b_drop.png', __('Drop')) + ); + ?> hasSubParitions()): ?> @@ -42,7 +53,16 @@ - + $title): ?> + + getName() + ) ?>"> + + + + + hasSubParitions()): ?> getSubParitions() as $subParition): ?> @@ -66,7 +86,7 @@ - + diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index bc7b2b3f9b..bdc0375373 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -168,7 +168,9 @@ $partition_names = PMA_Partition::getPartitionNames($db, $table); if (! is_null($partition_names[0])) { echo PMA\Template::get('table/structure/display_partitions')->render( array( - 'partitions' => PMA_Partition::getParititions($db, $table) + 'table' => $table, + 'url_query' => $url_query, + 'partitions' => PMA_Partition::getParititions($db, $table), ) ); } From 8e70f48817dd51763de0098e79702b14e4e0952e Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 07:20:44 +0530 Subject: [PATCH 05/11] Mark partition if it has sub partitions Signed-off-by: Madhura Jayaratne --- libraries/Partition.class.php | 2 +- templates/table/structure/display_partitions.phtml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index 461fd80027..2807633c89 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -199,7 +199,7 @@ class PMA_Partition extends PMA_SubPartition * * @return boolean */ - public function hasSubParitions() + public function hasSubPartitions() { return ! empty($this->subPartitions); } diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index 1ea3a65044..eb4365ec2a 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -28,8 +28,9 @@ ); ?> - - hasSubParitions()): ?> + hasSubPartitions(); ?> + + getOrdinal(); ?> @@ -63,7 +64,7 @@ - hasSubParitions()): ?> + getSubParitions() as $subParition): ?> From 46f2d752a0da2d1de2e9bfafedcf49d63033725e Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 07:43:20 +0530 Subject: [PATCH 06/11] Confirm partition actions Signed-off-by: Madhura Jayaratne --- js/tbl_structure.js | 30 +++++++++++++++++++ .../table/structure/display_partitions.phtml | 10 +++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/js/tbl_structure.js b/js/tbl_structure.js index b8b8f68e1d..12ce6eb152 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -85,6 +85,7 @@ AJAX.registerTeardown('tbl_structure.js', function () { $(document).off('click', "#printView"); $(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'); }); AJAX.registerOnload('tbl_structure.js', function () { @@ -432,6 +433,35 @@ AJAX.registerOnload('tbl_structure.js', function () { AJAX.source = $form; $.post($form.attr('action'), submitData, AJAX.responseHandler); }); + + /** + * Handles clicks on Action links in parition table + */ + $(document).on('click', 'a[name^=partition_action].ajax', function (e) { + e.preventDefault(); + var $link = $(this); + + function submitPartitionAction(url) { + var submitData = '&ajax_request=true&ajax_page_request=true'; + PMA_ajaxShowMessage(); + AJAX.source = $link; + $.post(url, submitData, AJAX.responseHandler); + } + + if ($link.is('#partition_action_DROP')) { + var question = PMA_messages.strDropPartitionWarning; + $link.PMA_confirm(question, $link.attr('href'), function (url) { + submitPartitionAction(url); + }); + } else if ($link.is('#partition_action_TRUNCATE')) { + var question = PMA_messages.strTruncatePartitionWarning; + $link.PMA_confirm(question, $link.attr('href'), function (url) { + submitPartitionAction(url); + }); + } else { + submitPartitionAction($link.attr('href')); + } + }); }); /** Handler for "More" dropdown in structure table rows */ diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index eb4365ec2a..3ab017405c 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -56,9 +56,13 @@ $title): ?> - getName() - ) ?>"> + getName() + ) ?>" + id="partition_action_" + name="partition_action_" + class="ajax" + > From 51da800173fa046f646cbbe0378d70150c2b2567 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 13:14:33 +0530 Subject: [PATCH 07/11] Add details about partition method and expression Signed-off-by: Madhura Jayaratne --- libraries/Partition.class.php | 32 ++++++++++++++++- .../table/structure/display_partitions.phtml | 36 +++++++++++++++++-- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index 2807633c89..ca967a7622 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -115,6 +115,26 @@ class PMA_SubPartition return $this->ordinal; } + /** + * Returns the partition method + * + * @return string partition method + */ + public function getMethod() + { + return $this->method; + } + + /** + * Returns the partition expression + * + * @return string partition expression + */ + public function getExpression() + { + return $this->expression; + } + /** * Returns the number of data rows * @@ -182,6 +202,16 @@ class PMA_Partition extends PMA_SubPartition } } + /** + * Returns the partiotion description + * + * @return string partition description + */ + public function getDescription() + { + return $this->description; + } + /** * Add a sub parition * @@ -263,7 +293,7 @@ class PMA_Partition extends PMA_SubPartition * * @return PMA_SubPartition[] */ - public function getSubParitions() + public function getSubPartitions() { return $this->subPartitions; } diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index 3ab017405c..1b1574c244 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -3,11 +3,35 @@ + hasSubPartitions(); + $hasDescription = ! empty($firstPartition->getDescription()); + ?> +

+ + getMethod() + . '(' . $firstPartition->getExpression() . ' )'; ?> +

+ + getSubPartitions(); + $fristSubParition = $subParitions[0]; + ?> +

+ + getMethod() + . '(' . $fristSubParition->getExpression() . ' )'; ?> +

+ + + + @@ -28,7 +52,6 @@ ); ?> - hasSubPartitions(); ?> @@ -37,6 +60,12 @@ + + + + + +
#
getOrdinal(); ?>getOrdinal(); ?> getName()); ?> + getExpression() + . ' < ' . $partition->getDescription()); ?> + getRows(); ?> - getSubParitions() as $subParition): ?> + getSubPartitions() as $subParition): ?>
getOrdinal(); ?> getName()); ?> getRows(); ?> Date: Fri, 14 Aug 2015 13:32:35 +0530 Subject: [PATCH 08/11] Move variable declarations out of view Signed-off-by: Madhura Jayaratne --- .../table/structure/display_partitions.phtml | 36 ++++--------------- .../table/structure/display_structure.phtml | 30 ++++++++++++++-- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index 1b1574c244..df8818bf44 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -3,25 +3,14 @@ - hasSubPartitions(); - $hasDescription = ! empty($firstPartition->getDescription()); - ?>

- getMethod() - . '(' . $firstPartition->getExpression() . ' )'; ?> +

- getSubPartitions(); - $fristSubParition = $subParitions[0]; - ?>

- getMethod() - . '(' . $fristSubParition->getExpression() . ' )'; ?> +

@@ -40,17 +29,6 @@ - PMA_Util::getIcon('b_empty.png', __('Analyze')), - 'CHECK' => PMA_Util::getIcon('eye.png', __('Check')), - 'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')), - 'REBUILD' => PMA_Util::getIcon('b_empty.png', __('Rebuild')), - 'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')), - 'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')), - 'DROP' => PMA_Util::getIcon('b_drop.png', __('Drop')) - ); - ?> @@ -83,16 +61,16 @@ - $title): ?> + $icon): ?> diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index bdc0375373..c090062cb2 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -164,13 +164,39 @@ getSubPartitions(); + $hasSubPartitions = $firstPartition->hasSubPartitions(); + if ($hasSubPartitions) { + $firstSubPartition = $subParitions[0]; + } + + $actionIcons = array( + 'ANALYZE' => PMA_Util::getIcon('b_empty.png', __('Analyze')), + 'CHECK' => PMA_Util::getIcon('eye.png', __('Check')), + 'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')), + 'REBUILD' => PMA_Util::getIcon('b_empty.png', __('Rebuild')), + 'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')), + 'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')), + 'DROP' => PMA_Util::getIcon('b_drop.png', __('Drop')) + ); + echo PMA\Template::get('table/structure/display_partitions')->render( array( 'table' => $table, 'url_query' => $url_query, - 'partitions' => PMA_Partition::getParititions($db, $table), + 'partitions' => $partitions, + 'partitionMethod' => $firstPartition->getMethod(), + 'partitionExpression' => $firstPartition->getExpression(), + 'hasDescription' => ! empty($firstPartition->getDescription()), + 'hasSubPartitions' => $hasSubPartitions, + 'subPartitionMethod' => $hasSubPartitions ? $firstSubPartition->getMethod() : null, + 'subPartitionExpression' => $hasSubPartitions ? $firstSubPartition->getExpression() : null, + 'actionIcons' => $actionIcons, ) ); } From c6af1488027b5854392003cd8936e8f12b742b34 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 15:41:29 +0530 Subject: [PATCH 09/11] Better icons Signed-off-by: Madhura Jayaratne --- templates/table/structure/display_structure.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index c090062cb2..7d79cb6a91 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -176,10 +176,10 @@ if (! is_null($partition_names[0])) { } $actionIcons = array( - 'ANALYZE' => PMA_Util::getIcon('b_empty.png', __('Analyze')), + '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('b_empty.png', __('Rebuild')), + 'REBUILD' => PMA_Util::getIcon('s_tbl.png', __('Rebuild')), 'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')), 'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')), 'DROP' => PMA_Util::getIcon('b_drop.png', __('Drop')) From 00f7d5ea7a7a0eaf81b11f02c8b96d29721a3941 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 15:47:09 +0530 Subject: [PATCH 10/11] Fix typo Signed-off-by: Madhura Jayaratne --- js/tbl_structure.js | 2 +- libraries/Partition.class.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 12ce6eb152..7eb36c0946 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -435,7 +435,7 @@ AJAX.registerOnload('tbl_structure.js', function () { }); /** - * Handles clicks on Action links in parition table + * Handles clicks on Action links in partition table */ $(document).on('click', 'a[name^=partition_action].ajax', function (e) { e.preventDefault(); diff --git a/libraries/Partition.class.php b/libraries/Partition.class.php index ca967a7622..414c2f0e7d 100644 --- a/libraries/Partition.class.php +++ b/libraries/Partition.class.php @@ -41,7 +41,7 @@ class PMA_SubPartition */ protected $expression; /** - * @var integer no of table rows in the parition + * @var integer no of table rows in the partition */ protected $rows; /** @@ -96,7 +96,7 @@ class PMA_SubPartition } /** - * Return the parition name + * Return the partition name * * @return string partition name */ @@ -106,7 +106,7 @@ class PMA_SubPartition } /** - * Return the ordinal of the parition + * Return the ordinal of the partition * * @return number the ordinal */ @@ -213,15 +213,15 @@ class PMA_Partition extends PMA_SubPartition } /** - * Add a sub parition + * Add a sub partition * - * @param PMA_SubPartition $parition + * @param PMA_SubPartition $partition * * @return void */ - public function addSubPartition(PMA_SubPartition $parition) + public function addSubPartition(PMA_SubPartition $partition) { - $this->subPartitions[] = $parition; + $this->subPartitions[] = $partition; } /** From 088cb74573d53c7f1aa04a0c7b0a08650f76c584 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 14 Aug 2015 16:09:24 +0530 Subject: [PATCH 11/11] Fix expression for LIST type partitions Signed-off-by: Madhura Jayaratne --- templates/table/structure/display_partitions.phtml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/table/structure/display_partitions.phtml b/templates/table/structure/display_partitions.phtml index df8818bf44..e11def912b 100644 --- a/templates/table/structure/display_partitions.phtml +++ b/templates/table/structure/display_partitions.phtml @@ -40,8 +40,14 @@
getName() + "ALTER TABLE " . PMA_Util::backquote($table) . $action . " PARTITION " . $partition->getName() ) ?>" - id="partition_action_" - name="partition_action_" + id="partition_action_" + name="partition_action_" class="ajax" > - + getName()); ?> - getExpression() - . ' < ' . $partition->getDescription()); ?> + + getExpression()) + . ($partition->getMethod() == 'LIST' ? ' IN (' : ' < ') + . htmlspecialchars($partition->getDescription()) + . ($partition->getMethod() == 'LIST' ? ')' : ''); + ?> + getRows(); ?>