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

Commit412c57b

Browse files
committed
Allow parsing of time and timetz inputs to accept the documented input
syntax '040506' for '04:05:06', as well as '0405' for '04:05:00'. Thishas been broken since 7.2 but was only recently complained of.
1 parent3b87c1f commit412c57b

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.113 2003/08/08 21:42:05 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.114 2003/08/25 22:47:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -243,7 +243,7 @@ static datetkn datetktbl[] = {
243243
ghst
244244
#endif
245245
{"gilt",TZ,POS(48)},/* Gilbert Islands Time */
246-
{"gmt",TZ,POS(0)},/*Greenwish Mean Time */
246+
{"gmt",TZ,POS(0)},/*Greenwich Mean Time */
247247
{"gst",TZ,POS(40)},/* Guam Std Time, USSR Zone 9 */
248248
{"gyt",TZ,NEG(16)},/* Guyana Time */
249249
{"h",UNITS,DTK_HOUR},/* "hour" */
@@ -1989,7 +1989,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19891989
* Set the type field to allow decoding other
19901990
* fields later. Example: 20011223 or 040506
19911991
*/
1992-
if ((ftype[i]=DecodeNumberField(flen,field[i],fmask,
1992+
if ((ftype[i]=DecodeNumberField(flen,field[i],
1993+
(fmask |DTK_DATE_M),
19931994
&tmask,tm,fsec,&is2digits))<0)
19941995
return-1;
19951996
}
@@ -1998,12 +1999,14 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19981999
}
19992000
elseif (flen>4)
20002001
{
2001-
if ((ftype[i]=DecodeNumberField(flen,field[i],fmask,
2002+
if ((ftype[i]=DecodeNumberField(flen,field[i],
2003+
(fmask |DTK_DATE_M),
20022004
&tmask,tm,fsec,&is2digits))<0)
20032005
return-1;
20042006
}
20052007
/* otherwise it is a single date/time field... */
2006-
elseif (DecodeNumber(flen,field[i],fmask,
2008+
elseif (DecodeNumber(flen,field[i],
2009+
(fmask |DTK_DATE_M),
20072010
&tmask,tm,fsec,&is2digits)!=0)
20082011
return-1;
20092012
}
@@ -2422,8 +2425,12 @@ DecodeNumber(int flen, char *str, int fmask,
24222425
* or a run-together time: 2001.360 20011225 040506.789
24232426
*/
24242427
if ((cp-str)>2)
2425-
returnDecodeNumberField(flen,str, (fmask |DTK_DATE_M),
2426-
tmask,tm,fsec,is2digits);
2428+
{
2429+
if (DecodeNumberField(flen,str, (fmask |DTK_DATE_M),
2430+
tmask,tm,fsec,is2digits)<0)
2431+
return-1;
2432+
return0;
2433+
}
24272434

24282435
frac=strtod(cp,&cp);
24292436
if (*cp!='\0')
@@ -2507,6 +2514,13 @@ DecodeNumber(int flen, char *str, int fmask,
25072514
tm->tm_mday=val;
25082515
break;
25092516

2517+
case (DTK_M(YEAR) |DTK_M(MONTH) |DTK_M(DAY)):
2518+
/* we have all the date, so it must be a time field */
2519+
if (DecodeNumberField(flen,str,fmask,
2520+
tmask,tm,fsec,is2digits)<0)
2521+
return-1;
2522+
return0;
2523+
25102524
default:
25112525
/* Anything else is bogus input */
25122526
return-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp