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 1rG6JN-00Dk1P-44 for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Dec 2023 23:49:13 +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 1rG6JL-000Xfn-Pn for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Dec 2023 23:49:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rG6IC-000Tai-Em for pgsql-hackers@lists.postgresql.org; Wed, 20 Dec 2023 23:48:00 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rG6I9-00BPMz-Md for pgsql-hackers@lists.postgresql.org; Wed, 20 Dec 2023 23:47:59 +0000 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-427941528d8so1022081cf.2 for ; Wed, 20 Dec 2023 15:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20230601.gappssmtp.com; s=20230601; t=1703116076; x=1703720876; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=Yf2y4HLFbo4as3AadY4gXTyTof7qVfjdOyqX1Zy/UtI=; b=Lde+ZdPV0yN6KVXl6Og99zG5777ivNkeTHMvFfv3LZ9f7F4gv2mypSV7C5S5PdZHCD tXY3LxhWephoA2yWiXohpdzyxP5ox8NZHn+sHsTvgl9n0GedgsnlhYZR5R0V8NRzEs8x e7+2zzXo+N8B4Or+P2Y4pXadDeEzfpsR6UKaJT3GmXo9xnxc6S7ES5z4aLqZTCSaICyp oobRpLqe4UeRfRCSGhyUQBFxgwBrPOFIFhm5LHDJIG7XNFtAB5khHU3RJMoe8A/qYkOP 3xsA/zZSX5YNvu5T7giBooC8+IgH0CpK00xWJxcz2KrTxc9j5WnjrKazA8Gy1DCSYXnw N97g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703116076; x=1703720876; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yf2y4HLFbo4as3AadY4gXTyTof7qVfjdOyqX1Zy/UtI=; b=VvPe0LTVnSW9Ol1vcnIb2mSjcwsXBANgGuZQbSGTlXVpZkg7TrAF3s5yHyO9y4cld5 w5UEnB0qNbFR3QI3Pli4zVR1ljzOLFbamHuY87UVS2JrkNfFItEztTtt/Q/V5Hy3pEUF jQjTLllOxJ33aQ3Id1heBc6BXR7d4g/NDO0QEZppcJiB8cDLs3UvZjlWQyhw/LeCiFI7 NPNQxNLDyiBIDgAWEkV90DnFmHi73Ym9Dzxu9h6GZxp52DAsRKTu8ImxJoazBfsaw7iw xi7bK8jviV8ibedNlMlOktWRyY+Zi/ieMbB4Nn8qm3m4ZIzQ1gvyhxNVm8kodSMT6FQX pLsA== X-Gm-Message-State: AOJu0Yzr/JwDme/6yWWy1KvcCmtnWgHRHbwjy4nxGv8Ap+ubveBYmXwK G2O8OyH4zHNnY6KsdhNf94FKWZWr244GiR2102A= X-Google-Smtp-Source: AGHT+IFaFAE7NDTFJV5hxwM+BmJUzr0gq3pWBz+kgOjGzfoEsKhnicRPwgqdCNKhPQpKSHbWPAbKoA== X-Received: by 2002:a05:622a:c8:b0:427:8115:f5c8 with SMTP id p8-20020a05622a00c800b004278115f5c8mr4015591qtw.30.1703116076163; Wed, 20 Dec 2023 15:47:56 -0800 (PST) Received: from [192.168.193.111] (54-240-198-34.amazon.com. [54.240.198.34]) by smtp.gmail.com with ESMTPSA id k7-20020ac84747000000b0041cb787ff41sm308161qtp.67.2023.12.20.15.47.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Dec 2023 15:47:54 -0800 (PST) Message-ID: <8a1ae216-8150-41e2-a98d-09c57e3dc90f@ardentperf.com> Date: Wed, 20 Dec 2023 15:47:51 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Built-in CTYPE provider To: pgsql-hackers@lists.postgresql.org, "Davis, Jeff" References: Content-Language: en-US From: Jeremy Schneider In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/5/23 3:46 PM, Jeff Davis wrote: > CTYPE, which handles character classification and upper/lowercasing > behavior, may be simpler than it first appears. We may be able to get > a net decrease in complexity by just building in most (or perhaps all) > of the functionality. > > === Character Classification === > > Character classification is used for regexes, e.g. whether a character > is a member of the "[[:digit:]]" ("\d") or "[[:punct:]]" > class. Unicode defines what character properties map into these > classes in TR #18 [1], specifying both a "Standard" variant and a > "POSIX Compatible" variant. The main difference with the POSIX variant > is that symbols count as punctuation. > > === LOWER()/INITCAP()/UPPER() === > > The LOWER() and UPPER() functions are defined in the SQL spec with > surprising detail, relying on specific Unicode General Category > assignments. How to map characters seems to be left (implicitly) up to > Unicode. If the input string is normalized, the output string must be > normalized, too. Weirdly, there's no room in the SQL spec to localize > LOWER()/UPPER() at all to handle issues like [1]. Also, the standard > specifies one example, which is that "ß" becomes "SS" when folded to > upper case. INITCAP() is not in the SQL spec. I'll be honest, even though this is primarily about CTYPE and not collation, I still need to keep re-reading the initial email slowly to let it sink in and better understand it... at least for me, it's complex to reason through. 🙂 I'm trying to make sure I understand clearly what the user impact/change is that we're talking about: after a little bit of brainstorming and looking through the PG docs, I'm actually not seeing much more than these two things you've mentioned here: the set of regexp_* functions PG provides, and these three generic functions. That alone doesn't seem highly concerning. I haven't checked the source code for the regexp_* functions yet, but are these just passing through to an external library? Are we actually able to easily change the CTYPE provider for them? If nobody knows/replies then I'll find some time to look. 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. (Kindof related... did you ever see the demo where I create a user named '🏃' and then I try to connect to a database with non-unicode encoding? 💥😜 ...at least it seems to be able to walk the index without decoding strings to find other users - but the way these global catalogs work scares me a little bit) -Jeremy -- http://about.me/jeremy_schneider