diff options
author | Masahiko Sawada <msawada@postgresql.org> | 2025-02-21 10:12:08 -0800 |
---|---|---|
committer | Masahiko Sawada <msawada@postgresql.org> | 2025-02-21 10:12:08 -0800 |
commit | 44fe30fdab6746a287163e7cc093fd36cda8eb92 (patch) | |
tree | 983324d294a1b25ca1d362f1b349337b59a451c2 /src/include/access/xlog.h | |
parent | 901a1cf8b4a291a3a22021bf7acb516c1d278e53 (diff) | |
download | postgresql-44fe30fdab6746a287163e7cc093fd36cda8eb92.tar.gz postgresql-44fe30fdab6746a287163e7cc093fd36cda8eb92.zip |
Add default_char_signedness field to ControlFileData.
The signedness of the 'char' type in C is
implementation-dependent. For instance, 'signed char' is used by
default on x86 CPUs, while 'unsigned char' is used on aarch
CPUs. Previously, we accidentally let C implementation signedness
affect persistent data. This led to inconsistent results when
comparing char data across different platforms.
This commit introduces a new 'default_char_signedness' field in
ControlFileData to store the signedness of the 'char' type. While this
change does not encourage the use of 'char' without explicitly
specifying its signedness, this field can be used as a hint to ensure
consistent behavior for pre-v18 data files that store data sorted by
the 'char' type on disk (e.g., GIN and GiST indexes), especially in
cross-platform replication scenarios.
Newly created database clusters unconditionally set the default char
signedness to true. pg_upgrade (with an upcoming commit) changes this
flag for clusters if the source database cluster has
signedness=false. As a result, signedness=false setting will become
rare over time. If we had known about the problem during the last
development cycle that forced initdb (v8.3), we would have made all
clusters signed or all clusters unsigned. Making pg_upgrade the only
source of signedness=false will cause the population of database
clusters to converge toward that retrospective ideal.
Bump catalog version (for the catalog changes) and PG_CONTROL_VERSION
(for the additions in ControlFileData).
Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/CB11ADBC-0C3F-4FE0-A678-666EE80CBB07%40amazon.com
Diffstat (limited to 'src/include/access/xlog.h')
-rw-r--r-- | src/include/access/xlog.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4411c1468ac..d313099c027 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -231,6 +231,7 @@ extern XLogRecPtr GetXLogWriteRecPtr(void); extern uint64 GetSystemIdentifier(void); extern char *GetMockAuthenticationNonce(void); extern bool DataChecksumsEnabled(void); +extern bool GetDefaultCharSignedness(void); extern XLogRecPtr GetFakeLSNForUnloggedRel(void); extern Size XLOGShmemSize(void); extern void XLOGShmemInit(void); |