make \d table Collation field showing domains collation if that attribute is type of domain.

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: make \d table Collation field showing domains collation if that attribute is type of domain.
Date: 2024-10-03 14:16:00
Message-ID: CACJufxG-Ww0Hezx=AxMxsM_Wkdp+VbWwXQQKPD7uC7pzym+-+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

$subject related demos:
CREATE COLLATION case_insensitive (provider = icu, locale =
'@colStrength=secondary', deterministic = false);
create domain d_colli as text collate case_insensitive;
create domain d_collc as d_colli collate "C";
create table s1(a d_colli);
create table s2(a d_colli[] collate "C");
create table s3(a d_collc);

currently in HEAD:
\d s1
Table "public.s1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | d_colli | | |

\d s2
Table "public.s2"
Column | Type | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
a | d_colli[] | C | |

\d s3
Table "public.s3"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | d_collc | | |

we can change it to
\d s1
Table "public.s1"
Column | Type | Collation | Nullable | Default
--------+---------+------------------+----------+---------
a | d_colli | case_insensitive | |

\d s2
Table "public.s2"
Column | Type | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
a | d_colli[] | C | |

\d s3
Table "public.s3"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | d_collc | C | |

as you can see:
For non-domain types, everything is the same as before.
but domains with COLLATION clauses behave differently.

main changes:
@@ -1866,7 +1866,7 @@ describeOneTableDetails(const char *schemaname,
attrdef_col = cols++;
attnotnull_col = cols++;
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname
FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
- " WHERE
c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <>
t.typcollation) AS attcollation");
+ " WHERE
c.oid = a.attcollation AND t.oid = a.atttypid and c.collname <>
'default' ) AS attcollation");

it will make a table column with type "name", display Collation "C",
since "name" type typcollation is 'C',
other than this all behavior is the same as HEAD.

what do you think?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2024-10-03 14:17:40 Re: Add on_error and log_verbosity options to file_fdw
Previous Message Masahiko Sawada 2024-10-03 13:55:47 Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation