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

Commit0affc29

Browse files
committed
Make sure that t_ctid is reset to equal t_self in heap_delete and
heap_mark4update; this avoids situations where a deleted tuple mightlook like it is chained to something else. Also, cause all the WALredo routines to set t_ctid to equal t_self, rather than leaving itundefined as before. Make heap_xlog_clean set the page's LSN and SUIcorrectly. All per past discussions in pghackers, ranging back tolast December.
1 parent1e4c4f9 commit0affc29

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.144 2002/08/06 02:36:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.145 2002/08/13 20:11:03 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1150,6 +1150,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
11501150

11511151
/* NO ELOG(ERROR) from here till changes are logged */
11521152
START_CRIT_SECTION();
1153+
11531154
RelationPutHeapTuple(relation,buffer,tup);
11541155

11551156
pgstat_count_heap_insert(&relation->pgstat_info);
@@ -1336,6 +1337,8 @@ heap_delete(Relation relation, ItemPointer tid,
13361337
HEAP_XMAX_INVALID |HEAP_MARKED_FOR_UPDATE);
13371338
HeapTupleHeaderSetXmax(tp.t_data,GetCurrentTransactionId());
13381339
HeapTupleHeaderSetCmax(tp.t_data,cid);
1340+
/* Make sure there is no forward chain link in t_ctid */
1341+
tp.t_data->t_ctid=tp.t_self;
13391342

13401343
/* XLOG stuff */
13411344
if (!relation->rd_istemp)
@@ -1844,6 +1847,8 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
18441847
tuple->t_data->t_infomask |=HEAP_MARKED_FOR_UPDATE;
18451848
HeapTupleHeaderSetXmax(tuple->t_data,GetCurrentTransactionId());
18461849
HeapTupleHeaderSetCmax(tuple->t_data,cid);
1850+
/* Make sure there is no forward chain link in t_ctid */
1851+
tuple->t_data->t_ctid=*tid;
18471852

18481853
LockBuffer(*buffer,BUFFER_LOCK_UNLOCK);
18491854

@@ -2126,14 +2131,17 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record)
21262131
}
21272132

21282133
PageRepairFragmentation(page,NULL);
2134+
2135+
PageSetLSN(page,lsn);
2136+
PageSetSUI(page,ThisStartUpID);/* prev sui */
21292137
UnlockAndWriteBuffer(buffer);
21302138
}
21312139

21322140
staticvoid
21332141
heap_xlog_delete(boolredo,XLogRecPtrlsn,XLogRecord*record)
21342142
{
21352143
xl_heap_delete*xlrec= (xl_heap_delete*)XLogRecGetData(record);
2136-
Relationreln=XLogOpenRelation(redo,RM_HEAP_ID,xlrec->target.node);
2144+
Relationreln;
21372145
Bufferbuffer;
21382146
Pagepage;
21392147
OffsetNumberoffnum;
@@ -2143,6 +2151,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
21432151
if (redo&& (record->xl_info&XLR_BKP_BLOCK_1))
21442152
return;
21452153

2154+
reln=XLogOpenRelation(redo,RM_HEAP_ID,xlrec->target.node);
2155+
21462156
if (!RelationIsValid(reln))
21472157
return;
21482158

@@ -2186,6 +2196,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
21862196
HEAP_XMAX_INVALID |HEAP_MARKED_FOR_UPDATE);
21872197
HeapTupleHeaderSetXmax(htup,record->xl_xid);
21882198
HeapTupleHeaderSetCmax(htup,FirstCommandId);
2199+
/* Make sure there is no forward chain link in t_ctid */
2200+
htup->t_ctid=xlrec->target.tid;
21892201
PageSetLSN(page,lsn);
21902202
PageSetSUI(page,ThisStartUpID);
21912203
UnlockAndWriteBuffer(buffer);
@@ -2199,14 +2211,16 @@ static void
21992211
heap_xlog_insert(boolredo,XLogRecPtrlsn,XLogRecord*record)
22002212
{
22012213
xl_heap_insert*xlrec= (xl_heap_insert*)XLogRecGetData(record);
2202-
Relationreln=XLogOpenRelation(redo,RM_HEAP_ID,xlrec->target.node);
2214+
Relationreln;
22032215
Bufferbuffer;
22042216
Pagepage;
22052217
OffsetNumberoffnum;
22062218

22072219
if (redo&& (record->xl_info&XLR_BKP_BLOCK_1))
22082220
return;
22092221

2222+
reln=XLogOpenRelation(redo,RM_HEAP_ID,xlrec->target.node);
2223+
22102224
if (!RelationIsValid(reln))
22112225
return;
22122226

@@ -2263,6 +2277,7 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
22632277
HeapTupleHeaderSetCmin(htup,FirstCommandId);
22642278
HeapTupleHeaderSetXmaxInvalid(htup);
22652279
HeapTupleHeaderSetCmax(htup,FirstCommandId);
2280+
htup->t_ctid=xlrec->target.tid;
22662281
if (reln->rd_rel->relhasoids)
22672282
{
22682283
AssertTupleDescHasOid(reln->rd_att);
@@ -2352,6 +2367,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move)
23522367
~(HEAP_XMIN_COMMITTED |HEAP_XMIN_INVALID |HEAP_MOVED_IN);
23532368
htup->t_infomask |=HEAP_MOVED_OFF;
23542369
HeapTupleHeaderSetXvac(htup,record->xl_xid);
2370+
/* Make sure there is no forward chain link in t_ctid */
2371+
htup->t_ctid=xlrec->target.tid;
23552372
}
23562373
else
23572374
{
@@ -2363,6 +2380,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move)
23632380
HEAP_XMAX_INVALID |HEAP_MARKED_FOR_UPDATE);
23642381
HeapTupleHeaderSetXmax(htup,record->xl_xid);
23652382
HeapTupleHeaderSetCmax(htup,FirstCommandId);
2383+
/* Set forward chain link in t_ctid */
2384+
htup->t_ctid=xlrec->newtid;
23662385
}
23672386
if (samepage)
23682387
gotonewsame;
@@ -2465,6 +2484,8 @@ newsame:;
24652484
HeapTupleHeaderSetXmaxInvalid(htup);
24662485
HeapTupleHeaderSetCmax(htup,FirstCommandId);
24672486
}
2487+
/* Make sure there is no forward chain link in t_ctid */
2488+
htup->t_ctid=xlrec->newtid;
24682489

24692490
offnum=PageAddItem(page, (Item)htup,newlen,offnum,
24702491
LP_USED |OverwritePageMode);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp