Skip to content

Commit ff5c8d9

Browse files
author
Kristofer Älvring
committed
WL#13562 CREATE/ALTER USER COMMENT 'JSON'
This feature enables the DBA to associate each authorization identifier with user defined comments or JSON key-values. It can be useful when supporting a third party auditing process or for just keeping track on all user accounts. It introduce two new statements: ALTER USER x COMMENT y ALTER USER x ATTRIBUTE y And a new Information schema: USER_ATTRIBUTES RB: 23946
1 parent 84064f6 commit ff5c8d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1207
-70
lines changed

Diff for: include/my_sqlcommand.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,

Diff for: mysql-test/r/dd_is_compatibility_ci.result

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ TABLE_CONSTRAINTS
195195
TABLE_CONSTRAINTS_EXTENSIONS
196196
TABLE_PRIVILEGES
197197
TRIGGERS
198+
USER_ATTRIBUTES
198199
USER_PRIVILEGES
199200
VIEWS
200201
VIEW_ROUTINE_USAGE

Diff for: mysql-test/r/dd_is_compatibility_cs.result

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ TABLE_CONSTRAINTS
195195
TABLE_CONSTRAINTS_EXTENSIONS
196196
TABLE_PRIVILEGES
197197
TRIGGERS
198+
USER_ATTRIBUTES
198199
USER_PRIVILEGES
199200
VIEWS
200201
VIEW_ROUTINE_USAGE

Diff for: mysql-test/r/information_schema_ci.result

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ TABLE_CONSTRAINTS
102102
TABLE_CONSTRAINTS_EXTENSIONS
103103
TABLE_PRIVILEGES
104104
TRIGGERS
105+
USER_ATTRIBUTES
105106
USER_PRIVILEGES
106107
VIEWS
107108
VIEW_ROUTINE_USAGE
@@ -802,6 +803,7 @@ information_schema ROUTINES ROUTINE_DEFINITION
802803
information_schema ST_GEOMETRY_COLUMNS GEOMETRY_TYPE_NAME
803804
information_schema STATISTICS EXPRESSION
804805
information_schema TRIGGERS ACTION_STATEMENT
806+
information_schema USER_ATTRIBUTES ATTRIBUTE
805807
information_schema VIEWS VIEW_DEFINITION
806808
select table_name, column_name, data_type from information_schema.columns
807809
where table_schema not in ('performance_schema', 'sys')
@@ -882,7 +884,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
882884
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
883885
GROUP BY TABLE_SCHEMA;
884886
TABLE_SCHEMA count(*)
885-
information_schema 46
887+
information_schema 47777777
886888
mysql 31
887889
create table t1 (i int, j int);
888890
create trigger trg1 before insert on t1 for each row
@@ -1372,6 +1374,7 @@ TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
13721374
TABLE_CONSTRAINTS_EXTENSIONS information_schema.TABLE_CONSTRAINTS_EXTENSIONS 1
13731375
TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
13741376
TRIGGERS information_schema.TRIGGERS 1
1377+
USER_ATTRIBUTES information_schema.USER_ATTRIBUTES 1
13751378
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
13761379
VIEWS information_schema.VIEWS 1
13771380
VIEW_ROUTINE_USAGE information_schema.VIEW_ROUTINE_USAGE 1
@@ -2500,6 +2503,7 @@ TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
25002503
TABLE_CONSTRAINTS_EXTENSIONS CONSTRAINT_SCHEMA
25012504
TABLE_PRIVILEGES TABLE_SCHEMA
25022505
TRIGGERS TRIGGER_SCHEMA
2506+
USER_ATTRIBUTES USER
25032507
USER_PRIVILEGES GRANTEE
25042508
VIEWS TABLE_SCHEMA
25052509
VIEW_ROUTINE_USAGE TABLE_SCHEMA
@@ -2565,6 +2569,7 @@ TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
25652569
TABLE_CONSTRAINTS_EXTENSIONS CONSTRAINT_SCHEMA
25662570
TABLE_PRIVILEGES TABLE_SCHEMA
25672571
TRIGGERS TRIGGER_SCHEMA
2572+
USER_ATTRIBUTES USER
25682573
USER_PRIVILEGES GRANTEE
25692574
VIEWS TABLE_SCHEMA
25702575
VIEW_ROUTINE_USAGE TABLE_SCHEMA

