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

Commit75f1479

Browse files
committed
Preserve pg_index.indisreplident across REINDEX CONCURRENTLY
If the flag value is lost, logical decoding would work the same way asREPLICA IDENTITY NOTHING, meaning that no old tuple values would beincluded in the changes anymore produced by logical decoding.Author: Michael PaquierReviewed-by: Euler TaveiraDiscussion:https://postgr.es/m/20200603065340.GK89559@paquier.xyzBackpatch-through: 12
1 parenta958b07 commit75f1479

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

‎src/backend/catalog/index.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
15271527
newIndexForm->indimmediate=oldIndexForm->indimmediate;
15281528
oldIndexForm->indimmediate= true;
15291529

1530+
/* Preserve indisreplident in the new index */
1531+
newIndexForm->indisreplident=oldIndexForm->indisreplident;
1532+
oldIndexForm->indisreplident= false;
1533+
15301534
/* Preserve indisclustered in the new index */
15311535
newIndexForm->indisclustered=oldIndexForm->indisclustered;
15321536

‎src/test/regress/expected/create_index.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,27 @@ SELECT indexrelid::regclass, indisclustered FROM pg_index
21282128
(1 row)
21292129

21302130
DROP TABLE concur_clustered;
2131+
-- Check that indisreplident updates are preserved.
2132+
CREATE TABLE concur_replident(i int NOT NULL);
2133+
CREATE UNIQUE INDEX concur_replident_i_idx ON concur_replident(i);
2134+
ALTER TABLE concur_replident REPLICA IDENTITY
2135+
USING INDEX concur_replident_i_idx;
2136+
SELECT indexrelid::regclass, indisreplident FROM pg_index
2137+
WHERE indrelid = 'concur_replident'::regclass;
2138+
indexrelid | indisreplident
2139+
------------------------+----------------
2140+
concur_replident_i_idx | t
2141+
(1 row)
2142+
2143+
REINDEX TABLE CONCURRENTLY concur_replident;
2144+
SELECT indexrelid::regclass, indisreplident FROM pg_index
2145+
WHERE indrelid = 'concur_replident'::regclass;
2146+
indexrelid | indisreplident
2147+
------------------------+----------------
2148+
concur_replident_i_idx | t
2149+
(1 row)
2150+
2151+
DROP TABLE concur_replident;
21312152
-- Partitions
21322153
-- Create some partitioned tables
21332154
CREATE TABLE concur_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1);

‎src/test/regress/sql/create_index.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,17 @@ REINDEX TABLE CONCURRENTLY concur_clustered;
860860
SELECT indexrelid::regclass, indisclusteredFROM pg_index
861861
WHERE indrelid='concur_clustered'::regclass;
862862
DROPTABLE concur_clustered;
863+
-- Check that indisreplident updates are preserved.
864+
CREATETABLEconcur_replident(iintNOT NULL);
865+
CREATEUNIQUE INDEXconcur_replident_i_idxON concur_replident(i);
866+
ALTERTABLE concur_replident REPLICA IDENTITY
867+
USING INDEX concur_replident_i_idx;
868+
SELECT indexrelid::regclass, indisreplidentFROM pg_index
869+
WHERE indrelid='concur_replident'::regclass;
870+
REINDEX TABLE CONCURRENTLY concur_replident;
871+
SELECT indexrelid::regclass, indisreplidentFROM pg_index
872+
WHERE indrelid='concur_replident'::regclass;
873+
DROPTABLE concur_replident;
863874

864875
-- Partitions
865876
-- Create some partitioned tables

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp