FAQ
The DBD::mysql do() method doesn't set $dbh->{Statement} attribute.

This means:
a) using DBI::Profile doesn't give correct profile results for calls to do()
b) using ShowErrorStatement may report the wrong statement in the error message.

I've attached a patch, including a test.

Tim.

p.s. Until DBD::mysql gets patched here's a workaround for profiling:

if ($ENV{DBI_PROFILE}) {
# workaround bug in DBD::mysql where its own do() method doesn't set $dbh->{Statement}
# if we're profiling the fallback to the DBI's own do metgod
require DBD::mysql;
no strict 'refs';
delete ${"DBD::mysql::db::"}{do};
}

Search Discussions

  • Tim Bunce at Feb 15, 2007 at 6:27 pm

    On Thu, Feb 15, 2007 at 05:10:20PM +0000, Tim Bunce wrote:
    The DBD::mysql do() method doesn't set $dbh->{Statement} attribute.

    This means:
    a) using DBI::Profile doesn't give correct profile results for calls to do()
    b) using ShowErrorStatement may report the wrong statement in the error message.

    I've attached a patch, including a test.

    Tim.

    p.s. Until DBD::mysql gets patched here's a workaround for profiling:

    if ($ENV{DBI_PROFILE}) {
    # workaround bug in DBD::mysql where its own do() method doesn't set $dbh->{Statement}
    # if we're profiling the fallback to the DBI's own do metgod
    require DBD::mysql;
    no strict 'refs';
    delete ${"DBD::mysql::db::"}{do};
    }
    Umm, it's curious where typos can lead...

    metgod: a phrase used in celebration of a goal in a footy game in the schoolyard

    http://www.odps.org/glossword/index.php?a=term&d=4&q=metgod

    Tim.

    p.s. Thanks to Jonathan Leffler for pointing out one of the two typos on that line ;-)
  • Patrick Galbraith at Feb 23, 2007 at 4:35 am
    Tim,

    Again, Thanks, and I'll be doing a release tomorrow or this weekend at
    latest.

    Kind regareds,

    Patrick

    Tim Bunce wrote:
    The DBD::mysql do() method doesn't set $dbh->{Statement} attribute.

    This means:
    a) using DBI::Profile doesn't give correct profile results for calls to do()
    b) using ShowErrorStatement may report the wrong statement in the error message.

    I've attached a patch, including a test.

    Tim.

    p.s. Until DBD::mysql gets patched here's a workaround for profiling:

    if ($ENV{DBI_PROFILE}) {
    # workaround bug in DBD::mysql where its own do() method doesn't set $dbh->{Statement}
    # if we're profiling the fallback to the DBI's own do metgod
    require DBD::mysql;
    no strict 'refs';
    delete ${"DBD::mysql::db::"}{do};
    }




    ------------------------------------------------------------------------

    Only in DBD-mysql-4.001.timbunce1: Makefile
    Only in DBD-mysql-4.001.timbunce1: blib
    Only in DBD-mysql-4.001.timbunce1: dbdimp.o
    Only in DBD-mysql-4.001.timbunce1: mysql.bs
    Only in DBD-mysql-4.001.timbunce1: mysql.c
    Only in DBD-mysql-4.001.timbunce1: mysql.o
    diff -ur DBD-mysql-4.001/mysql.xs DBD-mysql-4.001.timbunce1/mysql.xs
    --- DBD-mysql-4.001/mysql.xs 2007-01-08 00:39:05.000000000 +0000
    +++ DBD-mysql-4.001.timbunce1/mysql.xs 2007-02-15 16:59:46.000000000 +0000
    @@ -300,6 +300,8 @@
    "mysql.xs do() use_server_side_prepare %d\n",
    use_server_side_prepare);

    + hv_store((HV*)SvRV(dbh), "Statement", 9, SvREFCNT_inc(statement), 0);
    +
    if (use_server_side_prepare)
    {
    str_ptr= SvPV(statement, slen);
    Only in DBD-mysql-4.001.timbunce1: mysql.xsi
    Only in DBD-mysql-4.001.timbunce1: pm_to_blib
    diff -ur DBD-mysql-4.001/t/20createdrop.t DBD-mysql-4.001.timbunce1/t/20createdrop.t
    --- DBD-mysql-4.001/t/20createdrop.t 2006-12-23 18:03:30.000000000 +0000
    +++ DBD-mysql-4.001.timbunce1/t/20createdrop.t 2007-02-15 16:58:27.000000000 +0000
    @@ -73,6 +73,12 @@
    or DbiError($dbh->err, $dbh->errstr);

    #
    + # ... check do() sets $dbh->{Statement}
    + #
    + Test($state or $dbh->{Statement} eq "DROP TABLE $table")
    + or DbiError(1, "do() didn't set Statement attribute");
    +
    + #
    # Finally disconnect.
    #
    Test($state or $dbh->disconnect())
    Only in DBD-mysql-4.001.timbunce1/t: mysql.mtest

    --
    Patrick Galbraith, Senior Programmer
    Grazr - Easy feed grazing and sharing
    http://www.grazr.com

    Satyam Eva Jayate - Truth Alone Triumphs
    Mundaka Upanishad
  • Tim Bunce at Feb 23, 2007 at 3:05 pm

    On Thu, Feb 22, 2007 at 11:35:09PM -0500, Patrick Galbraith wrote:
    Tim,

    Again, Thanks, and I'll be doing a release tomorrow or this weekend at latest.
    Don't just yet! I've some more patches for you.
    (I'll send them as separate emails in a few minutes.)

    I've been testing DBD::Gofer by running the DBD::mysql test suite through it:

    $ DBI_AUTOPROXY='dbi:Gofer:transport=null;policy=pedantic' make test

    It's a *great* way to flush out issues with both DBD::Gofer and the driver.
    (I'll be doing the same with DBD::Sybase soon, since that's what
    Shopzilla are using.)

    I'd be delighted if other driver authors could do the same with their
    own test suites and post the results.

    Anyway, that showed up a DBD::mysql problem with NUM_OF_FIELDS. It
    wasn't being adjusted when returning multiple result sets of different
    widths. In fact none of the resultset attributes were being adjusted
    if they had already been accessed.

    I'd also be grateful if you could deal with
    http://bugs.mysql.com/bug.php?id=23974

    Tim.
    Kind regareds,

    Patrick

    Tim Bunce wrote:
    The DBD::mysql do() method doesn't set $dbh->{Statement} attribute.

    This means:
    a) using DBI::Profile doesn't give correct profile results for calls to
    do()
    b) using ShowErrorStatement may report the wrong statement in the error
    message.

    I've attached a patch, including a test.

    Tim.

    p.s. Until DBD::mysql gets patched here's a workaround for profiling:

    if ($ENV{DBI_PROFILE}) {
    # workaround bug in DBD::mysql where its own do() method doesn't
    set $dbh->{Statement}
    # if we're profiling the fallback to the DBI's own do metgod
    require DBD::mysql;
    no strict 'refs';
    delete ${"DBD::mysql::db::"}{do};
    }




    ------------------------------------------------------------------------

    Only in DBD-mysql-4.001.timbunce1: Makefile
    Only in DBD-mysql-4.001.timbunce1: blib
    Only in DBD-mysql-4.001.timbunce1: dbdimp.o
    Only in DBD-mysql-4.001.timbunce1: mysql.bs
    Only in DBD-mysql-4.001.timbunce1: mysql.c
    Only in DBD-mysql-4.001.timbunce1: mysql.o
    diff -ur DBD-mysql-4.001/mysql.xs DBD-mysql-4.001.timbunce1/mysql.xs
    --- DBD-mysql-4.001/mysql.xs 2007-01-08 00:39:05.000000000 +0000
    +++ DBD-mysql-4.001.timbunce1/mysql.xs 2007-02-15
    16:59:46.000000000 +0000
    @@ -300,6 +300,8 @@
    "mysql.xs do() use_server_side_prepare %d\n",
    use_server_side_prepare);

    + hv_store((HV*)SvRV(dbh), "Statement", 9, SvREFCNT_inc(statement), 0);
    +
    if (use_server_side_prepare)
    {
    str_ptr= SvPV(statement, slen);
    Only in DBD-mysql-4.001.timbunce1: mysql.xsi
    Only in DBD-mysql-4.001.timbunce1: pm_to_blib
    diff -ur DBD-mysql-4.001/t/20createdrop.t
    DBD-mysql-4.001.timbunce1/t/20createdrop.t
    --- DBD-mysql-4.001/t/20createdrop.t 2006-12-23 18:03:30.000000000 +0000
    +++ DBD-mysql-4.001.timbunce1/t/20createdrop.t 2007-02-15
    16:58:27.000000000 +0000
    @@ -73,6 +73,12 @@
    or DbiError($dbh->err, $dbh->errstr);

    #
    + # ... check do() sets $dbh->{Statement}
    + #
    + Test($state or $dbh->{Statement} eq "DROP TABLE $table")
    + or DbiError(1, "do() didn't set Statement attribute");
    +
    + #
    # Finally disconnect.
    #
    Test($state or $dbh->disconnect())
    Only in DBD-mysql-4.001.timbunce1/t: mysql.mtest

    --
    Patrick Galbraith, Senior Programmer
    Grazr - Easy feed grazing and sharing
    http://www.grazr.com

    Satyam Eva Jayate - Truth Alone Triumphs
    Mundaka Upanishad
  • Ask Bjørn Hansen at Feb 23, 2007 at 6:27 pm

    On Feb 23, 2007, at 7:04, Tim Bunce wrote:

    I'd also be grateful if you could deal with
    http://bugs.mysql.com/bug.php?id=23974
    And if you are inside column_info fixing things anyway, please have a
    look at
    http://bugs.mysql.com/bug.php?id=26544

    as well. :-)


    - ask

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-dev @
categoriesperl
postedFeb 15, '07 at 5:10p
activeFeb 23, '07 at 6:27p
posts5
users3
websitedbi.perl.org

People

Translate

site design / logo © 2019 Grokbase