Skip to content

Commit

Permalink
Support IDENTIFIED VIA in CREATE/ALTER USER statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Tithugues committed Mar 28, 2023
1 parent 1f28d2c commit 5eff781
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class AlterOperation extends Component
'var',
],

'IDENTIFIED VIA' => [
2,
'var',
],
'IDENTIFIED WITH' => [
2,
'var',
Expand Down
2 changes: 1 addition & 1 deletion src/Contexts/ContextMariaDb100400.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ContextMariaDb100400 extends Context
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
Expand Down
2 changes: 1 addition & 1 deletion src/Contexts/ContextMariaDb100500.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ContextMariaDb100500 extends Context
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
Expand Down
2 changes: 1 addition & 1 deletion src/Contexts/ContextMariaDb100600.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ContextMariaDb100600 extends Context
'FOREIGN KEY' => 23, 'PRIMARY KEY' => 23, 'SPATIAL KEY' => 23,
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'FULLTEXT INDEX' => 23, 'IDENTIFIED VIA' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
Expand Down
2 changes: 2 additions & 0 deletions tests/Lexer/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public function lexProvider(): array
['lexer/lexSymbolUser1'],
['lexer/lexSymbolUser2'],
['lexer/lexSymbolUser3'],
['lexer/lexSymbolUser4_mariadb_100400'],
['lexer/lexSymbolUser5_mariadb_100400'],
['lexer/lexWhitespace'],
['lexer/lexLabel1'],
['lexer/lexLabel2'],
Expand Down
1 change: 1 addition & 0 deletions tests/data/lexer/lexSymbolUser4_mariadb_100400.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';
183 changes: 183 additions & 0 deletions tests/data/lexer/lexSymbolUser4_mariadb_100400.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"query": "ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"PARSER_METHODS": [
"parseDelimiter",
"parseWhitespace",
"parseNumber",
"parseComment",
"parseOperator",
"parseBool",
"parseString",
"parseSymbol",
"parseKeyword",
"parseLabel",
"parseUnknown"
],
"KEYWORD_NAME_INDICATORS": [
"FROM",
"SET",
"WHERE"
],
"OPERATOR_NAME_INDICATORS": [
",",
"."
],
"str": "ALTER USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';",
"len": 80,
"last": 80,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "ALTER",
"value": "ALTER",
"keyword": "ALTER",
"type": 1,
"flags": 3,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 5
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "USER",
"value": "USER",
"keyword": "USER",
"type": 1,
"flags": 33,
"position": 6
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "'user'@'hostname'",
"value": "user@hostname",
"keyword": null,
"type": 8,
"flags": 4,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 28
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "IDENTIFIED VIA",
"value": "IDENTIFIED VIA",
"keyword": "IDENTIFIED VIA",
"type": 1,
"flags": 23,
"position": 29
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 43
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "mysql_native_password",
"value": "mysql_native_password",
"keyword": null,
"type": 0,
"flags": 0,
"position": 44
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 65
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "BY",
"value": "BY",
"keyword": "BY",
"type": 1,
"flags": 3,
"position": 66
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 68
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "'password'",
"value": "password",
"keyword": null,
"type": 7,
"flags": 1,
"position": 69
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ";",
"value": ";",
"keyword": null,
"type": 9,
"flags": 0,
"position": 79
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 15,
"idx": 0
},
"DEFAULT_DELIMITER": ";",
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": null,
"errors": {
"lexer": [],
"parser": []
}
}
1 change: 1 addition & 0 deletions tests/data/lexer/lexSymbolUser5_mariadb_100400.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE USER 'user'@'hostname' IDENTIFIED VIA mysql_native_password BY 'password';
Loading

0 comments on commit 5eff781

Please sign in to comment.