Re: plpgsql plugin - stmt_beg/end is not called for top level block of statements

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql plugin - stmt_beg/end is not called for top level block of statements
Date: 2018-12-16 09:33:38
Message-ID: CAFj8pRDOHHeJSWZTRoSK4Eo16TRZQxzxzKu9h6KLRvnmsE0F4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

po 19. 11. 2018 v 19:37 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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
>

Attachment Content-Type Size
plpgsql-bugfix-top-stmt-call.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2018-12-16 10:19:03 Re: select limit error in file_fdw
Previous Message Pavel Stehule 2018-12-16 08:04:41 Re: proposal: plpgsql pragma statement