pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tristan Partin <tristan@neon.tech>
To: Heikki Linnakangas <hlinnaka@iki.fi>
To: Joe Conway <mail@joeconway.com>
Cc: gdo@leader.it
Cc: pgsql-bugs@lists.postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Date: Wed, 14 Jun 2023 11:42:03 -0500
Message-ID: <CTCIT7UROG7Z.17MF02SIW1H6Y@gonk> (raw)
In-Reply-To: <49dfcad8-90fa-8577-008f-d142e61af46b@iki.fi>
References: <17946-3e84cb577e9551c3@postgresql.org>
	<1564676.1685043220@sss.pgh.pa.us>
	<555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi>
	<CT887GSPI31W.BQCSW35JL67L@gonk>
	<ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com>
	<5676b739-0854-f924-4b97-466e3504c692@joeconway.com>
	<f1856a5d-3703-66ff-e7c7-01d2489315c1@joeconway.com>
	<665279.1686422574@sss.pgh.pa.us>
	<c23d6ec1-f882-af48-82d9-54e9f3e15809@joeconway.com>
	<574a1afa-5c6e-829c-0fed-a9ff44719f9f@joeconway.com>
	<49dfcad8-90fa-8577-008f-d142e61af46b@iki.fi>

On Mon Jun 12, 2023 at 4:13 AM CDT, Heikki Linnakangas wrote:
> There are a few uselocale() calls in ecpg, and they are protected by 
> HAVE_USELOCALE. Interestingly, the calls in pg_locale.c are not, but 
> they are protected by HAVE_LOCALE_T. Seems a little inconsistent.

Patch is attached. CC-ing hackers.

-- 
Tristan Partin
Neon (https://neon.tech)

Attachments:

v1-0001-Make-uselocale-protection-more-consistent.patch (text/x-patch, 2.6K) download From 02a2cdb83405b5aecaec2af02e379a81161f8372 Mon Sep 17 00:00:00 2001 From: Tristan Partin <tristan@neon.tech> Date: Wed, 14 Jun 2023 11:36:00 -0500 Subject: [PATCH v1] Make uselocale protection more consistent In ecpg, uselocale uses are protected by checking if HAVE_USELOCALE is defined. Use the same check in pg_locale.c. Since HAVE_USELOCALE implies HAVE_LOCALE_T, the code should be the same on _all_ platforms that Postgres supports. Otherwise, I am sure there would have been a bug report with pg_locale.c failing to build due to the system having locale_t, but not uselocale. --- src/backend/utils/adt/pg_locale.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 31e3b16ae0..3585afb298 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -2972,7 +2972,7 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) } else { -#ifdef HAVE_LOCALE_T +#ifdef HAVE_USELOCALE #ifdef HAVE_WCSTOMBS_L /* Use wcstombs_l for nondefault locales */ result = wcstombs_l(to, from, tolen, locale->info.lt); @@ -2984,11 +2984,11 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) uselocale(save_locale); #endif /* HAVE_WCSTOMBS_L */ -#else /* !HAVE_LOCALE_T */ - /* Can't have locale != 0 without HAVE_LOCALE_T */ +#else /* !HAVE_USELOCALE */ + /* Can't have locale != 0 without HAVE_LOCALE_T, which HAVE_USELOCALE implies */ elog(ERROR, "wcstombs_l is not available"); result = 0; /* keep compiler quiet */ -#endif /* HAVE_LOCALE_T */ +#endif /* HAVE_USELOCALE */ } return result; @@ -3049,7 +3049,7 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, } else { -#ifdef HAVE_LOCALE_T +#ifdef HAVE_USELOCALE #ifdef HAVE_MBSTOWCS_L /* Use mbstowcs_l for nondefault locales */ result = mbstowcs_l(to, str, tolen, locale->info.lt); @@ -3061,11 +3061,11 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, uselocale(save_locale); #endif /* HAVE_MBSTOWCS_L */ -#else /* !HAVE_LOCALE_T */ - /* Can't have locale != 0 without HAVE_LOCALE_T */ +#else /* !HAVE_USELOCALE */ + /* Can't have locale != 0 without HAVE_LOCALE_T, which HAVE_USELOCALE implies */ elog(ERROR, "mbstowcs_l is not available"); result = 0; /* keep compiler quiet */ -#endif /* HAVE_LOCALE_T */ +#endif /* HAVE_USELOCALE */ } pfree(str); -- Tristan Partin Neon (https://neon.tech)

view thread (38+ messages)  latest in thread

Message-ID: <CTCIT7UROG7Z.17MF02SIW1H6Y@gonk>
Permalink:  ../CTCIT7UROG7Z.17MF02SIW1H6Y@gonk/
Also on:    postgresql.org/message-id/CTCIT7UROG7Z.17MF02SIW1H6Y@gonk

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tristan@neon.tech, hlinnaka@iki.fi, mail@joeconway.com, gdo@leader.it, pgsql-bugs@lists.postgresql.org, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
  Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
  In-Reply-To: <CTCIT7UROG7Z.17MF02SIW1H6Y@gonk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox