mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Adjust date/time input parsing code to correctly distinguish the four
SQLSTATE error codes required by SQL99 (invalid format, datetime field overflow, interval field overflow, invalid time zone displacement value). Also emit a HINT about DateStyle in cases where it seems appropriate. Per recent gripes.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.90 2003/08/08 00:10:31 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.91 2003/08/27 23:29:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -62,20 +62,19 @@ date_in(PG_FUNCTION_ARGS)
|
|||||||
int tzp;
|
int tzp;
|
||||||
int dtype;
|
int dtype;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
|
if (dterr == 0)
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp);
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp) != 0))
|
if (dterr != 0)
|
||||||
ereport(ERROR,
|
DateTimeParseError(dterr, str, "date");
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
|
||||||
|
|
||||||
switch (dtype)
|
switch (dtype)
|
||||||
{
|
{
|
||||||
@ -95,9 +94,8 @@ date_in(PG_FUNCTION_ARGS)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ereport(ERROR,
|
DateTimeParseError(DTERR_BAD_FORMAT, str, "date");
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
break;
|
||||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
||||||
@ -559,21 +557,20 @@ time_in(PG_FUNCTION_ARGS)
|
|||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
int tz;
|
int tz;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int dtype;
|
int dtype;
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for time: \"%s\"", str)));
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
|
if (dterr == 0)
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
dterr = DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz);
|
||||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
if (dterr != 0)
|
||||||
ereport(ERROR,
|
DateTimeParseError(dterr, str, "time");
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for time: \"%s\"", str)));
|
|
||||||
|
|
||||||
tm2time(tm, fsec, &result);
|
tm2time(tm, fsec, &result);
|
||||||
AdjustTimeForTypmod(&result, typmod);
|
AdjustTimeForTypmod(&result, typmod);
|
||||||
@ -1424,23 +1421,20 @@ timetz_in(PG_FUNCTION_ARGS)
|
|||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
int tz;
|
int tz;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int dtype;
|
int dtype;
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for time with time zone: \"%s\"",
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
str)));
|
if (dterr == 0)
|
||||||
|
dterr = DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz);
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if (dterr != 0)
|
||||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
DateTimeParseError(dterr, str, "time with time zone");
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for time with time zone: \"%s\"",
|
|
||||||
str)));
|
|
||||||
|
|
||||||
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
||||||
tm2timetz(tm, fsec, tz, result);
|
tm2timetz(tm, fsec, tz, result);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.114 2003/08/17 19:58:05 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.115 2003/08/27 23:29:29 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -364,6 +364,7 @@ abstimein(PG_FUNCTION_ARGS)
|
|||||||
int tz = 0;
|
int tz = 0;
|
||||||
struct tm date,
|
struct tm date,
|
||||||
*tm = &date;
|
*tm = &date;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
int dtype;
|
int dtype;
|
||||||
@ -371,15 +372,13 @@ abstimein(PG_FUNCTION_ARGS)
|
|||||||
ftype[MAXDATEFIELDS];
|
ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for abstime: \"%s\"", str)));
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
|
if (dterr == 0)
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
if (dterr != 0)
|
||||||
ereport(ERROR,
|
DateTimeParseError(dterr, str, "abstime");
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for abstime: \"%s\"", str)));
|
|
||||||
|
|
||||||
switch (dtype)
|
switch (dtype)
|
||||||
{
|
{
|
||||||
@ -768,21 +767,24 @@ reltimein(PG_FUNCTION_ARGS)
|
|||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
fsec_t fsec;
|
fsec_t fsec;
|
||||||
int dtype;
|
int dtype;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int nf,
|
int nf,
|
||||||
ftype[MAXDATEFIELDS];
|
ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for reltime: \"%s\"", str)));
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
|
if (dterr == 0)
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
dterr = DecodeInterval(field, ftype, nf, &dtype, tm, &fsec);
|
||||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
if (dterr != 0)
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
if (dterr == DTERR_FIELD_OVERFLOW)
|
||||||
errmsg("invalid input syntax for reltime: \"%s\"", str)));
|
dterr = DTERR_INTERVAL_OVERFLOW;
|
||||||
|
DateTimeParseError(dterr, str, "reltime");
|
||||||
|
}
|
||||||
|
|
||||||
switch (dtype)
|
switch (dtype)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.93 2003/08/26 21:31:11 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.94 2003/08/27 23:29:29 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -77,22 +77,19 @@ timestamp_in(PG_FUNCTION_ARGS)
|
|||||||
int tz;
|
int tz;
|
||||||
int dtype;
|
int dtype;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for timestamp: \"%s\"",
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
str)));
|
if (dterr == 0)
|
||||||
|
dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if (dterr != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
DateTimeParseError(dterr, str, "timestamp");
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for timestamp: \"%s\"",
|
|
||||||
str)));
|
|
||||||
|
|
||||||
switch (dtype)
|
switch (dtype)
|
||||||
{
|
{
|
||||||
@ -306,22 +303,19 @@ timestamptz_in(PG_FUNCTION_ARGS)
|
|||||||
int tz;
|
int tz;
|
||||||
int dtype;
|
int dtype;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for timestamp with time zone: \"%s\"",
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
str)));
|
if (dterr == 0)
|
||||||
|
dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if (dterr != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
DateTimeParseError(dterr, str, "timestamp with time zone");
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
||||||
errmsg("invalid input syntax for timestamp with time zone: \"%s\"",
|
|
||||||
str)));
|
|
||||||
|
|
||||||
switch (dtype)
|
switch (dtype)
|
||||||
{
|
{
|
||||||
@ -468,6 +462,7 @@ interval_in(PG_FUNCTION_ARGS)
|
|||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
int dtype;
|
int dtype;
|
||||||
int nf;
|
int nf;
|
||||||
|
int dterr;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
@ -481,17 +476,17 @@ interval_in(PG_FUNCTION_ARGS)
|
|||||||
fsec = 0;
|
fsec = 0;
|
||||||
|
|
||||||
if (strlen(str) >= sizeof(lowstr))
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
ereport(ERROR,
|
dterr = DTERR_BAD_FORMAT;
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
else
|
||||||
errmsg("invalid input syntax for interval: \"%s\"",
|
dterr = ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf);
|
||||||
str)));
|
if (dterr == 0)
|
||||||
|
dterr = DecodeInterval(field, ftype, nf, &dtype, tm, &fsec);
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if (dterr != 0)
|
||||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
{
|
||||||
ereport(ERROR,
|
if (dterr == DTERR_FIELD_OVERFLOW)
|
||||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
dterr = DTERR_INTERVAL_OVERFLOW;
|
||||||
errmsg("invalid input syntax for interval: \"%s\"",
|
DateTimeParseError(dterr, str, "interval");
|
||||||
str)));
|
}
|
||||||
|
|
||||||
result = (Interval *) palloc(sizeof(Interval));
|
result = (Interval *) palloc(sizeof(Interval));
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: datetime.h,v 1.44 2003/08/05 18:30:21 tgl Exp $
|
* $Id: datetime.h,v 1.45 2003/08/27 23:29:29 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -204,7 +204,7 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
#define FMODULO(t,q,u) \
|
#define FMODULO(t,q,u) \
|
||||||
do { \
|
do { \
|
||||||
q = ((t < 0) ? ceil(t / u): floor(t / u)); \
|
q = ((t < 0) ? ceil(t / u) : floor(t / u)); \
|
||||||
if (q != 0) t -= rint(q * u); \
|
if (q != 0) t -= rint(q * u); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ do { \
|
|||||||
#else
|
#else
|
||||||
#define TMODULO(t,q,u) \
|
#define TMODULO(t,q,u) \
|
||||||
do { \
|
do { \
|
||||||
q = ((t < 0) ? ceil(t / u): floor(t / u)); \
|
q = ((t < 0) ? ceil(t / u) : floor(t / u)); \
|
||||||
if (q != 0) t -= rint(q * u); \
|
if (q != 0) t -= rint(q * u); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#endif
|
#endif
|
||||||
@ -253,6 +253,15 @@ extern int day_tab[2][13];
|
|||||||
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \
|
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \
|
||||||
&& ((y) < JULIAN_MAXYEAR))
|
&& ((y) < JULIAN_MAXYEAR))
|
||||||
|
|
||||||
|
/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */
|
||||||
|
#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */
|
||||||
|
#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Info about limits of the Unix time_t data type. We assume that time_t
|
||||||
|
* is a signed int32 with origin 1970-01-01. Note this is only relevant
|
||||||
|
* when we use the C library's time routines for timezone processing.
|
||||||
|
*/
|
||||||
#define UTIME_MINYEAR (1901)
|
#define UTIME_MINYEAR (1901)
|
||||||
#define UTIME_MINMONTH (12)
|
#define UTIME_MINMONTH (12)
|
||||||
#define UTIME_MINDAY (14)
|
#define UTIME_MINDAY (14)
|
||||||
@ -267,9 +276,17 @@ extern int day_tab[2][13];
|
|||||||
|| (((y) == UTIME_MAXYEAR) && (((m) < UTIME_MAXMONTH) \
|
|| (((y) == UTIME_MAXYEAR) && (((m) < UTIME_MAXMONTH) \
|
||||||
|| (((m) == UTIME_MAXMONTH) && ((d) <= UTIME_MAXDAY))))))
|
|| (((m) == UTIME_MAXMONTH) && ((d) <= UTIME_MAXDAY))))))
|
||||||
|
|
||||||
/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */
|
/*
|
||||||
#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */
|
* Datetime input parsing routines (ParseDateTime, DecodeDateTime, etc)
|
||||||
#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */
|
* return zero or a positive value on success. On failure, they return
|
||||||
|
* one of these negative code values. DateTimeParseError may be used to
|
||||||
|
* produce a correct ereport.
|
||||||
|
*/
|
||||||
|
#define DTERR_BAD_FORMAT (-1)
|
||||||
|
#define DTERR_FIELD_OVERFLOW (-2)
|
||||||
|
#define DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */
|
||||||
|
#define DTERR_INTERVAL_OVERFLOW (-4)
|
||||||
|
#define DTERR_TZDISP_OVERFLOW (-5)
|
||||||
|
|
||||||
|
|
||||||
extern void GetCurrentDateTime(struct tm * tm);
|
extern void GetCurrentDateTime(struct tm * tm);
|
||||||
@ -283,14 +300,14 @@ extern int ParseDateTime(const char *timestr, char *lowstr,
|
|||||||
extern int DecodeDateTime(char **field, int *ftype,
|
extern int DecodeDateTime(char **field, int *ftype,
|
||||||
int nf, int *dtype,
|
int nf, int *dtype,
|
||||||
struct tm * tm, fsec_t *fsec, int *tzp);
|
struct tm * tm, fsec_t *fsec, int *tzp);
|
||||||
|
|
||||||
extern int DecodeTimeOnly(char **field, int *ftype,
|
extern int DecodeTimeOnly(char **field, int *ftype,
|
||||||
int nf, int *dtype,
|
int nf, int *dtype,
|
||||||
struct tm * tm, fsec_t *fsec, int *tzp);
|
struct tm * tm, fsec_t *fsec, int *tzp);
|
||||||
|
|
||||||
extern int DecodeInterval(char **field, int *ftype,
|
extern int DecodeInterval(char **field, int *ftype,
|
||||||
int nf, int *dtype,
|
int nf, int *dtype,
|
||||||
struct tm * tm, fsec_t *fsec);
|
struct tm * tm, fsec_t *fsec);
|
||||||
|
extern void DateTimeParseError(int dterr, const char *str,
|
||||||
|
const char *datatype);
|
||||||
|
|
||||||
extern int DetermineLocalTimeZone(struct tm * tm);
|
extern int DetermineLocalTimeZone(struct tm * tm);
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
|||||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||||
-- what happens if we specify slightly misformatted abstime?
|
-- what happens if we specify slightly misformatted abstime?
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
ERROR: date/time field value out of range: "Feb 35, 1946 10:00:00"
|
||||||
|
HINT: Perhaps you need a different DateStyle setting.
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
ERROR: date/time field value out of range: "Feb 28, 1984 25:08:10"
|
||||||
-- badly formatted abstimes: these should result in invalid abstimes
|
-- badly formatted abstimes: these should result in invalid abstimes
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||||
ERROR: invalid input syntax for abstime: "bad date format"
|
ERROR: invalid input syntax for abstime: "bad date format"
|
||||||
|
@ -28,9 +28,10 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
|||||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||||
-- what happens if we specify slightly misformatted abstime?
|
-- what happens if we specify slightly misformatted abstime?
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
ERROR: date/time field value out of range: "Feb 35, 1946 10:00:00"
|
||||||
|
HINT: Perhaps you need a different DateStyle setting.
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
ERROR: date/time field value out of range: "Feb 28, 1984 25:08:10"
|
||||||
-- badly formatted abstimes: these should result in invalid abstimes
|
-- badly formatted abstimes: these should result in invalid abstimes
|
||||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||||
ERROR: invalid input syntax for abstime: "bad date format"
|
ERROR: invalid input syntax for abstime: "bad date format"
|
||||||
|
@ -10,7 +10,7 @@ INSERT INTO DATE_TBL VALUES ('1996-03-01');
|
|||||||
INSERT INTO DATE_TBL VALUES ('1996-03-02');
|
INSERT INTO DATE_TBL VALUES ('1996-03-02');
|
||||||
INSERT INTO DATE_TBL VALUES ('1997-02-28');
|
INSERT INTO DATE_TBL VALUES ('1997-02-28');
|
||||||
INSERT INTO DATE_TBL VALUES ('1997-02-29');
|
INSERT INTO DATE_TBL VALUES ('1997-02-29');
|
||||||
ERROR: invalid input syntax for date: "1997-02-29"
|
ERROR: date/time field value out of range: "1997-02-29"
|
||||||
INSERT INTO DATE_TBL VALUES ('1997-03-01');
|
INSERT INTO DATE_TBL VALUES ('1997-03-01');
|
||||||
INSERT INTO DATE_TBL VALUES ('1997-03-02');
|
INSERT INTO DATE_TBL VALUES ('1997-03-02');
|
||||||
INSERT INTO DATE_TBL VALUES ('2000-04-01');
|
INSERT INTO DATE_TBL VALUES ('2000-04-01');
|
||||||
|
@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
|||||||
|
|
||||||
-- should fail in mdy mode:
|
-- should fail in mdy mode:
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||||
|
HINT: Perhaps you need a different DateStyle setting.
|
||||||
set datestyle to dmy;
|
set datestyle to dmy;
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
timestamptz
|
timestamptz
|
||||||
|
@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
|||||||
|
|
||||||
-- should fail in mdy mode:
|
-- should fail in mdy mode:
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||||
|
HINT: Perhaps you need a different DateStyle setting.
|
||||||
set datestyle to dmy;
|
set datestyle to dmy;
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
timestamptz
|
timestamptz
|
||||||
|
@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
|||||||
|
|
||||||
-- should fail in mdy mode:
|
-- should fail in mdy mode:
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||||
|
HINT: Perhaps you need a different DateStyle setting.
|
||||||
set datestyle to dmy;
|
set datestyle to dmy;
|
||||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||||
timestamptz
|
timestamptz
|
||||||
|
@ -128,7 +128,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996');
|
|||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||||
ERROR: invalid input syntax for timestamp: "Feb 29 17:32:01 1997"
|
ERROR: date/time field value out of range: "Feb 29 17:32:01 1997"
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||||
@ -138,7 +138,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000');
|
|||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||||
-- Currently unsupported syntax and ranges
|
-- Currently unsupported syntax and ranges
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||||
ERROR: invalid input syntax for timestamp: "Feb 16 17:32:01 -0097"
|
ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097"
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||||
SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
||||||
|
@ -123,7 +123,7 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996');
|
|||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 29 17:32:01 1997"
|
ERROR: date/time field value out of range: "Feb 29 17:32:01 1997"
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||||
@ -133,7 +133,7 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000');
|
|||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||||
-- Currently unsupported syntax and ranges
|
-- Currently unsupported syntax and ranges
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 16 17:32:01 -0097"
|
ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097"
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||||
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
||||||
|
Reference in New Issue
Block a user