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 1tLolM-00HF0X-Go for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 19:22:16 +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 1tLolK-00E2Co-1m for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 19:22:15 +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 1tLolJ-00E2CK-Ng for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2024 19:22:14 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tLolI-002Vs7-3k for pgsql-hackers@postgresql.org; Thu, 12 Dec 2024 19:22:14 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-728f337a921so1098760b3a.3 for ; Thu, 12 Dec 2024 11:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1734031331; x=1734636131; 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=XHVXDhZly5oo+AlSMxPkA6cSfsFaF41Si7YOZGFGa2M=; b=oNn/LmLijeP2NO3ZLp1FNWZ/De36lbxL6CR/QsXwJPU0yG02HLwHvlGLHPfcfTq2yR sXapS2lLE8I4s9a4DagWveBvmXwlWJ8A6uBxjT4peT+hdff19/twKcRw2gGGgw2AW2WJ 798QhojGJXk2GM6wPhm3rXezpHpqA6clcr7ljy569cG74GLDqODg87XDlNmztJqkMDv+ 2VMpTewZQlqtat/im/PQOR3US3yBO++nWwmb4qR5ZynUwZ0b3hUsWmqcZxiMeS9YN2MP 5HdksUcuBTA7XbPz1togkYeE9z9cK6nufXR4bFL9tmko3H1OiPcM4RmnKZBLY5RonJef ukQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734031331; x=1734636131; 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=XHVXDhZly5oo+AlSMxPkA6cSfsFaF41Si7YOZGFGa2M=; b=iLfh4d8qQmc1x5Z5n7u2xUfIBQrWUs5zlsPxBTrOn493WP0w1h6RxPAKQ35SenG6Ei +KmKJT+GgevXOMuMcgRTPQgkDSAuue2fknRJG9sLik2jLTEnMa5SjlrDRzWNGU3eAC4F rrJd0jOMsXfb613x0zTl/G6ShQHr+iiIiyZRFlcYtKKAv4BS8RExyE9h4wPqMfU3DIkh D+J7cEyuv6qifLCdbp2QrepbIRdIELyeIQ7i2W5YZmTBX1r/KqRBXsROLw6HRwBE2PrS Qm9GzjDuikmS+uUEfQwfQi7KnTRwgYothNX7nYNndXz1d8nbq7WMFj+WH/e8kMIg7A0P RDQw== X-Forwarded-Encrypted: i=1; AJvYcCWetxjfel+pAKjKtzUBRmzE2sy3YKYfkqJ7PxpFpGG+hfC5JzF7VVXiTo7PmCJ+VWQlIFm4HuL2ZGAMnK3y@postgresql.org X-Gm-Message-State: AOJu0YzzjhqMS/KPN01dFxeEpt2Patq+OL2yT/A0uxYS1W1FdxPnoMjJ lyf3FPnSn9TmJgJeKqgs1gJdVw8Waf1XMLt7wEGyoteJ9dFQU8xoG9Y1DJSE8Q== X-Gm-Gg: ASbGncuFgcaPd165bYqaGPJpZPOK43Zqn9ANwW6JyvOhXXdDILgwoBg24R0FO9aUuHA HNbVztA4zucNhXNSWQWw4bnS0Lw5GvcVvgFtcAl560x/ePAsMUJajQGo1KKQp2kdbn3+PAMTHJV 1nNt3bxUHoYak7C2vEwxO6a2sf/bz5vQkuU0/DClUR8NGn3HBL1zjLPWZ/eidjxN8z99Nm2S0JR oLMc+CS0rOHisgQxZaabPLtysdbZZfNi2ZNqXBRpbrgZvWi6ytpytEs9HFppxFBRePIkonGUOwh Xl/R9gGCYFmdPRASTS0fw8w= X-Google-Smtp-Source: AGHT+IGNVc8NMoOxReIgRXqsKGTtFvLJ9rO4oum4Aof7S+mjNipyjjuk8sEevfzsYaUZz6BFjWKV7g== X-Received: by 2002:a05:6a20:d81b:b0:1dc:790e:3bd0 with SMTP id adf61e73a8af0-1e1dab48496mr2573911637.15.1734031330774; Thu, 12 Dec 2024 11:22:10 -0800 (PST) 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-725f2d9af64sm7220386b3a.104.2024.12.12.11.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 11:22:10 -0800 (PST) Message-ID: Subject: Re: Remaining dependency on setlocale() From: Jeff Davis To: Thomas Munro Cc: Tom Lane , pgsql-hackers@postgresql.org Date: Thu, 12 Dec 2024 11:22:09 -0800 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 12:00 -0700, Jeff Davis wrote: > 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 cal= l > > 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. >=20 > +1 to this approach. It makes things more consistent across platforms > and avoids surprising dependencies on the global setting. >=20 > 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. Did we reach a conclusion here? Any thoughts on moving in this direction, and whether 18 is the right time to do it? Regards, Jeff Davis