diff -cr pgsql_org/src/backend/access/transam/xlog.c pgsql/src/backend/access/transam/xlog.c *** pgsql_org/src/backend/access/transam/xlog.c 2007-05-02 15:56:38.000000000 +0900 --- pgsql/src/backend/access/transam/xlog.c 2007-05-07 16:30:38.000000000 +0900 *************** *** 837,842 **** --- 837,854 ---- return RecPtr; } + /* + * If online backup is not in progress and WAL archiving is active, mark + * backup blocks removable if any. + * This mark will be referenced during archiving to remove needless backup + * blocks in the record and compress WAL segment files. + */ + if (XLogArchivingActive() && fullPageWrites && + (info & XLR_BKP_BLOCK_MASK) && !Insert->forcePageWrites) + { + info |= XLR_BKP_REMOVABLE; + } + /* Insert record header */ record = (XLogRecord *) Insert->currpos; *************** *** 2738,2750 **** blk += blen; } ! /* Check that xl_tot_len agrees with our calculation */ ! if (blk != (char *) record + record->xl_tot_len) { ! ereport(emode, ! (errmsg("incorrect total length in record at %X/%X", ! recptr.xlogid, recptr.xrecoff))); ! return false; } /* Finally include the record header */ --- 2750,2778 ---- blk += blen; } ! /* ! * If physical log has not been removed, check the length to see ! * the following. ! * - No physical log existed originally, ! * - WAL record was not removable because it is generated during ! * the online backup, ! * - Cannot be removed because the physical log spanned in ! * two segments. ! * The reason why we skip the length check on the physical log removal is ! * that the flag XLR_SET_BKB_BLOCK(0..2) is reset to zero and it prevents ! * the above loop to proceed blk to the end of the record. ! */ ! if (!(record->xl_info & XLR_BKP_REMOVABLE) || ! record->xl_info & XLR_BKP_BLOCK_MASK) { ! /* Check that xl_tot_len agrees with our calculation */ ! if (blk != (char *) record + record->xl_tot_len) ! { ! ereport(emode, ! (errmsg("incorrect total length in record at %X/%X", ! recptr.xlogid, recptr.xrecoff))); ! return false; ! } } /* Finally include the record header */ pgsql/src/backend/access/transamだけに発見: xlog.c.orig diff -cr pgsql_org/src/include/access/xlog.h pgsql/src/include/access/xlog.h *** pgsql_org/src/include/access/xlog.h 2007-01-06 07:19:51.000000000 +0900 --- pgsql/src/include/access/xlog.h 2007-05-07 16:30:38.000000000 +0900 *************** *** 66,73 **** /* * If we backed up any disk blocks with the XLOG record, we use flag bits in * xl_info to signal it. We support backup of up to 3 disk blocks per XLOG ! * record. (Could support 4 if we cared to dedicate all the xl_info bits for ! * this purpose; currently bit 0 of xl_info is unused and available.) */ #define XLR_BKP_BLOCK_MASK 0x0E /* all info bits used for bkp blocks */ #define XLR_MAX_BKP_BLOCKS 3 --- 66,74 ---- /* * If we backed up any disk blocks with the XLOG record, we use flag bits in * xl_info to signal it. We support backup of up to 3 disk blocks per XLOG ! * record. ! * Bit 0 of xl_info is used to represent that backup blocks are not necessary ! * in archive-log. */ #define XLR_BKP_BLOCK_MASK 0x0E /* all info bits used for bkp blocks */ #define XLR_MAX_BKP_BLOCKS 3 *************** *** 75,80 **** --- 76,82 ---- #define XLR_BKP_BLOCK_1 XLR_SET_BKP_BLOCK(0) /* 0x08 */ #define XLR_BKP_BLOCK_2 XLR_SET_BKP_BLOCK(1) /* 0x04 */ #define XLR_BKP_BLOCK_3 XLR_SET_BKP_BLOCK(2) /* 0x02 */ + #define XLR_BKP_REMOVABLE XLR_SET_BKP_BLOCK(3) /* 0x01 */ /* * Sometimes we log records which are out of transaction control.