php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68638 pg_update() fails to store infinite values
Submitted: 2014-12-23 14:06 UTC Modified: 2015-02-04 15:29 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: joerg dot ludwig at iserv dot eu Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 5.4.36 OS: Debian Linux
Private report: No CVE-ID: None
 [2014-12-23 14:06 UTC] joerg dot ludwig at iserv dot eu
Description:
------------
pg_update() fails to store infinite values.

Test script:
---------------
$dbh = pg_connect("dbname=test");
pg_update($dbh, "test", ["ping" => INF], ["id" => 42]);
pg_update($dbh, "test", ["ping" => "INF"], ["id" => 42]);



Expected result:
----------------
pg_update() (and pg_insert()) should be able to store infinite values (INF and -INF).

In PostgreSQL itself it works:
UPDATE test SET ping = 'INF' WHERE id = 42;

Actual result:
--------------
PHP Warning:  pg_update(): ERROR:  column "inf" does not exist
LINE 1: UPDATE "test" SET "ping"=INF WHERE "id"=42...
                                    ^
 in Command line code on line 1

PHP Notice:  pg_update(): 'INF' does not match with '^([+-]{0,1}[0-9]+)|([+-]{0,1}[0-9]*[\.][0-9]+)|([+-]{0,1}[0-9]+[\.][0-9]*)$' in Command line code on line 1
PHP Notice:  pg_update(): Expects NULL, string, long or double value for PostgreSQL 'float4' (ping) in Command line code on line 1

Patches

fix-accept-infinity-values (last revision 2015-02-04 00:18 UTC by william dot welter at 4linux dot com dot br)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-04 00:24 UTC] william dot welter at 4linux dot com dot br
The problem is that on source code, when a PHP string is passed to a float field on database, this string is checked with a regex that is not aware about "infinity" values.

See the the patch that i send.
 [2015-02-04 15:29 UTC] joerg dot ludwig at iserv dot eu
Hi William,

thanks for your patch, looks good to me!

In the meantime I also discovered, that pg_insert()/pg_update() do not understand IPv6 addresses and database fields of the extended type DEBVERSION. But maybe I should write another bug report for this.
 [2015-02-14 14:23 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7667f8efc6ee9727cbd7af26e5f62f9cebd8a25e
Log: Fixed bug #68638 (pg_update() fails to store infinite values)
 [2015-02-14 14:23 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-02-14 14:23 UTC] laruence@php.net
Automatic comment on behalf of william.welter@4linux.com.br
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0421404b7322167cdc7e3b5232757ce4a7bc7e11
Log: Fixed bug #68638 pg_update() fails to store infinite values Fix indent
 [2015-02-14 14:23 UTC] laruence@php.net
Automatic comment on behalf of william.welter@4linux.com.br
Revision: http://git.php.net/?p=php-src.git;a=commit;h=60d5cdf1379950afde23de10acc964e7fc34145b
Log: Fixed bug #68638 pg_update() fails to store infinite values Check if value is "infinity" with strcasestr() to add quotes
 [2015-02-14 14:23 UTC] laruence@php.net
Automatic comment on behalf of william.welter@4linux.com.br
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bb3a81c4b482e94354fed40d0f1e1f81afca7437
Log: Fixed bug #68638 pg_update() fails to store infinite values. Add quotes only if "infinity" values are received.
 [2015-02-14 14:23 UTC] laruence@php.net
Automatic comment on behalf of william.welter@4linux.com.br
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cb3833a3bef1d40ff630f6a0af55648acaf664f7
Log: Fixed bug #68638 pg_update() fails to store infinite values.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC