Re: Recursive CTE and collation

From: Sébastien Lardière <sebastien(at)lardiere(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, fluca1978(at)gmail(dot)com
Subject: Re: Recursive CTE and collation
Date: 2019-06-14 14:54:02
Message-ID: 4d73f7e5-a64d-2a9c-9148-09176d6261fb@lardiere.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 14/06/2019 15:39, Tom Lane wrote:
> =?UTF-8?Q?S=c3=a9bastien_Lardi=c3=a8re?= <sebastien(at)lardiere(dot)net> writes:
>> While playing with the query showed here :
>> https://fluca1978.github.io/2019/06/12/PartitioningCTE.html
>> I've seen something strange with v12 (actually compiled after
>> f43608bda2111a1fda514d1bed4df313ee2bbec3 so more recent than beta1) :
>> psql: ERROR:  recursive query "inheritance_tree" column 3 has collation
>> "default" in non-recursive term but collation "C" overall
>> LINE 4:             , NULL::text AS table_parent_name
>>                       ^
>> HINT:  Use the COLLATE clause to set the collation of the non-recursive
>> term.
> Yeah. Your query is really wrong as it stands, because it's trying
> to union "NULL::text" with a column of type "name".

Indeed, ::text is wrong,

> That accidentally
> works in previous releases, but as of v12, "name" has acquired
> collatability, and the recursive-union rules don't allow papering that
> over.

Good to know,

> I notice that it does work in a regular union:
>
> regression=# select null::text union select null::name collate "C";
> text
> ------
>
> (1 row)
>
> but I believe that recursive union is intentionally stricter.
>
>> It work correctly with 11, and with 12, we can workaround by adding
>> COLLATE "C" after NULL::text, so I don't know if it's a bug or a new
>> feature, but it break things, at least.
> I'd suggest using "NULL::name" instead.

yes, thanks,

--

Sébastien

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-06-14 15:19:29 Re: Recursive CTE and collation
Previous Message Tom Lane 2019-06-14 13:39:32 Re: Recursive CTE and collation