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 1seJEy-005wSI-1n for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 19:01:00 +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 1seJEw-00CHPj-BR for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 19:00:58 +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.94.2) (envelope-from ) id 1seJEv-00CHPb-Sr for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 19:00:58 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1seJEt-004kEL-9h for pgsql-hackers@postgresql.org; Wed, 14 Aug 2024 19:00:56 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1fc60c3ead4so1985335ad.0 for ; Wed, 14 Aug 2024 12:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1723662054; x=1724266854; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=q/zn58v7HDUSTEou0X+L6rcA51LLg6KQKaM2xMpiRnc=; b=TmBu1CiQgg3M6U2B43ykn3kp6RdzaiqUwsVwRKfC8PlU1en5uh3pK16HgD5LiPoJrt g2bcHpFqIxxo9387b07y7m+O6CB5jhLmukBcDoH0Fhe2MJ5zzjQ2z/gLdKK/OFxJLxl2 D0Oi5idEJ4nW3In3PRF+j3BOXsmFTiJp1Isx8EHj0zf7ShMsu75VzfRnjNsX5G0KnqXq 96K0A2iz4RtYpfSwcZaSZQGkv6gLo3xYIvjWQATtwM0+crJQiYTrsYM2ONi2NPKsuOnl wmZSELaFDyoAb3Az1T4Lj1OiM0XmghWkWBMwsZpN0IK3nvRWhsmQQrTKoxlwD85gQx4+ 39bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723662054; x=1724266854; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=q/zn58v7HDUSTEou0X+L6rcA51LLg6KQKaM2xMpiRnc=; b=S5cw+nKSkQRld6KIA8QR+BI4NBjVBqc2upgADAAD+jSNxGMacQc8lEofOzMglPqkB9 5GWvXRD7t5V3Gfoxc7p36eAJFrA4OKkhCkJ8ZxlbEqiT6UNMy8iJDOBUx6tE22mbgSGx JyHJD993O4W3YN+XCtD4bhMNHow72vwvhRU0j54AW3fxq3uEI2jbILU2geZzX+G9bcVy MYaddtmF72Ub3+notqR9dmUvbEB+y9qxDUypmBpVmStZdADDDkHQZUg3gJ7IDIvQU4Q5 KfeHrkgdYs5VNffiR4BQUSgskVV2Z1BYOii1PFPA4T54o6HOIo47szMcvf8psP38CisN aB2A== X-Forwarded-Encrypted: i=1; AJvYcCXuEPn6g93cI7SIxmuqR4H1qB7B1z3YtIfBhYUbxFNG1HEg8qWEdNJZZ70G1DCJqPbQg7EQAeCGY9bw8Qtavt1utSZx45VkEhUqhkbm X-Gm-Message-State: AOJu0YzJyyRVrVDH1L7sk/sbU//Y44Jn0lb2gjbd7RGxA+9P67sE7Xgd eIZXpW5JsclZXqJeNzZQAPSvsj++yMqs2ALiO2TzUcwX+T3Uvozo212HTF4L4g== X-Google-Smtp-Source: AGHT+IEZ4XdxT+AsXqrEmcCZL7a5GqQ2lfj8cZL5TFk8+av9ZfwE2L+X2BwkTEPfrzWxh8pSbwYeVw== X-Received: by 2002:a17:902:d4c5:b0:1ff:52c:34ce with SMTP id d9443c01a7336-201d64d01camr41404065ad.53.1723662053925; Wed, 14 Aug 2024 12:00:53 -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 d9443c01a7336-201cd1bcb65sm32638015ad.239.2024.08.14.12.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 12:00:53 -0700 (PDT) Message-ID: Subject: Re: Remaining dependency on setlocale() From: Jeff Davis To: Thomas Munro Cc: Tom Lane , pgsql-hackers@postgresql.org Date: Wed, 14 Aug 2024 12:00:52 -0700 In-Reply-To: References: <4c5da86af36a0d5e430eee3f60ce5e06f1b5cd34.camel@j-davis.com> <1841102.1722982989@sss.pgh.pa.us> 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-14 at 14:31 +1200, Thomas Munro wrote: > 1.=C2=A0 The process global locale is always "C".=C2=A0 If you ever call > uselocale(), it can only be for short stretches, and you have to > restore it straight after; perhaps it is only ever used in > replacement > _l() functions for systems that lack them.=C2=A0 You need to use _l() > functions for all non-"C" locales.=C2=A0 The current database default > needs > to be available as a variable (in future: thread-local variable, or > reachable from one), so you can use it in _l() functions.=C2=A0 The "C" > locale can be accessed implicitly with non-l() functions, or you > could > ban those to reduce confusion and use foo_l(..., LC_GLOBAL_LOCALE) > for > "C".=C2=A0 Or a name like PG_C_LOCALE, which, in backend code could be > just > LC_GLOBAL_LOCALE, while in frontend/library code it could be the > singleton mechanism I showed in CF#5166. +1 to this approach. It makes things more consistent across platforms and avoids surprising dependencies on the global setting. We'll have to be careful that each call site is either OK with C, or that it gets changed to an _l() variant. We also have to be careful about extensions. Regards, Jeff Davis