Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNEYl-0004Z4-9C for pgsql-bugs@arkaria.postgresql.org; Sun, 14 Aug 2022 14:25:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oNEYj-0005o7-6S for pgsql-bugs@arkaria.postgresql.org; Sun, 14 Aug 2022 14:25:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNEYi-0005ny-UM for pgsql-bugs@lists.postgresql.org; Sun, 14 Aug 2022 14:25:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNEYc-0004Jh-3p for pgsql-bugs@lists.postgresql.org; Sun, 14 Aug 2022 14:25:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27EEPWqr651208; Sun, 14 Aug 2022 10:25:33 -0400 From: Tom Lane To: Peter Geoghegan cc: James Inform , PostgreSQL mailing lists , Euler Taveira Subject: Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation In-reply-to: References: <17584-95c79b4a7d771f44@postgresql.org> <465044.1660428315@sss.pgh.pa.us> <92087cd5-5410-a4e9-41fe-4ff310439190@pharmapp.de> <541938.1660437017@sss.pgh.pa.us> <555147.1660447264@sss.pgh.pa.us> <559703.1660450255@sss.pgh.pa.us> <587801.1660457745@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Sat, 13 Aug 2022 23:31:06 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <651206.1660487132.1@sss.pgh.pa.us> Date: Sun, 14 Aug 2022 10:25:32 -0400 Message-ID: <651207.1660487132@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Geoghegan writes: > On Sat, Aug 13, 2022 at 11:15 PM Tom Lane wrote: >> How can we only be reaching this function with sss->collate_c true >> when the prevailing locale isn't that? > We don't trust libc's strxfrm() following the debacle with > locale-aware abbreviated keys back in 2016 (unless the user builds > their own Postgres, and goes out of their way to #define > TRUST_STRXFRM). So the relevant strxfrm() code is arguably dead code. > > ICU is different: our policy with ICU locales has always been to trust > ICU's strxfrm()-like function to agree with ICU's strcoll()-like > function. Ah ... so that explains the OP's observation that this is only seen with ICU locales. When I build with --with-icu and run coverage testing on the core regression tests under LANG=en_US.utf8, I see that most of varstr_abbrev_convert() is reached, but *not* the two buggy buffer-enlargement stanzas. So that explains why we've not seen this in testing. I wonder whether there is a reasonably cheap way to test that. The submitted test case is clearly out of the question to add as a regression test... regards, tom lane