mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix lost persistence setting during REINDEX INDEX
ReindexIndex() trusts a parser-built RangeVar with the persistence to
use for the new copy of the index; but the parser naturally does not
know what's the persistence of the original index. To find out the
correct persistence, grab it from relcache.
This bug was introduced by commit 85b506bbfc
, and therefore no
backpatch is necessary.
Bug reported by Thom Brown, analysis and patch by Michael Paquier; test
case provided by Fabrízio de Royes Mello.
This commit is contained in:
@ -208,6 +208,28 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
|
||||
);
|
||||
NOTICE: relation "test_tsvector" already exists, skipping
|
||||
CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK
|
||||
CREATE TEMPORARY TABLE unlogged2 (a int primary key); -- OK
|
||||
SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
|
||||
relname | relkind | relpersistence
|
||||
----------------+---------+----------------
|
||||
unlogged1 | r | u
|
||||
unlogged1_pkey | i | u
|
||||
unlogged2 | r | t
|
||||
unlogged2_pkey | i | t
|
||||
(4 rows)
|
||||
|
||||
REINDEX INDEX unlogged1_pkey;
|
||||
REINDEX INDEX unlogged2_pkey;
|
||||
SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
|
||||
relname | relkind | relpersistence
|
||||
----------------+---------+----------------
|
||||
unlogged1 | r | u
|
||||
unlogged1_pkey | i | u
|
||||
unlogged2 | r | t
|
||||
unlogged2_pkey | i | t
|
||||
(4 rows)
|
||||
|
||||
DROP TABLE unlogged2;
|
||||
INSERT INTO unlogged1 VALUES (42);
|
||||
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
|
||||
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
|
||||
|
@ -246,6 +246,12 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
|
||||
);
|
||||
|
||||
CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK
|
||||
CREATE TEMPORARY TABLE unlogged2 (a int primary key); -- OK
|
||||
SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
|
||||
REINDEX INDEX unlogged1_pkey;
|
||||
REINDEX INDEX unlogged2_pkey;
|
||||
SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname;
|
||||
DROP TABLE unlogged2;
|
||||
INSERT INTO unlogged1 VALUES (42);
|
||||
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
|
||||
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
|
||||
|
Reference in New Issue
Block a user