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

Commit040a1df

Browse files
committed
Correctly set t_self for heap tuples in expand_tuple
Commit16828d5 incorrectly set an invalid pointer for t_self for heaptuples. This patch correctly copies it from the source tuple, andincludes a regression test that relies on it being set correctly.Backpatch to release 11.Fixes bug #15448 reported by Tillmann SchulzDiagnosis and test case by Amit Langote
1 parent5ef037c commit040a1df

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
856856
= (HeapTupleHeader) ((char*)*targetHeapTuple+HEAPTUPLESIZE);
857857
(*targetHeapTuple)->t_len=len;
858858
(*targetHeapTuple)->t_tableOid=sourceTuple->t_tableOid;
859-
ItemPointerSetInvalid(&((*targetHeapTuple)->t_self));
859+
(*targetHeapTuple)->t_self=sourceTuple->t_self;
860860

861861
targetTHeader->t_infomask=sourceTHeader->t_infomask;
862862
targetTHeader->t_hoff=hoff;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,17 @@ SELECT * FROM t;
727727
(1 row)
728728

729729
DROP TABLE t;
730+
-- make sure expanded tuple has correct self pointer
731+
-- it will be required by the RI tigger doing the cascading delete
732+
CREATE TABLE leader (a int PRIMARY KEY, b int);
733+
CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int);
734+
INSERT INTO leader VALUES (1, 1), (2, 2);
735+
ALTER TABLE leader ADD c int;
736+
ALTER TABLE leader DROP c;
737+
DELETE FROM leader;
730738
-- cleanup
739+
DROP TABLE follower;
740+
DROP TABLE leader;
731741
DROP FUNCTION test_trigger();
732742
DROP TABLE t1;
733743
DROP FUNCTION set(name);

‎src/test/regress/sql/fast_default.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,19 @@ UPDATE t SET y = 2;
471471
SELECT*FROM t;
472472
DROPTABLE t;
473473

474+
-- make sure expanded tuple has correct self pointer
475+
-- it will be required by the RI tigger doing the cascading delete
476+
477+
CREATETABLEleader (aintPRIMARY KEY, bint);
478+
CREATETABLEfollower (aintREFERENCES leaderON DELETE CASCADE, bint);
479+
INSERT INTO leaderVALUES (1,1), (2,2);
480+
ALTERTABLE leader ADD cint;
481+
ALTERTABLE leader DROP c;
482+
DELETEFROM leader;
483+
474484
-- cleanup
485+
DROPTABLE follower;
486+
DROPTABLE leader;
475487
DROPFUNCTION test_trigger();
476488
DROPTABLE t1;
477489
DROPFUNCTIONset(name);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp