File tree Expand file tree Collapse file tree 5 files changed +120
-33
lines changed
Expand file tree Collapse file tree 5 files changed +120
-33
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,14 @@ class AlterStatement extends Statement
6767 public function parse (Parser $ parser , TokensList $ list )
6868 {
6969 ++$ list ->idx ; // Skipping `ALTER`.
70- $ this ->options = OptionsArray::parse ($ parser , $ list , static ::$ OPTIONS );
70+ $ parsedOptions = OptionsArray::parse ($ parser , $ list , static ::$ OPTIONS );
71+ if ($ parsedOptions ->isEmpty ()) {
72+ $ parser ->error ('Unrecognized alter operation. ' , $ list ->tokens [$ list ->idx ]);
73+
74+ return ;
75+ }
76+
77+ $ this ->options = $ parsedOptions ;
7178 ++$ list ->idx ;
7279
7380 // Parsing affected table.
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ public function bugProvider(): array
2525 ['bugs/fuzz1 ' ],
2626 ['bugs/fuzz2 ' ],
2727 ['bugs/fuzz3 ' ],
28+ ['bugs/fuzz4 ' ],
2829 ['bugs/gh9 ' ],
2930 ['bugs/gh14 ' ],
3031 ['bugs/gh16 ' ],
Original file line number Diff line number Diff line change 6161 "statements": [
6262 {
6363 "@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement",
64- "table": {
65- "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
66- "database": null,
67- "table": null,
68- "column": null,
69- "expr": ".",
70- "alias": null,
71- "function": null,
72- "subquery": null
73- },
74- "altered": [
75- {
76- "@type": "PhpMyAdmin\\SqlParser\\Components\\AlterOperation",
77- "options": {
78- "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
79- "options": []
80- },
81- "field": null,
82- "partitions": null,
83- "unknown": [
84- {
85- "@type": "@4"
86- }
87- ]
88- }
89- ],
90- "options": {
91- "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
92- "options": []
93- },
64+ "table": null,
65+ "altered": [],
66+ "options": null,
9467 "first": 0,
95- "last": 3
68+ "last": 0
9669 }
9770 ],
9871 "brackets": 0,
10578 [
10679 "Unrecognized alter operation.",
10780 {
108- "@type": "@5"
81+ "@type": "@2"
82+ },
83+ 0
84+ ],
85+ [
86+ "Unexpected beginning of statement.",
87+ {
88+ "@type": "@4"
10989 },
11090 0
11191 ]
Original file line number Diff line number Diff line change 1+ ALTeR=SET
Original file line number Diff line number Diff line change 1+ {
2+ "query": "ALTeR=SET",
3+ "lexer": {
4+ "@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+ "str": "ALTeR=SET",
6+ "len": 9,
7+ "last": 9,
8+ "list": {
9+ "@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+ "tokens": [
11+ {
12+ "@type": "PhpMyAdmin\\SqlParser\\Token",
13+ "token": "ALTeR",
14+ "value": "ALTER",
15+ "keyword": "ALTER",
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": 2,
26+ "flags": 2,
27+ "position": 5
28+ },
29+ {
30+ "@type": "PhpMyAdmin\\SqlParser\\Token",
31+ "token": "SET",
32+ "value": "SET",
33+ "keyword": "SET",
34+ "type": 1,
35+ "flags": 11,
36+ "position": 6
37+ },
38+ {
39+ "@type": "PhpMyAdmin\\SqlParser\\Token",
40+ "token": null,
41+ "value": null,
42+ "keyword": null,
43+ "type": 9,
44+ "flags": 0,
45+ "position": null
46+ }
47+ ],
48+ "count": 4,
49+ "idx": 4
50+ },
51+ "delimiter": ";",
52+ "delimiterLen": 1,
53+ "strict": false,
54+ "errors": []
55+ },
56+ "parser": {
57+ "@type": "PhpMyAdmin\\SqlParser\\Parser",
58+ "list": {
59+ "@type": "@1"
60+ },
61+ "statements": [
62+ {
63+ "@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement",
64+ "table": null,
65+ "altered": [],
66+ "options": null,
67+ "first": 0,
68+ "last": 0
69+ },
70+ {
71+ "@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement",
72+ "options": {
73+ "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
74+ "options": []
75+ },
76+ "end_options": null,
77+ "set": [],
78+ "first": 1,
79+ "last": 2
80+ }
81+ ],
82+ "brackets": 0,
83+ "strict": false,
84+ "errors": []
85+ },
86+ "errors": {
87+ "lexer": [],
88+ "parser": [
89+ [
90+ "Unrecognized alter operation.",
91+ {
92+ "@type": "@2"
93+ },
94+ 0
95+ ]
96+ ]
97+ }
98+ }
You can’t perform that action at this time.
0 commit comments