Commit 666cbae1 authored by Peter Eisentraut's avatar Peter Eisentraut

Remove explicit error handling for obsolete date/time values

The date/time values 'current', 'invalid', and 'undefined' were
removed a long time ago, but the code still contains explicit error
handling for the transition.  To simplify the code and avoid having to
handle these values everywhere, just remove the recognition of these
tokens altogether now.
Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
parent 54100f5c
...@@ -138,14 +138,6 @@ date_in(PG_FUNCTION_ARGS) ...@@ -138,14 +138,6 @@ date_in(PG_FUNCTION_ARGS)
case DTK_DATE: case DTK_DATE:
break; break;
case DTK_CURRENT:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"current\" is no longer supported")));
GetCurrentDateTime(tm);
break;
case DTK_EPOCH: case DTK_EPOCH:
GetEpochTime(tm); GetEpochTime(tm);
break; break;
......
...@@ -99,7 +99,6 @@ static const datetkn datetktbl[] = { ...@@ -99,7 +99,6 @@ static const datetkn datetktbl[] = {
{"aug", MONTH, 8}, {"aug", MONTH, 8},
{"august", MONTH, 8}, {"august", MONTH, 8},
{DB_C, ADBC, BC}, /* "bc" for years <= 0 */ {DB_C, ADBC, BC}, /* "bc" for years <= 0 */
{DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */
{"d", UNITS, DTK_DAY}, /* "day of month" for ISO input */ {"d", UNITS, DTK_DAY}, /* "day of month" for ISO input */
{"dec", MONTH, 12}, {"dec", MONTH, 12},
{"december", MONTH, 12}, {"december", MONTH, 12},
...@@ -113,7 +112,6 @@ static const datetkn datetktbl[] = { ...@@ -113,7 +112,6 @@ static const datetkn datetktbl[] = {
{"friday", DOW, 5}, {"friday", DOW, 5},
{"h", UNITS, DTK_HOUR}, /* "hour" */ {"h", UNITS, DTK_HOUR}, /* "hour" */
{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 bad time */
{"isodow", UNITS, DTK_ISODOW}, /* ISO day of week, Sunday == 7 */ {"isodow", UNITS, DTK_ISODOW}, /* ISO day of week, Sunday == 7 */
{"isoyear", UNITS, DTK_ISOYEAR}, /* year in terms of the ISO week date */ {"isoyear", UNITS, DTK_ISOYEAR}, /* year in terms of the ISO week date */
{"j", UNITS, DTK_JULIAN}, {"j", UNITS, DTK_JULIAN},
...@@ -157,7 +155,6 @@ static const datetkn datetktbl[] = { ...@@ -157,7 +155,6 @@ static const datetkn datetktbl[] = {
{"tue", DOW, 2}, {"tue", DOW, 2},
{"tues", DOW, 2}, {"tues", DOW, 2},
{"tuesday", DOW, 2}, {"tuesday", DOW, 2},
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"wed", DOW, 3}, {"wed", DOW, 3},
{"wednesday", DOW, 3}, {"wednesday", DOW, 3},
{"weds", DOW, 3}, {"weds", DOW, 3},
...@@ -191,7 +188,6 @@ static const datetkn deltatktbl[] = { ...@@ -191,7 +188,6 @@ static const datetkn deltatktbl[] = {
{"hours", UNITS, DTK_HOUR}, /* "hours" relative */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
{"hr", UNITS, DTK_HOUR}, /* "hour" relative */ {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
{"hrs", UNITS, DTK_HOUR}, /* "hours" relative */ {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
{INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
{"m", UNITS, DTK_MINUTE}, /* "minute" relative */ {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
{"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
...@@ -222,7 +218,6 @@ static const datetkn deltatktbl[] = { ...@@ -222,7 +218,6 @@ static const datetkn deltatktbl[] = {
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */ {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
{"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */ {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
...@@ -1186,14 +1181,6 @@ DecodeDateTime(char **field, int *ftype, int nf, ...@@ -1186,14 +1181,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
case RESERV: case RESERV:
switch (val) switch (val)
{ {
case DTK_CURRENT:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"current\" is no longer supported")));
return DTERR_BAD_FORMAT;
break;
case DTK_NOW: case DTK_NOW:
tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ)); tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
*dtype = DTK_DATE; *dtype = DTK_DATE;
...@@ -2097,13 +2084,6 @@ DecodeTimeOnly(char **field, int *ftype, int nf, ...@@ -2097,13 +2084,6 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
case RESERV: case RESERV:
switch (val) switch (val)
{ {
case DTK_CURRENT:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"current\" is no longer supported")));
return DTERR_BAD_FORMAT;
break;
case DTK_NOW: case DTK_NOW:
tmask = DTK_TIME_M; tmask = DTK_TIME_M;
*dtype = DTK_TIME; *dtype = DTK_TIME;
......
...@@ -188,14 +188,6 @@ timestamp_in(PG_FUNCTION_ARGS) ...@@ -188,14 +188,6 @@ timestamp_in(PG_FUNCTION_ARGS)
TIMESTAMP_NOBEGIN(result); TIMESTAMP_NOBEGIN(result);
break; break;
case DTK_INVALID:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"%s\" is no longer supported", str)));
TIMESTAMP_NOEND(result);
break;
default: default:
elog(ERROR, "unexpected dtype %d while parsing timestamp \"%s\"", elog(ERROR, "unexpected dtype %d while parsing timestamp \"%s\"",
dtype, str); dtype, str);
...@@ -439,14 +431,6 @@ timestamptz_in(PG_FUNCTION_ARGS) ...@@ -439,14 +431,6 @@ timestamptz_in(PG_FUNCTION_ARGS)
TIMESTAMP_NOBEGIN(result); TIMESTAMP_NOBEGIN(result);
break; break;
case DTK_INVALID:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"%s\" is no longer supported", str)));
TIMESTAMP_NOEND(result);
break;
default: default:
elog(ERROR, "unexpected dtype %d while parsing timestamptz \"%s\"", elog(ERROR, "unexpected dtype %d while parsing timestamptz \"%s\"",
dtype, str); dtype, str);
...@@ -946,12 +930,6 @@ interval_in(PG_FUNCTION_ARGS) ...@@ -946,12 +930,6 @@ interval_in(PG_FUNCTION_ARGS)
errmsg("interval out of range"))); errmsg("interval out of range")));
break; break;
case DTK_INVALID:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("date/time value \"%s\" is no longer supported", str)));
break;
default: default:
elog(ERROR, "unexpected dtype %d while parsing interval \"%s\"", elog(ERROR, "unexpected dtype %d while parsing interval \"%s\"",
dtype, str); dtype, str);
......
...@@ -148,8 +148,6 @@ struct tzEntry; ...@@ -148,8 +148,6 @@ struct tzEntry;
#define DTK_AGO 5 #define DTK_AGO 5
#define DTK_SPECIAL 6 #define DTK_SPECIAL 6
#define DTK_INVALID 7
#define DTK_CURRENT 8
#define DTK_EARLY 9 #define DTK_EARLY 9
#define DTK_LATE 10 #define DTK_LATE 10
#define DTK_EPOCH 11 #define DTK_EPOCH 11
......
...@@ -143,8 +143,6 @@ typedef int32 fsec_t; ...@@ -143,8 +143,6 @@ typedef int32 fsec_t;
#define DTK_AGO 5 #define DTK_AGO 5
#define DTK_SPECIAL 6 #define DTK_SPECIAL 6
#define DTK_INVALID 7
#define DTK_CURRENT 8
#define DTK_EARLY 9 #define DTK_EARLY 9
#define DTK_LATE 10 #define DTK_LATE 10
#define DTK_EPOCH 11 #define DTK_EPOCH 11
......
...@@ -111,7 +111,6 @@ static const datetkn datetktbl[] = { ...@@ -111,7 +111,6 @@ static const datetkn datetktbl[] = {
#endif #endif
{"cot", TZ, -18000}, /* Columbia Time */ {"cot", TZ, -18000}, /* Columbia Time */
{"cst", TZ, -21600}, /* Central Standard Time */ {"cst", TZ, -21600}, /* Central Standard Time */
{DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */
#if 0 #if 0
cvst cvst
#endif #endif
...@@ -201,7 +200,6 @@ static const datetkn datetktbl[] = { ...@@ -201,7 +200,6 @@ static const datetkn datetktbl[] = {
idt /* Israeli, Iran, Indian Daylight Time */ idt /* Israeli, Iran, Indian Daylight Time */
#endif #endif
{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 bad time */
{"iot", TZ, 18000}, /* Indian Chagos Time */ {"iot", TZ, 18000}, /* Indian Chagos Time */
{"irkst", DTZ, 32400}, /* Irkutsk Summer Time */ {"irkst", DTZ, 32400}, /* Irkutsk Summer Time */
{"irkt", TZ, 28800}, /* Irkutsk Time */ {"irkt", TZ, 28800}, /* Irkutsk Time */
...@@ -372,7 +370,6 @@ static const datetkn datetktbl[] = { ...@@ -372,7 +370,6 @@ static const datetkn datetktbl[] = {
#endif #endif
{"ulast", DTZ, 32400}, /* Ulan Bator Summer Time */ {"ulast", DTZ, 32400}, /* Ulan Bator Summer Time */
{"ulat", TZ, 28800}, /* Ulan Bator Time */ {"ulat", TZ, 28800}, /* Ulan Bator Time */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"ut", TZ, 0}, {"ut", TZ, 0},
{"utc", TZ, 0}, {"utc", TZ, 0},
{"uyst", DTZ, -7200}, /* Uruguay Summer Time */ {"uyst", DTZ, -7200}, /* Uruguay Summer Time */
...@@ -440,7 +437,6 @@ static const datetkn deltatktbl[] = { ...@@ -440,7 +437,6 @@ static const datetkn deltatktbl[] = {
{"hours", UNITS, DTK_HOUR}, /* "hours" relative */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
{"hr", UNITS, DTK_HOUR}, /* "hour" relative */ {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
{"hrs", UNITS, DTK_HOUR}, /* "hours" relative */ {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
{INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
{"m", UNITS, DTK_MINUTE}, /* "minute" relative */ {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
{"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
...@@ -471,7 +467,6 @@ static const datetkn deltatktbl[] = { ...@@ -471,7 +467,6 @@ static const datetkn deltatktbl[] = {
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */ {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
{"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */ {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
......
...@@ -253,10 +253,6 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr) ...@@ -253,10 +253,6 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
TIMESTAMP_NOBEGIN(result); TIMESTAMP_NOBEGIN(result);
break; break;
case DTK_INVALID:
errno = PGTYPES_TS_BAD_TIMESTAMP;
return noresult;
default: default:
errno = PGTYPES_TS_BAD_TIMESTAMP; errno = PGTYPES_TS_BAD_TIMESTAMP;
return noresult; return noresult;
......
...@@ -1444,9 +1444,6 @@ SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity ...@@ -1444,9 +1444,6 @@ SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity
SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized
ERROR: timestamp units "microsec" not recognized ERROR: timestamp units "microsec" not recognized
CONTEXT: SQL function "date_part" statement 1 CONTEXT: SQL function "date_part" statement 1
SELECT EXTRACT(UNDEFINED FROM DATE 'infinity'); -- ERROR: timestamp units "undefined" not supported
ERROR: timestamp units "undefined" not supported
CONTEXT: SQL function "date_part" statement 1
-- test constructors -- test constructors
select make_date(2013, 7, 15); select make_date(2013, 7, 15);
make_date make_date
......
...@@ -79,19 +79,6 @@ TRUNCATE TIMESTAMP_TBL; ...@@ -79,19 +79,6 @@ TRUNCATE TIMESTAMP_TBL;
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('epoch'); INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
ERROR: date/time value "invalid" is no longer supported
LINE 1: INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
^
INSERT INTO TIMESTAMP_TBL VALUES ('undefined');
ERROR: date/time value "undefined" is no longer supported
LINE 1: INSERT INTO TIMESTAMP_TBL VALUES ('undefined');
^
INSERT INTO TIMESTAMP_TBL VALUES ('current');
ERROR: date/time value "current" is no longer supported
LINE 1: INSERT INTO TIMESTAMP_TBL VALUES ('current');
^
-- Postgres v6.0 standard output format -- Postgres v6.0 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST'); INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
-- Variations on Postgres v6.1 standard output format -- Variations on Postgres v6.1 standard output format
......
...@@ -78,19 +78,6 @@ DELETE FROM TIMESTAMPTZ_TBL; ...@@ -78,19 +78,6 @@ DELETE FROM TIMESTAMPTZ_TBL;
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');
ERROR: date/time value "invalid" is no longer supported
LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');
^
INSERT INTO TIMESTAMPTZ_TBL VALUES ('undefined');
ERROR: date/time value "undefined" is no longer supported
LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('undefined');
^
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
ERROR: date/time value "current" is no longer supported
LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
^
-- Postgres v6.0 standard output format -- Postgres v6.0 standard output format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
-- Variations on Postgres v6.1 standard output format -- Variations on Postgres v6.1 standard output format
......
...@@ -334,7 +334,6 @@ SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity ...@@ -334,7 +334,6 @@ SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity
-- wrong fields from non-finite date: -- wrong fields from non-finite date:
-- --
SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized
SELECT EXTRACT(UNDEFINED FROM DATE 'infinity'); -- ERROR: timestamp units "undefined" not supported
-- test constructors -- test constructors
select make_date(2013, 7, 15); select make_date(2013, 7, 15);
......
...@@ -50,10 +50,6 @@ TRUNCATE TIMESTAMP_TBL; ...@@ -50,10 +50,6 @@ TRUNCATE TIMESTAMP_TBL;
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('epoch'); INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
INSERT INTO TIMESTAMP_TBL VALUES ('undefined');
INSERT INTO TIMESTAMP_TBL VALUES ('current');
-- Postgres v6.0 standard output format -- Postgres v6.0 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST'); INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
......
...@@ -49,10 +49,6 @@ DELETE FROM TIMESTAMPTZ_TBL; ...@@ -49,10 +49,6 @@ DELETE FROM TIMESTAMPTZ_TBL;
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('undefined');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
-- Postgres v6.0 standard output format -- Postgres v6.0 standard output format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST'); INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment