Help Center> GaussDB(DWS)> Troubleshooting> Account/Permission/Password> After the all Permission Is Granted to the Schema of a User, the Error Message "ERROR: current user does not have privilege to role tom" Persists During Table Creation
Updated on 2024-01-25 GMT+08:00

After the all Permission Is Granted to the Schema of a User, the Error Message "ERROR: current user does not have privilege to role tom" Persists During Table Creation

Symptom

Assume that there are two users, tom and jerry. jerry wants to create a table in the schema with the same name as that of tom. tom grants the all permission of the schema to jerry. However, an error is still reported when the table is created.

1
2
3
4
5
6
7
8
9
dbtest=# GRANT all on schema tom to jerry;
GRANT
dbtest=# \c - jerry
Password for user jerry: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "dbtest" as user "jerry".
dbtest=> 
dbtest=> CREATE TABLE tom.t(a int);
ERROR:  current user does not have privilege to role tom

Possible Causes

According to the error message, jerry requires the permission of the role tom.

Handling Procedure

After the permission of the role tom is granted to jerry, the table is created successfully.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dbtest=# GRANT tom to jerry;
GRANT ROLE
dbtest=# \c - jerry
Password for user jerry: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "dbtest" as user "jerry".
dbtest=> 
dbtest=> CREATE TABLE tom.t(a int);
NOTICE:  The 'DISTRIBUTE BY' clause is not specified. Using 'a' as the distribution column by default.
HINT:  Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.
CREATE TABLE