Skip to content

Commit

Permalink
Fix management of ALTER USER when used with IDENTIFIED WITH option
Browse files Browse the repository at this point in the history
  • Loading branch information
Tithugues committed Mar 24, 2023
1 parent dca8142 commit 4f23c41
Show file tree
Hide file tree
Showing 27 changed files with 418 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ class AlterOperation extends Component
1,
'var',
],
'BY' => [

'IDENTIFIED WITH' => [
2,
'expr',
'var',
],
'PASSWORD' => [
2,
Expand All @@ -172,6 +173,11 @@ class AlterOperation extends Component
'var',
],

'BY' => [
4,
'expr',
],

'ACCOUNT' => 1,
'DEFAULT' => 1,

Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100000.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class ContextMariaDb100000 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100100.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100100 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100200.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100200 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100300.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100300 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100400.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100400 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100500.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100500 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMariaDb100600.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMariaDb100600 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMySql50700.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ContextMySql50700 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
1 change: 1 addition & 0 deletions src/Contexts/ContextMySql80000.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class ContextMySql80000 extends Context
'FULLTEXT KEY' => 23, 'UNIQUE INDEX' => 23,
'SPATIAL INDEX' => 23,
'FULLTEXT INDEX' => 23,
'IDENTIFIED WITH' => 23,

'X' => 33, 'Y' => 33,
'LN' => 33, 'PI' => 33,
Expand Down
4 changes: 3 additions & 1 deletion tests/Lexer/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function lexProvider(): array
['lexer/lexSymbolErr1'],
['lexer/lexSymbolErr2'],
['lexer/lexSymbolErr3'],
['lexer/lexSymbolUser'],
['lexer/lexSymbolUser1'],
['lexer/lexSymbolUser2'],
['lexer/lexSymbolUser3'],
['lexer/lexWhitespace'],
['lexer/lexLabel1'],
['lexer/lexLabel2'],
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/data/lexer/lexSymbolUser2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER USER 'user'@'hostname' IDENTIFIED WITH mysql_native_password BY 'password';
183 changes: 183 additions & 0 deletions tests/data/lexer/lexSymbolUser2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"query": "ALTER USER 'user'@'hostname' IDENTIFIED WITH 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 WITH mysql_native_password BY 'password';",
"len": 81,
"last": 81,
"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 WITH",
"value": "IDENTIFIED WITH",
"keyword": "IDENTIFIED WITH",
"type": 1,
"flags": 23,
"position": 29
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 44
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "mysql_native_password",
"value": "mysql_native_password",
"keyword": null,
"type": 0,
"flags": 0,
"position": 45
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 66
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "BY",
"value": "BY",
"keyword": "BY",
"type": 1,
"flags": 3,
"position": 67
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 69
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "'password'",
"value": "password",
"keyword": null,
"type": 7,
"flags": 1,
"position": 70
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ";",
"value": ";",
"keyword": null,
"type": 9,
"flags": 0,
"position": 80
},
{
"@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/lexSymbolUser3.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER USER 'user'@'hostname' WITH MAX_QUERIES_PER_HOUR 500 MAX_UPDATES_PER_HOUR 100;
Loading

0 comments on commit 4f23c41

Please sign in to comment.