Skip to content

Commit

Permalink
fix(query): fix show user err: auth_string column not fount (#13158)
Browse files Browse the repository at this point in the history
* fix(query): fix show user err: auth_string column not fount

* delete auth_string in show doc
  • Loading branch information
TCeason authored Oct 10, 2023
1 parent 9128cb9 commit c135e78
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 43 deletions.
30 changes: 15 additions & 15 deletions docs/doc/14-sql-commands/00-ddl/30-user/01-user-create-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ For more information about MySQL authentication plugins, see [A Tale of Two Pass
CREATE USER user1 IDENTIFIED BY 'abc123';

SHOW USERS;
+-----------+----------+----------------------+------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-----------+----------+----------------------+------------------------------------------+---------------+
| user1 | % | double_sha1_password | 6691484ea6b50ddde1926a220da01fa9e575c18a | NO |
+-----------+----------+----------------------+------------------------------------------+---------------+
+-----------+----------+----------------------+---------------+
| name | hostname | auth_type | is_configured |
+-----------+----------+----------------------+---------------+
| user1 | % | double_sha1_password | NO |
+-----------+----------+----------------------+---------------+
```

### Creating User with sha256_password auth_type
Expand All @@ -54,11 +54,11 @@ SHOW USERS;
CREATE USER user1 IDENTIFIED WITH sha256_password BY 'abc123';

SHOW USERS;
+-----------+----------+----------------------+------------------------------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-----------+----------+----------------------+------------------------------------------------------------------+---------------+
| user1 | % | sha256_password | 6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090 | NO |
+-----------+----------+----------------------+------------------------------------------------------------------+---------------+
+-----------+----------+----------------------+---------------+
| name | hostname | auth_type | is_configured |
+-----------+----------+----------------------+---------------+
| user1 | % | sha256_password | NO |
+-----------+----------+----------------------+---------------+
```

### Creating User with Network Policy
Expand All @@ -67,9 +67,9 @@ SHOW USERS;
CREATE USER user1 IDENTIFIED BY 'abc123' WITH SET NETWORK POLICY='test_policy';

SHOW USERS;
+-----------+----------+----------------------+------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-----------+----------+----------------------+------------------------------------------+---------------+
| user1 | % | double_sha1_password | 6691484ea6b50ddde1926a220da01fa9e575c18a | NO |
+-----------+----------+----------------------+------------------------------------------+---------------+
+-----------+----------+----------------------+---------------+
| name | hostname | auth_type | is_configured |
+-----------+----------+----------------------+---------------+
| user1 | % | double_sha1_password | NO |
+-----------+----------+----------------------+---------------+
```
8 changes: 4 additions & 4 deletions docs/doc/14-sql-commands/00-ddl/30-user/02-user-show-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ SHOW USERS;
SHOW USERS;

---
| name | hostname | auth_type | auth_string | is_configured |
|---------------------------|----------|----------------------|------------------------------------------|---------------|
| sqluser_johnappleseed | % | double_sha1_password | 147dee8f648a745805ee8dda80bb8e277559f55b | NO |
| johnappleseed@example.com | % | jwt | | NO |
| name | hostname | auth_type | is_configured |
|---------------------------|----------|----------------------|---------------|
| sqluser_johnappleseed | % | double_sha1_password | NO |
| johnappleseed@example.com | % | jwt | NO |
```
30 changes: 15 additions & 15 deletions docs/doc/14-sql-commands/00-ddl/30-user/03-user-alter-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ ALTER USER <name> WITH UNSET NETWORK POLICY
CREATE USER user1 IDENTIFIED BY 'abc123';

SHOW USERS;
+-----------+----------+----------------------+------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-----------+----------+----------------------+------------------------------------------+---------------+
| user1 | % | double_sha1_password | 6691484ea6b50ddde1926a220da01fa9e575c18a | NO |
+-----------+----------+----------------------+------------------------------------------+---------------+
+-----------+----------+----------------------+---------------+
| name | hostname | auth_type | is_configured |
+-----------+----------+----------------------+---------------+
| user1 | % | double_sha1_password | NO |
+-----------+----------+----------------------+---------------+

ALTER USER user1 IDENTIFIED WITH sha256_password BY '123abc';

SHOW USERS;
+-------+----------+-----------------+------------------------------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-------+----------+-----------------+------------------------------------------------------------------+---------------+
| user1 | % | sha256_password | dd130a849d7b29e5541b05d2f7f86a4acd4f1ec598c1c9438783f56bc4f0ff80 | NO |
+-------+----------+-----------------+------------------------------------------------------------------+---------------+
+-------+----------+-----------------+---------------+
| name | hostname | auth_type | is_configured |
+-------+----------+-----------------+---------------+
| user1 | % | sha256_password | NO |
+-------+----------+-----------------+---------------+

ALTER USER 'user1' IDENTIFIED WITH no_password;

show users;
+-------+----------+-------------+-------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+-------+----------+-------------+-------------+---------------+
| user1 | % | no_password | | NO |
+-------+----------+-------------+-------------+---------------+
+-------+----------+-------------+---------------+
| name | hostname | auth_type | is_configured |
+-------+----------+-------------+---------------+
| user1 | % | no_password | NO |
+-------+----------+-------------+---------------+
```

### Setting & Unsetting Network Policy
Expand Down
14 changes: 7 additions & 7 deletions docs/doc/14-sql-commands/40-show/show-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ SHOW USERS

```sql
SHOW USERS;
+------+----------+----------------------+------------------------------------------+---------------+
| name | hostname | auth_type | auth_string | is_configured |
+------+----------+----------------------+------------------------------------------+---------------+
| root | % | double_sha1_password | 23ae809ddacaf96af0fd78ed04b6a265e05aa257 | YES |
+------+----------+----------------------+------------------------------------------+---------------+
| test | % | double_sha1_password | 3081f32caef285c232d066033c89a78d88a6d8a5 | NO |
+------+----------+----------------------+------------------------------------------+---------------+
+------+----------+----------------------+---------------+
| name | hostname | auth_type | is_configured |
+------+----------+----------------------+---------------+
| root | % | double_sha1_password | YES |
+------+----------+----------------------+---------------+
| test | % | double_sha1_password | NO |
+------+----------+----------------------+---------------+
```
2 changes: 1 addition & 1 deletion src/query/sql/src/planner/binder/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl<'a> Binder {
if_exists: *if_exists,
user: user.clone(),
})),
Statement::ShowUsers => self.bind_rewrite_to_query(bind_context, "SELECT name, hostname, auth_type, auth_string, is_configured FROM system.users ORDER BY name", RewriteKind::ShowUsers).await?,
Statement::ShowUsers => self.bind_rewrite_to_query(bind_context, "SELECT name, hostname, auth_type, is_configured FROM system.users ORDER BY name", RewriteKind::ShowUsers).await?,
Statement::AlterUser(stmt) => self.bind_alter_user(stmt).await?,

// Roles
Expand Down
2 changes: 2 additions & 0 deletions src/query/storages/system/src/users_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ impl AsyncSystemTable for UsersTable {

impl UsersTable {
pub fn create(table_id: u64) -> Arc<dyn Table> {
// QUERY show user is rewrite to `SELECT name, hostname, auth_type, is_configured FROM system.users ORDER BY name`
// If users table column has been modified, need to check the show user query.
let schema = TableSchemaRefExt::create(vec![
TableField::new("name", TableDataType::String),
TableField::new("hostname", TableDataType::String),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
SELECT * from system.tables where name = 'tables' and created_on > '2022-07-01 12:16:58.630 +0000'
SELECT * from system.tables where name = 'tables' and created_on > '2022-07-01 12:16:58.630'

query T
select * from (select name from system.tables where database='system') where name='tables'
Expand Down

1 comment on commit c135e78

@vercel
Copy link

@vercel vercel bot commented on c135e78 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.