Skip to content

Commit 2f5d2da

Browse files
committed
Only RANGE and LIST type partitions support VALUES.
1 parent 59a7ca7 commit 2f5d2da

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Components/PartitionDefinition.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,16 @@ public static function parse(Parser $parser, TokensList $list, array $options =
147147
$state = 1;
148148
} elseif ($state === 1) {
149149
$ret->name = $token->value;
150-
$state = $ret->isSubpartition ? 5 : 2;
150+
151+
// Looking ahead for a 'VALUES' keyword.
152+
$idx = $list->idx;
153+
$list->getNext();
154+
$nextToken = $list->getNext();
155+
$list->idx = $idx;
156+
157+
$state = ($nextToken->type === Token::TYPE_KEYWORD)
158+
&& ($nextToken->value === 'VALUES')
159+
? 2 : 5;
151160
} elseif ($state === 2) {
152161
$state = 3;
153162
} elseif ($state === 3) {
@@ -205,9 +214,11 @@ public static function build($component, array $options = array())
205214
} else {
206215
$subpartitions = empty($component->subpartitions)
207216
? '' : ' ' . PartitionDefinition::build($component->subpartitions);
208-
return 'PARTITION ' . $component->name
209-
. ' VALUES ' . $component->type . ' ' . $component->expr
210-
. $component->options . $subpartitions;
217+
return trim(
218+
'PARTITION ' . $component->name
219+
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr)
220+
. $component->options . $subpartitions
221+
);
211222
}
212223
}
213224
}

0 commit comments

Comments
 (0)