Skip to content

Commit

Permalink
Only RANGE and LIST type partitions support VALUES.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ungureanu committed Oct 1, 2015
1 parent 59a7ca7 commit 2f5d2da
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Components/PartitionDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,16 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$state = 1;
} elseif ($state === 1) {
$ret->name = $token->value;
$state = $ret->isSubpartition ? 5 : 2;

// Looking ahead for a 'VALUES' keyword.
$idx = $list->idx;
$list->getNext();
$nextToken = $list->getNext();
$list->idx = $idx;

$state = ($nextToken->type === Token::TYPE_KEYWORD)
&& ($nextToken->value === 'VALUES')
? 2 : 5;
} elseif ($state === 2) {
$state = 3;
} elseif ($state === 3) {
Expand Down Expand Up @@ -205,9 +214,11 @@ public static function build($component, array $options = array())
} else {
$subpartitions = empty($component->subpartitions)
? '' : ' ' . PartitionDefinition::build($component->subpartitions);
return 'PARTITION ' . $component->name
. ' VALUES ' . $component->type . ' ' . $component->expr
. $component->options . $subpartitions;
return trim(
'PARTITION ' . $component->name
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr)
. $component->options . $subpartitions
);
}
}
}
Expand Down

0 comments on commit 2f5d2da

Please sign in to comment.