php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61939 PDO_FIREBIRD incorrect result of query for NUMERIC(x, y) type in 1 dialect
Submitted: 2012-05-04 14:50 UTC Modified: 2012-07-06 07:52 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sim-mail at list dot ru Assigned: mariuz (profile)
Status: Not a bug Package: PDO related
PHP Version: 5.3.12 OS: Windows 7 32bit
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: sim-mail at list dot ru
New email:
PHP Version: OS:

 

 [2012-05-04 14:50 UTC] sim-mail at list dot ru
Description:
------------
PDO_FIREBIRD incorrect result of query for NUMERIC(x, y) or DECIMAL (x, y) type

<?php
$sql = 'select * from price';
$dbh = new PDO('firebird:dbname=localhost:d:\interbasedata\test.fdb;charset=win1251', 'sysdba', 'masterkey');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbh->prepare($sql);
$sth->execute();
$obj = $sth->fetch();
var_dump($obj);
$sth = null;
?>

Script print 

object(stdClass)[3]
  public 'ID' => string '1' (length=1)
  public 'NAME' => string 'my price' (length=8)
  public 'COST' => string '1.00' (length=4) <-- Error hear (correct result 12.34)

Test script:
---------------
Sql script for create database

SET SQL DIALECT 1;
SET NAMES WIN1251;

CREATE DATABASE 'LOCALHOST:D:\interbasedata\test.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET WIN1251 COLLATION WIN1251;

CREATE TABLE PRICE (
    ID    INTEGER NOT NULL,
    NAME  VARCHAR(10),
    COST  NUMERIC(15,2)
);

INSERT INTO PRICE (ID, NAME, COST) VALUES (1, 'my price', 12.34);

COMMIT WORK;

ALTER TABLE PRICE ADD CONSTRAINT PK_PRICE PRIMARY KEY (ID);


Patches

php5-bug61939.patch (last revision 2013-09-16 10:09 UTC by slavb18 at gmail dot com)

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-04 14:53 UTC] sim-mail at list dot ru
-Summary: PDO_FIREBIRD incorrect result of query for NUMERIC(x, y) or DECIMAL (x, y) type +Summary: PDO_FIREBIRD incorrect result of query for NUMERIC(x, y) type in 1 dialect
 [2012-05-04 14:53 UTC] sim-mail at list dot ru
only 1 dialect
 [2012-06-26 15:50 UTC] manubing at gmail dot com
Also affected on macosx using PHP 5.3.10 and debian lenny with PHP 5.2.6-1+lenny16.

Something odd: incorrect results are the same for a column for all rows fetched:
using the previous example:

public 'COST' => string '1.00' <-- Error

All rows fetched will have 'COST' set to '1.00' (even if actual values differs)


Running again the query will give another (eg: '600.000000') incorrect value, the same on all rows again.
 [2012-07-06 06:26 UTC] mariuz@php.net
Currently it is possible to create databases in Dialect 1 and 3 only, however it 
is recommended that you use Dialect 3 exclusively, since Dialect 1 will 
eventually be deprecated.
 [2012-07-06 06:47 UTC] mariuz@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mariuz
 [2012-07-06 07:52 UTC] mariuz@php.net
-Status: Assigned +Status: Not a bug
 [2012-07-06 07:52 UTC] mariuz@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please use dialect 3 that is the default dialect for firebird 2.5 
Dialect 1 will be deprecated
 [2013-09-16 10:14 UTC] slavb18 at gmail dot com
dialect 1 returning SQL_DOUBLE with var->sqlscale < 0
with quick and dirty patch ignoring var->sqlscale for SQL_DOUBLE, it works but returns not so pretty double numbers (with six digits after comma, like 123.450000 istead of 123.45)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Sep 09 08:01:28 2024 UTC