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

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: [subxact] Proof-of-concept: report nest level to client
Date: 2004-07-16 07:39:03
Message-ID: 20040716073902.GA24711@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hackers,

I tried to implement the reporting of the current transaction level to
the client using an ad-hoc ParameterStatus message. Seems it works.
To see it working I added a %d escape to psql prompt processing:

alvherre=# \set PROMPT1 '%n(at)%/%R[%d]%x '
alvherre(at)alvherre=[0] begin;
BEGIN
alvherre(at)alvherre=[1]* savepoint foo;
SAVEPOINT
alvherre(at)alvherre=[2]* savepoint bar;
SAVEPOINT
alvherre(at)alvherre=[3]* release foo;
RELEASE
alvherre(at)alvherre=[1]* savepoint another;
SAVEPOINT
alvherre(at)alvherre=[2]* commit;
COMMIT
alvherre(at)alvherre=[0]

(The nesting level, obviously, is the number between [ ]; the * is the
"in transaction" mark, which existed previously. Yes, it works if it's
> 9.)

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.

I added a function PQnestingLevel() to libpq, and a corresponding field
in pg_conn. We have to decide if we like the name, and whether we want
to have it at all.

(This is different from the previous idea in that the nesting level is
not a GUC variable -- the message is sent directly from xact.c. If this
is a bad idea, just moving the SendTransactionNestingLevel() function
can be moved somewhere else, though I couldn't figure out where.)

(*) Even then, this is hand-edited output of interdiff, so maybe it
doesn't apply at all ... if this is the case I'll submit a better patch
tomorrow.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No hay hombre que no aspire a la plenitud, es decir,
la suma de experiencias de que un hombre es capaz"

Attachment Content-Type Size
show-nest.patch text/plain 5.3 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2004-07-16 07:40:44 Re: Point in Time Recovery
Previous Message Alvaro Herrera 2004-07-16 05:44:12 Re: [subxacts] Savepoint syntax