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 1sbRux-00GeML-Px for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Aug 2024 21:40:31 +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 1sbRuv-0030b2-Ds for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Aug 2024 21:40:29 +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 1sbRuv-0030Zc-4z for pgsql-hackers@lists.postgresql.org; Tue, 06 Aug 2024 21:40:29 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbRuo-003Why-Sl for pgsql-hackers@postgresql.org; Tue, 06 Aug 2024 21:40:28 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7a10b293432so966596a12.0 for ; Tue, 06 Aug 2024 14:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1722980420; x=1723585220; 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=dshWYJkzLWs8NQ/TTQWEwM0RPf8ZZFzhJPwDHrzMr2Y=; b=c6zYIe/gpcU/WC4p23k76Df3cprNsN6M4qIKeckWUDUdFiNvCRx+/aowdZ8iHVRCw9 hGI78Lb6f2k+cyOaVeSxk0+9qVe87RDQA74ooth77q0VnQVWBWmNOk3QNRd/5mEIkVfh +f+mNjOIksct+Oa68rmXCsse+/09uGSRb/VVXfKErliW2ss5GvefaueUWTteuimP3fXW 4WVu8Nw8ZWj1sj4kcEgv11KcmDvMJKAI9eujv6wZ8IP6TDg1GFTeMYgyE/02HBBbK2hv Me0KCQCg9zaiYHmkvGgsYAZd7ayEySp6YrYYkgAGmaJbp66nXZQNo5aIXCUFlMaVEiWI 6sWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722980420; x=1723585220; 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=dshWYJkzLWs8NQ/TTQWEwM0RPf8ZZFzhJPwDHrzMr2Y=; b=tn1GQxzrnOJaJ//LbOrxWh4HJbmQB1V+mPoRHmQHIyZxuX4A+2kr/uMZCD1TkFB2yI AyU8jBLrfC1xplduWofUcc0oco67aOlabGoNEFRcna/aIowmjIeygJ+qqFmhOLx6nCuh KV8qR4tyZQUS4c2SsEjzyUJ24+fNI3vcSFT/2CnRdp/kgD5ycOVpwIk6vnJ1Qi6R3pkm Dv5BxF8EGzjC+BaXHpMKr3tlA9IHQeKGGl2vhveTl044Pm/fhqBDcgoYiXCWSsY3g0wn juLXrswkH3Xj5+OnaAJIrK7r7zRHDe83BhdOMCHpZvNzxPe0dmDItzr28y77hDMBS6xq Ip/w== X-Forwarded-Encrypted: i=1; AJvYcCU+9FBiVTPu8/WTGd+0Mq/0ME+J5jiCQu9PGQ0+IH0T8/vbmcx2eSYNCCcWsSSnQQmrjpQTI8W8q34ITffH@postgresql.org X-Gm-Message-State: AOJu0YypjDaYsFaOWcQBOYczdMTXgZf1fpPyTzfjuMk2GNHR5PGWkSPm 5rDA1RWCOeC7dUrT9y1LLoFuvSklWRWqdawaCSJMeP2xuuZ9dxCQshCJIFi4NiSQcQzem9rZyt0 = X-Google-Smtp-Source: AGHT+IFoZu/ycPK4/UHTU6ZfyY1h0R/oQpyQ4pc2Dzs8NGLXwSlOtbn/20SXqppv7dmM/gXCSU9izg== X-Received: by 2002:a05:6a20:914f:b0:1c2:956a:a909 with SMTP id adf61e73a8af0-1c6995a5fbbmr18914358637.27.1722980420120; Tue, 06 Aug 2024 14:40:20 -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 41be03b00d2f7-7b7654bf910sm7288545a12.79.2024.08.06.14.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 14:40:18 -0700 (PDT) Message-ID: <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com> Subject: Re: tiny step toward threading: reduce dependence on setlocale() From: Jeff Davis To: Peter Eisentraut , Andreas Karlsson , pgsql-hackers@postgresql.org Date: Tue, 06 Aug 2024 14:40:17 -0700 In-Reply-To: <89475ee5487d795124f4e25118ea8f1853edb8cb.camel@j-davis.com> 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> 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 Tue, 2024-07-30 at 12:13 -0700, Jeff Davis wrote: > I found a couple issues with the later patches: >=20 > * There was still some confusion about the default collation vs. > datcollate/datctype for callers of wchar2char() and char2wchar() > (those > functions only work for libc). I introduced a new pg_locale_t > structure > to represent datcollate/datctype regardless of datlocprovider to > solve > this. I didn't quite like the API I introduced in 0001, so I skipped 0001. For 0002 I left char2wchar() and wchar2char() as-is, where they expect libc and accept a NULL pg_locale_t. I committed the rest of 0002. > * Another loose end relying on setlocale(): in selfuncs.c, there's > still a call directly to strxfrm(), which depends on setlocale(). I > changed this to lookup the collation and then use pg_strxfrm(). That > should improve histogram selectivity estimates because it uses the > correct provider, rather than relying on setlocale(), right? Committed 0003. With these changes, collations are no longer dependent on the environment locale (setlocale()) at all for either collation behavior (ORDER BY) or ctype behavior (LOWER(), etc.). Additionally, unless I missed something, nothing in the server is dependent on LC_COLLATE at all. There are still some things that depend on setlocale() in one way or another: - char2wchar() & wchar2char() - ts_locale.c - various places that depend on LC_CTYPE unrelated to the collation infrastructure - things that depend on other locale settings, like LC_NUMERIC We can address those as part of a separate thread. I'll count this as committed. Regards, Jeff Davis