Skip to content

Commit 9575107

Browse files
committed
fix a bug related to the auto removal of the record from pathman_config on DROP COLUMN
1 parent 5d11c16 commit 9575107

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

expected/pathman_basic.out

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,8 @@ NOTICE: drop cascades to 7 other objects
16721672
/* Test automatic partition creation */
16731673
CREATE TABLE test.range_rel (
16741674
id SERIAL PRIMARY KEY,
1675-
dt TIMESTAMP NOT NULL);
1675+
dt TIMESTAMP NOT NULL,
1676+
data TEXT);
16761677
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '10 days'::INTERVAL, 1);
16771678
create_range_partitions
16781679
-------------------------
@@ -1692,9 +1693,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt = '2014-12-15';
16921693
(3 rows)
16931694

16941695
SELECT * FROM test.range_rel WHERE dt = '2014-12-15';
1695-
id | dt
1696-
-----+--------------------------
1697-
137 | Mon Dec 15 00:00:00 2014
1696+
id | dt | data
1697+
-----+--------------------------+------
1698+
137 | Mon Dec 15 00:00:00 2014 |
16981699
(1 row)
16991700

17001701
EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt = '2015-03-15';
@@ -1706,9 +1707,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt = '2015-03-15';
17061707
(3 rows)
17071708

17081709
SELECT * FROM test.range_rel WHERE dt = '2015-03-15';
1709-
id | dt
1710-
----+--------------------------
1711-
74 | Sun Mar 15 00:00:00 2015
1710+
id | dt | data
1711+
----+--------------------------+------
1712+
74 | Sun Mar 15 00:00:00 2015 |
17121713
(1 row)
17131714

17141715
SELECT pathman.set_auto('test.range_rel', false);
@@ -1726,6 +1727,17 @@ SELECT pathman.set_auto('test.range_rel', true);
17261727
(1 row)
17271728

17281729
INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
1730+
/*
1731+
* Test auto removing record from config on table DROP (but not on column drop
1732+
* as it used to be before version 1.2)
1733+
*/
1734+
ALTER TABLE test.range_rel DROP COLUMN data;
1735+
SELECT * FROM pathman.pathman_config;
1736+
partrel | attname | parttype | range_interval
1737+
----------------+---------+----------+----------------
1738+
test.range_rel | dt | 2 | @ 10 days
1739+
(1 row)
1740+
17291741
DROP TABLE test.range_rel CASCADE;
17301742
NOTICE: drop cascades to 20 other objects
17311743
SELECT * FROM pathman.pathman_config;

init.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ BEGIN
464464
SELECT array_agg(cfg.partrel) INTO relids
465465
FROM pg_event_trigger_dropped_objects() AS events
466466
JOIN @extschema@.pathman_config AS cfg ON cfg.partrel::oid = events.objid
467-
WHERE events.classid = pg_class_oid;
467+
WHERE events.classid = pg_class_oid AND events.objsubid = 0;
468468

469469
/* Cleanup pathman_config */
470470
DELETE FROM @extschema@.pathman_config WHERE partrel = ANY(relids);

sql/pathman_basic.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ DROP TABLE test.range_rel CASCADE;
480480
/* Test automatic partition creation */
481481
CREATE TABLE test.range_rel (
482482
id SERIAL PRIMARY KEY,
483-
dt TIMESTAMP NOT NULL);
483+
dt TIMESTAMP NOT NULL,
484+
data TEXT);
484485
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '10 days'::INTERVAL, 1);
485486
INSERT INTO test.range_rel (dt)
486487
SELECT generate_series('2015-01-01', '2015-04-30', '1 day'::interval);
@@ -498,6 +499,12 @@ INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
498499
SELECT pathman.set_auto('test.range_rel', true);
499500
INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
500501

502+
/*
503+
* Test auto removing record from config on table DROP (but not on column drop
504+
* as it used to be before version 1.2)
505+
*/
506+
ALTER TABLE test.range_rel DROP COLUMN data;
507+
SELECT * FROM pathman.pathman_config;
501508
DROP TABLE test.range_rel CASCADE;
502509
SELECT * FROM pathman.pathman_config;
503510

0 commit comments

Comments
 (0)