---------- * exec_assign_expr Put an expression's result into a variable. * ---------- */
| 4936 | * ---------- |
| 4937 | */ |
| 4938 | static void |
| 4939 | exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target, |
| 4940 | PLpgSQL_expr *expr) |
| 4941 | { |
| 4942 | Datum value; |
| 4943 | bool isnull; |
| 4944 | Oid valtype; |
| 4945 | int32 valtypmod; |
| 4946 | |
| 4947 | /* |
| 4948 | * If first time through, create a plan for this expression. |
| 4949 | */ |
| 4950 | if (expr->plan == NULL) |
| 4951 | { |
| 4952 | /* |
| 4953 | * Mark the expression as being an assignment source, if target is a |
| 4954 | * simple variable. (This is a bit messy, but it seems cleaner than |
| 4955 | * modifying the API of exec_prepare_plan for the purpose. We need to |
| 4956 | * stash the target dno into the expr anyway, so that it will be |
| 4957 | * available if we have to replan.) |
| 4958 | */ |
| 4959 | if (target->dtype == PLPGSQL_DTYPE_VAR) |
| 4960 | expr->target_param = target->dno; |
| 4961 | else |
| 4962 | expr->target_param = -1; /* should be that already */ |
| 4963 | |
| 4964 | exec_prepare_plan(estate, expr, 0); |
| 4965 | } |
| 4966 | |
| 4967 | value = exec_eval_expr(estate, expr, &isnull, &valtype, &valtypmod); |
| 4968 | exec_assign_value(estate, target, value, isnull, valtype, valtypmod); |
| 4969 | exec_eval_cleanup(estate); |
| 4970 | } |
| 4971 | |
| 4972 | |
| 4973 | /* ---------- |
no test coverage detected