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 1n7J2v-0002Ra-Lp for pgsql-general@arkaria.postgresql.org; Tue, 11 Jan 2022 15:26:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n7J2t-0004rd-Do for pgsql-general@arkaria.postgresql.org; Tue, 11 Jan 2022 15:26:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7J2t-0004rT-3B for pgsql-general@lists.postgresql.org; Tue, 11 Jan 2022 15:26:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7J2q-0008Iv-Kf for pgsql-general@postgresql.org; Tue, 11 Jan 2022 15:26:46 +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 20BFQeb22590821; Tue, 11 Jan 2022 10:26:41 -0500 From: Tom Lane To: Niels Jespersen cc: "pgsql-general@postgresql.org" Subject: Re: Folding of case of identifiers In-reply-to: References: Comments: In-reply-to Niels Jespersen message dated "Tue, 11 Jan 2022 11:52:43 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2590819.1641914800.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 11 Jan 2022 10:26:40 -0500 Message-ID: <2590820.1641914800@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Niels Jespersen writes: > According to https://www.postgresql.org/docs/current/sql-syntax-lexical.= html, "Key words and unquoted identifiers are case insensitive." And "SQL = identifiers and key words must begin with a letter (a-z, but also letters = with diacritical marks and non-Latin letters) or an underscore (_). Subseq= uent characters in an identifier or key word can be letters, underscores, = digits (0-9), or dollar signs ($)." > So far so good. Non-latin letters are included, which I take to also inc= lude the danish letters =C3=A6=C3=B8=C3=A5/=C3=86=C3=98=C3=85. = > However, name-folding is odd for these letters. Of these three create ta= bles, the two first succeed, the last one does not (G and g is equivalent,= =C3=86 and =C3=A6 is not). = Whether non-ASCII characters get downcased is very context dependent. You've not mentioned the database encoding or the locale (LC_CTYPE) setting, but both of those are relevant. Basically, in a single-byte encoding we'll apply tolower() to identifier characters; but we don't attempt to case-fold multi-byte characters at all. This logic is pretty hoary, dating from before Unicode became widespread, but I'd be hesitant to change it now. regards, tom lane