Skip to content

Commit 4611350

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79664: PDOStatement::getColumnMeta fails on empty result set
2 parents b26ad33 + 63bd8f3 commit 4611350

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #79595 (zend_init_fpu() alters FPU precision). (cmb, Nikita)
77
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
88

9+
- PDO SQLite:
10+
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).
11+
(cmb)
12+
913
- phpdbg:
1014
. Fixed bug #73926 (phpdbg will not accept input on restart execution). (cmb)
1115
. Fixed several mostly Windows related phpdbg bugs. (cmb)

ext/pdo_sqlite/sqlite_statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret
341341
if (!S->stmt) {
342342
return FAILURE;
343343
}
344-
if(colno >= sqlite3_data_count(S->stmt)) {
344+
if(colno >= sqlite3_column_count(S->stmt)) {
345345
/* error invalid column */
346346
pdo_sqlite_error_stmt(stmt);
347347
return FAILURE;

ext/pdo_sqlite/tests/bug79664.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Bug #79664 (PDOStatement::getColumnMeta fails on empty result set)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
6+
?>
7+
--FILE--
8+
<?php
9+
$pdo = new PDO('sqlite::memory:', null, null, [
10+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
11+
]);
12+
$stmt = $pdo->query('select 1 where 0');
13+
if ($stmt->columnCount()) {
14+
var_dump($stmt->getColumnMeta(0));
15+
}
16+
?>
17+
--EXPECT--
18+
array(6) {
19+
["native_type"]=>
20+
string(4) "null"
21+
["flags"]=>
22+
array(0) {
23+
}
24+
["name"]=>
25+
string(1) "1"
26+
["len"]=>
27+
int(4294967295)
28+
["precision"]=>
29+
int(0)
30+
["pdo_type"]=>
31+
int(2)
32+
}

0 commit comments

Comments
 (0)