pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Folding of case of identifiers 2+ messages / 2 participants [nested] [flat]
* Folding of case of identifiers @ 2022-01-11 11:52 Niels Jespersen <NJN@dst.dk> 2022-01-11 15:26 ` Re: Folding of case of identifiers Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: Niels Jespersen @ 2022-01-11 11:52 UTC (permalink / raw) To: pgsql-general Hello all 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). create table æblegrød (a int, køn text); create table ÆblegrØd (a int, køn text); create table ÆbleGrØd (a int, køn text); Can anyone explain the logic that rules this. Regards Niels Jespersen ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Folding of case of identifiers 2022-01-11 11:52 Folding of case of identifiers Niels Jespersen <NJN@dst.dk> @ 2022-01-11 15:26 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2022-01-11 15:26 UTC (permalink / raw) To: Niels Jespersen <NJN@dst.dk>; +Cc: pgsql-general Niels Jespersen <NJN@dst.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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-01-11 15:26 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-01-11 11:52 Folding of case of identifiers Niels Jespersen <NJN@dst.dk> 2022-01-11 15:26 ` Tom Lane <tgl@sss.pgh.pa.us>
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