@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $ Header : / cvsroot / pgsql / src / backend / access / heap / heapam . c , v 1.141 2002 / 07 / 02 05 : 48 : 44 momjian Exp $
* $ Header : / cvsroot / pgsql / src / backend / access / heap / heapam . c , v 1.142 2002 / 07 / 20 05 : 16 : 56 momjian Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
@ -1116,10 +1116,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
* to support a persistent object store ( objects need to contain
* to support a persistent object store ( objects need to contain
* pointers to one another ) .
* pointers to one another ) .
*/
*/
if ( ! OidIsValid ( tup - > t_data - > t_oid ) )
AssertTupleDescHasOid ( relation - > rd_att ) ;
tup - > t_data - > t_oid = newoid ( ) ;
if ( ! OidIsValid ( HeapTupleGetOid ( tup ) ) )
HeapTupleSetOid ( tup , newoid ( ) ) ;
else
else
CheckMaxObjectId ( tup - > t_data - > t_oid ) ;
CheckMaxObjectId ( HeapTupleGetOid ( tup ) ) ;
}
}
HeapTupleHeaderSetXmin ( tup - > t_data , GetCurrentTransactionId ( ) ) ;
HeapTupleHeaderSetXmin ( tup - > t_data , GetCurrentTransactionId ( ) ) ;
@ -1166,7 +1167,13 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
rdata [ 0 ] . len = SizeOfHeapInsert ;
rdata [ 0 ] . len = SizeOfHeapInsert ;
rdata [ 0 ] . next = & ( rdata [ 1 ] ) ;
rdata [ 0 ] . next = & ( rdata [ 1 ] ) ;
xlhdr . t_oid = tup - > t_data - > t_oid ;
if ( relation - > rd_rel - > relhasoids )
{
AssertTupleDescHasOid ( relation - > rd_att ) ;
xlhdr . t_oid = HeapTupleGetOid ( tup ) ;
}
else
xlhdr . t_oid = InvalidOid ;
xlhdr . t_natts = tup - > t_data - > t_natts ;
xlhdr . t_natts = tup - > t_data - > t_natts ;
xlhdr . t_hoff = tup - > t_data - > t_hoff ;
xlhdr . t_hoff = tup - > t_data - > t_hoff ;
xlhdr . mask = tup - > t_data - > t_infomask ;
xlhdr . mask = tup - > t_data - > t_infomask ;
@ -1176,6 +1183,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
rdata [ 1 ] . next = & ( rdata [ 2 ] ) ;
rdata [ 1 ] . next = & ( rdata [ 2 ] ) ;
rdata [ 2 ] . buffer = buffer ;
rdata [ 2 ] . buffer = buffer ;
/* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
rdata [ 2 ] . data = ( char * ) tup - > t_data + offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 2 ] . data = ( char * ) tup - > t_data + offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 2 ] . len = tup - > t_len - offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 2 ] . len = tup - > t_len - offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 2 ] . next = NULL ;
rdata [ 2 ] . next = NULL ;
@ -1206,7 +1214,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
*/
*/
CacheInvalidateHeapTuple ( relation , tup ) ;
CacheInvalidateHeapTuple ( relation , tup ) ;
return tup - > t_data - > t_oid ;
if ( ! relation - > rd_rel - > relhasoids )
return InvalidOid ;
AssertTupleDescHasOid ( relation - > rd_att ) ;
return HeapTupleGetOid ( tup ) ;
}
}
/*
/*
@ -1499,7 +1511,11 @@ l2:
}
}
/* Fill in OID and transaction status data for newtup */
/* Fill in OID and transaction status data for newtup */
newtup - > t_data - > t_oid = oldtup . t_data - > t_oid ;
if ( relation - > rd_rel - > relhasoids )
{
AssertTupleDescHasOid ( relation - > rd_att ) ;
HeapTupleSetOid ( newtup , HeapTupleGetOid ( & oldtup ) ) ;
}
newtup - > t_data - > t_infomask & = ~ ( HEAP_XACT_MASK ) ;
newtup - > t_data - > t_infomask & = ~ ( HEAP_XACT_MASK ) ;
newtup - > t_data - > t_infomask | = ( HEAP_XMAX_INVALID | HEAP_UPDATED ) ;
newtup - > t_data - > t_infomask | = ( HEAP_XMAX_INVALID | HEAP_UPDATED ) ;
HeapTupleHeaderSetXmin ( newtup - > t_data , GetCurrentTransactionId ( ) ) ;
HeapTupleHeaderSetXmin ( newtup - > t_data , GetCurrentTransactionId ( ) ) ;
@ -1972,24 +1988,28 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
rdata [ 1 ] . len = 0 ;
rdata [ 1 ] . len = 0 ;
rdata [ 1 ] . next = & ( rdata [ 2 ] ) ;
rdata [ 1 ] . next = & ( rdata [ 2 ] ) ;
xlhdr . hdr . t_oid = newtup - > t_data - > t_oid ;
if ( reln - > rd_rel - > relhasoids )
{
AssertTupleDescHasOid ( reln - > rd_att ) ;
xlhdr . hdr . t_oid = HeapTupleGetOid ( newtup ) ;
}
else
xlhdr . hdr . t_oid = InvalidOid ;
xlhdr . hdr . t_natts = newtup - > t_data - > t_natts ;
xlhdr . hdr . t_natts = newtup - > t_data - > t_natts ;
xlhdr . hdr . t_hoff = newtup - > t_data - > t_hoff ;
xlhdr . hdr . t_hoff = newtup - > t_data - > t_hoff ;
xlhdr . hdr . mask = newtup - > t_data - > t_infomask ;
xlhdr . hdr . mask = newtup - > t_data - > t_infomask ;
if ( move ) /* remember xmin & xmax */
if ( move ) /* remember xmin & xmax */
{
{
TransactionId xmax ;
TransactionId xid [ 2 ] ; /* xmax, xmin */
TransactionId xmin ;
if ( newtup - > t_data - > t_infomask & HEAP_XMAX_INVALID | |
if ( newtup - > t_data - > t_infomask & ( HEAP_XMAX_INVALID |
newtup - > t_data - > t_infomask & HEAP_MARKED_FOR_UPDATE )
HEAP_MARKED_FOR_UPDATE ) )
xmax = InvalidTransactionId ;
xid [ 0 ] = InvalidTransactionId ;
else
else
xmax = HeapTupleHeaderGetXmax ( newtup - > t_data ) ;
xid [ 0 ] = HeapTupleHeaderGetXmax ( newtup - > t_data ) ;
xmin = HeapTupleHeaderGetXmin ( newtup - > t_data ) ;
xid [ 1 ] = HeapTupleHeaderGetXmin ( newtup - > t_data ) ;
memcpy ( ( char * ) & xlhdr + hsize , & xmax , sizeof ( TransactionId ) ) ;
memcpy ( ( char * ) & xlhdr + hsize ,
memcpy ( ( char * ) & xlhdr + hsize + sizeof ( TransactionId ) ,
( char * ) xid , 2 * sizeof ( TransactionId ) ) ;
& xmin , sizeof ( TransactionId ) ) ;
hsize + = 2 * sizeof ( TransactionId ) ;
hsize + = 2 * sizeof ( TransactionId ) ;
}
}
rdata [ 2 ] . buffer = newbuf ;
rdata [ 2 ] . buffer = newbuf ;
@ -1998,6 +2018,7 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
rdata [ 2 ] . next = & ( rdata [ 3 ] ) ;
rdata [ 2 ] . next = & ( rdata [ 3 ] ) ;
rdata [ 3 ] . buffer = newbuf ;
rdata [ 3 ] . buffer = newbuf ;
/* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
rdata [ 3 ] . data = ( char * ) newtup - > t_data + offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 3 ] . data = ( char * ) newtup - > t_data + offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 3 ] . len = newtup - > t_len - offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 3 ] . len = newtup - > t_len - offsetof ( HeapTupleHeaderData , t_bits ) ;
rdata [ 3 ] . next = NULL ;
rdata [ 3 ] . next = NULL ;
@ -2193,12 +2214,13 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
memcpy ( ( char * ) & xlhdr ,
memcpy ( ( char * ) & xlhdr ,
( char * ) xlrec + SizeOfHeapInsert ,
( char * ) xlrec + SizeOfHeapInsert ,
SizeOfHeapHeader ) ;
SizeOfHeapHeader ) ;
htup = & tbuf . hdr ;
MemSet ( ( char * ) htup , 0 , sizeof ( HeapTupleHeaderData ) ) ;
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
memcpy ( ( char * ) & tbuf + offsetof ( HeapTupleHeaderData , t_bits ) ,
memcpy ( ( char * ) & tbuf + offsetof ( HeapTupleHeaderData , t_bits ) ,
( char * ) xlrec + SizeOfHeapInsert + SizeOfHeapHeader ,
( char * ) xlrec + SizeOfHeapInsert + SizeOfHeapHeader ,
newlen ) ;
newlen ) ;
newlen + = offsetof ( HeapTupleHeaderData , t_bits ) ;
newlen + = offsetof ( HeapTupleHeaderData , t_bits ) ;
htup = & tbuf . hdr ;
htup - > t_oid = xlhdr . t_oid ;
htup - > t_natts = xlhdr . t_natts ;
htup - > t_natts = xlhdr . t_natts ;
htup - > t_hoff = xlhdr . t_hoff ;
htup - > t_hoff = xlhdr . t_hoff ;
htup - > t_infomask = HEAP_XMAX_INVALID | xlhdr . mask ;
htup - > t_infomask = HEAP_XMAX_INVALID | xlhdr . mask ;
@ -2206,6 +2228,11 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
HeapTupleHeaderSetCmin ( htup , FirstCommandId ) ;
HeapTupleHeaderSetCmin ( htup , FirstCommandId ) ;
HeapTupleHeaderSetXmaxInvalid ( htup ) ;
HeapTupleHeaderSetXmaxInvalid ( htup ) ;
HeapTupleHeaderSetCmax ( htup , FirstCommandId ) ;
HeapTupleHeaderSetCmax ( htup , FirstCommandId ) ;
if ( reln - > rd_rel - > relhasoids )
{
AssertTupleDescHasOid ( reln - > rd_att ) ;
HeapTupleHeaderSetOid ( htup , xlhdr . t_oid ) ;
}
offnum = PageAddItem ( page , ( Item ) htup , newlen , offnum ,
offnum = PageAddItem ( page , ( Item ) htup , newlen , offnum ,
LP_USED | OverwritePageMode ) ;
LP_USED | OverwritePageMode ) ;
@ -2362,28 +2389,33 @@ newsame:;
memcpy ( ( char * ) & xlhdr ,
memcpy ( ( char * ) & xlhdr ,
( char * ) xlrec + SizeOfHeapUpdate ,
( char * ) xlrec + SizeOfHeapUpdate ,
SizeOfHeapHeader ) ;
SizeOfHeapHeader ) ;
htup = & tbuf . hdr ;
MemSet ( ( char * ) htup , 0 , sizeof ( HeapTupleHeaderData ) ) ;
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
memcpy ( ( char * ) & tbuf + offsetof ( HeapTupleHeaderData , t_bits ) ,
memcpy ( ( char * ) & tbuf + offsetof ( HeapTupleHeaderData , t_bits ) ,
( char * ) xlrec + hsize ,
( char * ) xlrec + hsize ,
newlen ) ;
newlen ) ;
newlen + = offsetof ( HeapTupleHeaderData , t_bits ) ;
newlen + = offsetof ( HeapTupleHeaderData , t_bits ) ;
htup = & tbuf . hdr ;
htup - > t_oid = xlhdr . t_oid ;
htup - > t_natts = xlhdr . t_natts ;
htup - > t_natts = xlhdr . t_natts ;
htup - > t_hoff = xlhdr . t_hoff ;
htup - > t_hoff = xlhdr . t_hoff ;
if ( reln - > rd_rel - > relhasoids )
{
AssertTupleDescHasOid ( reln - > rd_att ) ;
HeapTupleHeaderSetOid ( htup , xlhdr . t_oid ) ;
}
if ( move )
if ( move )
{
{
TransactionId xmax ;
TransactionId xid [ 2 ] ; /* xmax, xmin */
TransactionId xmin ;
hsize = SizeOfHeapUpdate + SizeOfHeapHeader ;
hsize = SizeOfHeapUpdate + SizeOfHeapHeader ;
memcpy ( & xmax , ( char * ) xlrec + hsize , sizeof ( TransactionId ) ) ;
memcpy ( ( char * ) xid ,
memcpy ( & xmin , ( char * ) xlrec + hsize + sizeof ( TransactionId ) , sizeof ( TransactionId ) ) ;
( char * ) xlrec + hsize , 2 * sizeof ( TransactionId ) ) ;
htup - > t_infomask = xlhdr . mask ;
htup - > t_infomask = xlhdr . mask ;
htup - > t_infomask & = ~ ( HEAP_XMIN_COMMITTED |
htup - > t_infomask & = ~ ( HEAP_XMIN_COMMITTED |
HEAP_XMIN_INVALID | HEAP_MOVED_OFF ) ;
HEAP_XMIN_INVALID | HEAP_MOVED_OFF ) ;
htup - > t_infomask | = HEAP_MOVED_IN ;
htup - > t_infomask | = HEAP_MOVED_IN ;
HeapTupleHeaderSetXmin ( htup , xmin ) ;
HeapTupleHeaderSetXmin ( htup , xid [ 1 ] ) ;
HeapTupleHeaderSetXmax ( htup , xmax ) ;
HeapTupleHeaderSetXmax ( htup , xid [ 0 ] ) ;
HeapTupleHeaderSetXvac ( htup , record - > xl_xid ) ;
HeapTupleHeaderSetXvac ( htup , record - > xl_xid ) ;
}
}
else
else