php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79294 ::columnType() may fail after SQLite3Stmt::reset()
Submitted: 2020-02-21 11:13 UTC Modified: 2020-02-21 11:25 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: SQLite related
PHP Version: 7.3Git-2020-02-21 (Git) OS: *
Private report: No CVE-ID: None
 [2020-02-21 11:13 UTC] cmb@php.net
Description:
------------
As expected, after an SQLite3Result has been fully processed,
SQLite3Result::columnType() returns FALSE.  If the result is
reset by calling SQLite3Result::reset(), ::columnType() yields
the expected results again; however, if the statement is reset by
calling SQLite3Stmt::reset(), ::columnType() keeps returning
FALSE.

In other words, whenever SQLite3Result::fetchArray() succeeds
(i.e. does not return FALSE), I expect SQLite3Result::columType()
to succeed (i.e. not to return FALSE).  However, that does not
necessarily happen after calling SQLite3Stmt::reset().


Test script:
---------------
<?php
$db = new SQLite3(':memory:');
$db->exec("CREATE TABLE foo (bar INT)");
$db->exec("INSERT INTO foo VALUES (1)");

$stmt = $db->prepare("SELECT * FROM foo");
$res = $stmt->execute();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
$stmt->reset();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
$res->reset();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
?>


Expected result:
----------------
bool(true)
int(1)
bool(false)
bool(false)
bool(true)
int(1)
bool(true)
int(1)


Actual result:
--------------
bool(true)
int(1)
bool(false)
bool(false)
bool(true)
bool(false)
bool(true)
int(1)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-21 11:25 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-02-21 12:41 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f133f0024ec801dc9636ee5bf84a93de1300d4b2
Log: Fix #79294: ::columnType() may fail after SQLite3Stmt::reset()
 [2020-02-21 12:41 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-03-26 01:59 UTC] david at grudl dot com
I think this fix caused a problem, and columnType() returns FALSE when it did not do before.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC