Skip to content

Commit 7be1b3b

Browse files
committed
Add hint for to_char(interval) invalid format specifications.
1 parent a11fe54 commit 7be1b3b

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.98 2005/08/18 04:37:08 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.99 2005/08/18 13:43:08 momjian Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2005, PostgreSQL Global Development Group
@@ -421,26 +421,27 @@ typedef struct TmToChar
421421
#define tmtcFsec(_X) ((_X)->fsec)
422422

423423
#define ZERO_tm(_X) \
424-
do { \
425-
(_X)->tm_sec = (_X)->tm_year = (_X)->tm_min = (_X)->tm_wday = \
426-
(_X)->tm_hour = (_X)->tm_yday = (_X)->tm_isdst = 0; \
427-
(_X)->tm_mday = (_X)->tm_mon = 1; \
428-
} while(0)
424+
do { \
425+
(_X)->tm_sec = (_X)->tm_year = (_X)->tm_min = (_X)->tm_wday = \
426+
(_X)->tm_hour = (_X)->tm_yday = (_X)->tm_isdst = 0; \
427+
(_X)->tm_mday = (_X)->tm_mon = 1; \
428+
} while(0)
429429

430430
#define ZERO_tmtc(_X) \
431-
do { \
432-
ZERO_tm( tmtcTm(_X) ); \
433-
tmtcFsec(_X) = 0; \
434-
tmtcTzn(_X) = NULL; \
435-
} while(0)
431+
do { \
432+
ZERO_tm( tmtcTm(_X) ); \
433+
tmtcFsec(_X) = 0; \
434+
tmtcTzn(_X) = NULL; \
435+
} while(0)
436436

437437
#define INVALID_FOR_INTERVAL \
438-
do { \
439-
if (is_interval) \
440-
ereport(ERROR, \
441-
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
442-
errmsg("invalid format specification for an interval value"))); \
443-
} while(0)
438+
do { \
439+
if (is_interval) \
440+
ereport(ERROR, \
441+
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
442+
errmsg("invalid format specification for an interval value"), \
443+
errhint("Intervals are not tied to specific calendar dates."))); \
444+
} while(0)
444445

445446
/*****************************************************************************
446447
* KeyWords definition & action

0 commit comments

Comments
 (0)