Skip to content

Commit 35398df

Browse files
committed
Support ALTER FUNCTION and ALTER PROCEDURE statements by the parser.
1 parent e4dff20 commit 35398df

13 files changed

+210
-712
lines changed

src/Statements/AlterStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function parse(Parser $parser, TokensList $list)
130130
} elseif ($this->options->has('EVENT')) {
131131
$options = AlterOperation::$EVENT_OPTIONS;
132132
} elseif ($this->options->has('FUNCTION') || $this->options->has('PROCEDURE')) {
133-
//$options = AlterOperation::$ROUTINE_OPTIONS;
133+
$options = AlterOperation::$ROUTINE_OPTIONS;
134134
}
135135

136136
$this->altered[] = AlterOperation::parse($parser, $list, $options);

tests/data/parser/parseAlterFunction1.out

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,18 @@
162162
},
163163
"options": {
164164
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
165-
"options": []
166-
},
167-
"field": {
168-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
169-
"database": null,
170-
"table": null,
171-
"column": "COMMENT",
172-
"expr": "COMMENT",
173-
"alias": null,
174-
"function": null,
175-
"subquery": null
165+
"options": {
166+
"1": {
167+
"name": "COMMENT",
168+
"equals": false,
169+
"expr": "\"test\"",
170+
"value": "test"
171+
}
172+
}
176173
},
174+
"field": null,
177175
"partitions": null,
178-
"unknown": [
179-
{
180-
"@type": "@10"
181-
}
182-
]
176+
"unknown": []
183177
}
184178
],
185179
"options": {
@@ -198,14 +192,6 @@
198192
},
199193
"errors": {
200194
"lexer": [],
201-
"parser": [
202-
[
203-
"Unrecognized alter operation.",
204-
{
205-
"@type": "@11"
206-
},
207-
0
208-
]
209-
]
195+
"parser": []
210196
}
211197
}

tests/data/parser/parseAlterFunction2.out

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,13 @@
6464
},
6565
{
6666
"@type": "PhpMyAdmin\\SqlParser\\Token",
67-
"token": "LANGUAGE",
68-
"value": "LANGUAGE",
69-
"keyword": "LANGUAGE",
67+
"token": "LANGUAGE SQL",
68+
"value": "LANGUAGE SQL",
69+
"keyword": "LANGUAGE SQL",
7070
"type": 1,
71-
"flags": 1,
71+
"flags": 7,
7272
"position": 25
7373
},
74-
{
75-
"@type": "PhpMyAdmin\\SqlParser\\Token",
76-
"token": " ",
77-
"value": " ",
78-
"keyword": null,
79-
"type": 3,
80-
"flags": 0,
81-
"position": 33
82-
},
83-
{
84-
"@type": "PhpMyAdmin\\SqlParser\\Token",
85-
"token": "SQL",
86-
"value": "SQL",
87-
"keyword": "SQL",
88-
"type": 1,
89-
"flags": 3,
90-
"position": 34
91-
},
9274
{
9375
"@type": "PhpMyAdmin\\SqlParser\\Token",
9476
"token": ";",
@@ -117,8 +99,8 @@
11799
"position": null
118100
}
119101
],
120-
"count": 12,
121-
"idx": 12
102+
"count": 10,
103+
"idx": 10
122104
},
123105
"delimiter": ";",
124106
"delimiterLen": 1,
@@ -162,24 +144,13 @@
162144
},
163145
"options": {
164146
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
165-
"options": []
166-
},
167-
"field": {
168-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
169-
"database": null,
170-
"table": null,
171-
"column": "LANGUAGE",
172-
"expr": "LANGUAGE",
173-
"alias": null,
174-
"function": null,
175-
"subquery": null
147+
"options": {
148+
"2": "LANGUAGE SQL"
149+
}
176150
},
151+
"field": null,
177152
"partitions": null,
178-
"unknown": [
179-
{
180-
"@type": "@10"
181-
}
182-
]
153+
"unknown": []
183154
}
184155
],
185156
"options": {
@@ -189,7 +160,7 @@
189160
}
190161
},
191162
"first": 0,
192-
"last": 9
163+
"last": 7
193164
}
194165
],
195166
"brackets": 0,
@@ -198,14 +169,6 @@
198169
},
199170
"errors": {
200171
"lexer": [],
201-
"parser": [
202-
[
203-
"Unrecognized alter operation.",
204-
{
205-
"@type": "@11"
206-
},
207-
0
208-
]
209-
]
172+
"parser": []
210173
}
211174
}

tests/data/parser/parseAlterFunction3.out

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -234,48 +234,22 @@
234234
},
235235
"options": {
236236
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
237-
"options": []
238-
},
239-
"field": {
240-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
241-
"database": null,
242-
"table": null,
243-
"column": "COMMENT",
244-
"expr": "COMMENT",
245-
"alias": null,
246-
"function": null,
247-
"subquery": null
237+
"options": {
238+
"1": {
239+
"name": "COMMENT",
240+
"equals": false,
241+
"expr": "\"test\"",
242+
"value": "test"
243+
},
244+
"2": "LANGUAGE SQL",
245+
"3": "CONTAINS SQL",
246+
"4": "SQL SECURITY",
247+
"5": "DEFINER"
248+
}
248249
},
250+
"field": null,
249251
"partitions": null,
250-
"unknown": [
251-
{
252-
"@type": "@10"
253-
},
254-
{
255-
"@type": "@11"
256-
},
257-
{
258-
"@type": "@12"
259-
},
260-
{
261-
"@type": "@13"
262-
},
263-
{
264-
"@type": "@14"
265-
},
266-
{
267-
"@type": "@15"
268-
},
269-
{
270-
"@type": "@16"
271-
},
272-
{
273-
"@type": "@17"
274-
},
275-
{
276-
"@type": "@18"
277-
}
278-
]
252+
"unknown": []
279253
}
280254
],
281255
"options": {
@@ -294,14 +268,6 @@
294268
},
295269
"errors": {
296270
"lexer": [],
297-
"parser": [
298-
[
299-
"Unrecognized alter operation.",
300-
{
301-
"@type": "@19"
302-
},
303-
0
304-
]
305-
]
271+
"parser": []
306272
}
307273
}

tests/data/parser/parseAlterFunction4.out

Lines changed: 22 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,13 @@
100100
},
101101
{
102102
"@type": "PhpMyAdmin\\SqlParser\\Token",
103-
"token": "LANGUAGE",
104-
"value": "LANGUAGE",
105-
"keyword": "LANGUAGE",
103+
"token": "LANGUAGE SQL",
104+
"value": "LANGUAGE SQL",
105+
"keyword": "LANGUAGE SQL",
106106
"type": 1,
107-
"flags": 1,
107+
"flags": 7,
108108
"position": 40
109109
},
110-
{
111-
"@type": "PhpMyAdmin\\SqlParser\\Token",
112-
"token": " ",
113-
"value": " ",
114-
"keyword": null,
115-
"type": 3,
116-
"flags": 0,
117-
"position": 48
118-
},
119-
{
120-
"@type": "PhpMyAdmin\\SqlParser\\Token",
121-
"token": "SQL",
122-
"value": "SQL",
123-
"keyword": "SQL",
124-
"type": 1,
125-
"flags": 3,
126-
"position": 49
127-
},
128110
{
129111
"@type": "PhpMyAdmin\\SqlParser\\Token",
130112
"token": " ",
@@ -207,8 +189,8 @@
207189
"position": null
208190
}
209191
],
210-
"count": 22,
211-
"idx": 22
192+
"count": 20,
193+
"idx": 20
212194
},
213195
"delimiter": ";",
214196
"delimiterLen": 1,
@@ -252,54 +234,22 @@
252234
},
253235
"options": {
254236
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
255-
"options": []
256-
},
257-
"field": {
258-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
259-
"database": null,
260-
"table": null,
261-
"column": "COMMENT",
262-
"expr": "COMMENT",
263-
"alias": null,
264-
"function": null,
265-
"subquery": null
237+
"options": {
238+
"1": {
239+
"name": "COMMENT",
240+
"equals": false,
241+
"expr": "\"test\"",
242+
"value": "test"
243+
},
244+
"2": "LANGUAGE SQL",
245+
"3": "NO SQL",
246+
"4": "SQL SECURITY",
247+
"5": "INVOKER"
248+
}
266249
},
250+
"field": null,
267251
"partitions": null,
268-
"unknown": [
269-
{
270-
"@type": "@10"
271-
},
272-
{
273-
"@type": "@11"
274-
},
275-
{
276-
"@type": "@12"
277-
},
278-
{
279-
"@type": "@13"
280-
},
281-
{
282-
"@type": "@14"
283-
},
284-
{
285-
"@type": "@15"
286-
},
287-
{
288-
"@type": "@16"
289-
},
290-
{
291-
"@type": "@17"
292-
},
293-
{
294-
"@type": "@18"
295-
},
296-
{
297-
"@type": "@19"
298-
},
299-
{
300-
"@type": "@20"
301-
}
302-
]
252+
"unknown": []
303253
}
304254
],
305255
"options": {
@@ -309,7 +259,7 @@
309259
}
310260
},
311261
"first": 0,
312-
"last": 19
262+
"last": 17
313263
}
314264
],
315265
"brackets": 0,
@@ -318,14 +268,6 @@
318268
},
319269
"errors": {
320270
"lexer": [],
321-
"parser": [
322-
[
323-
"Unrecognized alter operation.",
324-
{
325-
"@type": "@21"
326-
},
327-
0
328-
]
329-
]
271+
"parser": []
330272
}
331273
}

0 commit comments

Comments
 (0)