diff options
author | Peter Eisentraut | 2024-10-16 06:45:09 +0000 |
---|---|---|
committer | Peter Eisentraut | 2024-10-16 06:48:10 +0000 |
commit | 04bec894a04cb0d32533f1522ab81b7016141ff1 (patch) | |
tree | 0fdb1a99f7c316c3a5715507bed82a56af9b37bc | |
parent | 67846550dc6d7d90db4d98cdd8a8440725ef5c65 (diff) |
initdb: Change default to using data checksums.
Checksums are now on by default. They can be disabled by the
previously added option --no-data-checksums.
Author: Greg Sabino Mullane <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com
-rw-r--r-- | doc/src/sgml/ref/initdb.sgml | 15 | ||||
-rw-r--r-- | src/bin/initdb/initdb.c | 2 | ||||
-rw-r--r-- | src/bin/initdb/t/001_initdb.pl | 18 |
3 files changed, 21 insertions, 14 deletions
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml index b8207438910..0c32114cf70 100644 --- a/doc/src/sgml/ref/initdb.sgml +++ b/doc/src/sgml/ref/initdb.sgml @@ -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> diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 34db43f47b7..9a91830783e 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -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; diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index 8072adb97fe..7520d3d0dda 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -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(); |