Tim Bunce wrote:
On Mon, Jul 28, 2008 at 01:13:50PM +0100, Martin Evans wrote:
Hi,

From the DBI::DBD docs in "The dbd_db_login6 method" I read:

=====
Here’s how you fetch them; as an example we use hostname attribute,
which can be up to 12 characters long excluding null terminator:

SV** svp;
STRLEN len;
char* hostname;

if ( (svp = DBD_ATTRIB_GET_SVP(attr, "drv_hostname", 12)) && SvTRUE(*svp)) {
   hostname = SvPV(*svp, len);
   DBD__ATTRIB_DELETE(attr, "drv_hostname", 12); /* avoid later STORE */
} else {
    hostname = "localhost";
}
=====

My question concerns the comment saying "avoid later STORE". If I have a DBD::ODBC specific attribute which a) may be specified on the connect call and b) is copied to any statement handles when they are created and c) may also be on a statement handle, should I be calling DBD__ATTRIB_DELETE? and what does that "avoid later STORE" really mean?

After $drh->connect(..., $attr) returns a handle DBI->connect(...)
effectively does $dbh->STORE($_, $attr->{$_}) for keys %$attr;

If the handle has already dealt with the attribute during the drivers
connect/login processing then the later STORE by the DBI is at best
redundant and could, at worse, cause problems/errors/whatever.

So the driver can delete from %$attr any attributes it doesn't want the
DBI to call STORE on later.

Tim.

p.s. patch to DBI::DBD docs most welcome!



Thanks for the clarification.

First patch appears to be:

DBD__ATTRIB_DELETE => DBD_ATTRIB_DELETE

as I can find the latter and not the former. Unless I've got something else wrong I get a segfault the minute I used DBD_ATTRIB_DELETE and I notice DBD::Oracle does not use it. Is anyone using DBD_ATTRIB_DELETE and can confirm it works? I am only doing:

/* odbc_putdata_start */
{
    SV **svp;
    IV putdata_start_value;

    DBD_ATTRIB_GET_IV(
        attr, "odbc_putdata_start", strlen("odbc_putdata_start"),
        svp, putdata_start_value);
    if (svp) {
        imp_dbh->odbc_putdata_start = putdata_start_value;
        if (DBIc_TRACE(imp_dbh, 0, 0, 3))
            TRACE1(imp_dbh, "    Setting DBH putdata_start to %d\n",
                   (int)putdata_start_value);
#ifdef THE_FOLLOWING_SEG_FAULTS
        /* avoid later STORE */
        DBD_ATTRIB_DELETE(attr, "odbc_putdata_start",
                          strlen("odbc_putdata_start"));
#endif
    }
}

Thanks

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Reply via email to