pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sébastien Lardière <sebastien@lardiere.net>
Cc: pgsql-bugs@lists.postgresql.org
Cc: fluca1978@gmail.com
Subject: Re: Recursive CTE and collation
Date: Fri, 14 Jun 2019 09:39:32 -0400
Message-ID: <28491.1560519572@sss.pgh.pa.us> (raw)
In-Reply-To: <97aa6131-7f79-a29b-1bb3-7e87b2f4f50c@lardiere.net>
References: <97aa6131-7f79-a29b-1bb3-7e87b2f4f50c@lardiere.net>

=?UTF-8?Q?S=c3=a9bastien_Lardi=c3=a8re?= <sebastien@lardiere.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".  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.

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.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <28491.1560519572@sss.pgh.pa.us>
Permalink:  ../28491.1560519572@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28491.1560519572@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sebastien@lardiere.net, fluca1978@gmail.com
  Subject: Re: Recursive CTE and collation
  In-Reply-To: <28491.1560519572@sss.pgh.pa.us>
  References: <97aa6131-7f79-a29b-1bb3-7e87b2f4f50c@lardiere.net> <28491.1560519572@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox