Re: [subxact] Proof-of-concept: report nest level to client

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [subxact] Proof-of-concept: report nest level to client
Date: 2004-07-16 22:50:20
Message-ID: 40F85BAC.7090308@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
>
>>Patch attached (surprinsingly small), though it only applies with the
>>savepoint patch applied(*). If any driver writer wants to play, however,
>>it's easy to see what's going on -- a ParameterStatus message will be
>>received from the backend whenever the nesting level changes.
>
>
> This is really quite the wrong behavior --- think about a function that
> executes thousands of subtransactions before returning. You really do
> not want to emit a message for every nestlevel change. (That's one of
> the reasons I rejected doing this as a regular GUC variable.)
>
> We could possibly send the info as a fake ParameterStatus that's only
> sent just before the Z message, ie only when the backend is about to
> wait for a command.

This is not really sufficient when using the extended query protocol to
run several queries before a Sync. Consider "SAVEPOINT foo; SELECT ...;
SAVEPOINT bar; SELECT ..." run as (Parse/Bind/Execute)x4 + Sync. If the
client wants to track the nesting level of portals returned by the Bind
messages -- so it can know when they're invalidated on rollback -- it
can't if the level is only given in ReadyForQuery.

What about emitting any nesting level change once at the end of
processing each protocol message? More specifically I think Execute and
Query are the only messages that should change nesting level?

> - need for option to make protocol-created portals act like WITH HOLD cursors

And SCROLL.

> and IIRC we have identified some other minor misfeatures in the 7.4
> protocol design as well, though I'd have to dig through the archives
> to remember the details. If we find any more I'll start to think that
> we should just do it ...

One change I thought might be useful is to include the name of the
opened or closed portal or statement in ParseComplete, BindComplete,
CloseComplete messages. A V3 client that's streaming multiple commands
before a Sync has to do some extra work to track exactly which resources
it's allocated, remembering the exact order it requested operations and
matching them up to the (anonymous) responses it gets.

Also on my wishlist is a message whenever a portal is implicitly closed
(perhaps a spontaneous CloseComplete?) although I have no idea how hard
this is to implement :)

There was also a brief discussion earlier around defining exactly when
in the protocol stream the client encoding changes after a SET
client_encoding (and the encoding of the startup packets). This might
just be documentation.

But none of these are important enough to force a protocol change by
themselves.

-O

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-07-17 01:11:23 Re: initdb authentication
Previous Message Bruce Momjian 2004-07-16 21:13:57 Re: pg_autovacuum integration attempt #2