Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e577c9

Browse files
committed
Remove assertion for ALTER TABLE .. DETACH PARTITION CONCURRENTLY
One code path related to this flavor of ALTER TABLE was checking thatthe relation to detach has to be a normal table or a partitioned table,which would fail if using the command with a different relation kind.Views, sequences and materialized views cannot be part of a partitiontree, so these would cause the command to fail anyway, but the assertionwas triggered. Foreign tables can be part of a partition tree, andagain the assertion would have failed. The simplest solution is just toremove this assertion, so as we get the same failure as thenon-concurrent code path.While on it, add a regression test in postgres_fdw for the concurrentpartition detach of a foreign table, as per a suggestion from AlexanderLakhin.Issue introduced in 71f4c8c.Reported-by: Alexander LakhinAuthor: Michael Paquier, Alexander LakhinReviewed-by: Peter Eisentraut, Kyotaro HoriguchiDiscussion:https://postgr.es/m/17339-a9e09aaf38a3457a@postgresql.orgBackpatch-through: 14
1 parentcc8b257 commit2e577c9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6485,6 +6485,9 @@ CREATE FOREIGN TABLE foreign_tbl (a int, b int)
64856485
SERVER loopback OPTIONS (table_name 'child_tbl');
64866486
CREATE TABLE parent_tbl (a int, b int) PARTITION BY RANGE(a);
64876487
ALTER TABLE parent_tbl ATTACH PARTITION foreign_tbl FOR VALUES FROM (0) TO (100);
6488+
-- Detach and re-attach once, to stress the concurrent detach case.
6489+
ALTER TABLE parent_tbl DETACH PARTITION foreign_tbl CONCURRENTLY;
6490+
ALTER TABLE parent_tbl ATTACH PARTITION foreign_tbl FOR VALUES FROM (0) TO (100);
64886491
CREATE VIEW rw_view AS SELECT * FROM parent_tbl
64896492
WHERE a < b WITH CHECK OPTION;
64906493
\d+ rw_view

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,9 @@ CREATE FOREIGN TABLE foreign_tbl (a int, b int)
14901490

14911491
CREATETABLEparent_tbl (aint, bint) PARTITION BY RANGE(a);
14921492
ALTERTABLE parent_tbl ATTACH PARTITION foreign_tbl FORVALUESFROM (0) TO (100);
1493+
-- Detach and re-attach once, to stress the concurrent detach case.
1494+
ALTERTABLE parent_tbl DETACH PARTITION foreign_tbl CONCURRENTLY;
1495+
ALTERTABLE parent_tbl ATTACH PARTITION foreign_tbl FORVALUESFROM (0) TO (100);
14931496

14941497
CREATEVIEWrw_viewASSELECT*FROM parent_tbl
14951498
WHERE a< b WITHCHECK OPTION;

‎src/backend/commands/tablecmds.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15013,8 +15013,6 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel)
1501315013
HeapTupleinheritsTuple;
1501415014
boolfound = false;
1501515015

15016-
Assert(child_rel->rd_rel->relkind == RELKIND_RELATION ||
15017-
child_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
1501815016
Assert(parent_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
1501915017

1502015018
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp