cast to domain with default collation issue.
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: pgsql-general@postgresql.org
Date: 2022-05-24T05:02:25Z
Lists: pgsql-general
CREATE DOMAIN testdomain AS text;
--asume the default collation is as per show LC_COLLATE;
– on my pc, it is C.UTF-8.
--So the testdomain will be collation "C.UTF-8"
------------
=> \d collate_test1
Table "test.collate_test1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
b | text | en-x-icu | not null |
=> \d collate_test2
Table "test.collate_test2"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
b | text | sv-x-icu | |
=> \d collate_test3
Table "test.collate_test3"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
b | text | C | |
-----------------------------------------------
My guess is that the following should be the same. Since the same content
in the end will be cast to the same collation. However the following output
contradicts with my understanding.
SELECT a, b::testdomain FROM collate_test1 ORDER BY 2;
/*
+---+-----+
| a | b |
+---+-----+
| 1 | abc |
| 4 | ABC |
| 2 | äbc |
| 3 | bbc |
+---+-----+
*/
SELECT a, b::testdomain FROM collate_test2 ORDER BY 2;
/*
+---+-----+
| a | b |
+---+-----+
| 1 | abc |
| 4 | ABC |
| 3 | bbc |
| 2 | äbc |
+---+-----+
*/
SELECT a, b::testdomain FROM collate_test3 ORDER BY 2;
/*
+---+-----+
| a | b |
+---+-----+
| 4 | ABC |
| 1 | abc |
| 3 | bbc |
| 2 | äbc |
+---+-----+
*/
--
I recommend David Deutsch's <<The Beginning of Infinity>>
Jian
Commits
-
Doc: clarify the default collation behavior of domains.
- e0047269a8c9 10.22 landed
- d6d9ea0a468b 13.8 landed
- d26ac35d0d7c 15.0 landed
- cc5de7ba255d 12.12 landed
- be35a6456901 14.5 landed
- a8c63282ddce 11.17 landed