summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--ext/pgsql/pgsql.c10
-rw-r--r--ext/pgsql/tests/bug68638.phpt53
3 files changed, 63 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 28335d957e..c75ad95798 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@
. Fix bug #61285, #68329, #68046, #41631: encrypted streams don't observe
socket timeouts (Brad Broerman)
+- pgsql:
+ . Fixed bug #68638 (pg_update() fails to store infinite values).
+ (william dot welter at 4linux dot com dot br, Laruence)
+
?? Feb 2015, PHP 5.6.6
- Core:
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index ed7bf0b610..4bc20bc142 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -5722,9 +5722,6 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
if (regerr == REG_NOMATCH) {
-#ifdef PHP_DEBUG
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "'%s' does not match with '%s'", str, regex);
-#endif
ret = FAILURE;
}
else if (regerr) {
@@ -5971,7 +5968,12 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
else {
/* better regex? */
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$", 0 TSRMLS_CC) == FAILURE) {
- err = 1;
+ if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^[+-]{0,1}(inf)(inity){0,1}$", 1 TSRMLS_CC) == FAILURE) {
+ err = 1;
+ } else {
+ ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
+ php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
+ }
}
else {
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
diff --git a/ext/pgsql/tests/bug68638.phpt b/ext/pgsql/tests/bug68638.phpt
new file mode 100644
index 0000000000..e0701a79f5
--- /dev/null
+++ b/ext/pgsql/tests/bug68638.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Bug #68638 pg_update() fails to store infinite values
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+include('config.inc');
+
+$conn = pg_connect($conn_str);
+
+$table='test_68638';
+
+pg_query("CREATE TABLE $table (id INT, value FLOAT)");
+
+pg_insert($conn,$table, array('id' => 1, 'value' => 1.2));
+pg_insert($conn,$table, array('id' => 2, 'value' => 10));
+pg_insert($conn,$table, array('id' => 3, 'value' => 15));
+
+var_dump(pg_update($conn,$table, array('value' => 'inf'), array('id' => 1), PGSQL_DML_STRING));
+
+pg_update($conn,$table, array('value' => 'inf'), array('id' => 1));
+pg_update($conn,$table, array('value' => '-inf'), array('id' => 2));
+pg_update($conn,$table, array('value' => '+inf'), array('id' => 3));
+
+$rs = pg_query("SELECT * FROM $table");
+while ($row = pg_fetch_assoc($rs)) {
+ var_dump($row);
+}
+
+pg_query("DROP TABLE $table");
+
+?>
+--EXPECT--
+string(52) "UPDATE "test_68638" SET "value"=E'inf' WHERE "id"=1;"
+array(2) {
+ ["id"]=>
+ string(1) "1"
+ ["value"]=>
+ string(8) "Infinity"
+}
+array(2) {
+ ["id"]=>
+ string(1) "2"
+ ["value"]=>
+ string(9) "-Infinity"
+}
+array(2) {
+ ["id"]=>
+ string(1) "3"
+ ["value"]=>
+ string(8) "Infinity"
+}