initdb: Change default to using data checksums.
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 16 Oct 2024 06:45:09 +0000 (08:45 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 16 Oct 2024 06:48:10 +0000 (08:48 +0200)
Checksums are now on by default.  They can be disabled by the
previously added option --no-data-checksums.

Author: Greg Sabino Mullane <greg@turnstep.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
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 b8207438910ae060f90132ef8448975ef899cd79..0c32114cf70056bcdbd8d0035111fa78edcbcd83 100644 (file)
@@ -265,8 +265,14 @@ PostgreSQL documentation
       <term><option>--data-checksums</option></term>
       <listitem>
        <para>
-        Use checksums on data pages to help detect corruption by the
-        I/O system that would otherwise be silent. Enabling checksums
+        Use checksums on data pages to help detect corruption by the I/O
+        system that would otherwise be silent.  This is enabled by default;
+        use <xref linkend="app-initdb-no-data-checksums"/> to disable
+        checksums.
+       </para>
+
+       <para>
+        Enabling checksums
         might incur a small performance penalty. If set, checksums
         are calculated for all objects, in all databases. All checksum
         failures will be reported in the
@@ -343,12 +349,11 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry id="app-initdb-no-data-checksums" xreflabel="no data checksums">
+     <varlistentry id="app-initdb-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.
+        Do not enable data checksums.
        </para>
       </listitem>
      </varlistentry>
index 34db43f47b7fdff6d9acfbe05b3960a9863404dc..9a91830783edfa1b65373c48a179e80a113d2390 100644 (file)
@@ -164,7 +164,7 @@ static bool noinstructions = false;
 static bool do_sync = true;
 static bool sync_only = false;
 static bool show_setting = false;
-static bool data_checksums = false;
+static bool data_checksums = true;
 static char *xlog_dir = NULL;
 static int wal_segment_size_mb = (DEFAULT_XLOG_SEG_SIZE) / (1024 * 1024);
 static DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
index 8072adb97fefe07c6442c7a136f80417cc94d818..7520d3d0ddab13eaf9209127c2e0537ee5827543 100644 (file)
@@ -69,16 +69,11 @@ mkdir $datadir;
    }
 }
 
-# Control file should tell that data checksums are disabled by default.
+# Control file should tell that data checksums are enabled by default.
 command_like(
    [ 'pg_controldata', $datadir ],
-   qr/Data page checksum version:.*0/,
-   'checksums are disabled in control file');
-# pg_checksums fails with checksums disabled by default.  This is
-# not part of the tests included in pg_checksums to save from
-# the creation of an extra instance.
-command_fails([ 'pg_checksums', '-D', $datadir ],
-   "pg_checksums fails with data checksum disabled");
+   qr/Data page checksum version:.*1/,
+   'checksums are enabled in control file');
 
 command_ok([ 'initdb', '-S', $datadir ], 'sync only');
 command_fails([ 'initdb', $datadir ], 'existing data directory');
@@ -280,4 +275,11 @@ command_like(
    qr/Data page checksum version:.*0/,
    'checksums are disabled in control file');
 
+# pg_checksums fails with checksums disabled. This is
+# not part of the tests included in pg_checksums to save from
+# the creation of an extra instance.
+command_fails(
+   [ 'pg_checksums', '-D', $datadir_nochecksums ],
+   "pg_checksums fails with data checksum disabled");
+
 done_testing();