Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d12fbe2

Browse files
committed
Test partition functions with legacy inheritance children, too
It's worth immortalizing this behavior, per discussion. Discussion: https://postgr.es/m/20190228193203.GA26151@alvherre.pgsql
1 parent 278584b commit d12fbe2

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/test/regress/expected/partition_info.out

+27-2
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ SELECT pg_partition_root('ptif_normal_table');
180180
(1 row)
181181

182182
DROP TABLE ptif_normal_table;
183-
-- Various partitioning-related functions return NULL if passed relations
183+
-- Various partitioning-related functions return empty/NULL if passed relations
184184
-- of types that cannot be part of a partition tree; for example, views,
185-
-- materialized views, etc.
185+
-- materialized views, legacy inheritance children or parents, etc.
186186
CREATE VIEW ptif_test_view AS SELECT 1;
187187
CREATE MATERIALIZED VIEW ptif_test_matview AS SELECT 1;
188+
CREATE TABLE ptif_li_parent ();
189+
CREATE TABLE ptif_li_child () INHERITS (ptif_li_parent);
188190
SELECT * FROM pg_partition_tree('ptif_test_view');
189191
relid | parentrelid | isleaf | level
190192
-------+-------------+--------+-------
@@ -195,6 +197,16 @@ SELECT * FROM pg_partition_tree('ptif_test_matview');
195197
-------+-------------+--------+-------
196198
(0 rows)
197199

200+
SELECT * FROM pg_partition_tree('ptif_li_parent');
201+
relid | parentrelid | isleaf | level
202+
-------+-------------+--------+-------
203+
(0 rows)
204+
205+
SELECT * FROM pg_partition_tree('ptif_li_child');
206+
relid | parentrelid | isleaf | level
207+
-------+-------------+--------+-------
208+
(0 rows)
209+
198210
SELECT pg_partition_root('ptif_test_view');
199211
pg_partition_root
200212
-------------------
@@ -207,5 +219,18 @@ SELECT pg_partition_root('ptif_test_matview');
207219

208220
(1 row)
209221

222+
SELECT pg_partition_root('ptif_li_parent');
223+
pg_partition_root
224+
-------------------
225+
226+
(1 row)
227+
228+
SELECT pg_partition_root('ptif_li_child');
229+
pg_partition_root
230+
-------------------
231+
232+
(1 row)
233+
210234
DROP VIEW ptif_test_view;
211235
DROP MATERIALIZED VIEW ptif_test_matview;
236+
DROP TABLE ptif_li_parent, ptif_li_child;

src/test/regress/sql/partition_info.sql

+9-2
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,21 @@ SELECT relid, parentrelid, level, isleaf
8484
SELECT pg_partition_root('ptif_normal_table');
8585
DROP TABLE ptif_normal_table;
8686

87-
-- Various partitioning-related functions return NULL if passed relations
87+
-- Various partitioning-related functions return empty/NULL if passed relations
8888
-- of types that cannot be part of a partition tree; for example, views,
89-
-- materialized views, etc.
89+
-- materialized views, legacy inheritance children or parents, etc.
9090
CREATE VIEW ptif_test_view AS SELECT 1;
9191
CREATE MATERIALIZED VIEW ptif_test_matview AS SELECT 1;
92+
CREATE TABLE ptif_li_parent ();
93+
CREATE TABLE ptif_li_child () INHERITS (ptif_li_parent);
9294
SELECT * FROM pg_partition_tree('ptif_test_view');
9395
SELECT * FROM pg_partition_tree('ptif_test_matview');
96+
SELECT * FROM pg_partition_tree('ptif_li_parent');
97+
SELECT * FROM pg_partition_tree('ptif_li_child');
9498
SELECT pg_partition_root('ptif_test_view');
9599
SELECT pg_partition_root('ptif_test_matview');
100+
SELECT pg_partition_root('ptif_li_parent');
101+
SELECT pg_partition_root('ptif_li_child');
96102
DROP VIEW ptif_test_view;
97103
DROP MATERIALIZED VIEW ptif_test_matview;
104+
DROP TABLE ptif_li_parent, ptif_li_child;

0 commit comments

Comments
 (0)