php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78227 Prepared statements ignore RENAME COLUMN
Submitted: 2019-06-28 10:32 UTC Modified: 2021-09-15 10:06 UTC
From: cmb@php.net Assigned:
Status: Open Package: PDO Core
PHP Version: 7.2.19 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-06-28 10:32 UTC] 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
)

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-15 10:06 UTC] cmb@php.net
-Package: PDO SQLite +Package: PDO Core
 [2021-09-15 10:06 UTC] cmb@php.net
This is not particular to PDO_SQLite, but rather a general PDO
issue; at least PDO_MySQL exhibits the same behavior.
 [2021-09-15 10:07 UTC] cmb@php.net
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
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 18:03:40 2021 UTC