Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-04 Thread Tom Lane
Nathan Bossart writes: > On Tue, Jun 04, 2024 at 02:28:43PM -0400, Tom Lane wrote: >> Hence, new patch attached, now with docs and tests. Barring >> objections I'll push this one. > Should we expand the documentation for SPI_connect_ext() to note that > SPI_execute_extended()/SPI_execute_plan_ex

Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-04 Thread Nathan Bossart
On Tue, Jun 04, 2024 at 02:28:43PM -0400, Tom Lane wrote: > Actually, after poking around some more I found that there *is* a way > to deal with this within spi.c: we can make _SPI_execute_plan ignore > options->allow_nonatomic unless the SPI_OPT_NONATOMIC flag was given > when connecting. > > I l

Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-04 Thread Tom Lane
I wrote: > I poked into this and found that the source of the problem is that > plpgsql's exec_stmt_call passes allow_nonatomic = true even when > it's running in an atomic context. So we can fix it with basically > a one-line change: > - options.allow_nonatomic = true; > + options.allow_

Re: Unexpected results from CALL and AUTOCOMMIT=off

2024-06-03 Thread Tom Lane
[ redirecting to pgsql-hackers ] I wrote: > I agree that this looks like a bug, since your example shows that the > same function works as-expected in an ordinary expression but not in > a CALL. The dependency on AUTOCOMMIT (that is, being within an outer > transaction block) seems even odder. I