48#error -ffast-math is known to break this code
51#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
89#define IA_TOTAL_COUNT(ia) \
90 ((ia)->N + (ia)->pInfcount + (ia)->nInfcount)
117 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
118 errmsg(
"invalid type modifier")));
129 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
130 errmsg(
"TIMESTAMP(%d)%s precision must not be negative",
131 typmod, (istz ?
" WITH TIME ZONE" :
""))));
135 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
136 errmsg(
"TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
137 typmod, (istz ?
" WITH TIME ZONE" :
""),
149 const char *tz = istz ?
" with time zone" :
" without time zone";
152 return psprintf(
"(%d)%s", (
int) typmod, tz);
173 Node *escontext = fcinfo->context;
191 &dtype,
tm, &fsec, &tz, &extra);
203 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
204 errmsg(
"timestamp out of range: \"%s\"",
str)));
220 elog(
ERROR,
"unexpected dtype %d while parsing timestamp \"%s\"",
249 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
250 errmsg(
"timestamp out of range")));
281 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
282 errmsg(
"timestamp out of range")));
395 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
396 errmsg(
"timestamp(%d) precision must be between %d and %d",
401 *time = ((*time + TimestampOffsets[typmod]) / TimestampScales[typmod]) *
402 TimestampScales[typmod];
406 *time = -((((-*time) + TimestampOffsets[typmod]) / TimestampScales[typmod])
407 * TimestampScales[typmod]);
425 Node *escontext = fcinfo->context;
443 &dtype,
tm, &fsec, &tz, &extra);
456 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
457 errmsg(
"timestamp out of range: \"%s\"",
str)));
473 elog(
ERROR,
"unexpected dtype %d while parsing timestamptz \"%s\"",
509 if (isdigit((
unsigned char) *tzname))
511 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
512 errmsg(
"invalid input syntax for type %s: \"%s\"",
513 "numeric time zone", tzname),
514 errhint(
"Numeric time zones must have \"-\" or \"+\" as first character.")));
525 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
526 errmsg(
"numeric time zone \"%s\" out of range", tzname)));
529 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
530 errmsg(
"time zone \"%s\" not recognized", tzname)));
575 int hour,
int min,
double sec)
599 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
600 errmsg(
"date field value out of range: %d-%02d-%02d",
605 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
606 errmsg(
"date out of range: %d-%02d-%02d",
614 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
615 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",
633 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
634 errmsg(
"timestamp out of range: %d-%02d-%02d %d:%02d:%02g",
706 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
707 errmsg(
"timestamp out of range")));
715 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
716 errmsg(
"timestamp out of range")));
734 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
735 errmsg(
"timestamp cannot be NaN")));
752 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
753 errmsg(
"timestamp out of range: \"%g\"", seconds)));
759 result = (
int64) seconds;
764 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
765 errmsg(
"timestamp out of range: \"%g\"",
793 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
794 errmsg(
"timestamp out of range")));
826 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
827 errmsg(
"timestamp out of range")));
898 Node *escontext = fcinfo->context;
947 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
948 errmsg(
"interval out of range")));
960 elog(
ERROR,
"unexpected dtype %d while parsing interval \"%s\"",
1084 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1085 errmsg(
"invalid INTERVAL type modifier")));
1100 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1101 errmsg(
"INTERVAL(%d) precision must not be negative",
1106 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1107 errmsg(
"INTERVAL(%d) precision reduced to maximum allowed, %d",
1117 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1118 errmsg(
"invalid INTERVAL type modifier")));
1129 char *res = (
char *)
palloc(64);
1132 const char *fieldstr;
1149 fieldstr =
" month";
1158 fieldstr =
" minute";
1161 fieldstr =
" second";
1164 fieldstr =
" year to month";
1167 fieldstr =
" day to hour";
1170 fieldstr =
" day to minute";
1173 fieldstr =
" day to second";
1176 fieldstr =
" hour to minute";
1179 fieldstr =
" hour to second";
1182 fieldstr =
" minute to second";
1188 elog(
ERROR,
"invalid INTERVAL typmod: 0x%x", typmod);
1194 snprintf(res, 64,
"%s(%d)", fieldstr, precision);
1248 elog(
ERROR,
"invalid INTERVAL typmod: 0x%x", typmod);
1291 int old_least_field;
1292 int new_least_field;
1310 noop = (new_least_field <= old_least_field) &&
1311 (old_least_field > 0 ||
1313 new_precis >= old_precis);
1489 elog(
ERROR,
"unrecognized interval typmod: %d", typmod);
1496 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1497 errmsg(
"interval(%d) precision must be between %d and %d",
1503 IntervalOffsets[precision],
1506 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1507 errmsg(
"interval out of range")));
1513 IntervalOffsets[precision],
1516 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1517 errmsg(
"interval out of range")));
1545 if (isinf(secs) || isnan(secs))
1577 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1578 errmsg(
"interval out of range"));
1594 elog(
ERROR,
"invalid argument for EncodeSpecialTimestamp");
1605 elog(
ERROR,
"invalid argument for EncodeSpecialInterval");
1722 long *secs,
int *microsecs)
1766 return (
long) INT_MAX;
1767 if (diff >= (INT_MAX *
INT64CONST(1000) - 999))
1768 return (
long) INT_MAX;
1770 return (
long) ((diff + 999) / 1000);
1805 return (secs >= threshold_sec);
1917 if (attimezone == NULL)
2028 *result =
dt2local(*result, -(*tzp));
2062 itm->
tm_min = (int) tfrac;
2065 itm->
tm_sec = (int) tfrac;
2081 if (total_months > INT_MAX || total_months < INT_MIN)
2119 if (total_months > INT_MAX || total_months < INT_MIN)
2176 elog(
ERROR,
"could not convert epoch to timestamp: %m");
2212 return (dt1 < dt2) ? -1 : ((dt1 > dt2) ? 1 : 0);
2295#if SIZEOF_DATUM >= 8
2706#define TIMESTAMP_GT(t1,t2) \
2707 DatumGetBool(DirectFunctionCall2(timestamp_gt,t1,t2))
2708#define TIMESTAMP_LT(t1,t2) \
2709 DatumGetBool(DirectFunctionCall2(timestamp_lt,t1,t2))
2724 else if (!te1IsNull)
2744 else if (!te2IsNull)
2800 if (te1IsNull || te2IsNull)
2865 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2866 errmsg(
"interval out of range")));
2874 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2875 errmsg(
"interval out of range")));
2889 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2890 errmsg(
"interval out of range")));
2956 if ((result->
day > 0 && result->
time > 0) ||
2957 (result->
day < 0 && result->
time < 0))
2963 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2964 errmsg(
"interval out of range")));
2974 result->
day += wholeday;
2980 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2981 errmsg(
"interval out of range")));
2983 if (result->
month > 0 &&
2984 (result->
day < 0 || (result->
day == 0 && result->
time < 0)))
2989 else if (result->
month < 0 &&
2990 (result->
day > 0 || (result->
day == 0 && result->
time > 0)))
2996 if (result->
day > 0 && result->
time < 0)
3001 else if (result->
day < 0 && result->
time > 0)
3037 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3038 errmsg(
"interval out of range")));
3040 if (result->
day > 0 && result->
time < 0)
3045 else if (result->
day < 0 && result->
time > 0)
3080 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3081 errmsg(
"interval out of range")));
3083 if (result->
month > 0 && result->
day < 0)
3088 else if (result->
month < 0 && result->
day > 0)
3124 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3125 errmsg(
"timestamp out of range")));
3133 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3134 errmsg(
"timestamp out of range")));
3142 if (span->
month != 0)
3150 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3151 errmsg(
"timestamp out of range")));
3155 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3156 errmsg(
"timestamp out of range")));
3174 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3175 errmsg(
"timestamp out of range")));
3187 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3188 errmsg(
"timestamp out of range")));
3198 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3199 errmsg(
"timestamp out of range")));
3204 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3205 errmsg(
"timestamp out of range")));
3210 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3211 errmsg(
"timestamp out of range")));
3215 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3216 errmsg(
"timestamp out of range")));
3268 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3269 errmsg(
"timestamp out of range")));
3277 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3278 errmsg(
"timestamp out of range")));
3287 if (attimezone == NULL)
3290 if (span->
month != 0)
3298 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3299 errmsg(
"timestamp out of range")));
3303 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3304 errmsg(
"timestamp out of range")));
3324 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3325 errmsg(
"timestamp out of range")));
3337 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3338 errmsg(
"timestamp out of range")));
3351 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3352 errmsg(
"timestamp out of range")));
3359 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3360 errmsg(
"timestamp out of range")));
3365 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3366 errmsg(
"timestamp out of range")));
3370 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3371 errmsg(
"timestamp out of range")));
3458 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3459 errmsg(
"interval out of range")));
3516 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3517 errmsg(
"interval out of range")));
3539 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3540 errmsg(
"interval out of range")));
3548 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3549 errmsg(
"interval out of range")));
3554 memcpy(result, span2,
sizeof(
Interval));
3572 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3573 errmsg(
"interval out of range")));
3595 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3596 errmsg(
"interval out of range")));
3604 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3605 errmsg(
"interval out of range")));
3630 double month_remainder_days,
3634 orig_day = span->
day;
3656 memcpy(result, span,
sizeof(
Interval));
3667 if (factor * isign < 0)
3675 result_double = span->
month * factor;
3680 result_double = span->
day * factor;
3683 result->
day = (
int32) result_double;
3704 month_remainder_days =
TSROUND(month_remainder_days);
3705 sec_remainder = (orig_day * factor - result->
day +
3706 month_remainder_days - (int) month_remainder_days) *
SECS_PER_DAY;
3707 sec_remainder =
TSROUND(sec_remainder);
3739 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3740 errmsg(
"interval out of range"));
3760 double month_remainder_days,
3764 orig_day = span->
day;
3771 (
errcode(ERRCODE_DIVISION_BY_ZERO),
3772 errmsg(
"division by zero")));
3792 memcpy(result, span,
sizeof(
Interval));
3797 result_double = span->
month / factor;
3802 result_double = span->
day / factor;
3805 result->
day = (
int32) result_double;
3811 month_remainder_days =
TSROUND(month_remainder_days);
3812 sec_remainder = (orig_day / factor - result->
day +
3813 month_remainder_days - (int) month_remainder_days) *
SECS_PER_DAY;
3814 sec_remainder =
TSROUND(sec_remainder);
3840 errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3841 errmsg(
"interval out of range"));
3868 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3869 errmsg(
"invalid preceding or following size in window function")));
3905 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3906 errmsg(
"invalid preceding or following size in window function")));
3946 (
errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
3947 errmsg(
"invalid preceding or following size in window function")));
3992 elog(
ERROR,
"aggregate function called in non-aggregate context");
4053 memset(&
state->sumX, 0,
sizeof(
state->sumX));
4100 state1->
N = state2->
N;
4111 state1->
N += state2->
N;
4135 elog(
ERROR,
"aggregate function called in non-aggregate context");
4172 elog(
ERROR,
"aggregate function called in non-aggregate context");
4216 elog(
ERROR,
"interval_avg_accum_inv called with NULL state");
4241 if (
state->pInfcount > 0 ||
state->nInfcount > 0)
4245 if (
state->pInfcount > 0 &&
state->nInfcount > 0)
4247 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4248 errmsg(
"interval out of range")));
4251 if (
state->pInfcount > 0)
4282 if (
state->pInfcount > 0 &&
state->nInfcount > 0)
4284 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4285 errmsg(
"interval out of range")));
4289 if (
state->pInfcount > 0)
4291 else if (
state->nInfcount > 0)
4332 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4333 errmsg(
"interval out of range")));
4341 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4342 errmsg(
"interval out of range")));
4350 else if (
timestamp2tm(dt1, NULL, tm1, &fsec1, NULL, NULL) == 0 &&
4354 tm->tm_usec = fsec1 - fsec2;
4365 tm->tm_usec = -
tm->tm_usec;
4375 while (
tm->tm_usec < 0)
4422 tm->tm_usec = -
tm->tm_usec;
4433 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4434 errmsg(
"interval out of range")));
4438 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4439 errmsg(
"timestamp out of range")));
4480 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4481 errmsg(
"interval out of range")));
4489 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4490 errmsg(
"interval out of range")));
4498 else if (
timestamp2tm(dt1, &tz1, tm1, &fsec1, NULL, NULL) == 0 &&
4502 tm->tm_usec = fsec1 - fsec2;
4513 tm->tm_usec = -
tm->tm_usec;
4523 while (
tm->tm_usec < 0)
4574 tm->tm_usec = -
tm->tm_usec;
4585 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4586 errmsg(
"interval out of range")));
4590 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4591 errmsg(
"timestamp out of range")));
4622 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4623 errmsg(
"origin out of range")));
4627 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4628 errmsg(
"timestamps cannot be binned into infinite intervals")));
4630 if (stride->
month != 0)
4632 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4633 errmsg(
"timestamps cannot be binned into intervals containing months or years")));
4638 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4639 errmsg(
"interval out of range")));
4641 if (stride_usecs <= 0)
4643 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4644 errmsg(
"stride must be greater than zero")));
4648 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4649 errmsg(
"interval out of range")));
4652 tm_modulo = tm_diff % stride_usecs;
4653 tm_delta = tm_diff - tm_modulo;
4654 result = origin + tm_delta;
4666 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4667 errmsg(
"timestamp out of range")));
4723 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4724 errmsg(
"unit \"%s\" not supported for type %s",
4732 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4733 errmsg(
"timestamp out of range")));
4806 fsec = (fsec / 1000) * 1000;
4814 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4815 errmsg(
"unit \"%s\" not supported for type %s",
4822 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4823 errmsg(
"timestamp out of range")));
4828 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4829 errmsg(
"unit \"%s\" not recognized for type %s",
4857 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4858 errmsg(
"origin out of range")));
4862 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4863 errmsg(
"timestamps cannot be binned into infinite intervals")));
4865 if (stride->
month != 0)
4867 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4868 errmsg(
"timestamps cannot be binned into intervals containing months or years")));
4873 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4874 errmsg(
"interval out of range")));
4876 if (stride_usecs <= 0)
4878 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4879 errmsg(
"stride must be greater than zero")));
4883 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4884 errmsg(
"interval out of range")));
4887 tm_modulo = tm_diff % stride_usecs;
4888 tm_delta = tm_diff - tm_modulo;
4889 result = origin + tm_delta;
4901 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4902 errmsg(
"timestamp out of range")));
4921 bool redotz =
false;
4962 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4963 errmsg(
"unit \"%s\" not supported for type %s",
4971 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4972 errmsg(
"timestamp out of range")));
5056 fsec = (fsec / 1000) * 1000;
5063 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5064 errmsg(
"unit \"%s\" not supported for type %s",
5074 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5075 errmsg(
"timestamp out of range")));
5080 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5081 errmsg(
"unit \"%s\" not recognized for type %s",
5178 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5179 errmsg(
"unit \"%s\" not supported for type %s",
5223 tm->tm_usec = (
tm->tm_usec / 1000) * 1000;
5230 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5231 errmsg(
"unit \"%s\" not supported for type %s",
5238 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5239 errmsg(
"interval out of range")));
5244 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5245 errmsg(
"unit \"%s\" not recognized for type %s",
5268 day4 =
date2j(year, 1, 4);
5271 day0 =
j2day(day4 - 1);
5273 return ((week - 1) * 7) + (day4 - day0);
5305 j2date(jday, year, mon, mday);
5321 dayn =
date2j(year, mon, mday);
5324 day4 =
date2j(year, 1, 4);
5327 day0 =
j2day(day4 - 1);
5333 if (dayn < day4 - day0)
5335 day4 =
date2j(year - 1, 1, 4);
5338 day0 =
j2day(day4 - 1);
5341 result = (dayn - (day4 - day0)) / 7 + 1;
5349 day4 =
date2j(year + 1, 1, 4);
5352 day0 =
j2day(day4 - 1);
5354 if (dayn >= day4 - day0)
5355 result = (dayn - (day4 - day0)) / 7 + 1;
5358 return (
int) result;
5376 dayn =
date2j(year, mon, mday);
5379 day4 =
date2j(year, 1, 4);
5382 day0 =
j2day(day4 - 1);
5388 if (dayn < day4 - day0)
5390 day4 =
date2j(year - 1, 1, 4);
5393 day0 =
j2day(day4 - 1);
5398 result = (dayn - (day4 - day0)) / 7 + 1;
5406 day4 =
date2j(year + 1, 1, 4);
5409 day0 =
j2day(day4 - 1);
5411 if (dayn >= day4 - day0)
5443 bool isNegative,
bool isTz)
5447 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5448 errmsg(
"unit \"%s\" not recognized for type %s",
5487 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5488 errmsg(
"unit \"%s\" not supported for type %s",
5552 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5553 errmsg(
"timestamp out of range")));
5600 intresult = (
tm->
tm_mon - 1) / 3 + 1;
5625 intresult = -((8 - (
tm->
tm_year - 1)) / 10);
5640 intresult = -((99 - (
tm->
tm_year - 1)) / 100);
5648 intresult = -((999 - (
tm->
tm_year - 1)) / 1000);
5688 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5689 errmsg(
"unit \"%s\" not supported for type %s",
5735 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5736 errmsg(
"unit \"%s\" not supported for type %s",
5744 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5745 errmsg(
"unit \"%s\" not recognized for type %s",
5826 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5827 errmsg(
"timestamp out of range")));
5886 intresult = (
tm->
tm_mon - 1) / 3 + 1;
5906 intresult = -((8 - (
tm->
tm_year - 1)) / 10);
5914 intresult = -((99 - (
tm->
tm_year - 1)) / 100);
5922 intresult = -((999 - (
tm->
tm_year - 1)) / 1000);
5959 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5960 errmsg(
"unit \"%s\" not supported for type %s",
6006 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6007 errmsg(
"unit \"%s\" not supported for type %s",
6015 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6016 errmsg(
"unit \"%s\" not recognized for type %s",
6056 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6057 errmsg(
"unit \"%s\" not recognized for type %s",
6087 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6088 errmsg(
"unit \"%s\" not supported for type %s",
6231 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6232 errmsg(
"unit \"%s\" not supported for type %s",
6242 int64 secs_from_day_month;
6292 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6293 errmsg(
"unit \"%s\" not recognized for type %s",
6360 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6361 errmsg(
"timestamp out of range")));
6370 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6371 errmsg(
"timestamp out of range")));
6375 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6376 errmsg(
"timestamp out of range")));
6381 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6382 errmsg(
"timestamp out of range")));
6403 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6404 errmsg(
"interval time zone \"%s\" must be finite",
6408 if (
zone->month != 0 ||
zone->day != 0)
6410 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6411 errmsg(
"interval time zone \"%s\" must not include months or days",
6421 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6422 errmsg(
"timestamp out of range")));
6508 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6509 errmsg(
"timestamp out of range")));
6549 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6550 errmsg(
"timestamp out of range")));
6553 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6554 errmsg(
"timestamp out of range")));
6607 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6608 errmsg(
"timestamp out of range")));
6611 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6612 errmsg(
"timestamp out of range")));
6617 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6618 errmsg(
"timestamp out of range")));
6640 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6641 errmsg(
"interval time zone \"%s\" must be finite",
6645 if (
zone->month != 0 ||
zone->day != 0)
6647 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6648 errmsg(
"interval time zone \"%s\" must not include months or days",
6658 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6659 errmsg(
"timestamp out of range")));
6707 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6708 errmsg(
"step size cannot equal zero")));
6712 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6713 errmsg(
"step size cannot be infinite")));
6793 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6794 errmsg(
"step size cannot equal zero")));
6798 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6799 errmsg(
"step size cannot be infinite")));
6909#define INTERVAL_TO_MICROSECONDS(i) ((((double) (i)->month * DAYS_PER_MONTH + (i)->day)) * USECS_PER_DAY + (i)->time)
6919 req->
rows = floor(ddiff / dstep + 1.0);
6922#undef INTERVAL_TO_MICROSECONDS
#define PG_GETARG_ARRAYTYPE_P(n)
int32 * ArrayGetIntegerTypmods(ArrayType *arr, int *n)
Node * TemporalSimplify(int32 max_precis, Node *node)
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)
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)
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 pg_tz * lookup_timezone(text *zone)
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 TimestampDifferenceExceedsSeconds(TimestampTz start_time, TimestampTz stop_time, int threshold_sec)
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)
Datum timestamptz_hash_extended(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)
Datum timestamp_skipsupport(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)
static char * anytimestamp_typmodout(bool istz, int32 typmod)
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 timestamptz_hash(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)
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)
const char * timestamptz_to_str(TimestampTz t)
Datum interval_eq(PG_FUNCTION_ARGS)
static Datum timestamp_increment(Relation rel, Datum existing, bool *overflow)
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)
Datum interval_larger(PG_FUNCTION_ARGS)
Datum timestamp_gt(PG_FUNCTION_ARGS)
static IntervalAggState * makeIntervalAggState(FunctionCallInfo fcinfo)
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)
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 Datum timestamp_decrement(Relation rel, Datum existing, bool *underflow)
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 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)
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)
Assert(PointerIsAligned(start, uint64))
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 MemoryContext MemoryContextSwitchTo(MemoryContext context)
static int list_length(const List *l)
static rewind_source * source
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
PGDLLIMPORT pg_tz * session_timezone
size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
struct pg_tm * pg_gmtime(const pg_time_t *timep)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define Int64GetDatumFast(X)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
char * psprintf(const char *fmt,...)
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 SkipSupportData * SkipSupport
struct SortSupportData * SortSupport
StringInfoData * StringInfo
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
MemoryContext multi_call_memory_ctx
SkipSupportIncDec decrement
SkipSupportIncDec increment
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)
text * cstring_to_text(const char *s)
void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
static const unsigned __int64 epoch
int gettimeofday(struct timeval *tp, void *tzp)
TimestampTz GetCurrentStatementStartTimestamp(void)
TimestampTz GetCurrentTransactionStartTimestamp(void)