Skip to content

Commit d28670f

Browse files
committed
v4.0.0 Initial release for PG11 support. Major security requirement changes. See CHANGELOG for full details.
1 parent 20ca4d2 commit d28670f

File tree

5 files changed

+26
-40
lines changed

5 files changed

+26
-40
lines changed

test/README_test.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
pg_partman Test Suite
22
=====================
33

4-
The pgTAP testing suite is used to provide an extensive and easily maintainable set of unit tests. Please see the pgTAP home page for more details on its installation and use.
4+
The pgTAP testing suite is used to provide an extensive and easily maintainable set of unit tests. Please see the pgTAP home page for more details on its installation and use.
55

66
http://pgTAP.org/
77

8+
A minimum version of pgtap 0.99.1 is required for pg_partman's test suite.
9+
810
Tests assume that the required extensions have been installed in the following schemas:
911

1012
pg_partman: partman
@@ -34,20 +36,4 @@ As of version 4.0.0, SECURITY DEFINER is no longer in use by the majority of fun
3436
pg_prove -ovf -U partman -d mydatabase test/test-id-nonsuperuser.sql
3537
pg_prove -ovf -U partman -d mydatabase test/test_native/test-id-time-subpart-native.sql
3638

37-
Partitioning in PostgreSQL 10
38-
=============================
39-
pgtap currently does not have any tests for natively partitioned tables. The below two functions should be installed to the same schema as pgtap to allow the native partitioning tests to work. Once pgtap adds this support in itself, this will no longer be needed
40-
41-
create or replace function has_partition(name, name, text)
42-
returns text
43-
language sql
44-
as $$
45-
SELECT ok(_rexists('p', $1, $2), $3);
46-
$$;
47-
48-
create or replace function hasnt_partition(name, name, text)
49-
returns text
50-
language sql
51-
as $$
52-
SELECT ok( NOT _rexists('p', $1, $2), $3);
53-
$$;
39+

test/test_native/test-id-time-subpart-native.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ END $pg11_objects_check$;
4747
SELECT partman.create_parent('partman_test.id_taptest_table', 'col1', 'native', '10', '{"col3"}', p_jobmon := false, p_template_table := 'partman_test.template_id_taptest_table');
4848
INSERT INTO partman_test.id_taptest_table (col1) VALUES (generate_series(1,9));
4949

50-
SELECT has_partition('partman_test', 'id_taptest_table', 'Check that id_taptest_table is natively partitioned');
50+
SELECT is_partitioned('partman_test', 'id_taptest_table', 'Check that id_taptest_table is natively partitioned');
5151

5252
SELECT has_table('partman_test', 'id_taptest_table_p0', 'Check id_taptest_table_p0 exists');
5353
SELECT has_table('partman_test', 'id_taptest_table_p10', 'Check id_taptest_table_p10 exists');
@@ -80,12 +80,12 @@ SELECT partman.create_sub_parent('partman_test.id_taptest_table', 'col3', 'nativ
8080
--Reinsert data due to child table destruction
8181
INSERT INTO partman_test.id_taptest_table (col1) VALUES (generate_series(1,9));
8282

83-
SELECT has_partition('partman_test', 'id_taptest_table_p0', 'Check id_taptest_table_p0 is natively partitioned');
84-
SELECT has_partition('partman_test', 'id_taptest_table_p10', 'Check id_taptest_table_p10 is natively partitioned');
85-
SELECT has_partition('partman_test', 'id_taptest_table_p20', 'Check id_taptest_table_p20 is natively partitioned');
86-
SELECT has_partition('partman_test', 'id_taptest_table_p30', 'Check id_taptest_table_p30 is natively partitioned');
87-
SELECT has_partition('partman_test', 'id_taptest_table_p40', 'Check id_taptest_table_p40 is natively partitioned');
88-
SELECT hasnt_partition('partman_test', 'id_taptest_table_p50', 'Check id_taptest_table_p50 doesn''t exists as partition yet');
83+
SELECT is_partitioned('partman_test', 'id_taptest_table_p0', 'Check id_taptest_table_p0 is natively partitioned');
84+
SELECT is_partitioned('partman_test', 'id_taptest_table_p10', 'Check id_taptest_table_p10 is natively partitioned');
85+
SELECT is_partitioned('partman_test', 'id_taptest_table_p20', 'Check id_taptest_table_p20 is natively partitioned');
86+
SELECT is_partitioned('partman_test', 'id_taptest_table_p30', 'Check id_taptest_table_p30 is natively partitioned');
87+
SELECT is_partitioned('partman_test', 'id_taptest_table_p40', 'Check id_taptest_table_p40 is natively partitioned');
88+
SELECT isnt_partitioned('partman_test', 'id_taptest_table_p50', 'Check id_taptest_table_p50 doesn''t exists as partition yet');
8989

9090
-- p0
9191
SELECT has_table('partman_test', 'id_taptest_table_p0_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD'), 'Check id_taptest_table_p0_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||' exists');
@@ -281,7 +281,7 @@ SELECT results_eq('SELECT count(*)::int FROM partman_test.id_taptest_table_p20_p
281281

282282

283283
-- p50
284-
SELECT has_partition('partman_test', 'id_taptest_table_p50', 'Check id_taptest_table_p50 is natively partitioned');
284+
SELECT is_partitioned('partman_test', 'id_taptest_table_p50', 'Check id_taptest_table_p50 is natively partitioned');
285285

286286
SELECT has_table('partman_test', 'id_taptest_table_p50_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD'), 'Check id_taptest_table_p50_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||' exists');
287287
SELECT has_table('partman_test', 'id_taptest_table_p50_p'||to_char(CURRENT_TIMESTAMP+'1 day'::interval, 'YYYY_MM_DD'),
@@ -319,7 +319,7 @@ SELECT is_empty('SELECT * FROM ONLY partman_test.id_taptest_table_p50', 'Check t
319319
SELECT is_empty('SELECT * FROM partman_test.id_taptest_table_p50', 'Check count from parent table _p50 (should be empty)');
320320

321321
-- p60
322-
SELECT has_partition('partman_test', 'id_taptest_table_p60', 'Check id_taptest_table_p60 is natively partitioned');
322+
SELECT is_partitioned('partman_test', 'id_taptest_table_p60', 'Check id_taptest_table_p60 is natively partitioned');
323323

324324
SELECT has_table('partman_test', 'id_taptest_table_p60_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD'), 'Check id_taptest_table_p60_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||' exists');
325325
SELECT has_table('partman_test', 'id_taptest_table_p60_p'||to_char(CURRENT_TIMESTAMP+'1 day'::interval, 'YYYY_MM_DD'),

test/test_native/test-time-daily-native.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ALTER TABLE partman_test.time_taptest_table OWNER TO partman_owner;
3030

3131
SELECT create_parent('partman_test.time_taptest_table', 'col3', 'native', 'daily', p_publications := ARRAY['partman_test_publication']);
3232

33-
SELECT has_partition('partman_test', 'time_taptest_table', 'Check that time_taptest_table is natively partitioned');
33+
SELECT is_partitioned('partman_test', 'time_taptest_table', 'Check that time_taptest_table is natively partitioned');
3434
SELECT has_table('partman', 'template_partman_test_time_taptest_table', 'Check that default template table was created');
3535
SELECT table_owner_is ('partman', 'template_partman_test_time_taptest_table', 'partman_owner',
3636
'Check that template table ownership is set properly');

test/test_native/test-time-epoch-weekly-native.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CREATE TABLE partman_test.undo_taptest (LIKE partman_test.time_taptest_table INC
2525
SELECT create_parent('partman_test.time_taptest_table', 'col3', 'native', 'weekly', '{"col1"}', p_epoch := 'seconds'
2626
, p_premake := 2, p_start_partition := to_char(CURRENT_TIMESTAMP-'8 weeks'::interval, 'YYYY-MM-DD HH24:MI:SS'));
2727

28-
SELECT has_partition('partman_test', 'time_taptest_table', 'Check that time_taptest_table is natively partitioned');
28+
SELECT is_partitioned('partman_test', 'time_taptest_table', 'Check that time_taptest_table is natively partitioned');
2929

3030
INSERT INTO partman_test.time_taptest_table (col1, col3) VALUES (generate_series(1,10), extract('epoch' from CURRENT_TIMESTAMP - '8 weeks'::interval)::int);
3131

test/test_native/test-time-id-subpart-native.sql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,26 @@ SELECT is_empty('SELECT * FROM ONLY partman_test.time_taptest_table_p'||to_char(
8383
SELECT results_eq('SELECT count(*)::int FROM ONLY partman_test.time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||'_p0', ARRAY[10],
8484
'Check count from partman_test.time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||'_p0');
8585

86-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD'), 'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||' is natively partitioned');
87-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'1 day'::interval, 'YYYY_MM_DD'),
86+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD'), 'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||' is natively partitioned');
87+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'1 day'::interval, 'YYYY_MM_DD'),
8888
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'1 day'::interval, 'YYYY_MM_DD')||' is natively partitioned');
89-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'2 days'::interval, 'YYYY_MM_DD'),
89+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'2 days'::interval, 'YYYY_MM_DD'),
9090
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'2 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
91-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'3 days'::interval, 'YYYY_MM_DD'),
91+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'3 days'::interval, 'YYYY_MM_DD'),
9292
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'3 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
93-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'4 days'::interval, 'YYYY_MM_DD'),
93+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'4 days'::interval, 'YYYY_MM_DD'),
9494
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'4 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
95-
SELECT hasnt_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'5 days'::interval, 'YYYY_MM_DD'),
95+
SELECT isnt_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'5 days'::interval, 'YYYY_MM_DD'),
9696
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP+'5 days'::interval, 'YYYY_MM_DD')||' is not natively partitioned');
97-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'1 day'::interval, 'YYYY_MM_DD'),
97+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'1 day'::interval, 'YYYY_MM_DD'),
9898
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'1 day'::interval, 'YYYY_MM_DD')||' is natively partitioned');
99-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'2 days'::interval, 'YYYY_MM_DD'),
99+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'2 days'::interval, 'YYYY_MM_DD'),
100100
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'2 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
101-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'3 days'::interval, 'YYYY_MM_DD'),
101+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'3 days'::interval, 'YYYY_MM_DD'),
102102
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'3 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
103-
SELECT has_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'4 days'::interval, 'YYYY_MM_DD'),
103+
SELECT is_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'4 days'::interval, 'YYYY_MM_DD'),
104104
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'4 days'::interval, 'YYYY_MM_DD')||' is natively partitioned');
105-
SELECT hasnt_partition('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'5 days'::interval, 'YYYY_MM_DD'),
105+
SELECT isnt_partitioned('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'5 days'::interval, 'YYYY_MM_DD'),
106106
'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP-'5 days'::interval, 'YYYY_MM_DD')||' is not natively partitioned');
107107

108108
SELECT has_table('partman_test', 'time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||'_p0', 'Check time_taptest_table_p'||to_char(CURRENT_TIMESTAMP, 'YYYY_MM_DD')||'_p0 exists');

0 commit comments

Comments
 (0)