尝试设置一个用户对另一个用户对象的访问权限时出现“必须是角色成员”错误

oh *_* no 2 postgresql google-cloud-platform

在谷歌云上,使用“postgres”用户(不是超级用户),我这样做:

CREATE ROLE postgres_subuser1 LOGIN PASSWORD 'some_pass';
CREATE ROLE postgres_subuser2 LOGIN PASSWORD 'some_pass';

GRANT postgres TO postgres_subuser1;
GRANT postgres TO postgres_subuser2;
Run Code Online (Sandbox Code Playgroud)

上面的部分有效,但随后我尝试设置用户对每个其他对象的访问权限:

ALTER DEFAULT PRIVILEGES FOR ROLE postgres_subuser1 GRANT ALL PRIVILEGES ON TABLES TO postgres_subuser2; 
ALTER DEFAULT PRIVILEGES FOR ROLE postgres_subuser2 GRANT ALL PRIVILEGES ON TABLES TO postgres_subuser1;
Run Code Online (Sandbox Code Playgroud)

给出:must be member of role "postgres_subuser1"

怎么解决呢?

顺便说一句,如果在本地实例上尝试相同的操作,它可以正常工作,不会出现任何错误,但在谷歌云上会出现此错误。

Mic*_*ael 7

您需要显式授予postgres用户该角色。例如:

GRANT postgres_subuser1 TO postgres;
Run Code Online (Sandbox Code Playgroud)