Skip to content

Commit a05588a

Browse files
committed
Merge branch '5.10.x' into 5.11.x
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents 4652d80 + b14fd66 commit a05588a

11 files changed

+1614
-313
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## [5.10.1] - 2024-11-10
4+
5+
### Fixed
6+
7+
- Fix parsing of ALTER TABLE … RENAME KEY (#580)
8+
- Fix parsing table names that start with "e1" (#578)
9+
- Improve handling of negative and overflowed offsets on TokensList (#582)
10+
- Fix parsing of queries with 'AND' (#590)
11+
- Fix C style comments with two asterisks (#597)
12+
- Fix parsing of SRID in column definition (#595)
13+
314
## [5.10.0] - 2024-08-29
415

516
- Fix parsing of UPDATE ... SET (#577)
@@ -579,6 +590,7 @@ __Breaking changes:__
579590

580591
* First release of this library.
581592

593+
[5.10.1]: https://github.com/phpmyadmin/sql-parser/compare/5.10.0...5.10.1
582594
[5.10.0]: https://github.com/phpmyadmin/sql-parser/compare/5.9.1...5.10.0
583595
[5.9.1]: https://github.com/phpmyadmin/sql-parser/compare/5.9.0...5.9.1
584596
[5.9.0]: https://github.com/phpmyadmin/sql-parser/compare/5.8.2...5.9.0

src/Components/CreateDefinition.php

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class CreateDefinition extends Component
9393
'ENFORCED' => 14,
9494
'NOT' => 15,
9595
'COMPRESSED' => 16,
96+
'SRID' => [
97+
17,
98+
'var',
99+
],
96100
// Common entries.
97101
//
98102
// NOTE: Some of the common options are not in the same order which

src/Lexer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ public function parseComment()
677677
// - "SELECT */* comment */ FROM ..."
678678
// - "SELECT 2*/* comment */3 AS `six`;"
679679
$next = $this->last + 1;
680-
if (($next < $this->len) && $this->str[$next] === '*') {
680+
if (($next < $this->len) && $this->str[$next] === '*' && $token === '*/') {
681681
// Conflict in "*/*": first "*" was not for ending a comment.
682682
// Stop here and let other parsing method define the true behavior of that first star.
683683
$this->last = $iBak;

tests/Lexer/LexerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static function lexProvider(): array
7979
['lexer/lexOperator'],
8080
['lexer/lexOperatorStarIsArithmetic'],
8181
['lexer/lexOperatorStarIsWildcard'],
82+
['lexer/lexEmptyCStyleComment'],
8283
['lexer/lexString'],
8384
['lexer/lexStringErr1'],
8485
['lexer/lexSymbol'],

tests/Parser/CreateStatementTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static function createProvider(): array
6262
['parser/parseCreateTableAsSelect'],
6363
['parser/parseCreateTableLike'],
6464
['parser/parseCreateTableSpatial'],
65+
['parser/parseCreateTableSRID'],
6566
['parser/parseCreateTableTimestampWithPrecision'],
6667
['parser/parseCreateTableEnforcedCheck'],
6768
['parser/parseCreateTableNotEnforcedCheck'],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT /**/ 1
2+
SELECT /*+*/ 1
3+
SELECT /***/ 1
4+
SELECT /** */ 1
5+
SELECT /* **/ 1
+304
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
{
2+
"query": "SELECT /**/ 1\nSELECT /*+*/ 1\nSELECT /***/ 1\nSELECT /** */ 1\nSELECT /* **/ 1\n",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "SELECT /**/ 1\nSELECT /*+*/ 1\nSELECT /***/ 1\nSELECT /** */ 1\nSELECT /* **/ 1\n",
6+
"len": 76,
7+
"last": 76,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "SELECT",
14+
"value": "SELECT",
15+
"keyword": "SELECT",
16+
"type": 1,
17+
"flags": 3,
18+
"position": 0
19+
},
20+
{
21+
"@type": "PhpMyAdmin\\SqlParser\\Token",
22+
"token": " ",
23+
"value": " ",
24+
"keyword": null,
25+
"type": 3,
26+
"flags": 0,
27+
"position": 6
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "/**/",
32+
"value": "/**/",
33+
"keyword": null,
34+
"type": 4,
35+
"flags": 2,
36+
"position": 7
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 11
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "1",
50+
"value": 1,
51+
"keyword": null,
52+
"type": 6,
53+
"flags": 0,
54+
"position": 12
55+
},
56+
{
57+
"@type": "PhpMyAdmin\\SqlParser\\Token",
58+
"token": "\n",
59+
"value": " ",
60+
"keyword": null,
61+
"type": 3,
62+
"flags": 0,
63+
"position": 13
64+
},
65+
{
66+
"@type": "PhpMyAdmin\\SqlParser\\Token",
67+
"token": "SELECT",
68+
"value": "SELECT",
69+
"keyword": "SELECT",
70+
"type": 1,
71+
"flags": 3,
72+
"position": 14
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": " ",
77+
"value": " ",
78+
"keyword": null,
79+
"type": 3,
80+
"flags": 0,
81+
"position": 20
82+
},
83+
{
84+
"@type": "PhpMyAdmin\\SqlParser\\Token",
85+
"token": "/*+*/",
86+
"value": "/*+*/",
87+
"keyword": null,
88+
"type": 4,
89+
"flags": 2,
90+
"position": 21
91+
},
92+
{
93+
"@type": "PhpMyAdmin\\SqlParser\\Token",
94+
"token": " ",
95+
"value": " ",
96+
"keyword": null,
97+
"type": 3,
98+
"flags": 0,
99+
"position": 26
100+
},
101+
{
102+
"@type": "PhpMyAdmin\\SqlParser\\Token",
103+
"token": "1",
104+
"value": 1,
105+
"keyword": null,
106+
"type": 6,
107+
"flags": 0,
108+
"position": 27
109+
},
110+
{
111+
"@type": "PhpMyAdmin\\SqlParser\\Token",
112+
"token": "\n",
113+
"value": " ",
114+
"keyword": null,
115+
"type": 3,
116+
"flags": 0,
117+
"position": 28
118+
},
119+
{
120+
"@type": "PhpMyAdmin\\SqlParser\\Token",
121+
"token": "SELECT",
122+
"value": "SELECT",
123+
"keyword": "SELECT",
124+
"type": 1,
125+
"flags": 3,
126+
"position": 29
127+
},
128+
{
129+
"@type": "PhpMyAdmin\\SqlParser\\Token",
130+
"token": " ",
131+
"value": " ",
132+
"keyword": null,
133+
"type": 3,
134+
"flags": 0,
135+
"position": 35
136+
},
137+
{
138+
"@type": "PhpMyAdmin\\SqlParser\\Token",
139+
"token": "/***/",
140+
"value": "/***/",
141+
"keyword": null,
142+
"type": 4,
143+
"flags": 2,
144+
"position": 36
145+
},
146+
{
147+
"@type": "PhpMyAdmin\\SqlParser\\Token",
148+
"token": " ",
149+
"value": " ",
150+
"keyword": null,
151+
"type": 3,
152+
"flags": 0,
153+
"position": 41
154+
},
155+
{
156+
"@type": "PhpMyAdmin\\SqlParser\\Token",
157+
"token": "1",
158+
"value": 1,
159+
"keyword": null,
160+
"type": 6,
161+
"flags": 0,
162+
"position": 42
163+
},
164+
{
165+
"@type": "PhpMyAdmin\\SqlParser\\Token",
166+
"token": "\n",
167+
"value": " ",
168+
"keyword": null,
169+
"type": 3,
170+
"flags": 0,
171+
"position": 43
172+
},
173+
{
174+
"@type": "PhpMyAdmin\\SqlParser\\Token",
175+
"token": "SELECT",
176+
"value": "SELECT",
177+
"keyword": "SELECT",
178+
"type": 1,
179+
"flags": 3,
180+
"position": 44
181+
},
182+
{
183+
"@type": "PhpMyAdmin\\SqlParser\\Token",
184+
"token": " ",
185+
"value": " ",
186+
"keyword": null,
187+
"type": 3,
188+
"flags": 0,
189+
"position": 50
190+
},
191+
{
192+
"@type": "PhpMyAdmin\\SqlParser\\Token",
193+
"token": "/** */",
194+
"value": "/** */",
195+
"keyword": null,
196+
"type": 4,
197+
"flags": 2,
198+
"position": 51
199+
},
200+
{
201+
"@type": "PhpMyAdmin\\SqlParser\\Token",
202+
"token": " ",
203+
"value": " ",
204+
"keyword": null,
205+
"type": 3,
206+
"flags": 0,
207+
"position": 57
208+
},
209+
{
210+
"@type": "PhpMyAdmin\\SqlParser\\Token",
211+
"token": "1",
212+
"value": 1,
213+
"keyword": null,
214+
"type": 6,
215+
"flags": 0,
216+
"position": 58
217+
},
218+
{
219+
"@type": "PhpMyAdmin\\SqlParser\\Token",
220+
"token": "\n",
221+
"value": " ",
222+
"keyword": null,
223+
"type": 3,
224+
"flags": 0,
225+
"position": 59
226+
},
227+
{
228+
"@type": "PhpMyAdmin\\SqlParser\\Token",
229+
"token": "SELECT",
230+
"value": "SELECT",
231+
"keyword": "SELECT",
232+
"type": 1,
233+
"flags": 3,
234+
"position": 60
235+
},
236+
{
237+
"@type": "PhpMyAdmin\\SqlParser\\Token",
238+
"token": " ",
239+
"value": " ",
240+
"keyword": null,
241+
"type": 3,
242+
"flags": 0,
243+
"position": 66
244+
},
245+
{
246+
"@type": "PhpMyAdmin\\SqlParser\\Token",
247+
"token": "/* **/",
248+
"value": "/* **/",
249+
"keyword": null,
250+
"type": 4,
251+
"flags": 2,
252+
"position": 67
253+
},
254+
{
255+
"@type": "PhpMyAdmin\\SqlParser\\Token",
256+
"token": " ",
257+
"value": " ",
258+
"keyword": null,
259+
"type": 3,
260+
"flags": 0,
261+
"position": 73
262+
},
263+
{
264+
"@type": "PhpMyAdmin\\SqlParser\\Token",
265+
"token": "1",
266+
"value": 1,
267+
"keyword": null,
268+
"type": 6,
269+
"flags": 0,
270+
"position": 74
271+
},
272+
{
273+
"@type": "PhpMyAdmin\\SqlParser\\Token",
274+
"token": "\n",
275+
"value": " ",
276+
"keyword": null,
277+
"type": 3,
278+
"flags": 0,
279+
"position": 75
280+
},
281+
{
282+
"@type": "PhpMyAdmin\\SqlParser\\Token",
283+
"token": null,
284+
"value": null,
285+
"keyword": null,
286+
"type": 9,
287+
"flags": 0,
288+
"position": null
289+
}
290+
],
291+
"count": 31,
292+
"idx": 0
293+
},
294+
"delimiter": ";",
295+
"delimiterLen": 1,
296+
"strict": false,
297+
"errors": []
298+
},
299+
"parser": null,
300+
"errors": {
301+
"lexer": [],
302+
"parser": []
303+
}
304+
}

tests/data/lexer/lexOperatorStarIsWildcard.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SELECT a.*, b.* FROM
66
SELECT a.*, /* with a comment */ b.* FROM
77
SELECT a.*,/* with a comment */b.* FROM
88
SELECT a.* /* comment */ FROM
9-
-- SELECT a.*/* comment */ FROM (This one is not working yet because of https://github.com/phpmyadmin/sql-parser/issues/285. Please uncomment when this issue is fixed.)
9+
SELECT a.*/* comment */ FROM
1010
SELECT DISTINCT * FROM
1111
SELECT DISTINCT *FROM
1212
SELECT DISTINCT a.* FROM
@@ -15,7 +15,7 @@ SELECT DISTINCT a.*, b.* FROM
1515
SELECT DISTINCT a.*, /* with a comment */ b.* FROM
1616
SELECT DISTINCT a.*,/* with a comment */b.* FROM
1717
SELECT DISTINCT a.* /* comment */ FROM
18-
-- SELECT DISTINCT a.*/* comment */ FROM (This one is not working yet because of https://github.com/phpmyadmin/sql-parser/issues/285. Please uncomment when this issue is fixed.)
18+
SELECT DISTINCT a.*/* comment */ FROM
1919
SELECT `*` FROM table_name
2020
SELECT `*`.* FROM table_name AS `*`
2121
SELECT COUNT(*) FROM table_name

0 commit comments

Comments
 (0)