|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.111 2004/08/3002:54:39 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.112 2004/08/3003:52:43 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -937,10 +937,19 @@ _mdfd_getseg(SMgrRelation reln, BlockNumber blkno, bool allowNotFound)
|
937 | 937 | * "target" block.We should never need to create more than
|
938 | 938 | * one new segment per call, so this restriction seems
|
939 | 939 | * reasonable.
|
| 940 | + * |
| 941 | + * BUT: when doing WAL recovery, disable this logic and create |
| 942 | + * segments unconditionally. In this case it seems better |
| 943 | + * to assume the given blkno is good (it presumably came from |
| 944 | + * a CRC-checked WAL record); furthermore this lets us cope |
| 945 | + * in the case where we are replaying WAL data that has a write |
| 946 | + * into a high-numbered segment of a relation that was later |
| 947 | + * deleted. We want to go ahead and create the segments so |
| 948 | + * we can finish out the replay. |
940 | 949 | */
|
941 | 950 | v->mdfd_chain=_mdfd_openseg(reln,
|
942 | 951 | nextsegno,
|
943 |
| - (segstogo==1) ?O_CREAT :0); |
| 952 | + (segstogo==1||InRecovery) ?O_CREAT :0); |
944 | 953 | if (v->mdfd_chain==NULL)
|
945 | 954 | {
|
946 | 955 | if (allowNotFound&&errno==ENOENT)
|
|