Skip to content

Commit 6ee6fa8

Browse files
committed
Add support for MariaDB 10.3 INTERSECT and EXCEPT.
Fixes #166 Signed-off-by: Michal Čihař <[email protected]>
1 parent 1c1abcc commit 6ee6fa8

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased]
44

55
* Initial support for MariaDB SQL contexts.
6+
* Add support for MariaDB 10.3 INTERSECT and EXCEPT.
67

78
## [4.1.10] - 2017-08-21
89

src/Parser.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ class Parser extends Core
110110
'field' => 'end_options',
111111
),
112112

113+
'INTERSECT' => array(
114+
'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
115+
'field' => 'union',
116+
),
117+
'EXCEPT' => array(
118+
'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
119+
'field' => 'union',
120+
),
113121
'UNION' => array(
114122
'class' => 'PhpMyAdmin\\SqlParser\\Components\\UnionKeyword',
115123
'field' => 'union',
@@ -427,7 +435,12 @@ public function parse()
427435
continue;
428436
}
429437

430-
if (($token->keyword === 'UNION') || ($token->keyword === 'UNION ALL') || ($token->keyword === 'UNION DISTINCT')) {
438+
if (($token->keyword === 'UNION') ||
439+
($token->keyword === 'UNION ALL') ||
440+
($token->keyword === 'UNION DISTINCT') ||
441+
($token->keyword === 'EXCEPT') ||
442+
($token->keyword === 'INTERSECT')
443+
) {
431444
$unionType = $token->keyword;
432445
continue;
433446
}

src/Statement.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,12 @@ public function parse(Parser $parser, TokensList $list)
246246

247247
// Unions are parsed by the parser because they represent more than
248248
// one statement.
249-
if (($token->value === 'UNION') || ($token->value === 'UNION ALL') || ($token->value === 'UNION DISTINCT')) {
249+
if (($token->keyword === 'UNION') ||
250+
($token->keyword === 'UNION ALL') ||
251+
($token->keyword === 'UNION DISTINCT') ||
252+
($token->keyword === 'EXCEPT') ||
253+
($token->keyword === 'INTERSECT')
254+
) {
250255
break;
251256
}
252257

src/Statements/SelectStatement.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class SelectStatement extends Statement
112112
'LIMIT' => array('LIMIT', 3),
113113
'PROCEDURE' => array('PROCEDURE', 3),
114114
'UNION' => array('UNION', 1),
115+
'EXCEPT' => array('EXCEPT', 1),
116+
'INTERSECT' => array('INTERSECT', 1),
115117
'_END_OPTIONS' => array('_END_OPTIONS', 1),
116118
// These are available only when `UNION` is present.
117119
// 'ORDER BY' => array('ORDER BY', 3),

0 commit comments

Comments
 (0)