initdb: Add new option "--no-data-checksums"
authorPeter Eisentraut <[email protected]>
Tue, 1 Oct 2024 14:27:39 +0000 (10:27 -0400)
committerPeter Eisentraut <[email protected]>
Tue, 1 Oct 2024 14:50:30 +0000 (10:50 -0400)
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 <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com

doc/src/sgml/ref/initdb.sgml
src/bin/initdb/initdb.c
src/bin/initdb/t/001_initdb.pl

index c2531f551a8698e8ac8afd68cdf481950b36e2f3..a0ce261999943baf97c7b80e16cac061c834ebdf 100644 (file)
@@ -343,6 +343,16 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry id="app-initdb-no-data-checksums" xreflabel="no data checksums">
+      <term><option>--no-data-checksums</option></term>
+      <listitem>
+       <para>
+        Do not enable data checksums.  This can be used to override a
+        <option>--data-checksums</option> option.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="app-initdb-option-pwfile">
       <term><option>--pwfile=<replaceable>filename</replaceable></option></term>
       <listitem>
index f00718a0150c2fd06870953906769411f087a7a0..eac6cbd8e514257e5910098435ffb90b657ff876 100644 (file)
@@ -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);
index 06a35ac0b738e9dda06543f0ed7de0a0d356fc79..8072adb97fefe07c6442c7a136f80417cc94d818 100644 (file)
@@ -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();