=?utf-8?Q?=C3=81lvaro?= Herrera <[email protected]> writes:
> On 2026-Feb-10, Kyotaro Horiguchi wrote:
>> In extended_stats_funcs.c:
>>> errmsg("could not find extended statistics object \"%s\".\"%s\"",
>>>        quote_identifier(nspname),
>>>        quote_identifier(stxname)));
>> 
>> Since quote_identifier() already adds quoting when needed, adding
>> "%s"."%s" in the format string results in double quoting. It would be
>> better to use %s.%s instead.  I think quoting should be applied only
>> when necessary here. I'm not sure we should use
>> quote_qualified_identifier() instead.

> Hmm, in the vast majority of messages, the quotes are in the literal
> string, and we do not add quote_identifier().  This way, the names are
> always quoted, not just when they are funny identifiers; also the
> translator chooses the quoting style they want, which is not necessarily
> the same as the one used in English.

Yeah, this code is simply wrong.  You should remove the
quote_identifier() calls and otherwise leave it as-is.

quote_identifier(), quote_qualified_identifier(), etc are meant for
building valid SQL strings.  However, an error message is a totally
different animal.  We decided years ago that the preferred style is
to wrap "..." around the unadorned identifier *in the error text*,
not by using quote_identifier(), so that translators could replace
the double-quote marks with appropriate marks for their language.
Is the English version 100% consistent in the presence of identifiers
containing double-quote marks?  No.  But we'd be making matters
worse not better for other languages if we did it differently.

This choice is documented at

https://www.postgresql.org/docs/devel/error-style-guide.html#ERROR-STYLE-GUIDE-QUOTATION-MARKS

                        regards, tom lane


Reply via email to