Skip site navigation (1) Skip section navigation (2)

Re: PQsetNoticeReceiver issues

From: L J Bayuk <ljb220(at)mindspring(dot)com>
To: peter_e(at)gmx(dot)net (Peter Eisentraut)
Cc: jgardner(at)jonathangardner(dot)net (Jonathan Gardner),pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQsetNoticeReceiver issues
Date: 2004-01-19 02:38:30
Message-ID: 200401190238.i0J2cUwB000262@mindspring.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
Peter Eisentraut wrote:
> 
> Jonathan Gardner wrote:
> > I've run into a conundrum with the PQsetNoticeReceiver function call.
> > How do you set it back to the original default? How do you call the
> > appropriate PQnoticeProcessor as well?
> 
> The documentation says:
> 
>  Each of these functions returns the previous notice receiver or 
> processor function pointer, and sets the new value. If you supply a 
> null function pointer, no action is taken, but the current pointer is 
> returned.

Saving and restoring the previous noticeProcessor or noticeReceiver handler
function works, unless they actually made use of the "arg" pass-through
argument.  For example, somewhere you have:
     PQsetNoticeProcessor(conn, myNoticeProc, &mydata);

And somewhere else you want to temporarily override the noticeProcessor:
     prevNoticeProc = PQsetNoticeProcessor(conn, newNoticeProc, &newdata);
     /* ... Do something which makes a notice ... */

     /* Restore previous notice processor */
     PQsetNoticeProcessor(conn, prevNoticeProc, ????);
     /* Oops, lost the previous "arg". */
Not exactly a huge API hole, but nevertheless...

In response to

pgsql-interfaces by date

Next:From: Edmund BaconDate: 2004-01-19 18:31:36
Subject: ECPG and typedef struct
Previous:From: Peter EisentrautDate: 2004-01-18 10:19:58
Subject: Re: PQsetNoticeReceiver issues

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group