4
4
*/
5
5
SET client_min_messages = 'warning';
6
6
DROP FUNCTION IF EXISTS _partition_data_concurrent(oid,integer);
7
- DROP TABLE IF EXISTS conc_part CASCADE;
7
+ DROP FUNCTION IF EXISTS create_single_range_partition(TEXT,ANYELEMENT,ANYELEMENT,TEXT);
8
+ DROP TABLE IF EXISTS test1 CASCADE;
9
+ DROP TABLE IF EXISTS test2 CASCADE;
8
10
DROP ROLE IF EXISTS regress_hacker;
9
11
SET client_min_messages = 'notice';
10
12
CREATE EXTENSION pg_pathman;
11
13
CREATE ROLE regress_hacker LOGIN;
14
+ -- Test 1
15
+ RESET ROLE;
16
+ ALTER ROLE regress_hacker NOSUPERUSER;
12
17
SET ROLE regress_hacker;
13
18
SHOW is_superuser;
14
19
is_superuser
@@ -24,17 +29,17 @@ BEGIN
24
29
SELECT _partition_data_concurrent(relation, NULL::text, NULL::text, p_limit) INTO p_total;
25
30
END
26
31
$$ LANGUAGE plpgsql;
27
- CREATE TABLE conc_part(id INT4 NOT NULL);
28
- INSERT INTO conc_part SELECT generate_series(1, 500);
29
- SELECT create_hash_partitions('conc_part ', 'id ', 5, false);
32
+ CREATE TABLE test1(i INT4 NOT NULL);
33
+ INSERT INTO test1 SELECT generate_series(1, 500);
34
+ SELECT create_hash_partitions('test1 ', 'i ', 5, false);
30
35
create_hash_partitions
31
36
------------------------
32
37
5
33
38
(1 row)
34
39
35
40
RESET ROLE;
36
- SELECT partition_table_concurrently('conc_part ', 10, 1);
37
- NOTICE: worker started, you can stop it with the following command: select public.stop_concurrent_part_task('conc_part ');
41
+ SELECT partition_table_concurrently('test1 ', 10, 1);
42
+ NOTICE: worker started, you can stop it with the following command: select public.stop_concurrent_part_task('test1 ');
38
43
partition_table_concurrently
39
44
------------------------------
40
45
@@ -54,15 +59,57 @@ SHOW is_superuser;
54
59
off
55
60
(1 row)
56
61
62
+ -- Test 2
63
+ RESET ROLE;
64
+ ALTER ROLE regress_hacker NOSUPERUSER;
65
+ SET ROLE regress_hacker;
66
+ SHOW is_superuser;
67
+ is_superuser
68
+ --------------
69
+ off
70
+ (1 row)
71
+
72
+ CREATE FUNCTION create_single_range_partition(parent_relid TEXT, start_value ANYELEMENT, end_value ANYELEMENT, partition_name TEXT)
73
+ RETURNS REGCLASS
74
+ AS $$
75
+ BEGIN
76
+ ALTER ROLE regress_hacker SUPERUSER;
77
+ RETURN create_single_range_partition(parent_relid, start_value, end_value, partition_name, NULL::text);
78
+ END
79
+ $$ LANGUAGE plpgsql;
80
+ RESET ROLE;
81
+ CREATE TABLE test2(i INT4 NOT NULL);
82
+ INSERT INTO test2 VALUES(0);
83
+ SELECT create_range_partitions('test2', 'i', 0, 1);
84
+ create_range_partitions
85
+ -------------------------
86
+ 1
87
+ (1 row)
88
+
89
+ INSERT INTO test2 values(1);
90
+ -- Test result (must be 'off')
91
+ SET ROLE regress_hacker;
92
+ SHOW is_superuser;
93
+ is_superuser
94
+ --------------
95
+ off
96
+ (1 row)
97
+
57
98
-- Cleanup
58
99
RESET ROLE;
59
100
DROP FUNCTION _partition_data_concurrent(oid,integer);
60
- DROP TABLE conc_part CASCADE;
101
+ DROP FUNCTION create_single_range_partition(TEXT,ANYELEMENT,ANYELEMENT,TEXT);
102
+ DROP TABLE test1 CASCADE;
61
103
NOTICE: drop cascades to 5 other objects
62
- DETAIL: drop cascades to table conc_part_0
63
- drop cascades to table conc_part_1
64
- drop cascades to table conc_part_2
65
- drop cascades to table conc_part_3
66
- drop cascades to table conc_part_4
104
+ DETAIL: drop cascades to table test1_0
105
+ drop cascades to table test1_1
106
+ drop cascades to table test1_2
107
+ drop cascades to table test1_3
108
+ drop cascades to table test1_4
109
+ DROP TABLE test2 CASCADE;
110
+ NOTICE: drop cascades to 3 other objects
111
+ DETAIL: drop cascades to sequence test2_seq
112
+ drop cascades to table test2_1
113
+ drop cascades to table test2_2
67
114
DROP ROLE regress_hacker;
68
115
DROP EXTENSION pg_pathman;
0 commit comments