47 #error -ffast-math is known to break this code
50 #define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
88 #define IA_TOTAL_COUNT(ia) \
89 ((ia)->N + (ia)->pInfcount + (ia)->nInfcount)
116 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
117 errmsg(
"invalid type modifier")));
128 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
129 errmsg(
"TIMESTAMP(%d)%s precision must not be negative",
130 typmod, (istz ?
" WITH TIME ZONE" :
""))));
134 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
135 errmsg(
"TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
136 typmod, (istz ?
" WITH TIME ZONE" :
""),
148 const char *tz = istz ?
" with time zone" :
" without time zone";
151 return psprintf(
"(%d)%s", (
int) typmod, tz);
172 Node *escontext = fcinfo->context;
190 &dtype,
tm, &fsec, &tz, &extra);
202 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
203 errmsg(
"timestamp out of range: \"%s\"",
str)));
219 elog(
ERROR,
"unexpected dtype %d while parsing timestamp \"%s\"",
248 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
249 errmsg(
"timestamp out of range")));
280 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
281 errmsg(
"timestamp out of range")));
394 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
395 errmsg(
"timestamp(%d) precision must be between %d and %d",
398 if (*time >= INT64CONST(0))
400 *time = ((*time + TimestampOffsets[typmod]) / TimestampScales[typmod]) *
401 TimestampScales[typmod];
405 *time = -((((-*time) + TimestampOffsets[typmod]) / TimestampScales[typmod])
406 * TimestampScales[typmod]);
424 Node *escontext = fcinfo->context;
442 &dtype,
tm, &fsec, &tz, &extra);
455 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
456 errmsg(
"timestamp out of range: \"%s\"",
str)));
472 elog(
ERROR,
"unexpected dtype %d while parsing timestamptz \"%s\"",
508 if (isdigit((
unsigned char) *tzname))
510 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
511 errmsg(
"invalid input syntax for type %s: \"%s\"",
512 "numeric time zone", tzname),
513 errhint(
"Numeric time zones must have \"-\" or \"+\" as first character.")));
524 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
525 errmsg(
"numeric time zone \"%s\" out of range", tzname)));
528 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
529 errmsg(
"time zone \"%s\" not recognized", tzname)));
574 int hour,
int min,
double sec)
598 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
599 errmsg(
"date field value out of range: %d-%02d-%02d",
604 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
605 errmsg(
"date out of range: %d-%02d-%02d",
613 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
614 errmsg(
"time field value out of range: %d:%02d:%02g",
625 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
626 errmsg(
"timestamp out of range: %d-%02d-%02d %d:%02d:%02g",
632 if ((result < 0 && date > 0) ||
633 (result > 0 &&
date < -1))
635 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
636 errmsg(
"timestamp out of range: %d-%02d-%02d %d:%02d:%02g",
643 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
644 errmsg(
"timestamp out of range: %d-%02d-%02d %d:%02d:%02g",
716 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
717 errmsg(
"timestamp out of range")));
725 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
726 errmsg(
"timestamp out of range")));
744 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
745 errmsg(
"timestamp cannot be NaN")));
762 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
763 errmsg(
"timestamp out of range: \"%g\"", seconds)));
769 result = (int64) seconds;
774 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
775 errmsg(
"timestamp out of range: \"%g\"",
803 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
804 errmsg(
"timestamp out of range")));
836 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
837 errmsg(
"timestamp out of range")));
908 Node *escontext = fcinfo->context;
957 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
958 errmsg(
"interval out of range")));
970 elog(
ERROR,
"unexpected dtype %d while parsing interval \"%s\"",
1094 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1095 errmsg(
"invalid INTERVAL type modifier")));
1110 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1111 errmsg(
"INTERVAL(%d) precision must not be negative",
1116 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1117 errmsg(
"INTERVAL(%d) precision reduced to maximum allowed, %d",
1127 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1128 errmsg(
"invalid INTERVAL type modifier")));
1142 const char *fieldstr;
1159 fieldstr =
" month";
1168 fieldstr =
" minute";
1171 fieldstr =
" second";
1174 fieldstr =
" year to month";
1177 fieldstr =
" day to hour";
1180 fieldstr =
" day to minute";
1183 fieldstr =
" day to second";
1186 fieldstr =
" hour to minute";
1189 fieldstr =
" hour to second";
1192 fieldstr =
" minute to second";
1198 elog(
ERROR,
"invalid INTERVAL typmod: 0x%x", typmod);
1258 elog(
ERROR,
"invalid INTERVAL typmod: 0x%x", typmod);
1301 int old_least_field;
1302 int new_least_field;
1320 noop = (new_least_field <= old_least_field) &&
1321 (old_least_field > 0 ||
1323 new_precis >= old_precis);
1364 INT64CONST(1000000),
1499 elog(
ERROR,
"unrecognized interval typmod: %d", typmod);
1506 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1507 errmsg(
"interval(%d) precision must be between %d and %d",
1513 IntervalOffsets[precision],
1516 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1517 errmsg(
"interval out of range")));
1523 IntervalOffsets[precision],
1526 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1527 errmsg(
"interval out of range")));
1555 if (isinf(secs) || isnan(secs))
1587 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1588 errmsg(
"interval out of range"));
1604 elog(
ERROR,
"invalid argument for EncodeSpecialTimestamp");
1615 elog(
ERROR,
"invalid argument for EncodeSpecialInterval");
1732 long *secs,
int *microsecs)
1776 return (
long) INT_MAX;
1777 if (diff >= (INT_MAX * INT64CONST(1000) - 999))
1778 return (
long) INT_MAX;
1780 return (
long) ((diff + 999) / 1000);
1797 return (diff >= msec * INT64CONST(1000));
1909 if (attimezone == NULL)
1915 if (time < INT64CONST(0))
2022 if ((*result < 0 && date > 0) ||
2023 (*result > 0 &&
date < -1))
2029 *result =
dt2local(*result, -(*tzp));
2063 itm->
tm_min = (int) tfrac;
2066 itm->
tm_sec = (int) tfrac;
2082 if (total_months > INT_MAX || total_months < INT_MIN)
2120 if (total_months > INT_MAX || total_months < INT_MIN)
2177 elog(
ERROR,
"could not convert epoch to timestamp: %m");
2213 return (dt1 < dt2) ? -1 : ((dt1 > dt2) ? 1 : 0);
2279 #if SIZEOF_DATUM < 8
2296 #if SIZEOF_DATUM >= 8
2648 #define TIMESTAMP_GT(t1,t2) \
2649 DatumGetBool(DirectFunctionCall2(timestamp_gt,t1,t2))
2650 #define TIMESTAMP_LT(t1,t2) \
2651 DatumGetBool(DirectFunctionCall2(timestamp_lt,t1,t2))
2666 else if (!te1IsNull)
2686 else if (!te2IsNull)
2742 if (te1IsNull || te2IsNull)
2807 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2808 errmsg(
"interval out of range")));
2816 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2817 errmsg(
"interval out of range")));
2831 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2832 errmsg(
"interval out of range")));
2898 if ((result->
day > 0 && result->
time > 0) ||
2899 (result->
day < 0 && result->
time < 0))
2905 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2906 errmsg(
"interval out of range")));
2916 result->
day += wholeday;
2922 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2923 errmsg(
"interval out of range")));
2925 if (result->
month > 0 &&
2926 (result->
day < 0 || (result->
day == 0 && result->
time < 0)))
2931 else if (result->
month < 0 &&
2932 (result->
day > 0 || (result->
day == 0 && result->
time > 0)))
2938 if (result->
day > 0 && result->
time < 0)
2943 else if (result->
day < 0 && result->
time > 0)
2979 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2980 errmsg(
"interval out of range")));
2982 if (result->
day > 0 && result->
time < 0)
2987 else if (result->
day < 0 && result->
time > 0)
3022 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3023 errmsg(
"interval out of range")));
3025 if (result->
month > 0 && result->
day < 0)
3030 else if (result->
month < 0 && result->
day > 0)
3066 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3067 errmsg(
"timestamp out of range")));
3075 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3076 errmsg(
"timestamp out of range")));
3084 if (span->
month != 0)
3092 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3093 errmsg(
"timestamp out of range")));
3097 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3098 errmsg(
"timestamp out of range")));
3116 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3117 errmsg(
"timestamp out of range")));
3129 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3130 errmsg(
"timestamp out of range")));
3140 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3141 errmsg(
"timestamp out of range")));
3146 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3147 errmsg(
"timestamp out of range")));
3152 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3153 errmsg(
"timestamp out of range")));
3157 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3158 errmsg(
"timestamp out of range")));
3210 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3211 errmsg(
"timestamp out of range")));
3219 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3220 errmsg(
"timestamp out of range")));
3229 if (attimezone == NULL)
3232 if (span->
month != 0)
3240 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3241 errmsg(
"timestamp out of range")));
3245 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3246 errmsg(
"timestamp out of range")));
3266 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3267 errmsg(
"timestamp out of range")));
3279 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3280 errmsg(
"timestamp out of range")));
3293 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3294 errmsg(
"timestamp out of range")));
3301 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3302 errmsg(
"timestamp out of range")));
3307 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3308 errmsg(
"timestamp out of range")));
3312 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3313 errmsg(
"timestamp out of range")));
3400 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3401 errmsg(
"interval out of range")));
3458 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3459 errmsg(
"interval out of range")));
3481 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3482 errmsg(
"interval out of range")));
3490 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3491 errmsg(
"interval out of range")));
3496 memcpy(result, span2,
sizeof(
Interval));
3514 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3515 errmsg(
"interval out of range")));
3537 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3538 errmsg(
"interval out of range")));
3546 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3547 errmsg(
"interval out of range")));
3572 double month_remainder_days,
3576 orig_day = span->
day;
3598 memcpy(result, span,
sizeof(
Interval));
3609 if (factor * isign < 0)
3617 result_double = span->
month * factor;
3622 result_double = span->
day * factor;
3625 result->
day = (
int32) result_double;
3646 month_remainder_days =
TSROUND(month_remainder_days);
3647 sec_remainder = (orig_day * factor - result->
day +
3648 month_remainder_days - (int) month_remainder_days) *
SECS_PER_DAY;
3649 sec_remainder =
TSROUND(sec_remainder);
3672 result->
time = (int64) result_double;
3681 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3682 errmsg(
"interval out of range"));
3702 double month_remainder_days,
3706 orig_day = span->
day;
3713 (
errcode(ERRCODE_DIVISION_BY_ZERO),
3714 errmsg(
"division by zero")));
3734 memcpy(result, span,
sizeof(
Interval));
3739 result_double = span->
month / factor;
3744 result_double = span->
day / factor;
3747 result->
day = (
int32) result_double;
3753 month_remainder_days =
TSROUND(month_remainder_days);
3754 sec_remainder = (orig_day / factor - result->
day +
3755 month_remainder_days - (int) month_remainder_days) *
SECS_PER_DAY;
3756 sec_remainder =
TSROUND(sec_remainder);
3773 result->
time = (int64) result_double;
3782 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3783 errmsg(
"interval out of range"));
3810 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3811 errmsg(
"invalid preceding or following size in window function")));
3847 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3848 errmsg(
"invalid preceding or following size in window function")));
3888 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3889 errmsg(
"invalid preceding or following size in window function")));
3934 elog(
ERROR,
"aggregate function called in non-aggregate context");
3995 memset(&
state->sumX, 0,
sizeof(
state->sumX));
4042 state1->
N = state2->
N;
4053 state1->
N += state2->
N;
4077 elog(
ERROR,
"aggregate function called in non-aggregate context");
4114 elog(
ERROR,
"aggregate function called in non-aggregate context");
4158 elog(
ERROR,
"interval_avg_accum_inv called with NULL state");
4183 if (
state->pInfcount > 0 ||
state->nInfcount > 0)
4187 if (
state->pInfcount > 0 &&
state->nInfcount > 0)
4189 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4190 errmsg(
"interval out of range")));
4193 if (
state->pInfcount > 0)
4224 if (
state->pInfcount > 0 &&
state->nInfcount > 0)
4226 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4227 errmsg(
"interval out of range")));
4231 if (
state->pInfcount > 0)
4233 else if (
state->nInfcount > 0)
4274 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4275 errmsg(
"interval out of range")));
4283 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4284 errmsg(
"interval out of range")));
4292 else if (
timestamp2tm(dt1, NULL, tm1, &fsec1, NULL, NULL) == 0 &&
4296 tm->tm_usec = fsec1 - fsec2;
4307 tm->tm_usec = -
tm->tm_usec;
4317 while (
tm->tm_usec < 0)
4364 tm->tm_usec = -
tm->tm_usec;
4375 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4376 errmsg(
"interval out of range")));
4380 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4381 errmsg(
"timestamp out of range")));
4422 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4423 errmsg(
"interval out of range")));
4431 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4432 errmsg(
"interval out of range")));
4440 else if (
timestamp2tm(dt1, &tz1, tm1, &fsec1, NULL, NULL) == 0 &&
4444 tm->tm_usec = fsec1 - fsec2;
4455 tm->tm_usec = -
tm->tm_usec;
4465 while (
tm->tm_usec < 0)
4516 tm->tm_usec = -
tm->tm_usec;
4527 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4528 errmsg(
"interval out of range")));
4532 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4533 errmsg(
"timestamp out of range")));
4564 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4565 errmsg(
"origin out of range")));
4569 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4570 errmsg(
"timestamps cannot be binned into infinite intervals")));
4572 if (stride->
month != 0)
4574 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4575 errmsg(
"timestamps cannot be binned into intervals containing months or years")));
4580 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4581 errmsg(
"interval out of range")));
4583 if (stride_usecs <= 0)
4585 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4586 errmsg(
"stride must be greater than zero")));
4590 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4591 errmsg(
"interval out of range")));
4594 tm_modulo = tm_diff % stride_usecs;
4595 tm_delta = tm_diff - tm_modulo;
4596 result = origin + tm_delta;
4608 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4609 errmsg(
"timestamp out of range")));
4644 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4645 errmsg(
"timestamp out of range")));
4718 fsec = (fsec / 1000) * 1000;
4726 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4727 errmsg(
"unit \"%s\" not supported for type %s",
4734 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4735 errmsg(
"timestamp out of range")));
4740 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4741 errmsg(
"unit \"%s\" not recognized for type %s",
4769 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4770 errmsg(
"origin out of range")));
4774 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4775 errmsg(
"timestamps cannot be binned into infinite intervals")));
4777 if (stride->
month != 0)
4779 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4780 errmsg(
"timestamps cannot be binned into intervals containing months or years")));
4785 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4786 errmsg(
"interval out of range")));
4788 if (stride_usecs <= 0)
4790 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4791 errmsg(
"stride must be greater than zero")));
4795 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4796 errmsg(
"interval out of range")));
4799 tm_modulo = tm_diff % stride_usecs;
4800 tm_delta = tm_diff - tm_modulo;
4801 result = origin + tm_delta;
4813 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4814 errmsg(
"timestamp out of range")));
4833 bool redotz =
false;
4849 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4850 errmsg(
"timestamp out of range")));
4934 fsec = (fsec / 1000) * 1000;
4941 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4942 errmsg(
"unit \"%s\" not supported for type %s",
4952 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4953 errmsg(
"timestamp out of range")));
4958 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4959 errmsg(
"unit \"%s\" not recognized for type %s",
5082 tm->tm_usec = (
tm->tm_usec / 1000) * 1000;
5089 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5090 errmsg(
"unit \"%s\" not supported for type %s",
5097 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5098 errmsg(
"interval out of range")));
5103 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5104 errmsg(
"unit \"%s\" not recognized for type %s",
5123 day4 =
date2j(year, 1, 4);
5126 day0 =
j2day(day4 - 1);
5128 return ((week - 1) * 7) + (day4 - day0);
5160 j2date(jday, year, mon, mday);
5176 dayn =
date2j(year, mon, mday);
5179 day4 =
date2j(year, 1, 4);
5182 day0 =
j2day(day4 - 1);
5188 if (dayn < day4 - day0)
5190 day4 =
date2j(year - 1, 1, 4);
5193 day0 =
j2day(day4 - 1);
5196 result = (dayn - (day4 - day0)) / 7 + 1;
5204 day4 =
date2j(year + 1, 1, 4);
5207 day0 =
j2day(day4 - 1);
5209 if (dayn >= day4 - day0)
5210 result = (dayn - (day4 - day0)) / 7 + 1;
5213 return (
int) result;
5231 dayn =
date2j(year, mon, mday);
5234 day4 =
date2j(year, 1, 4);
5237 day0 =
j2day(day4 - 1);
5243 if (dayn < day4 - day0)
5245 day4 =
date2j(year - 1, 1, 4);
5248 day0 =
j2day(day4 - 1);
5253 result = (dayn - (day4 - day0)) / 7 + 1;
5261 day4 =
date2j(year + 1, 1, 4);
5264 day0 =
j2day(day4 - 1);
5266 if (dayn >= day4 - day0)
5298 bool isNegative,
bool isTz)
5302 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5303 errmsg(
"unit \"%s\" not recognized for type %s",
5342 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5343 errmsg(
"unit \"%s\" not supported for type %s",
5407 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5408 errmsg(
"timestamp out of range")));
5413 intresult =
tm->
tm_sec * INT64CONST(1000000) + fsec;
5455 intresult = (
tm->
tm_mon - 1) / 3 + 1;
5480 intresult = -((8 - (
tm->
tm_year - 1)) / 10);
5495 intresult = -((99 - (
tm->
tm_year - 1)) / 100);
5503 intresult = -((999 - (
tm->
tm_year - 1)) / 1000);
5543 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5544 errmsg(
"unit \"%s\" not supported for type %s",
5590 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5591 errmsg(
"unit \"%s\" not supported for type %s",
5599 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5600 errmsg(
"unit \"%s\" not recognized for type %s",
5681 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5682 errmsg(
"timestamp out of range")));
5699 intresult =
tm->
tm_sec * INT64CONST(1000000) + fsec;
5741 intresult = (
tm->
tm_mon - 1) / 3 + 1;
5761 intresult = -((8 - (
tm->
tm_year - 1)) / 10);
5769 intresult = -((99 - (
tm->
tm_year - 1)) / 100);
5777 intresult = -((999 - (
tm->
tm_year - 1)) / 1000);
5814 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5815 errmsg(
"unit \"%s\" not supported for type %s",
5861 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5862 errmsg(
"unit \"%s\" not supported for type %s",
5870 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5871 errmsg(
"unit \"%s\" not recognized for type %s",
5911 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5912 errmsg(
"unit \"%s\" not recognized for type %s",
5941 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5942 errmsg(
"unit \"%s\" not supported for type %s",
6004 intresult =
tm->
tm_sec * INT64CONST(1000000) +
tm->tm_usec;
6070 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6071 errmsg(
"unit \"%s\" not supported for type %s",
6081 int64 secs_from_day_month;
6131 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6132 errmsg(
"unit \"%s\" not recognized for type %s",
6199 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6200 errmsg(
"timestamp out of range")));
6209 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6210 errmsg(
"timestamp out of range")));
6214 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6215 errmsg(
"timestamp out of range")));
6220 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6221 errmsg(
"timestamp out of range")));
6242 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6243 errmsg(
"interval time zone \"%s\" must be finite",
6247 if (
zone->month != 0 ||
zone->day != 0)
6249 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6250 errmsg(
"interval time zone \"%s\" must not include months or days",
6260 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6261 errmsg(
"timestamp out of range")));
6347 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6348 errmsg(
"timestamp out of range")));
6388 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6389 errmsg(
"timestamp out of range")));
6392 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6393 errmsg(
"timestamp out of range")));
6446 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6447 errmsg(
"timestamp out of range")));
6450 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6451 errmsg(
"timestamp out of range")));
6456 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6457 errmsg(
"timestamp out of range")));
6479 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6480 errmsg(
"interval time zone \"%s\" must be finite",
6484 if (
zone->month != 0 ||
zone->day != 0)
6486 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6487 errmsg(
"interval time zone \"%s\" must not include months or days",
6497 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6498 errmsg(
"timestamp out of range")));
6546 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6547 errmsg(
"step size cannot equal zero")));
6551 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6552 errmsg(
"step size cannot be infinite")));
6632 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6633 errmsg(
"step size cannot equal zero")));
6637 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6638 errmsg(
"step size cannot be infinite")));
6748 #define INTERVAL_TO_MICROSECONDS(i) ((((double) (i)->month * DAYS_PER_MONTH + (i)->day)) * USECS_PER_DAY + (i)->time)
6758 req->
rows = floor(ddiff / dstep + 1.0);
6761 #undef INTERVAL_TO_MICROSECONDS
#define PG_GETARG_ARRAYTYPE_P(n)
int32 * ArrayGetIntegerTypmods(ArrayType *arr, int *n)
pg_tz * DecodeTimezoneNameToTz(const char *tzname)
int DetermineTimeZoneAbbrevOffsetTS(TimestampTz ts, const char *abbr, pg_tz *tzp, int *isdst)
int DecodeUnits(int field, const char *lowtoken, int *val)
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)
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
void DateTimeParseError(int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext)
int DecodeInterval(char **field, int *ftype, int nf, int range, int *dtype, 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 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[]
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)
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)
Datum numeric_round(PG_FUNCTION_ARGS)
Numeric numeric_div_opt_error(Numeric num1, Numeric num2, bool *have_error)
Numeric int64_to_numeric(int64 val)
Numeric int64_div_fast_to_numeric(int64 val1, int log10val2)
Datum numeric_in(PG_FUNCTION_ARGS)
Numeric numeric_sub_opt_error(Numeric num1, Numeric num2, bool *have_error)
Numeric numeric_add_opt_error(Numeric num1, Numeric num2, bool *have_error)
void dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
Datum interval_out(PG_FUNCTION_ARGS)
Datum interval_justify_hours(PG_FUNCTION_ARGS)
Datum make_timestamptz_at_timezone(PG_FUNCTION_ARGS)
int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2)
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
void isoweek2date(int woy, int *year, int *mon, int *mday)
Datum in_range_timestamp_interval(PG_FUNCTION_ARGS)
void GetEpochTime(struct pg_tm *tm)
Datum generate_series_timestamptz(PG_FUNCTION_ARGS)
static float8 NonFiniteTimestampTzPart(int type, int unit, char *lowunits, bool isNegative, bool isTz)
static INT128 interval_cmp_value(const Interval *interval)
Datum interval_trunc(PG_FUNCTION_ARGS)
Datum overlaps_timestamp(PG_FUNCTION_ARGS)
Datum extract_timestamp(PG_FUNCTION_ARGS)
Datum timestamptypmodout(PG_FUNCTION_ARGS)
Datum interval_gt(PG_FUNCTION_ARGS)
Datum interval_avg_accum(PG_FUNCTION_ARGS)
int itmin2interval(struct pg_itm_in *itm_in, Interval *span)
Datum interval_justify_interval(PG_FUNCTION_ARGS)
static void finite_interval_mi(const Interval *span1, const Interval *span2, Interval *result)
Datum timestamptz_part(PG_FUNCTION_ARGS)
int isoweek2j(int year, int week)
Datum clock_timestamp(PG_FUNCTION_ARGS)
Datum timestamptz_pl_interval_at_zone(PG_FUNCTION_ARGS)
Datum timestamp_pl_interval(PG_FUNCTION_ARGS)
Datum interval_le(PG_FUNCTION_ARGS)
Datum interval_avg_serialize(PG_FUNCTION_ARGS)
Datum interval_mi(PG_FUNCTION_ARGS)
TimestampTz time_t_to_timestamptz(pg_time_t tm)
Datum timestamp_le_timestamptz(PG_FUNCTION_ARGS)
Datum interval_lt(PG_FUNCTION_ARGS)
Datum timestamp_larger(PG_FUNCTION_ARGS)
static Datum timestamptz_part_common(PG_FUNCTION_ARGS, bool retnumeric)
Datum timestamptz_izone(PG_FUNCTION_ARGS)
Datum timestamp_cmp_timestamptz(PG_FUNCTION_ARGS)
static bool AdjustIntervalForTypmod(Interval *interval, int32 typmod, Node *escontext)
static IntervalAggState * makeIntervalAggState(FunctionCallInfo fcinfo)
Datum timestamp_part(PG_FUNCTION_ARGS)
Datum timestamptz_eq_timestamp(PG_FUNCTION_ARGS)
Datum interval_hash(PG_FUNCTION_ARGS)
Datum timestamptztypmodout(PG_FUNCTION_ARGS)
int date2isoweek(int year, int mon, int mday)
Datum timestamptz_pl_interval(PG_FUNCTION_ARGS)
Datum timestamp_cmp(PG_FUNCTION_ARGS)
static TimestampTz timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp)
Datum timestamp_bin(PG_FUNCTION_ARGS)
Datum timestamp_zone(PG_FUNCTION_ARGS)
static TimestampTz timestamp2timestamptz(Timestamp timestamp)
Datum interval_finite(PG_FUNCTION_ARGS)
Timestamp SetEpochTimestamp(void)
Datum timestamptz_ne_timestamp(PG_FUNCTION_ARGS)
Datum timestamptz_lt_timestamp(PG_FUNCTION_ARGS)
Datum timestamp_sortsupport(PG_FUNCTION_ARGS)
Datum timestamp_mi_interval(PG_FUNCTION_ARGS)
Datum timestamptypmodin(PG_FUNCTION_ARGS)
bool AdjustTimestampForTypmod(Timestamp *time, int32 typmod, Node *escontext)
Datum timestamptz_ge_timestamp(PG_FUNCTION_ARGS)
Datum timestamp_smaller(PG_FUNCTION_ARGS)
TimestampTz timestamp2timestamptz_opt_overflow(Timestamp timestamp, int *overflow)
Datum interval_justify_days(PG_FUNCTION_ARGS)
Datum timestamp_ge(PG_FUNCTION_ARGS)
Datum interval_avg_accum_inv(PG_FUNCTION_ARGS)
Datum generate_series_timestamp(PG_FUNCTION_ARGS)
int date2isoyearday(int year, int mon, int mday)
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Datum timestamptz_cmp_timestamp(PG_FUNCTION_ARGS)
Datum timestamp_ge_timestamptz(PG_FUNCTION_ARGS)
static Timestamp timestamptz2timestamp(TimestampTz timestamp)
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
static void do_interval_accum(IntervalAggState *state, Interval *newval)
Datum timestamp_scale(PG_FUNCTION_ARGS)
Datum timestamptz_scale(PG_FUNCTION_ARGS)
Datum make_timestamptz(PG_FUNCTION_ARGS)
bool TimestampTimestampTzRequiresRewrite(void)
Datum timestamp_timestamptz(PG_FUNCTION_ARGS)
Datum timestamp_recv(PG_FUNCTION_ARGS)
Datum timestamp_lt(PG_FUNCTION_ARGS)
Datum timestamptz_trunc(PG_FUNCTION_ARGS)
Datum timestamptz_zone(PG_FUNCTION_ARGS)
static void finite_interval_pl(const Interval *span1, const Interval *span2, Interval *result)
void isoweekdate2date(int isoweek, int wday, int *year, int *mon, int *mday)
int32 timestamp_cmp_timestamptz_internal(Timestamp timestampVal, TimestampTz dt2)
Datum timestamptz_gt_timestamp(PG_FUNCTION_ARGS)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
static int32 anytimestamp_typmodin(bool istz, ArrayType *ta)
Datum generate_series_timestamp_support(PG_FUNCTION_ARGS)
static int timestamp_fastcmp(Datum x, Datum y, SortSupport ssup)
Datum interval_cmp(PG_FUNCTION_ARGS)
Datum interval_sum(PG_FUNCTION_ARGS)
Datum timestamp_hash_extended(PG_FUNCTION_ARGS)
Datum timestamptz_le_timestamp(PG_FUNCTION_ARGS)
Datum interval_pl(PG_FUNCTION_ARGS)
Datum interval_um(PG_FUNCTION_ARGS)
static float8 NonFiniteIntervalPart(int type, int unit, char *lowunits, bool isNegative)
void EncodeSpecialTimestamp(Timestamp dt, char *str)
Datum make_interval(PG_FUNCTION_ARGS)
Datum interval_ge(PG_FUNCTION_ARGS)
static Timestamp make_timestamp_internal(int year, int month, int day, int hour, int min, double sec)
Datum timestamp_gt_timestamptz(PG_FUNCTION_ARGS)
Datum timestamp_in(PG_FUNCTION_ARGS)
Datum timestamp_le(PG_FUNCTION_ARGS)
Datum interval_ne(PG_FUNCTION_ARGS)
Datum interval_in(PG_FUNCTION_ARGS)
static Timestamp dt2local(Timestamp dt, int timezone)
static Datum interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
static pg_tz * lookup_timezone(text *zone)
Datum timestamp_ne_timestamptz(PG_FUNCTION_ARGS)
Datum interval_hash_extended(PG_FUNCTION_ARGS)
Datum timestamptz_mi_interval(PG_FUNCTION_ARGS)
Datum timestamp_age(PG_FUNCTION_ARGS)
Datum interval_smaller(PG_FUNCTION_ARGS)
static void EncodeSpecialInterval(const Interval *interval, char *str)
Datum timestamptz_mi_interval_at_zone(PG_FUNCTION_ARGS)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
Datum interval_support(PG_FUNCTION_ARGS)
Datum timestamptz_in(PG_FUNCTION_ARGS)
static int intervaltypmodleastfield(int32 typmod)
int32 anytimestamp_typmod_check(bool istz, int32 typmod)
Datum extract_timestamptz(PG_FUNCTION_ARGS)
Datum pg_postmaster_start_time(PG_FUNCTION_ARGS)
TimestampTz GetCurrentTimestamp(void)
static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec)
Datum interval_part(PG_FUNCTION_ARGS)
Datum pg_conf_load_time(PG_FUNCTION_ARGS)
Datum in_range_interval_interval(PG_FUNCTION_ARGS)
#define IA_TOTAL_COUNT(ia)
Datum interval_eq(PG_FUNCTION_ARGS)
Timestamp GetSQLLocalTimestamp(int32 typmod)
Datum timestamp_finite(PG_FUNCTION_ARGS)
static TimestampTz timestamptz_mi_interval_internal(TimestampTz timestamp, Interval *span, pg_tz *attimezone)
Datum timestamp_trunc(PG_FUNCTION_ARGS)
Datum mul_d_interval(PG_FUNCTION_ARGS)
Datum timestamptztypmodin(PG_FUNCTION_ARGS)
Datum interval_avg(PG_FUNCTION_ARGS)
Datum timestamp_send(PG_FUNCTION_ARGS)
Datum timestamptz_send(PG_FUNCTION_ARGS)
Datum timestamptz_recv(PG_FUNCTION_ARGS)
Datum interval_scale(PG_FUNCTION_ARGS)
static Datum timestamp_part_common(PG_FUNCTION_ARGS, bool retnumeric)
static char * anytimestamp_typmodout(bool istz, int32 typmod)
Datum interval_larger(PG_FUNCTION_ARGS)
Datum timestamp_gt(PG_FUNCTION_ARGS)
Datum timestamptz_bin(PG_FUNCTION_ARGS)
Datum timestamptz_timestamp(PG_FUNCTION_ARGS)
Datum timestamp_mi(PG_FUNCTION_ARGS)
Datum timestamptz_at_local(PG_FUNCTION_ARGS)
Datum interval_send(PG_FUNCTION_ARGS)
Datum intervaltypmodin(PG_FUNCTION_ARGS)
#define TIMESTAMP_GT(t1, t2)
Datum timestamp_lt_timestamptz(PG_FUNCTION_ARGS)
Datum timestamptz_out(PG_FUNCTION_ARGS)
static void interval_um_internal(const Interval *interval, Interval *result)
Datum timestamp_hash(PG_FUNCTION_ARGS)
Datum timestamp_out(PG_FUNCTION_ARGS)
Datum timestamp_support(PG_FUNCTION_ARGS)
void interval2itm(Interval span, struct pg_itm *itm)
struct IntervalAggState IntervalAggState
Datum float8_timestamptz(PG_FUNCTION_ARGS)
Datum now(PG_FUNCTION_ARGS)
Datum interval_avg_deserialize(PG_FUNCTION_ARGS)
Datum timestamp_ne(PG_FUNCTION_ARGS)
static int interval_cmp_internal(const Interval *interval1, const Interval *interval2)
Datum interval_recv(PG_FUNCTION_ARGS)
#define INTERVAL_TO_MICROSECONDS(i)
Datum statement_timestamp(PG_FUNCTION_ARGS)
Datum timestamptz_age(PG_FUNCTION_ARGS)
const char * timestamptz_to_str(TimestampTz t)
Datum interval_mul(PG_FUNCTION_ARGS)
Datum interval_div(PG_FUNCTION_ARGS)
Datum timestamptz_trunc_zone(PG_FUNCTION_ARGS)
Datum timestamp_eq_timestamptz(PG_FUNCTION_ARGS)
static TimestampTz timestamptz_pl_interval_internal(TimestampTz timestamp, Interval *span, pg_tz *attimezone)
static Datum generate_series_timestamptz_internal(FunctionCallInfo fcinfo)
int itm2interval(struct pg_itm *itm, Interval *span)
pg_time_t timestamptz_to_time_t(TimestampTz t)
Datum make_timestamp(PG_FUNCTION_ARGS)
Datum intervaltypmodout(PG_FUNCTION_ARGS)
static int interval_sign(const Interval *interval)
static void do_interval_discard(IntervalAggState *state, Interval *newval)
Datum timeofday(PG_FUNCTION_ARGS)
Datum generate_series_timestamptz_at_zone(PG_FUNCTION_ARGS)
int date2isoyear(int year, int mon, int mday)
Datum timestamp_izone(PG_FUNCTION_ARGS)
static int parse_sane_timezone(struct pg_tm *tm, text *zone)
Datum timestamp_at_local(PG_FUNCTION_ARGS)
TimestampTz GetSQLCurrentTimestamp(int32 typmod)
Datum in_range_timestamptz_interval(PG_FUNCTION_ARGS)
Datum interval_avg_combine(PG_FUNCTION_ARGS)
Datum extract_interval(PG_FUNCTION_ARGS)
Datum timestamp_eq(PG_FUNCTION_ARGS)
#define TIMESTAMP_LT(t1, t2)
#define FLOAT8_FITS_IN_INT32(num)
#define Assert(condition)
#define FLOAT8_FITS_IN_INT64(num)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
#define DATETIME_MIN_JULIAN
#define INTERVAL_NOEND(i)
#define MAX_TIMESTAMP_PRECISION
#define INTERVAL_NOT_FINITE(i)
#define TIMESTAMP_NOBEGIN(j)
#define TIMESTAMP_END_JULIAN
#define IS_VALID_JULIAN(y, m, d)
#define INTERVAL_NOBEGIN(i)
#define INTERVAL_IS_NOBEGIN(i)
#define IS_VALID_TIMESTAMP(t)
#define MAX_INTERVAL_PRECISION
#define INTERVAL_IS_NOEND(i)
#define TIMESTAMP_IS_NOEND(j)
#define TIMESTAMP_IS_NOBEGIN(j)
#define TIMESTAMP_NOT_FINITE(j)
#define POSTGRES_EPOCH_JDATE
#define TIMESTAMP_NOEND(j)
bool float_time_overflows(int hour, int min, double sec)
static void PGresult * res
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define ereport(elevel,...)
static float8 float8_mul(const float8 val1, const float8 val2)
static float8 get_float8_infinity(void)
Datum Float8GetDatum(float8 X)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_FLOAT8(n)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_CSTRING(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
Datum hashint8extended(PG_FUNCTION_ARGS)
Datum hashint8(PG_FUNCTION_ARGS)
#define DTERR_INTERVAL_OVERFLOW
#define TZNAME_FIXED_OFFSET
#define DTERR_TZDISP_OVERFLOW
#define DTERR_FIELD_OVERFLOW
static int int128_compare(INT128 x, INT128 y)
static INT128 int64_to_int128(int64 v)
static int64 int128_to_int64(INT128 val)
static void int128_add_int64_mul_int64(INT128 *i128, int64 x, int64 y)
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
static bool pg_mul_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_sub_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)
char * pstrdup(const char *in)
void * palloc0(Size size)
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
int32 exprTypmod(const Node *expr)
Node * relabel_to_typmod(Node *expr, int32 typmod)
static bool is_funcclause(const void *clause)
#define IsA(nodeptr, _type_)
static Numeric DatumGetNumeric(Datum X)
#define PG_RETURN_NUMERIC(x)
static Datum NumericGetDatum(Numeric X)
static int list_length(const List *l)
static rewind_source * source
struct pg_tm * pg_gmtime(const pg_time_t *timep)
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
PGDLLIMPORT pg_tz * session_timezone
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define Int64GetDatumFast(X)
static Datum PointerGetDatum(const void *X)
static char * DatumGetCString(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
char * psprintf(const char *fmt,...)
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)
struct SortSupportData * SortSupport
StringInfoData * StringInfo
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
MemoryContext multi_call_memory_ctx
int(* comparator)(Datum x, Datum y, SortSupport ssup)
struct PlannerInfo * root
#define INTERVAL_FULL_RANGE
#define timestamptz_cmp_internal(dt1, dt2)
#define INTERVAL_PRECISION(t)
static Datum TimestampTzGetDatum(TimestampTz X)
#define INTERVAL_RANGE(t)
static Datum TimestampGetDatum(Timestamp X)
#define PG_GETARG_TIMESTAMP(n)
static Datum IntervalPGetDatum(const Interval *X)
#define PG_RETURN_TIMESTAMP(x)
#define PG_GETARG_INTERVAL_P(n)
#define PG_GETARG_TIMESTAMPTZ(n)
#define PG_RETURN_TIMESTAMPTZ(x)
static Interval * DatumGetIntervalP(Datum X)
#define PG_RETURN_INTERVAL_P(x)
#define INTERVAL_TYPMOD(p, r)
static Timestamp DatumGetTimestamp(Datum X)
#define INTERVAL_FULL_PRECISION
#define VARSIZE_ANY_EXHDR(PTR)
void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
text * cstring_to_text(const char *s)
static const unsigned __int64 epoch
int gettimeofday(struct timeval *tp, void *tzp)
TimestampTz GetCurrentStatementStartTimestamp(void)
TimestampTz GetCurrentTransactionStartTimestamp(void)