Bug #78227 [PATCH]: Prepared statements ignore RENAME COLUMN

From: Date: Wed, 15 Sep 2021 10:07:25 +0000
Subject: Bug #78227 [PATCH]: Prepared statements ignore RENAME COLUMN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236613@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78227&edit=1 ID: 78227 Patch added by: cmb@php.net Reported by: cmb@php.net Summary: Prepared statements ignore RENAME COLUMN Status: Open Type: Bug Package: PDO Core Operating System: * PHP Version: 7.2.19 Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix bug #78227 Prepared statements ignore RENAME COLUMN On GitHub: https://github.com/php/php-src/pull/7495 Patch: https://github.com/php/php-src/pull/7495.patch Previous Comments: ------------------------------------------------------------------------ [2021-09-15 10:06:53] cmb@php.net This is not particular to PDO_SQLite, but rather a general PDO issue; at least PDO_MySQL exhibits the same behavior. ------------------------------------------------------------------------ [2019-06-28 10:32:03] cmb@php.net Description: ------------ As of SQLite 3.25.0, ALTER TABLE RENAME COLUMN queries are supported. However, already prepared statements ignore such changes, and report the old column names when fetching. ext/sqlite3 behaves like expected. Test script: --------------- <?php $db = new PDO('sqlite::memory:'); $db->exec("CREATE TABLE user (id INTEGER PRIMARY KEY NOT NULL, foo VARCHAR(255) NOT NULL)"); $db->exec("INSERT INTO user (id, foo) VALUES (10, 'test')"); $stmt = $db->prepare("SELECT * FROM user WHERE id = :id"); $stmt->execute(['id' => 10]); print_r($stmt->fetch(PDO::FETCH_ASSOC)); $db->exec("ALTER TABLE user RENAME COLUMN foo TO bar"); $res = $stmt->execute(['id' => 10]); print_r($stmt->fetch(PDO::FETCH_ASSOC)); Expected result: ---------------- Array ( [id] => 10 [foo] => test ) Array ( [id] => 10 [bar] => test ) Actual result: -------------- Array ( [id] => 10 [foo] => test ) Array ( [id] => 10 [foo] => test ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78227&edit=1

« previous php.bugs (#236613) next »