Diff for: mysql-test/r/information_schema_cs.result

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ TABLE_CONSTRAINTS
102102
TABLE_CONSTRAINTS_EXTENSIONS
103103
TABLE_PRIVILEGES
104104
TRIGGERS
105+
USER_ATTRIBUTES
105106
USER_PRIVILEGES
106107
VIEWS
107108
VIEW_ROUTINE_USAGE
@@ -802,6 +803,7 @@ information_schema ROUTINES ROUTINE_DEFINITION
802803
information_schema STATISTICS EXPRESSION
803804
information_schema ST_GEOMETRY_COLUMNS GEOMETRY_TYPE_NAME
804805
information_schema TRIGGERS ACTION_STATEMENT
806+
information_schema USER_ATTRIBUTES ATTRIBUTE
805807
information_schema VIEWS VIEW_DEFINITION
806808
select table_name, column_name, data_type from information_schema.columns
807809
where table_schema not in ('performance_schema', 'sys')
@@ -882,7 +884,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
882884
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
883885
GROUP BY TABLE_SCHEMA;
884886
TABLE_SCHEMA count(*)
885-
information_schema 46
887+
information_schema 47
886888
mysql 31
887889
create table t1 (i int, j int);
888890
create trigger trg1 before insert on t1 for each row
@@ -1372,6 +1374,7 @@ TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
13721374
TABLE_CONSTRAINTS_EXTENSIONS information_schema.TABLE_CONSTRAINTS_EXTENSIONS 1
13731375
TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
13741376
TRIGGERS information_schema.TRIGGERS 1
1377+
USER_ATTRIBUTES information_schema.USER_ATTRIBUTES 1
13751378
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
13761379
VIEWS information_schema.VIEWS 1
13771380
VIEW_ROUTINE_USAGE information_schema.VIEW_ROUTINE_USAGE 1
@@ -2500,6 +2503,7 @@ TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
25002503
TABLE_CONSTRAINTS_EXTENSIONS CONSTRAINT_SCHEMA
25012504
TABLE_PRIVILEGES TABLE_SCHEMA
25022505
TRIGGERS TRIGGER_SCHEMA
2506+
USER_ATTRIBUTES USER
25032507
USER_PRIVILEGES GRANTEE
25042508
VIEWS TABLE_SCHEMA
25052509
VIEW_ROUTINE_USAGE TABLE_SCHEMA
@@ -2565,6 +2569,7 @@ TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
25652569
TABLE_CONSTRAINTS_EXTENSIONS CONSTRAINT_SCHEMA
25662570
TABLE_PRIVILEGES TABLE_SCHEMA
25672571
TRIGGERS TRIGGER_SCHEMA
2572+
USER_ATTRIBUTES USER
25682573
USER_PRIVILEGES GRANTEE
25692574
VIEWS TABLE_SCHEMA
25702575
VIEW_ROUTINE_USAGE TABLE_SCHEMA

Diff for: mysql-test/r/information_schema_keywords.result

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ASC 1
2525
ASCII 0
2626
ASENSITIVE 1
2727
AT 0
28+
ATTRIBUTE 0
2829
AUTOEXTEND_SIZE 0
2930
AUTO_INCREMENT 0
3031
AVG 0

Diff for: mysql-test/r/mysqlshow_ci.result

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Database: information_schema
152152
| TABLESPACES |
153153
| TABLESPACES_EXTENSIONS |
154154
| TRIGGERS |
155+
| USER_ATTRIBUTES |
155156
| USER_PRIVILEGES |
156157
| VIEW_ROUTINE_USAGE |
157158
| VIEW_TABLE_USAGE |
@@ -234,6 +235,7 @@ Database: INFORMATION_SCHEMA
234235
| TABLESPACES |
235236
| TABLESPACES_EXTENSIONS |
236237
| TRIGGERS |
238+
| USER_ATTRIBUTES |
237239
| USER_PRIVILEGES |
238240
| VIEW_ROUTINE_USAGE |
239241
| VIEW_TABLE_USAGE |

Diff for: mysql-test/r/mysqlshow_cs.result

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Database: information_schema
152152
| TABLE_CONSTRAINTS_EXTENSIONS |
153153
| TABLE_PRIVILEGES |
154154
| TRIGGERS |
155+
| USER_ATTRIBUTES |
155156
| USER_PRIVILEGES |
156157
| VIEWS |
157158
| VIEW_ROUTINE_USAGE |
@@ -234,6 +235,7 @@ Database: INFORMATION_SCHEMA
234235
| TABLE_CONSTRAINTS_EXTENSIONS |
235236
| TABLE_PRIVILEGES |
236237
| TRIGGERS |
238+
| USER_ATTRIBUTES |
237239
| USER_PRIVILEGES |
238240
| VIEWS |
239241
| VIEW_ROUTINE_USAGE |

Diff for: mysql-test/r/user_account_password_lock.result

+21
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,25 @@ ERROR 28000: Access denied for user 'non-existent'@'localhost' (using password:
261261
# we lock foo user account
262262
ERROR HY000: Access denied for user ''@'localhost'. Account is blocked for 3 day(s) (3 day(s) remaining) due to 2 consecutive failed logins.
263263
DROP USER ''@localhost;
264+
#
265+
# user account password in conjunction with other user attributes and annotations
266+
#
267+
CREATE USER foo@localhost IDENTIFIED BY 'foo' PASSWORD_LOCK_TIME 3 FAILED_LOGIN_ATTEMPTS 2;
268+
ALTER USER foo@localhost ATTRIBUTE "{ \"test\": \"account locking\" }";
269+
ALTER USER foo@localhost COMMENT "This is a test account for verifying that password locking and user attributes won't interfer with one and another.";
270+
SELECT user_attributes FROM mysql.user WHERE user='foo';
271+
user_attributes
272+
{"metadata": {"test": "account locking", "comment": "This is a test account for verifying that password locking and user attributes won't interfer with one and another."}, "Password_locking": {"failed_login_attempts": 2, "password_lock_time_days": 3}}
273+
# Should fail as unlocked
274+
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: NO)
275+
# we lock foo user account
276+
ERROR HY000: Access denied for user 'foo'@'localhost'. Account is blocked for 3 day(s) (3 day(s) remaining) due to 2 consecutive failed logins.
277+
ALTER USER foo@localhost ACCOUNT UNLOCK;
278+
# Check that we idn't drop the COMMENT or METADATA
279+
SELECT user_attributes FROM mysql.user WHERE user='foo';
280+
user_attributes
281+
{"metadata": {"test": "account locking", "comment": "This is a test account for verifying that password locking and user attributes won't interfer with one and another."}, "Password_locking": {"failed_login_attempts": 2, "password_lock_time_days": 3}}
282+
# Should fail as unlocked
283+
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: NO)
284+
DROP USER foo@localhost;
264285
# End of 8.0 tests

0 commit comments

Comments
 (0)