Skip to content

Commit 5eff781

Browse files
committed
Support IDENTIFIED VIA in CREATE/ALTER USER statements
1 parent 1f28d2c commit 5eff781

12 files changed

Lines changed: 380 additions & 3 deletions

src/Components/AlterOperation.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class AlterOperation extends Component
160160
'var',
161161
],
162162

163+
'IDENTIFIED VIA' => [
164+
2,
165+
'var',
166+
],
163167
'IDENTIFIED WITH' => [
164168
2,
165169
'var',

src/Contexts/ContextMariaDb100400.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class ContextMariaDb100400 extends Context
215215
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
216216
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
217217
'SPATIAL INDEX' => 23,
218-
'FULLTEXT INDEX' => 23,
218+
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
219219
'IDENTIFIED WITH' => 23,
220220

221221
'X' => 33, 'Y' => 33,

src/Contexts/ContextMariaDb100500.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class ContextMariaDb100500 extends Context
215215
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
216216
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
217217
'SPATIAL INDEX' => 23,
218-
'FULLTEXT INDEX' => 23,
218+
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
219219
'IDENTIFIED WITH' => 23,
220220

221221
'X' => 33, 'Y' => 33,

src/Contexts/ContextMariaDb100600.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class ContextMariaDb100600 extends Context
215215
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
216216
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
217217
'SPATIAL INDEX' => 23,
218-
'FULLTEXT INDEX' => 23,
218+
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
219219
'IDENTIFIED WITH' => 23,
220220

221221
'X' => 33, 'Y' => 33,

tests/Lexer/LexerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public function lexProvider(): array
8888
['lexer/lexSymbolUser1'],
8989
['lexer/lexSymbolUser2'],
9090
['lexer/lexSymbolUser3'],
91+
['lexer/lexSymbolUser4_mariadb_100400'],
92+
['lexer/lexSymbolUser5_mariadb_100400'],
9193
['lexer/lexWhitespace'],
9294
['lexer/lexLabel1'],
9395
['lexer/lexLabel2'],
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
"query": "ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"PARSER_METHODS": [
6+
"parseDelimiter",
7+
"parseWhitespace",
8+
"parseNumber",
9+
"parseComment",
10+
"parseOperator",
11+
"parseBool",
12+
"parseString",
13+
"parseSymbol",
14+
"parseKeyword",
15+
"parseLabel",
16+
"parseUnknown"
17+
],
18+
"KEYWORD_NAME_INDICATORS": [
19+
"FROM",
20+
"SET",
21+
"WHERE"
22+
],
23+
"OPERATOR_NAME_INDICATORS": [
24+
",",
25+
"."
26+
],
27+
"str": "ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';",
28+
"len": 80,
29+
"last": 80,
30+
"list": {
31+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
32+
"tokens": [
33+
{
34+
"@type": "PhpMyAdmin\\SqlParser\\Token",
35+
"token": "ALTER",
36+
"value": "ALTER",
37+
"keyword": "ALTER",
38+
"type": 1,
39+
"flags": 3,
40+
"position": 0
41+
},
42+
{
43+
"@type": "PhpMyAdmin\\SqlParser\\Token",
44+
"token": " ",
45+
"value": " ",
46+
"keyword": null,
47+
"type": 3,
48+
"flags": 0,
49+
"position": 5
50+
},
51+
{
52+
"@type": "PhpMyAdmin\\SqlParser\\Token",
53+
"token": "USER",
54+
"value": "USER",
55+
"keyword": "USER",
56+
"type": 1,
57+
"flags": 33,
58+
"position": 6
59+
},
60+
{
61+
"@type": "PhpMyAdmin\\SqlParser\\Token",
62+
"token": " ",
63+
"value": " ",
64+
"keyword": null,
65+
"type": 3,
66+
"flags": 0,
67+
"position": 10
68+
},
69+
{
70+
"@type": "PhpMyAdmin\\SqlParser\\Token",
71+
"token": "'user'@'hostname'",
72+
"value": "user@hostname",
73+
"keyword": null,
74+
"type": 8,
75+
"flags": 4,
76+
"position": 11
77+
},
78+
{
79+
"@type": "PhpMyAdmin\\SqlParser\\Token",
80+
"token": " ",
81+
"value": " ",
82+
"keyword": null,
83+
"type": 3,
84+
"flags": 0,
85+
"position": 28
86+
},
87+
{
88+
"@type": "PhpMyAdmin\\SqlParser\\Token",
89+
"token": "IDENTIFIED VIA",
90+
"value": "IDENTIFIED VIA",
91+
"keyword": "IDENTIFIED VIA",
92+
"type": 1,
93+
"flags": 23,
94+
"position": 29
95+
},
96+
{
97+
"@type": "PhpMyAdmin\\SqlParser\\Token",
98+
"token": " ",
99+
"value": " ",
100+
"keyword": null,
101+
"type": 3,
102+
"flags": 0,
103+
"position": 43
104+
},
105+
{
106+
"@type": "PhpMyAdmin\\SqlParser\\Token",
107+
"token": "mysql_native_password",
108+
"value": "mysql_native_password",
109+
"keyword": null,
110+
"type": 0,
111+
"flags": 0,
112+
"position": 44
113+
},
114+
{
115+
"@type": "PhpMyAdmin\\SqlParser\\Token",
116+
"token": " ",
117+
"value": " ",
118+
"keyword": null,
119+
"type": 3,
120+
"flags": 0,
121+
"position": 65
122+
},
123+
{
124+
"@type": "PhpMyAdmin\\SqlParser\\Token",
125+
"token": "BY",
126+
"value": "BY",
127+
"keyword": "BY",
128+
"type": 1,
129+
"flags": 3,
130+
"position": 66
131+
},
132+
{
133+
"@type": "PhpMyAdmin\\SqlParser\\Token",
134+
"token": " ",
135+
"value": " ",
136+
"keyword": null,
137+
"type": 3,
138+
"flags": 0,
139+
"position": 68
140+
},
141+
{
142+
"@type": "PhpMyAdmin\\SqlParser\\Token",
143+
"token": "'password'",
144+
"value": "password",
145+
"keyword": null,
146+
"type": 7,
147+
"flags": 1,
148+
"position": 69
149+
},
150+
{
151+
"@type": "PhpMyAdmin\\SqlParser\\Token",
152+
"token": ";",
153+
"value": ";",
154+
"keyword": null,
155+
"type": 9,
156+
"flags": 0,
157+
"position": 79
158+
},
159+
{
160+
"@type": "PhpMyAdmin\\SqlParser\\Token",
161+
"token": null,
162+
"value": null,
163+
"keyword": null,
164+
"type": 9,
165+
"flags": 0,
166+
"position": null
167+
}
168+
],
169+
"count": 15,
170+
"idx": 0
171+
},
172+
"DEFAULT_DELIMITER": ";",
173+
"delimiter": ";",
174+
"delimiterLen": 1,
175+
"strict": false,
176+
"errors": []
177+
},
178+
"parser": null,
179+
"errors": {
180+
"lexer": [],
181+
"parser": []
182+
}
183+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';

0 commit comments

Comments
 (0)