Skip to content

Commit e017f35

Browse files
committed
Merge branch 'PHP-5.6'
Conflicts: ext/pgsql/pgsql.c
2 parents b73fa1f + 1db720c commit e017f35

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

ext/pgsql/pgsql.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,9 +5746,6 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
57465746

57475747
regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
57485748
if (regerr == REG_NOMATCH) {
5749-
#ifdef PHP_DEBUG
5750-
php_error_docref(NULL, E_NOTICE, "'%s' does not match with '%s'", str, regex);
5751-
#endif
57525749
ret = FAILURE;
57535750
}
57545751
else if (regerr) {
@@ -5987,7 +5984,12 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
59875984
else {
59885985
/* better regex? */
59895986
if (php_pgsql_convert_match(Z_STRVAL_P(val), Z_STRLEN_P(val), "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$", 0) == FAILURE) {
5990-
err = 1;
5987+
if (php_pgsql_convert_match(Z_STRVAL_P(val), Z_STRLEN_P(val), "^[+-]{0,1}(inf)(inity){0,1}$", 1) == FAILURE) {
5988+
err = 1;
5989+
} else {
5990+
ZVAL_STRING(&new_val, Z_STRVAL_P(val));
5991+
php_pgsql_add_quotes(&new_val, 1);
5992+
}
59915993
}
59925994
else {
59935995
ZVAL_STRING(&new_val, Z_STRVAL_P(val));

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)