summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDeven Bansod <devenbansod.bits@gmail.com>2018-12-21 11:43:44 +0530
committerDeven Bansod <devenbansod.bits@gmail.com>2018-12-21 11:43:44 +0530
commite135782aca6e54e9535e43aaa34259392d92dc89 (patch)
treeccab01cc3035682fee210e813e484e6eabba4211 /src
parent5e8dbcf3ff0d1123efd731863083a9af539e5992 (diff)
downloadsql-parser-e135782aca6e54e9535e43aaa34259392d92dc89.zip
sql-parser-e135782aca6e54e9535e43aaa34259392d92dc89.tar.gz
sql-parser-e135782aca6e54e9535e43aaa34259392d92dc89.tar.bz2
Add support for end options in SET statement
* Support `[{ COLLATE expr | DEFAULT }] in `SET NAMES` statement Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Statement.php15
-rw-r--r--src/Statements/SetStatement.php22
2 files changed, 33 insertions, 4 deletions
diff --git a/src/Statement.php b/src/Statement.php
index 4186275..ec715c2 100644
--- a/src/Statement.php
+++ b/src/Statement.php
@@ -354,12 +354,23 @@ abstract class Statement
$parsedOptions = true;
}
} elseif ($class === null) {
- // Handle special end options in Select statement
- // See Statements\SelectStatement::$END_OPTIONS
if ($this instanceof Statements\SelectStatement
&& ($token->value === 'FOR UPDATE'
|| $token->value === 'LOCK IN SHARE MODE')
) {
+ // Handle special end options in Select statement
+ // See Statements\SelectStatement::$END_OPTIONS
+ $this->end_options = OptionsArray::parse(
+ $parser,
+ $list,
+ static::$END_OPTIONS
+ );
+ } elseif ($this instanceof Statements\SetStatement
+ && ($token->value === 'COLLATE'
+ || $token->value === 'DEFAULT')
+ ) {
+ // Handle special end options in SET statement
+ // See Statements\SetStatement::$END_OPTIONS
$this->end_options = OptionsArray::parse(
$parser,
$list,
diff --git a/src/Statements/SetStatement.php b/src/Statements/SetStatement.php
index 007134f..ef3a0c1 100644
--- a/src/Statements/SetStatement.php
+++ b/src/Statements/SetStatement.php
@@ -28,6 +28,7 @@ class SetStatement extends Statement
*/
public static $CLAUSES = array(
'SET' => array('SET', 3),
+ '_END_OPTIONS' => array('_END_OPTIONS', 1),
);
/**
@@ -42,6 +43,11 @@ class SetStatement extends Statement
'PASSWORD' => array(3, 'expr'),
);
+ public static $END_OPTIONS = array(
+ 'COLLATE' => array(1, 'var'),
+ 'DEFAULT' => 1
+ );
+
/**
* Options used in current statement.
*
@@ -50,6 +56,15 @@ class SetStatement extends Statement
public $options;
/**
+ * The end options of this query.
+ *
+ * @var OptionsArray
+ *
+ * @see static::$END_OPTIONS
+ */
+ public $end_options;
+
+ /**
* The updated values.
*
* @var SetOperation[]
@@ -61,7 +76,10 @@ class SetStatement extends Statement
*/
public function build()
{
- return 'SET ' . OptionsArray::build($this->options)
- . ' ' . SetOperation::build($this->set);
+ $ret = 'SET ' . OptionsArray::build($this->options)
+ . ' ' . SetOperation::build($this->set)
+ . ' ' . OptionsArray::build($this->end_options);
+
+ return trim($ret);
}
}