From ccbbb268374074f767b6cb2daa7124ca7ec3df6b Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 23 Aug 2024 09:36:35 -0400 Subject: [PATCH v2 1/4] Add new initdb argument "--no-data-checksums" to force checksums off --- doc/src/sgml/ref/initdb.sgml | 9 +++++++++ src/bin/initdb/initdb.c | 5 +++++ src/bin/initdb/t/001_initdb.pl | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml index bdd613e77f..a854b32e54 100644 --- a/doc/src/sgml/ref/initdb.sgml +++ b/doc/src/sgml/ref/initdb.sgml @@ -277,6 +277,15 @@ PostgreSQL documentation + + + + + Prevents initdb from enabling data checksums. + + + + diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f00718a015..1f36e59286 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2456,6 +2456,7 @@ usage(const char *progname) printf(_(" --icu-locale=LOCALE set ICU locale ID for new databases\n")); printf(_(" --icu-rules=RULES set additional ICU collation rules for new databases\n")); printf(_(" -k, --data-checksums use data page checksums\n")); + printf(_(" --no-data-checksums do not use data page checksums\n")); printf(_(" --locale=LOCALE set default locale for new databases\n")); printf(_(" --lc-collate=, --lc-ctype=, --lc-messages=LOCALE\n" " --lc-monetary=, --lc-numeric=, --lc-time=LOCALE\n" @@ -3121,6 +3122,7 @@ main(int argc, char *argv[]) {"waldir", required_argument, NULL, 'X'}, {"wal-segsize", required_argument, NULL, 12}, {"data-checksums", no_argument, NULL, 'k'}, + {"no-data-checksums", no_argument, NULL, 20}, {"allow-group-access", no_argument, NULL, 'g'}, {"discard-caches", no_argument, NULL, 14}, {"locale-provider", required_argument, NULL, 15}, @@ -3319,6 +3321,9 @@ main(int argc, char *argv[]) if (!parse_sync_method(optarg, &sync_method)) exit(1); break; + case 20: + data_checksums = false; + break; default: /* getopt_long already emitted a complaint */ pg_log_error_hint("Try \"%s --help\" for more information.", progname); diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index 06a35ac0b7..8072adb97f 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -268,4 +268,16 @@ ok($conf !~ qr/^WORK_MEM = /m, "WORK_MEM should not be configured"); ok($conf !~ qr/^Work_Mem = /m, "Work_Mem should not be configured"); ok($conf =~ qr/^work_mem = 512/m, "work_mem should be in config"); +# Test the no-data-checksums flag +my $datadir_nochecksums = "$tempdir/data_no_checksums"; + +command_ok([ 'initdb', '--no-data-checksums', $datadir_nochecksums ], + 'successful creation without data checksums'); + +# Control file should tell that data checksums are disabled. +command_like( + [ 'pg_controldata', $datadir_nochecksums ], + qr/Data page checksum version:.*0/, + 'checksums are disabled in control file'); + done_testing(); -- 2.30.2