---------- * plpgsql_exec_event_trigger Called by the call handler for * event trigger execution. * ---------- */
| 1143 | * ---------- |
| 1144 | */ |
| 1145 | void |
| 1146 | plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata) |
| 1147 | { |
| 1148 | PLpgSQL_execstate estate; |
| 1149 | ErrorContextCallback plerrcontext; |
| 1150 | int rc; |
| 1151 | |
| 1152 | /* |
| 1153 | * Setup the execution state |
| 1154 | */ |
| 1155 | plpgsql_estate_setup(&estate, func, NULL, NULL, NULL); |
| 1156 | estate.evtrigdata = trigdata; |
| 1157 | |
| 1158 | /* |
| 1159 | * Setup error traceback support for ereport() |
| 1160 | */ |
| 1161 | plerrcontext.callback = plpgsql_exec_error_callback; |
| 1162 | plerrcontext.arg = &estate; |
| 1163 | plerrcontext.previous = error_context_stack; |
| 1164 | error_context_stack = &plerrcontext; |
| 1165 | |
| 1166 | /* |
| 1167 | * Make local execution copies of all the datums |
| 1168 | */ |
| 1169 | estate.err_text = gettext_noop("during initialization of execution state"); |
| 1170 | copy_plpgsql_datums(&estate, func); |
| 1171 | |
| 1172 | /* |
| 1173 | * Let the instrumentation plugin peek at this function |
| 1174 | */ |
| 1175 | if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg) |
| 1176 | ((*plpgsql_plugin_ptr)->func_beg) (&estate, func); |
| 1177 | |
| 1178 | /* |
| 1179 | * Now call the toplevel block of statements |
| 1180 | */ |
| 1181 | estate.err_text = NULL; |
| 1182 | rc = exec_toplevel_block(&estate, func->action); |
| 1183 | if (rc != PLPGSQL_RC_RETURN) |
| 1184 | { |
| 1185 | estate.err_text = NULL; |
| 1186 | ereport(ERROR, |
| 1187 | (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), |
| 1188 | errmsg("control reached end of trigger procedure without RETURN"))); |
| 1189 | } |
| 1190 | |
| 1191 | estate.err_text = gettext_noop("during function exit"); |
| 1192 | |
| 1193 | /* |
| 1194 | * Let the instrumentation plugin peek at this function |
| 1195 | */ |
| 1196 | if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_end) |
| 1197 | ((*plpgsql_plugin_ptr)->func_end) (&estate, func); |
| 1198 | |
| 1199 | /* Clean up any leftover temporary memory */ |
| 1200 | plpgsql_destroy_econtext(&estate); |
| 1201 | exec_eval_cleanup(&estate); |
| 1202 | /* stmt_mcontext will be destroyed when function's main context is */ |
no test coverage detected