Skip to content

Commit 9afc583

Browse files
committed
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.
1 parent bfb8a8d commit 9afc583

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/backend/utils/adt/date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,10 +2696,10 @@ timetz_izone(PG_FUNCTION_ARGS)
26962696
TimeTzADT *result;
26972697
int tz;
26982698

2699-
if (zone->month != 0)
2699+
if (zone->month != 0 || zone->day != 0)
27002700
ereport(ERROR,
27012701
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2702-
errmsg("\"interval\" time zone \"%s\" not valid",
2702+
errmsg("interval time zone \"%s\" must not include months or days",
27032703
DatumGetCString(DirectFunctionCall1(interval_out,
27042704
PointerGetDatum(zone))))));
27052705

src/backend/utils/adt/timestamp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,10 +4604,10 @@ timestamp_izone(PG_FUNCTION_ARGS)
46044604
if (TIMESTAMP_NOT_FINITE(timestamp))
46054605
PG_RETURN_TIMESTAMPTZ(timestamp);
46064606

4607-
if (zone->month != 0)
4607+
if (zone->month != 0 || zone->day != 0)
46084608
ereport(ERROR,
46094609
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4610-
errmsg("interval time zone \"%s\" must not specify month",
4610+
errmsg("interval time zone \"%s\" must not include months or days",
46114611
DatumGetCString(DirectFunctionCall1(interval_out,
46124612
PointerGetDatum(zone))))));
46134613

@@ -4777,10 +4777,10 @@ timestamptz_izone(PG_FUNCTION_ARGS)
47774777
if (TIMESTAMP_NOT_FINITE(timestamp))
47784778
PG_RETURN_TIMESTAMP(timestamp);
47794779

4780-
if (zone->month != 0)
4780+
if (zone->month != 0 || zone->day != 0)
47814781
ereport(ERROR,
47824782
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4783-
errmsg("interval time zone \"%s\" must not specify month",
4783+
errmsg("interval time zone \"%s\" must not include months or days",
47844784
DatumGetCString(DirectFunctionCall1(interval_out,
47854785
PointerGetDatum(zone))))));
47864786

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy