php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76665 SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle
Submitted: 2018-07-25 17:25 UTC Modified: 2018-07-26 12:26 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: SQLite related
PHP Version: 7.2.8 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2018-07-25 17:25 UTC] cmb@php.net
Description:
------------
If SQLite3Stmt::bindValue() is called with the explicit $type
SQLITE3_FLOAT, and a $value which is not a float, garbage is
written to the database in the best case.

For some reason the respective conversion to double[1] is
commented out since ext/sqlite3 has been moved to php-src (and
actually has been commented out at least since PECL/sqlite3
version 0.3).

[1] <https://github.com/php/php-src/blob/php-7.2.8/ext/sqlite3/sqlite3.c#L1598>


Test script:
---------------
<?php
$db = new SQLite3('memory');
$db->exec("CREATE TABLE foo (bar REAL)");
$stmt = $db->prepare("INSERT INTO foo VALUES (:bar)");
$stmt->bindValue(':bar', 17, SQLITE3_FLOAT);
$stmt->execute();
var_dump($db->querySingle("SELECT bar FROM foo LIMIT 1"));


Expected result:
----------------
float(17)

Actual result:
--------------
float(8.3991159793012E-323)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-26 09:53 UTC] ab@php.net
You got it, Christoph. Looks like just uncommenting it and adding test should be fine for 7.1.

thanks.
 [2018-07-26 12:25 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed7e3bc70a89a0838a5b7e44928cbd65aec50bb1
Log: Fix #76665: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle
 [2018-07-26 12:25 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2018-07-26 12:26 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2018-07-26 12:26 UTC] cmb@php.net
Thanks, Anatol!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC