我有一个在 AL2023 docker 镜像中运行的 postgres 数据库:
postgres=# select version();
select version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 15.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), 64-bit
(1 row)
postgres=#
我使用这些参数创建了这个:
--locale-provider=icu --icu-locale=C.UTF8 --encoding=UTF8
产生以下结果:
The database cluster will be initialized with this locale configuration:
provider: icu
ICU locale: C.UTF8
LC_COLLATE: C
LC_CTYPE: C
LC_MESSAGES: C
LC_MONETARY: C
LC_NUMERIC: C
LC_TIME: C
The default text search configuration will be set to "english".
如果我要求在大写字母和非大写字母之间进行排序,我会首先得到小写字母,这(a)不是我想要的,(b)不是我对 ASCII / UTF-8 / C 的期望
postgres=# select 'C' < 'c';
select 'C' < 'c';
?column?
----------
f
(1 row)
因此,如果我使用 C 排序规则,也许我会以正确的方式得到它?
postgres=# select 'C' < 'c' collate "C";
select 'C' < 'c' collate "C";
?column?
----------
t
(1 row)
我以为我正在使用 C,所以我检查了我使用的排序规则并得到...
postgres=# select datname, datcollate from pg_database;
select datname, datcollate from pg_database;
datname | datcollate
-----------+------------
postgres | C
template1 | C
template0 | C
(3 rows)
我正在使用 C - 那么为什么默认值与我显式使用 C 不同?