132#include "utils/fmgroids.h"
145#define DEFAULT_PAGE_CPU_MULTIPLIER 50.0
154 double nd1,
double nd2,
155 bool isdefault1,
bool isdefault2,
158 bool have_mcvs1,
bool have_mcvs2);
161 double nd1,
double nd2,
162 bool isdefault1,
bool isdefault2,
165 bool have_mcvs1,
bool have_mcvs2,
172 double *scaledlobound,
double *scaledhibound);
177 double *scaledlobound,
179 double *scaledhibound);
183 double *scaledlobound,
185 double *scaledhibound);
187 int rangelo,
int rangehi);
189 int rangelo,
int rangehi);
197 Oid sortop,
Oid collation,
201 Oid collation,
int16 typLen,
bool typByVal,
205 Oid sortop,
Oid collation,
215 Datum *endpointDatum);
268 &vardata, &other, &varonleft))
278 ((
Const *) other)->constvalue,
279 ((
Const *) other)->constisnull,
297 Datum constval,
bool constisnull,
298 bool varonleft,
bool negate)
301 double nullfrac = 0.0;
321 nullfrac = stats->stanullfrac;
367 fcinfo->args[0].isnull =
false;
368 fcinfo->args[1].isnull =
false;
371 fcinfo->args[1].value = constval;
373 fcinfo->args[0].value = constval;
380 fcinfo->args[0].value = sslot.
values[
i];
382 fcinfo->args[1].value = sslot.
values[
i];
383 fcinfo->isnull =
false;
413 double sumcommon = 0.0;
414 double otherdistinct;
418 selec = 1.0 - sumcommon - nullfrac;
428 if (otherdistinct > 1)
429 selec /= otherdistinct;
453 selec = 1.0 - selec - nullfrac;
469 bool varonleft,
bool negate)
472 double nullfrac = 0.0;
483 nullfrac = stats->stanullfrac;
512 selec = 1.0 - nullfrac;
542 selec = 1.0 - selec - nullfrac;
626 if (block >= vardata->
rel->
pages - 1)
641 block +=
Min(offset / density, 1.0);
648 selec = block / (vardata->
rel->
pages - 0.5);
658 if (iseq == isgt && vardata->
rel->
tuples >= 1.0)
682 mcv_selec =
mcv_selectivity(vardata, &opproc, collation, constval,
true,
690 operator, &opproc, isgt, iseq,
692 constval, consttype);
699 selec = 1.0 - stats->stanullfrac - sumcommon;
701 if (hist_selec >= 0.0)
734 Datum constval,
bool varonleft,
762 fcinfo->args[0].isnull =
false;
763 fcinfo->args[1].isnull =
false;
766 fcinfo->args[1].value = constval;
768 fcinfo->args[0].value = constval;
775 fcinfo->args[0].value = sslot.
values[
i];
777 fcinfo->args[1].value = sslot.
values[
i];
778 fcinfo->isnull =
false;
787 *sumcommonp = sumcommon;
826 Datum constval,
bool varonleft,
827 int min_hist_size,
int n_skip,
835 Assert(min_hist_size > 2 * n_skip);
844 if (sslot.
nvalues >= min_hist_size)
860 fcinfo->args[0].isnull =
false;
861 fcinfo->args[1].isnull =
false;
864 fcinfo->args[1].value = constval;
866 fcinfo->args[0].value = constval;
868 for (
i = n_skip;
i < sslot.
nvalues - n_skip;
i++)
873 fcinfo->args[0].value = sslot.
values[
i];
875 fcinfo->args[1].value = sslot.
values[
i];
876 fcinfo->isnull =
false;
881 result = ((double) nmatch) / ((double) (sslot.
nvalues - 2 * n_skip));
917 double default_selectivity)
929 &vardata, &other, &varonleft))
930 return default_selectivity;
937 ((
Const *) other)->constisnull)
946 Datum constval = ((
Const *) other)->constvalue;
974 selec = default_selectivity;
976 else if (hist_size < 100)
983 double hist_weight = hist_size / 100.0;
985 selec = selec * hist_weight +
986 default_selectivity * (1.0 - hist_weight);
992 else if (selec > 0.9999)
1006 selec *= 1.0 - nullfrac - mcvsum;
1012 selec = default_selectivity;
1044 Oid opoid,
FmgrInfo *opproc,
bool isgt,
bool iseq,
1096 bool have_end =
false;
1112 while (lobound < hibound)
1114 int probe = (lobound + hibound) / 2;
1122 if (probe == 0 && sslot.
nvalues > 2)
1144 lobound = probe + 1;
1161 else if (lobound >= sslot.
nvalues)
1172 double eq_selec = 0;
1194 if (
i == 1 || isgt == iseq)
1196 double otherdistinct;
1214 if (otherdistinct > 1)
1215 eq_selec = 1.0 / otherdistinct;
1234 else if (
val <= low)
1236 else if (
val >= high)
1240 binfrac = (
val - low) / (high - low);
1248 if (isnan(binfrac) ||
1249 binfrac < 0.0 || binfrac > 1.0)
1271 histfrac = (double) (
i - 1) + binfrac;
1272 histfrac /= (double) (sslot.
nvalues - 1);
1307 histfrac += eq_selec * (1.0 - binfrac);
1315 histfrac -= eq_selec;
1322 hist_selec = isgt ? (1.0 - histfrac) : histfrac;
1337 double cutoff = 0.01 / (double) (sslot.
nvalues - 1);
1339 if (hist_selec < cutoff)
1340 hist_selec = cutoff;
1341 else if (hist_selec > 1.0 - cutoff)
1342 hist_selec = 1.0 - cutoff;
1359 fcinfo->args[0].isnull =
false;
1360 fcinfo->args[1].isnull =
false;
1361 fcinfo->args[1].value = constval;
1366 fcinfo->args[0].value = sslot.
values[
i];
1367 fcinfo->isnull =
false;
1372 hist_selec = ((double) nmatch) / ((double) sslot.
nvalues);
1381 double cutoff = 0.01 / (double) (sslot.
nvalues - 1);
1383 if (hist_selec < cutoff)
1384 hist_selec = cutoff;
1385 else if (hist_selec > 1.0 - cutoff)
1386 hist_selec = 1.0 - cutoff;
1420 &vardata, &other, &varonleft))
1436 if (((
Const *) other)->constisnull)
1441 constval = ((
Const *) other)->constvalue;
1442 consttype = ((
Const *) other)->consttype;
1461 &vardata, constval, consttype);
1556 freq_null = stats->stanullfrac;
1572 freq_true = 1.0 - sslot.
numbers[0] - freq_null;
1578 freq_false = 1.0 - freq_true - freq_null;
1580 switch (booltesttype)
1588 selec = 1.0 - freq_null;
1596 selec = 1.0 - freq_true;
1604 selec = 1.0 - freq_false;
1607 elog(
ERROR,
"unrecognized booltesttype: %d",
1608 (
int) booltesttype);
1622 switch (booltesttype)
1630 selec = 1.0 - freq_null;
1635 selec = (1.0 - freq_null) / 2.0;
1641 selec = (freq_null + 1.0) / 2.0;
1644 elog(
ERROR,
"unrecognized booltesttype: %d",
1645 (
int) booltesttype);
1659 switch (booltesttype)
1680 elog(
ERROR,
"unrecognized booltesttype: %d",
1681 (
int) booltesttype);
1713 freq_null = stats->stanullfrac;
1715 switch (nulltesttype)
1730 selec = 1.0 - freq_null;
1733 elog(
ERROR,
"unrecognized nulltesttype: %d",
1734 (
int) nulltesttype);
1739 ((
Var *) vardata.
var)->varattno < 0)
1745 selec = (nulltesttype ==
IS_NULL) ? 0.0 : 1.0;
1752 switch (nulltesttype)
1761 elog(
ERROR,
"unrecognized nulltesttype: %d",
1762 (
int) nulltesttype);
1819 bool is_join_clause,
1825 bool useOr = clause->
useOr;
1826 bool isEquality =
false;
1827 bool isInequality =
false;
1830 Oid nominal_element_type;
1831 Oid nominal_element_collation;
1864 if (
operator == typentry->
eq_opr)
1867 isInequality =
true;
1876 if ((isEquality || isInequality) && !is_join_clause)
1879 nominal_element_type,
1880 isEquality, useOr, varRelid);
1905 if (oprsel == F_EQSEL || oprsel == F_EQJOINSEL)
1907 else if (oprsel == F_NEQSEL || oprsel == F_NEQJOINSEL)
1908 isInequality =
true;
1922 if (rightop &&
IsA(rightop,
Const))
1924 Datum arraydatum = ((
Const *) rightop)->constvalue;
1925 bool arrayisnull = ((
Const *) rightop)->constisnull;
1939 &elmlen, &elmbyval, &elmalign);
1942 elmlen, elmbyval, elmalign,
1943 &elem_values, &elem_nulls, &num_elems);
1959 s1 = s1disjoint = (useOr ? 0.0 : 1.0);
1961 for (
i = 0;
i < num_elems;
i++)
1969 nominal_element_collation,
1976 clause->inputcollid,
1984 clause->inputcollid,
2000 s1disjoint +=
s2 - 1.0;
2005 if ((useOr ? isEquality : isInequality) &&
2006 s1disjoint >= 0.0 && s1disjoint <= 1.0)
2018 &elmlen, &elmbyval);
2027 s1 = s1disjoint = (useOr ? 0.0 : 1.0);
2043 clause->inputcollid,
2051 clause->inputcollid,
2067 s1disjoint +=
s2 - 1.0;
2072 if ((useOr ? isEquality : isInequality) &&
2073 s1disjoint >= 0.0 && s1disjoint <= 1.0)
2089 dummyexpr->
typeId = nominal_element_type;
2090 dummyexpr->typeMod = -1;
2091 dummyexpr->collation = clause->inputcollid;
2095 clause->inputcollid,
2103 clause->inputcollid,
2108 s1 = useOr ? 0.0 : 1.0;
2115 for (
i = 0;
i < 10;
i++)
2145 if (arrayexpr &&
IsA(arrayexpr,
Const))
2147 Datum arraydatum = ((
Const *) arrayexpr)->constvalue;
2148 bool arrayisnull = ((
Const *) arrayexpr)->constisnull;
2161 else if (arrayexpr &&
root)
2214 bool is_join_clause;
2230 is_join_clause =
false;
2232 else if (sjinfo == NULL)
2238 is_join_clause =
false;
2297 bool have_mcvs1 =
false;
2298 bool have_mcvs2 =
false;
2300 bool join_is_reversed;
2304 &vardata1, &vardata2, &join_is_reversed);
2311 memset(&sslot1, 0,
sizeof(sslot1));
2312 memset(&sslot2, 0,
sizeof(sslot2));
2331 if (get_mcv_stats &&
2342 if (get_mcv_stats &&
2351 &vardata1, &vardata2,
2353 isdefault1, isdefault2,
2356 have_mcvs1, have_mcvs2);
2363 selec = selec_inner;
2376 if (!join_is_reversed)
2378 &vardata1, &vardata2,
2380 isdefault1, isdefault2,
2383 have_mcvs1, have_mcvs2,
2391 &vardata2, &vardata1,
2393 isdefault2, isdefault1,
2396 have_mcvs2, have_mcvs1,
2410 selec =
Min(selec, inner_rel->
rows * selec_inner);
2414 elog(
ERROR,
"unrecognized join type: %d",
2440 double nd1,
double nd2,
2441 bool isdefault1,
bool isdefault2,
2444 bool have_mcvs1,
bool have_mcvs2)
2448 if (have_mcvs1 && have_mcvs2)
2466 double nullfrac1 = stats1->stanullfrac;
2467 double nullfrac2 = stats2->stanullfrac;
2468 double matchprodfreq,
2490 fcinfo->args[0].isnull =
false;
2491 fcinfo->args[1].isnull =
false;
2502 matchprodfreq = 0.0;
2508 fcinfo->args[0].value = sslot1->
values[
i];
2516 fcinfo->args[1].value = sslot2->
values[
j];
2517 fcinfo->isnull =
false;
2521 hasmatch1[
i] = hasmatch2[
j] =
true;
2530 matchfreq1 = unmatchfreq1 = 0.0;
2536 unmatchfreq1 += sslot1->
numbers[
i];
2540 matchfreq2 = unmatchfreq2 = 0.0;
2546 unmatchfreq2 += sslot2->
numbers[
i];
2557 otherfreq1 = 1.0 - nullfrac1 - matchfreq1 - unmatchfreq1;
2558 otherfreq2 = 1.0 - nullfrac2 - matchfreq2 - unmatchfreq2;
2570 totalsel1 = matchprodfreq;
2572 totalsel1 += unmatchfreq1 * otherfreq2 / (nd2 - sslot2->
nvalues);
2574 totalsel1 += otherfreq1 * (otherfreq2 + unmatchfreq2) /
2577 totalsel2 = matchprodfreq;
2579 totalsel2 += unmatchfreq2 * otherfreq1 / (nd1 - sslot1->
nvalues);
2581 totalsel2 += otherfreq2 * (otherfreq1 + unmatchfreq1) /
2590 selec = (totalsel1 < totalsel2) ? totalsel1 : totalsel2;
2614 double nullfrac1 = stats1 ? stats1->stanullfrac : 0.0;
2615 double nullfrac2 = stats2 ? stats2->stanullfrac : 0.0;
2617 selec = (1.0 - nullfrac1) * (1.0 - nullfrac2);
2637 double nd1,
double nd2,
2638 bool isdefault1,
bool isdefault2,
2641 bool have_mcvs1,
bool have_mcvs2,
2667 if (nd2 >= vardata2->
rel->
rows)
2673 if (nd2 >= inner_rel->
rows)
2675 nd2 = inner_rel->
rows;
2679 if (have_mcvs1 && have_mcvs2 &&
OidIsValid(opfuncoid))
2693 double nullfrac1 = stats1->stanullfrac;
2708 clamped_nvalues2 =
Min(sslot2->
nvalues, nd2);
2720 fcinfo->args[0].isnull =
false;
2721 fcinfo->args[1].isnull =
false;
2724 hasmatch2 = (
bool *)
palloc0(clamped_nvalues2 *
sizeof(
bool));
2737 fcinfo->args[0].value = sslot1->
values[
i];
2739 for (
j = 0;
j < clamped_nvalues2;
j++)
2745 fcinfo->args[1].value = sslot2->
values[
j];
2746 fcinfo->isnull =
false;
2750 hasmatch1[
i] = hasmatch2[
j] =
true;
2782 if (!isdefault1 && !isdefault2)
2786 if (nd1 <= nd2 || nd2 < 0)
2787 uncertainfrac = 1.0;
2789 uncertainfrac = nd2 / nd1;
2792 uncertainfrac = 0.5;
2793 uncertain = 1.0 - matchfreq1 - nullfrac1;
2795 selec = matchfreq1 + uncertainfrac * uncertain;
2803 double nullfrac1 = stats1 ? stats1->stanullfrac : 0.0;
2805 if (!isdefault1 && !isdefault2)
2807 if (nd1 <= nd2 || nd2 < 0)
2808 selec = 1.0 - nullfrac1;
2810 selec = (nd2 / nd1) * (1.0 - nullfrac1);
2813 selec = 0.5 * (1.0 - nullfrac1);
2865 result = 1.0 - nullfrac;
2891 result = 1.0 - result;
2957 Oid opfamily,
int strategy,
bool nulls_first,
2987 *leftstart = *rightstart = 0.0;
2988 *leftend = *rightend = 1.0;
2993 opno = ((
OpExpr *) clause)->opno;
2994 collation = ((
OpExpr *) clause)->inputcollid;
3022 if (op_lefttype == op_righttype)
3026 op_lefttype, op_righttype,
3029 op_lefttype, op_righttype,
3041 op_lefttype, op_righttype,
3044 op_lefttype, op_righttype,
3047 op_lefttype, op_lefttype,
3050 op_righttype, op_righttype,
3055 op_righttype, op_lefttype,
3058 op_righttype, op_lefttype,
3065 if (op_lefttype == op_righttype)
3069 op_lefttype, op_righttype,
3072 op_lefttype, op_righttype,
3077 op_lefttype, op_lefttype,
3086 op_lefttype, op_righttype,
3089 op_lefttype, op_righttype,
3092 op_lefttype, op_lefttype,
3095 op_righttype, op_righttype,
3098 op_lefttype, op_lefttype,
3101 op_righttype, op_righttype,
3104 op_righttype, op_lefttype,
3107 op_righttype, op_lefttype,
3129 &leftmin, &leftmax))
3132 &rightmin, &rightmax))
3139 &leftmax, &leftmin))
3142 &rightmax, &rightmin))
3152 rightmax, op_righttype);
3158 leftmax, op_lefttype);
3168 if (*leftend > *rightend)
3170 else if (*leftend < *rightend)
3173 *leftend = *rightend = 1.0;
3182 rightmin, op_righttype);
3188 leftmin, op_lefttype);
3190 *rightstart = selec;
3198 if (*leftstart < *rightstart)
3200 else if (*leftstart > *rightstart)
3203 *leftstart = *rightstart = 0.0;
3218 *leftstart += stats->stanullfrac;
3220 *leftend += stats->stanullfrac;
3226 *rightstart += stats->stanullfrac;
3228 *rightend += stats->stanullfrac;
3234 if (*leftstart >= *leftend)
3239 if (*rightstart >= *rightend)
3319 foreach(lc, varinfos)
3332 if (vardata->
rel != varinfo->
rel &&
3351 varinfo->
rel = vardata->
rel;
3354 varinfos =
lappend(varinfos, varinfo);
3434 double srf_multiplier = 1.0;
3440 if (estinfo != NULL)
3456 if (groupExprs ==
NIL || (pgset && *pgset ==
NIL))
3469 foreach(l, groupExprs)
3472 double this_srf_multiplier;
3493 if (srf_multiplier < this_srf_multiplier)
3494 srf_multiplier = this_srf_multiplier;
3497 if (
exprType(groupexpr) == BOOLOID)
3520 groupexpr, &vardata);
3543 if (varshere ==
NIL)
3553 foreach(l2, varshere)
3567 if (varinfos ==
NIL)
3570 numdistinct *= srf_multiplier;
3572 numdistinct = ceil(numdistinct);
3574 if (numdistinct > input_rows)
3575 numdistinct = input_rows;
3576 if (numdistinct < 1.0)
3593 double reldistinct = 1;
3594 double relmaxndistinct = reldistinct;
3595 int relvarcount = 0;
3603 relvarinfos =
lappend(relvarinfos, varinfo1);
3608 if (varinfo2->
rel == varinfo1->
rel)
3611 relvarinfos =
lappend(relvarinfos, varinfo2);
3616 newvarinfos =
lappend(newvarinfos, varinfo2);
3639 reldistinct *= mvndistinct;
3640 if (relmaxndistinct < mvndistinct)
3641 relmaxndistinct = mvndistinct;
3646 foreach(l, relvarinfos)
3651 if (relmaxndistinct < varinfo2->ndistinct)
3659 if (estinfo != NULL && varinfo2->
isdefault)
3681 double clamp = rel->
tuples;
3683 if (relvarcount > 1)
3686 if (clamp < relmaxndistinct)
3688 clamp = relmaxndistinct;
3694 if (reldistinct > clamp)
3695 reldistinct = clamp;
3702 if (reldistinct > 0 && rel->
rows < rel->
tuples)
3740 rel->
tuples / reldistinct));
3747 numdistinct *= reldistinct;
3750 varinfos = newvarinfos;
3751 }
while (varinfos !=
NIL);
3754 numdistinct *= srf_multiplier;
3757 numdistinct = ceil(numdistinct);
3760 if (numdistinct > input_rows)
3761 numdistinct = input_rows;
3762 if (numdistinct < 1.0)
3864 stanullfrac = stats->stanullfrac;
3870 avgfreq = (1.0 - stanullfrac) / ndistinct;
3891 if (ndistinct > nbuckets)
3892 estfract = 1.0 / nbuckets;
3894 estfract = 1.0 / ndistinct;
3899 if (avgfreq > 0.0 && *mcv_freq > avgfreq)
3900 estfract *= *mcv_freq / avgfreq;
3907 if (estfract < 1.0e-6)
3909 else if (estfract > 1.0)
3937 path->pathtarget->width,
3946 return hashentrysize * dNumGroups;
3969 List **varinfos,
double *ndistinct)
3990 int nshared_vars = 0;
3991 int nshared_exprs = 0;
3994 if (info->
kind != STATS_EXT_NDISTINCT)
4006 foreach(lc2, *varinfos)
4034 foreach(lc3, info->
exprs)
4046 if (nshared_vars + nshared_exprs < 2)
4056 if ((nshared_exprs > nmatches_exprs) ||
4057 (((nshared_exprs == nmatches_exprs)) && (nshared_vars > nmatches_vars)))
4060 nmatches_vars = nshared_vars;
4061 nmatches_exprs = nshared_exprs;
4062 matched_info = info;
4070 Assert(nmatches_vars + nmatches_exprs > 1);
4092 if (matched_info->
exprs)
4098 foreach(lc2, *varinfos)
4146 foreach(lc3, matched_info->
exprs)
4213 elog(
ERROR,
"corrupt MVNDistinct entry");
4216 foreach(lc, *varinfos)
4238 newlist =
lappend(newlist, varinfo);
4247 newlist =
lappend(newlist, varinfo);
4263 foreach(lc3, matched_info->
exprs)
4278 newlist =
lappend(newlist, varinfo);
4281 *varinfos = newlist;
4321 double *scaledlobound,
double *scaledhibound)
4323 bool failure =
false;
4357 case REGPROCEDUREOID:
4359 case REGOPERATOROID:
4362 case REGCOLLATIONOID:
4364 case REGDICTIONARYOID:
4366 case REGNAMESPACEOID:
4400 lostr, scaledlobound,
4401 histr, scaledhibound);
4414 if (boundstypid != BYTEAOID)
4417 lobound, scaledlobound,
4418 hibound, scaledhibound);
4426 case TIMESTAMPTZOID:
4455 *scaledvalue = *scaledlobound = *scaledhibound = 0;
4489 case REGPROCEDUREOID:
4491 case REGOPERATOROID:
4494 case REGCOLLATIONOID:
4496 case REGDICTIONARYOID:
4498 case REGNAMESPACEOID:
4529 double *scaledvalue,
4531 double *scaledlobound,
4533 double *scaledhibound)
4539 rangelo = rangehi = (
unsigned char) hibound[0];
4540 for (sptr = lobound; *sptr; sptr++)
4542 if (rangelo > (
unsigned char) *sptr)
4543 rangelo = (
unsigned char) *sptr;
4544 if (rangehi < (
unsigned char) *sptr)
4545 rangehi = (
unsigned char) *sptr;
4547 for (sptr = hibound; *sptr; sptr++)
4549 if (rangelo > (
unsigned char) *sptr)
4550 rangelo = (
unsigned char) *sptr;
4551 if (rangehi < (
unsigned char) *sptr)
4552 rangehi = (
unsigned char) *sptr;
4555 if (rangelo <= 'Z' && rangehi >=
'A')
4563 if (rangelo <= 'z' && rangehi >=
'a')
4571 if (rangelo <= '9' && rangehi >=
'0')
4583 if (rangehi - rangelo < 9)
4594 if (*lobound != *hibound || *lobound != *
value)
4596 lobound++, hibound++,
value++;
4610 int slen = strlen(
value);
4631 base = rangehi - rangelo + 1;
4636 int ch = (
unsigned char) *
value++;
4640 else if (ch > rangehi)
4642 num += ((double) (ch - rangelo)) / denom;
4717 if (xfrmlen == INT_MAX)
4720 xfrmstr = (
char *)
palloc(xfrmlen + 1);
4727 Assert(xfrmlen2 <= xfrmlen);
4748 double *scaledvalue,
4750 double *scaledlobound,
4752 double *scaledhibound)
4764 unsigned char *valstr = (
unsigned char *)
VARDATA_ANY(valuep);
4765 unsigned char *lostr = (
unsigned char *)
VARDATA_ANY(loboundp);
4766 unsigned char *histr = (
unsigned char *)
VARDATA_ANY(hiboundp);
4777 minlen =
Min(
Min(valuelen, loboundlen), hiboundlen);
4778 for (
i = 0;
i < minlen;
i++)
4780 if (*lostr != *histr || *lostr != *valstr)
4782 lostr++, histr++, valstr++;
4783 loboundlen--, hiboundlen--, valuelen--;
4796 int rangelo,
int rangehi)
4813 base = rangehi - rangelo + 1;
4816 while (valuelen-- > 0)
4822 else if (ch > rangehi)
4824 num += ((double) (ch - rangelo)) / denom;
4844 case TIMESTAMPTZOID:
4871 return (
double) (timetz->
time + (timetz->
zone * 1000000.0));
4929 if (vardata->
rel && rdata.
rel == NULL)
4937 if (vardata->
rel == NULL && rdata.
rel)
4966 bool *join_is_reversed)
4972 elog(
ERROR,
"join operator should take two arguments");
4980 if (vardata1->
rel &&
4982 *join_is_reversed =
true;
4983 else if (vardata2->
rel &&
4985 *join_is_reversed =
true;
4987 *join_is_reversed =
false;
5056 if (
IsA(basenode,
Var) &&
5057 (varRelid == 0 || varRelid == ((
Var *) basenode)->varno))
5059 Var *var = (
Var *) basenode;
5062 vardata->
var = basenode;
5064 vardata->
atttype = var->vartype;
5095 if (varRelid == 0 || varRelid == relid)
5098 vardata->
rel = onerel;
5125 vardata->
var = node;
5174 if (indexpr_item == NULL)
5177 for (pos = 0; pos <
index->ncolumns; pos++)
5179 if (
index->indexkeys[pos] == 0)
5183 if (indexpr_item == NULL)
5184 elog(
ERROR,
"too few entries in indexprs list");
5188 if (
equal(node, indexkey))
5194 if (
index->unique &&
5195 index->nkeycolumns == 1 &&
5221 elog(
ERROR,
"no function provided to release variable stats with");
5250 rte->securityQuals ==
NIL &&
5271 root->append_rel_array != NULL)
5276 appinfo =
root->append_rel_array[varno];
5282 appinfo =
root->append_rel_array[varno];
5284 if (varno !=
index->rel->relid)
5291 rte->securityQuals ==
NIL &&
5307 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5335 if (info->
kind != STATS_EXT_EXPRESSIONS)
5343 foreach(expr_item, info->
exprs)
5354 if (
equal(node, expr))
5374 rte->securityQuals ==
NIL &&
5392 root->append_rel_array != NULL)
5397 appinfo =
root->append_rel_array[varno];
5403 appinfo =
root->append_rel_array[varno];
5405 if (varno != onerel->
relid)
5412 rte->securityQuals ==
NIL &&
5456 elog(
ERROR,
"no function provided to release variable stats with");
5498 rte->securityQuals ==
NIL &&
5515 root->append_rel_array != NULL)
5522 appinfo =
root->append_rel_array[varno];
5535 int parent_varattno;
5540 parent_varattno = appinfo->parent_colnos[varattno - 1];
5541 if (parent_varattno == 0)
5545 varattno = parent_varattno;
5549 appinfo =
root->append_rel_array[varno];
5569 rte->securityQuals ==
NIL &&
5636 while (levelsup-- > 0)
5638 cteroot = cteroot->parent_root;