Enable modify the owner of procedure
修改测试用例名
This commit is contained in:
@ -9459,6 +9459,14 @@ privilege_target:
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| PROCEDURE function_with_argtypes_list
|
||||
{
|
||||
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
|
||||
n->targtype = ACL_TARGET_OBJECT;
|
||||
n->objtype = ACL_OBJECT_FUNCTION;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| DATABASE name_list
|
||||
{
|
||||
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
|
||||
|
||||
33
src/test/regress/input/procedure_privilege_test.source
Normal file
33
src/test/regress/input/procedure_privilege_test.source
Normal file
@ -0,0 +1,33 @@
|
||||
DROP SCHEMA IF EXISTS test_sch;
|
||||
DROP TABLE IF EXISTS test_sch.test_table;
|
||||
CREATE SCHEMA test_sch;
|
||||
CREATE TABLE test_sch.test_table(id1 int, id2 varchar(20));
|
||||
CREATE OR REPLACE PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) AS
|
||||
BEGIN
|
||||
INSERT INTO test_sch.test_table values(num1, num2);
|
||||
END;
|
||||
/
|
||||
|
||||
CALL test_sch.test_pro(1, 'initial');
|
||||
|
||||
DROP USER IF EXISTS test_owner CASCADE;
|
||||
DROP USER IF EXISTS test_acl CASCADE;
|
||||
CREATE USER test_owner WITH PASSWORD 'openGauss@123';
|
||||
CREATE USER test_acl WITH PASSWORD 'openGauss@123';
|
||||
GRANT ALL PRIVILEGES ON SCHEMA test_sch TO test_acl;
|
||||
GRANT INSERT ON TABLE test_sch.test_table TO test_acl;
|
||||
REVOKE ALL PRIVILEGES ON PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) FROM test_acl;
|
||||
|
||||
\! @abs_bindir@/gsql -r -p @portstring@ -d regression -U test_acl -W 'openGauss@123' -c 'ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) RENAME TO new_test_pro;'
|
||||
|
||||
ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) OWNER TO test_owner;
|
||||
GRANT ALL PRIVILEGES ON PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) TO test_acl;
|
||||
|
||||
SELECT p.proname, r.rolname FROM PG_PROC AS p, pg_roles AS r WHERE p.proowner=r.oid AND proname='test_pro';
|
||||
\! @abs_bindir@/gsql -r -p @portstring@ -d regression -U test_acl -W 'openGauss@123' -c 'ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) RENAME TO new_test_pro;'
|
||||
|
||||
SELECT p.proname, r.rolname FROM PG_PROC AS p, pg_roles AS r WHERE p.proowner=r.oid AND proname='new_test_pro';
|
||||
|
||||
DROP TABLE IF EXISTS test_sch.test_table;
|
||||
DROP USER IF EXISTS test_owner CASCADE;
|
||||
DROP USER IF EXISTS test_acl CASCADE;
|
||||
47
src/test/regress/output/procedure_privilege_test.source
Normal file
47
src/test/regress/output/procedure_privilege_test.source
Normal file
@ -0,0 +1,47 @@
|
||||
DROP SCHEMA IF EXISTS test_sch;
|
||||
NOTICE: schema "test_sch" does not exist, skipping
|
||||
DROP TABLE IF EXISTS test_sch.test_table;
|
||||
ERROR: schema "test_sch" does not exist
|
||||
CREATE SCHEMA test_sch;
|
||||
CREATE TABLE test_sch.test_table(id1 int, id2 varchar(20));
|
||||
CREATE OR REPLACE PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) AS
|
||||
BEGIN
|
||||
INSERT INTO test_sch.test_table values(num1, num2);
|
||||
END;
|
||||
/
|
||||
CALL test_sch.test_pro(1, 'initial');
|
||||
test_pro
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP USER IF EXISTS test_owner CASCADE;
|
||||
NOTICE: role "test_owner" does not exist, skipping
|
||||
DROP USER IF EXISTS test_acl CASCADE;
|
||||
NOTICE: role "test_acl" does not exist, skipping
|
||||
CREATE USER test_owner WITH PASSWORD 'openGauss@123';
|
||||
CREATE USER test_acl WITH PASSWORD 'openGauss@123';
|
||||
GRANT ALL PRIVILEGES ON SCHEMA test_sch TO test_acl;
|
||||
GRANT INSERT ON TABLE test_sch.test_table TO test_acl;
|
||||
REVOKE ALL PRIVILEGES ON PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) FROM test_acl;
|
||||
\! @abs_bindir@/gsql -r -p @portstring@ -d regression -U test_acl -W 'openGauss@123' -c 'ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) RENAME TO new_test_pro;'
|
||||
ERROR: permission denied for function test_sch.test_pro
|
||||
ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) OWNER TO test_owner;
|
||||
GRANT ALL PRIVILEGES ON PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) TO test_acl;
|
||||
SELECT p.proname, r.rolname FROM PG_PROC AS p, pg_roles AS r WHERE p.proowner=r.oid AND proname='test_pro';
|
||||
proname | rolname
|
||||
----------+------------
|
||||
test_pro | test_owner
|
||||
(1 row)
|
||||
|
||||
\! @abs_bindir@/gsql -r -p @portstring@ -d regression -U test_acl -W 'openGauss@123' -c 'ALTER PROCEDURE test_sch.test_pro(num1 integer, num2 varchar(20)) RENAME TO new_test_pro;'
|
||||
ALTER FUNCTION
|
||||
SELECT p.proname, r.rolname FROM PG_PROC AS p, pg_roles AS r WHERE p.proowner=r.oid AND proname='new_test_pro';
|
||||
proname | rolname
|
||||
--------------+------------
|
||||
new_test_pro | test_owner
|
||||
(1 row)
|
||||
|
||||
DROP TABLE IF EXISTS test_sch.test_table;
|
||||
DROP USER IF EXISTS test_owner CASCADE;
|
||||
DROP USER IF EXISTS test_acl CASCADE;
|
||||
@ -760,4 +760,5 @@ test: leaky_function_operator
|
||||
#test: gs_guc
|
||||
|
||||
test: smp
|
||||
test: sequence_cache_test
|
||||
test: sequence_cache_test
|
||||
test: procedure_privilege_test
|
||||
Reference in New Issue
Block a user