36 int fmask,
int *tmask,
39 int fmask,
int *tmask,
42 int *tmask,
struct pg_itm *itm);
48static int DecodeDate(
char *
str,
int fmask,
int *tmask,
bool *is2digits,
51 int precision,
bool fillzeros);
69 const char *abbr,
pg_tz *tzp,
70 int *offset,
int *isdst);
77 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
78 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}
81const char *
const months[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
82"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec", NULL};
84const char *
const days[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
85"Thursday",
"Friday",
"Saturday", NULL};
116 {
"august",
MONTH, 8},
120 {
"december",
MONTH, 12},
126 {
"february",
MONTH, 2},
135 {
"january",
MONTH, 1},
150 {
"november",
MONTH, 11},
153 {
"october",
MONTH, 10},
158 {
"saturday",
DOW, 6},
161 {
"september",
MONTH, 9},
168 {
"thursday",
DOW, 4},
175 {
"wednesday",
DOW, 3},
302 century = year / 100;
303 julian = year * 365 - 32167;
304 julian += year / 4 - century + century / 4;
305 julian += 7834 * month / 256 + day;
311j2date(
int jd,
int *year,
int *month,
int *day)
320 quad = julian / 146097;
321 extra = (julian - quad * 146097) * 4 + 3;
322 julian += 60 + quad * 3 + extra / 146097;
323 quad = julian / 1461;
324 julian -= quad * 1461;
325 y = julian * 4 / 1461;
326 julian = ((
y != 0) ? ((julian + 305) % 365) : ((julian + 306) % 366))
330 quad = julian * 2141 / 65536;
331 *day = julian - 7834 * quad / 256;
400 static pg_tz *cache_timezone = NULL;
401 static struct pg_tm cache_tm;
411 cache_timezone = NULL;
418 if (
timestamp2tm(cur_ts, &cache_tz, &cache_tm, &cache_fsec,
421 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
422 errmsg(
"timestamp out of range")));
461 char *end = &cp[precision + 1];
462 bool gotnonzero =
false;
477 remainder = oldval -
value * 10;
484 cp[precision] =
'0' + remainder;
486 end = &cp[precision];
557 else if (frac < -0.5)
583 extra_days = (int) frac;
637 if (val < INT_MIN || val > INT_MAX)
651 if (val < INT_MIN || val > INT_MAX)
666 if (val < INT_MIN || val > INT_MAX)
696 *frac = strtod(cp, &cp);
698 if (*cp !=
'\0' || errno != 0)
717 *fsec = rint(frac * 1000000);
755 char **field,
int *ftype,
int maxfields,
int *numfields)
758 const char *cp = timestr;
759 char *bufp = workbuf;
760 const char *bufend = workbuf + buflen;
768#define APPEND_CHAR(bufptr, end, newchar) \
771 if (((bufptr) + 1) >= (end)) \
772 return DTERR_BAD_FORMAT; \
773 *(bufptr)++ = newchar; \
780 if (isspace((
unsigned char) *cp))
792 if (isdigit((
unsigned char) *cp))
795 while (isdigit((
unsigned char) *cp))
803 while (isdigit((
unsigned char) *cp) ||
804 (*cp ==
':') || (*cp ==
'.'))
808 else if (*cp ==
'-' || *cp ==
'/' || *cp ==
'.')
815 if (isdigit((
unsigned char) *cp))
818 while (isdigit((
unsigned char) *cp))
829 while (isdigit((
unsigned char) *cp) || *cp == delim)
836 while (isalnum((
unsigned char) *cp) || *cp == delim)
852 while (isdigit((
unsigned char) *cp))
861 else if (isalpha((
unsigned char) *cp))
867 while (isalpha((
unsigned char) *cp))
879 if (*cp ==
'-' || *cp ==
'/' || *cp ==
'.')
881 else if (*cp ==
'+' || isdigit((
unsigned char) *cp))
894 }
while (*cp ==
'+' || *cp ==
'-' ||
895 *cp ==
'/' || *cp ==
'_' ||
896 *cp ==
'.' || *cp ==
':' ||
897 isalnum((
unsigned char) *cp));
901 else if (*cp ==
'+' || *cp ==
'-')
905 while (isspace((
unsigned char) *cp))
909 if (isdigit((
unsigned char) *cp))
913 while (isdigit((
unsigned char) *cp) ||
914 *cp ==
':' || *cp ==
'.' || *cp ==
'-')
918 else if (isalpha((
unsigned char) *cp))
922 while (isalpha((
unsigned char) *cp))
930 else if (ispunct((
unsigned char) *cp))
990 bool haveTextMonth =
false;
991 bool isjulian =
false;
992 bool is2digits =
false;
994 pg_tz *namedTz = NULL;
995 pg_tz *abbrevTz = NULL;
1014 for (
i = 0;
i < nf;
i++)
1035 if (errno == ERANGE || jday < 0)
1061 else if (ptype != 0 ||
1069 if (isdigit((
unsigned char) *field[
i]) || ptype != 0)
1092 if ((cp = strchr(field[
i],
'-')) == NULL)
1133 &tmask, &is2digits,
tm);
1189 if (errno == ERANGE)
1191 if (*cp !=
'.' && *cp !=
'\0')
1245 flen = strlen(field[
i]);
1246 cp = strchr(field[
i],
'.');
1252 &tmask, &is2digits,
tm);
1257 else if (cp != NULL && flen - strlen(cp) > 2)
1280 else if (flen >= 6 && (!(fmask &
DTK_DATE_M) ||
1293 haveTextMonth, fmask,
1370 elog(
ERROR,
"unrecognized RESERV datetime token: %d",
1382 if ((fmask &
DTK_M(
MONTH)) && !haveTextMonth &&
1389 haveTextMonth =
true;
1532 if (namedTz != NULL)
1545 if (abbrevTz != NULL)
1555 if (tzp != NULL && !(fmask &
DTK_M(
TZ)))
1617 long int before_gmtoff,
1639 if (mytime < 0 && day > 0)
1649 if (mytime < 0 && prevtime > 0)
1653 &before_gmtoff, &before_isdst,
1655 &after_gmtoff, &after_isdst,
1664 *tp = mytime - before_gmtoff;
1665 return -(int) before_gmtoff;
1671 beforetime = mytime - before_gmtoff;
1672 if ((before_gmtoff > 0 &&
1673 mytime < 0 && beforetime > 0) ||
1674 (before_gmtoff <= 0 &&
1675 mytime > 0 && beforetime < 0))
1677 aftertime = mytime - after_gmtoff;
1678 if ((after_gmtoff > 0 &&
1679 mytime < 0 && aftertime > 0) ||
1680 (after_gmtoff <= 0 &&
1681 mytime > 0 && aftertime < 0))
1689 if (beforetime < boundary && aftertime < boundary)
1693 return -(int) before_gmtoff;
1695 if (beforetime > boundary && aftertime >= boundary)
1699 return -(int) after_gmtoff;
1713 if (beforetime > aftertime)
1717 return -(int) before_gmtoff;
1721 return -(int) after_gmtoff;
1763 &abbr_offset, &abbr_isdst))
1785 pg_tz *tzp,
int *isdst)
1798 &abbr_offset, isdst))
1806 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1807 errmsg(
"timestamp out of range")));
1822 int *offset,
int *isdst)
1829 strlcpy(upabbr, abbr,
sizeof(upabbr));
1830 for (p = (
unsigned char *) upabbr; *p; p++)
1841 *offset = (int) -gmtoff;
1875 bool isjulian =
false;
1876 bool is2digits =
false;
1879 pg_tz *namedTz = NULL;
1880 pg_tz *abbrevTz = NULL;
1881 char *abbrev = NULL;
1895 for (
i = 0;
i < nf;
i++)
1909 if (
i == 0 && nf >= 2 &&
1913 &tmask, &is2digits,
tm);
1920 if (isdigit((
unsigned char) *field[
i]))
1934 if ((cp = strchr(field[
i],
'-')) == NULL)
2018 if (errno == ERANGE)
2020 if (*cp !=
'.' && *cp !=
'\0')
2077 flen = strlen(field[
i]);
2078 cp = strchr(field[
i],
'.');
2087 if (
i == 0 && nf >= 2 && ftype[nf - 1] ==
DTK_DATE)
2090 &tmask, &is2digits,
tm);
2095 else if (flen - strlen(cp) > 2)
2300 if (namedTz != NULL)
2311 *tzp = -(int) gmtoff;
2325 if (abbrevTz != NULL)
2355 if (tzp != NULL && !(fmask &
DTK_M(
TZ)))
2406 bool haveTextMonth =
false;
2418 while (*
str !=
'\0' && !isalnum((
unsigned char) *
str))
2425 if (isdigit((
unsigned char) *
str))
2427 while (isdigit((
unsigned char) *
str))
2430 else if (isalpha((
unsigned char) *
str))
2432 while (isalpha((
unsigned char) *
str))
2443 for (
i = 0;
i < nf;
i++)
2445 if (isalpha((
unsigned char) *field[
i]))
2456 haveTextMonth =
true;
2474 for (
i = 0;
i < nf;
i++)
2476 if (field[
i] == NULL)
2479 if ((
len = strlen(field[
i])) <= 0)
2591 int *tmask,
struct pg_itm *itm)
2601 if (errno == ERANGE)
2607 if (errno == ERANGE)
2622 else if (*cp ==
'.')
2634 else if (*cp ==
':')
2638 if (errno == ERANGE)
2646 else if (*cp !=
'\0')
2728 int *tmask,
struct pg_tm *
tm,
fsec_t *fsec,
bool *is2digits)
2738 if (errno == ERANGE)
2764 else if (*cp !=
'\0')
2845 if (flen >= 3 && *is2digits)
2898 *is2digits = (flen <= 2);
2913 int *tmask,
struct pg_tm *
tm,
fsec_t *fsec,
bool *is2digits)
2921 if ((cp = strchr(
str,
'.')) != NULL)
2937 frac = strtod(cp, NULL);
2940 *fsec = rint(frac * 1000000);
2958 *(
str + (
len - 2)) =
'\0';
2960 *(
str + (
len - 4)) =
'\0';
3016 if (*
str !=
'+' && *
str !=
'-')
3021 if (errno == ERANGE)
3029 if (errno == ERANGE)
3035 if (errno == ERANGE)
3040 else if (*cp ==
'\0' && strlen(
str) > 3)
3092 int *ftype,
int *offset,
pg_tz **tz,
3126 *offset = tp->
value;
3231 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3232 errmsg(
"time zone \"%s\" not recognized", tzname)));
3287 if (*
str ==
'\0' || !isalpha((
unsigned char) *
str))
3291 lowtoken[
len] =
'\0';
3323 *offset = tp->
value;
3327 lowtoken[--
len] =
'\0';
3367 bool force_negative =
false;
3368 bool is_before =
false;
3369 bool parsing_unit_val =
false;
3402 force_negative =
true;
3404 for (
i = 1;
i < nf;
i++)
3406 if (*field[
i] ==
'-' || *field[
i] ==
'+')
3408 force_negative =
false;
3415 for (
i = nf - 1;
i >= 0;
i--)
3424 if (force_negative &&
3428 parsing_unit_val =
false;
3438 Assert(*field[
i] ==
'-' || *field[
i] ==
'+');
3444 if (strchr(field[
i] + 1,
':') != NULL &&
3446 &tmask, itm_in) == 0)
3448 if (*field[
i] ==
'-')
3456 if (force_negative &&
3466 parsing_unit_val =
false;
3516 val = strtoi64(field[
i], &cp, 10);
3517 if (errno == ERANGE)
3531 if (*field[
i] ==
'-')
3539 else if (*cp ==
'.')
3544 if (*field[
i] ==
'-')
3547 else if (*cp ==
'\0')
3656 parsing_unit_val =
false;
3662 if (parsing_unit_val)
3675 parsing_unit_val =
true;
3730 if (parsing_unit_val)
3738 itm_in->
tm_mon == INT_MIN ||
3776 if (!(isdigit((
unsigned char) *
str) || *
str ==
'-' || *
str ==
'.'))
3779 val = strtod(
str, endptr);
3781 if (*endptr ==
str || errno != 0)
3784 if (isnan(
val) || val < -1.0e15 || val > 1.0e15)
3791 *fpart =
val - *ipart;
3793 Assert(*fpart > -1.0 && *fpart < 1.0);
3805 if (*fieldstart ==
'-')
3807 return strspn(fieldstart,
"0123456789");
3832 bool datepart =
true;
3833 bool havefield =
false;
3838 if (strlen(
str) < 2 ||
str[0] !=
'P')
4093 const char *
str,
const char *datatype,
4100 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
4101 errmsg(
"date/time field value out of range: \"%s\"",
4107 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
4108 errmsg(
"date/time field value out of range: \"%s\"",
4110 errhint(
"Perhaps you need a different \"DateStyle\" setting.")));
4114 (
errcode(ERRCODE_INTERVAL_FIELD_OVERFLOW),
4115 errmsg(
"interval field value out of range: \"%s\"",
4120 (
errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE),
4121 errmsg(
"time zone displacement out of range: \"%s\"",
4126 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4127 errmsg(
"time zone \"%s\" not recognized",
4132 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4133 errmsg(
"time zone \"%s\" not recognized",
4135 errdetail(
"This time zone name appears in the configuration file for time zone abbreviation \"%s\".",
4141 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4142 errmsg(
"invalid input syntax for type %s: \"%s\"",
4157 const datetkn *last = base + nel - 1,
4161 while (last >= base)
4163 position = base + ((last - base) >> 1);
4165 result = (int)
key[0] - (
int) position->token[0];
4174 last = position - 1;
4176 base = position + 1;
4202 *
str++ = (tz <= 0 ?
'+' :
'-');
4296 memcpy(
str,
" BC", 3);
4500 memcpy(
str,
" BC", 3);
4518 return cp + strlen(cp);
4524 bool *is_zero,
bool *is_before)
4529 (!*is_zero) ?
" " :
"",
4530 (*is_before &&
value > 0) ?
"+" :
"",
4533 (
value != 1) ?
"s" :
"");
4539 *is_before = (
value < 0);
4541 return cp + strlen(cp);
4547 bool *is_zero,
bool *is_before)
4554 *is_before = (
value < 0);
4557 else if (*is_before)
4561 return cp + strlen(cp);
4595 bool is_before =
false;
4596 bool is_zero =
true;
4609 bool has_negative = year < 0 || mon < 0 ||
4610 mday < 0 || hour < 0 ||
4611 min < 0 || sec < 0 || fsec < 0;
4612 bool has_positive = year > 0 || mon > 0 ||
4613 mday > 0 || hour > 0 ||
4614 min > 0 || sec > 0 || fsec > 0;
4615 bool has_year_month = year != 0 || mon != 0;
4616 bool has_day_time = mday != 0 || hour != 0 ||
4617 min != 0 || sec != 0 || fsec != 0;
4618 bool has_day = mday != 0;
4619 bool sql_standard_value = !(has_negative && has_positive) &&
4620 !(has_year_month && has_day_time);
4626 if (has_negative && sql_standard_value)
4638 if (!has_negative && !has_positive)
4642 else if (!sql_standard_value)
4649 char year_sign = (year < 0 || mon < 0) ?
'-' :
'+';
4650 char day_sign = (mday < 0) ?
'-' :
'+';
4651 char sec_sign = (hour < 0 || min < 0 ||
4652 sec < 0 || fsec < 0) ?
'-' :
'+';
4654 sprintf(cp,
"%c%d-%d %c%lld %c%lld:%02d:",
4655 year_sign, abs(year), abs(mon),
4656 day_sign, (
long long) i64abs(mday),
4657 sec_sign, (
long long) i64abs(hour), abs(min));
4662 else if (has_year_month)
4664 sprintf(cp,
"%d-%d", year, mon);
4668 sprintf(cp,
"%lld %lld:%02d:",
4669 (
long long) mday, (
long long) hour, min);
4676 sprintf(cp,
"%lld:%02d:", (
long long) hour, min);
4687 if (year == 0 && mon == 0 && mday == 0 &&
4688 hour == 0 && min == 0 && sec == 0 && fsec == 0)
4697 if (hour != 0 || min != 0 || sec != 0 || fsec != 0)
4701 if (sec != 0 || fsec != 0)
4703 if (sec < 0 || fsec < 0)
4722 if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0)
4724 bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
4726 sprintf(cp,
"%s%s%02lld:%02d:",
4728 (minus ?
"-" : (is_before ?
"+" :
"")),
4729 (
long long) i64abs(hour), abs(min));
4746 if (sec != 0 || fsec != 0)
4749 if (sec < 0 || (sec == 0 && fsec < 0))
4753 else if (!is_before)
4761 (abs(sec) != 1 || fsec != 0) ?
"s" :
"");
4784 for (
i = 0;
i < nel;
i++)
4790 elog(
LOG,
"token too long in %s table: \"%.*s\"",
4800 elog(
LOG,
"ordering error in %s table: \"%s\" >= \"%s\"",
4856 if (new_precis < 0 || new_precis == max_precis ||
4857 (old_precis >= 0 && new_precis >= old_precis))
4884 for (
i = 0;
i < n;
i++)
4886 struct tzEntry *abbr = abbrevs +
i;
4888 if (abbr->
zone != NULL)
4893 strlen(abbr->
zone) + 1;
4910 for (
i = 0;
i < n;
i++)
4912 struct tzEntry *abbr = abbrevs +
i;
4917 if (abbr->
zone != NULL)
4932 strlen(abbr->
zone) + 1;
4982 if (dtza->
tz == NULL)
4985 if (dtza->
tz == NULL)
5008 bool nulls[3] = {0};
5032 pindex = (
int *)
palloc(
sizeof(
int));
5037 elog(
ERROR,
"return type must be a row type");
5056 gmtoffset = tp->
value;
5060 gmtoffset = tp->
value;
5080 is_dst = (bool) isdst;
5084 elog(
ERROR,
"unrecognized timezone type %d", (
int) tp->
type);
5095 for (p = (
unsigned char *) buffer; *p; p++)
5128 bool nulls[4] = {0};
5150 &tzoff, &
tm, &fsec, &tzn, tz) != 0)
5162 if (tzn && strlen(tzn) > 31)
static const datetkn * abbrevcache[MAXDATEFIELDS]
static char * EncodeTimezone(char *str, int tz, int style)
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)
#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)
Node * TemporalSimplify(int32 max_precis, Node *node)
pg_tz * DecodeTimezoneNameToTz(const char *tzname)
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)
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)
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)
static char * AddPostgresIntPart(char *cp, int64 value, const char *units, bool *is_zero, bool *is_before)
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)
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)
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
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 char * AddISO8601IntPart(char *cp, int64 value, char units)
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 char * AddVerboseIntPart(char *cp, int64 value, const char *units, bool *is_zero, bool *is_before)
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)
int DecodeTimezoneAbbrevPrefix(const char *str, int *offset, pg_tz **tz)
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 Assert(condition)
#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
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,...)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define SRF_RETURN_DONE(_funcctx)
void * guc_malloc(int elevel, size_t size)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define DTERR_BAD_ZONE_ABBREV
#define DTERR_INTERVAL_OVERFLOW
#define DTERR_BAD_TIMEZONE
#define TZNAME_FIXED_OFFSET
#define DTERR_TZDISP_OVERFLOW
#define DTERR_FIELD_OVERFLOW
#define DTERR_MD_FIELD_OVERFLOW
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
static bool pg_mul_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_add_s64_overflow(int64 a, int64 b, int64 *result)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
if(TABLE==NULL||TABLE_index==NULL)
#define USE_POSTGRES_DATES
#define INTSTYLE_SQL_STANDARD
#define INTSTYLE_POSTGRES_VERBOSE
#define INTSTYLE_ISO_8601
#define INTSTYLE_POSTGRES
int32 exprTypmod(const Node *expr)
Node * relabel_to_typmod(Node *expr, int32 typmod)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
char * pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth)
char * pg_ultostr(char *str, uint32 value)
static int list_length(const List *l)
static rewind_source * source
pg_tz * pg_tzset_offset(long gmtoffset)
pg_tz * pg_tzenumerate_next(pg_tzenum *dir)
int pg_next_dst_boundary(const pg_time_t *timep, long int *before_gmtoff, int *before_isdst, pg_time_t *boundary, long int *after_gmtoff, int *after_isdst, const pg_tz *tz)
const char * pg_get_timezone_name(pg_tz *tz)
pg_tz * pg_tzset(const char *tzname)
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
PGDLLIMPORT pg_tz * session_timezone
void pg_tzenumerate_end(pg_tzenum *dir)
pg_tzenum * pg_tzenumerate_start(void)
bool pg_interpret_timezone_abbrev(const char *abbrev, const pg_time_t *timep, long int *gmtoff, int *isdst, const pg_tz *tz)
unsigned char pg_toupper(unsigned char ch)
unsigned char pg_tolower(unsigned char ch)
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum BoolGetDatum(bool X)
static int32 DatumGetInt32(Datum X)
MemoryContextSwitchTo(old_ctx)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
char * downcase_truncate_identifier(const char *ident, int len, bool warn)
int strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
char zone[FLEXIBLE_ARRAY_MEMBER]
MemoryContext multi_call_memory_ctx
datetkn abbrevs[FLEXIBLE_ARRAY_MEMBER]
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
#define INTERVAL_FULL_RANGE
static Datum IntervalPGetDatum(const Interval *X)
TimestampTz GetCurrentTransactionStartTimestamp(void)