Re: BUG #18456: Trigger data in plpython3u trigger-function changes in AFTER UPDATE OR INSERT trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jacques(at)quantsolutions(dot)co(dot)za
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18456: Trigger data in plpython3u trigger-function changes in AFTER UPDATE OR INSERT trigger
Date: 2024-05-04 18:34:40
Message-ID: 2944262.1714847680@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> Then the trigger data changes after the insert statement in the trigger
> function.

Hmm. TD is defined as a global dictionary like SD, so it saves values
across calls to the plpython function. So the inner INSERT operation
fires the same trigger, which decides not to print anything, but
nonetheless it's changed TD and the outer trigger call will see that.

There used to be similar problems in plain plpython functions if they
were invoked recursively, because named function arguments are also
passed as global variables. We fixed that in a rather hacky way in
1d2fe56e4, ie save and restore those globals when recursing.
Probably the same thing could be done with TD.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2024-05-05 00:55:38 Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries
Previous Message Alena Rybakina 2024-05-04 11:53:10 Re: BUG #17257: (auto)vacuum hangs within lazy_scan_prune()