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 1vNi7c-00BcuI-2E for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 01:45:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNi7b-005p0T-0Y for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 01:45:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNi7a-005p0L-2j for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 01:45:35 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vNi7Y-001Ije-1x for pgsql-hackers@postgresql.org; Tue, 25 Nov 2025 01:45:34 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7aad4823079so4320702b3a.0 for ; Mon, 24 Nov 2025 17:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764035132; x=1764639932; 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=i+NK7Sl4GEPqPaxfT937aQC+IdWdqiOrZ5/TEwt99NE=; b=lLfhLgD2MKO0rKlWH8btnyVlWAi7+P4H7Ak8a6viQVNy7uxNxmltWDuzfV/CKK2H+3 MNV1TPN2aTHVFfA7T0xlHZD6sUaPk6AG8sqS1kO0J4M0wc+M1qRNtCuT1tbw9v3tCBTB 4h+wylY6WxxAI+hFjbgV08/hQNbfd2kS5bahJrtZTAl72e0LS5hFR+m69NFZ/Loi2qrh ulGoAlZpxuy4K8CdeSl1lAU0K5Bn/Klijzs5V3lei3ReB9CHl1kubBJFOaMZk4+TCrFI tzWF9uQO9Xw9SKG5DQRZw27dJnox7+hP/uRDStyWTEJAkZisQ9X4/3+QR9fKoNs763T/ fMgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764035132; x=1764639932; 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=i+NK7Sl4GEPqPaxfT937aQC+IdWdqiOrZ5/TEwt99NE=; b=nvNHa00+stvu+FMMOxNTmMA0+tKycIVO5MuDurEUY+aihKdwpQLvLbnPxX3FSo38nL W+YbMXtx0STYjiz0Aa8vw/4AfE8vswbfAPENqybosFvCqiV4e6GmI4Hs+6X6ZqcSTR53 3zlhD/YhDBlLxH6HHsRcQClfX2p7/ZrDxenAptkrHK7HGTKsPzRdzSMuin7jqsIh7i3n 0NUPjqsQggDLsGClYQGOCKlVwtJbQTDfyOK6yovIrwQjxmRvNMyILw1oEkVTr3QMAFjU bLtequVjRcKxIMIZJ3kOY4qmgLXe2g+iOZNhK2DE151mxHNQJ609IlxTGih2BQuGA2B6 mcKw== X-Forwarded-Encrypted: i=1; AJvYcCXB22EsmWUQLQmi3mDIucJOTHgJAPSKWzzOYEDOYZIgvOVprxl2xWrNDK+2ZQQUShx04TozQB/UL5KR4k2q@postgresql.org X-Gm-Message-State: AOJu0Yxd/NT9cFvcXEdRdBhMp/lQUNO9Xs1D5MJAXPLsgIfGcxR/IT+d 5Caz+XBadvbO9qJdf48z0GeSTzB4i2uIQ9fNAHVtzWX3AFdk2e3L2wAQ2PH4dyW3wsI= X-Gm-Gg: ASbGncukYgAmMxJ3++2/DRCAmqkTuhKyJmV49wLkZqXQgsth8AM7nYPh15rckaVYzfT oGjbopiMLE+vZncVistmQCF9HTPTVgnMBC9Z/i4+8+Ei8O03Gk17rj1DUgTG5o3E5lIC0RccNQi ZmviG3bEIOEHm90KjXkOobNxOtvO9PYDzx0wMuPua8gSOMpM65yhmZRlfPvdAv5zauwUPapBxkQ loNnxKTk5h05DicMlDLEEj33++ftHnA7mwpf9MdIwquy6Z8P/htkZggBNemkI+0l8bAL8Lp1paf R+PsdvzfMAIgf47yDsTWnnsrCiykTHN195pK/nxHoFKbTjM/YprjOxhKNIst8Hqdpin+VIR9+Ni DQXVJrYu0c/G7k+LruRFacadLKow6q8BY1SQRFHcoJpMFTk7k3qnwq07xLSBasTl1Uy4k5GXBxu Keq0CRRn9DbJmIEmDWX16yJZYP4ycaFg== X-Google-Smtp-Source: AGHT+IG/SN2EJNf9tHxgV8lgGKts7ffbt5nGrDTwY5NOQdjSPysj9837v144O92GIvKliG/hTHKE1w== X-Received: by 2002:a05:6a20:9389:b0:35f:b96d:af11 with SMTP id adf61e73a8af0-36150e1fc44mr13597893637.5.1764035132387; Mon, 24 Nov 2025 17:45:32 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f0243b2fsm15875921b3a.32.2025.11.24.17.45.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2025 17:45:31 -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: <450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com> Date: Tue, 25 Nov 2025 09:44:51 +0800 Cc: Peter Eisentraut , Thomas Munro , Tom Lane , pgsql-hackers@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <4c5da86af36a0d5e430eee3f60ce5e06f1b5cd34.camel@j-davis.com> <9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org> <6956823dd669abc64183fc91e64dc2e56e31f3ea.camel@j-davis.com> <8186b28a1a39e61a0d833a4c25a8909ebbbabd48.camel@j-davis.com> <450ceb6260cad30d7afdf155d991a9caafee7c0d.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 Hi Jeff, I have reviewed 0001-0004 and got a few comments: > On Nov 25, 2025, at 07:57, Jeff Davis wrote: >=20 >=20 > 0001-0004: Pure refactoring patches. I intend to commit a couple of > these soon. >=20 1 - 0001 ``` +/* + * Fold a character to upper case, following C/POSIX locale rules. + */ +static inline unsigned char +pg_ascii_toupper(unsigned char ch) ``` I was curious why =E2=80=9Cinline=E2=80=9D is needed, then I figured out = when I tried to build. Without =E2=80=9Cinline=E2=80=9D, compile will = raise warnings of =E2=80=9Cunused function=E2=80=9D. So I guess it=E2=80=99= s better to explain why =E2=80=9Cinline=E2=80=9D is used in the function = comment, otherwise other readers may get the same confusion. 2 - 0002 ``` + * three output codepoints. See Unicode 5.18.2, "Change in Length". ``` With =E2=80=9Cchange in length=E2=80=9D, I confirmed =E2=80=9CUnicode = 5.18.2=E2=80=9D means the Unicode Standard Section 5.18.2 = =E2=80=9CComplications for Case Mapping=E2=80=9D. Why don=E2=80=99t we = just give the URL in the comment. = https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-5/#G29675= 3 - 0004 ``` @@ -1282,10 +1327,18 @@ size_t pg_strfold(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale) { - if (locale->ctype->strfold) - return locale->ctype->strfold(dst, dstsize, src, srclen, = locale); - else - return locale->ctype->strlower(dst, dstsize, src, = srclen, locale); + if (locale->ctype =3D=3D NULL) + { + int i; + + srclen =3D (srclen >=3D 0) ? srclen : strlen(src); + for (i =3D 0; i < srclen && i < dstsize; i++) + dst[i] =3D pg_ascii_tolower(src[i]); + if (i < dstsize) + dst[i] =3D '\0'; + return srclen; + } + return locale->ctype->strfold(dst, dstsize, src, srclen, = locale); } ``` I don=E2=80=99t get this change. In old code, depending on = locale->ctype->strfold, it calls strfold or strlower. But in this patch, = it only calls strfold. Why? If that=E2=80=99s intentional, maybe better = to add a comment to explain that. 4 - 0004 In pg_strfold, the ctype=3D=3DNULL fallback code is exactly the same as = pg_strlower. I guess you intentionally to not call pg_strlower here for = performance consideration, is that true? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/