Re: Schema variables - new implementation for Postgres 15

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Joel Jacobson <joel(at)compiler(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Schema variables - new implementation for Postgres 15
Date: 2022-01-19 05:07:37
Message-ID: CAFj8pRCzb2jpMLPamCwNVk6wHWxay8yP71iDCqTTdRCDDeyZ9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=# "
>> CREATE COLLATION
>>
>> =# create variable myvariable text collate mycollation;
>> CREATE VARIABLE
>>
>> =# select classid::regclass, objid, objsubid, refclassid::regclass,
>> refobjid, refobjsubid from pg_depend where classid::regclass::text =
>> 'pg_variable' or refclassid::regclass::text = 'pg_variable';
>> classid | objid | objsubid | refclassid | refobjid | refobjsubid
>> -------------+-------+----------+--------------+----------+-------------
>> pg_variable | 16407 | 0 | pg_namespace | 2200 | 0
>> (1 row)
>>
>
> fixed
>
>
>>
>> =# let myvariable = 'AA';
>> LET
>>
>> =# select 'AA' collate "en-x-icu" < myvariable;
>> ?column?
>> ----------
>> f
>> (1 row)
>>
>> =# select 'AA' collate "en-x-icu" < myvariable collate mycollation;
>> ERROR: 42P21: collation mismatch between explicit collations "en-x-icu"
>> and "mycollation"
>> LINE 1: select 'AA' collate "en-x-icu" < myvariable collate mycollat...
>>
>
> What do you expect? I don't understand collating well, but it looks
> correct. Minimally the tables have the same behavior.
>
> create collation mycollation (locale = 'fr-FR', provider = 'icu');
> create table foo(mycol text collate mycollation);
> select 'AA' collate "en-x-icu" < mycol from foo;
> ┌──────────┐
> │ ?column? │
> ╞══════════╡
> │ f │
> └──────────┘
> (1 row)
>
>
> postgres=# select 'AA' collate "en-x-icu" < mycol collate mycollation from
> foo;
> ERROR: collation mismatch between explicit collations "en-x-icu" and
> "mycollation"
> LINE 1: select 'AA' collate "en-x-icu" < mycol collate mycollation f...
> ^
>
>
here is second test

postgres=# CREATE COLLATION nd2 (
provider = 'icu',
locale = '@colStrength=secondary', -- or 'und-u-ks-level2'
deterministic = false
);
CREATE COLLATION
postgres=# create variable testv as text col

postgres=# create variable testv as text collate nd2;
CREATE VARIABLE
postgres=# let testv = 'Ahoj';
LET
postgres=# select testv = 'AHOJ';
┌──────────┐
│ ?column? │
╞══════════╡
│ t │
└──────────┘
(1 row)

postgres=# select testv = 'AHOJ' collate "default";
┌──────────┐
│ ?column? │
╞══════════╡
│ f │
└──────────┘
(1 row)

Regards

Pavel

>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2022-01-19 05:46:01 Re: do only critical work during single-user vacuum?
Previous Message Dilip Kumar 2022-01-19 05:07:21 Re: Make relfile tombstone files conditional on WAL level