Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7b78474

Browse files
committed
Make CLUSTER MVCC-safe. Heikki Linnakangas
1 parent 2fca2c0 commit 7b78474

File tree

10 files changed

+894
-97
lines changed

10 files changed

+894
-97
lines changed

src/backend/access/heap/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for access/heap
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/access/heap/Makefile,v 1.14 2007/01/20 17:16:10 petere Exp $
7+
# $PostgreSQL: pgsql/src/backend/access/heap/Makefile,v 1.15 2007/04/08 01:26:27 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/access/heap
1212
top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = heapam.o hio.o tuptoaster.o
15+
OBJS = heapam.o hio.o rewriteheap.o tuptoaster.o
1616

1717
all: SUBSYS.o
1818

src/backend/access/heap/heapam.c

Lines changed: 46 additions & 1 deletion
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.231 2007/04/03 04:14:26 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.232 2007/04/08 01:26:27 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -3299,6 +3299,51 @@ log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from,
32993299
return log_heap_update(reln, oldbuf, from, newbuf, newtup, true);
33003300
}
33013301

3302+
/*
3303+
* Perform XLogInsert of a HEAP_NEWPAGE record to WAL. Caller is responsible
3304+
* for writing the page to disk after calling this routine.
3305+
*
3306+
* Note: all current callers build pages in private memory and write them
3307+
* directly to smgr, rather than using bufmgr. Therefore there is no need
3308+
* to pass a buffer ID to XLogInsert, nor to perform MarkBufferDirty within
3309+
* the critical section.
3310+
*
3311+
* Note: the NEWPAGE log record is used for both heaps and indexes, so do
3312+
* not do anything that assumes we are touching a heap.
3313+
*/
3314+
XLogRecPtr
3315+
log_newpage(RelFileNode *rnode, BlockNumber blkno, Page page)
3316+
{
3317+
xl_heap_newpage xlrec;
3318+
XLogRecPtr recptr;
3319+
XLogRecData rdata[2];
3320+
3321+
/* NO ELOG(ERROR) from here till newpage op is logged */
3322+
START_CRIT_SECTION();
3323+
3324+
xlrec.node = *rnode;
3325+
xlrec.blkno = blkno;
3326+
3327+
rdata[0].data = (char *) &xlrec;
3328+
rdata[0].len = SizeOfHeapNewpage;
3329+
rdata[0].buffer = InvalidBuffer;
3330+
rdata[0].next = &(rdata[1]);
3331+
3332+
rdata[1].data = (char *) page;
3333+
rdata[1].len = BLCKSZ;
3334+
rdata[1].buffer = InvalidBuffer;
3335+
rdata[1].next = NULL;
3336+
3337+
recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);
3338+
3339+
PageSetLSN(page, recptr);
3340+
PageSetTLI(page, ThisTimeLineID);
3341+
3342+
END_CRIT_SECTION();
3343+
3344+
return recptr;
3345+
}
3346+
33023347
static void
33033348
heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record)
33043349
{

0 commit comments

Comments
 (0)