Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGS1r-00FM8K-Tb for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Dec 2023 23:00:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rGS1p-00G40B-QF for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Dec 2023 23:00:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGS1p-00G403-Gc for pgsql-hackers@lists.postgresql.org; Thu, 21 Dec 2023 23:00:33 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rGS1n-00DFZ0-6l for pgsql-hackers@lists.postgresql.org; Thu, 21 Dec 2023 23:00:32 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d3eae5c1d7so9428795ad.2 for ; Thu, 21 Dec 2023 15:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1703199629; x=1703804429; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=qQ1tTDp0o4gYPeV7VevuVYqVmqs5DBmAXkpO9q+r2tk=; b=qgFngr93+3oWrOj9UerfY0hOXlkKmtktmkUsaOtbcMLSuU1Dwgc9LynUN79tJKtvE0 InTYQhuOoltELN7xh38M4bC5nPAJAP5SzLdwtKCORChCWRlUuG4wrdFBxPlFgeEVjyRp iIjA+YpnlS1WJxD8w228fRhwD+ToQ228MGmSObx6UyYe9llENIPAAqxSJRbaIwbwjmnG IwzmMBPO1oJMqGlldf/VwUY+FuWB/lDOOm3wf01dwxRQe693IyfYPt+IcUmOhHNCXgmp 38MiXa6ZbfQ5XvJA2H1mLT9RxJg2yJqmUPxt6P8NjYBlpdb+uMreO9CyLrEJEPeMEqvN snqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703199629; x=1703804429; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qQ1tTDp0o4gYPeV7VevuVYqVmqs5DBmAXkpO9q+r2tk=; b=c3kvhfpI0Xi5s/+tnIyYbv9tWpxrRGh7yzwNZaHY77cYN4OQbbXWfnBhgn6q2CXQht p+GePULSg1MEa0JtOGM/V2egTt+U8tJHQ1Dxgnb+1YiffZLQEZPi7gF8GUwZCsrwjlOQ aIdg0RPQlwqSl9g/NQE03K3uQU5YeDFimvixjzU0sWcgegHFB2UWY+ZwTdSEzdKkPVio oIZA3fYvpjnTHR1xqTMeXOSAYN0sML9tfGHf6VD2F7wJcSwpE992LuB95FDq+SvLmEJF MZXbfc4kKZAlmgcEvxxzAYL8tDucibZqh8q/1bhy9PRDHIRhmnWT9aBTDOk+AqgVaHYm dUtw== X-Gm-Message-State: AOJu0Yy1s1W6Hct/BvZqFR4mSOkZXYPJDSjii/ZCQTMr0ytlj5erSozD 3TLvEJ97brUJwVn/7j6pvOtlVzruFbOy X-Google-Smtp-Source: AGHT+IFk7ewTcIKWPBDcAH5yr0mzp/fhqprPRmr+WDId4EvIiScJJwDhoKTrpZAP3t1MMPQiOfRxcA== X-Received: by 2002:a17:902:ba81:b0:1d0:c986:8aae with SMTP id k1-20020a170902ba8100b001d0c9868aaemr311882pls.97.1703199628741; Thu, 21 Dec 2023 15:00:28 -0800 (PST) Received: from [172.18.10.36] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id x2-20020a170902ea8200b001d3ef57d937sm2176901plb.18.2023.12.21.15.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 15:00:28 -0800 (PST) Message-ID: Subject: Re: Built-in CTYPE provider From: Jeff Davis To: Jeremy Schneider , pgsql-hackers@lists.postgresql.org, "Davis, Jeff" Date: Thu, 21 Dec 2023 15:00:26 -0800 In-Reply-To: <8a1ae216-8150-41e2-a98d-09c57e3dc90f@ardentperf.com> References: <8a1ae216-8150-41e2-a98d-09c57e3dc90f@ardentperf.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2023-12-20 at 15:47 -0800, Jeremy Schneider wrote: > One other thing that comes to mind: how does the parser do case > folding > for relation names? Is that using OS-provided libc as of today? Or > did > we code it to use ICU if that's the DB default? I'm guessing libc, > and > global catalogs probably need to be handled in a consistent manner, > even > across different encodings. The code is in downcase_identifier(): /* =20 * SQL99 specifies Unicode-aware case normalization, which we don't=20 * yet have the infrastructure for... */ if (ch >=3D 'A' && ch <=3D 'Z') ch +=3D 'a' - 'A'; else if (enc_is_single_byte && IS_HIGHBIT_SET(ch) && isupper(ch)) ch =3D tolower(ch); result[i] =3D (char) ch; My proposal would add the infrastructure that the comment above says is missing. It seems like we should be using the database collation at this point because you don't want inconsistency between the catalogs and the parser here. Then again, the SQL spec doesn't seem to support tailoring of case conversions, so maybe we are avoiding it for that reason? Or maybe we're avoiding catalog access? Or perhaps the work for ICU just wasn't done here yet? > (Kindof related... did you ever see the demo where I create a user > named > '=F0=9F=8F=83' and then I try to connect to a database with non-unicode > encoding? > =F0=9F=92=A5=F0=9F=98=9C=C2=A0 ...at least it seems to be able to walk th= e index without > decoding > strings to find other users - but the way these global catalogs work > scares me a little bit) I didn't see that specific demo, but in general we seem to change between pg_wchar and unicode code points too freely, so I'm not surprised that something went wrong. Regards, Jeff Davis