xref: /php-src/ext/pgsql/tests/bug37100.phpt (revision beaf1e81)
1--TEST--
2Bug #37100 (data is returned truncated with BINARY CURSOR)
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("inc/skipif.inc");
8skip_bytea_not_escape();
9?>
10--FILE--
11<?php
12
13include 'inc/config.inc';
14$table_name = 'table_bug37100';
15
16$db = pg_connect($conn_str);
17@pg_query("SET bytea_output = 'escape'");
18
19pg_query("CREATE TABLE {$table_name} (binfield byteA) ;");
20pg_query("INSERT INTO {$table_name} VALUES (decode('0103AA000812','hex'))");
21
22
23$data = pg_query("SELECT binfield FROM {$table_name}");
24$res = pg_fetch_result($data,0);
25var_dump($res);
26var_dump(bin2hex(pg_unescape_bytea($res)));
27
28$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM {$table_name}; FETCH ALL IN mycursor;";
29
30$data = pg_query($sql);
31$res = pg_fetch_result($data,0);
32
33var_dump(strlen($res));
34var_dump(bin2hex($res));
35
36pg_close($db);
37?>
38--CLEAN--
39<?php
40require_once('inc/config.inc');
41$table_name = 'table_bug37100';
42
43$db = pg_connect($conn_str);
44pg_query("DROP TABLE IF EXISTS {$table_name}");
45?>
46--EXPECTF--
47Deprecated: Calling pg_fetch_result() with 2 arguments is deprecated, use the 3-parameter signature with a null $row parameter instead in %s on line %d
48string(24) "\001\003\252\000\010\022"
49string(12) "0103aa000812"
50
51Deprecated: Calling pg_fetch_result() with 2 arguments is deprecated, use the 3-parameter signature with a null $row parameter instead in %s on line %d
52int(6)
53string(12) "0103aa000812"
54