\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_recyclebin = on" > /dev/null 2>&1
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
-- timeCapsule table t to before truncate
-- 1. revoke schema
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user if exists user_a;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "create table user_a.t2(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "insert into user_a.t2 values(0),(1),(2);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "truncate table user_a.t2;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "revoke usage on schema user_a from user_a;"
-- The expected results: ERROR: permission denied for schema user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t2 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a.t2 purge;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
-- 2. revoke truncate
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "create table user_a.t2(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "insert into user_a.t2 values(0),(1),(2);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "truncate table user_a.t2;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "revoke truncate on user_a.t2 from user_a;"
-- The expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t2 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a.t2 purge;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
-- 3. alter schema user_a owner to user_b
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_A.t_a_1026(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Insert into user_A.t_a_1026 values(0),(1),(2);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "truncate table user_a.t_a_1026;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "alter schema user_A owner to user_b;"
-- The expected results: permission denied for schema user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
-- The expected results: ERROR: permission denied for relation t_a_1026
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "Truncate table user_a.t_a_1026;"
-- The expected results: ERROR: permission denied for recyclebin object
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "grant truncate on user_a.t_a_1026 to user_b;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a. t_a_1026 purge;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- 4. grant user_b to user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant user_b to user_a;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_b.t1(a int);"
-- The expected results: success
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Truncate user_b.t1;"
-- The expected results: success
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_b.t1 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "revoke user_b from user_a;"
-- The expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_b.t1 to before truncate;"
-- The expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "truncate table user_b.t1;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- 5. must be owner of table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_A.t_a_1026(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Insert into user_A.t_a_1026 values(0),(1),(2);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "truncate table user_a.t_a_1026; "
-- expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant usage on schema user_a to user_b;"
-- expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant create on schema user_a to user_b;"
-- expected results: must be owner of
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
-- expected results:timeCapsule table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before truncate;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a. t_a_1026 purge;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- timeCapsule to before drop
-- 1. revoke usage on schema
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "create table user_a.t2(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "drop table user_a.t2;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "revoke usage on schema user_a from user_a;"
-- The expected results: ERROR: permission denied for schema user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t2 to before drop;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
-- 2. alter schema user_a owner to user_b
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
-- user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_A.t_a_1026(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "drop table user_a.t_a_1026;"
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "alter schema user_A owner to user_b;"
-- user_a:
-- The expected results: ERROR: permission denied for schema user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
-- user_b:
-- The expected results: timeCapsule table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a.t_a_1026 purge;"
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- 3. grant user_b to user_a
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant user_b to user_a;"
-- user_a:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_b.t1(a int);"
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_b.t1; "
-- user_a:
-- The expected results: timeCapsule table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_b.t1 to before drop;"
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_b.t1;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "revoke user_b from user_a;"
-- user_a:
-- The expected results: failed
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_b.t1 to before drop;"
-- Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop schema if exists user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- 4. must be owner of table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_A.t_a_1026(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Insert into user_A.t_a_1026 values(0),(1),(2);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "drop table user_a.t_a_1026; "
-- expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant usage on schema user_a to user_b;"
-- expected results: permission denied
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Grant create on schema user_a to user_b;"
-- expected results: must be owner of
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
-- expected results:timeCapsule table
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "timeCapsule table user_a.t_a_1026 to before drop;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop table user_a. t_a_1026 purge;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
-- purge recyclebin
--1.Initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_c identified by 'TestPwd@123';"
--2.user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_a.tab1_(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_a.tab2(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Drop table user_a.tab1_;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Drop table user_a.tab2;"
--3.user_b
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "Create table user_b.tab3(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "Create table user_b.tab4(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "Drop table user_b.tab3;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "Drop table user_b.tab4;"
--4.user_c
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_c -W TestPwd@123 -c "Create table user_c.tab5(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_c -W TestPwd@123 -c "Create table user_c.tab6(a int);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_c -W TestPwd@123 -c "Drop table user_c.tab5;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_c -W TestPwd@123 -c "Drop table user_c.tab6;"
--5.user_a:purge recyclebin
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Select rcyoriginname from gs_recyclebin;"
--6.the initializing user:purge recyclebin
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "Select rcyoriginname from gs_recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b cascade;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_c cascade;"
-- timeCapsule table to before drop: There are multiple objects of the same name in the recyclebin
Create table tab1_(a int);
Insert into tab1_ values(0);
Drop table tab1_;
Create table tab1_(a int);
Insert into tab1_ values(1);
Drop table tab1_;
Create table tab1_(a int);
Insert into tab1_ values(2);
Drop table tab1_;
Timecapsule table tab1_ to before drop;
-- expected: 2
Select * from tab1_;
Drop table tab1_;
Purge recyclebin;
-- purge index
--1.the initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_a identified by 'TestPwd@123';"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user user_b identified by 'TestPwd@123';"
--2.user_a
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create table user_a.tab1_(a int, b char);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Create index index_tab1_a on user_a.tab1_(a);"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "Drop table user_a.tab1_;"
--3.user_b
--expected: no privilege
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_b -W TestPwd@123 -c "purge index user_a.index_tab1_a;"
--4.user_a
--expected: success
\! @abs_bindir@/gsql -d postgres -p @portstring@ -U user_a -W TestPwd@123 -c "purge index user_a.index_tab1_a;"
--5.the initializing user:
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "purge recyclebin;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_a;"
\! @abs_bindir@/gsql -d postgres -p @portstring@ -c "drop user user_b;"
\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_recyclebin = off" > /dev/null 2>&1