* Evaluate a wholerow Var expression. * * Returns a Datum whose value is the value of a whole-row range variable * with respect to given expression context. */
| 4170 | * with respect to given expression context. |
| 4171 | */ |
| 4172 | void |
| 4173 | ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext) |
| 4174 | { |
| 4175 | Var *variable = op->d.wholerow.var; |
| 4176 | TupleTableSlot *slot; |
| 4177 | TupleDesc output_tupdesc; |
| 4178 | MemoryContext oldcontext; |
| 4179 | HeapTupleHeader dtuple; |
| 4180 | HeapTuple tuple; |
| 4181 | |
| 4182 | /* This was checked by ExecInitExpr */ |
| 4183 | Assert(variable->varattno == InvalidAttrNumber); |
| 4184 | |
| 4185 | /* Get the input slot we want */ |
| 4186 | switch (variable->varno) |
| 4187 | { |
| 4188 | case INNER_VAR: |
| 4189 | /* get the tuple from the inner node */ |
| 4190 | slot = econtext->ecxt_innertuple; |
| 4191 | break; |
| 4192 | |
| 4193 | case OUTER_VAR: |
| 4194 | /* get the tuple from the outer node */ |
| 4195 | slot = econtext->ecxt_outertuple; |
| 4196 | break; |
| 4197 | |
| 4198 | /* INDEX_VAR is handled by default case */ |
| 4199 | |
| 4200 | default: |
| 4201 | /* get the tuple from the relation being scanned */ |
| 4202 | slot = econtext->ecxt_scantuple; |
| 4203 | break; |
| 4204 | } |
| 4205 | |
| 4206 | /* Apply the junkfilter if any */ |
| 4207 | if (op->d.wholerow.junkFilter != NULL) |
| 4208 | slot = ExecFilterJunk(op->d.wholerow.junkFilter, slot); |
| 4209 | |
| 4210 | /* |
| 4211 | * If first time through, obtain tuple descriptor and check compatibility. |
| 4212 | * |
| 4213 | * XXX: It'd be great if this could be moved to the expression |
| 4214 | * initialization phase, but due to using slots that's currently not |
| 4215 | * feasible. |
| 4216 | */ |
| 4217 | if (op->d.wholerow.first) |
| 4218 | { |
| 4219 | /* optimistically assume we don't need slow path */ |
| 4220 | op->d.wholerow.slow = false; |
| 4221 | |
| 4222 | /* |
| 4223 | * If the Var identifies a named composite type, we must check that |
| 4224 | * the actual tuple type is compatible with it. |
| 4225 | */ |
| 4226 | if (variable->vartype != RECORDOID) |
| 4227 | { |
| 4228 | TupleDesc var_tupdesc; |
| 4229 | TupleDesc slot_tupdesc; |
no test coverage detected