summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2017-08-30 12:07:32 +0200
committerMichal Čihař <michal@cihar.com>2017-08-30 12:07:32 +0200
commit6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30 (patch)
treeea2974c011912b5bec3ffadc63e54fefd7743390
parent1c1abcc7f311eb55ddeef4fed2d03119683ccc10 (diff)
downloadsql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.zip
sql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.tar.gz
sql-parser-6ee6fa8e3b0df5b954b3156da5f75bf4ceb93f30.tar.bz2
Add support for MariaDB 10.3 INTERSECT and EXCEPT.
Fixes #166 Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/Parser.php15
-rw-r--r--src/Statement.php7
-rw-r--r--src/Statements/SelectStatement.php2
4 files changed, 23 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1078114..4853319 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## [Unreleased]
* Initial support for MariaDB SQL contexts.
+* Add support for MariaDB 10.3 INTERSECT and EXCEPT.
## [4.1.10] - 2017-08-21
diff --git a/src/Parser.php b/src/Parser.php
index 9ef7deb..88451f0 100644
--- a/src/Parser.php
+++ b/src/Parser.php
@@ -110,6 +110,14 @@ class Parser extends Core
'field' => 'end_options',
),
+ 'INTERSECT' => array(
+ 'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
+ 'field' => 'union',
+ ),
+ 'EXCEPT' => array(
+ 'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
+ 'field' => 'union',
+ ),
'UNION' => array(
'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
'field' => 'union',
@@ -427,7 +435,12 @@ class Parser extends Core
continue;
}
- if (($token->keyword === 'UNION') || ($token->keyword === 'UNION ALL') || ($token->keyword === 'UNION DISTINCT')) {
+ if (($token->keyword === 'UNION') ||
+ ($token->keyword === 'UNION ALL') ||
+ ($token->keyword === 'UNION DISTINCT') ||
+ ($token->keyword === 'EXCEPT') ||
+ ($token->keyword === 'INTERSECT')
+ ) {
$unionType = $token->keyword;
continue;
}
diff --git a/src/Statement.php b/src/Statement.php
index ab554c3..59850d6 100644
--- a/src/Statement.php
+++ b/src/Statement.php
@@ -246,7 +246,12 @@ abstract class Statement
// Unions are parsed by the parser because they represent more than
// one statement.
- if (($token->value === 'UNION') || ($token->value === 'UNION ALL') || ($token->value === 'UNION DISTINCT')) {
+ if (($token->keyword === 'UNION') ||
+ ($token->keyword === 'UNION ALL') ||
+ ($token->keyword === 'UNION DISTINCT') ||
+ ($token->keyword === 'EXCEPT') ||
+ ($token->keyword === 'INTERSECT')
+ ) {
break;
}
diff --git a/src/Statements/SelectStatement.php b/src/Statements/SelectStatement.php
index deee68a..3dd0416 100644
--- a/src/Statements/SelectStatement.php
+++ b/src/Statements/SelectStatement.php
@@ -112,6 +112,8 @@ class SelectStatement extends Statement
'LIMIT' => array('LIMIT', 3),
'PROCEDURE' => array('PROCEDURE', 3),
'UNION' => array('UNION', 1),
+ 'EXCEPT' => array('EXCEPT', 1),
+ 'INTERSECT' => array('INTERSECT', 1),
'_END_OPTIONS' => array('_END_OPTIONS', 1),
// These are available only when `UNION` is present.
// 'ORDER BY' => array('ORDER BY', 3),