xref: /PHP-8.4/ext/pgsql/tests/bug68638.phpt (revision c15988aa)
1--TEST--
2Bug #68638 pg_update() fails to store infinite values
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9
10include('inc/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
33
34?>
35--CLEAN--
36<?php
37require_once('inc/config.inc');
38$conn = pg_connect($conn_str);
39$table='test_68638';
40
41pg_query($conn, "DROP TABLE IF EXISTS $table");
42?>
43--EXPECT--
44string(52) "UPDATE "test_68638" SET "value"=E'inf' WHERE "id"=1;"
45array(2) {
46  ["id"]=>
47  string(1) "1"
48  ["value"]=>
49  string(8) "Infinity"
50}
51array(2) {
52  ["id"]=>
53  string(1) "2"
54  ["value"]=>
55  string(9) "-Infinity"
56}
57array(2) {
58  ["id"]=>
59  string(1) "3"
60  ["value"]=>
61  string(8) "Infinity"
62}
63