po 12. 10. 2020 v 16:15 odesÃlatel Pavel Stehule <pavel.steh...@gmail.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 > > >