summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Lexer.php6
-rw-r--r--src/Token.php8
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Lexer.php b/src/Lexer.php
index b969a19..e11d5a2 100644
--- a/src/Lexer.php
+++ b/src/Lexer.php
@@ -799,7 +799,11 @@ namespace SqlParser {
}
if ($flags & Token::FLAG_SYMBOL_VARIABLE) {
- ++$this->last;
+ if ($this->str[++$this->last] === '@') {
+ // This is a system variable (e.g. `@@hostname`).
+ $token .= $this->str[$this->last++];
+ $flags |= Token::FLAG_SYMBOL_SYSTEM;
+ }
} else {
$token = '';
}
diff --git a/src/Token.php b/src/Token.php
index 3c36d1c..d534321 100644
--- a/src/Token.php
+++ b/src/Token.php
@@ -157,6 +157,7 @@ class Token
const FLAG_SYMBOL_VARIABLE = 1;
const FLAG_SYMBOL_BACKTICK = 2;
const FLAG_SYMBOL_USER = 4;
+ const FLAG_SYMBOL_SYSTEM = 8;
/**
* The token it its raw string representation.
@@ -256,7 +257,12 @@ class Token
if ((isset($str[0])) && ($str[0] === '@')) {
// `mb_strlen($str)` must be used instead of `null` because
// in PHP 5.3- the `null` parameter isn't handled correctly.
- $str = mb_substr($str, 1, mb_strlen($str), 'UTF-8');
+ $str = mb_substr(
+ $str,
+ ((!empty($str[1])) && ($str[1] === '@')) ? 2 : 1,
+ mb_strlen($str),
+ 'UTF-8'
+ );
}
if ((isset($str[0])) && (($str[0] === '`')
|| ($str[0] === '"') || ($str[0] === '\''))