Re: Nested transactions: deferred triggers

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Nested transactions: deferred triggers
Date: 2003-06-11 22:02:25
Message-ID: 20030611220225.GC1932@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Wed, Jun 11, 2003 at 03:53:56PM -0400, Tom Lane wrote:

> Seems reasonable, but I have a stylistic gripe:
>
> > + static DeferredTriggers ts;
>
> I dislike static variables with names as short as that --- they are too
> likely to conflict against local variables. (And before you say there's
> no problem because a local declaration would mask it, what happens if
> you forget the local declaration?)
>
> I suspect you named it this way because you intend to pass it as a
> parameter to all these routines later, and you're trying to avoid
> one pass of editing when you add "DeferredTriggers ts" to the parameter
> lists. I would suggest doing that now and including it in the patch.
> Whether you are intending that or not, please use a better name for
> the static variable.

Actually, the function itself is going to obtain it via a
TransactionGetDeferredTriggers() call so it's going to be a variable
local to the function. I'm not sure if it can be made a parameter,
because I don't control the deferred trigger queue completely (e.g. on
new item insertion the caller is something outside my control).

Please comment on what do you think about the
TransactionGetDeferredTrigger function mentioned earlier. This is going
to be in a struct that will be part of the TransactionState, and which
will hold pointer to the deferred triggers queue, the smgr's pending
deletes, the asynchronous notify queue and the OnCommit actions queue.

Also there will be a MemoryContext for holding items on each of those
lists. This context will be destroyed on subtransaction abort but will
be kept on subtransaction commit -- this allows for easy deallocation of
said items on subtrans abort, while keeping them after the
subtransaction commits.

So I need a way for the affected subsystems to get their structures.
This is it. There'll also be a TransactionGetParentPendingDeletes so I
can concatenate the list of the committing subtransaction to its
parent's list. (This will be done using your new cool FastLists, BTW).

Regarding the current patch, I have changed the variable name to
something better. Please apply.

Thanks for the quick reviewing.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"The Gord often wonders why people threaten never to come back after they've
been told never to return" (www.actsofgord.com)

Attachment Content-Type Size
deferredTriggers-4.patch text/plain 13.5 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-06-11 22:12:17 Re: [HACKERS] "Adding missing from clause" (replacement)
Previous Message Bruce Momjian 2003-06-11 21:34:17 Re: Ipv6 network cleanup patch #2.