Bug #79664 [Ver->Csd]: PDOStatement::getColumnMeta fails on empty result set
| From: | cmb@php.net | Date: | Tue, 02 Jun 2020 08:48:51 +0000 |
| Subject: | Bug #79664 [Ver->Csd]: PDOStatement::getColumnMeta fails on empty result set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227271@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79664&edit=1
ID: 79664
Updated by: cmb@php.net
Reported by: mic at kwayisi dot org
Summary: PDOStatement::getColumnMeta fails on empty result
set
-Status: Verified
+Status: Closed
Type: Bug
Package: PDO SQLite
Operating System: Windows
PHP Version: 7.4.6
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=63bd8f38f4b7e8ffbcbd0ea607e21041ebba2455
Log: Fix #79664: PDOStatement::getColumnMeta fails on empty result set
Previous Comments:
------------------------------------------------------------------------
[2020-06-02 07:55:41] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #79664: PDOStatement::getColumnMeta fails on empty result set
On GitHub: https://github.com/php/php-src/pull/5654
Patch: https://github.com/php/php-src/pull/5654.patch
------------------------------------------------------------------------
[2020-06-02 00:23:44] mic at kwayisi dot org
Description:
------------
PDOStatement::getColumnMeta throws a "column index out of range" error if the result set
is empty.
After calling PDOStatement::columnCount to confirm that there are columns in the result set,
subsequent call to PDOStatement::getColumnMeta shouldn't produce an error even if its
implementation does not enable it to fetch the requested column (because there are no rows).
Test script:
---------------
$pdo = new PDO('sqlite:', null, null, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$stmt = $pdo->query('select 1 where 0');
if ($stmt->columnCount())
var_dump($stmt->getColumnMeta(0));
Expected result:
----------------
array(6) {
["native_type"]=>
string(7) "integer"
["flags"]=>
array(0) {
}
["name"]=>
string(1) "1"
["len"]=>
int(4294967295)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
Actual result:
--------------
ERROR: SQLSTATE[HY000]: General error: 25 column index out of range
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79664&edit=1