pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anton Voloshin <a.voloshin@postgrespro.ru>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Subject: Re: missing warning in pg_import_system_collations
Date: Thu, 09 Sep 2021 10:51:10 -0400
Message-ID: <3607308.1631199070@sss.pgh.pa.us> (raw)
In-Reply-To: <429d64ee-188d-3ce1-106a-53a8b45c4fce@postgrespro.ru>
References: <429d64ee-188d-3ce1-106a-53a8b45c4fce@postgrespro.ru>

Anton Voloshin <a.voloshin@postgrespro.ru> writes:
> In pg_import_system_collations() there is this fragment of code:

> enc = pg_get_encoding_from_locale(localebuf, false);
> if (enc < 0)
> {
> 	/* error message printed by pg_get_encoding_from_locale() */
> 	continue;
> }

> However, false passed to pg_get_encoding_from_locale() means 
> write_message argument is false, so no error message is ever printed.
> I propose an obvious patch (see attachment).
> Introduced in aa17c06fb in January 2017 when debug was replaced by 
> false, so I guess back-patching through 10 would be appropriate.

I don't think this is obvious at all.

In the original coding (before aa17c06fb, when this code was in initdb),
we printed a warning if "debug" was true and otherwise printed nothing.
The other "if (debug)" cases in the code that got moved over were
translated to "elog(DEBUG1)", but there isn't any API to make
pg_get_encoding_from_locale() log at that level.

What you propose to do here would promote this case from
ought-to-be-DEBUG1 to WARNING, which seems to me to be way too much in the
user's face.  Or, if there actually is a case for complaining, then all
those messages ought to be WARNING not DEBUG1.  But I'm inclined to think
that having pg_import_system_collations silently ignore unusable locales
is the right thing most of the time.

Assuming we don't want to change pg_get_encoding_from_locale()'s API,
the simplest fix is to duplicate its error message, so more or less

     if (enc < 0)
     {
-        /* error message printed by pg_get_encoding_from_locale() */
+        elog(DEBUG1, "could not determine encoding for locale \"%s\"",
+             localebuf)));
         continue;
     }

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <3607308.1631199070@sss.pgh.pa.us>
Permalink:  ../3607308.1631199070@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3607308.1631199070@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, a.voloshin@postgrespro.ru, peter.eisentraut@enterprisedb.com
  Subject: Re: missing warning in pg_import_system_collations
  In-Reply-To: <3607308.1631199070@sss.pgh.pa.us>
  References: <429d64ee-188d-3ce1-106a-53a8b45c4fce@postgrespro.ru> <3607308.1631199070@sss.pgh.pa.us>

* 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