Re: Folding of case of identifiers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Niels Jespersen <NJN(at)dst(dot)dk>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Folding of case of identifiers
Date: 2022-01-11 15:26:40
Message-ID: 2590820.1641914800@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Niels Jespersen <NJN(at)dst(dot)dk> 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 (_). Subsequent 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 include the danish letters æøå/ÆØÅ.

> However, name-folding is odd for these letters. Of these three create tables, the two first succeed, the last one does not (G and g is equivalent, Æ and æ 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message benj.dev 2022-01-11 15:51:30 Re: plpgsql function problem whith creating temp table - not correctly using search_path ?
Previous Message Tom Lane 2022-01-11 15:18:47 Re: plpgsql function problem whith creating temp table - not correctly using search_path ?