php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39700 NUMERIC error when result precision are 7,8 or 12-14
Submitted: 2006-12-01 11:00 UTC Modified: 2007-11-08 19:46 UTC
Votes:34
Avg. Score:4.8 ± 0.4
Reproduced:34 of 34 (100.0%)
Same Version:9 (26.5%)
Same OS:24 (70.6%)
From: ilpochta at gmail dot com Assigned:
Status: Closed Package: InterBase related
PHP Version: 5.2.0 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ilpochta at gmail dot com
New email:
PHP Version: OS:

 

 [2006-12-01 11:00 UTC] ilpochta at gmail dot com
Description:
------------
When SQL query returns numbers with precision 7, 8 or 12-14 (digits after period) ibase_fetch_*() returns these numbers divided by 10. 
When precision are 18 - returns "29".
I was tested this on PHP 5.2, 5.1.6; on WinXP and RedHat Linux; on Firebird 1.5 and 2.
Maybe, this is some bug with #39056 ?

Reproduce code:
---------------
//generate SQL
$nums=array();
for($i=0;$i<=18;$i++) {
	$nums[]=sprintf('1.%s AS prc_%d', str_repeat('0',$i), $i);
}
$stmt='SELECT '. implode(', ',$nums). ' FROM RDB$DATABASE';

//query
$dbh = ibase_connect('localhost:c:/main.gdb', 'SYSDBA', 'masterkey');

$sth = ibase_query($dbh, $stmt) or die(ibase_errmsg());
$res=ibase_fetch_assoc($sth);
   
print_r($res);


Expected result:
----------------
PHP 4 outputs:
Array
(
    [PRC_0] => 1
    [PRC_1] => 1.0
    [PRC_2] => 1.00
    [PRC_3] => 1.000
    [PRC_4] => 1.0000
    [PRC_5] => 1.00000
    [PRC_6] => 1.000000
    [PRC_7] => 1.0000000
    [PRC_8] => 1.00000000
    [PRC_9] => 1.000000000
    [PRC_10] => 1.0000000000
    [PRC_11] => 1.00000000000
    [PRC_12] => 1.000000000000
    [PRC_13] => 1.0000000000000
    [PRC_14] => 1.00000000000000
    [PRC_15] => 1.000000000000000
    [PRC_16] => 1.0000000000000000
    [PRC_17] => 1.00000000000000000
    [PRC_18] => 1.000000000000000000
)

Actual result:
--------------
Array
(
    [PRC_0] => 1
    [PRC_1] => 1.0
    [PRC_2] => 1.00
    [PRC_3] => 1.000
    [PRC_4] => 1.0000
    [PRC_5] => 1.00000
    [PRC_6] => 1.000000
    [PRC_7] => 0.10000000
    [PRC_8] => 0.100000000
    [PRC_9] => 1.000000000
    [PRC_10] => 1.0000000000
    [PRC_11] => 1.00000000000
    [PRC_12] => 0.1000000000000
    [PRC_13] => 0.10000000000000
    [PRC_14] => 0.100000000000000
    [PRC_15] => 1.000000000000000
    [PRC_16] => 0.10000000000000000
    [PRC_17] => 0.100000000000000000
    [PRC_18] => 29.008656684181574799
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-01 11:09 UTC] tony2001@php.net
You can try to change the lines mentioned in #39056 (see ext/interbase/ibase_query.c) and tell us if it works.
I don't think anybody here uses Interbase these days.
 [2006-12-01 21:51 UTC] ilpochta at gmail dot com
Take the solution from #39056, add two strings to them (for precisions 17 and 18) and .... it works! :)

# diff ./php-5.2.0/ext/interbase/old/ibase_query.c ./fixed/ext/interbase/ibase_query.c
1289,1291c1289,1304
<       static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 100000000, 1000000000,
<               1000000000, LL_LIT(10000000000),LL_LIT(100000000000),LL_LIT(10000000000000),LL_LIT(100000000000000),
<               LL_LIT(1000000000000000),LL_LIT(1000000000000000),LL_LIT(1000000000000000000) };
---
>       static ISC_INT64 const scales[] = { 1, 10, 100, 1000,
>       10000,
>       100000,
>       1000000,
>       10000000,
>       100000000,
>       1000000000, LL_LIT
>       (10000000000),LL_LIT
>       (100000000000),LL_LIT
>       (1000000000000),LL_LIT
>       (10000000000000),LL_LIT
>       (100000000000000),LL_LIT
>       (1000000000000000),LL_LIT
>       (10000000000000000),LL_LIT
>       (100000000000000000),LL_LIT
>       (1000000000000000000) };

----------
I think, same error is present in function firebird_stmt_get_col() from ext/pdo_firebird/firebird_statement.c .
 [2007-01-22 10:29 UTC] ilpochta at gmail dot com
Are the php_interbase maintained?
Please, fix this bug before PHP-5.2.1. Just recount the nulls in "scales" array :)
 [2007-01-22 10:34 UTC] tony2001@php.net
>Are the php_interbase maintained?
No, feel free to take it over.
 [2007-09-11 10:44 UTC] nb,b at fdhf dot hgk
http://www.meta-fx.com/
 [2007-11-08 19:46 UTC] lwe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in HEAD and PHP_5_3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC