diff options
Diffstat (limited to 'src/backend/access/heap')
-rw-r--r-- | src/backend/access/heap/heapam.c | 34 | ||||
-rw-r--r-- | src/backend/access/heap/hio.c | 12 | ||||
-rw-r--r-- | src/backend/access/heap/tuptoaster.c | 4 |
3 files changed, 41 insertions, 9 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 1abb938fdf8..e9f69476283 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.143 2002/07/30 16:08:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.144 2002/08/06 02:36:33 tgl Exp $ * * * INTERFACE ROUTINES @@ -1155,6 +1155,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) pgstat_count_heap_insert(&relation->pgstat_info); /* XLOG stuff */ + if (!relation->rd_istemp) { xl_heap_insert xlrec; xl_heap_header xlhdr; @@ -1204,6 +1205,12 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) PageSetLSN(page, recptr); PageSetSUI(page, ThisStartUpID); } + else + { + /* No XLOG record, but still need to flag that XID exists on disk */ + MyXactMadeTempRelUpdate = true; + } + END_CRIT_SECTION(); LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1323,12 +1330,15 @@ l1: } START_CRIT_SECTION(); + /* store transaction information of xact deleting the tuple */ tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); HeapTupleHeaderSetXmax(tp.t_data, GetCurrentTransactionId()); HeapTupleHeaderSetCmax(tp.t_data, cid); + /* XLOG stuff */ + if (!relation->rd_istemp) { xl_heap_delete xlrec; XLogRecPtr recptr; @@ -1351,12 +1361,17 @@ l1: PageSetLSN(dp, recptr); PageSetSUI(dp, ThisStartUpID); } + else + { + /* No XLOG record, but still need to flag that XID exists on disk */ + MyXactMadeTempRelUpdate = true; + } + END_CRIT_SECTION(); LockBuffer(buffer, BUFFER_LOCK_UNLOCK); #ifdef TUPLE_TOASTER_ACTIVE - /* * If the relation has toastable attributes, we need to delete no * longer needed items there too. We have to do this before @@ -1659,6 +1674,7 @@ l2: oldtup.t_data->t_ctid = newtup->t_self; /* XLOG stuff */ + if (!relation->rd_istemp) { XLogRecPtr recptr = log_heap_update(relation, buffer, oldtup.t_self, newbuf, newtup, false); @@ -1671,6 +1687,11 @@ l2: PageSetLSN(BufferGetPage(buffer), recptr); PageSetSUI(BufferGetPage(buffer), ThisStartUpID); } + else + { + /* No XLOG record, but still need to flag that XID exists on disk */ + MyXactMadeTempRelUpdate = true; + } END_CRIT_SECTION(); @@ -1927,6 +1948,9 @@ log_heap_clean(Relation reln, Buffer buffer, char *unused, int unlen) XLogRecPtr recptr; XLogRecData rdata[3]; + /* Caller should not call me on a temp relation */ + Assert(!reln->rd_istemp); + xlrec.node = reln->rd_node; xlrec.block = BufferGetBlockNumber(buffer); rdata[0].buffer = InvalidBuffer; @@ -1978,6 +2002,9 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, Page page = BufferGetPage(newbuf); uint8 info = (move) ? XLOG_HEAP_MOVE : XLOG_HEAP_UPDATE; + /* Caller should not call me on a temp relation */ + Assert(!reln->rd_istemp); + xlrec.target.node = reln->rd_node; xlrec.target.tid = from; xlrec.newtid = newtup->t_self; @@ -2012,7 +2039,8 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, xid[0] = HeapTupleHeaderGetXmax(newtup->t_data); xid[1] = HeapTupleHeaderGetXmin(newtup->t_data); memcpy((char *) &xlhdr + hsize, - (char *) xid, 2 * sizeof(TransactionId)); + (char *) xid, + 2 * sizeof(TransactionId)); hsize += 2 * sizeof(TransactionId); } rdata[2].buffer = newbuf; diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 602ad748d9b..67eb4ad7e24 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.45 2002/06/20 20:29:25 momjian Exp $ + * $Id: hio.c,v 1.46 2002/08/06 02:36:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -102,6 +102,7 @@ RelationGetBufferForTuple(Relation relation, Size len, Size pageFreeSpace; BlockNumber targetBlock, otherBlock; + bool needLock; len = MAXALIGN(len); /* be conservative */ @@ -231,9 +232,12 @@ RelationGetBufferForTuple(Relation relation, Size len, * * We have to use a lock to ensure no one else is extending the rel at * the same time, else we will both try to initialize the same new - * page. + * page. We can skip locking for new or temp relations, however, + * since no one else could be accessing them. */ - if (!relation->rd_myxactonly) + needLock = !(relation->rd_isnew || relation->rd_istemp); + + if (needLock) LockPage(relation, 0, ExclusiveLock); /* @@ -249,7 +253,7 @@ RelationGetBufferForTuple(Relation relation, Size len, * Release the file-extension lock; it's now OK for someone else to * extend the relation some more. */ - if (!relation->rd_myxactonly) + if (needLock) UnlockPage(relation, 0, ExclusiveLock); /* diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index 2945cf3458c..1c09af2b308 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.33 2002/07/20 05:16:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.34 2002/08/06 02:36:33 tgl Exp $ * * * INTERFACE ROUTINES @@ -915,7 +915,7 @@ toast_save_datum(Relation rel, Datum value) */ idxres = index_insert(toastidx, t_values, t_nulls, &(toasttup->t_self), - toastrel, toastidx->rd_uniqueindex); + toastrel, toastidx->rd_index->indisunique); if (idxres == NULL) elog(ERROR, "Failed to insert index entry for TOAST tuple"); |