Re: Remove inconsistent quotes from date_part error

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nikhil Benesch <nikhil(dot)benesch(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Remove inconsistent quotes from date_part error
Date: 2022-01-03 08:17:20
Message-ID: YdKxEISD6nB7Kvq/@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 02, 2022 at 11:47:32PM -0500, Nikhil Benesch wrote:
> The attached patch corrects a very minor typographical inconsistency
> when date_part is invoked with invalid units on time/timetz data vs
> timestamp/timestamptz/interval data.

Hmm, you are right that this is inconsistent, but I don't think that
what you are doing is completely correct either. First, from what I
can see from the core code, we don't apply quotes to types in error
messages. So your patch is going in the right direction.

However, there is a specific routine called format_type_be() aimed at
formatting type names for error strings. If you switch to that, my
guess is that this makes the error messages of time/timetz and
timestamp/timestamptz/interval more consistent, while reducing the
effort of translation because we'd finish with the same base error
string, as of "%s units \"%s\" not recognized".

If we rework this part, we could even rework this error message more.
One suggestion I have would be "units of type %s not recognized", for
example.

> (If stuff like this is too minor to bother with, let me know and I'll
> hold off in the future... but since this was pointed out to me I can't
> unsee it.)

This usually comes down to a case-by-case analysis. Now, in this
case, your suggestion looks right to me.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-01-03 08:36:25 Re: An obsolete comment of pg_stat_statements
Previous Message Michael Paquier 2022-01-03 08:00:13 Re: Use MaxLockMode in lock methods initialization