Skip to content

Commit

Permalink
arrow_fdw: unable to detect stats-hint operators if expression node w…
Browse files Browse the repository at this point in the history
…as rewritten to INDEX_VAR+resno form

this bug is related to heterodb#747
  • Loading branch information
kaigai committed Apr 13, 2024
1 parent 58b1866 commit b47e1d5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/arrow_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,18 @@ __buildArrowStatsOper(arrowStatsHint *as_hint,
var = lsecond(op->args);
arg = linitial(op->args);
}
/* Is it VAR <OPER> ARG form? */
/*
* Is it VAR <OPER> ARG form?
*
* MEMO: expression nodes (like Var) might be rewritten to INDEX_VAR +
* resno on the custom_scan_tlist by setrefs.c, so we should reference
* Var::varnosyn and ::varattnosyn, instead of ::varno and ::varattno.
*/
if (!IsA(var, Var) || !OidIsValid(opcode))
return false;
if (var->varno != scan->scanrelid)
if (var->varnosyn != scan->scanrelid)
return false;
if (!bms_is_member(var->varattno, as_hint->stat_attrs))
if (!bms_is_member(var->varattnosyn, as_hint->stat_attrs))
return false;
if (contain_var_clause(arg) ||
contain_volatile_functions(arg))
Expand Down

0 comments on commit b47e1d5

Please sign in to comment.