mirror of
https://github.com/postgres/postgres.git
synced 2026-05-07 17:29:43 -04:00
eb2e2eb4d4
Commit 28d534e2ae introduced reform_tuple() with a fast path that
returns the source tuple verbatim when no dropped columns require fixing
up. I (Álvaro) failed to realize that this broke handling of columns
with a 'missingval' defined: after a VACUUM FULL, CLUSTER, or REPACK
operation, the catalogued missingval is thrown away, so the tuples are
no longer correct.
Fix by forcing the rewrite when the tuple is shorter than the tuple
descriptor.
Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeoccU5CudrJpmSKZfKZ1gRMNY=5BxSC=JpHgkonzgcOw@mail.gmail.com
35 lines
1.5 KiB
SQL
35 lines
1.5 KiB
SQL
-- Test REPACK (CONCURRENTLY).
|
|
-- This test isn't strictly about logical decoding per se, but
|
|
-- REPACK (CONCURRENTLY) involves logical decoding and therefore requires
|
|
-- to be run under higher than minimal wal_level, so we can't have them in
|
|
-- the main regression test suite.
|
|
|
|
-- Ownership of partitions is checked
|
|
CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
|
|
CREATE INDEX ptnowner_i_idx ON ptnowner(i);
|
|
CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1);
|
|
CREATE ROLE regress_ptnowner;
|
|
CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
|
|
ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
|
|
SET SESSION AUTHORIZATION regress_ptnowner;
|
|
ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key;
|
|
REPACK (CONCURRENTLY) ptnowner1;
|
|
RESET SESSION AUTHORIZATION;
|
|
ALTER TABLE ptnowner OWNER TO regress_ptnowner;
|
|
CREATE TEMP TABLE ptnowner_oldnodes AS
|
|
SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree
|
|
JOIN pg_class AS c ON c.oid=tree.relid;
|
|
SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
|
|
JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
|
|
DROP TABLE ptnowner;
|
|
DROP ROLE regress_ptnowner;
|
|
|
|
-- Verify that REPACK (CONCURRENTLY) doesn't lose "attmissingval" columns
|
|
CREATE TABLE rpk_missing (id int PRIMARY KEY);
|
|
INSERT INTO rpk_missing SELECT generate_series(1, 3);
|
|
ALTER TABLE rpk_missing ADD COLUMN a int DEFAULT 42;
|
|
SELECT * FROM rpk_missing;
|
|
REPACK (CONCURRENTLY) rpk_missing;
|
|
SELECT * FROM rpk_missing;
|
|
DROP TABLE rpk_missing;
|