File: bug37100_9.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (54 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--TEST--
Bug #37100 (data is returned truncated with BINARY CURSOR) (9.0+)
--EXTENSIONS--
pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
skip_bytea_not_hex();
?>
--FILE--
<?php

include 'inc/config.inc';
$table_name = 'table_bug37100_9';

$db = pg_connect($conn_str);

pg_query($db, "CREATE TABLE {$table_name} (binfield byteA) ;");
pg_query($db, "INSERT INTO {$table_name} VALUES (decode('0103AA000812','hex'))");


$data = pg_query($db, "SELECT binfield FROM {$table_name}");
$res = pg_fetch_result($data, null, 0);
var_dump($res);
var_dump(bin2hex(pg_unescape_bytea($res)));

$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM {$table_name}; FETCH ALL IN mycursor;";

$data = pg_query($db, $sql);
$res = pg_fetch_result($data, null, 0);

var_dump(strlen($res));
var_dump(bin2hex($res));

pg_close($db);

$db = pg_connect($conn_str);
pg_close($db);


?>
--CLEAN--
<?php
require_once('inc/config.inc');
$table_name = 'table_bug37100_9';

$db = pg_connect($conn_str);
pg_query($db, "DROP TABLE IF EXISTS {$table_name}");
?>
--EXPECT--
string(14) "\x0103aa000812"
string(12) "0103aa000812"
int(6)
string(12) "0103aa000812"