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

Commit1127f0e

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 parenta963283 commit1127f0e

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
@@ -1538,6 +1538,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
15381538
newIndexForm->indimmediate=oldIndexForm->indimmediate;
15391539
oldIndexForm->indimmediate= true;
15401540

1541+
/* Preserve indisreplident in the new index */
1542+
newIndexForm->indisreplident=oldIndexForm->indisreplident;
1543+
oldIndexForm->indisreplident= false;
1544+
15411545
/* Preserve indisclustered in the new index */
15421546
newIndexForm->indisclustered=oldIndexForm->indisclustered;
15431547

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

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

21432143
DROP TABLE concur_clustered;
2144+
-- Check that indisreplident updates are preserved.
2145+
CREATE TABLE concur_replident(i int NOT NULL);
2146+
CREATE UNIQUE INDEX concur_replident_i_idx ON concur_replident(i);
2147+
ALTER TABLE concur_replident REPLICA IDENTITY
2148+
USING INDEX concur_replident_i_idx;
2149+
SELECT indexrelid::regclass, indisreplident FROM pg_index
2150+
WHERE indrelid = 'concur_replident'::regclass;
2151+
indexrelid | indisreplident
2152+
------------------------+----------------
2153+
concur_replident_i_idx | t
2154+
(1 row)
2155+
2156+
REINDEX TABLE CONCURRENTLY concur_replident;
2157+
SELECT indexrelid::regclass, indisreplident FROM pg_index
2158+
WHERE indrelid = 'concur_replident'::regclass;
2159+
indexrelid | indisreplident
2160+
------------------------+----------------
2161+
concur_replident_i_idx | t
2162+
(1 row)
2163+
2164+
DROP TABLE concur_replident;
21442165
-- Partitions
21452166
-- Create some partitioned tables
21462167
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
@@ -866,6 +866,17 @@ REINDEX TABLE CONCURRENTLY concur_clustered;
866866
SELECT indexrelid::regclass, indisclusteredFROM pg_index
867867
WHERE indrelid='concur_clustered'::regclass;
868868
DROPTABLE concur_clustered;
869+
-- Check that indisreplident updates are preserved.
870+
CREATETABLEconcur_replident(iintNOT NULL);
871+
CREATEUNIQUE INDEXconcur_replident_i_idxON concur_replident(i);
872+
ALTERTABLE concur_replident REPLICA IDENTITY
873+
USING INDEX concur_replident_i_idx;
874+
SELECT indexrelid::regclass, indisreplidentFROM pg_index
875+
WHERE indrelid='concur_replident'::regclass;
876+
REINDEX TABLE CONCURRENTLY concur_replident;
877+
SELECT indexrelid::regclass, indisreplidentFROM pg_index
878+
WHERE indrelid='concur_replident'::regclass;
879+
DROPTABLE concur_replident;
869880

870881
-- Partitions
871882
-- Create some partitioned tables

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp