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 1n5JYo-0001zf-Mf for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Jan 2022 03:35:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n5JYm-0005M5-TP for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Jan 2022 03:35:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5JYm-0005Lv-Is for pgsql-hackers@lists.postgresql.org; Thu, 06 Jan 2022 03:35:28 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n5JYg-0007jZ-2t for pgsql-hackers@postgresql.org; Thu, 06 Jan 2022 03:35:27 +0000 Received: by mail-pg1-x532.google.com with SMTP id i8so1416485pgt.13 for ; Wed, 05 Jan 2022 19:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tTgz22ht1Xi5/43iXBIon6KNnElblwcoP9th8iqETAM=; b=OCFb6UV/Yg05447HPxEcv3A+NadKj/9LJv3alswdBNut7GS6zMBN9LnDbaeZAHuord 3va4IzwEKy19PfZPnK5NDETdOI2sKNgL6WdNVhBKVaMtC0L6MaovpV1cMK6DzNaArRic AxxRHWQjj/Gue8P549Yy/0JcJuY1F2Exf8Z+oJ97yVvWZMJ/2H6OWbZlQbNJVWb7qnuo DGl/9eMF64cryMvje7yKPBn1LnJEGiJ6J8wIOp62tAHvqyHk+66vJZ0WwGS1oIBnBL9L nXdV40+mRdCDXxpUov6cAmv7cloKL/tsoAfyWn1hpL11X8Sy6Ti4IPsRw/cyyKE8o/sh nayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tTgz22ht1Xi5/43iXBIon6KNnElblwcoP9th8iqETAM=; b=Z2pMQLWW8X6bRzkOIC/BcH1AAS1wNX9HFyofSC5ALLQaAKGc2mE902TrR4UzABefrO Xgna8TjmfeY80JtZ3XHKpHBy58fXLcA0VB5iOeqYGlQEthaQREyfteAQuetg9B5vg/3P w21XXyErHpeXzD75J/xGyuBQmVovGRgmwKQd3Enpi1zB5nXxfKG8J+7Dl5jY6z4te835 lEUVsiC8gukRA7htYJwoGNfVww7MhDrtIU4B06/3wQn9eNuo0UqK4gxwVcE2zjkH6LlF fYKO8zTo9PcLBUmcFgVrnYVgI2TOKTU77ZzARGNRV9bKHJTVhqyTBc0doRPYNCbLsidT Mo+g== X-Gm-Message-State: AOAM532zTAVP7a1GXxojOh5BHi4blK1gIUlD5Gcj1OVrNGhj2JRDjHuY 8jf9VIzTk18vWh/jUbMagutTgXW9dUE= X-Google-Smtp-Source: ABdhPJxBTxjbe7asBTYo5Z/GaejD+c/ZZmQMZHYAwMZajZehdQNY5ieY2CIo9dUV8AWKCHiuf5e0Qg== X-Received: by 2002:a63:ce4c:: with SMTP id r12mr51125885pgi.21.1641440119716; Wed, 05 Jan 2022 19:35:19 -0800 (PST) Received: from jrouhaud (1-171-187-20.dynamic-ip.hinet.net. [1.171.187.20]) by smtp.gmail.com with ESMTPSA id nu14sm424289pjb.17.2022.01.05.19.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 19:35:18 -0800 (PST) Date: Thu, 6 Jan 2022 11:35:14 +0800 From: Julien Rouhaud To: Peter Eisentraut Cc: pgsql-hackers , Daniel Verite Subject: Re: ICU for global collation Message-ID: References: <374f8048-9d87-462c-a8aa-d02ffca6525f@manitou-mail.org> <525ef44f-52bf-505f-a491-07835d039424@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jan 04, 2022 at 05:03:10PM +0100, Peter Eisentraut wrote: > On 04.01.22 03:21, Julien Rouhaud wrote: > > > > - if (!lc_collate_is_c(collid) && collid != DEFAULT_COLLATION_OID) > > > - mylocale = pg_newlocale_from_collation(collid); > > > + if (!lc_collate_is_c(collid)) > > > + { > > > + if (collid != DEFAULT_COLLATION_OID) > > > + mylocale = pg_newlocale_from_collation(collid); > > > + else if (default_locale.provider == COLLPROVIDER_ICU) > > > + mylocale = &default_locale; > > > + } > > > > There are really a lot of places with this new code. Maybe it could be some > > new function/macro to wrap that for the normal case (e.g. not formatting.c)? > > Right, we could just put this into pg_newlocale_from_collation(), but the > comment there says > > * In fact, they shouldn't call this function at all when they are dealing > * with the default locale. That can save quite a bit in hotspots. > > I don't know how to assess that. > > We could pack this into a macro or inline function if we are concerned about > this. Yes that was my idea, just have a new function (inline function or a macro then since pg_newlocale_from_collation() clearly warns about performance concerns) that have the whole is-not-c-collation-and-is-default-collation-or-icu-collation logic and calls pg_newlocale_from_collation() only when needed.