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.96) (envelope-from ) id 1vVJw2-000R09-2G for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2025 01:33:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVJw0-003UkI-1r for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2025 01:33:05 +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.96) (envelope-from ) id 1vVJw0-003UkA-0o for pgsql-hackers@lists.postgresql.org; Tue, 16 Dec 2025 01:33:05 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVJvy-000xl2-0v for pgsql-hackers@postgresql.org; Tue, 16 Dec 2025 01:33:04 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2a0ac29fca1so19928765ad.2 for ; Mon, 15 Dec 2025 17:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765848780; x=1766453580; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=CUqf71Pu899Jqfa+RNUJtw2tPTKrNFVYnVtMnGAEz2g=; b=igQxNIYAK9VBp8q6Z3ErxoyAHQB8CZaXtEn0owrRRQh8RjxvtFHKC7iokEgQLckKUL vfpXMaOdEQw9RI3UvuNKp3Ib+8qEaspLaj7Wml/TEmuajF2TSYIGIuOe6Gg5V0wv8//s 7dB9HrtbYT9dPPsX75E/Ypg0P3NebIUbplv1zt04J9UNdCRR0N/39cubOmG/icLJVbKS pjgbC+k2Yc6Wmgy2py5RBFx5r6zraizRV4J6vlzLVjpLu+WSnTIZFwA6DydbERS6kVMK MUKMuBkR69xJRxdnnYpyvvNQ/sNIKifYFzvL/cyRwNiuvJRT+XFbvRp4v6ur+n7CVeXs kLOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765848780; x=1766453580; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CUqf71Pu899Jqfa+RNUJtw2tPTKrNFVYnVtMnGAEz2g=; b=Po5GAua3Nz/Pqy+poQAOAiKjJmgYalrYS8cYS51hyeZ9+1iIPi93rPs3n8fXLurGmY hdnuZ/HEZ7w8ZbdLlU28zKkdC+NrAxl69b2Sm62k2S6suuT3uLQmJv5OxLTwNEQts94i iE6T4MQ7yYWjQQ49mjobtwrGLQxmDlmY/NSBiUNNDjEM5COONa9TnEl2aP/N+Z1n75aJ O+OVnIFTDSJ56Aa8ASIt9Co2nlFkVnw3eREEdgux5TIkQOLG53dbFZvSFQk7DoCXKb/8 lyJa9SDlyayaejGCSsYEb/KTchf5e+iDp19GBdK+lnxPjBxQSyf//NdRHW53yrgXXesp HlpA== X-Forwarded-Encrypted: i=1; AJvYcCUE5bTJom3nujlhbuYes6hZ+EUyTJ7MxxhRwvFlmqsBh/bguiFobnSUw2YL1FJkhv4PKS659aUE1RStmibw@postgresql.org X-Gm-Message-State: AOJu0YwgJsWttq6VJd+HCMvlWvi301h6gSOUoXIhF1V+XQFJvroFRdLB v9yUA5e4jp/FBKpAdoxL+EBdMUwTtf+5FXRRcDDA0vvrrCBOQ+aZrZFT X-Gm-Gg: AY/fxX7qa7iq45BMTQ6y+Ri29OZrFNSoWpUOvm7/9bqDE/+lyVh/LsgacCuJSGugayY ZiYoZbIN/z7Pbjot1tIOs1a/AQgMuoQy3WxWmK/8nRtgAKvx/SlBRuFd70B+ww0Cah2N7GctrKb MoF0F1AkycI9jWA9FTOOa9Oj0Ytm2ZDwrORB7d8YPegHid4Pa49dEcRjJ6+ZDZa5vBOcqaVv2Fe qkNActxZcaj33UaXw2+VjI4viyoXj8THGCJ/7tzmbE0S+C2SiVeShrvV8NJpXDL6rUgMeqwV+KC 5NldadmhrLKQceR5SzMqjIwwWPXJxc+GhNQ8QJZyXkKkA+r8gDKNvEcLXnGgoeonwKGhQtHpAat HmKtSdwxKflPhcLrLo59oPEv1aG+HhHbZmRHe/6toWBuwo2I2yDCS9KmNHP70f9PMbHQBft9qvM 1xtyQ/TCZAz6pp7zJLCUc= X-Google-Smtp-Source: AGHT+IF60/gSce6lLWl3DfHdhZOXbJA2KYIoqhT0ymGYwNDOqkxphT3Pqc2bo3i4NUsn4oXLQDPcYg== X-Received: by 2002:a17:902:da8c:b0:2a0:bd93:4dbf with SMTP id d9443c01a7336-2a0bda2946cmr74644725ad.13.1765848779856; Mon, 15 Dec 2025 17:32:59 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a05689dcf9sm97771175ad.98.2025.12.15.17.32.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2025 17:32:59 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Remaining dependency on setlocale() From: Chao Li In-Reply-To: <5f70ee8a3f73df753285f8928c01dd32f14d7fcb.camel@j-davis.com> Date: Tue, 16 Dec 2025 09:32:09 +0800 Cc: Peter Eisentraut , Thomas Munro , Tom Lane , pgsql-hackers@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <651F79AB-8E21-4CDD-9A5A-221AC271265E@gmail.com> References: <4c5da86af36a0d5e430eee3f60ce5e06f1b5cd34.camel@j-davis.com> <6956823dd669abc64183fc91e64dc2e56e31f3ea.camel@j-davis.com> <8186b28a1a39e61a0d833a4c25a8909ebbbabd48.camel@j-davis.com> <450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com> <78edc741a168c54d57cc898a5877b6443527a2c8.camel@j-davis.com> <83F6E6A9-FF29-41C9-9E15-EA5360E912D0@gmail.com> <5f65b85740197ba6249ea507cddf609f84a6188b.camel@j-davis.com> <38f3f4a6-e95e-47a7-914f-110dd6191301@eisentraut.org> <0e186a9a92634f0c5675a618ff5685d00cd8f836.camel@j-davis.com> <0E8DD47F-710D-45E1-B87F-2336042A377E@gmail.com> <5f70ee8a3f73df753285f8928c01dd32f14d7fcb.camel@j-davis.com> To: Jeff Davis X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Dec 16, 2025, at 03:34, Jeff Davis wrote: >=20 > On Sat, 2025-12-13 at 17:48 +0800, Chao Li wrote: >> 1 - 0001 >> ``` >> + int match_mblen pg_attribute_unused(); >> ``` >>=20 >> Why this variable is marked unused? It=E2=80=99s actually used. >=20 > Fixed and committed. >=20 > I originally marked it unused because I just had an: >=20 > Assert(match[match_mblen] =3D=3D '\0'); >=20 > but I changed it to just set it: >=20 > match[match_mblen] =3D '\0'; >=20 > for clarity, even though I think the underlying API guarantees NUL- > termination. >=20 >> 2 - 0002 >>=20 >> I did a search and found one place that you missed at line 181 in >> pg_locale.h >> ``` >> extern bool char_is_cased(char ch, pg_locale_t locale); >> ``` >=20 > Thank you, fixed and committed. >=20 >=20 > I'll continue committing v12 0003-0005. Note that I'm planning to > backport 0003. I have re-reviewed 0003-0005 last week, they all look good to me. I have no comment on backport 0003. >=20 > I'm also inclined to move forward with 0006. It's not a long-term > solution, but it solves an instance of the problem under discussion in > this thread (removes setlocale() dependency) and is a narrow fix. >=20 >=20 > After that, remaining loose ends: >=20 > * 0007: Can we just rip out the non-ASCII support? If it's gone all > this time without UTF8 support, and there's no suggestion about what > the non-ASCII behavior should be (in docs or source code), then it's > probably not terribly important. >=20 > * Use of pg_strncasecmp() in the backend, which uses tolower() to do > case-insensitive matching of command options, e.g. "if > (pg_strcasecmp(a, "plain") =3D=3D 0)" to check for PLAIN storage in = CREATE > TYPE. >=20 > * strerror(): either consider an lc_ctype GUC, or the approach over > here[1]. >=20 > * Daniel suggests that we need some way to set LC_COLLATE for > extensions/dependencies. >=20 > * address calls to pg_tolower in datetime.c and tzparser.c -- can = those > just be pg_ascii_tolower()? >=20 > * examine remaining isalpha(), etc., calls in the backend >=20 > Regards, > Jeff Davis >=20 > [1] > = https://www.postgresql.org/message-id/flat/90f176c5b85b9da26a3265b2630ece3= 552068566.camel@j-davis.com >=20 I just reviewed 0006-0007. Only got one comment on 0006: ``` @@ -306,6 +342,7 @@ create_pg_locale_icu(Oid collid, MemoryContext = context) result =3D MemoryContextAllocZero(context, sizeof(struct = pg_locale_struct)); result->icu.locale =3D MemoryContextStrdup(context, iculocstr); result->icu.ucol =3D collator; + result->icu.lt =3D loc; ``` The old code didn=E2=80=99t create a locale object and store in result, = thus it didn=E2=80=99t have a logic to free the created locale. This = patch now dose that, but I don=E2=80=99t see where the created locale = object is free-ed. I suppose newlocale() will allocate memory from the = OS, so I guess the memory should be free-ed somewhere. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/