Changeset: 4df298ac8ea2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4df298ac8ea2
Modified Files:
        sql/server/sql_privileges.c
        sql/test/Users/Tests/schema.stable.err
Branch: Oct2020
Log Message:

Give a clearer error message when a user or a role is not found when granting 
the role


diffs (33 lines):

diff --git a/sql/server/sql_privileges.c b/sql/server/sql_privileges.c
--- a/sql/server/sql_privileges.c
+++ b/sql/server/sql_privileges.c
@@ -532,7 +532,7 @@ sql_grant_role(mvc *m, str grantee, str 
 
        rid = table_funcs.column_find_row(m->session->tr, auths_name, role, 
NULL);
        if (is_oid_nil(rid))
-               throw(SQL, "sql.grant_role", SQLSTATE(M1M05) "GRANT: Cannot 
grant ROLE '%s' to user '%s'", role, grantee);
+               throw(SQL, "sql.grant_role", SQLSTATE(M1M05) "GRANT: no such 
role '%s' or grantee '%s'", role, grantee);
        role_id = table_funcs.column_find_sqlid(m->session->tr, auths_id, rid);
        if (backend_find_user(m, role) >= 0)
                throw(SQL,"sql.grant_role", SQLSTATE(M1M05) "GRANT: '%s' is a 
USER not a ROLE", role);
@@ -540,7 +540,7 @@ sql_grant_role(mvc *m, str grantee, str 
                throw(SQL,"sql.grant_role", SQLSTATE(0P000) "GRANT: 
Insufficient privileges to grant ROLE '%s'", role);
        rid = table_funcs.column_find_row(m->session->tr, auths_name, grantee, 
NULL);
        if (is_oid_nil(rid))
-               throw(SQL,"sql.grant_role", SQLSTATE(M1M05) "GRANT: Cannot 
grant ROLE '%s' to user '%s'", role, grantee);
+               throw(SQL,"sql.grant_role", SQLSTATE(M1M05) "GRANT: no such 
role '%s' or grantee '%s'", role, grantee);
        grantee_id = table_funcs.column_find_sqlid(m->session->tr, auths_id, 
rid);
        rid = table_funcs.column_find_row(m->session->tr, 
find_sql_column(roles, "login_id"), &grantee_id, find_sql_column(roles, 
"role_id"), &role_id, NULL);
        if (!is_oid_nil(rid))
diff --git a/sql/test/Users/Tests/schema.stable.err 
b/sql/test/Users/Tests/schema.stable.err
--- a/sql/test/Users/Tests/schema.stable.err
+++ b/sql/test/Users/Tests/schema.stable.err
@@ -12,7 +12,7 @@ stderr of test 'schema` in directory 'sq
 
 MAPI  = (monetdb) /var/tmp/mtest-26250/.s.monetdb.37381
 QUERY = GRANT my_owner to my_user; -- error wrong non existing role
-ERROR = !GRANT: Cannot grant ROLE 'my_owner' to user 'my_user'
+ERROR = !GRANT: no such role 'my_owner' or grantee 'my_user'
 CODE  = M1M05
 
 # 14:00:57 >  
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to