Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe1b07a

Browse files
committed
When checking for datetime field overflow, we should allow a fractional-second
part that rounds up to exactly 1.0 second. The previous coding rejected inputlike "00:12:57.9999999999999999999999999999", with the exact number of ninesneeded to cause failure varying depending on float-timestamp option andpossibly on platform. Obviously this should round up to the next integralsecond, if we don't have enough precision to distinguish the value from that.Per bug #4789 from Robert Kruus.In passing, fix a missed check for fractional seconds in one copy of the"is it greater than 24:00:00" code.Broken all the way back, so patch all the way back.
1 parentcfb61be commitfe1b07a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

‎src/backend/utils/adt/datetime.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.203 2009/03/22 01:12:31 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.204 2009/05/01 19:29:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -950,7 +950,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
950950
*/
951951
/* test for > 24:00:00 */
952952
if (tm->tm_hour>24||
953-
(tm->tm_hour==24&& (tm->tm_min>0||tm->tm_sec>0)))
953+
(tm->tm_hour==24&&
954+
(tm->tm_min>0||tm->tm_sec>0||*fsec>0)))
954955
returnDTERR_FIELD_OVERFLOW;
955956
break;
956957

@@ -2058,15 +2059,13 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
20582059

20592060
if (tm->tm_hour<0||tm->tm_min<0||tm->tm_min>59||
20602061
tm->tm_sec<0||tm->tm_sec>60||tm->tm_hour>24||
2061-
/* test for > 24:00:00 */
2062+
/* test for > 24:00:00 */
2063+
(tm->tm_hour==24&&
2064+
(tm->tm_min>0||tm->tm_sec>0||*fsec>0))||
20622065
#ifdefHAVE_INT64_TIMESTAMP
2063-
(tm->tm_hour==24&& (tm->tm_min>0||tm->tm_sec>0||
2064-
*fsec>INT64CONST(0)))||
2065-
*fsec<INT64CONST(0)||*fsec >=USECS_PER_SEC
2066+
*fsec<INT64CONST(0)||*fsec>USECS_PER_SEC
20662067
#else
2067-
(tm->tm_hour==24&& (tm->tm_min>0||tm->tm_sec>0||
2068-
*fsec>0))||
2069-
*fsec<0||*fsec >=1
2068+
*fsec<0||*fsec>1
20702069
#endif
20712070
)
20722071
returnDTERR_FIELD_OVERFLOW;
@@ -2386,11 +2385,11 @@ DecodeTime(char *str, int fmask, int range,
23862385
#ifdefHAVE_INT64_TIMESTAMP
23872386
if (tm->tm_hour<0||tm->tm_min<0||tm->tm_min>59||
23882387
tm->tm_sec<0||tm->tm_sec>60||*fsec<INT64CONST(0)||
2389-
*fsec >=USECS_PER_SEC)
2388+
*fsec>USECS_PER_SEC)
23902389
returnDTERR_FIELD_OVERFLOW;
23912390
#else
23922391
if (tm->tm_hour<0||tm->tm_min<0||tm->tm_min>59||
2393-
tm->tm_sec<0||tm->tm_sec>60||*fsec<0||*fsec >=1)
2392+
tm->tm_sec<0||tm->tm_sec>60||*fsec<0||*fsec>1)
23942393
returnDTERR_FIELD_OVERFLOW;
23952394
#endif
23962395

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp