Bug #80271 [Com]: prepare json_set throw exception on mysql 8.0.22

From: Date: Sat, 24 Oct 2020 19:07:58 +0000
Subject: Bug #80271 [Com]: prepare json_set throw exception on mysql 8.0.22
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229904@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80271&edit=1 ID: 80271 Comment by: mxmsw at hotmail dot com Reported by: cxlblm at gmail dot com Summary: prepare json_set throw exception on mysql 8.0.22 Status: Open Type: Bug Package: PDO MySQL Operating System: docker/ubuntu PHP Version: 7.4.11 Block user comment: N Private report: N New Comment: Encountering this issue with 'ATTR_EMULATE_PREPARES' set to true will "fix" this. This is not the recommended way (security vulnerabilities). Reading the mysql change log (https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html) under the 'Optimizer Notes' section notes ---- Important Change: A prepared statement is now prepared only once, when executing PREPARE, rather than once each time it is executed. In addition, a statement inside a stored procedure is also now prepared only once, when the stored procedure is first executed. This change enhances performance of such statements, since it avoids the added cost of repeated preparation and rollback of preparation structures, the latter being the source of several bugs. ------ This has also affected prepared statements not regarding JSON specifically. Downgrading from MYSQL 8.0.22 to 8.0.21 resolves this issue Previous Comments: ------------------------------------------------------------------------ [2020-10-22 15:55:06] cxlblm at gmail dot com Description: ------------ $pdo = new \PDO("mysql:host=host.docker.internal;dbname=laravel;charset=utf8mb4", 'root', 'root'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $stmt = $pdo->prepare('update test set setting = json_set(setting, "$.name", ?)'); $r = $stmt->execute(['fefwef']); var_dump($r); Expected result: ---------------- true Actual result: -------------- PHP Fatal error: Uncaught PDOException: SQLSTATE[22032]: <<Unknown error>>: 3141 Invalid JSON text in argument 1 to function cast_as_json: "Invalid value." at position 1. in /opt/project/local/PDO.php:10 Stack trace: #0 /opt/project/local/PDO.php(10): PDOStatement->execute(Array) #1 {main} thrown in /opt/project/local/PDO.php on line 10 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80271&edit=1

« previous php.bugs (#229904) next »