Skip to content

Commit c79aed4

Browse files
Restore lost amcheck TOAST test coverage.
Commit eba7753 fixed an amcheck false positive bug involving inconsistencies in TOAST input state between table and index. A test case was added that verified that such an inconsistency didn't result in a spurious corruption related error. Test coverage from the test was accidentally lost by commit 501e41d, which propagated ALTER TABLE ... SET STORAGE attstorage state to indexes. This broke the test because the test specifically relied on attstorage not being propagated. This artificially forced there to be index tuples whose datums were equivalent to the datums in the heap without the datums actually being bitwise equal. Fix this by updating pg_attribute directly instead. Commit 501e41d made similar changes to a test_decoding TOAST-related test case which made the same assumption, but overlooked the amcheck test case. Backpatch: 11-, just like commit eba7753 (and commit 501e41d).
1 parent 3d2376d commit c79aed4

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

contrib/amcheck/expected/check_btree.out

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,19 @@ SELECT bt_index_parent_check('delete_test_table_pkey', true);
155155
-- tuple. Bloom filter must fingerprint normalized index tuple representation.
156156
--
157157
CREATE TABLE toast_bug(buggy text);
158-
ALTER TABLE toast_bug ALTER COLUMN buggy SET STORAGE plain;
159-
-- pg_attribute entry for toasty.buggy will have plain storage:
160-
CREATE INDEX toasty ON toast_bug(buggy);
161-
-- Whereas pg_attribute entry for toast_bug.buggy now has extended storage:
162158
ALTER TABLE toast_bug ALTER COLUMN buggy SET STORAGE extended;
159+
CREATE INDEX toasty ON toast_bug(buggy);
160+
-- pg_attribute entry for toasty.buggy (the index) will have plain storage:
161+
UPDATE pg_attribute SET attstorage = 'p'
162+
WHERE attrelid = 'toasty'::regclass AND attname = 'buggy';
163+
-- Whereas pg_attribute entry for toast_bug.buggy (the table) still has extended storage:
164+
SELECT attstorage FROM pg_attribute
165+
WHERE attrelid = 'toast_bug'::regclass AND attname = 'buggy';
166+
attstorage
167+
------------
168+
x
169+
(1 row)
170+
163171
-- Insert compressible heap tuple (comfortably exceeds TOAST_TUPLE_THRESHOLD):
164172
INSERT INTO toast_bug SELECT repeat('a', 2200);
165173
-- Should not get false positive report of corruption:

contrib/amcheck/sql/check_btree.sql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ SELECT bt_index_parent_check('delete_test_table_pkey', true);
9999
-- tuple. Bloom filter must fingerprint normalized index tuple representation.
100100
--
101101
CREATE TABLE toast_bug(buggy text);
102-
ALTER TABLE toast_bug ALTER COLUMN buggy SET STORAGE plain;
103-
-- pg_attribute entry for toasty.buggy will have plain storage:
104-
CREATE INDEX toasty ON toast_bug(buggy);
105-
-- Whereas pg_attribute entry for toast_bug.buggy now has extended storage:
106102
ALTER TABLE toast_bug ALTER COLUMN buggy SET STORAGE extended;
103+
CREATE INDEX toasty ON toast_bug(buggy);
104+
105+
-- pg_attribute entry for toasty.buggy (the index) will have plain storage:
106+
UPDATE pg_attribute SET attstorage = 'p'
107+
WHERE attrelid = 'toasty'::regclass AND attname = 'buggy';
108+
109+
-- Whereas pg_attribute entry for toast_bug.buggy (the table) still has extended storage:
110+
SELECT attstorage FROM pg_attribute
111+
WHERE attrelid = 'toast_bug'::regclass AND attname = 'buggy';
112+
107113
-- Insert compressible heap tuple (comfortably exceeds TOAST_TUPLE_THRESHOLD):
108114
INSERT INTO toast_bug SELECT repeat('a', 2200);
109115
-- Should not get false positive report of corruption:

0 commit comments

Comments
 (0)