diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index ac5636d8..7b905360 100644 --- a/src/common/backend/parser/parse_utilcmd.cpp +++ b/src/common/backend/parser/parse_utilcmd.cpp @@ -4299,7 +4299,8 @@ List* transformCreateSchemaStmt(CreateSchemaStmt* stmt) cxt.triggers = lappend(cxt.triggers, element); } break; - case T_GrantStmt: + case T_GrantStmt: /* GRANT XXX ON XXX TO XXX */ + case T_AlterRoleStmt: /* GRANT ALL PRIVILEGES TO XXX */ cxt.grants = lappend(cxt.grants, element); break; diff --git a/src/test/regress/expected/create_schema.out b/src/test/regress/expected/create_schema.out index c6bb2acc..99e8bb04 100644 --- a/src/test/regress/expected/create_schema.out +++ b/src/test/regress/expected/create_schema.out @@ -26,6 +26,22 @@ create user pg_error_username password 'test-1234'; ERROR: unacceptable user name: fail to create same name schema for user "pg_error_username" DETAIL: The prefix "pg_" is reserved for system schemas. drop role samedb_schema_cn_role_02_001; +create user grant_user_test password 'test-1234'; +select rolsystemadmin from pg_roles where rolname='grant_user_test'; + rolsystemadmin +---------------- + f +(1 row) + +create schema schema_with_grant_test grant all privileges to grant_user_test; +select rolsystemadmin from pg_roles where rolname='grant_user_test'; + rolsystemadmin +---------------- + t +(1 row) + +drop user grant_user_test; +drop schema schema_with_grant_test; drop schema test_ns_schema_1 cascade; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to table test_ns_schema_1.abc diff --git a/src/test/regress/sql/create_schema.sql b/src/test/regress/sql/create_schema.sql index 33a8b317..cd8c76a6 100644 --- a/src/test/regress/sql/create_schema.sql +++ b/src/test/regress/sql/create_schema.sql @@ -31,4 +31,13 @@ create user pg_error_username password 'test-1234'; drop role samedb_schema_cn_role_02_001; +create user grant_user_test password 'test-1234'; +select rolsystemadmin from pg_roles where rolname='grant_user_test'; + +create schema schema_with_grant_test grant all privileges to grant_user_test; +select rolsystemadmin from pg_roles where rolname='grant_user_test'; + +drop user grant_user_test; +drop schema schema_with_grant_test; + drop schema test_ns_schema_1 cascade;