Re: troubleshooting pointers - Mailing list pgsql-hackers

From Joe Conway
Subject Re: troubleshooting pointers
Date
Msg-id 3CDC76A9.7080308@joeconway.com
Whole thread Raw
In response to troubleshooting pointers  (Joe Conway <mail@joeconway.com>)
Responses Re: troubleshooting pointers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Um.  I don't like that; it assumes not only that ExecutorEnd is the only
> kind of callback needed, but also that there is at most one function
> per ExprContext that needs a shutdown callback.  Neither of these
> assumptions hold water IMO.
> 
> The design I had in mind was more like this: add to ExprContext a list
> header field pointing to a list of structs along the lines of
> 
>     struct exprcontext_callback {
>         struct exprcontext_callback *next;
>         void (*function) (Datum);
>         Datum arg;
>     }
> 
> and then call each specified function with given argument during
> FreeExprContext.  Probably ought to be careful to do that in reverse
> order of registration.  We'd also need to invent a RescanExprContext
> operation to call the callbacks during a Rescan.  The use of Datum
> (and not, say, void *) as PG's standard callback arg type was settled on
> some time ago --- originally for on_proc_exit IIRC --- and seems to have
> worked well enough.

Well, I guess I set my sights too low ;-) This is a very nice design.

I have the shutdown callback working now, and will send a new patch in a 
few minutes. I have not started RescanExprContext() yet, but will do it 
when I address rescans in general.

> What's really more relevant here is that during the hypothetical new
> RescanExprContext function, we ought to go around and clear any fcaches
> in the context that have setArgsValid = true, so that they will be
> restarted afresh during the next scan of the plan.  (The fact that that
> doesn't happen now is another shortcoming of the existing set-functions-
> in-expressions code.)  So this suggests making a callback function type
> specifically to do that, and registering every fcache that is executing
> a set function in the callback list...

I also added FunctionCachePtr_callback struct and a member to 
ExprContext. I have not yet created the registration or shutdown 
functions, but again, I'll work on them as part of the rescan work.

I still have a couple of issues related to VIEWs that I need to figure 
out, then I'll start the rescan work.

Thanks for the review and help!

Joe



pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: [BUGS] Bug #659: lower()/upper() bug on ->multibyte<- DB
Next
From: Tom Lane
Date:
Subject: Re: troubleshooting pointers