Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 192047 - >=dev-lang/php-5.2.4_pre200708051230-r2 PDO-MySQL invalid return code for execute()
Summary: >=dev-lang/php-5.2.4_pre200708051230-r2 PDO-MySQL invalid return code for exe...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: AMD64 Linux
: High major (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-10 21:03 UTC by Christian Mandery
Modified: 2007-09-12 16:20 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Mandery 2007-09-10 21:03:31 UTC
I am experiencing trouble with PHP using PDO with the MySQL driver. If using the same PDO statement multiple times, all calls but the first to execute() return FALSE, yet fetchAll() still returns the correct results (which may be cached from the first successful call). errorInfo() does not show any usable information.

The problem happens with both dev-lang/php-5.2.4_pre200708051230-r2 (Gentoo x86_64 stable) and dev-lang/php-5.2.4 (Gentoo ~x86_64 and latest version in Portage Tree).

It's not a problem with PHP or PDO because it does not occur when using another database driver (i.e. SQLite). It is also not a problem with MySQL because execution the command multiple times per hand works fine. I also found an unbroken PHP 5.1 version on a Red Hat system that worked fine with the same database server.

Some investigations using a network sniffer have shown that all three requests are properly sent to the server and correctly answered, so it should be a problem in the part that parses the answer from the MySQL server.

This is not a Gentoo-only problem. It happens with Ubuntu at my workplace, too. I'm posting it here because I once read that you want all Gentoo-related issues posted here to investigate and deliver to upstream dev team.

If you do not feel responsible, please tell me and I will report upstream.

Test case to demonstrate the problem is below.

Reproducible: Always

Steps to Reproduce:
1. Setup MySQL server, database, database user and grant database access to the user.
2. Create a table in the database and optionally fill it with some data.
3. Run my posted sniplet.

Script:

<?php

$db = new PDO( "mysql:host=localhost;dbname=pem", "pem", "pem" );
// $db = new PDO( "sqlite:database" );

$q = $db->prepare( "SELECT * FROM test;" );

for ( $i = 1; $i <= 3; ++$i )
{
        if ( $q->execute() )
                echo "success in $i\n";
        else
        {
                echo "error in $i:\n";
                print_r( $q->errorInfo() );
                echo "\n";
        }

        print_r( $q->fetchAll() );
        echo "\n\n\n";

        $q->closeCursor();
}

?>
Actual Results:  
success in 1
Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



error in 2:
Array
(
    [0] => 00000
)

Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



error in 3:
Array
(
    [0] => 00000
)

Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)

Expected Results:  
success in 1
Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



success in 2
Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



success in 3
Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)

Emerge Info:

Portage 2.1.2.12 (default-linux/amd64/2006.1/desktop, gcc-4.1.2, glibc-2.5-r4, 2.6.22-gentoo-r2 x86_64)
=================================================================
System uname: 2.6.22-gentoo-r2 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
Gentoo Base System release 1.12.9
Timestamp of tree: Mon, 10 Sep 2007 20:00:01 +0000
app-shells/bash:     3.2_p17
dev-java/java-config: 1.3.7, 2.0.33-r1
dev-lang/python:     2.4.4-r4
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 1.12.9-r2
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.21
ACCEPT_KEYWORDS="amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=athlon64"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -march=athlon64"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.intergenia.de http://gentoo.tiscali.nl/ http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/ http://pandemonium.tiscali.de/pub/gentoo/"
LINGUAS="de"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/armagetron /usr/portage/local/local"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X alsa amd64 apache2 bash-completion berkdb bitmap-fonts bzip2 cairo cdr cli cracklib crypt ctype cups dbus dri dv dvd dvdr eds emboss encode esd exif fam ffmpeg firefox flac fortran fuse gdbm gif gpm gstreamer gtk2 hal iconv imlib insecure-savers isdnlog jabber java jpeg kde kdeenablefinal mad midi mikmod mng mozdevelop mp3 mpeg mudflap musicbrainz mysql ncurses nls nptl nptlonly ogg oggvorbis opengl openmp oscar pam pcre pdf perl php png ppds pppd python qt qt3 qt3support qt4 quicktime readline reflection samba sdl session spell spl sql ssl tcpd tetex tiff truetype truetype-fonts type1-fonts unicode visualization vorbis xine xinerama xml xorg xscreensaver xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de" USERLAND="GNU" VIDEO_CARDS="nvidia fbdev vesa"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-09-10 21:07:07 UTC
(In reply to comment #0)
> This is not a Gentoo-only problem. It happens with Ubuntu at my workplace, too.
> I'm posting it here because I once read that you want all Gentoo-related issues
> posted here to investigate and deliver to upstream dev team.
> 
> If you do not feel responsible, please tell me and I will report upstream.

Yeah, we indeed do not feel responsible for something that's reproducible on Ubuntu. :) Please report upstream and stick the URL here for tracking. Thanks. 
Comment 2 Christian Mandery 2007-09-12 16:20:55 UTC
The bug is reported upstream here:
http://bugs.php.net/bug.php?id=42620

But until to now, no PHP developer has accepted the bug. If someone is able to reproduce it, please vote for it in the PHP bugtracker!