8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -243,7 +243,7 @@ static datetkn datetktbl[] = {
243
243
ghst
244
244
#endif
245
245
{"gilt" ,TZ ,POS (48 )},/* Gilbert Islands Time */
246
- {"gmt" ,TZ ,POS (0 )},/*Greenwish Mean Time */
246
+ {"gmt" ,TZ ,POS (0 )},/*Greenwich Mean Time */
247
247
{"gst" ,TZ ,POS (40 )},/* Guam Std Time, USSR Zone 9 */
248
248
{"gyt" ,TZ ,NEG (16 )},/* Guyana Time */
249
249
{"h" ,UNITS ,DTK_HOUR },/* "hour" */
@@ -1989,7 +1989,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
1989
1989
* Set the type field to allow decoding other
1990
1990
* fields later. Example: 20011223 or 040506
1991
1991
*/
1992
- if ((ftype [i ]= DecodeNumberField (flen ,field [i ],fmask ,
1992
+ if ((ftype [i ]= DecodeNumberField (flen ,field [i ],
1993
+ (fmask |DTK_DATE_M ),
1993
1994
& tmask ,tm ,fsec ,& is2digits ))< 0 )
1994
1995
return -1 ;
1995
1996
}
@@ -1998,12 +1999,14 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
1998
1999
}
1999
2000
else if (flen > 4 )
2000
2001
{
2001
- if ((ftype [i ]= DecodeNumberField (flen ,field [i ],fmask ,
2002
+ if ((ftype [i ]= DecodeNumberField (flen ,field [i ],
2003
+ (fmask |DTK_DATE_M ),
2002
2004
& tmask ,tm ,fsec ,& is2digits ))< 0 )
2003
2005
return -1 ;
2004
2006
}
2005
2007
/* otherwise it is a single date/time field... */
2006
- else if (DecodeNumber (flen ,field [i ],fmask ,
2008
+ else if (DecodeNumber (flen ,field [i ],
2009
+ (fmask |DTK_DATE_M ),
2007
2010
& tmask ,tm ,fsec ,& is2digits )!= 0 )
2008
2011
return -1 ;
2009
2012
}
@@ -2422,8 +2425,12 @@ DecodeNumber(int flen, char *str, int fmask,
2422
2425
* or a run-together time: 2001.360 20011225 040506.789
2423
2426
*/
2424
2427
if ((cp - str )> 2 )
2425
- return DecodeNumberField (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
+ return 0 ;
2433
+ }
2427
2434
2428
2435
frac = strtod (cp ,& cp );
2429
2436
if (* cp != '\0' )
@@ -2507,6 +2514,13 @@ DecodeNumber(int flen, char *str, int fmask,
2507
2514
tm -> tm_mday = val ;
2508
2515
break ;
2509
2516
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
+ return 0 ;
2523
+
2510
2524
default :
2511
2525
/* Anything else is bogus input */
2512
2526
return -1 ;