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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Fri Aug 19 11:05:45 2022 UTC