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. Regards Pavel