Skip to content

Commit 32cd09a

Browse files
committed
Good Bye, Time Travel!
1 parent 6cc0a00 commit 32cd09a

File tree

36 files changed

+258
-1834
lines changed

36 files changed

+258
-1834
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.27 1997/09/24 17:44:24 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.28 1997/11/02 15:24:09 vadim Exp $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -115,7 +115,7 @@ DataFill(char *data,
115115
TupleDesc tupleDesc,
116116
Datum value[],
117117
char nulls[],
118-
char *infomask,
118+
uint16 *infomask,
119119
bits8 *bit)
120120
{
121121
bits8 *bitP = 0;
@@ -246,11 +246,6 @@ heap_attisnull(HeapTuple tup, int attnum)
246246
case MinCommandIdAttributeNumber:
247247
case MaxTransactionIdAttributeNumber:
248248
case MaxCommandIdAttributeNumber:
249-
case ChainItemPointerAttributeNumber:
250-
case AnchorItemPointerAttributeNumber:
251-
case MinAbsoluteTimeAttributeNumber:
252-
case MaxAbsoluteTimeAttributeNumber:
253-
case VersionTypeAttributeNumber:
254249
break;
255250

256251
case 0:
@@ -293,18 +288,6 @@ heap_sysattrlen(AttrNumber attno)
293288
return sizeof f->t_xmax;
294289
case MaxCommandIdAttributeNumber:
295290
return sizeof f->t_cmax;
296-
case ChainItemPointerAttributeNumber:
297-
return sizeof f->t_chain;
298-
case MinAbsoluteTimeAttributeNumber:
299-
return sizeof f->t_tmin;
300-
case MaxAbsoluteTimeAttributeNumber:
301-
return sizeof f->t_tmax;
302-
case VersionTypeAttributeNumber:
303-
return sizeof f->t_vtype;
304-
305-
case AnchorItemPointerAttributeNumber:
306-
elog(WARN, "heap_sysattrlen: field t_anchor does not exist!");
307-
return 0;
308291

309292
default:
310293
elog(WARN, "sysattrlen: System attribute number %d unknown.", attno);
@@ -343,21 +326,6 @@ heap_sysattrbyval(AttrNumber attno)
343326
case MaxCommandIdAttributeNumber:
344327
byval = true;
345328
break;
346-
case ChainItemPointerAttributeNumber:
347-
byval = false;
348-
break;
349-
case AnchorItemPointerAttributeNumber:
350-
byval = false;
351-
break;
352-
case MinAbsoluteTimeAttributeNumber:
353-
byval = true;
354-
break;
355-
case MaxAbsoluteTimeAttributeNumber:
356-
byval = true;
357-
break;
358-
case VersionTypeAttributeNumber:
359-
byval = true;
360-
break;
361329
default:
362330
byval = true;
363331
elog(WARN, "sysattrbyval: System attribute number %d unknown.",
@@ -377,7 +345,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
377345
{
378346
switch (attnum)
379347
{
380-
case SelfItemPointerAttributeNumber:
348+
case SelfItemPointerAttributeNumber:
381349
return ((Datum) &tup->t_ctid);
382350
case ObjectIdAttributeNumber:
383351
return ((Datum) (long) tup->t_oid);
@@ -389,38 +357,6 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
389357
return ((Datum) (long) tup->t_xmax);
390358
case MaxCommandIdAttributeNumber:
391359
return ((Datum) (long) tup->t_cmax);
392-
case ChainItemPointerAttributeNumber:
393-
return ((Datum) &tup->t_chain);
394-
case AnchorItemPointerAttributeNumber:
395-
elog(WARN, "heap_getsysattr: t_anchor does not exist!");
396-
break;
397-
398-
/*
399-
* For tmin and tmax, we need to do some extra work. These
400-
* don't get filled in until the vacuum cleaner runs (or we
401-
* manage to flush a page after setting the value correctly
402-
* below). If the vacuum cleaner hasn't run yet, then the
403-
* times stored in the tuple are wrong, and we need to look up
404-
* the commit time of the transaction. We cache this value in
405-
* the tuple to avoid doing the work more than once.
406-
*/
407-
408-
case MinAbsoluteTimeAttributeNumber:
409-
if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) &&
410-
TransactionIdDidCommit(tup->t_xmin))
411-
tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin);
412-
return ((Datum) (long) tup->t_tmin);
413-
case MaxAbsoluteTimeAttributeNumber:
414-
if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax))
415-
{
416-
if (TransactionIdDidCommit(tup->t_xmax))
417-
tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax);
418-
else
419-
tup->t_tmax = CURRENT_ABSTIME;
420-
}
421-
return ((Datum) (long) tup->t_tmax);
422-
case VersionTypeAttributeNumber:
423-
return ((Datum) (long) tup->t_vtype);
424360
default:
425361
elog(WARN, "heap_getsysattr: undefined attnum %d", attnum);
426362
}
@@ -858,8 +794,6 @@ heap_formtuple(TupleDesc tupleDescriptor,
858794
tuple->t_len = len;
859795
tuple->t_natts = numberOfAttributes;
860796
tuple->t_hoff = hoff;
861-
tuple->t_tmin = INVALID_ABSTIME;
862-
tuple->t_tmax = CURRENT_ABSTIME;
863797

864798
DataFill((char *) tuple + tuple->t_hoff,
865799
tupleDescriptor,
@@ -868,6 +802,8 @@ heap_formtuple(TupleDesc tupleDescriptor,
868802
&tuple->t_infomask,
869803
(hasnull ? tuple->t_bits : NULL));
870804

805+
tuple->t_infomask |= HEAP_XMAX_INVALID;
806+
871807
return (tuple);
872808
}
873809

@@ -970,9 +906,9 @@ heap_modifytuple(HeapTuple tuple,
970906
* ----------------
971907
*/
972908
infomask = newTuple->t_infomask;
973-
memmove((char *) &newTuple->t_ctid, /* XXX */
974-
(char *) &tuple->t_ctid,
975-
((char *) &tuple->t_hoff - (char *) &tuple->t_ctid)); /* XXX */
909+
memmove((char *) &newTuple->t_oid, /* XXX */
910+
(char *) &tuple->t_oid,
911+
((char *) &tuple->t_hoff - (char *) &tuple->t_oid)); /* XXX */
976912
newTuple->t_infomask = infomask;
977913
newTuple->t_natts = numberOfAttributes; /* fix t_natts just in
978914
* case */
@@ -1013,10 +949,11 @@ heap_addheader(uint32 natts, /* max domain index */
1013949
tup = (HeapTuple) tp;
1014950
MemSet((char *) tup, 0, len);
1015951

1016-
tup->t_len = (short) len; /* XXX */
952+
tup->t_len = len;
1017953
tp += tup->t_hoff = hoff;
1018954
tup->t_natts = natts;
1019955
tup->t_infomask = 0;
956+
tup->t_infomask |= HEAP_XMAX_INVALID;
1020957

1021958
memmove(tp, structure, structlen);
1022959

src/backend/access/common/indextuple.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.19 1997/09/18 20:19:37 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.20 1997/11/02 15:24:11 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -52,7 +52,7 @@ index_formtuple(TupleDesc tupleDescriptor,
5252
int i;
5353
unsigned short infomask = 0;
5454
bool hasnull = false;
55-
char tupmask = 0;
55+
uint16 tupmask = 0;
5656
int numberOfAttributes = tupleDescriptor->natts;
5757

5858
if (numberOfAttributes > MaxIndexAttributeNumber)

src/backend/access/heap/heapam.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.20 1997/09/18 14:19:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.21 1997/11/02 15:24:26 vadim Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1174,8 +1174,8 @@ heap_insert(Relation relation, HeapTuple tup)
11741174
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
11751175
tup->t_cmin = GetCurrentCommandId();
11761176
StoreInvalidTransactionId(&(tup->t_xmax));
1177-
tup->t_tmin = INVALID_ABSTIME;
1178-
tup->t_tmax = CURRENT_ABSTIME;
1177+
tup->t_infomask &= ~(HEAP_XACT_MASK);
1178+
tup->t_infomask |= HEAP_XMAX_INVALID;
11791179

11801180
doinsert(relation, tup);
11811181

@@ -1281,7 +1281,7 @@ heap_delete(Relation relation, ItemPointer tid)
12811281
*/
12821282
TransactionIdStore(GetCurrentTransactionId(), &(tp->t_xmax));
12831283
tp->t_cmax = GetCurrentCommandId();
1284-
ItemPointerSetInvalid(&tp->t_chain);
1284+
tp->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
12851285

12861286
/* ----------------
12871287
* invalidate caches
@@ -1410,9 +1410,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
14101410
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
14111411
tup->t_cmin = GetCurrentCommandId();
14121412
StoreInvalidTransactionId(&(tup->t_xmax));
1413-
tup->t_tmin = INVALID_ABSTIME;
1414-
tup->t_tmax = CURRENT_ABSTIME;
1415-
ItemPointerSetInvalid(&tup->t_chain);
1413+
tup->t_infomask &= ~(HEAP_XACT_MASK);
1414+
tup->t_infomask |= HEAP_XMAX_INVALID;
14161415

14171416
/* ----------------
14181417
* insert new item
@@ -1438,7 +1437,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
14381437
*/
14391438
TransactionIdStore(GetCurrentTransactionId(), &(tp->t_xmax));
14401439
tp->t_cmax = GetCurrentCommandId();
1441-
tp->t_chain = tup->t_ctid;
1440+
tp->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
14421441

14431442
/* ----------------
14441443
* invalidate caches

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy