po 19. 11. 2018 v 19:37 odesÃlatel Pavel Stehule <pavel.steh...@gmail.com> napsal:
> Hi > > I am playing with plpgsql profiling and and plpgsql plugin API. I found so > callback stmt_beg and stmt_end was not called for top statement due direct > call exec_stmt_block function. > > <-->estate.err_text = NULL; > <-->estate.err_stmt = (PLpgSQL_stmt *) (func->action); > <-->rc = exec_stmt_block(&estate, func->action); > <-->if (rc != PLPGSQL_RC_RETURN) > <-->{ > <--><-->estate.err_stmt = NULL; > <--><-->estate.err_text = NULL; > > Isn't better to call exec_stmt there? Then plpgsql plugin function will be > called really for every plpgsql statement. > Now, the statement's hook is not called for every plpgsql_stmt_block statement. It is not big issue, but it is not consistent - and this inconsistency should be repaired inside extension. Better to be consistent and every plpgsql statement call identically. patch attached - all regress tests passed. This patch has a effect only on plpgsql extensions. Regards Pavel > Regards > > Pavel >
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 42358c2ebe..f292fcad2d 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -585,7 +585,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo, */ estate.err_text = NULL; estate.err_stmt = (PLpgSQL_stmt *) (func->action); - rc = exec_stmt_block(&estate, func->action); + rc = exec_stmt(&estate, (PLpgSQL_stmt *) func->action); if (rc != PLPGSQL_RC_RETURN) { estate.err_stmt = NULL; @@ -955,7 +955,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, */ estate.err_text = NULL; estate.err_stmt = (PLpgSQL_stmt *) (func->action); - rc = exec_stmt_block(&estate, func->action); + rc = exec_stmt(&estate, (PLpgSQL_stmt *) func->action); if (rc != PLPGSQL_RC_RETURN) { estate.err_stmt = NULL; @@ -1116,7 +1116,7 @@ plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata) */ estate.err_text = NULL; estate.err_stmt = (PLpgSQL_stmt *) (func->action); - rc = exec_stmt_block(&estate, func->action); + rc = exec_stmt(&estate, (PLpgSQL_stmt *) func->action); if (rc != PLPGSQL_RC_RETURN) { estate.err_stmt = NULL;