Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Fixed differentiating between `ANALYZE` and `EXPLAIN` statements (#386)
* Added "NOT" to the select options (#374)
* Implement the `EXPLAIN` Parser (#389)
* Performance improvement to use less the `nextToken()` function (#397)

## [5.5.0] - 2021-12-08

Expand Down
14 changes: 2 additions & 12 deletions src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}
} elseif (! self::checkIfTokenQuotedSymbol($token)) {
if (! empty(Parser::$STATEMENT_PARSERS[$token->value])) {
// We want to get the next non-comment and non-space token after $token
// therefore, the first getNext call will start with the current $idx which's $token,
// will return it and increase $idx by 1, which's not guaranteed to be non-comment
// and non-space, that's why we're calling getNext again.

$list->getNext();
$list->idx++; // Ignore the current token
$nextToken = $list->getNext();

if ($token->value === 'SET' && $nextToken !== null && $nextToken->value === '(') {
Expand Down Expand Up @@ -387,12 +382,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$ret->unknown[] = $token;
} elseif ($state === 3) {
if ($partitionState === 0) {
// We want to get the next non-comment and non-space token after $token
// therefore, the first getNext call will start with the current $idx which's $token,
// will return it and increase $idx by 1, which's not guaranteed to be non-comment
// and non-space, that's why we're calling getNext again.

$list->getNext();
$list->idx++; // Ignore the current token
$nextToken = $list->getNext();
if (
($token->type === Token::TYPE_KEYWORD)
Expand Down
6 changes: 3 additions & 3 deletions src/Statements/ExplainStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ public function parse(Parser $parser, TokensList $list)
$state = 2;
} elseif ($state === 2) {
$currIdx = $list->idx;
$currToken = $list->getNext();
$list->idx++; // Ignore the current token
$nextToken = $list->getNext();
$list->idx = $currIdx;

if ($token->keyword === 'FOR' && $nextToken->keyword === 'CONNECTION') {
$forToken = $list->getNext(); // FOR
$connectionToken = $list->getNext(); // CONNECTION
$list->idx++; // Ignore the current token
$list->getNext(); // CONNECTION
$nextToken = $list->getNext(); // Identifier
$this->connectionId = $nextToken->value;
break;
Expand Down
6 changes: 1 addition & 5 deletions src/Statements/WithStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ public function parse(Parser $parser, TokensList $list)
} elseif ($state === 3) {
$idxBeforeGetNext = $list->idx;

// We want to get the next non-comment and non-space token after $token
// therefore, the first getNext call will start with the current $idx which's $token,
// will return it and increase $idx by 1, which's not guaranteed to be non-comment
// and non-space, that's why we're calling getNext again.
$list->getNext();
$list->idx++; // Ignore the current token
$nextKeyword = $list->getNext();

if (! ($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) {
Expand Down