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 1sliBz-000jT5-QP for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Sep 2024 05:04:32 +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 1sliBy-004A0q-BT for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Sep 2024 05:04:30 +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 1sliBx-004A0g-Te for pgsql-hackers@lists.postgresql.org; Wed, 04 Sep 2024 05:04:30 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sliBv-000448-CW for pgsql-hackers@postgresql.org; Wed, 04 Sep 2024 05:04:29 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3df121f7088so3064609b6e.2 for ; Tue, 03 Sep 2024 22:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1725426265; x=1726031065; darn=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=kaHlLtCA0ZMRGbeA3b9Fb8lzf0j6Wk3jaKqEj91aLHY=; b=qTdf/rCtT9LgvMbDnSVR7Pf7U4T0BZy5tBwkduLXDBK5QW8g/d4iRagFRMs/hmPGjh Gm1Snl4uY/OAq6mRSoi3UmWvz4vPFZlzUQjuZ2Aq+NJAUlXVhMGkbg7xGqh0wGNCv+FZ aGmvmMATe7Azc8YkuGEn3tWxIfQqfjwodD5kb4/AV8JO0mXiQDenMf3cx4FsaLTziPrp caUYNY7+TcKzX7ELs97ya5yARLFmhTgVSP7YYF6qz10RCLIOw6eZ8IZSJbYIEahevBcK N0P3eIsJVAVDjs8K3EzI+DR5LwERCqcjS63fAsV87VAw2zTVSSmiMPsaKMNmcD+HAylY I4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725426265; x=1726031065; 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=kaHlLtCA0ZMRGbeA3b9Fb8lzf0j6Wk3jaKqEj91aLHY=; b=U2K7IPhlUw3IB59KKwKrWXG9SzW/QCWn6gdTinxSieAI3pHBibeb2NTTSnv0fjmA+1 uyGAHfjEzOpJv3BkViYi1HcPkUU6T8HAiBWbDZ3QaN90Uso8y8SGy/5qfMhHFeMl3O83 Suih78vIRGc/dT7OC63TwgCDZy7IHJ602HFNPESrRlFqE8qyzFB7D7PUq/qH0UuEYPK8 qqxQWedKdHjAypVhaDE+VWsA3joVamIUVum2+5jF0x/2C8x9Otb0F27omZPHA7pW5wnB xklKVyq9w9Bkr5b8cQTkGHtBtSwpUZCfWtXgcxoxpUQQR39kjZT7eR2OTXCQUZm85X0d 4o4w== X-Forwarded-Encrypted: i=1; AJvYcCUFaOXdEZ+VyD/f1lDbqV+XtLroCN0xvwbzAPee0bR1eHBh4OYpnDcOGs5Xp9mZ42m9Ui2X4Ik54cyAloXK@postgresql.org X-Gm-Message-State: AOJu0Ywj7BIvjM/lTrLDFo6tAoc3ihnU3VjV+8dwKx0SEaSuwlHfJz9g PRFAFmJdhYhaJvhk3GzRqkfFo7xMn0QQCNJzQRmlv2kIHcvp11xfPHScG9L6DFXFOi8Ox1/okFw = X-Google-Smtp-Source: AGHT+IEVZDmBEJho2xYuF1bYzCb6ivn5gqqi6o9ZpsdHF0JtTKDeqU+QkTHdL6VV1/3/Wkcwea/ZaA== X-Received: by 2002:a05:6870:5591:b0:260:eb3a:1be with SMTP id 586e51a60fabf-27800507bdemr9154517fac.34.1725426265167; Tue, 03 Sep 2024 22:04:25 -0700 (PDT) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778595107sm728167b3a.150.2024.09.03.22.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 22:04:24 -0700 (PDT) Message-ID: <82cc9fa110254fdf3b87aed9edd79de4a655fbdc.camel@j-davis.com> Subject: Re: tiny step toward threading: reduce dependence on setlocale() From: Jeff Davis To: Andreas Karlsson , Peter Eisentraut , pgsql-hackers@postgresql.org Date: Tue, 03 Sep 2024 22:04:23 -0700 In-Reply-To: <60929555-4709-40a7-b136-bcb44cff5a3c@proxel.se> References: <2228884bb1f1a02614b39f71a90c94d2cc8a3a2f.camel@j-davis.com> <239b7ef6ce058c6b1c77b3a0cfcc70c1cd8968b1.camel@j-davis.com> <56af65bde2190cc5ee20c807be7b7bdcda54f40c.camel@j-davis.com> <468dd1fb-20f5-4213-bc70-d1388ccf28fa@proxel.se> <59ea4275d75829a055fc55d8fe139eb85764cf2b.camel@j-davis.com> <89475ee5487d795124f4e25118ea8f1853edb8cb.camel@j-davis.com> <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com> <96d51fbb8b6f338a210cee97abb63c0162bcb781.camel@j-davis.com> <69c2a864-846f-4309-bd5a-aaa1c34f9a11@proxel.se> <96a559be83329bc66074a3925ebcfa8ceb16dfc5.camel@j-davis.com> <60929555-4709-40a7-b136-bcb44cff5a3c@proxel.se> 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, 2024-08-28 at 18:43 +0200, Andreas Karlsson wrote: > On 8/15/24 12:55 AM, Jeff Davis wrote: > > This overlaps a bit with what Peter already proposed here: > >=20 > > https://www.postgresql.org/message-id/4f562d84-87f4-44dc-8946-01d6c4379= 36f%40eisentraut.org > >=20 > > right? >=20 > Maybe I am missing something but not as far as I can see. It is > related=20 > but I do not see any overlap. v2-0002: Oh, I see, pattern_char_isalpha() only has one caller, and it never passes a NULL for pg_locale_t, so my complaint doesn't affect your patch. This is about ready, then. > > > 0003-Remove-dubious-check-against-default-locale.patch > > >=20 > > > This patch removes a check against DEFAULT_COLLATION_OID which I > > > thought > > > looked really dubious. Shouldn't this just be a simple check for > > > if > > > the > > > locale is deterministic? Since we know we have a valid locale > > > that > > > should be enough, right? > >=20 > > Looks good to me. The code was correct in the sense that the > > default > > collation is always deterministic, but (a) Peter is working on non- > > deterministic default collations; and (b) it was a redundant check. >=20 > Suspected so. >=20 > I have attached a set of rebased patches with an added assert. Maybe > I=20 > should start a new thread though. v2-0001: * There was a performance regression for repeated lookups, such as a "t < 'xyz'" predicate. I committed 12d3345c0d (to remember the last collation lookup), which will prevent that regression. * This patch may change the handling of collation oid 0, and I'm not sure whether that was intentional or not. lc_collate_is_c(0) returned false, whereas pg_newlocale_from_collation(0)->collate_is_c raised Assert or threw an cache lookup error. I'm not sure if this is an actual problem, but looking at the callers, they should be more defensive if they expect a collation oid of 0 to work at all. * The comment in lc_collate_is_c() said that it returned false with the idea that the caller would throw a useful error, and I think that comment has been wrong for a while. If it returns false, the caller is expected to call pg_newlocale_from_collation(), which would Assert on a debug build. Should we remove that Assert, too, so that it will consistently throw a cache lookup failure? Regards, Jeff Davis