Bug #76665 [NEW]: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle
| From: | cmb@php.net | Date: | Wed, 25 Jul 2018 17:25:00 +0000 |
| Subject: | Bug #76665 [NEW]: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216457@lists.php.net to get a copy of this message | ||
From: cmb
Operating system: *
PHP version: 7.2.8
Package: SQLite related
Bug Type: Bug
Bug description:SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle
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)
--
Edit bug report at https://bugs.php.net/bug.php?id=76665&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76665&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76665&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76665&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76665&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76665&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76665&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76665&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76665&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76665&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76665&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76665&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76665&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76665&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76665&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76665&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76665&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76665&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76665&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76665&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76665&r=mysqlcfg