Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/classes/Index.php12
-rw-r--r--libraries/classes/IndexColumn.php26
-rw-r--r--templates/indexes.twig2
-rw-r--r--templates/table/structure/display_structure.twig2
4 files changed, 36 insertions, 6 deletions
diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php
index b194caf069..b51312a03c 100644
--- a/libraries/classes/Index.php
+++ b/libraries/classes/Index.php
@@ -254,13 +254,16 @@ class Index
*/
public function addColumn(array $params)
{
- if (! isset($params['Column_name'])
- || strlen($params['Column_name']) <= 0
- ) {
+ $key = $params['Column_name'] ?? $params['Expression'] ?? '';
+ if (isset($params['Expression'])) {
+ // The Expression only does not make the key unique, add a sequence number
+ $key .= $params['Seq_in_index'];
+ }
+ if (strlen($key) <= 0) {
return;
}
- $this->columns[$params['Column_name']] = new IndexColumn($params);
+ $this->columns[$key] = new IndexColumn($params);
}
/**
@@ -364,6 +367,7 @@ class Index
if (isset($params['Key_block_size'])) {
$this->keyBlockSize = $params['Key_block_size'];
}
+
if (! isset($params['Parser'])) {
return;
}
diff --git a/libraries/classes/IndexColumn.php b/libraries/classes/IndexColumn.php
index 0751337ef5..e0d9292ea1 100644
--- a/libraries/classes/IndexColumn.php
+++ b/libraries/classes/IndexColumn.php
@@ -49,6 +49,13 @@ class IndexColumn
private $cardinality = null;
/**
+ * If the Index uses an expression and not a name
+ *
+ * @var string|null
+ */
+ private $expression = null;
+
+ /**
* @param array $params an array containing the parameters of the index column
*/
public function __construct(array $params = [])
@@ -57,6 +64,22 @@ class IndexColumn
}
/**
+ * If the Index has an expression
+ */
+ public function hasExpression(): bool
+ {
+ return $this->expression !== null;
+ }
+
+ /**
+ * The Index expression if it has one
+ */
+ public function getExpression(): ?string
+ {
+ return $this->expression;
+ }
+
+ /**
* Sets parameters of the index column
*
* @param array $params an array containing the parameters of the index column
@@ -80,6 +103,9 @@ class IndexColumn
if (isset($params['Sub_part'])) {
$this->subPart = $params['Sub_part'];
}
+ if (isset($params['Expression'])) {
+ $this->expression = $params['Expression'];
+ }
if (! isset($params['Null'])) {
return;
}
diff --git a/templates/indexes.twig b/templates/indexes.twig
index 2cfddb8aac..3e54db141b 100644
--- a/templates/indexes.twig
+++ b/templates/indexes.twig
@@ -68,7 +68,7 @@
<tr class="noclick">
{% endif %}
<td>
- {{ column.getName() }}
+ {% if column.hasExpression() %}{{ column.getExpression() }}{% else %}{{ column.getName() }}{% endif %}
{% if column.getSubPart() is not empty %}
({{ column.getSubPart() }})
{% endif %}
diff --git a/templates/table/structure/display_structure.twig b/templates/table/structure/display_structure.twig
index 056d405c6c..9c404ce09e 100644
--- a/templates/table/structure/display_structure.twig
+++ b/templates/table/structure/display_structure.twig
@@ -475,7 +475,7 @@
<tr class="noclick">
{% endif %}
<td>
- {{ column.getName() }}
+ {% if column.hasExpression() %}{{ column.getExpression() }}{% else %}{{ column.getName() }}{% endif %}
{% if column.getSubPart() is not empty %}
({{ column.getSubPart() }})
{% endif %}