Skip to content

Commit 40a9459

Browse files
committed
Merge branch 'PHP-5.4' of https://github.com/wfelipew/php-src into PHP-5.5
2 parents c0dd221 + 0421404 commit 40a9459

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

ext/pgsql/pgsql.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5607,11 +5607,14 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
56075607
}
56085608
else {
56095609
/* FIXME: better regex must be used */
5610-
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^([+-]{0,1}[0-9]+)|([+-]{0,1}[0-9]*[\\.][0-9]+)|([+-]{0,1}[0-9]+[\\.][0-9]*)$", 0 TSRMLS_CC) == FAILURE) {
5610+
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^([+-]{0,1}[0-9]+)|([+-]{0,1}[0-9]*[\\.][0-9]+)|([+-]{0,1}[0-9]+[\\.][0-9]*)|([+-]{0,1}(inf)(inity){0,1})$", 1 TSRMLS_CC) == FAILURE) {
56115611
err = 1;
56125612
}
56135613
else {
56145614
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
5615+
if(strcasestr(Z_STRVAL_PP(val),"inf")!=0){
5616+
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
5617+
}
56155618
}
56165619
}
56175620
break;

ext/pgsql/tests/bug68638.phpt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Bug #68638 pg_update() fails to store infinite values
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
8+
include('config.inc');
9+
10+
$conn = pg_connect($conn_str);
11+
12+
$table='test_68638';
13+
14+
pg_query("CREATE TABLE $table (id INT, value FLOAT)");
15+
16+
pg_insert($conn,$table, array('id' => 1, 'value' => 1.2));
17+
pg_insert($conn,$table, array('id' => 2, 'value' => 10));
18+
pg_insert($conn,$table, array('id' => 3, 'value' => 15));
19+
20+
var_dump(pg_update($conn,$table, array('value' => 'inf'), array('id' => 1), PGSQL_DML_STRING));
21+
22+
pg_update($conn,$table, array('value' => 'inf'), array('id' => 1));
23+
pg_update($conn,$table, array('value' => '-inf'), array('id' => 2));
24+
pg_update($conn,$table, array('value' => '+inf'), array('id' => 3));
25+
26+
$rs = pg_query("SELECT * FROM $table");
27+
while ($row = pg_fetch_assoc($rs)) {
28+
var_dump($row);
29+
}
30+
31+
pg_query("DROP TABLE $table");
32+
33+
?>
34+
--EXPECT--
35+
string(52) "UPDATE "test_68638" SET "value"=E'inf' WHERE "id"=1;"
36+
array(2) {
37+
["id"]=>
38+
string(1) "1"
39+
["value"]=>
40+
string(8) "Infinity"
41+
}
42+
array(2) {
43+
["id"]=>
44+
string(1) "2"
45+
["value"]=>
46+
string(9) "-Infinity"
47+
}
48+
array(2) {
49+
["id"]=>
50+
string(1) "3"
51+
["value"]=>
52+
string(8) "Infinity"
53+
}

0 commit comments

Comments
 (0)