* ExecGetInsertNewTuple * This prepares a "new" tuple ready to be inserted into given result * relation, by removing any junk columns of the plan's output tuple * and (if necessary) coercing the tuple to the right tuple format. */
| 577 | * and (if necessary) coercing the tuple to the right tuple format. |
| 578 | */ |
| 579 | static TupleTableSlot * |
| 580 | ExecGetInsertNewTuple(ResultRelInfo *relinfo, |
| 581 | TupleTableSlot *planSlot) |
| 582 | { |
| 583 | ProjectionInfo *newProj = relinfo->ri_projectNew; |
| 584 | ExprContext *econtext; |
| 585 | |
| 586 | /* |
| 587 | * If there's no projection to be done, just make sure the slot is of the |
| 588 | * right type for the target rel. If the planSlot is the right type we |
| 589 | * can use it as-is, else copy the data into ri_newTupleSlot. |
| 590 | */ |
| 591 | if (newProj == NULL) |
| 592 | { |
| 593 | if (relinfo->ri_newTupleSlot->tts_ops != planSlot->tts_ops) |
| 594 | { |
| 595 | ExecCopySlot(relinfo->ri_newTupleSlot, planSlot); |
| 596 | return relinfo->ri_newTupleSlot; |
| 597 | } |
| 598 | else |
| 599 | return planSlot; |
| 600 | } |
| 601 | |
| 602 | /* |
| 603 | * Else project; since the projection output slot is ri_newTupleSlot, this |
| 604 | * will also fix any slot-type problem. |
| 605 | * |
| 606 | * Note: currently, this is dead code, because INSERT cases don't receive |
| 607 | * any junk columns so there's never a projection to be done. |
| 608 | */ |
| 609 | econtext = newProj->pi_exprContext; |
| 610 | econtext->ecxt_outertuple = planSlot; |
| 611 | return ExecProject(newProj); |
| 612 | } |
| 613 | |
| 614 | /* |
| 615 | * ExecGetUpdateNewTuple |
no test coverage detected