pgsql: Fix precision handling for some COERCE_SQL_SYNTAX functions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix precision handling for some COERCE_SQL_SYNTAX functions
Date: 2022-12-30 11:49:06
Message-ID: E1pBDso-0018aX-6W@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix precision handling for some COERCE_SQL_SYNTAX functions

f193883 has been incorrectly setting up the precision used in the
timestamp compilations returned by the following functions:
- LOCALTIME
- LOCALTIMESTAMP
- CURRENT_TIME
- CURRENT_TIMESTAMP

Specifying an out-of-range precision for CURRENT_TIMESTAMP and
LOCALTIMESTAMP was raising a WARNING without adjusting the precision,
leading to a subsequent error. LOCALTIME and CURRENT_TIME raised a
WARNING without an error, still the precision given to the internal
routines was not correct, so let's be clean.

Ian has reported the problems in timestamp.c, while I have noticed the
ones in date.c. Regression tests are added for all of them with
precisions high enough to provide coverage for the warnings, something
that went missing up to this commit.

Author: Ian Lawrence Barwick, Michael Paquier
Discussion: https://postgr.es/m/CAB8KJ=jQEnn9sYG+N752spt68wMrhmT-ocHCh4oeNmHF82QMWA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7aa81c61ec8f68212570192f3088544dbfa43cb9

Modified Files
--------------
src/backend/utils/adt/date.c | 10 ++--------
src/backend/utils/adt/timestamp.c | 10 ++--------
src/test/regress/expected/expressions.out | 31 ++++++++++++++++++++++++++++++-
src/test/regress/sql/expressions.sql | 7 ++++++-
4 files changed, 40 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2022-12-30 19:48:19 pgsql: Fix assert in BRIN build_distances
Previous Message Peter Eisentraut 2022-12-30 10:15:36 pgsql: Change argument of appendBinaryStringInfo from char * to void *