-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
create/alter/drop user
statement (#3678)
* feat: add Encrypt * feat: add sql node * feat: auth in sdk * fix: fix test * fix: fix bugs * test: add case * feat: hide password in terminal * feat: update sdk * fix: fix test * feat: add user in spark * fix: fix python * docs: add doc * fix: skip python test * fix: fix comment * fix: revert HandleDelete * feat: add user to openmldb-import * fix: fix alter root password --------- Co-authored-by: 4paradigm <[email protected]> Co-authored-by: denglong <[email protected]>
- Loading branch information
1 parent
7d755ff
commit 7ca5f44
Showing
71 changed files
with
1,421 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2021 4Paradigm | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cases: | ||
- id: alter_user | ||
desc: alter user | ||
sql: | | ||
alter user root set options(password="123456"); | ||
expect: | ||
node_tree_str: | | ||
+-node[kAlterUserStmt] | ||
+-if_exists: false | ||
+-user: root | ||
+-options: | ||
+-password: | ||
+-expr[primary] | ||
+-value: 123456 | ||
+-type: string | ||
- id: alter_user_if_exist | ||
desc: alter user | ||
sql: | | ||
alter user if exists root set options(password="123456"); | ||
expect: | ||
node_tree_str: | | ||
+-node[kAlterUserStmt] | ||
+-if_exists: true | ||
+-user: root | ||
+-options: | ||
+-password: | ||
+-expr[primary] | ||
+-value: 123456 | ||
+-type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ALTER USER | ||
|
||
The `ALTER USER` statement is used to modify a user's password. | ||
|
||
## Syntax | ||
```sql | ||
AlterUserstmt ::= | ||
'ALTER' 'USER' [IF EXISTS] UserName SET OptOptionsList | ||
|
||
UserName ::= Identifier | ||
|
||
OptOptionsList ::= | ||
"OPTIONS" OptionList | ||
|
||
OptionList ::= | ||
OptionsListPrefix ")" | ||
|
||
OptionsListPrefix ::= | ||
"(" OptionEntry | ||
| OptionsListPrefix "," OptionEntry | ||
|
||
OptionEntry ::= | ||
Identifier "=" Identifier | ||
``` | ||
|
||
## **Examples** | ||
```sql | ||
ALTER USER user1; | ||
-- SUCCEED | ||
ALTER USER IF EXISTS user2 SET OPTIONS(password='123456'); | ||
-- SUCCEED | ||
ALTER USER user3 SET OPTIONS (password='123456'); | ||
-- SUCCEED | ||
``` | ||
|
||
```{note} | ||
1. If the password is not specified in the OPTIONS, the password will not be changed | ||
2. You can only specify the password in the OPTIONS | ||
``` | ||
|
||
## Related SQL | ||
|
||
[CREATE USER](./CREATE_USER_STATEMENT.md) | ||
[DROP USER](./DROP_USER_STATEMENT.md) | ||
[SHOW CURRENT_USER](./SHOW_CURRENT_USER_STATEMENT.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# CREATE USER | ||
|
||
The `CREATE USER` statement is used to create a user | ||
|
||
## Syntax | ||
```sql | ||
CreateUserstmt ::= | ||
'CREATE' 'USER' [IF NOT EXISTS] UserName OptOptionsList | ||
|
||
UserName ::= Identifier | ||
|
||
OptOptionsList ::= | ||
"OPTIONS" OptionList | ||
|
||
OptionList ::= | ||
OptionsListPrefix ")" | ||
|
||
OptionsListPrefix ::= | ||
"(" OptionEntry | ||
| OptionsListPrefix "," OptionEntry | ||
|
||
OptionEntry ::= | ||
Identifier "=" Identifier | ||
``` | ||
|
||
## **Examples** | ||
```sql | ||
CREATE USER user1; | ||
-- SUCCEED | ||
CREATE USER IF NOT EXISTS user2; | ||
-- SUCCEED | ||
CREATE USER user3 OPTIONS (password='123456'); | ||
-- SUCCEED | ||
``` | ||
|
||
```{note} | ||
1. Only the password can be specified in the OPTIONS | ||
2. The password will be empty if not specified explicitly | ||
``` | ||
|
||
## Related SQL | ||
|
||
[DROP USER](./DROP_USER_STATEMENT.md) | ||
[ALTER USER](./ALTER_USER_STATEMENT.md) | ||
[SHOW CURRENT_USER](./SHOW_CURRENT_USER_STATEMENT.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# DROP USER | ||
|
||
The `DROP USER` statement is used to drop a user. | ||
|
||
## Syntax | ||
```sql | ||
DropUserstmt ::= | ||
'DROP' 'USER' [IF EXISTS] UserName | ||
|
||
UserName ::= Identifier | ||
``` | ||
|
||
## **Examples** | ||
```sql | ||
DROP USER user1; | ||
-- SUCCEED | ||
DROP USER IF EXISTS user2; | ||
-- SUCCEED | ||
``` | ||
|
||
```{note} | ||
1. The user `root` cannot be deleted | ||
``` | ||
|
||
## Related SQL | ||
|
||
[CREATE USER](./CREATE_USER_STATEMENT.md) | ||
[ALTER USER](./ALTER_USER_STATEMENT.md) | ||
[SHOW CURRENT_USER](./SHOW_CURRENT_USER_STATEMENT.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SHOW CURRENT_USER | ||
|
||
The `SHOW CURRENT_USER` statement is used to display the current user. | ||
|
||
## **Examples** | ||
```sql | ||
SHOW CURRENT_USER; | ||
------ | ||
User | ||
------ | ||
root | ||
------ | ||
``` | ||
|
||
[CREATE USER](./CREATE_USER_STATEMENT.md) | ||
[ALTER USER](./ALTER_USER_STATEMENT.md) | ||
[DROP USER](./DROP_USER_STATEMENT.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ALTER USER | ||
|
||
`ALTER USER` 语句可用来修改用户密码。 | ||
|
||
## 语法 | ||
```sql | ||
AlterUserstmt ::= | ||
'ALTER' 'USER' [IF EXISTS] UserName SET OptOptionsList | ||
|
||
UserName ::= Identifier | ||
|
||
OptOptionsList ::= | ||
"OPTIONS" OptionList | ||
|
||
OptionList ::= | ||
OptionsListPrefix ")" | ||
|
||
OptionsListPrefix ::= | ||
"(" OptionEntry | ||
| OptionsListPrefix "," OptionEntry | ||
|
||
OptionEntry ::= | ||
Identifier "=" Identifier | ||
``` | ||
|
||
## **示例** | ||
```sql | ||
ALTER USER user1; | ||
-- SUCCEED | ||
ALTER USER IF EXISTS user2 SET OPTIONS(password='123456'); | ||
-- SUCCEED | ||
ALTER USER user3 SET OPTIONS (password='123456'); | ||
-- SUCCEED | ||
``` | ||
|
||
```{note} | ||
1. 如果不指定OPTIONS密码不会修改 | ||
2. OPTIONS中只能指定password | ||
``` | ||
|
||
## 相关SQL | ||
|
||
[CREATE USER](./CREATE_USER_STATEMENT.md) | ||
[DROP USER](./DROP_USER_STATEMENT.md) | ||
[SHOW CURRENT_USER](./SHOW_CURRENT_USER_STATEMENT.md) |
Oops, something went wrong.