Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hbmQg-00036v-VV for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Jun 2019 13:39:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hbmQf-00067C-KG for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Jun 2019 13:39:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hbmQf-00063o-7f for pgsql-bugs@lists.postgresql.org; Fri, 14 Jun 2019 13:39:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hbmQc-0003Gd-7k for pgsql-bugs@lists.postgresql.org; Fri, 14 Jun 2019 13:39:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5EDdWOT028492; Fri, 14 Jun 2019 09:39:33 -0400 From: Tom Lane To: =?UTF-8?Q?S=c3=a9bastien_Lardi=c3=a8re?= cc: pgsql-bugs@lists.postgresql.org, fluca1978@gmail.com Subject: Re: Recursive CTE and collation In-reply-to: <97aa6131-7f79-a29b-1bb3-7e87b2f4f50c@lardiere.net> References: <97aa6131-7f79-a29b-1bb3-7e87b2f4f50c@lardiere.net> Comments: In-reply-to =?UTF-8?Q?S=c3=a9bastien_Lardi=c3=a8re?= message dated "Fri, 14 Jun 2019 11:22:57 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <28490.1560519572.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 14 Jun 2019 09:39:32 -0400 Message-ID: <28491.1560519572@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?S=c3=a9bastien_Lardi=c3=a8re?= 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