Skip to content

mariadb_use_result is broken #173

@rovo89

Description

@rovo89

The following example displays Active: no and has no results:

my $dbh = DBI->connect(...);
my $sth = $dbh->prepare('SELECT id FROM sometable');
$sth->{'mariadb_use_result'} = 1;
$sth->execute();
print 'Active: ', $sth->{'Active'} ? 'yes' : 'no', "\n";
while (my $id = $sth->fetchrow_array()) {
  print $id, "\n";
}
$dbh->disconnect()

It works fine without mariadb_use_result. It works fine with DBD::mysql, both with and without mysql_use_result.

It might be related to 4f47a06. The execute() call returns 0E0 rows, but with mariadb_use_results this doesn't mean that there are no results.

Trace:

    DBI::db=HASH(0x13cffc0) trace level set to 0x0/9 (DBI @ 0x0/0) in DBI 1.642-ithread (pid 7788)
    -> prepare for DBD::MariaDB::db (DBI::db=HASH(0x13cff30)~0x13cffc0 'SELECT id FROM sometable') thr#9fb260
    >> func        DISPATCH (DBI::db=HASH(0x13cffc0) rc1/2 @2 g2 ima6 pid#7788) at /perlpath/DBD/MariaDB.pm line 180 via  at test.pl line 26
1   -> _async_check for DBD::MariaDB::db (DBI::db=HASH(0x13cffc0)~INNER) thr#9fb260
1   <- _async_check= ( 1 ) [1 items] at /perlpath/DBD/MariaDB.pm line 180 via  at test.pl line 26
    New 'DBI::st' (for DBD::MariaDB::st, parent=DBI::db=HASH(0x13cffc0), id=undef)
    dbih_setup_handle(DBI::st=HASH(0x13cfa08)=>DBI::st=HASH(0xb00bc0), DBD::MariaDB::st, 11fb088, Null!)
    dbih_make_com(DBI::db=HASH(0x13cffc0), feb8f0, DBD::MariaDB::st, 464, 0) thr#9fb260
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), Err, DBI::db=HASH(0x13cffc0)) SCALAR(0x11faf98) (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), State, DBI::db=HASH(0x13cffc0)) SCALAR(0x11faff8) (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), Errstr, DBI::db=HASH(0x13cffc0)) SCALAR(0x11fafc8) (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), TraceLevel, DBI::db=HASH(0x13cffc0)) 9 (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), FetchHashKeyName, DBI::db=HASH(0x13cffc0)) 'NAME_uc' (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), HandleSetErr, DBI::db=HASH(0x13cffc0)) undef (not defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), HandleError, DBI::db=HASH(0x13cffc0)) CODE(0x137f710) (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), ReadOnly, DBI::db=HASH(0x13cffc0)) 1 (already defined)
    dbih_setup_attrib(DBI::st=HASH(0xb00bc0), Profile, DBI::db=HASH(0x13cffc0)) undef (not defined)
        -> mariadb_st_prepare_sv MYSQL_VERSION_ID 100505, SQL statement: SELECT id FROM sometable
        >- mariadb_st_free_result_sets
        <- mariadb_st_free_result_sets RC -1
        <- mariadb_st_free_result_sets
>count_params statement SELECT id FROM sometable
        <- mariadb_st_prepare_sv
    <- prepare= ( DBI::st=HASH(0x13cfa08) ) [1 items] at test.pl line 26
    -> STORE for DBD::MariaDB::st (DBI::st=HASH(0xb00bc0)~INNER 'mariadb_use_result' 1 (magic-r:p)) thr#9fb260
                -> mariadb_st_STORE_attrib for 11fb0a0, key mariadb_use_result
                <- mariadb_st_STORE_attrib for 11fb0a0, result 1
    <- STORE= ( 1 ) [1 items] at test.pl line 28
    -> execute for DBD::MariaDB::st (DBI::st=HASH(0x13cfa08)~0xb00bc0) thr#9fb260
 -> mariadb_st_execute_iv for 11fb0a0
        >- mariadb_st_free_result_sets
        <- mariadb_st_free_result_sets RC -1
        <- mariadb_st_free_result_sets
mariadb_st_internal_execute MYSQL_VERSION_ID 100505
>parse_params statement SELECT id FROM sometable
 <- mariadb_st_execute_iv returning imp_sth->row_num 0
    <- execute= ( '0E0' ) [1 items] at test.pl line 29
    -> FETCH for DBD::MariaDB::st (DBI::st=HASH(0xb00bc0)~INNER 'Active') thr#9fb260
    -> mariadb_st_FETCH_attrib for 11fb0a0, key Active
    .. FETCH DBI::st=HASH(0xb00bc0) 'Active' = ''
    <- FETCH= ( '' ) [1 items] at test.pl line 30
Active: no
    -> fetchrow_array for DBD::MariaDB::st (DBI::st=HASH(0x13cfa08)~0xb00bc0) thr#9fb260
        -> mariadb_st_fetch
    <- fetchrow_array= ( undef ) [1 items] at test.pl line 31
    -> disconnect for DBD::MariaDB::db (DBI::db=HASH(0x13cff30)~0x13cffc0) thr#9fb260
        mariadb_db_close_mysql: imp_dbh=feb8f0 pmysql=16ba410
    >> FETCH       DISPATCH (DBI::db=HASH(0x13cffc0) rc2/3 @2 g2 ima404 pid#7788) at test.pl line 34
1   <> FETCH= ( [ DBI::st=HASH(0x13cfa08) ] ) [1 items] ('ChildHandles' from cache) at test.pl line 34
    <- disconnect= ( 1 ) [1 items] at test.pl line 34
    -> DESTROY for DBD::MariaDB::st (DBI::st=HASH(0xb00bc0)~INNER) thr#9fb260

--> mariadb_st_finish

<-- mariadb_st_finish
    <- DESTROY= ( undef ) [1 items] at test.pl line 34 via  at test.pl line 34
    -> DESTROY for DBD::MariaDB::db (DBI::db=HASH(0x13cffc0)~INNER) thr#9fb260
    <- DESTROY= ( undef ) [1 items]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions