Re: NOTIFY in multi-statement PQexec() not sent outside of transaction

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Muehlhausen <jgm(at)jgm(dot)org>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: NOTIFY in multi-statement PQexec() not sent outside of transaction
Date: 2020-04-20 20:10:03
Message-ID: 7726.1587413403@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

John Muehlhausen <jgm(at)jgm(dot)org> writes:
> My perspective as a libpq user is that multi-statement PQexec() should have
> the same effects as multiple PQexec() calls other than for the former
> dropping the results of all but the most recent statement.

Well, that's not even close to true, because of the rules about statements
within a multi-statement string getting merged into single transactions.

> As a practical matter, what I was trying to do is signal a test case that
> Postgres is in the middle of processing a transaction string.

I'm not really sure why you want to go about that in this particular way;
under ordinary circumstances the client app wouldn't see the notify until
after PQexec returned, anyway. (Yes, I realize that there are ways around
that, but still, you can't really do anything with the connection until
PQexec returns.)

Perhaps you could achieve a similar effect using single-row mode,
ie break the connection after collecting a few rows from a multi-row
query? That's not PQexec at all of course, but if you use PQsendQuery
then the server doesn't know the difference.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message John Muehlhausen 2020-04-20 20:27:04 Re: NOTIFY in multi-statement PQexec() not sent outside of transaction
Previous Message John Muehlhausen 2020-04-20 19:56:33 Re: NOTIFY in multi-statement PQexec() not sent outside of transaction