38 int fmask,
int *tmask,
41 int fmask,
int *tmask,
44 int *tmask,
struct pg_itm *itm);
50 static int DecodeDate(
char *
str,
int fmask,
int *tmask,
bool *is2digits,
53 int precision,
bool fillzeros);
71 const char *abbr,
pg_tz *tzp,
72 int *offset,
int *isdst);
79 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
80 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}
83 const char *
const months[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
84 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec", NULL};
86 const char *
const days[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
87 "Thursday",
"Friday",
"Saturday", NULL};
118 {
"august",
MONTH, 8},
122 {
"december",
MONTH, 12},
128 {
"february",
MONTH, 2},
137 {
"january",
MONTH, 1},
152 {
"november",
MONTH, 11},
155 {
"october",
MONTH, 10},
160 {
"saturday",
DOW, 6},
163 {
"september",
MONTH, 9},
170 {
"thursday",
DOW, 4},
177 {
"wednesday",
DOW, 3},
304 century = year / 100;
305 julian = year * 365 - 32167;
306 julian += year / 4 - century + century / 4;
307 julian += 7834 * month / 256 + day;
313 j2date(
int jd,
int *year,
int *month,
int *day)
322 quad = julian / 146097;
323 extra = (julian - quad * 146097) * 4 + 3;
324 julian += 60 + quad * 3 + extra / 146097;
325 quad = julian / 1461;
326 julian -= quad * 1461;
327 y = julian * 4 / 1461;
328 julian = ((
y != 0) ? ((julian + 305) % 365) : ((julian + 306) % 366))
332 quad = julian * 2141 / 65536;
333 *day = julian - 7834 * quad / 256;
402 static pg_tz *cache_timezone = NULL;
403 static struct pg_tm cache_tm;
413 cache_timezone = NULL;
420 if (
timestamp2tm(cur_ts, &cache_tz, &cache_tm, &cache_fsec,
423 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
424 errmsg(
"timestamp out of range")));
463 char *end = &cp[precision + 1];
464 bool gotnonzero =
false;
479 remainder = oldval -
value * 10;
486 cp[precision] =
'0' + remainder;
488 end = &cp[precision];
559 else if (frac < -0.5)
585 extra_days = (int) frac;
639 if (val < INT_MIN || val > INT_MAX)
653 if (val < INT_MIN || val > INT_MAX)
668 if (val < INT_MIN || val > INT_MAX)
698 *frac = strtod(cp, &cp);
700 if (*cp !=
'\0' || errno != 0)
719 *fsec = rint(frac * 1000000);
757 char **field,
int *ftype,
int maxfields,
int *numfields)
760 const char *cp = timestr;
761 char *bufp = workbuf;
762 const char *bufend = workbuf + buflen;
770 #define APPEND_CHAR(bufptr, end, newchar) \
773 if (((bufptr) + 1) >= (end)) \
774 return DTERR_BAD_FORMAT; \
775 *(bufptr)++ = newchar; \
782 if (isspace((
unsigned char) *cp))
794 if (isdigit((
unsigned char) *cp))
797 while (isdigit((
unsigned char) *cp))
805 while (isdigit((
unsigned char) *cp) ||
806 (*cp ==
':') || (*cp ==
'.'))
810 else if (*cp ==
'-' || *cp ==
'/' || *cp ==
'.')
817 if (isdigit((
unsigned char) *cp))
820 while (isdigit((
unsigned char) *cp))
831 while (isdigit((
unsigned char) *cp) || *cp == delim)
838 while (isalnum((
unsigned char) *cp) || *cp == delim)
854 while (isdigit((
unsigned char) *cp))
863 else if (isalpha((
unsigned char) *cp))
869 while (isalpha((
unsigned char) *cp))
881 if (*cp ==
'-' || *cp ==
'/' || *cp ==
'.')
883 else if (*cp ==
'+' || isdigit((
unsigned char) *cp))
896 }
while (*cp ==
'+' || *cp ==
'-' ||
897 *cp ==
'/' || *cp ==
'_' ||
898 *cp ==
'.' || *cp ==
':' ||
899 isalnum((
unsigned char) *cp));
903 else if (*cp ==
'+' || *cp ==
'-')
907 while (isspace((
unsigned char) *cp))
911 if (isdigit((
unsigned char) *cp))
915 while (isdigit((
unsigned char) *cp) ||
916 *cp ==
':' || *cp ==
'.' || *cp ==
'-')
920 else if (isalpha((
unsigned char) *cp))
924 while (isalpha((
unsigned char) *cp))
932 else if (ispunct((
unsigned char) *cp))
992 bool haveTextMonth =
false;
993 bool isjulian =
false;
994 bool is2digits =
false;
996 pg_tz *namedTz = NULL;
997 pg_tz *abbrevTz = NULL;
1000 struct pg_tm cur_tm;
1016 for (
i = 0;
i < nf;
i++)
1037 if (errno == ERANGE || jday < 0)
1063 else if (ptype != 0 ||
1071 if (isdigit((
unsigned char) *field[
i]) || ptype != 0)
1094 if ((cp = strchr(field[
i],
'-')) == NULL)
1135 &tmask, &is2digits,
tm);
1191 if (errno == ERANGE)
1193 if (*cp !=
'.' && *cp !=
'\0')
1247 flen = strlen(field[
i]);
1248 cp = strchr(field[
i],
'.');
1254 &tmask, &is2digits,
tm);
1259 else if (cp != NULL && flen - strlen(cp) > 2)
1282 else if (flen >= 6 && (!(fmask &
DTK_DATE_M) ||
1295 haveTextMonth, fmask,
1372 elog(
ERROR,
"unrecognized RESERV datetime token: %d",
1384 if ((fmask &
DTK_M(
MONTH)) && !haveTextMonth &&
1391 haveTextMonth =
true;
1534 if (namedTz != NULL)
1547 if (abbrevTz != NULL)
1557 if (tzp != NULL && !(fmask &
DTK_M(
TZ)))
1619 long int before_gmtoff,
1641 if (mytime < 0 && day > 0)
1651 if (mytime < 0 && prevtime > 0)
1655 &before_gmtoff, &before_isdst,
1657 &after_gmtoff, &after_isdst,
1666 *tp = mytime - before_gmtoff;
1667 return -(int) before_gmtoff;
1673 beforetime = mytime - before_gmtoff;
1674 if ((before_gmtoff > 0 &&
1675 mytime < 0 && beforetime > 0) ||
1676 (before_gmtoff <= 0 &&
1677 mytime > 0 && beforetime < 0))
1679 aftertime = mytime - after_gmtoff;
1680 if ((after_gmtoff > 0 &&
1681 mytime < 0 && aftertime > 0) ||
1682 (after_gmtoff <= 0 &&
1683 mytime > 0 && aftertime < 0))
1691 if (beforetime < boundary && aftertime < boundary)
1695 return -(int) before_gmtoff;
1697 if (beforetime > boundary && aftertime >= boundary)
1701 return -(int) after_gmtoff;
1715 if (beforetime > aftertime)
1719 return -(int) before_gmtoff;
1723 return -(int) after_gmtoff;
1765 &abbr_offset, &abbr_isdst))
1787 pg_tz *tzp,
int *isdst)
1800 &abbr_offset, isdst))
1808 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1809 errmsg(
"timestamp out of range")));
1824 int *offset,
int *isdst)
1831 strlcpy(upabbr, abbr,
sizeof(upabbr));
1832 for (p = (
unsigned char *) upabbr; *p; p++)
1843 *offset = (int) -gmtoff;
1877 bool isjulian =
false;
1878 bool is2digits =
false;
1881 pg_tz *namedTz = NULL;
1882 pg_tz *abbrevTz = NULL;
1883 char *abbrev = NULL;
1897 for (
i = 0;
i < nf;
i++)
1911 if (
i == 0 && nf >= 2 &&
1915 &tmask, &is2digits,
tm);
1922 if (isdigit((
unsigned char) *field[
i]))
1936 if ((cp = strchr(field[
i],
'-')) == NULL)
2009 if (errno == ERANGE)
2011 if (*cp !=
'.' && *cp !=
'\0')
2068 flen = strlen(field[
i]);
2069 cp = strchr(field[
i],
'.');
2078 if (
i == 0 && nf >= 2 && ftype[nf - 1] ==
DTK_DATE)
2081 &tmask, &is2digits,
tm);
2086 else if (flen - strlen(cp) > 2)
2291 if (namedTz != NULL)
2302 *tzp = -(int) gmtoff;
2316 if (abbrevTz != NULL)
2346 if (tzp != NULL && !(fmask &
DTK_M(
TZ)))
2397 bool haveTextMonth =
false;
2409 while (*
str !=
'\0' && !isalnum((
unsigned char) *
str))
2416 if (isdigit((
unsigned char) *
str))
2418 while (isdigit((
unsigned char) *
str))
2421 else if (isalpha((
unsigned char) *
str))
2423 while (isalpha((
unsigned char) *
str))
2434 for (
i = 0;
i < nf;
i++)
2436 if (isalpha((
unsigned char) *field[
i]))
2447 haveTextMonth =
true;
2465 for (
i = 0;
i < nf;
i++)
2467 if (field[
i] == NULL)
2470 if ((
len = strlen(field[
i])) <= 0)
2582 int *tmask,
struct pg_itm *itm)
2592 if (errno == ERANGE)
2598 if (errno == ERANGE)
2613 else if (*cp ==
'.')
2625 else if (*cp ==
':')
2629 if (errno == ERANGE)
2637 else if (*cp !=
'\0')
2719 int *tmask,
struct pg_tm *
tm,
fsec_t *fsec,
bool *is2digits)
2729 if (errno == ERANGE)
2755 else if (*cp !=
'\0')
2836 if (flen >= 3 && *is2digits)
2889 *is2digits = (flen <= 2);
2904 int *tmask,
struct pg_tm *
tm,
fsec_t *fsec,
bool *is2digits)
2912 if ((cp = strchr(
str,
'.')) != NULL)
2928 frac = strtod(cp, NULL);
2931 *fsec = rint(frac * 1000000);
2949 *(
str + (
len - 2)) =
'\0';
2951 *(
str + (
len - 4)) =
'\0';
3007 if (*
str !=
'+' && *
str !=
'-')
3012 if (errno == ERANGE)
3020 if (errno == ERANGE)
3026 if (errno == ERANGE)
3031 else if (*cp ==
'\0' && strlen(
str) > 3)
3083 int *ftype,
int *offset,
pg_tz **tz,
3117 *offset = tp->
value;
3222 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3223 errmsg(
"time zone \"%s\" not recognized", tzname)));
3279 bool force_negative =
false;
3280 bool is_before =
false;
3281 bool parsing_unit_val =
false;
3314 force_negative =
true;
3316 for (
i = 1;
i < nf;
i++)
3318 if (*field[
i] ==
'-' || *field[
i] ==
'+')
3320 force_negative =
false;
3327 for (
i = nf - 1;
i >= 0;
i--)
3336 if (force_negative &&
3340 parsing_unit_val =
false;
3350 Assert(*field[
i] ==
'-' || *field[
i] ==
'+');
3356 if (strchr(field[
i] + 1,
':') != NULL &&
3358 &tmask, itm_in) == 0)
3360 if (*field[
i] ==
'-')
3368 if (force_negative &&
3378 parsing_unit_val =
false;
3429 if (errno == ERANGE)
3443 if (*field[
i] ==
'-')
3451 else if (*cp ==
'.')
3456 if (*field[
i] ==
'-')
3459 else if (*cp ==
'\0')
3568 parsing_unit_val =
false;
3574 if (parsing_unit_val)
3585 parsing_unit_val =
true;
3619 if (parsing_unit_val)
3627 itm_in->
tm_mon == INT_MIN ||
3665 if (!(isdigit((
unsigned char) *
str) || *
str ==
'-' || *
str ==
'.'))
3668 val = strtod(
str, endptr);
3670 if (*endptr ==
str || errno != 0)
3673 if (isnan(
val) || val < -1.0e15 || val > 1.0e15)
3677 *ipart = (int64) floor(
val);
3679 *ipart = (int64) -floor(-
val);
3680 *fpart =
val - *ipart;
3682 Assert(*fpart > -1.0 && *fpart < 1.0);
3694 if (*fieldstart ==
'-')
3696 return strspn(fieldstart,
"0123456789");
3721 bool datepart =
true;
3722 bool havefield =
false;
3727 if (strlen(
str) < 2 ||
str[0] !=
'P')
3982 const char *
str,
const char *datatype,
3989 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3990 errmsg(
"date/time field value out of range: \"%s\"",
3996 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3997 errmsg(
"date/time field value out of range: \"%s\"",
3999 errhint(
"Perhaps you need a different \"datestyle\" setting.")));
4003 (
errcode(ERRCODE_INTERVAL_FIELD_OVERFLOW),
4004 errmsg(
"interval field value out of range: \"%s\"",
4009 (
errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE),
4010 errmsg(
"time zone displacement out of range: \"%s\"",
4015 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4016 errmsg(
"time zone \"%s\" not recognized",
4021 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4022 errmsg(
"time zone \"%s\" not recognized",
4024 errdetail(
"This time zone name appears in the configuration file for time zone abbreviation \"%s\".",
4030 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4031 errmsg(
"invalid input syntax for type %s: \"%s\"",
4046 const datetkn *last = base + nel - 1,
4050 while (last >= base)
4052 position = base + ((last - base) >> 1);
4054 result = (int)
key[0] - (
int) position->token[0];
4063 last = position - 1;
4065 base = position + 1;
4091 *
str++ = (tz <= 0 ?
'+' :
'-');
4185 memcpy(
str,
" BC", 3);
4389 memcpy(
str,
" BC", 3);
4407 return cp + strlen(cp);
4413 bool *is_zero,
bool *is_before)
4418 (!*is_zero) ?
" " :
"",
4419 (*is_before &&
value > 0) ?
"+" :
"",
4422 (
value != 1) ?
"s" :
"");
4428 *is_before = (
value < 0);
4430 return cp + strlen(cp);
4436 bool *is_zero,
bool *is_before)
4443 *is_before = (
value < 0);
4446 else if (*is_before)
4450 return cp + strlen(cp);
4484 bool is_before =
false;
4485 bool is_zero =
true;
4498 bool has_negative = year < 0 || mon < 0 ||
4499 mday < 0 || hour < 0 ||
4500 min < 0 || sec < 0 || fsec < 0;
4501 bool has_positive = year > 0 || mon > 0 ||
4502 mday > 0 || hour > 0 ||
4503 min > 0 || sec > 0 || fsec > 0;
4504 bool has_year_month = year != 0 || mon != 0;
4505 bool has_day_time = mday != 0 || hour != 0 ||
4506 min != 0 || sec != 0 || fsec != 0;
4507 bool has_day = mday != 0;
4508 bool sql_standard_value = !(has_negative && has_positive) &&
4509 !(has_year_month && has_day_time);
4515 if (has_negative && sql_standard_value)
4527 if (!has_negative && !has_positive)
4531 else if (!sql_standard_value)
4538 char year_sign = (year < 0 || mon < 0) ?
'-' :
'+';
4539 char day_sign = (mday < 0) ?
'-' :
'+';
4540 char sec_sign = (hour < 0 || min < 0 ||
4541 sec < 0 || fsec < 0) ?
'-' :
'+';
4543 sprintf(cp,
"%c%d-%d %c%lld %c%lld:%02d:",
4544 year_sign, abs(year), abs(mon),
4545 day_sign, (
long long)
i64abs(mday),
4546 sec_sign, (
long long)
i64abs(hour), abs(min));
4551 else if (has_year_month)
4553 sprintf(cp,
"%d-%d", year, mon);
4557 sprintf(cp,
"%lld %lld:%02d:",
4558 (
long long) mday, (
long long) hour, min);
4565 sprintf(cp,
"%lld:%02d:", (
long long) hour, min);
4576 if (year == 0 && mon == 0 && mday == 0 &&
4577 hour == 0 && min == 0 && sec == 0 && fsec == 0)
4586 if (hour != 0 || min != 0 || sec != 0 || fsec != 0)
4590 if (sec != 0 || fsec != 0)
4592 if (sec < 0 || fsec < 0)
4611 if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0)
4613 bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
4615 sprintf(cp,
"%s%s%02lld:%02d:",
4617 (minus ?
"-" : (is_before ?
"+" :
"")),
4618 (
long long)
i64abs(hour), abs(min));
4635 if (sec != 0 || fsec != 0)
4638 if (sec < 0 || (sec == 0 && fsec < 0))
4642 else if (!is_before)
4650 (abs(sec) != 1 || fsec != 0) ?
"s" :
"");
4673 for (
i = 0;
i < nel;
i++)
4679 elog(
LOG,
"token too long in %s table: \"%.*s\"",
4689 elog(
LOG,
"ordering error in %s table: \"%s\" >= \"%s\"",
4745 if (new_precis < 0 || new_precis == max_precis ||
4746 (old_precis >= 0 && new_precis >= old_precis))
4773 for (
i = 0;
i < n;
i++)
4775 struct tzEntry *abbr = abbrevs +
i;
4777 if (abbr->
zone != NULL)
4782 strlen(abbr->
zone) + 1;
4799 for (
i = 0;
i < n;
i++)
4801 struct tzEntry *abbr = abbrevs +
i;
4806 if (abbr->
zone != NULL)
4821 strlen(abbr->
zone) + 1;
4871 if (dtza->
tz == NULL)
4874 if (dtza->
tz == NULL)
4897 bool nulls[3] = {0};
4921 pindex = (
int *)
palloc(
sizeof(
int));
4926 elog(
ERROR,
"return type must be a row type");
4945 gmtoffset = tp->
value;
4949 gmtoffset = tp->
value;
4969 is_dst = (
bool) isdst;
4973 elog(
ERROR,
"unrecognized timezone type %d", (
int) tp->
type);
4984 for (p = (
unsigned char *) buffer; *p; p++)
5017 bool nulls[4] = {0};
5039 &tzoff, &
tm, &fsec, &tzn, tz) != 0)
5051 if (tzn && strlen(tzn) > 31)
static const datetkn * abbrevcache[MAXDATEFIELDS]
static int DecodeDate(char *str, int fmask, int *tmask, bool *is2digits, struct pg_tm *tm)
static int DetermineTimeZoneOffsetInternal(struct pg_tm *tm, pg_tz *tzp, pg_time_t *tp)
static char * AddVerboseIntPart(char *cp, int64 value, const char *units, bool *is_zero, bool *is_before)
#define APPEND_CHAR(bufptr, end, newchar)
static int DecodeNumberField(int len, char *str, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits)
pg_tz * DecodeTimezoneNameToTz(const char *tzname)
static char * AddPostgresIntPart(char *cp, int64 value, const char *units, bool *is_zero, bool *is_before)
static bool CheckDateTokenTable(const char *tablename, const datetkn *base, int nel)
int DetermineTimeZoneAbbrevOffsetTS(TimestampTz ts, const char *abbr, pg_tz *tzp, int *isdst)
static int ParseFraction(char *cp, double *frac)
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
static const datetkn datetktbl[]
static bool int64_multiply_add(int64 val, int64 multiplier, int64 *sum)
int DecodeUnits(int field, const char *lowtoken, int *val)
static char * EncodeTimezone(char *str, int tz, int style)
int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)
static TimeZoneAbbrevTable * zoneabbrevtbl
static const datetkn * deltacache[MAXDATEFIELDS]
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
void EncodeInterval(struct pg_itm *itm, int style, char *str)
static bool AdjustDays(int64 val, int scale, struct pg_itm_in *itm_in)
static const datetkn * datecache[MAXDATEFIELDS]
static int DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits)
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
static bool DetermineTimeZoneAbbrevOffsetInternal(pg_time_t t, const char *abbr, pg_tz *tzp, int *offset, int *isdst)
static char * AddISO8601IntPart(char *cp, int64 value, char units)
void DateTimeParseError(int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext)
static int ParseFractionalSecond(char *cp, fsec_t *fsec)
static bool AdjustFractYears(double frac, int scale, struct pg_itm_in *itm_in)
static bool AdjustMicroseconds(int64 val, double fval, int64 scale, struct pg_itm_in *itm_in)
static int DecodeTimeCommon(char *str, int fmask, int range, int *tmask, struct pg_itm *itm)
int DecodeInterval(char **field, int *ftype, int nf, int range, int *dtype, struct pg_itm_in *itm_in)
static int DecodeTimeForInterval(char *str, int fmask, int range, int *tmask, struct pg_itm_in *itm_in)
bool CheckDateTokenTables(void)
static const int szdeltatktbl
int DecodeTimezoneAbbrev(int field, const char *lowtoken, int *ftype, int *offset, pg_tz **tz, DateTimeErrorExtra *extra)
Datum pg_timezone_names(PG_FUNCTION_ARGS)
void EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, int style, char *str)
static int DecodeTime(char *str, int fmask, int range, int *tmask, struct pg_tm *tm, fsec_t *fsec)
static bool AdjustFractMicroseconds(double frac, int64 scale, struct pg_itm_in *itm_in)
int DecodeISO8601Interval(char *str, int *dtype, struct pg_itm_in *itm_in)
int ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm)
int DecodeSpecial(int field, const char *lowtoken, int *val)
void j2date(int jd, int *year, int *month, int *day)
void GetCurrentDateTime(struct pg_tm *tm)
static int ISO8601IntegerWidth(char *fieldstart)
static bool AdjustYears(int64 val, int scale, struct pg_itm_in *itm_in)
Datum pg_timezone_abbrevs(PG_FUNCTION_ARGS)
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
void EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
int DecodeTimezone(const char *str, int *tzp)
const char *const months[]
static bool AdjustMonths(int64 val, struct pg_itm_in *itm_in)
static char * AppendSeconds(char *cp, int sec, fsec_t fsec, int precision, bool fillzeros)
static const int szdatetktbl
void EncodeDateOnly(struct pg_tm *tm, int style, char *str)
static char * AppendTimestampSeconds(char *cp, struct pg_tm *tm, fsec_t fsec)
static const datetkn * datebsearch(const char *key, const datetkn *base, int nel)
static int ParseISO8601Number(char *str, char **endptr, int64 *ipart, double *fpart)
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)
int date2j(int year, int month, int day)
static bool AdjustFractDays(double frac, int scale, struct pg_itm_in *itm_in)
static void ClearPgItmIn(struct pg_itm_in *itm_in)
static const datetkn deltatktbl[]
void GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp)
static pg_tz * FetchDynamicTimeZone(TimeZoneAbbrevTable *tbl, const datetkn *tp, DateTimeErrorExtra *extra)
int DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)
Node * TemporalSimplify(int32 max_precis, Node *node)
int DetermineTimeZoneAbbrevOffset(struct pg_tm *tm, const char *abbr, pg_tz *tzp)
void dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
int itmin2interval(struct pg_itm_in *itm_in, Interval *span)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
Datum now(PG_FUNCTION_ARGS)
pg_time_t timestamptz_to_time_t(TimestampTz t)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define strtoi64(str, endptr, base)
#define MemSet(start, val, len)
#define MAX_TIMESTAMP_PRECISION
#define IS_VALID_JULIAN(y, m, d)
#define MAX_INTERVAL_PRECISION
#define POSTGRES_EPOCH_JDATE
bool time_overflows(int hour, int min, int sec, fsec_t fsec)
#define MAX_TIME_PRECISION
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define errsave(context,...)
#define ereport(elevel,...)