Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntNB8-0007lX-NB for pgsql-general@arkaria.postgresql.org; Tue, 24 May 2022 05:33:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntNB7-0003rJ-JC for pgsql-general@arkaria.postgresql.org; Tue, 24 May 2022 05:33:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntNB7-0003rA-8U for pgsql-general@lists.postgresql.org; Tue, 24 May 2022 05:33:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntNB4-0004p6-EC for pgsql-general@postgresql.org; Tue, 24 May 2022 05:33:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 24O5XplJ1432729; Tue, 24 May 2022 01:33:51 -0400 From: Tom Lane To: "David G. Johnston" cc: jian he , "pgsql-general@postgresql.org" Subject: Re: cast to domain with default collation issue. In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Mon, 23 May 2022 22:13:38 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1432727.1653370431.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 24 May 2022 01:33:51 -0400 Message-ID: <1432728.1653370431@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Monday, May 23, 2022, jian he wrote: >> CREATE DOMAIN testdomain AS text; >> --asume the default collation is as per show LC_COLLATE; >> – on my pc, it is C.UTF-8. >> --So the testdomain will be collation "C.UTF-8" > My reading of the docs say this is consistent with outcome #2. > https://www.postgresql.org/docs/current/collation.html Yeah. The comments in parse_collate.c are clear that this behavior is intentional: case T_CoerceToDomain: { /* * If the domain declaration included a non-default COLLATE * spec, then use that collation as the output collation of * the coercion. Otherwise allow the input collation to * bubble up. (The input should be of the domain's base type, * therefore we don't need to worry about it not being * collatable when the domain is.) */ Perhaps this should be documented more clearly, but it's not obviously wrong. If the domain declaration doesn't include an explicit COLLATE then casting to the domain doesn't create an explicit collation requirement. (That is, the domain *doesn't* have a specific collation attached to it, any more than type text does.) regards, tom lane