Re: DBD::ODBC Destroy bug?

Joel Plotkin <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CAGyjN7QV9YHhZzdxGRK+qL5T9ukiECRK3puj5=GvJNeaBbPL7A@mail.gmail.com>
Hi,

I've attached the sample test8.pl script (smallest one possible that
creates the problem) and a trace file at level 15.

Thanks for any insight,

Joel
dbi_trace.dat (application/octet-stream, 7.5 KB) - not displayed
test8.pl (application/octet-stream, 1.8 KB)
#!/usr/bin/perl

use strict;

select((select(STDOUT), $|=1)[$[]);

# Standard - Devel (AT EJPRESS)
package main;
BEGIN {
    # Standard modules
    use Carp;
    use DBI;
};

my $dbh;

MAIN: {
    print "Calling load_config()\n";

    # open data connection
    my $attr = {};
    my $odbc = "DBI:ODBC:XXXX_odbc";
    my $db_nm="XXXX";
    my $db_user_nm="XXXX";
    my $db_user_passwd="XXXX";

    carp "opening new db connection\n";
    $dbh = DBI->connect($odbc, $db_user_nm, $db_user_passwd, $attr) ||
	carp "Error opening database";
	
    my $trace_filename = "/tmp/dbi_trace.dat";
    $dbh->trace(15, $trace_filename);

    # run QUERY #1
    my $sql = "SELECT p.p_id, p.last_nm
                 FROM Person p 
                WHERE p.p_id = 3";
    my $sth = &do_pexect($sql);
    my $rowcache = $sth->fetchall_arrayref();

    while (my $row = shift @$rowcache) {
        my ($lookup_p_id, $last_nm) = @$row;
    }
    carp "This is a test 1\n";

    # run QUERY #2

    $sql = "SELECT p.p_id, p.last_nm
                 FROM Person p 
                WHERE p.p_id = 3";
    carp "This is a test 2b\n";

    $sth = &do_pexect($sql);
    carp "This is a test 3\n";
    $rowcache = $sth->fetchall_arrayref();
    carp "This is a test 4\n";

    #pop off all rows. destroys $rowcache structure
    while (my $row = shift @$rowcache) {
        my ($lookup_p_id, $last_nm) = @$row;
    }
}

sub do_pexect {

    # input parameters
    my($sql) = @_;

    my $out;    

    $out = $dbh->prepare($sql) || 
	carp "prepare ($sql): ".$dbh->errstr;
    
    $out->execute() ||
	carp "execute ($sql): ".$dbh->errstr;

    return($out);
}

1;

#  a = 123
#  a = 234
#
#  a = {sub {a=4}}   ...not sure how to deallocate outer "a"
#
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.