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

Commit493f726

Browse files
committed
Renumber SnapshotNow and the other special snapshot codes so that
((Snapshot) NULL) can no longer be confused with a valid snapshot,as per my recent suggestion. Define a macro InvalidSnapshot for 0.Use InvalidSnapshot instead of SnapshotAny as the do-nothing specialcase for heap_update and heap_delete crosschecks; this seems a littlecleaner even though the behavior is really the same.
1 parent9835944 commit493f726

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.173 2004/08/29 05:06:40 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.174 2004/09/11 18:28:32 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1262,7 +1262,7 @@ simple_heap_insert(Relation relation, HeapTuple tup)
12621262
*tid - TID of tuple to be deleted
12631263
*ctid - output parameter, used only for failure case (see below)
12641264
*cid - delete command ID to use in verifying tuple visibility
1265-
*crosscheck - if notSnapshotAny, also check tuple against this
1265+
*crosscheck - if notInvalidSnapshot, also check tuple against this
12661266
*wait - true if should wait for any conflicting update to commit/abort
12671267
*
12681268
* Normal, successful return value is HeapTupleMayBeUpdated, which
@@ -1274,7 +1274,8 @@ simple_heap_insert(Relation relation, HeapTuple tup)
12741274
*/
12751275
int
12761276
heap_delete(Relationrelation,ItemPointertid,
1277-
ItemPointerctid,CommandIdcid,Snapshotcrosscheck,boolwait)
1277+
ItemPointerctid,CommandIdcid,
1278+
Snapshotcrosscheck,boolwait)
12781279
{
12791280
ItemIdlp;
12801281
HeapTupleDatatp;
@@ -1339,7 +1340,7 @@ heap_delete(Relation relation, ItemPointer tid,
13391340
result=HeapTupleUpdated;
13401341
}
13411342

1342-
if (crosscheck!=SnapshotAny&&result==HeapTupleMayBeUpdated)
1343+
if (crosscheck!=InvalidSnapshot&&result==HeapTupleMayBeUpdated)
13431344
{
13441345
/* Perform additional check for serializable RI updates */
13451346
if (!HeapTupleSatisfiesSnapshot(tp.t_data,crosscheck))
@@ -1443,7 +1444,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
14431444

14441445
result=heap_delete(relation,tid,
14451446
&ctid,
1446-
GetCurrentCommandId(),SnapshotAny,
1447+
GetCurrentCommandId(),InvalidSnapshot,
14471448
true/* wait for commit */ );
14481449
switch (result)
14491450
{
@@ -1477,7 +1478,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
14771478
*newtup - newly constructed tuple data to store
14781479
*ctid - output parameter, used only for failure case (see below)
14791480
*cid - update command ID to use in verifying old tuple visibility
1480-
*crosscheck - if notSnapshotAny, also check old tuple against this
1481+
*crosscheck - if notInvalidSnapshot, also check old tuple against this
14811482
*wait - true if should wait for any conflicting update to commit/abort
14821483
*
14831484
* Normal, successful return value is HeapTupleMayBeUpdated, which
@@ -1491,7 +1492,8 @@ simple_heap_delete(Relation relation, ItemPointer tid)
14911492
*/
14921493
int
14931494
heap_update(Relationrelation,ItemPointerotid,HeapTuplenewtup,
1494-
ItemPointerctid,CommandIdcid,Snapshotcrosscheck,boolwait)
1495+
ItemPointerctid,CommandIdcid,
1496+
Snapshotcrosscheck,boolwait)
14951497
{
14961498
ItemIdlp;
14971499
HeapTupleDataoldtup;
@@ -1566,7 +1568,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15661568
result=HeapTupleUpdated;
15671569
}
15681570

1569-
if (crosscheck!=SnapshotAny&&result==HeapTupleMayBeUpdated)
1571+
if (crosscheck!=InvalidSnapshot&&result==HeapTupleMayBeUpdated)
15701572
{
15711573
/* Perform additional check for serializable RI updates */
15721574
if (!HeapTupleSatisfiesSnapshot(oldtup.t_data,crosscheck))
@@ -1804,7 +1806,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
18041806

18051807
result=heap_update(relation,otid,tup,
18061808
&ctid,
1807-
GetCurrentCommandId(),SnapshotAny,
1809+
GetCurrentCommandId(),InvalidSnapshot,
18081810
true/* wait for commit */ );
18091811
switch (result)
18101812
{

‎src/backend/commands/async.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.116 2004/09/06 23:32:54 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.117 2004/09/11 18:28:33 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -544,7 +544,7 @@ AtCommit_Notify(void)
544544
*/
545545
result=heap_update(lRel,&lTuple->t_self,rTuple,
546546
&ctid,
547-
GetCurrentCommandId(),SnapshotAny,
547+
GetCurrentCommandId(),InvalidSnapshot,
548548
false/* no wait for commit */ );
549549
switch (result)
550550
{

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.236 2004/08/29 05:06:42 momjian Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.237 2004/09/11 18:28:34 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -176,7 +176,7 @@ ExecutorStart(QueryDesc *queryDesc, bool useCurrentSnapshot, bool explainOnly)
176176
{
177177
/* normal query --- use query snapshot, no crosscheck */
178178
estate->es_snapshot=CopyQuerySnapshot();
179-
estate->es_crosscheck_snapshot=SnapshotAny;
179+
estate->es_crosscheck_snapshot=InvalidSnapshot;
180180
}
181181

182182
/*

‎src/backend/executor/execUtils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.114 2004/08/29 05:06:42 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.115 2004/09/11 18:28:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -179,7 +179,7 @@ CreateExecutorState(void)
179179
*/
180180
estate->es_direction=ForwardScanDirection;
181181
estate->es_snapshot=SnapshotNow;
182-
estate->es_crosscheck_snapshot=SnapshotAny;/* means no crosscheck */
182+
estate->es_crosscheck_snapshot=InvalidSnapshot;/* no crosscheck */
183183
estate->es_range_table=NIL;
184184

185185
estate->es_result_relations=NULL;

‎src/include/utils/tqual.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.50 2004/08/29 04:13:11 momjian Exp $
11+
* $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.51 2004/09/11 18:28:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -19,6 +19,20 @@
1919
#include"access/xact.h"
2020

2121

22+
/*
23+
* "Regular" snapshots are pointers to a SnapshotData structure.
24+
*
25+
* We also have some "special" snapshot values that have fixed meanings
26+
* and don't need any backing SnapshotData. These are encoded by small
27+
* integer values, which of course is a gross violation of ANSI C, but
28+
* it works fine on all known platforms.
29+
*
30+
* SnapshotDirty is an even more special case: its semantics are fixed,
31+
* but there is a backing SnapshotData struct for it. That struct is
32+
* actually used as *output* data from tqual.c, not input into it.
33+
* (But hey, SnapshotDirty ought to have a dirty implementation, no? ;-))
34+
*/
35+
2236
typedefstructSnapshotData
2337
{
2438
TransactionIdxmin;/* XID < xmin are visible to me */
@@ -32,10 +46,12 @@ typedef struct SnapshotData
3246

3347
typedefSnapshotData*Snapshot;
3448

35-
#defineSnapshotNow((Snapshot) 0x0)
36-
#defineSnapshotSelf((Snapshot) 0x1)
37-
#defineSnapshotAny((Snapshot) 0x2)
38-
#defineSnapshotToast((Snapshot) 0x3)
49+
/* Special snapshot values: */
50+
#defineInvalidSnapshot((Snapshot) 0x0)/* same as NULL */
51+
#defineSnapshotNow((Snapshot) 0x1)
52+
#defineSnapshotSelf((Snapshot) 0x2)
53+
#defineSnapshotAny((Snapshot) 0x3)
54+
#defineSnapshotToast((Snapshot) 0x4)
3955

4056
externDLLIMPORTSnapshotSnapshotDirty;
4157
externDLLIMPORTSnapshotQuerySnapshot;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp