----------------------- Original Message -----------------------
From:    "[EMAIL PROTECTED] (via RT)" <[EMAIL PROTECTED]>
To:      [EMAIL PROTECTED]
Date:    28 Aug 2002 08:15:59 -0000
Subject: [perl #16805] Seemingly impossible to connect to a mysql db using the DBI 
package, from within a perl thread (ithread)
----

# New Ticket Created by  [EMAIL PROTECTED] 
# Please include the string:  [perl #16805]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16805 >



This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.26 running under perl 5.008.


-----------------------------------------------------------------
[Please enter your report here]


Based on the execution of the small script further down the page, I think i might have 
found a bug..
When I try to connect to a mysql db using the DBI package, from a thread, rather then 
attempting from the main thread, I get this error:
thread failed to start: Undefined subroutine &Carp::shortmess_heavy called at 
/usr/local/lib/perl5/5.8.0/Carp.pm line 182.

I'm not really sure, but i suspect it to be caused by the new implementation of 
threads in perl 5.8.0 (ithreads), and also i found this section on perldoc for the 
DBI-package:

Threads and Thread Safety
Perl versions 5.004_50 and later include optional experimental support for
multiple threads on many platforms. If the DBI is built using a Perl that
has threads enabled then it will use a per-driver mutex to ensure that only
one thread is with a driver at any one time. Please note that support for
threads in Perl is still experimental and is known to have some significant
problems. It's use is not recommended.

BUT! That way that I understand this, it only means that two threads can't use DBI at 
the same time, and NOT that threads in general can't access DBI.. What do you think?



This is the connect line:
$dbremote = DBI->connect("DBI:mysql:DBNAME;host=127.0.0.1", "USER", "PASS", { 
AutoCommit => 1 });  

This will work, when executed from the main thread, but not when attempted from a 
program initiated thread


use DBI;
use threads;

my $mythread;

my $dblocal;
$dblocal = DBI->connect("DBI:mysql:DBNAME;host=127.0.0.1", "USER", "PASS", { 
AutoCommit => 1 });
print "If you see this, it opened the connection to dblocal..\n";



$mythread = threads->create( \&start_mythread );

#Wait for thread to join..
$mythread->join();

sub start_mythread
{
        my $dbthread;
        $dbthread = DBI->connect("DBI:mysql:DBNAME;host=127.0.0.1", "USER", "PASS", { 
AutoCommit => 1 });
        print "If you see this, it opened the connection to dbthread..\n";
        return;
}






[Please do not change anything below this line]
-----------------------------------------------------------------

---
This perlbug was built using Perl 5.00503 - Sun Mar  5 13:39:27 SAST 2000
It is being executed now by  Perl 5.008 - Thu Aug 22 10:55:24 CEST 2002.

Site configuration information for perl 5.008:

Configured by testbruger at Thu Aug 22 10:55:24 CEST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=freebsd, osvers=4.6.1-rc2, archname=i386-freebsd-thread-multi
    uname='freebsd qostest.ip.tele.dk 4.6.1-rc2 freebsd 4.6.1-rc2 #0: thu jul 18 
08:24:45 gmt 2002 [EMAIL PROTECTED]:usrsrcsyscompilegeneric i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.0/mach 
-Dprivlib=/usr/local/lib/perl5/5.8.0 -Dman3dir=/usr/local/lib/perl5/5.8.0/man/man3 
-Dsitearch=/usr/local/lib/perl5/site_perl/5.8.0/mach 
-Dsitelib=/usr/local/lib/perl5/site_perl/5.8.0 -Ui_malloc -Ui_iconv 
-Uinstallusrbinperl -Duseithreads -Dusethreads 
-Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -Ui_gdbm -Dusemymalloc=n'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" 
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include',
    optimize='-O -pipe ',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSETMASK 
-DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3 20010315 (release) [FreeBSD]', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lc_r -lcrypt -lutil
    perllibs=-lm -lc_r -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.008:
    /usr/local/lib/perl5/site_perl/5.8.0/mach
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.8.0/BSDPAN
    /usr/local/lib/perl5/5.8.0/mach
    /usr/local/lib/perl5/5.8.0
    .

---
Environment for perl 5.008:
    HOME=/home/ssch
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/home/ssch/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


--------------------- Original Message Ends --------------------


Reply via email to