We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

SQL Error when executing custom queries on add-on install in EE 3.2

Developer Preview

Gustavs Gutmanis's avatar
Gustavs Gutmanis
2 posts
9 years ago
Gustavs Gutmanis's avatar Gustavs Gutmanis

Hi, there seems to be an issue with EE 3.2 executing custom queries when installing add-ons.

I have made a bare-bones add-on which does nothing except execute a simple, safe query when the install() method is called in upd.sample.php class.

ee()->db->query("DROP FUNCTION IF EXISTS SOMEFUNCTION;");

Since I can’t upload a .zip or .php file here, I will instead e-mail the add-on to you on [email protected].

The error it dies with is as follows:

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.:
DROP FUNCTION IF EXISTS SOMEFUNCTION;

The error message is quite descriptive and I imagine that some data is fetched before the install method gets called and it doesn’t tell MYSQL to close the cursor just yet, and is iterating through the fetched results one-by-one, thus preventing any other queries from being executed while the cursor hasn’t been released yet.

I tried to pinpoint the cause of this, but failed to find the problem. Could you please take a look at this?

EE 3.1 doesn’t have this problem.

Our Solspace Super Search add-on has been using this very same approach to drop and then create a MYSQL function successfully for years, never once has this been a problem before.

Thank you very much.

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
9 years ago
Pascal Kriete's avatar Pascal Kriete

Interesting. We disabled PDO’s EMULATE_PREPARES in this build. It looks like that was handling the buffering intelligently. For a quick fix, we’ll turn it back on for this release.

Thanks for catching that!

       
kmartens's avatar
kmartens
155 posts
9 years ago
kmartens's avatar kmartens

Thanks Pascal 😊

       
Gustavs Gutmanis's avatar
Gustavs Gutmanis
2 posts
9 years ago
Gustavs Gutmanis's avatar Gustavs Gutmanis

Thank you!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.