diff options
author | Bruce Momjian | 2005-10-14 11:47:57 +0000 |
---|---|---|
committer | Bruce Momjian | 2005-10-14 11:47:57 +0000 |
commit | a93bf4503ffc6d7cd6243a6324fb2ef206b10adf (patch) | |
tree | b42cbc485e4250d2b1116ac9e52a5ac94f7d1d5f /src/interfaces | |
parent | dbc214f7e611ed32bd8208955486ba46d2dbc941 (diff) |
Allow times of 24:00:00 to match rounding behavior:
regression=# select '23:59:59.9'::time(0);
time
----------
24:00:00
(1 row)
This is bad because:
regression=# select '24:00:00'::time(0);
ERROR: date/time field value out of range: "24:00:00"
The last example now works.
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/ecpg/pgtypeslib/dt_common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index 305f192a7bd..b5939c243ec 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -2095,7 +2095,9 @@ DecodeDateTime(char **field, int *ftype, int nf, * Check upper limit on hours; other limits checked in * DecodeTime() */ - if (tm->tm_hour > 23) + /* test for > 24:00:00 */ + if (tm->tm_hour > 24 || + (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0))) return -1; break; @@ -3161,7 +3163,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, err = 1; *minute = 0; } - if (*hour > 23) + if (*hour > 24 || /* test for > 24:00:00 */ + (*hour == 24 && (*minute > 0 || *second > 0))) { err = 1; *hour = 0; |