Closed arvidfm closed 2 months ago
I can reproduce this.
It looks like the reason that the error happens even if the subquery is for a different table is because the error occurs while evaluating the conditional, regardless of what's inside the THEN
block.
This seems straightforward: we have an analysis pass called assignExecIndexes
that visits each each expression and assigns it an index based on the current scope. This pass isn't being run on if-conditions in procedures.
I say "seems", because updating the pass to also apply to if-conditions fixes this behavior, but breaks some other tests. So the actual fix might be a bit more nuanced.
Trying to run an INSERT statement in a procedure within an IF that runs a subquery fails with
ERROR 1105 (HY000): unable to find field with index ... in row of ... columns
:The error seems to happen even if the subquery is for a different table than the insert.
Complete MWE: