From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: broken logic of simple_eval_resowner after CALL and COMMIT inside procedure |
Date: | 2020-10-12 14:36:00 |
Message-ID: | CAFj8pRBWy9FkmNqLP0agd=jMWsqnF80-1r5DmidgSm0RHEf+uA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
po 12. 10. 2020 v 16:15 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
napsal:
> Hi
>
> Inline handler creates simple_eval_resowner (without parent).
>
> Inside plpgsql_estate_setup this value is assigned to
> estate->simple_eval_resowner
>
> <-->if (simple_eval_resowner)
> <--><-->estate->simple_eval_resowner = simple_eval_resowner;
> <-->else
> <--><-->estate->simple_eval_resowner = shared_simple_eval_resowner;
>
> When we call procedure with inner COMMIT, then when "before_lxid !=
> after_lxid" following code is
> executed.
>
> <--><-->estate->simple_eval_estate = NULL;
> <--><-->estate->simple_eval_resowner = NULL;
> <--><-->plpgsql_create_econtext(estate);
>
> and
>
> fragment from plpgsql_create_econtext
>
> <-->/*
> <--> * Likewise for the simple-expression resource owner.
> <--> */
> <-->if (estate->simple_eval_resowner == NULL)
> <-->{
> <--><-->if (shared_simple_eval_resowner == NULL)
> <--><--><-->shared_simple_eval_resowner =
> <--><--><--><-->ResourceOwnerCreate(TopTransactionResourceOwner,
> <--><--><--><--><--><--><--><--><-->"PL/pgSQL simple expressions");
> <--><-->estate->simple_eval_resowner = shared_simple_eval_resowner;
> <-->}
>
> In this case simple_eval_resowner from inline handler is overwritten and
> only shared_simple_eval_resowner will be used.
>
> So is it "estate->simple_eval_resowner = NULL;" error (without other
> conditions)?
>
Probably it is described
*
* (However, if a DO block executes COMMIT or ROLLBACK, then
exec_stmt_commit
* or exec_stmt_rollback will unlink it from the DO's simple-expression
EState
* and create a new shared EState that will be used thenceforth. The
original
* EState will be cleaned up when we get back to plpgsql_inline_handler.
This
* is a bit ugly, but it isn't worth doing better, since scenarios like this
* can't result in indefinite accumulation of state trees.)
Pavel
>
> Regards
>
> Pavel
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Shinoda, Noriyoshi (PN Japan A&PS Delivery) | 2020-10-12 14:45:04 | RE: Resetting spilled txn statistics in pg_stat_replication |
Previous Message | Pavel Stehule | 2020-10-12 14:15:51 | broken logic of simple_eval_resowner after CALL and COMMIT inside procedure |