]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/adt/datetime.c
Fix initialization of fake LSN for unlogged relations
[postgresql] / src / backend / utils / adt / datetime.c
index 9def318c57d37baaf6fba8aae0f4a151833d921d..e38bd930543f9e1a1462d6b330e7e1637660884b 100644 (file)
@@ -99,7 +99,6 @@ static const datetkn datetktbl[] = {
        {"aug", MONTH, 8},
        {"august", MONTH, 8},
        {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 */
        {"dec", MONTH, 12},
        {"december", MONTH, 12},
@@ -113,7 +112,6 @@ static const datetkn datetktbl[] = {
        {"friday", DOW, 5},
        {"h", UNITS, DTK_HOUR},         /* "hour" */
        {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 */
        {"isoyear", UNITS, DTK_ISOYEAR},        /* year in terms of the ISO week date */
        {"j", UNITS, DTK_JULIAN},
@@ -157,7 +155,6 @@ static const datetkn datetktbl[] = {
        {"tue", DOW, 2},
        {"tues", DOW, 2},
        {"tuesday", DOW, 2},
-       {"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
        {"wed", DOW, 3},
        {"wednesday", DOW, 3},
        {"weds", DOW, 3},
@@ -191,7 +188,6 @@ static const datetkn deltatktbl[] = {
        {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
        {"hr", UNITS, DTK_HOUR},        /* "hour" relative */
        {"hrs", UNITS, DTK_HOUR},       /* "hours" relative */
-       {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
        {"m", UNITS, DTK_MINUTE},       /* "minute" relative */
        {"microsecon", UNITS, DTK_MICROSEC},    /* "microsecond" relative */
        {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
@@ -222,7 +218,6 @@ static const datetkn deltatktbl[] = {
        {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
        {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour 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 */
        {"usec", UNITS, DTK_MICROSEC},  /* "microsecond" relative */
        {DMICROSEC, UNITS, DTK_MICROSEC},       /* "microsecond" relative */
@@ -1186,14 +1181,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                        case RESERV:
                                                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:
                                                                tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
                                                                *dtype = DTK_DATE;
@@ -1868,7 +1855,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 
                                /*
                                 * Was this an "ISO time" with embedded field labels? An
-                                * example is "h04m05s06" - thomas 2001-02-04
+                                * example is "h04mm05s06" - thomas 2001-02-04
                                 */
                                if (ptype != 0)
                                {
@@ -2097,13 +2084,6 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                                        case RESERV:
                                                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:
                                                                tmask = DTK_TIME_M;
                                                                *dtype = DTK_TIME;
@@ -2300,6 +2280,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                        GetCurrentDateTime(tmp);
                else
                {
+                       /* a date has to be specified */
+                       if ((fmask & DTK_DATE_M) != DTK_DATE_M)
+                               return DTERR_BAD_FORMAT;
                        tmp->tm_year = tm->tm_year;
                        tmp->tm_mon = tm->tm_mon;
                        tmp->tm_mday = tm->tm_mday;
@@ -2327,6 +2310,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                        GetCurrentDateTime(tmp);
                else
                {
+                       /* a date has to be specified */
+                       if ((fmask & DTK_DATE_M) != DTK_DATE_M)
+                               return DTERR_BAD_FORMAT;
                        tmp->tm_year = tm->tm_year;
                        tmp->tm_mon = tm->tm_mon;
                        tmp->tm_mday = tm->tm_mday;
@@ -3049,7 +3035,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
 }
 
 
-/* ClearPgTM
+/* ClearPgTm
  *
  * Zero out a pg_tm and associated fsec_t
  */
@@ -4846,16 +4832,15 @@ pg_timezone_names(PG_FUNCTION_ARGS)
                        continue;                       /* ignore if conversion fails */
 
                /*
-                * Ignore zic's rather silly "Factory" time zone.  The long string
-                * about "see zic manual page" is used in tzdata versions before
-                * 2016g; we can drop it someday when we're pretty sure no such data
-                * exists in the wild on platforms using --with-system-tzdata.  In
-                * 2016g and later, the time zone abbreviation "-00" is used for
-                * "Factory" as well as some invalid cases, all of which we can
-                * reasonably omit from the pg_timezone_names view.
+                * IANA's rather silly "Factory" time zone used to emit ridiculously
+                * long "abbreviations" such as "Local time zone must be set--see zic
+                * manual page" or "Local time zone must be set--use tzsetup".  While
+                * modern versions of tzdb emit the much saner "-00", it seems some
+                * benighted packagers are hacking the IANA data so that it continues
+                * to produce these strings.  To prevent producing a weirdly wide
+                * abbrev column, reject ridiculously long abbreviations.
                 */
-               if (tzn && (strcmp(tzn, "-00") == 0 ||
-                                       strcmp(tzn, "Local time zone must be set--see zic manual page") == 0))
+               if (tzn && strlen(tzn) > 31)
                        continue;
 
                /* Found a displayable zone */