diff options
-rw-r--r-- | src/backend/access/heap/heapam.c | 14 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 13 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index d6a04122cfc..d631a95de68 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.222.2.3 2008/12/16 16:26:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.222.2.4 2010/07/29 16:15:18 rhaas Exp $ * * * INTERFACE ROUTINES @@ -3393,8 +3393,16 @@ heap_xlog_newpage(XLogRecPtr lsn, XLogRecord *record) Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ); memcpy(page, (char *) xlrec + SizeOfHeapNewpage, BLCKSZ); - PageSetLSN(page, lsn); - PageSetTLI(page, ThisTimeLineID); + /* + * The page may be uninitialized. If so, we can't set the LSN + * and TLI because that would corrupt the page. + */ + if (!PageIsNew(page)) + { + PageSetLSN(page, lsn); + PageSetTLI(page, ThisTimeLineID); + } + MarkBufferDirty(buffer); UnlockReleaseBuffer(buffer); } diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 01255dc6b1f..ec9696e6bbe 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.206.2.9 2010/07/01 14:11:23 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.206.2.10 2010/07/29 16:15:18 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -6151,8 +6151,15 @@ copy_relation_data(Relation rel, SMgrRelation dst) recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata); - PageSetLSN(page, recptr); - PageSetTLI(page, ThisTimeLineID); + /* + * The page may be uninitialized. If so, we can't set the LSN + * and TLI because that would corrupt the page. + */ + if (!PageIsNew(page)) + { + PageSetLSN(page, recptr); + PageSetTLI(page, ThisTimeLineID); + } END_CRIT_SECTION(); } |