Bug #80827 [Com]: SHOW WARNINGS fails when using native prepared statements

From: Date: Fri, 05 Mar 2021 12:32:19 +0000
Subject: Bug #80827 [Com]: SHOW WARNINGS fails when using native prepared statements
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232573@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80827&edit=1 ID: 80827 Comment by: dharman@php.net Reported by: john@php.net Summary: SHOW WARNINGS fails when using native prepared statements Status: Feedback Type: Bug Package: PDO MySQL Operating System: Ubuntu Focal PHP Version: 7.4.3 Assigned To: john Block user comment: N Private report: N New Comment: I can't reproduce this with MariaDB but with MySQL I can confirm that Nikita's fix solves the problem. https://phpize.online/?phpses=e1cac05bd0bc9086f6700ec82e7eaedb&sqlses=63c46b19554d6ac448aaeca4ef1a06e3&php_version=php8&sql_version=mysql80 However, I don't think I should be seeing any warnings. The results I get with MySQL are incorrect! https://phpize.online/?phpses=042e260408b41e85450cc702c2802aee&sqlses=63c46b19554d6ac448aaeca4ef1a06e3&php_version=php8&sql_version=mysql80 Nikita, are we sure that fallback to emulated prepares is the right solution here? Previous Comments: ------------------------------------------------------------------------ [2021-03-05 08:35:27] nikic@php.net I believe that https://github.com/php/php-src/commit/f3d5877845358d011174cf87283b456cee6f7f53 already fixed this issue a while ago, you're just using a very old PHP 7.4 version. ------------------------------------------------------------------------ [2021-03-03 23:13:59] john@php.net Description: ------------ There is a bug in the pdo_mysql driver with PDO::ATTR_EMULATE_PREPARES set to false that prevents a query such as SHOW WARNINGS from working properly. I'm intending on writing a patch to fix this issue once I dig into it further, but I wanted to get the bug report live in case anyone else runs into this issue in the wild (e.g. Laravel disables emulated prepares for their DB implementation on top of PDO). Test script: --------------- <?php $db = new \PDO(...$params); $db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); $result = $db->query('SHOW WARNINGS')->fetchAll(); // causes a 2014 client error $db = new \PDO(...$params); $db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); $result = $db->query('SHOW WARNINGS')->fetchAll(); // works ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80827&edit=1

« previous php.bugs (#232573) next »