#33689 [NEW]: query() execute() and fetch() all return false on valid select queries

From: Date: Thu, 14 Jul 2005 01:49:37 +0000
Subject: #33689 [NEW]: query() execute() and fetch() all return false on valid select queries
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81837@lists.php.net to get a copy of this message
From: james at safesearching dot com Operating system: * PHP version: 5CVS-2005-07-14 (dev) PHP Bug Type: PDO related Bug description: query() execute() and fetch() all return false on valid select queries Description: ------------ The code below works fine in 5.1.0b2 for me. In 5.1.0b3 and CVS, however, the code produces an error and segfaults. In b3/CVS the table is created and the value is inserted. $db->query('SELECT * FROM foo') returns false and causes the invalid argument error. $stmt->execute() returns false. Accessing $stmt->getColumnMeta() causes a segfault. Throwing a $stmt->fetch() between execute() and getColumnMeta() produces the correct results. (but query() obviously still returns false) Reproduce code: --------------- header('Content-type: text/plain'); $db = new PDO('mysql:dbname=test;host=localhost','**','**'); $db->query('CREATE TABLE foo ( bar INT NOT NULL );'); $db->query('INSERT INTO foo VALUES(1)'); var_dump($db->query('SELECT * FROM foo')); foreach ($db->query('SELECT * FROM foo') as $row) { print_r($row); } $stmt = $db->prepare('SELECT * FROM foo'); $stmt->execute(); print_r($stmt->getColumnMeta(0)); Expected result: ---------------- object(PDOStatement)#2 (1) { ["queryString"]=> string(17) "SELECT * FROM foo" } Array ( [bar] => 1 [0] => 1 ) Array ( [native_type] => LONG [flags] => Array ( [0] => not_null ) [name] => bar [len] => 11 [precision] => 0 [pdo_type] => 2 ) Actual result: -------------- bool(false) Warning: Invalid argument supplied for foreach() in test.php on line 10 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1024 (LWP 8530)] zif_PDOStatement_getColumnMeta (ht=1, return_value=0x8173554, return_value_ptr=0x0, this_ptr=0x816e6fc, return_value_used=1) at /home/james/php5-200507140030/ext/pdo/pdo_stmt.c:1550 1550 add_assoc_string(return_value, "name", col->name, 1); (gdb) bt #0 zif_PDOStatement_getColumnMeta (ht=1, return_value=0x8173554, return_value_ptr=0x0, this_ptr=0x816e6fc, return_value_used=1) at /home/james/php5-200507140030/ext/pdo/pdo_stmt.c:1550 #1 0x404e2e30 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfffc9d0) at /home/james/php5-200507140030/Zend/zend_vm_execute.h:184 #2 0x404e2a59 in execute (op_array=0x816e534) at /home/james/php5-200507140030/Zend/zend_vm_execute.h:87 #3 0x404c576c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/james/php5-200507140030/Zend/zend.c:1087 #4 0x404956ce in php_execute_script (primary_file=0xbfffed30) at /home/james/php5-200507140030/main/main.c:1672 #5 0x40558eee in apache_php_module_main (r=0x8160f78, display_source_mode=0) at /home/james/php5-200507140030/sapi/apache/sapi_apache.c:53 #6 0x405598e0 in send_php (r=0x8160f78, display_source_mode=0, filename=0x0) at /home/james/php5-200507140030/sapi/apache/mod_php5.c:643 #7 0x4055992e in send_parsed_php (r=0x8160f78) at /home/james/php5-200507140030/sapi/apache/mod_php5.c:658 #8 0x0805480d in ap_invoke_handler () #9 0x08067b0c in process_request_internal () #10 0x08067b83 in ap_process_request () #11 0x0805fc97 in child_main () #12 0x0805fe3a in make_child () #13 0x0805ff7d in startup_children () #14 0x080605d0 in standalone_main () #15 0x08060ed3 in main () #16 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 -- Edit bug report at http://bugs.php.net/?id=33689&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33689&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33689&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33689&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33689&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33689&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33689&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33689&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33689&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33689&r=support Expected behavior: http://bugs.php.net/fix.php?id=33689&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33689&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33689&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33689&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33689&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33689&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33689&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33689&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33689&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33689&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33689&r=mysqlcfg

« previous php.bugs (#81837) next »