Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
302 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
\unset ECHO | ||
1..66 | ||
ok 1 - is_partition_of( csch, ctab, psch, ptab, desc ) should pass | ||
ok 2 - is_partition_of( csch, ctab, psch, ptab, desc ) should have the proper description | ||
ok 3 - is_partition_of( csch, ctab, psch, ptab, desc ) should have the proper diagnostics | ||
ok 4 - is_partition_of( csch, ctab, psch, ptab ) should pass | ||
ok 5 - is_partition_of( csch, ctab, psch, ptab ) should have the proper description | ||
ok 6 - is_partition_of( csch, ctab, psch, ptab ) should have the proper diagnostics | ||
ok 7 - is_partition_of( ctab, ptab, desc ) should pass | ||
ok 8 - is_partition_of( ctab, ptab, desc ) should have the proper description | ||
ok 9 - is_partition_of( ctab, ptab, desc ) should have the proper diagnostics | ||
ok 10 - is_partition_of( ctab, ptab ) should pass | ||
ok 11 - is_partition_of( ctab, ptab ) should have the proper description | ||
ok 12 - is_partition_of( ctab, ptab ) should have the proper diagnostics | ||
ok 13 - is_partition_of( csch, non-part ctab, psch, non-part ptab, desc ) should fail | ||
ok 14 - is_partition_of( csch, non-part ctab, psch, non-part ptab, desc ) should have the proper description | ||
ok 15 - is_partition_of( csch, non-part ctab, psch, non-part ptab, desc ) should have the proper diagnostics | ||
ok 16 - is_partition_of( non-part ctab, non-part ptab, desc ) should fail | ||
ok 17 - is_partition_of( non-part ctab, non-part ptab, desc ) should have the proper description | ||
ok 18 - is_partition_of( non-part ctab, non-part ptab, desc ) should have the proper diagnostics | ||
ok 19 - is_partition_of( csch, non-part ctab, psch, ptab, desc ) should fail | ||
ok 20 - is_partition_of( csch, non-part ctab, psch, ptab, desc ) should have the proper description | ||
ok 21 - is_partition_of( csch, non-part ctab, psch, ptab, desc ) should have the proper diagnostics | ||
ok 22 - is_partition_of( non-part ctab, ptab, desc ) should fail | ||
ok 23 - is_partition_of( non-part ctab, ptab, desc ) should have the proper description | ||
ok 24 - is_partition_of( non-part ctab, ptab, desc ) should have the proper diagnostics | ||
ok 25 - is_partition_of( csch, ctab, psch, non-part ptab, desc ) should fail | ||
ok 26 - is_partition_of( csch, ctab, psch, non-part ptab, desc ) should have the proper description | ||
ok 27 - is_partition_of( csch, ctab, psch, non-part ptab, desc ) should have the proper diagnostics | ||
ok 28 - is_partition_of( ctab, non-part ptab, desc ) should fail | ||
ok 29 - is_partition_of( ctab, non-part ptab, desc ) should have the proper description | ||
ok 30 - is_partition_of( ctab, non-part ptab, desc ) should have the proper diagnostics | ||
ok 31 - is_partition_of( priv csch, ctab, priv psch, ptab, desc ) should pass | ||
ok 32 - is_partition_of( priv csch, ctab, priv psch, ptab, desc ) should have the proper description | ||
ok 33 - is_partition_of( priv csch, ctab, priv psch, ptab, desc ) should have the proper diagnostics | ||
ok 34 - is_partition_of( priv ctab, priv ptab, desc ) should fail | ||
ok 35 - is_partition_of( priv ctab, priv ptab, desc ) should have the proper description | ||
ok 36 - is_partition_of( priv ctab, priv ptab, desc ) should have the proper diagnostics | ||
ok 37 - is_partition_of( priv csch, ctab, psch, ptab, desc ) should pass | ||
ok 38 - is_partition_of( priv csch, ctab, psch, ptab, desc ) should have the proper description | ||
ok 39 - is_partition_of( priv csch, ctab, psch, ptab, desc ) should have the proper diagnostics | ||
ok 40 - is_partition_of( priv ctab, ptab, desc ) should fail | ||
ok 41 - is_partition_of( priv ctab, ptab, desc ) should have the proper description | ||
ok 42 - is_partition_of( priv ctab, ptab, desc ) should have the proper diagnostics | ||
ok 43 - is_partition_of( csch, ctab, priv psch, ptab, desc ) should pass | ||
ok 44 - is_partition_of( csch, ctab, priv psch, ptab, desc ) should have the proper description | ||
ok 45 - is_partition_of( csch, ctab, priv psch, ptab, desc ) should have the proper diagnostics | ||
ok 46 - is_partition_of( ctab, priv ptab, desc ) should fail | ||
ok 47 - is_partition_of( ctab, priv ptab, desc ) should have the proper description | ||
ok 48 - is_partition_of( ctab, priv ptab, desc ) should have the proper diagnostics | ||
ok 49 - is_partition_of( csch, non-ctab, psch, non-ptab, desc ) should fail | ||
ok 50 - is_partition_of( csch, non-ctab, psch, non-ptab, desc ) should have the proper description | ||
ok 51 - is_partition_of( csch, non-ctab, psch, non-ptab, desc ) should have the proper diagnostics | ||
ok 52 - is_partition_of( non-ctab, non-ptab, desc ) should fail | ||
ok 53 - is_partition_of( non-ctab, non-ptab, desc ) should have the proper description | ||
ok 54 - is_partition_of( non-ctab, non-ptab, desc ) should have the proper diagnostics | ||
ok 55 - is_partition_of( csch, ctab, psch, non-ptab, desc ) should fail | ||
ok 56 - is_partition_of( csch, ctab, psch, non-ptab, desc ) should have the proper description | ||
ok 57 - is_partition_of( csch, ctab, psch, non-ptab, desc ) should have the proper diagnostics | ||
ok 58 - is_partition_of( ctab, non-ptab, desc ) should fail | ||
ok 59 - is_partition_of( ctab, non-ptab, desc ) should have the proper description | ||
ok 60 - is_partition_of( ctab, non-ptab, desc ) should have the proper diagnostics | ||
ok 61 - is_partition_of( csch, non-ctab, psch, ptab, desc ) should fail | ||
ok 62 - is_partition_of( csch, non-ctab, psch, ptab, desc ) should have the proper description | ||
ok 63 - is_partition_of( csch, non-ctab, psch, ptab, desc ) should have the proper diagnostics | ||
ok 64 - is_partition_of( non-ctab, ptab, desc ) should fail | ||
ok 65 - is_partition_of( non-ctab, ptab, desc ) should have the proper description | ||
ok 66 - is_partition_of( non-ctab, ptab, desc ) should have the proper diagnostics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
\unset ECHO | ||
\i test/setup.sql | ||
|
||
SELECT plan(66); | ||
--SELECT * FROM no_plan(); | ||
|
||
-- This will be rolled back. :-) | ||
SET client_min_messages = warning; | ||
|
||
-- Create inherited tables (not partitions). | ||
CREATE TABLE public.parent(id INT PRIMARY KEY); | ||
CREATE TABLE public.child(id INT PRIMARY KEY) INHERITS (public.parent); | ||
|
||
-- Create a partitioned table with two partitions. | ||
CREATE TABLE public.parted(id INT NOT NULL) PARTITION BY RANGE (id); | ||
CREATE TABLE public.part1 PARTITION OF public.parted FOR VALUES FROM (1) TO (10); | ||
CREATE TABLE public.part2 PARTITION OF public.parted FOR VALUES FROM (11) TO (20); | ||
|
||
-- Create partitions outside of search path. | ||
CREATE SCHEMA hide; | ||
CREATE TABLE hide.hidden_parted(id INT NOT NULL) PARTITION BY RANGE (id); | ||
CREATE TABLE hide.hidden_part1 PARTITION OF hide.hidden_parted FOR VALUES FROM (1) TO (10); | ||
CREATE TABLE hide.hidden_part2 PARTITION OF hide.hidden_parted FOR VALUES FROM (11) TO (20); | ||
|
||
-- Put a partition for the public table in the hidden schema. | ||
CREATE TABLE hide.part3 PARTITION OF public.parted FOR VALUES FROM (21) TO (30); | ||
|
||
-- Put a partition for the hidden table in the public schema. | ||
CREATE TABLE public.not_hidden_part3 PARTITION OF hide.hidden_parted | ||
FOR VALUES FROM (21) TO (30); | ||
|
||
RESET client_min_messages; | ||
|
||
/****************************************************************************/ | ||
-- Test is_partition_of(). | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'part1', 'public', 'parted', 'whatevs' ), | ||
true, | ||
'is_partition_of( csch, ctab, psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'part1', 'public', 'parted' ), | ||
true, | ||
'is_partition_of( csch, ctab, psch, ptab )', | ||
'Table public.part1 should be a partition of public.parted', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'part1', 'parted', 'whatevs' ), | ||
true, | ||
'is_partition_of( ctab, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'part1', 'parted' ), | ||
true, | ||
'is_partition_of( ctab, ptab )', | ||
'Table part1 should be a partition of parted', | ||
'' | ||
); | ||
|
||
-- is_partition_of() should fail for inherited but not partitioned tables. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'child', 'public', 'parent', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, non-part ctab, psch, non-part ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'child', 'parent', 'whatevs' ), | ||
false, | ||
'is_partition_of( non-part ctab, non-part ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- is_partition_of() should fail for parted table and non-part child. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'child', 'public', 'parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, non-part ctab, psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'child', 'parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( non-part ctab, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- is_partition_of() should fail for partition child but wrong parent. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'part1', 'public', 'parent', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, ctab, psch, non-part ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'part1', 'parent', 'whatevs' ), | ||
false, | ||
'is_partition_of( ctab, non-part ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- Should find tables outside search path for explicit schema. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'hide', 'hidden_part1', 'hide', 'hidden_parted', 'whatevs' ), | ||
true, | ||
'is_partition_of( priv csch, ctab, priv psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- But not when the schema is not specified. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'hidden_part1', 'hidden_parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( priv ctab, priv ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- Should find explicit hidden table for public partition. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'hide', 'part3', 'public', 'parted', 'whatevs' ), | ||
true, | ||
'is_partition_of( priv csch, ctab, psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- But still not when schemas not specified. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'part3', 'hidden', 'whatevs' ), | ||
false, | ||
'is_partition_of( priv ctab, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- Should find public partition for hidden parent. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'not_hidden_part3', 'hide', 'hidden_parted', 'whatevs' ), | ||
true, | ||
'is_partition_of( csch, ctab, priv psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- But not if no schemas are specified. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'not_hidden_part3', 'hidden_parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( ctab, priv ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
-- And of course, it should not work for nonexistent partitions. | ||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'nonesuch', 'public', 'nothing', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, non-ctab, psch, non-ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'nonesuch', 'nothing', 'whatevs' ), | ||
false, | ||
'is_partition_of( non-ctab, non-ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'part1', 'public', 'nothing', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, ctab, psch, non-ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'nonesuch', 'part1', 'whatevs' ), | ||
false, | ||
'is_partition_of( ctab, non-ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'public', 'nonesuch', 'public', 'parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( csch, non-ctab, psch, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
SELECT * FROM check_test( | ||
is_partition_of( 'nonesuch', 'parted', 'whatevs' ), | ||
false, | ||
'is_partition_of( non-ctab, ptab, desc )', | ||
'whatevs', | ||
'' | ||
); | ||
|
||
/****************************************************************************/ | ||
-- Finish the tests and clean up. | ||
SELECT * FROM finish(); | ||
ROLLBACK; |