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

From: Date: Wed, 15 Sep 2021 10:06:53 +0000
Subject: Bug #78227 [Opn]: Prepared statements ignore RENAME COLUMN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236612@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 Updated by: cmb@php.net Reported by: cmb@php.net Summary: Prepared statements ignore RENAME COLUMN Status: Open Type: Bug -Package: PDO SQLite +Package: PDO Core Operating System: * PHP Version: 7.2.19 Block user comment: N Private report: N New Comment: This is not particular to PDO_SQLite, but rather a general PDO issue; at least PDO_MySQL exhibits the same behavior. Previous Comments: ------------------------------------------------------------------------ [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 (#236612) next »