我遇到了同样的问题,但@Laurenz 的回答只是部分帮助了我 - 我遇到了权限问题,因为在撤销默认权限之前,我已经将架构的所有权从 ted.mosby 转移给了我的主用户。 长话短说 - 在转让所有权之前撤销默认权限。
重现我的问题(我不知道这是 Redshift 中的错误还是预期的行为?):
-- executed with master user redshift_master
CREATE USER anton_test_user PASSWORD '***' IN GROUP redshift_dev;
然后使用anton_test_user
CREATE SCHEMA anton_test_schema;
CREATE TABLE anton_test_schema.anton_test_table AS SELECT 1 AS anton;
ALTER DEFAULT PRIVILEGES IN SCHEMA anton_test_schema
GRANT SELECT ON TABLES TO GROUP redshift_readonly;
再次使用redshift_master
ALTER SCHEMA anton_test_schema OWNER TO redshift_master;
ALTER TABLE anton_test_schema.anton_test_table OWNER TO redshift_master;
现在尝试删除它抱怨默认权限的用户:
DROP USER anton_test_user;
结果如预期:
owner of default privileges on new relations belonging to user
anton_test_user in schema anton_test_schema;
现在到奇怪的部分,仍然是redshift_master
ALTER DEFAULT PRIVILEGES FOR USER anton_test_user IN SCHEMA anton_test_schema
REVOKE ALL ON TABLES FROM redshift_readonly;
给Invalid operation: permission denied for schema anton_test_schema。什么?
如果使用anton_test_user 运行
ALTER DEFAULT PRIVILEGES IN SCHEMA anton_test_schema
REVOKE ALL ON TABLES FROM redshift_readonly;
同时提供Invalid operation: permission denied for schema anton_test_schema。
我解决这个问题并能够删除 anton_test_user 的唯一方法是,redshift_master 完全删除架构和表
DROP TABLE anton_test_schema.anton_test_table;
DROP SCHEMA anton_test_schema;
DROP USER anton_test_user; -- it works now
我完全不知情的猜测是 anton_test_user 已经失去了对架构的权限,因此无法在该架构中应用或撤销对用户的授权。