|
7 | 7 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.4 2004/08/11 04:09:12 tgl Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.5 2005/05/31 19:11:28 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -427,8 +427,8 @@ static uint32 readOff = 0;
|
427 | 427 | static char *readBuf = NULL;
|
428 | 428 |
|
429 | 429 | /* State information for XLOG reading */
|
430 |
| -static XLogRecPtr ReadRecPtr; |
431 |
| -static XLogRecPtr EndRecPtr; |
| 430 | +static XLogRecPtr ReadRecPtr; /* start of last record read */ |
| 431 | +static XLogRecPtr EndRecPtr; /* end+1 of last record read */ |
432 | 432 | static XLogRecord *nextRecord = NULL;
|
433 | 433 | static StartUpID lastReadSUI;
|
434 | 434 |
|
@@ -1872,6 +1872,37 @@ got_record:;
|
1872 | 1872 | RecPtr->xlogid, RecPtr->xrecoff);
|
1873 | 1873 | goto next_record_is_invalid;
|
1874 | 1874 | }
|
| 1875 | + if (!nextmode) |
| 1876 | + { |
| 1877 | + /* |
| 1878 | + * We can't exactly verify the prev-link, but surely it should be |
| 1879 | + * less than the record's own address. |
| 1880 | + */ |
| 1881 | + if (!XLByteLT(record->xl_prev, *RecPtr)) |
| 1882 | + { |
| 1883 | + elog(emode, |
| 1884 | + "ReadRecord: record with incorrect prev-link %X/%X at %X/%X", |
| 1885 | + record->xl_prev.xlogid, record->xl_prev.xrecoff, |
| 1886 | + RecPtr->xlogid, RecPtr->xrecoff); |
| 1887 | + goto next_record_is_invalid; |
| 1888 | + } |
| 1889 | + } |
| 1890 | + else |
| 1891 | + { |
| 1892 | + /* |
| 1893 | + * Record's prev-link should exactly match our previous location. |
| 1894 | + * This check guards against torn WAL pages where a stale but |
| 1895 | + * valid-looking WAL record starts on a sector boundary. |
| 1896 | + */ |
| 1897 | + if (!XLByteEQ(record->xl_prev, ReadRecPtr)) |
| 1898 | + { |
| 1899 | + elog(emode, |
| 1900 | + "record with incorrect prev-link %X/%X at %X/%X", |
| 1901 | + record->xl_prev.xlogid, record->xl_prev.xrecoff, |
| 1902 | + RecPtr->xlogid, RecPtr->xrecoff); |
| 1903 | + goto next_record_is_invalid; |
| 1904 | + } |
| 1905 | + } |
1875 | 1906 |
|
1876 | 1907 | /*
|
1877 | 1908 | * Compute total length of record including any appended backup
|
|
0 commit comments