New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDC-453: PDOException "SQLSTATE[HY000]: General error: 2014" when trying to prepare statement while other unbuffered queries are still active #4955
Comments
Comment created by markus.woessner: I wasn't able to run tests with applied patch yet. It's late and I will try to do it tomorrow |
Comment created by romanb: Not sure since our test suite runs fine against MySQL and there are plenty functional tests. -Moreover, there have been bugs in PDO drivers frequently.- OK, your versions seem quite up-to-date. We certainly need a test case that fails for everyone before doing anything. |
Comment created by romanb: @benjamin: Thats quite possible even though I would be surprised if we have not a single test yet that causes eager loading. If this is the case it should be easy to reproduce. Just create a bidirectional one-one and then query only for the inverse side. Since the association from inverse to owning side in a to-one association can not be lazy (because it doesnt have the FK so it cant use proxying) this error should be triggered. |
Comment created by romanb: My first tries to reproduce this have been unsuccessful. Mind you I'm using the mysqlnd client library, not libmysql, dont know whether that makes a difference here. |
Comment created by markus.woessner: I tried to reproduce this failure today and wasn't able. Apparently I missed something yesterday. I'm sorry to have troubled you. Yet I keep wondering what was the mistake. Yesterday MySQL log looked as follows for mentioned query when I set "PDO::MYSQL_ATTR_USE_BUFFERED_QUERY" to "true":
Why would Doctrine issue another "users" SELECT within hydration loop? Anyway, I recommend closing this issue! |
Comment created by romanb: OK. As soon as you encounter this problem again and you have a reproducable test case, feel free to reopen this issue. Thanks for your help. |
Comment created by romanb: User reported that this issue reoccured, however, we're still waiting for someone who can provide a reproducable unit test. I could not get the error to occur. |
Comment created by romanb: The reason I don't get that error is because pdo_mysql defaults to using buffered queries, and that since 2006 it seems ( http://svn.php.net/viewvc?view=revision&revision=224291 ). Maybe the distribution you use has a customized/patched PHP/PDO version that changes this default? |
Comment created by markus.woessner: I use PDO_MYSQL 1.0.2. Sorry for delayed response. Didn't realize that "pecl list" will reveal version information. |
Comment created by romanb: I think all we can do here is to document that Doctrine requires buffered queries (which is the default in PDO normally). |
Comment created by @beberlei: Configuration error, closing. |
Issue was closed with resolution "Invalid" |
Imported 1 attachments from Jira into https://gist.github.com/9e25dd073dddbe09639a |
Jira issue originally created by user markus.woessner:
Doing a fetch join query to Entity "User" with bidirectional one-to-one association to Entity "Address", where User is owning side produces error.
Query: "SELECT u,a FROM Entities\User u JOIN u.address a"
Fatal error: Uncaught exception 'PDOException' with message '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.' in /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/DBAL/Connection.php:549
Stack trace:
#0 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/DBAL/Connection.php(549): PDO->prepare('SELECT users.id...')
#1 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(438): Doctrine\DBAL\Connection->prepare('SELECT users.id...')
#2 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Mapping/OneToOneMapping.php(253): Doctrine\ORM\Persisters\StandardEntityPersister->load(Array, NULL, Object(Doctrine\ORM\Mapping\OneToOneMapping))
#3 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/UnitOfWork.php(1811): Doctrine\ORM\Mapping\OneToOneMapping->load(Object(Entities\Address), NULL, Object(Doctrine\ORM\EntityManager))
#4 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php(179): Doctrine\ORM\UnitOfWork->createEntity('Entities\Addres...', Array, Array)
#5 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php(342): Doctrine\ORM\Internal\Hydration\ObjectHydrator->_getEntity(Array, 'a')
#6 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php(112): Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateRow(Array, Array, Array)
#7 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(102): Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateAll()
#8 /usr/lib/php5.3/lib/php/Doctrine_2_checkout/lib/Doctrine/ORM/AbstractQuery.php(520): Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(Object(Doctrine\DBAL\Driver\PDOStatement), Object(Doctrine\ORM\Query\ResultSetMapping), Array)
#9 /var/www/adition/doctrine2_sandbox/debug/pdo2014.php(10): Doctrine\ORM\AbstractQuery->execute()
#10 {main}
While second advice of above PDO exception message seems to be limited to MySQL environments following patch might do it:
With this patch applied to my checkout I was able to retrieve correct User entity and Address entity in NON-proxy mode.
The text was updated successfully, but these errors were encountered: