pgsql: Fix precision handling for some COERCE_SQL_SYNTAX functions - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix precision handling for some COERCE_SQL_SYNTAX functions
Date
Msg-id E1pBDso-0018aX-6W@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Change argument of appendBinaryStringInfo from char * to void *
Next
From: Tomas Vondra
Date:
Subject: pgsql: Fix assert in BRIN build_distances