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