Skip to content

Commit 4439517

Browse files
Record data_checksum_version in control file.
The value is not used anywhere in code, but will allow future changes to the checksum version should that become necessary in the future.
1 parent 7309243 commit 4439517

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#include "utils/timestamp.h"
6161
#include "pg_trace.h"
6262

63-
extern bool bootstrap_data_checksums;
63+
extern uint32 bootstrap_data_checksum_version;
6464

6565
/* File path names (all relative to $PGDATA) */
6666
#define RECOVERY_COMMAND_FILE "recovery.conf"
@@ -3797,7 +3797,7 @@ bool
37973797
DataChecksumsEnabled(void)
37983798
{
37993799
Assert(ControlFile != NULL);
3800-
return ControlFile->data_checksums;
3800+
return (ControlFile->data_checksum_version > 0);
38013801
}
38023802

38033803
/*
@@ -4126,7 +4126,7 @@ BootStrapXLOG(void)
41264126
ControlFile->max_prepared_xacts = max_prepared_xacts;
41274127
ControlFile->max_locks_per_xact = max_locks_per_xact;
41284128
ControlFile->wal_level = wal_level;
4129-
ControlFile->data_checksums = bootstrap_data_checksums;
4129+
ControlFile->data_checksum_version = bootstrap_data_checksum_version;
41304130

41314131
/* some additional ControlFile fields are set in WriteControlFile() */
41324132

src/backend/bootstrap/bootstrap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "postmaster/walwriter.h"
3535
#include "replication/walreceiver.h"
3636
#include "storage/bufmgr.h"
37+
#include "storage/bufpage.h"
3738
#include "storage/ipc.h"
3839
#include "storage/proc.h"
3940
#include "tcop/tcopprot.h"
@@ -48,7 +49,7 @@
4849
extern int optind;
4950
extern char *optarg;
5051

51-
bool bootstrap_data_checksums = false;
52+
uint32 bootstrap_data_checksum_version = 0; /* No checksum */
5253

5354

5455
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
@@ -262,7 +263,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
262263
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
263264
break;
264265
case 'k':
265-
bootstrap_data_checksums = true;
266+
bootstrap_data_checksum_version = PG_DATA_CHECKSUM_VERSION;
266267
break;
267268
case 'r':
268269
strlcpy(OutputFileName, optarg, MAXPGPATH);

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ main(int argc, char *argv[])
287287
(ControlFile.float4ByVal ? _("by value") : _("by reference")));
288288
printf(_("Float8 argument passing: %s\n"),
289289
(ControlFile.float8ByVal ? _("by value") : _("by reference")));
290-
printf(_("Data page checksums: %s\n"),
291-
(ControlFile.data_checksums ? _("enabled") : _("disabled")));
290+
printf(_("Data page checksum version: %u\n"),
291+
ControlFile.data_checksum_version);
292292
return 0;
293293
}

src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ PrintControlValues(bool guessed)
624624
(ControlFile.float4ByVal ? _("by value") : _("by reference")));
625625
printf(_("Float8 argument passing: %s\n"),
626626
(ControlFile.float8ByVal ? _("by value") : _("by reference")));
627-
printf(_("Data page checksums: %s\n"),
628-
(ControlFile.data_checksums ? _("enabled") : _("disabled")));
627+
printf(_("Data page checksum version: %u\n"),
628+
ControlFile.data_checksum_version);
629629
}
630630

631631

src/include/catalog/pg_control.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ typedef struct ControlFileData
213213
bool float4ByVal; /* float4 pass-by-value? */
214214
bool float8ByVal; /* float8, int8, etc pass-by-value? */
215215

216-
/* Are data pages protected by checksums? */
217-
bool data_checksums;
216+
/* Are data pages protected by checksums? Zero if no checksum version */
217+
uint32 data_checksum_version;
218218

219219
/* CRC of all above ... MUST BE LAST! */
220220
pg_crc32 crc;

src/include/storage/bufpage.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ typedef PageHeaderData *PageHeader;
189189
* Release 8.3 uses 4; it changed the HeapTupleHeader layout again, and
190190
* added the pd_flags field (by stealing some bits from pd_tli),
191191
* as well as adding the pd_prune_xid field (which enlarges the header).
192+
*
193+
* As of Release 9.3, the checksum version must also be considered when
194+
* handling pages.
192195
*/
193196
#define PG_PAGE_LAYOUT_VERSION 4
194-
197+
#define PG_DATA_CHECKSUM_VERSION 1
195198

196199
/* ----------------------------------------------------------------
197200
* page support macros

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy