Fix typo for default units for timespan input.

Place single-ticks around bad argument in elog messages.
Fix tabbing of large lookup tables (ugh).
This commit is contained in:
Thomas G. Lockhart 1997-09-20 16:20:29 +00:00
parent fbf12681ab
commit cc8dc825d8
1 changed files with 223 additions and 240 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.40 1997/09/08 21:48:23 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.41 1997/09/20 16:20:29 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -115,7 +115,7 @@ datetime_in(char *str)
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0) if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0)) || (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
elog(WARN, "Bad datetime external representation %s", str); elog(WARN, "Bad datetime external representation '%s'", str);
result = PALLOCTYPE(DateTime); result = PALLOCTYPE(DateTime);
@ -123,7 +123,7 @@ datetime_in(char *str)
{ {
case DTK_DATE: case DTK_DATE:
if (tm2datetime(tm, fsec, &tz, result) != 0) if (tm2datetime(tm, fsec, &tz, result) != 0)
elog(WARN, "Datetime out of range %s", str); elog(WARN, "Datetime out of range '%s'", str);
#ifdef DATEDEBUG #ifdef DATEDEBUG
printf("datetime_in- date is %f\n", *result); printf("datetime_in- date is %f\n", *result);
@ -243,7 +243,7 @@ timespan_in(char *str)
#if FALSE #if FALSE
TIMESPAN_INVALID(span); TIMESPAN_INVALID(span);
#endif #endif
elog(WARN, "Bad timespan external representation %s", str); elog(WARN, "Bad timespan external representation '%s'", str);
} }
break; break;
@ -1488,7 +1488,7 @@ datetime_trunc(text *units, DateTime *datetime)
break; break;
default: default:
elog(WARN, "Datetime units %s not supported", lowunits); elog(WARN, "Datetime units '%s' not supported", lowunits);
result = NULL; result = NULL;
} }
@ -1521,7 +1521,7 @@ datetime_trunc(text *units, DateTime *datetime)
} }
if (tm2datetime(tm, fsec, &tz, result) != 0) if (tm2datetime(tm, fsec, &tz, result) != 0)
elog(WARN, "Unable to truncate datetime to %s", lowunits); elog(WARN, "Unable to truncate datetime to '%s'", lowunits);
#if FALSE #if FALSE
} }
@ -1534,7 +1534,7 @@ datetime_trunc(text *units, DateTime *datetime)
} }
else else
{ {
elog(WARN, "Datetime units %s not recognized", lowunits); elog(WARN, "Datetime units '%s' not recognized", lowunits);
result = NULL; result = NULL;
} }
} }
@ -1631,12 +1631,12 @@ timespan_trunc(text *units, TimeSpan *timespan)
break; break;
default: default:
elog(WARN, "Timespan units %s not supported", lowunits); elog(WARN, "Timespan units '%s' not supported", lowunits);
result = NULL; result = NULL;
} }
if (tm2timespan(tm, fsec, result) != 0) if (tm2timespan(tm, fsec, result) != 0)
elog(WARN, "Unable to truncate timespan to %s", lowunits); elog(WARN, "Unable to truncate timespan to '%s'", lowunits);
} }
else else
@ -1660,7 +1660,7 @@ timespan_trunc(text *units, TimeSpan *timespan)
} }
else else
{ {
elog(WARN, "Timespan units %s not recognized", units); elog(WARN, "Timespan units '%s' not recognized", units);
result = NULL; result = NULL;
} }
@ -1782,7 +1782,7 @@ datetime_part(text *units, DateTime *datetime)
break; break;
default: default:
elog(WARN, "Datetime units %s not supported", lowunits); elog(WARN, "Datetime units '%s' not supported", lowunits);
*result = 0; *result = 0;
} }
@ -1804,14 +1804,14 @@ datetime_part(text *units, DateTime *datetime)
break; break;
default: default:
elog(WARN, "Datetime units %s not supported", lowunits); elog(WARN, "Datetime units '%s' not supported", lowunits);
*result = 0; *result = 0;
} }
} }
else else
{ {
elog(WARN, "Datetime units %s not recognized", lowunits); elog(WARN, "Datetime units '%s' not recognized", lowunits);
*result = 0; *result = 0;
} }
} }
@ -1925,7 +1925,7 @@ timespan_part(text *units, TimeSpan *timespan)
break; break;
default: default:
elog(WARN, "Timespan units %s not yet supported", units); elog(WARN, "Timespan units '%s' not yet supported", units);
result = NULL; result = NULL;
} }
@ -1949,7 +1949,7 @@ timespan_part(text *units, TimeSpan *timespan)
} }
else else
{ {
elog(WARN, "Timespan units %s not recognized", units); elog(WARN, "Timespan units '%s' not recognized", units);
*result = 0; *result = 0;
} }
@ -2039,7 +2039,7 @@ datetime_zone(text *zone, DateTime *datetime)
} }
else else
{ {
elog(WARN, "Time zone %s not recognized", lowzone); elog(WARN, "Time zone '%s' not recognized", lowzone);
result = NULL; result = NULL;
} }
@ -2070,8 +2070,7 @@ static datetkn datetktbl[] = {
{"acsst", DTZ, 63}, /* Cent. Australia */ {"acsst", DTZ, 63}, /* Cent. Australia */
{"acst", TZ, 57}, /* Cent. Australia */ {"acst", TZ, 57}, /* Cent. Australia */
{DA_D, ADBC, AD}, /* "ad" for years >= 0 */ {DA_D, ADBC, AD}, /* "ad" for years >= 0 */
{"abstime", IGNORE, 0}, /* "abstime" for pre-v6.1 "Invalid {"abstime", IGNORE, 0}, /* "abstime" for pre-v6.1 "Invalid Abstime" */
* Abstime" */
{"adt", DTZ, NEG(18)}, /* Atlantic Daylight Time */ {"adt", DTZ, NEG(18)}, /* Atlantic Daylight Time */
{"aesst", DTZ, 66}, /* E. Australia */ {"aesst", DTZ, 66}, /* E. Australia */
{"aest", TZ, 60}, /* Australia Eastern Std Time */ {"aest", TZ, 60}, /* Australia Eastern Std Time */
@ -2125,10 +2124,9 @@ static datetkn datetktbl[] = {
{"hmt", DTZ, 18}, /* Hellas ? ? */ {"hmt", DTZ, 18}, /* Hellas ? ? */
{"hst", TZ, NEG(60)}, /* Hawaii Std Time */ {"hst", TZ, NEG(60)}, /* Hawaii Std Time */
{"idle", TZ, 72}, /* Intl. Date Line, East */ {"idle", TZ, 72}, /* Intl. Date Line, East */
{"idlw", TZ, NEG(72)}, /* Intl. Date Line, West */ {"idlw", TZ, NEG(72)}, /* Intl. Date Line,, est */
{LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */ {LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */
{INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid time */
* time */
{"ist", TZ, 12}, /* Israel */ {"ist", TZ, 12}, /* Israel */
{"it", TZ, 22}, /* Iran Time */ {"it", TZ, 22}, /* Iran Time */
{"jan", MONTH, 1}, {"jan", MONTH, 1},
@ -2192,8 +2190,7 @@ static datetkn datetktbl[] = {
{"tue", DOW, 2}, {"tue", DOW, 2},
{"tues", DOW, 2}, {"tues", DOW, 2},
{"tuesday", DOW, 2}, {"tuesday", DOW, 2},
{"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid time */
* time */
{"ut", TZ, 0}, {"ut", TZ, 0},
{"utc", TZ, 0}, {"utc", TZ, 0},
{"wadt", DTZ, 48}, /* West Australian DST */ {"wadt", DTZ, 48}, /* West Australian DST */
@ -2230,7 +2227,7 @@ static datetkn deltatktbl[] = {
{DDAY, UNITS, DTK_DAY}, /* "day" relative time units */ {DDAY, UNITS, DTK_DAY}, /* "day" relative time units */
{"days", UNITS, DTK_DAY}, /* "days" relative time units */ {"days", UNITS, DTK_DAY}, /* "days" relative time units */
{"dec", UNITS, DTK_DECADE}, /* "decade" relative time units */ {"dec", UNITS, DTK_DECADE}, /* "decade" relative time units */
{"decs", UNITS, DTK_DECADE},/* "decades" relative time units */ {"decs", UNITS, DTK_DECADE}, /* "decades" relative time units */
{DDECADE, UNITS, DTK_DECADE}, /* "decade" relative time units */ {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative time units */
{"decades", UNITS, DTK_DECADE}, /* "decades" relative time units */ {"decades", UNITS, DTK_DECADE}, /* "decades" relative time units */
{"h", UNITS, DTK_HOUR}, /* "hour" relative time units */ {"h", UNITS, DTK_HOUR}, /* "hour" relative time units */
@ -2238,57 +2235,44 @@ static datetkn deltatktbl[] = {
{"hours", UNITS, DTK_HOUR}, /* "hours" relative time units */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative time units */
{"hr", UNITS, DTK_HOUR}, /* "hour" relative time units */ {"hr", UNITS, DTK_HOUR}, /* "hour" relative time units */
{"hrs", UNITS, DTK_HOUR}, /* "hours" relative time units */ {"hrs", UNITS, DTK_HOUR}, /* "hours" relative time units */
{INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid time */
* time */
{"m", UNITS, DTK_MINUTE}, /* "minute" relative time units */ {"m", UNITS, DTK_MINUTE}, /* "minute" relative time units */
{"microsecon", UNITS, DTK_MILLISEC}, /* "microsecond" relative {"microsecon", UNITS, DTK_MILLISEC}, /* "microsecond" relative time units */
* time units */
{"mil", UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ {"mil", UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */
{"mils", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ {"mils", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */
{"millenia", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ {"millenia", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */
{DMILLENIUM, UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ {DMILLENIUM, UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */
{"millisecon", UNITS, DTK_MILLISEC}, /* "millisecond" relative {"millisecon", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */
* time units */
{"min", UNITS, DTK_MINUTE}, /* "minute" relative time units */ {"min", UNITS, DTK_MINUTE}, /* "minute" relative time units */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */ {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative time units */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */ {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative time units */
{DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative time units */ {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative time units */
{"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative time units */ {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative time units */
{"mon", UNITS, DTK_MONTH}, /* "months" relative time units */ {"mon", UNITS, DTK_MONTH}, /* "months" relative time units */
{"mons", UNITS, DTK_MONTH}, /* "months" relative time units */ {"mons", UNITS, DTK_MONTH}, /* "months" relative time units */
{DMONTH, UNITS, DTK_MONTH}, /* "month" relative time units */ {DMONTH, UNITS, DTK_MONTH}, /* "month" relative time units */
{"months", UNITS, DTK_MONTH}, /* "months" relative time units */ {"months", UNITS, DTK_MONTH}, /* "months" relative time units */
{"ms", UNITS, DTK_MILLISEC},/* "millisecond" relative time units */ {"ms", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */
{"msec", UNITS, DTK_MILLISEC}, /* "millisecond" relative time {"msec", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */
* units */ {DMILLISEC, UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */
{DMILLISEC, UNITS, DTK_MILLISEC}, /* "millisecond" relative time {"mseconds", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time units */
* units */ {"msecs", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time units */
{"mseconds", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative time units */
* units */
{"msecs", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time
* units */
{"qtr", UNITS, DTK_QUARTER},/* "quarter" relative time units */
{DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative time units */ {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative time units */
{"reltime", IGNORE, 0}, /* "reltime" for pre-v6.1 "Undefined {"reltime", IGNORE, 0}, /* "reltime" for pre-v6.1 "Undefined Reltime" */
* Reltime" */
{"s", UNITS, DTK_SECOND}, /* "second" relative time units */ {"s", UNITS, DTK_SECOND}, /* "second" relative time units */
{"sec", UNITS, DTK_SECOND}, /* "second" relative time units */ {"sec", UNITS, DTK_SECOND}, /* "second" relative time units */
{DSECOND, UNITS, DTK_SECOND}, /* "second" relative time units */ {DSECOND, UNITS, DTK_SECOND}, /* "second" relative time units */
{"seconds", UNITS, DTK_SECOND}, /* "seconds" relative time units */ {"seconds", UNITS, DTK_SECOND}, /* "seconds" relative time units */
{"secs", UNITS, DTK_SECOND},/* "seconds" relative time units */ {"secs", UNITS, DTK_SECOND}, /* "seconds" relative time units */
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"tz", UNITS, DTK_TZ}, /* "timezone" time offset */ {"tz", UNITS, DTK_TZ}, /* "timezone" time offset */
{"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid time */
* time */ {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */
{"us", UNITS, DTK_MICROSEC},/* "microsecond" relative time units */ {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative time {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */
* units */ {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative time units */
{DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative time {"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative time units */
* units */
{"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative time
* units */
{"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative time
* units */
{"w", UNITS, DTK_WEEK}, /* "week" relative time units */ {"w", UNITS, DTK_WEEK}, /* "week" relative time units */
{DWEEK, UNITS, DTK_WEEK}, /* "week" relative time units */ {DWEEK, UNITS, DTK_WEEK}, /* "week" relative time units */
{"weeks", UNITS, DTK_WEEK}, /* "weeks" relative time units */ {"weeks", UNITS, DTK_WEEK}, /* "weeks" relative time units */
@ -3719,7 +3703,6 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm,
#if READ_FORWARD #if READ_FORWARD
int is_neg = FALSE; int is_neg = FALSE;
#endif #endif
int fmask = 0, int fmask = 0,
@ -3734,7 +3717,7 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm,
*dtype = DTK_DELTA; *dtype = DTK_DELTA;
type = SECOND; type = DTK_SECOND;
tm->tm_year = 0; tm->tm_year = 0;
tm->tm_mon = 0; tm->tm_mon = 0;
tm->tm_mday = 0; tm->tm_mday = 0;