|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.292 2010/07/06 19:18:55 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.293 2010/07/29 16:14:36 rhaas Exp $ |
12 | 12 | *
|
13 | 13 | *
|
14 | 14 | * INTERFACE ROUTINES
|
@@ -4079,8 +4079,15 @@ log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno,
|
4079 | 4079 |
|
4080 | 4080 | recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);
|
4081 | 4081 |
|
4082 |
| - PageSetLSN(page, recptr); |
4083 |
| - PageSetTLI(page, ThisTimeLineID); |
| 4082 | + /* |
| 4083 | + * The page may be uninitialized. If so, we can't set the LSN |
| 4084 | + * and TLI because that would corrupt the page. |
| 4085 | + */ |
| 4086 | + if (!PageIsNew(page)) |
| 4087 | + { |
| 4088 | + PageSetLSN(page, recptr); |
| 4089 | + PageSetTLI(page, ThisTimeLineID); |
| 4090 | + } |
4084 | 4091 |
|
4085 | 4092 | END_CRIT_SECTION();
|
4086 | 4093 |
|
@@ -4266,8 +4273,16 @@ heap_xlog_newpage(XLogRecPtr lsn, XLogRecord *record)
|
4266 | 4273 | Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ);
|
4267 | 4274 | memcpy(page, (char *) xlrec + SizeOfHeapNewpage, BLCKSZ);
|
4268 | 4275 |
|
4269 |
| - PageSetLSN(page, lsn); |
4270 |
| - PageSetTLI(page, ThisTimeLineID); |
| 4276 | + /* |
| 4277 | + * The page may be uninitialized. If so, we can't set the LSN |
| 4278 | + * and TLI because that would corrupt the page. |
| 4279 | + */ |
| 4280 | + if (!PageIsNew(page)) |
| 4281 | + { |
| 4282 | + PageSetLSN(page, lsn); |
| 4283 | + PageSetTLI(page, ThisTimeLineID); |
| 4284 | + } |
| 4285 | + |
4271 | 4286 | MarkBufferDirty(buffer);
|
4272 | 4287 | UnlockReleaseBuffer(buffer);
|
4273 | 4288 | }
|
|
0 commit comments