summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugues Peccatte <hugues.peccatte@aareon.fr>2019-11-01 00:51:39 +0100
committerHugues Peccatte <hugues.peccatte@aareon.fr>2019-11-01 00:51:39 +0100
commitfe98a34d4c5e557fbc3c0ae1152f8570bcaf2991 (patch)
treef6995d92c97bba607c8ba1d4cc68b73be134dbe1
parent49731d2db2e45f967d3b1c103958f6d9f189e543 (diff)
downloadsql-parser-fe98a34d4c5e557fbc3c0ae1152f8570bcaf2991.zip
sql-parser-fe98a34d4c5e557fbc3c0ae1152f8570bcaf2991.tar.gz
sql-parser-fe98a34d4c5e557fbc3c0ae1152f8570bcaf2991.tar.bz2
Fix #13951 wrong parsing partitions
When partition names contain "_", the parser wasn't reading the full name, but stopped before the first "_". Signed-off-by: Hugues Peccatte <hugues.peccatte@aareon.fr>
-rw-r--r--src/Components/PartitionDefinition.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php
index 71f73b8..841a16a 100644
--- a/src/Components/PartitionDefinition.php
+++ b/src/Components/PartitionDefinition.php
@@ -170,10 +170,16 @@ class PartitionDefinition extends Component
$ret->name = $token->value;
// Looking ahead for a 'VALUES' keyword.
- $idx = $list->idx;
- $list->getNext();
- $nextToken = $list->getNext();
- $list->idx = $idx;
+ // Loop until the end of the partition name (delimited by a whitespace)
+ while ($nextToken = $list->tokens[++$list->idx]) {
+ if ($nextToken->type === Token::TYPE_WHITESPACE) {
+ break;
+ }
+ $ret->name .= $nextToken->value;
+ }
+ $idx = $list->idx--;
+ // Get the first token after the white space.
+ $nextToken = $list->tokens[++$idx];
$state = ($nextToken->type === Token::TYPE_KEYWORD)
&& ($nextToken->value === 'VALUES')