Edit report at http://bugs.php.net/bug.php?id=50318&edit=1

 ID:                 50318
 Updated by:         u...@php.net
 Reported by:        yury at nix dot co dot il
 Summary:            multiple statments result exception
-Status:             Assigned
+Status:             Bogus
 Type:               Bug
 Package:            PDO related
 Operating System:   FreeBSD 7.2-STABLE
 PHP Version:        5.2.11
 Assigned To:        mysql
 Block user comment: N

 New Comment:

PHP 5.2 is EOL'd. Use PHP 5.3



http://www.php.net/archive/2010.php#id2010-07-22-1



 The PHP development team would like to announce the immediate
availability of PHP 5.2.14. This release focuses on improving the
stability of the PHP 5.2.x branch with over 60 bug fixes, some of which
are security related.



This release marks the end of the active support for PHP 5.2. *Following
this release the PHP 5.2 series will receive no further active bug
maintenance.* Security fixes for PHP 5.2 might be published on a case by
cases basis. All users of PHP 5.2 are encouraged to upgrade to PHP 5.3


Previous Comments:
------------------------------------------------------------------------
[2009-11-28 12:18:29] yury at nix dot co dot il

I have just checked out the code of mysql_driver.c in 5_3,

it seems that the issue handled there, however I do not understand why
to

mysql_store_result() and then mysql_free_result(), it seems to work with
my solution as well... ( checked only on 5.2.11 )

------------------------------------------------------------------------
[2009-11-28 12:08:55] yury at nix dot co dot il

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 this bug report at http://bugs.php.net/bug.php?id=50318&edit=1

Reply via email to