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