From:             yury at nix dot co dot il
Operating system: FreeBSD 7.2-STABLE
PHP version:      5.2.11
PHP Bug Type:     PDO related
Bug description:  multiple statments result exception

Description:
------------
When using multiple statments in a single $pdo->execute(),
php throws an exception, however the staments bieng executed anyway.
( example: http://pastebin.com/f6aec645c )

I think the mysql server expects the resultset to be advanced even if it's
empty, as shown in the c-api example here:
http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html

I think the follwing will resolve the issue
( diff against svn 5_2 )
*** mysql_driver.c      Sat Nov 28 13:13:07 2009
--- /home/yury/php-5.2.11/ext/pdo_mysql/mysql_driver.c  Fri Nov 27
13:55:46 2009
***************
*** 252,261 ****
--- 252,262 ----
                my_ulonglong c = mysql_affected_rows(H->server);
                if (c == (my_ulonglong) -1) {
                        pdo_mysql_error(dbh);
                        return (H->einfo.errcode ? -1 : 0);
                } else {
+                       while ( 0 == mysql_next_result( H->server ) );
                        return c;
                }
        }
  }


Reproduce code:
---------------
http://pastebin.com/f6aec645c

Expected result:
----------------
throw exception and not commit
-or-
commit and not throw exception

Actual result:
--------------
The follwing exception thrown:

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other
unbuffered queries are active.  Consider using PDOStatement::fetchAll(). 
Alternatively, if your code is only ever going to run against mysql, you
may enable query buffering by setting the
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

But the data IS commited to the database.

-- 
Edit bug report at http://bugs.php.net/?id=50318&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50318&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50318&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50318&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50318&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50318&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50318&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50318&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50318&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50318&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50318&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50318&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50318&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50318&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50318&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50318&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50318&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50318&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50318&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50318&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50318&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50318&r=mysqlcfg

Reply via email to