From 3fa2cb2126a5df20ae539b72095c7347343e01bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 18 Oct 2013 05:41:34 -0700 Subject: [PATCH] Updated error message in case the user table's format is not up to date and can not support roles --- ...te_and_drop_role_invalid_user_table.result | 14 +++++++++++ ...eate_and_drop_role_invalid_user_table.test | 23 +++++++++++++++++++ sql/sql_acl.cc | 4 +++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/acl_roles_create_and_drop_role_invalid_user_table.result create mode 100644 mysql-test/t/acl_roles_create_and_drop_role_invalid_user_table.test diff --git a/mysql-test/r/acl_roles_create_and_drop_role_invalid_user_table.result b/mysql-test/r/acl_roles_create_and_drop_role_invalid_user_table.result new file mode 100644 index 00000000000..569997adde0 --- /dev/null +++ b/mysql-test/r/acl_roles_create_and_drop_role_invalid_user_table.result @@ -0,0 +1,14 @@ +use mysql; +alter table user drop column is_role; +flush privileges; +create role test_role; +ERROR HY000: Column count of mysql.user is wrong. Expected 43, found 42. Created with MariaDB 100003, now running 100003. Please use mysql_upgrade to fix this error. +drop role test_role; +ERROR HY000: Operation DROP ROLE failed for 'test_role' +alter table user add column is_role enum('N', 'Y') default 'N' not null +COLLATE utf8_general_ci +after authentication_string; +update user set is_role='N'; +flush privileges; +create role test_role; +drop role test_role; diff --git a/mysql-test/t/acl_roles_create_and_drop_role_invalid_user_table.test b/mysql-test/t/acl_roles_create_and_drop_role_invalid_user_table.test new file mode 100644 index 00000000000..9558b2a1a80 --- /dev/null +++ b/mysql-test/t/acl_roles_create_and_drop_role_invalid_user_table.test @@ -0,0 +1,23 @@ +connect (mysql, localhost, root,,); +use mysql; + +alter table user drop column is_role; + +flush privileges; + +--error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE +create role test_role; +--error ER_CANNOT_USER +drop role test_role; +alter table user add column is_role enum('N', 'Y') default 'N' not null + COLLATE utf8_general_ci +after authentication_string; + +update user set is_role='N'; + +flush privileges; +create role test_role; +drop role test_role; + + + diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 75693d02ea3..d3fb0b54d7f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3128,7 +3128,9 @@ static int replace_user_table(THD *thd, TABLE *table, LEX_USER &combo, /* if the user table is not up to date, we can't handle role updates */ if (table->s->fields <= 42 && handle_as_role) { - my_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE, MYF(0)); + my_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE, MYF(0), table->alias.c_ptr(), + 43, table->s->fields, + static_cast(table->s->mysql_version), MYSQL_VERSION_ID); DBUG_RETURN(-1); }