mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Correctly set t_self for heap tuples in expand_tuple
Commit 16828d5c0 incorrectly set an invalid pointer for t_self for heap tuples. This patch correctly copies it from the source tuple, and includes a regression test that relies on it being set correctly. Backpatch to release 11. Fixes bug #15448 reported by Tillmann Schulz Diagnosis and test case by Amit Langote
This commit is contained in:
parent
374fe86a8f
commit
372102b81d
@ -893,7 +893,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
|
|||||||
= (HeapTupleHeader) ((char *) *targetHeapTuple + HEAPTUPLESIZE);
|
= (HeapTupleHeader) ((char *) *targetHeapTuple + HEAPTUPLESIZE);
|
||||||
(*targetHeapTuple)->t_len = len;
|
(*targetHeapTuple)->t_len = len;
|
||||||
(*targetHeapTuple)->t_tableOid = sourceTuple->t_tableOid;
|
(*targetHeapTuple)->t_tableOid = sourceTuple->t_tableOid;
|
||||||
ItemPointerSetInvalid(&((*targetHeapTuple)->t_self));
|
(*targetHeapTuple)->t_self = sourceTuple->t_self;
|
||||||
|
|
||||||
targetTHeader->t_infomask = sourceTHeader->t_infomask;
|
targetTHeader->t_infomask = sourceTHeader->t_infomask;
|
||||||
targetTHeader->t_hoff = hoff;
|
targetTHeader->t_hoff = hoff;
|
||||||
|
@ -727,7 +727,17 @@ SELECT * FROM t;
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
-- make sure expanded tuple has correct self pointer
|
||||||
|
-- it will be required by the RI tigger doing the cascading delete
|
||||||
|
CREATE TABLE leader (a int PRIMARY KEY, b int);
|
||||||
|
CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int);
|
||||||
|
INSERT INTO leader VALUES (1, 1), (2, 2);
|
||||||
|
ALTER TABLE leader ADD c int;
|
||||||
|
ALTER TABLE leader DROP c;
|
||||||
|
DELETE FROM leader;
|
||||||
-- cleanup
|
-- cleanup
|
||||||
|
DROP TABLE follower;
|
||||||
|
DROP TABLE leader;
|
||||||
DROP FUNCTION test_trigger();
|
DROP FUNCTION test_trigger();
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP FUNCTION set(name);
|
DROP FUNCTION set(name);
|
||||||
|
@ -471,7 +471,19 @@ UPDATE t SET y = 2;
|
|||||||
SELECT * FROM t;
|
SELECT * FROM t;
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
|
||||||
|
-- make sure expanded tuple has correct self pointer
|
||||||
|
-- it will be required by the RI tigger doing the cascading delete
|
||||||
|
|
||||||
|
CREATE TABLE leader (a int PRIMARY KEY, b int);
|
||||||
|
CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int);
|
||||||
|
INSERT INTO leader VALUES (1, 1), (2, 2);
|
||||||
|
ALTER TABLE leader ADD c int;
|
||||||
|
ALTER TABLE leader DROP c;
|
||||||
|
DELETE FROM leader;
|
||||||
|
|
||||||
-- cleanup
|
-- cleanup
|
||||||
|
DROP TABLE follower;
|
||||||
|
DROP TABLE leader;
|
||||||
DROP FUNCTION test_trigger();
|
DROP FUNCTION test_trigger();
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP FUNCTION set(name);
|
DROP FUNCTION set(name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user