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