Movable DataBase Locales for Cloudberry
We inherited this issue from PostgreSQL.
PostgreSQL uses glibc to sort strings. In version glibc=2.28, collations broke down badly (in general, there are no guarantees when updating glibc). Changing collations breaks indexes. Similarly, a cluster with different collations also behaves unpredictably.
What and when something has changed in glibc can be found on https://github.com/ardentperf/glibc-unicode-sorting Also there is special postgresql-wiki https://wiki.postgresql.org/wiki/Locale_data_changes And you tube video https://www.youtube.com/watch?v=0E6O-V8Jato
In short, the issue can be seen through the use of bash:
( echo "1-1"; echo "11" ) | LC_COLLATE=en_US.UTF-8 sort
gives the different results in ubuntu 18.04 and 22.04.
There is no way to solve the problem other than by not changing the symbol order. We freeze symbol order and use it instead of glibc.
Here the solution https://github.com/postgredients/mdb-locales.
In this PR I have added PostgreSQL patch that replaces all glibc locale-related calls with a calls to an external libary. It activates using new configure parameter --with-mdblocales, which is off by default.
Using custom locales needs libmdblocales1 package and mdb-locales package with symbol table.
Build needs libmdblocales-dev package with headers.
Fixing the symbol order is necessary for OS upgrade. For example Ubuntu 22.04 EOL is April 2027, Rocky 8 Active Support ended May 2024, and Security support ends in 2029.
We use Movable DataBase Locales in Greenplum 6 and all our PostgreSQL installations (starting with PostgreSQL 12). This patch is adopted patch version from our internal PostgreSQL 14 fork.
Thank you very much for bringing up this issue and providing the corresponding patch. Yes, we've run into this problem as well - the same database version behaving inconsistently when deployed on different OS platforms. This is definitely an issue that requires fixing.
Lirong
Leonid @.***> 于2025年9月19日周五 20:26写道:
We inherited this issue from PostgreSQL.
PostgreSQL uses glibc to sort strings. In version glibc=2.28, collations broke down badly (in general, there are no guarantees when updating glibc). Changing collations breaks indexes. Similarly, a cluster with different collations also behaves unpredictably.
What and when something has changed in glibc can be found on https://github.com/ardentperf/glibc-unicode-sorting Also there is special postgresql-wiki https://wiki.postgresql.org/wiki/Locale_data_changes And you tube video https://www.youtube.com/watch?v=0E6O-V8Jato
In short, the issue can be seen through the use of bash:
( echo "1-1"; echo "11" ) | LC_COLLATE=en_US.UTF-8 sort
gives the different results in ubunru 18.04 and 22.04.
There is no way to solve the problem other than by not changing the symbol order. We freeze symbol order and use it instead of glibc.
Here the solution https://github.com/postgredients/mdb-locales.
In this PR I have added PostgreSQL patch that replaces all glibc locale-related calls with a calls to an external libary. It activates using new configure parameter --with-mdblocales, which is off by default.
Using custom locales needs libmdblocales1 package and mdb-locales package with symbol table.
Build needs libmdblocales-dev package with headers.
Fixing the symbol order is necessary for OS upgrade. For example Ubuntu 22.04 EOL is April 2027, Rocky 8 Active Support ended May 2024, and Security support ends in 2029.
We use Movable DataBase Locales in Greenplum 6 and all our PostgreSQL installations (starting with PostgreSQL 12). This patch is adopted patch version from our internal PostgreSQL 14 fork.
You can view, comment on, or merge this pull request online at:
https://github.com/apache/cloudberry/pull/1363 Commit Summary
- a92d3b9 https://github.com/apache/cloudberry/pull/1363/commits/a92d3b9a5ff2030dc8649b6aca619c4340f58ff4 Movable DataBase Locales for Cloudberry
File Changes
(25 files https://github.com/apache/cloudberry/pull/1363/files)
- M configure https://github.com/apache/cloudberry/pull/1363/files#diff-90d08e583c4c9c6f391b2ae90f819f600a6326928ea9512c9e0c6d98e9f29ac2 (97)
- M configure.ac https://github.com/apache/cloudberry/pull/1363/files#diff-49473dca262eeab3b4a43002adb08b4db31020d190caaad1594b47f1d5daa810 (17)
- M contrib/pax_storage/src/cpp/storage/oper/pax_oper.cc https://github.com/apache/cloudberry/pull/1363/files#diff-a4f236b55f00d924541a614b6b143bdad20c6a32b370e6810b9c838518232714 (5)
- M gpcontrib/orafce/others.c https://github.com/apache/cloudberry/pull/1363/files#diff-5777052ac2e6a93cb5b5c37a1f2f0556f34a2d4802f9b7a6ebd0ed66d74f1dd2 (9)
- M src/backend/gporca/libgpos/server/src/unittest/gpos/string/CWStringTest.cpp https://github.com/apache/cloudberry/pull/1363/files#diff-10ed58bc82adc94e7d8f1abaa6e2fef2cb170f590d8dd5a52e0b4c99415a3d69 (7)
- M src/backend/utils/adt/Makefile https://github.com/apache/cloudberry/pull/1363/files#diff-e8f3e2eba13bb5873b9358db9efdf130c141fbf9353c1a0b367794cfb06cda06 (3)
- A src/backend/utils/adt/mdb.c https://github.com/apache/cloudberry/pull/1363/files#diff-697a7b6a0199324da6839e548a1ac1410b43812d0421695bb867d2fd88b29ad3 (37)
- M src/backend/utils/adt/pg_locale.c https://github.com/apache/cloudberry/pull/1363/files#diff-234705d97b415bf78b3e964c0a3427539c9058636927b3f41a355533c9e7619e (63)
- M src/backend/utils/mb/mbutils.c https://github.com/apache/cloudberry/pull/1363/files#diff-8a2fb92064e0c1aa20703050fca73225ee400d3ec87227551b546881ff26175a (3)
- M src/bin/initdb/initdb.c https://github.com/apache/cloudberry/pull/1363/files#diff-8c4022d576e7486b986a173fc8a9b9207e3dbb81a194cfd2df00faa0c468916d (14)
- M src/bin/pg_upgrade/check.c https://github.com/apache/cloudberry/pull/1363/files#diff-b077f70746e5018e7bf503af88dd356c0fc389e4f9b40b63b3c9f50010855120 (9)
- M src/common/exec.c https://github.com/apache/cloudberry/pull/1363/files#diff-b930d00f932eecc43f74cb3ce235374319456abc2a6f31cf5869f2af7807d492 (4)
- M src/include/catalog/pg_proc.dat https://github.com/apache/cloudberry/pull/1363/files#diff-e2a931f90073b784e341960c6fe1f48aaea4b5d57eb4388143534eec3863477b (4)
- A src/include/common/mdb_locale.h https://github.com/apache/cloudberry/pull/1363/files#diff-d9af1dd4ccb3589343852a6c2684ac8a4e89e1b4445241de61f98bf9bf8475b6 (41)
- M src/include/pg_config.h.in https://github.com/apache/cloudberry/pull/1363/files#diff-96c452e404307390e33d320a5fde529c737044954f6f9fbef7efc441d813ecf9 (6)
- M src/interfaces/ecpg/ecpglib/connect.c https://github.com/apache/cloudberry/pull/1363/files#diff-422b590104bb87968ae985f70447ab13d533205496486bc7d8bcfc78f0082da6 (3)
- M src/interfaces/ecpg/ecpglib/descriptor.c https://github.com/apache/cloudberry/pull/1363/files#diff-1785ee4325781fd4d709f17d93039d9ed8f3ea3fff83388c9203440444de752c (8)
- M src/interfaces/ecpg/ecpglib/execute.c https://github.com/apache/cloudberry/pull/1363/files#diff-198d6b6b123c2350b5fc9cf7de08d55db2d789deba5503599cc93686137cb90e (7)
- M src/interfaces/libpq/Makefile https://github.com/apache/cloudberry/pull/1363/files#diff-7e3777116a6053e76daba3c221986de04f7634306efd492c0741cbff481c55aa (2)
- M src/pl/plperl/plperl.c https://github.com/apache/cloudberry/pull/1363/files#diff-056d611a5895bf073a5df0a2206a57b948760e91b4aaa500a4e9966d8e6ebc70 (19)
- M src/port/chklocale.c https://github.com/apache/cloudberry/pull/1363/files#diff-98f236e65fcbcef4fb77796815945dd3637f0a4fe9ca4ef53e99447c2ff6ef8c (10)
- M src/test/locale/test-ctype.c https://github.com/apache/cloudberry/pull/1363/files#diff-e12a9f3496e68f48f207f8f55cef0ab1cb81dd6725e0546f8530df6ffc0900a3 (4)
- M src/test/regress/input/misc.source https://github.com/apache/cloudberry/pull/1363/files#diff-88f5661113b04c7a9af2793aa9cd248948754be02061dde0832ea3a14450b475 (5)
- M src/test/regress/output/misc.source https://github.com/apache/cloudberry/pull/1363/files#diff-a5ad86509aea7692a5e6acb44f3cc53c5c8181a4e90f6c392377da2c06a1b969 (7)
- A src/test/regress/sql/misc.sql https://github.com/apache/cloudberry/pull/1363/files#diff-c9689259afcf05937237cf8e48b07faa0b8fa488959824cf88a4dbd2aafce805 (271)
Patch Links:
- https://github.com/apache/cloudberry/pull/1363.patch
- https://github.com/apache/cloudberry/pull/1363.diff
— Reply to this email directly, view it on GitHub https://github.com/apache/cloudberry/pull/1363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD6XVHICRZ6I2NQCJL6PZD3TPY5VAVCNFSM6AAAAACG62TJISVHI2DSMVQWIX3LMV43ASLTON2WKOZTGQZTIMJYGAZTCNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Fixed all the issues, failed tests still waiting for the working CI