|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *
|
14 | 14 | * INTERFACE ROUTINES
|
@@ -3299,6 +3299,51 @@ log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from,
|
3299 | 3299 | returnlog_heap_update(reln,oldbuf,from,newbuf,newtup, true);
|
3300 | 3300 | }
|
3301 | 3301 |
|
| 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,BlockNumberblkno,Pagepage) |
| 3316 | +{ |
| 3317 | +xl_heap_newpagexlrec; |
| 3318 | +XLogRecPtrrecptr; |
| 3319 | +XLogRecDatardata[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 | +returnrecptr; |
| 3345 | +} |
| 3346 | + |
3302 | 3347 | staticvoid
|
3303 | 3348 | heap_xlog_clean(XLogRecPtrlsn,XLogRecord*record)
|
3304 | 3349 | {
|
|