summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2015-02-14 22:03:53 +0800
committerXinchen Hui <laruence@php.net>2015-02-14 22:03:53 +0800
commit40a94597aeef59172cefecb25c79ec54ff7b5725 (patch)
tree3feba21453fb0cbb329bbea8dc696693d15da8f1
parentc0dd221a3a47dfcb53e1c4415e1d3979ad1da6df (diff)
parent0421404b7322167cdc7e3b5232757ce4a7bc7e11 (diff)
downloadphp-git-40a94597aeef59172cefecb25c79ec54ff7b5725.tar.gz
Merge branch 'PHP-5.4' of https://github.com/wfelipew/php-src into PHP-5.5
-rw-r--r--ext/pgsql/pgsql.c5
-rw-r--r--ext/pgsql/tests/bug68638.phpt53
2 files changed, 57 insertions, 1 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 33e65767cf..68459f1376 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -5607,11 +5607,14 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
}
else {
/* FIXME: better regex must be used */
- 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) {
+ 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) {
err = 1;
}
else {
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
+ if(strcasestr(Z_STRVAL_PP(val),"inf")!=0){
+ php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
+ }
}
}
break;
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"
+}