diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-01-31 12:12:23 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-01-31 12:12:23 -0500 |
commit | 9afc58396af75d59ea2eec467724faf68fe63890 (patch) | |
tree | c1d8b77deb4ecdcfd2ddeb81603de6c5b616ca7c /src | |
parent | bfb8a8d3818972faf1976eccedddfaee7eb0f613 (diff) | |
download | postgresql-9afc58396af75d59ea2eec467724faf68fe63890.tar.gz postgresql-9afc58396af75d59ea2eec467724faf68fe63890.zip |
Reject nonzero day fields in AT TIME ZONE INTERVAL functions.
It's not sensible for an interval that's used as a time zone value to be
larger than a day. When we changed the interval type to contain a separate
day field, check_timezone() was adjusted to reject nonzero day values, but
timetz_izone(), timestamp_izone(), and timestamptz_izone() evidently were
overlooked.
While at it, make the error messages for these three cases consistent.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/date.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 4e4832415a1..57391c30edf 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -2696,10 +2696,10 @@ timetz_izone(PG_FUNCTION_ARGS) TimeTzADT *result; int tz; - if (zone->month != 0) + if (zone->month != 0 || zone->day != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("\"interval\" time zone \"%s\" not valid", + errmsg("interval time zone \"%s\" must not include months or days", DatumGetCString(DirectFunctionCall1(interval_out, PointerGetDatum(zone)))))); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index f870491e1fa..451f4dae70c 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -4604,10 +4604,10 @@ timestamp_izone(PG_FUNCTION_ARGS) if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMPTZ(timestamp); - if (zone->month != 0) + if (zone->month != 0 || zone->day != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("interval time zone \"%s\" must not specify month", + errmsg("interval time zone \"%s\" must not include months or days", DatumGetCString(DirectFunctionCall1(interval_out, PointerGetDatum(zone)))))); @@ -4777,10 +4777,10 @@ timestamptz_izone(PG_FUNCTION_ARGS) if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMP(timestamp); - if (zone->month != 0) + if (zone->month != 0 || zone->day != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("interval time zone \"%s\" must not specify month", + errmsg("interval time zone \"%s\" must not include months or days", DatumGetCString(DirectFunctionCall1(interval_out, PointerGetDatum(zone)))))); |