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 1uRwHh-0013oc-B4 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jun 2025 17:09: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 1uRwHe-0033uW-LP for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jun 2025 17:09:11 +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 1uRwHe-0033uO-A8 for pgsql-hackers@lists.postgresql.org; Wed, 18 Jun 2025 17:09:11 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRwHc-002nNB-2C for pgsql-hackers@postgresql.org; Wed, 18 Jun 2025 17:09:10 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5891543137; Wed, 18 Jun 2025 17:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgresfriends.org; s=gm1; t=1750266546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w/l3fylE/9yV912FXyWbtE6QNAMNj0tYMLnUv0hVybs=; b=R66hp3SM2fMTRfR/bTCjysrztmQwgkgSQ9xTSJw4R/m8vHxzQBaJ386Wj6NkhTkvgVcoC4 t6DPMtjNM5n0MPtPORo6WIDtU3CajVnx3/znL5GsCNOIU58Mv3ufLUijbU8bfpVt6OW9Ty 9U+pVsrJ2gBUOsJU0McULTo2/1UW8lXVDrCPyAGtfS5mrqHtfaj/k9SEAyrqvcRqVh08yZ 9jlxZT0SfUa2N1ryb/V0j5HP64F5HtLrsAfvXWwp7p5+pMIRlcuPFxtl2IZJR0RQFE5dpZ TmCxvAV+RsU1fXCIH8VjVxaewPRhbWu9AUCCRuESwaoUrGyQBXTivG20fmemzg== Message-ID: <692d28a2-d5f8-4db5-a3ad-c7db9bab522f@postgresfriends.org> Date: Wed, 18 Jun 2025 19:09:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add CASEFOLD() function. To: Jeff Davis , Joe Conway , Ian Lawrence Barwick Cc: pgsql-hackers@postgresql.org, Peter Eisentraut References: <47716a78-eb0b-4728-8991-fc0d958a01c9@joeconway.com> <36f69fa9-db3f-44a1-8c8a-95ff09704a9c@postgresfriends.org> Content-Language: en-US From: Vik Fearing In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgdefvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepgghikhcuhfgvrghrihhnghcuoehvihhksehpohhsthhgrhgvshhfrhhivghnughsrdhorhhgqeenucggtffrrghtthgvrhhnpedutdevfeelgedvuddtjefhhfelhefhveehieelhfegtedtuefhtdffgedvgfetffenucfkphepudelfedrfedvrdduvdeirdduieeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelfedrfedvrdduvdeirdduieeipdhhvghloheplgdutddrudefgedruddthedrkeekngdpmhgrihhlfhhrohhmpehvihhksehpohhsthhgrhgvshhfrhhivghnughsrdhorhhgpdhnsggprhgtphhtthhopeehpdhrtghpthhtohepphhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphhtthhopehmrghilhesjhhovggtohhnfigrhidrtghomhdprhgtphhtthhopegsrghrfihitghksehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhg X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 17/06/2025 20:14, Jeff Davis wrote: > On Tue, 2025-06-17 at 17:37 +0200, Vik Fearing wrote: >> If the character set of is UTF8, UTF16, or UTF32, >> then FR is replaced by >>      Case: >>          i) If the S IS NORMALIZED evaluates to >> True, then NORMALIZE (FR) >>          ii) Otherwise, FR. > I read that as "if the input is normalized, then the output should be > normalized", IOW preserve the normalization. But does it mean "preserve > whatever the input normal form is" or "preserve NFC if the input is > NFC, otherwise the normalization is undefined"? > > The above wording seems to mean "preserve NFC if the input is NFC", > because that's what NORMALIZE(FR) does when the normal form is > unspecified. Yes, and that is also the default for . >> It does not appear to me that our LOWER and UPPER functions obey this >> rule, > You are correct: > > WITH s(t) AS > (SELECT NORMALIZE(U&'\00C1\00DF\0301' COLLATE "en-US-x-icu")) > SELECT UPPER(t) = NORMALIZE(UPPER(t)) FROM s; > ?column? > ---------- > f > >> so there is a valid argument that we should continue to ignore it. >> Or, we can say that we have at least one of three compliant. > What do other databases do? I don't know.  I am just pointing out what the Standard says.  I think we should either comply, or say that we don't do it for LOWER and UPPER so let's keep things implementation-consistent. > Given how costly normalization can be, imposing that on every caller > seems like a bit much. How much does it cost to check for NFC?  I honestly don't know the answer to that question, but that is the only case where we need to maintain normalization. > And favoring NFC for the user unconditionally > might not be the best thing. Then again, NFC is good most of the time, > and there are patches to speed up normalization. It's not unconditionally, it's only if the input was NFC. > I tend to think that a lot of users who want casefolding would also > want normalization, but it's hard to weigh that against the performance > cost. It might not matter outside of a few edge cases, though I'm not > sure exactly how many. I defer to you and others in the thread to make this decision. -- Vik Fearing