summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-11-08 14:14:26 +0200
committerDan Ungureanu <udan1107@gmail.com>2015-11-08 14:14:26 +0200
commit77974239bb04637a0dceefc3a301e345952fbbd0 (patch)
treeb53a8bbb1c4513e76bbb710cbddb77968a503cd0
parentedb0f111b948b30b969c5ab07c23af91caa5d2c8 (diff)
downloadsql-parser-77974239bb04637a0dceefc3a301e345952fbbd0.zip
sql-parser-77974239bb04637a0dceefc3a301e345952fbbd0.tar.gz
sql-parser-77974239bb04637a0dceefc3a301e345952fbbd0.tar.bz2
Fixed DELIMITER statements in BufferedQuery.
-rw-r--r--src/Utils/BufferedQuery.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php
index 7a2e5f4..f399220 100644
--- a/src/Utils/BufferedQuery.php
+++ b/src/Utils/BufferedQuery.php
@@ -283,6 +283,10 @@ class BufferedQuery
* `strtoupper(substr($this->query, $i, 9)) === 'DELIMITER'`
*
* This optimization makes the code about 3 times faster.
+ *
+ * `DELIMITER` is not being considered a keyword. The only context
+ * it has a special meaning is when it is the beginning of a
+ * statement. This is the reason for the last condition.
*/
if (($i + 9 < $len)
&& (($this->query[$i ] === 'D') || ($this->query[$i ] === 'd'))
@@ -295,6 +299,7 @@ class BufferedQuery
&& (($this->query[$i + 7] === 'E') || ($this->query[$i + 7] === 'e'))
&& (($this->query[$i + 8] === 'R') || ($this->query[$i + 8] === 'r'))
&& (Context::isWhitespace($this->query[$i + 9]))
+ && (trim($this->current) === '')
) {
// Saving the current index to be able to revert any parsing
// done in this block.