|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.77 2000/07/03 23:58:32 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.78 2000/07/04 01:39:24 vadim Exp $ |
12 | 12 | * |
13 | 13 | * |
14 | 14 | * INTERFACE ROUTINES |
@@ -1125,6 +1125,7 @@ heap_fetch(Relation relation, |
1125 | 1125 |
|
1126 | 1126 | if (!ItemIdIsUsed(lp)) |
1127 | 1127 | { |
| 1128 | +LockBuffer(buffer,BUFFER_LOCK_UNLOCK); |
1128 | 1129 | ReleaseBuffer(buffer); |
1129 | 1130 | *userbuf=InvalidBuffer; |
1130 | 1131 | tuple->t_datamcxt=NULL; |
@@ -1331,17 +1332,17 @@ heap_insert(Relation relation, HeapTuple tup) |
1331 | 1332 | xlrec.mask=tup->t_data->t_infomask; |
1332 | 1333 |
|
1333 | 1334 | XLogRecPtrrecptr=XLogInsert(RM_HEAP_ID,XLOG_HEAP_INSERT, |
1334 | | -(char*)xlrec,sizeof(xlrec), |
1335 | | -(char*)tup->t_data+ offsetof(HeapTupleHeaderData,tbits), |
1336 | | -tup->t_len- offsetof(HeapTupleHeaderData,tbits)); |
| 1335 | +(char*)xlrec,SizeOfHeapInsert, |
| 1336 | +(char*)tup->t_data+ offsetof(HeapTupleHeaderData,t_bits), |
| 1337 | +tup->t_len- offsetof(HeapTupleHeaderData,t_bits)); |
1337 | 1338 |
|
1338 | 1339 | ((PageHeader)BufferGetPage(buffer))->pd_lsn=recptr; |
1339 | 1340 | ((PageHeader)BufferGetPage(buffer))->pd_sui=ThisStartUpID; |
1340 | 1341 | } |
1341 | 1342 | #endif |
1342 | 1343 |
|
1343 | | -WriteBuffer(buffer); |
1344 | 1344 | LockBuffer(buffer,BUFFER_LOCK_UNLOCK); |
| 1345 | +WriteBuffer(buffer); |
1345 | 1346 |
|
1346 | 1347 | if (IsSystemRelationName(RelationGetRelationName(relation))) |
1347 | 1348 | RelationMark4RollbackHeapTuple(relation,tup); |
@@ -1440,7 +1441,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) |
1440 | 1441 | xlrec.dtid.cid=GetCurrentCommandId(); |
1441 | 1442 | xlrec.dtid.tid=tp.t_self; |
1442 | 1443 | XLogRecPtrrecptr=XLogInsert(RM_HEAP_ID,XLOG_HEAP_DELETE, |
1443 | | -(char*)xlrec,sizeof(xlrec),NULL,0); |
| 1444 | +(char*)xlrec,SizeOfHeapDelete,NULL,0); |
1444 | 1445 |
|
1445 | 1446 | dp->pd_lsn=recptr; |
1446 | 1447 | dp->pd_sui=ThisStartUpID; |
@@ -1610,9 +1611,9 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, |
1610 | 1611 | xlrec.mask=newtup->t_data->t_infomask; |
1611 | 1612 |
|
1612 | 1613 | XLogRecPtrrecptr=XLogInsert(RM_HEAP_ID,XLOG_HEAP_UPDATE, |
1613 | | -(char*)xlrec,sizeof(xlrec), |
1614 | | -(char*)newtup->t_data+ offsetof(HeapTupleHeaderData,tbits), |
1615 | | -newtup->t_len- offsetof(HeapTupleHeaderData,tbits)); |
| 1614 | +(char*)xlrec,SizeOfHeapUpdate, |
| 1615 | +(char*)newtup->t_data+ offsetof(HeapTupleHeaderData,t_bits), |
| 1616 | +newtup->t_len- offsetof(HeapTupleHeaderData,t_bits)); |
1616 | 1617 |
|
1617 | 1618 | if (newbuf!=buffer) |
1618 | 1619 | { |
@@ -1907,3 +1908,43 @@ heap_restrpos(HeapScanDesc scan) |
1907 | 1908 | (ScanKey)NULL); |
1908 | 1909 | } |
1909 | 1910 | } |
| 1911 | + |
| 1912 | +#ifdefXLOG |
| 1913 | +voidheap_redo(XLogRecPtrlsn,XLogRecord*record) |
| 1914 | +{ |
| 1915 | +uint8info=record->xl_info& ~XLR_INFO_MASK; |
| 1916 | + |
| 1917 | +if (info==XLOG_HEAP_INSERT) |
| 1918 | +heap_xlog_insert(true,lsn,record); |
| 1919 | +elseif (info==XLOG_HEAP_DELETE) |
| 1920 | +heap_xlog_delete(true,lsn,record); |
| 1921 | +elseif (info==XLOG_HEAP_UPDATE) |
| 1922 | +heap_xlog_update(true,lsn,record); |
| 1923 | +elseif (info==XLOG_HEAP_MOVE) |
| 1924 | +heap_xlog_move(true,lsn,record); |
| 1925 | +else |
| 1926 | +elog(STOP,"heap_redo: unknown op code %u",info); |
| 1927 | +} |
| 1928 | + |
| 1929 | +voidheap_undo(XLogRecPtrlsn,XLogRecord*record) |
| 1930 | +{ |
| 1931 | +uint8info=record->xl_info& ~XLR_INFO_MASK; |
| 1932 | + |
| 1933 | +if (info==XLOG_HEAP_INSERT) |
| 1934 | +heap_xlog_insert(false,lsn,record); |
| 1935 | +elseif (info==XLOG_HEAP_DELETE) |
| 1936 | +heap_xlog_delete(false,lsn,record); |
| 1937 | +elseif (info==XLOG_HEAP_UPDATE) |
| 1938 | +heap_xlog_update(false,lsn,record); |
| 1939 | +elseif (info==XLOG_HEAP_MOVE) |
| 1940 | +heap_xlog_move(false,lsn,record); |
| 1941 | +else |
| 1942 | +elog(STOP,"heap_undo: unknown op code %u",info); |
| 1943 | +} |
| 1944 | + |
| 1945 | +voidheap_xlog_insert(boolredo,XLogRecPtrlsn,XLogRecord*record) |
| 1946 | +{ |
| 1947 | +xl_heap_insertxlrec=XLogRecGetData(record); |
| 1948 | +} |
| 1949 | + |
| 1950 | +#endif/* XLOG */ |