From 384a83d8c904100174da76bbc6696252a26f7f84 Mon Sep 17 00:00:00 2001 From: TotaJ Date: Wed, 20 Jan 2021 11:22:04 +0800 Subject: [PATCH] Fix create schema with grant all. --- src/common/backend/parser/parse_utilcmd.cpp | 3 ++- src/test/regress/expected/create_schema.out | 16 ++++++++++++++++ src/test/regress/sql/create_schema.sql | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index ac5636d86..7b9053603 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 260c27c31..49ce4d318 100644 --- a/src/test/regress/expected/create_schema.out +++ b/src/test/regress/expected/create_schema.out @@ -18,6 +18,22 @@ create table abc( ); NOTICE: CREATE TABLE will create implicit sequence "abc_a_seq" for serial column "abc.a" 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 8859582d8..a3a042563 100644 --- a/src/test/regress/sql/create_schema.sql +++ b/src/test/regress/sql/create_schema.sql @@ -26,4 +26,13 @@ create table abc( 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;