From 983a588e0b864d5c016d5902217ba4b11fc82b4f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 1 Oct 2024 10:27:39 -0400 Subject: [PATCH] initdb: Add new option "--no-data-checksums" Right now this does nothing except override any earlier --data-checksums option. But the idea is that --data-checksums could become the default, and then this option would allow forcing it off instead. Author: Greg Sabino Mullane Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com --- doc/src/sgml/ref/initdb.sgml | 10 ++++++++++ src/bin/initdb/initdb.c | 5 +++++ src/bin/initdb/t/001_initdb.pl | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml index c2531f551a..a0ce261999 100644 --- a/doc/src/sgml/ref/initdb.sgml +++ b/doc/src/sgml/ref/initdb.sgml @@ -343,6 +343,16 @@ PostgreSQL documentation + + + + + Do not enable data checksums. This can be used to override a + option. + + + + diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f00718a015..eac6cbd8e5 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2466,6 +2466,7 @@ usage(const char *progname) " set builtin locale name for new databases\n")); printf(_(" --locale-provider={builtin|libc|icu}\n" " set default locale provider for new databases\n")); + printf(_(" --no-data-checksums do not use data page checksums\n")); printf(_(" --pwfile=FILE read password for the new superuser from file\n")); printf(_(" -T, --text-search-config=CFG\n" " default text search configuration\n")); @@ -3128,6 +3129,7 @@ main(int argc, char *argv[]) {"icu-locale", required_argument, NULL, 17}, {"icu-rules", required_argument, NULL, 18}, {"sync-method", required_argument, NULL, 19}, + {"no-data-checksums", no_argument, NULL, 20}, {NULL, 0, NULL, 0} }; @@ -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