On Mon, Jun 02, 2003 at 02:27:13PM +0100, Dominic Mitchell wrote:
> >>Well, we're calling PQsetNoticeProcessor[1], from inside dbd_db_login, 
> >>so I should be able to pass in imp_dbh as the "arg" argument.  The bit 
> >>that I wasn't sure about before was what to cast it to in order to 
> >>retrieve it from a void *.
> >
> >You could always cast it to a void * :-)
> 
> Right, I've tried to amend my patch to save a reference to the dbh, and 
> only warn if DBIc_WARN(), just like all the other cases in the code.
> 
> However, it doesn't work.  When the callback function pg_warn() gets 
> called, DBI complains that I've passed in undef.  Which implies that the 
> dbh I'm using has gone out of scope somewhere, but I can't see where.
> 
> Would somebody who's more familiar with DBD::Pg mind having a look at 
> the attached patch?  I've got no idea why it isn't working.  :-(

Ah, you're passing it the address of (probably temporary) reference.
It's the underlying object (which the ref points to) that you need.

Try something like:

  PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh));

the D_imp_dbh( (SV *)arg ) will do-the-right-thing *if* the
handle is the 'last handle used' ($DBI::lasth) whenever it's called.

That's probably not a safe assumption so you could try something
more like this:

    D_imp_dbh( sv_2mortal(newRV((SV*)arg)) );

Tim.


Reply via email to