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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
--TEST--
PostgreSQL import large object with given oid
--SKIPIF--
<?php
include("skipif.inc");
$v = pg_version($conn);
if (version_compare("8.4devel", $v["client"]) > 0) die("skip - requires pg client >= 8.4\n");
if (version_compare("8.4devel", $v["server"]) > 0) die("skip - requires pg server >= 8.4\n");
?>
--FILE--
<?php
include('config.inc');
$db = pg_connect($conn_str);
echo "import LO from int\n";
pg_exec($db, 'begin');
$oid = pg_lo_import($db, __FILE__, 21003);
if (!$oid) echo ("pg_lo_import() error\n");
if ($oid != 21003) echo ("pg_lo_import() wrong id\n");
pg_lo_unlink ($db, $oid);
pg_exec($db, 'commit');
echo "import LO from string\n";
pg_exec($db, 'begin');
$oid = pg_lo_import($db, __FILE__, "21004");
if (!$oid) echo ("pg_lo_import() error\n");
if ($oid != 21004) echo ("pg_lo_import() wrong id\n");
pg_lo_unlink ($db, $oid);
pg_exec($db, 'commit');
echo "import LO using default connection\n";
pg_exec('begin');
$oid = pg_lo_import($db, __FILE__, 21005);
if (!$oid) echo ("pg_lo_import() error\n");
if ($oid != 21005) echo ("pg_lo_import() wrong id\n");
pg_lo_unlink ($oid);
pg_exec('commit');
/* Invalide OID */
try {
pg_lo_import(__FILE__, -15);
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import($db, __FILE__, -15);
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import(__FILE__, 'giberrish');
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import($db, __FILE__, 'giberrish');
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import(__FILE__, true);
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import($db, __FILE__, []);
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import($db, __FILE__, new stdClass());
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
pg_lo_import($db, __FILE__, $db);
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
echo "OK";
?>
--EXPECT--
import LO from int
import LO from string
import LO using default connection
Invalid OID value passed
Invalid OID value passed
Invalid OID value passed
Invalid OID value passed
OID value must be of type string|int, bool given
OID value must be of type string|int, array given
OID value must be of type string|int, stdClass given
OID value must be of type string|int, resource given
OK
|