]> granicus.if.org Git - postgresql/commit
Make our parsing of INTERVAL literals spec-compliant (or at least a heck of
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Sep 2008 18:29:41 +0000 (18:29 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Sep 2008 18:29:41 +0000 (18:29 +0000)
commitf867339c0148381eb1d01f93ab5c79f9d10211de
treebeb851c791d7ee639f0a9a6f5c5d0825d282cb3f
parent3b9ec4682c2f1baeeeba10b6d782386656a98f4a
Make our parsing of INTERVAL literals spec-compliant (or at least a heck of
a lot closer than it was before).  To do this, tweak coerce_type() to pass
through the typmod information when invoking interval_in() on an UNKNOWN
constant; then fix DecodeInterval to pay attention to the typmod when deciding
how to interpret a units-less integer value.  I changed one or two other
details as well.  I believe the code now reacts as expected by spec for all
the literal syntaxes that are specifically enumerated in the spec.  There
are corner cases involving strings that don't exactly match the set of fields
called out by the typmod, for which we might want to tweak the behavior some
more; but I think this is an area of user friendliness rather than spec
compliance.  There remain some non-compliant details about the SQL syntax
(as opposed to what's inside the literal string); but at least we'll throw
error rather than silently doing the wrong thing in those cases.
src/backend/parser/parse_coerce.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/timestamp.c
src/include/utils/datetime.h
src/test/regress/expected/interval.out
src/test/regress/sql/interval.sql