mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Fix checksums for CLUSTER, VACUUM FULL etc.
In CLUSTER, VACUUM FULL and ALTER TABLE SET TABLESPACE I erroneously set checksum before log_newpage, which sets the LSN and invalidates the checksum. So set checksum immediately *after* log_newpage. Bug report Fujii Masao, Fix and patch by Jeff Davis
This commit is contained in:
@ -51,6 +51,7 @@
|
||||
#include "commands/tablespace.h"
|
||||
#include "commands/trigger.h"
|
||||
#include "commands/typecmds.h"
|
||||
#include "common/relpath.h"
|
||||
#include "executor/executor.h"
|
||||
#include "foreign/foreign.h"
|
||||
#include "miscadmin.h"
|
||||
@ -8902,12 +8903,21 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst,
|
||||
|
||||
smgrread(src, forkNum, blkno, buf);
|
||||
|
||||
PageSetChecksumInplace(page, blkno);
|
||||
if (!PageIsVerified(page, blkno))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg("invalid page in block %u of relation %s",
|
||||
blkno,
|
||||
relpathbackend(src->smgr_rnode.node,
|
||||
src->smgr_rnode.backend,
|
||||
forkNum))));
|
||||
|
||||
/* XLOG stuff */
|
||||
if (use_wal)
|
||||
log_newpage(&dst->smgr_rnode.node, forkNum, blkno, page);
|
||||
|
||||
PageSetChecksumInplace(page, blkno);
|
||||
|
||||
/*
|
||||
* Now write the page. We say isTemp = true even if it's not a temp
|
||||
* rel, because there's no need for smgr to schedule an fsync for this
|
||||
|
Reference in New Issue
Block a user