xref: /PHP-7.4/ext/pgsql/tests/bug37100_9.phpt (revision c6662392)
1--TEST--
2Bug #37100 (data is returned truncated with BINARY CURSOR) (9.0+)
3--SKIPIF--
4<?php
5include("skipif.inc");
6skip_bytea_not_hex();
7?>
8--FILE--
9<?php
10
11include 'config.inc';
12
13$db = pg_connect($conn_str);
14
15@pg_query('DROP TABLE test_bug');
16
17pg_query('CREATE TABLE test_bug (binfield byteA) ;');
18pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
19
20
21$data = pg_query("SELECT binfield FROM test_bug");
22$res = pg_fetch_result($data,0);
23var_dump($res);
24var_dump(bin2hex(pg_unescape_bytea($res)));
25
26$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
27
28$data = pg_query($sql);
29$res = pg_fetch_result($data,0);
30
31var_dump(strlen($res));
32var_dump(bin2hex($res));
33
34pg_close($db);
35
36$db = pg_connect($conn_str);
37pg_query('DROP TABLE test_bug');
38pg_close($db);
39
40
41?>
42--EXPECT--
43string(14) "\x0103aa000812"
44string(12) "0103aa000812"
45int(6)
46string(12) "0103aa000812"
47