summaryrefslogtreecommitdiff
path: root/ext/oci8/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/oci8/tests')
-rw-r--r--ext/oci8/tests/array_bind_005.phpt3
-rw-r--r--ext/oci8/tests/array_bind_013.phpt39
-rw-r--r--ext/oci8/tests/bind_long.phpt14
-rw-r--r--ext/oci8/tests/bug35973.phpt43
-rw-r--r--ext/oci8/tests/bug37581.phpt69
-rw-r--r--ext/oci8/tests/bug38161.phpt30
-rw-r--r--ext/oci8/tests/bug38173.phpt79
-rw-r--r--ext/oci8/tests/coll_016.phpt4
-rw-r--r--ext/oci8/tests/coll_016_func.phpt4
-rw-r--r--ext/oci8/tests/connect_with_charset_001.phpt37
-rw-r--r--ext/oci8/tests/define1.phpt52
-rw-r--r--ext/oci8/tests/error1.phpt4
-rw-r--r--ext/oci8/tests/field_funcs.phpt6
-rw-r--r--ext/oci8/tests/field_funcs_old.phpt6
-rw-r--r--ext/oci8/tests/lob_015.phpt24
-rw-r--r--ext/oci8/tests/lob_021.phpt74
-rw-r--r--ext/oci8/tests/lob_022.phpt80
-rw-r--r--ext/oci8/tests/lob_023.phpt84
-rw-r--r--ext/oci8/tests/lob_024.phpt75
-rw-r--r--ext/oci8/tests/lob_025.phpt82
-rw-r--r--ext/oci8/tests/lob_026.phpt100
-rw-r--r--ext/oci8/tests/pecl_bug8816.phpt98
-rw-r--r--ext/oci8/tests/statement_cache.phpt4
-rw-r--r--ext/oci8/tests/test.txt9
24 files changed, 987 insertions, 33 deletions
diff --git a/ext/oci8/tests/array_bind_005.phpt b/ext/oci8/tests/array_bind_005.phpt
index 192d15563..15278532e 100644
--- a/ext/oci8/tests/array_bind_005.phpt
+++ b/ext/oci8/tests/array_bind_005.phpt
@@ -58,7 +58,8 @@ var_dump($array);
echo "Done\n";
?>
---EXPECT--
+--EXPECTF--
+Warning: oci_execute(): ORA-01405: fetched column value is NULL in %s on line %d
array(5) {
[0]=>
string(0) ""
diff --git a/ext/oci8/tests/array_bind_013.phpt b/ext/oci8/tests/array_bind_013.phpt
new file mode 100644
index 000000000..da8f6fdd1
--- /dev/null
+++ b/ext/oci8/tests/array_bind_013.phpt
@@ -0,0 +1,39 @@
+--TEST--
+oci_bind_array_by_name(), SQLT_CHR, default max_length and empty array
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$statement = oci_parse($c, 'SELECT user FROM v$session');
+
+$array = array();
+
+var_dump(oci_bind_array_by_name($statement, ":c1", $array, 5, -10, SQLT_CHR, -10));
+var_dump(oci_bind_array_by_name($statement, ":c1", $array, 5, -10));
+var_dump(oci_bind_array_by_name($statement, ":c1", $array, 5, -1));
+var_dump(oci_bind_array_by_name($statement, ":c1", $array, 5, 0));
+
+oci_execute($statement);
+
+var_dump($array);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: oci_bind_array_by_name() expects at most 6 parameters, 7 given in %s on line %d
+NULL
+
+Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d
+bool(false)
+
+Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d
+bool(false)
+
+Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d
+bool(false)
+array(0) {
+}
+Done
diff --git a/ext/oci8/tests/bind_long.phpt b/ext/oci8/tests/bind_long.phpt
index 58590f145..ddbc11eb6 100644
--- a/ext/oci8/tests/bind_long.phpt
+++ b/ext/oci8/tests/bind_long.phpt
@@ -7,19 +7,19 @@ bind LONG field
require dirname(__FILE__)."/connect.inc";
-$stmt = oci_parse($c, "create table phptestlng( id number(10), fileimage long)");
+$stmt = oci_parse($c, "create table phptestlng( id number(10), filetxt long)");
oci_execute($stmt);
-$stmt = oci_parse ($c, "insert into phptestlng (id, fileimage) values (:id, :fileimage)");
+$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
$i=1;
-$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+$filetxt = file_get_contents( dirname(__FILE__)."/test.txt");
oci_bind_by_name( $stmt, ":id", $i, -1);
-oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LNG);
+oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
oci_execute($stmt, OCI_DEFAULT);
oci_commit($c);
-$stmt = oci_parse($c, "SELECT fileimage FROM phptestlng");
+$stmt = oci_parse($c, "SELECT filetxt FROM phptestlng");
oci_execute($stmt);
$row = oci_fetch_row($stmt);
@@ -33,6 +33,6 @@ echo "Done\n";
?>
--EXPECT--
-string(32) "d04e7036e2f4221abc88fd14e960a45b"
-int(2523)
+string(32) "da852396d08c9ef9fbdf914db1d6d5bb"
+int(276)
Done
diff --git a/ext/oci8/tests/bug35973.phpt b/ext/oci8/tests/bug35973.phpt
new file mode 100644
index 000000000..b62f5cfd0
--- /dev/null
+++ b/ext/oci8/tests/bug35973.phpt
@@ -0,0 +1,43 @@
+--TEST--
+bug #35973 (Error ORA-24806 occurs when trying to fetch a NCLOB field)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$s1 = oci_parse($c, "drop table test_nclob");
+@oci_execute($s1);
+
+$s2 = oci_parse($c, "create table test_nclob (nc NCLOB)");
+oci_execute($s2);
+
+$s3 = oci_parse($c, "insert into test_nclob (nc) values ('12345data')");
+oci_execute($s3);
+
+$s3 = oci_parse($c, "select * from test_nclob");
+oci_execute($s3);
+
+var_dump($data = oci_fetch_assoc($s3));
+$d = $data['NC'];
+
+var_dump($d->read(5));
+var_dump($d->read(4));
+
+$s1 = oci_parse($c, "drop table test_nclob");
+@oci_execute($s1);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(1) {
+ ["NC"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(%d) "%s5"
+string(%d) "%sa"
+Done
diff --git a/ext/oci8/tests/bug37581.phpt b/ext/oci8/tests/bug37581.phpt
new file mode 100644
index 000000000..ec86c5195
--- /dev/null
+++ b/ext/oci8/tests/bug37581.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$p1 = "create or replace package ARRAYBINDPKG1 as
+type str_array is table of char(2) index by binary_integer;
+procedure array_bind(in_str in str_array, out_str out string);
+end ARRAYBINDPKG1;";
+
+$p2 = "create or replace package body ARRAYBINDPKG1 as
+ procedure array_bind(in_str in str_array, out_str out string) is
+ begin
+ for i in 1 .. in_str.count loop
+ out_str := in_str(i);
+ end loop;
+ end array_bind;
+end ARRAYBINDPKG1;";
+
+$s1 = oci_parse($c, $p1);
+$s2 = oci_parse($c, $p2);
+oci_execute($s1);
+oci_execute($s2);
+
+
+$stmt = oci_parse($c,'begin ARRAYBINDPKG1.array_bind(:in_arr, :out_str); end;');
+$strings = array('A','B','C','D','E');
+
+oci_bind_array_by_name($stmt,':in_arr',$strings,5,1,SQLT_AFC);
+oci_bind_by_name($stmt,':out_str',$result,10);
+
+oci_execute($stmt);
+var_dump($strings);
+
+oci_execute($stmt);
+var_dump($strings);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(5) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(1) "B"
+ [2]=>
+ string(1) "C"
+ [3]=>
+ string(1) "D"
+ [4]=>
+ string(1) "E"
+}
+array(5) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(1) "B"
+ [2]=>
+ string(1) "C"
+ [3]=>
+ string(1) "D"
+ [4]=>
+ string(1) "E"
+}
+Done
diff --git a/ext/oci8/tests/bug38161.phpt b/ext/oci8/tests/bug38161.phpt
new file mode 100644
index 000000000..27cfafdc8
--- /dev/null
+++ b/ext/oci8/tests/bug38161.phpt
@@ -0,0 +1,30 @@
+--TEST--
+bug #38161 (oci_bind_by_name() returns garbage when Oracle didn't set the variable)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$query = "begin if false then :bv := 1; end if; end;";
+$stid = oci_parse($c, $query);
+oci_bind_by_name($stid, ":bv", $bv, 22);
+oci_execute($stid, OCI_DEFAULT);
+
+var_dump($bv);
+unset($bv);
+
+$query = "begin if false then :bv := 1; end if; end;";
+$stid = oci_parse($c, $query);
+oci_bind_by_name($stid, ":bv", $bv, 22, SQLT_INT);
+oci_execute($stid, OCI_DEFAULT);
+
+var_dump($bv);
+
+echo "Done\n";
+?>
+--EXPECTF--
+NULL
+int(0)
+Done
diff --git a/ext/oci8/tests/bug38173.phpt b/ext/oci8/tests/bug38173.phpt
new file mode 100644
index 000000000..b92df9e39
--- /dev/null
+++ b/ext/oci8/tests/bug38173.phpt
@@ -0,0 +1,79 @@
+--TEST--
+Bug #38173 (Freeing nested cursors causes OCI8 to segfault)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$create_1 = "CREATE TABLE t1 (id INTEGER)";
+$create_2 = "CREATE TABLE t2 (id INTEGER)";
+$drop_1 = "DROP TABLE t1";
+$drop_2 = "DROP TABLE t2";
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+$s1 = oci_parse($c, $create_1);
+$s2 = oci_parse($c, $create_2);
+oci_execute($s1);
+oci_execute($s2);
+
+for($i=0; $i < 5; $i++) {
+ $insert = "INSERT INTO t1 VALUES(".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+for($i=0; $i < 5; $i++) {
+ $insert = "INSERT INTO t2 VALUES(".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+$query ="
+SELECT
+ t1.*,
+ CURSOR( SELECT * FROM t2 ) as cursor
+FROM
+ t1
+";
+
+$sth = oci_parse($c, $query);
+oci_execute($sth);
+
+// dies on oci_free_statement on 2nd pass through loop
+while ( $row = oci_fetch_assoc($sth) ) {
+ print "Got row!\n";
+ var_dump(oci_execute($row['CURSOR']));
+ var_dump(oci_free_statement($row['CURSOR']));
+}
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Done
diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt
index 1a57a104e..c2af9cc22 100644
--- a/ext/oci8/tests/coll_016.phpt
+++ b/ext/oci8/tests/coll_016.phpt
@@ -37,10 +37,10 @@ require dirname(__FILE__)."/drop_type.inc";
--EXPECTF--
bool(true)
-Warning: OCI-Collection::assignelem(): OCI-22165: given index [4294967295] must be in the range of 0 to [0] in %s on line %d
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d
bool(false)
-Warning: OCI-Collection::assignelem(): OCI-22165: given index [5000] must be in the range of 0 to [0] in %s on line %d
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d
bool(false)
bool(false)
bool(false)
diff --git a/ext/oci8/tests/coll_016_func.phpt b/ext/oci8/tests/coll_016_func.phpt
index e090ca19e..cde26f22f 100644
--- a/ext/oci8/tests/coll_016_func.phpt
+++ b/ext/oci8/tests/coll_016_func.phpt
@@ -37,10 +37,10 @@ require dirname(__FILE__)."/drop_type.inc";
--EXPECTF--
bool(true)
-Warning: oci_collection_element_assign(): OCI-22165: given index [4294967295] must be in the range of 0 to [0] in %s on line %d
+Warning: oci_collection_element_assign(): OCI-22165: given index [%d] must be in the range of%s0%sto [0] in %s on line %d
bool(false)
-Warning: oci_collection_element_assign(): OCI-22165: given index [5000] must be in the range of 0 to [0] in %s on line %d
+Warning: oci_collection_element_assign(): OCI-22165: given index [5000] must be in the range of%s0%sto [0] in %s on line %d
bool(false)
bool(false)
bool(false)
diff --git a/ext/oci8/tests/connect_with_charset_001.phpt b/ext/oci8/tests/connect_with_charset_001.phpt
new file mode 100644
index 000000000..9149747cd
--- /dev/null
+++ b/ext/oci8/tests/connect_with_charset_001.phpt
@@ -0,0 +1,37 @@
+--TEST--
+oci_connect() with invalid character set
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+var_dump($c1 = oci_connect($user, $password, $dbase));
+var_dump($c2 = oci_connect($user, $password, $dbase, ""));
+var_dump($c3 = oci_connect($user, $password, $dbase, "blah"));
+var_dump($c4 = oci_connect($user, $password, $dbase, "obviously wrong"));
+
+var_dump($c3 == $c4);
+
+var_dump($c5 = oci_connect($user, $password, $dbase, "US7ASCII"));
+var_dump($c6 = oci_connect($user, $password, $dbase, "UTF8"));
+
+var_dump($c5 == $c6);
+
+echo "Done\n";
+?>
+--EXPECTF--
+resource(%d) of type (oci8 connection)
+resource(%d) of type (oci8 connection)
+
+Warning: oci_connect(): Invalid character set name: blah in %s on line %d
+resource(%d) of type (oci8 connection)
+
+Warning: oci_connect(): Invalid character set name: obviously wrong in %s on line %d
+resource(%d) of type (oci8 connection)
+bool(true)
+resource(%d) of type (oci8 connection)
+resource(%d) of type (oci8 connection)
+bool(false)
+Done
diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt
new file mode 100644
index 000000000..f6e04cc18
--- /dev/null
+++ b/ext/oci8/tests/define1.phpt
@@ -0,0 +1,52 @@
+--TEST--
+oci_define_by_name()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_table.inc";
+
+$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
+
+if (!($s = oci_parse($c, $insert_sql))) {
+ die("oci_parse(insert) failed!\n");
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(insert) failed!\n");
+}
+
+$stmt = oci_parse($c, "SELECT string FROM ".$table_name."");
+
+/* the define MUST be done BEFORE ociexecute! */
+
+$strong = '';
+var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
+var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
+var_dump(oci_define_by_name($stmt, "", $string, 20));
+var_dump(oci_define_by_name($stmt, ""));
+
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($string);
+}
+
+require dirname(__FILE__)."/drop_table.inc";
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+
+Warning: oci_define_by_name(): Column name cannot be empty in %s on line %d
+bool(false)
+
+Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+string(4) "some"
+Done
diff --git a/ext/oci8/tests/error1.phpt b/ext/oci8/tests/error1.phpt
index 8b358b612..25a3f09e9 100644
--- a/ext/oci8/tests/error1.phpt
+++ b/ext/oci8/tests/error1.phpt
@@ -12,13 +12,13 @@ echo "Done\n";
?>
--EXPECTF--
-Warning: oci_connect(): ORA-12154: TNS:could not resolve service name in %s on line %d
+Warning: oci_connect(): ORA-12154: TNS:could not resolve %s in %s on line %d
bool(false)
array(4) {
["code"]=>
int(12154)
["message"]=>
- string(45) "ORA-12154: TNS:could not resolve service name"
+ string(%d) "ORA-12154: TNS:could not resolve %s"
["offset"]=>
int(0)
["sqltext"]=>
diff --git a/ext/oci8/tests/field_funcs.phpt b/ext/oci8/tests/field_funcs.phpt
index 988e5f7a1..102f2fdc0 100644
--- a/ext/oci8/tests/field_funcs.phpt
+++ b/ext/oci8/tests/field_funcs.phpt
@@ -54,7 +54,7 @@ require dirname(__FILE__).'/drop_table.inc';
echo "Done\n";
?>
---EXPECT--
+--EXPECTF--
array(5) {
[0]=>
string(1) "1"
@@ -71,14 +71,14 @@ bool(false)
string(2) "ID"
string(6) "NUMBER"
int(2)
-int(0)
+int(%d)
int(0)
int(22)
bool(false)
string(5) "VALUE"
string(6) "NUMBER"
int(2)
-int(0)
+int(%d)
int(0)
int(22)
bool(true)
diff --git a/ext/oci8/tests/field_funcs_old.phpt b/ext/oci8/tests/field_funcs_old.phpt
index 34af09429..e6f21d613 100644
--- a/ext/oci8/tests/field_funcs_old.phpt
+++ b/ext/oci8/tests/field_funcs_old.phpt
@@ -54,7 +54,7 @@ require dirname(__FILE__).'/drop_table.inc';
echo "Done\n";
?>
---EXPECT--
+--EXPECTF--
array(5) {
[0]=>
string(1) "1"
@@ -71,14 +71,14 @@ bool(false)
string(2) "ID"
string(6) "NUMBER"
int(2)
-int(0)
+int(%d)
int(0)
int(22)
bool(false)
string(5) "VALUE"
string(6) "NUMBER"
int(2)
-int(0)
+int(%d)
int(0)
int(22)
bool(true)
diff --git a/ext/oci8/tests/lob_015.phpt b/ext/oci8/tests/lob_015.phpt
index d2b7f0ad4..297d5b497 100644
--- a/ext/oci8/tests/lob_015.phpt
+++ b/ext/oci8/tests/lob_015.phpt
@@ -18,10 +18,11 @@ $ora_sql = "INSERT INTO
$statement = oci_parse($c,$ora_sql);
$blob = oci_new_descriptor($c,OCI_D_LOB,1,2,3);
$blob = oci_new_descriptor($c);
+$int = 1;
oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB,4);
oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB,4,5);
-oci_bind_by_name($statement,":v_blob", $blob,-1);
-oci_bind_by_name($statement,":v_blob", $blob);
+oci_bind_by_name($statement,":v_blob", $int,-1);
+oci_bind_by_name($statement,":v_blob", $int);
oci_bind_by_name($statement,":v_blob");
oci_bind_by_name($statement);
oci_execute($statement, OCI_DEFAULT);
@@ -34,18 +35,19 @@ echo "Done\n";
?>
--EXPECTF--
-Warning: oci_new_descriptor() expects at most 2 parameters, 5 given in %slob_015.php on line %d
+Warning: oci_new_descriptor() expects at most 2 parameters, 5 given in %s on line %d
-Warning: oci_bind_by_name() expects at most 5 parameters, 6 given in %slob_015.php on line %d
+Warning: oci_bind_by_name() expects at most 5 parameters, 6 given in %s on line %d
-Warning: oci_bind_by_name() expects at most 5 parameters, 7 given in %slob_015.php on line %d
+Warning: oci_bind_by_name() expects at most 5 parameters, 7 given in %s on line %d
-Notice: Object of class OCI-Lob to string conversion in %slob_015.php on line %d
+Warning: oci_bind_by_name() expects at least 3 parameters, 2 given in %s on line %d
-Warning: oci_bind_by_name() expects at least 3 parameters, 2 given in %slob_015.php on line %d
+Warning: oci_bind_by_name() expects at least 3 parameters, 1 given in %s on line %d
-Warning: oci_bind_by_name() expects at least 3 parameters, 1 given in %slob_015.php on line %d
-
-Warning: oci_execute(): ORA-00932: inconsistent datatypes: expected NUMBER got BLOB in %slob_015.php on line %d
-string(6) "Object"
+Warning: oci_execute(): ORA-00932: inconsistent datatypes: expected NUMBER got BLOB in %s on line %d
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
Done
diff --git a/ext/oci8/tests/lob_021.phpt b/ext/oci8/tests/lob_021.phpt
new file mode 100644
index 000000000..32ef6f9fe
--- /dev/null
+++ b/ext/oci8/tests/lob_021.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_lob_free()/close()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+$blob;
+
+var_dump($blob->write("test"));
+var_dump($blob->close());
+var_dump($blob->write("test"));
+var_dump(oci_free_descriptor($blob));
+var_dump($blob->write("test"));
+
+var_dump(oci_free_descriptor($blob));
+var_dump(oci_free_descriptor(new stdclass));
+
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+unset($blob->descriptor);
+var_dump(oci_free_descriptor($blob));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name."";
+$s = oci_parse($c, $select_sql);
+oci_execute($s);
+
+var_dump(oci_fetch_array($s, OCI_NUM + OCI_RETURN_LOBS));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+int(4)
+
+Warning: OCI-Lob::close(): ORA-22289: cannot perform operation on an unopened file or LOB in %s on line %d
+bool(false)
+int(4)
+bool(true)
+
+Warning: OCI-Lob::write(): %d is not a valid oci8 descriptor resource in %s on line %d
+bool(false)
+
+Warning: oci_free_descriptor(): %d is not a valid oci8 descriptor resource in %s on line %d
+bool(false)
+
+Warning: oci_free_descriptor() expects parameter 1 to be OCI-Lob, object given in %s on line %d
+NULL
+
+Warning: oci_free_descriptor(): Unable to find descriptor property in %s on line %d
+bool(false)
+array(1) {
+ [0]=>
+ string(8) "testtest"
+}
+Done
diff --git a/ext/oci8/tests/lob_022.phpt b/ext/oci8/tests/lob_022.phpt
new file mode 100644
index 000000000..5fb9dfab0
--- /dev/null
+++ b/ext/oci8/tests/lob_022.phpt
@@ -0,0 +1,80 @@
+--TEST--
+fetching the same lob several times
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "CREATE table lob_test(mykey NUMBER, lob_1 CLOB)";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(1, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob";
+$statement = oci_parse($c, $init);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+$clob->save();
+oci_lob_save();
+oci_lob_save($clob, "data");
+unset($clob->descriptor);
+oci_lob_save($clob, "data");
+
+oci_commit($c);
+
+$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(2, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob";
+$statement = oci_parse($c, $init);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+$clob->save("long data");
+$clob->save("long data", -1);
+$clob->save("long data", 0);
+
+oci_commit($c);
+
+
+$query = 'SELECT * FROM lob_test ORDER BY mykey ASC';
+$statement = oci_parse ($c, $query);
+oci_execute($statement, OCI_DEFAULT);
+
+while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
+ $result = $row['LOB_1']->load();
+ var_dump($result);
+}
+
+$query = 'SELECT * FROM lob_test ORDER BY mykey DESC';
+$statement = oci_parse ($c, $query);
+oci_execute($statement, OCI_DEFAULT);
+
+while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
+ $result = $row['LOB_1']->load();
+ var_dump($result);
+}
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Warning: OCI-Lob::save() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: oci_lob_save() expects at least 2 parameters, 0 given in %s on line %d
+
+Warning: oci_lob_save(): Unable to find descriptor property in %s on line %d
+
+Warning: OCI-Lob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d
+string(4) "data"
+string(9) "long data"
+string(9) "long data"
+string(4) "data"
+Done
diff --git a/ext/oci8/tests/lob_023.phpt b/ext/oci8/tests/lob_023.phpt
new file mode 100644
index 000000000..0c352956d
--- /dev/null
+++ b/ext/oci8/tests/lob_023.phpt
@@ -0,0 +1,84 @@
+--TEST--
+oci_lob_import()/read()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+var_dump($blob->seek(10, OCI_SEEK_CUR));
+var_dump($blob->import(dirname(__FILE__)."/lob_009.txt"));
+var_dump($blob->import());
+var_dump(oci_lob_import($blob));
+var_dump(oci_lob_import($blob, dirname(__FILE__)."/lob_009.txt"));
+unset($blob->descriptor);
+var_dump(oci_lob_import($blob, dirname(__FILE__)."/lob_009.txt"));
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+while (!$row[0]->eof()) {
+ var_dump($row[0]->read(1024));
+}
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+bool(true)
+bool(true)
+
+Warning: OCI-Lob::import() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_import() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+bool(true)
+
+Warning: oci_lob_import(): Unable to find descriptor property in %s on line %d
+bool(false)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(43) "this
+is
+a
+test
+file for
+test lob_009.phpt
+"
+Done
diff --git a/ext/oci8/tests/lob_024.phpt b/ext/oci8/tests/lob_024.phpt
new file mode 100644
index 000000000..9a7f53240
--- /dev/null
+++ b/ext/oci8/tests/lob_024.phpt
@@ -0,0 +1,75 @@
+--TEST--
+oci_lob_load()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($blob->size());
+var_dump($blob->write(str_repeat("string.", 1000)));
+var_dump($blob->size());
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(strlen($row[0]->load()));
+var_dump(strlen(oci_lob_load($row[0])));
+var_dump(oci_lob_load());
+unset($row[0]->descriptor);
+var_dump(oci_lob_load($row[0]));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+int(0)
+int(7000)
+int(7000)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+int(7000)
+int(7000)
+
+Warning: oci_lob_load() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_load(): Unable to find descriptor property in %s on line %d
+bool(false)
+Done
diff --git a/ext/oci8/tests/lob_025.phpt b/ext/oci8/tests/lob_025.phpt
new file mode 100644
index 000000000..5b5e845a7
--- /dev/null
+++ b/ext/oci8/tests/lob_025.phpt
@@ -0,0 +1,82 @@
+--TEST--
+oci_lob_read() tests
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->size());
+var_dump($blob->write(str_repeat("string.", 1000)));
+var_dump($blob->size());
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(oci_lob_read($row[0], 2));
+var_dump(oci_lob_read($row[0]));
+var_dump(oci_lob_read());
+var_dump(oci_lob_eof($row[0]));
+var_dump(oci_lob_eof());
+
+unset($row[0]->descriptor);
+var_dump(oci_lob_read($row[0],1));
+var_dump(oci_lob_eof($row[0]));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+int(0)
+int(7000)
+int(7000)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(2) "st"
+
+Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: oci_lob_read() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+bool(false)
+
+Warning: oci_lob_eof() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_read(): Unable to find descriptor property in %s on line %d
+bool(false)
+
+Warning: oci_lob_eof(): Unable to find descriptor property in %s on line %d
+bool(false)
+Done
diff --git a/ext/oci8/tests/lob_026.phpt b/ext/oci8/tests/lob_026.phpt
new file mode 100644
index 000000000..157d78a2b
--- /dev/null
+++ b/ext/oci8/tests/lob_026.phpt
@@ -0,0 +1,100 @@
+--TEST--
+oci_lob_seek()/rewind()/append()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump(oci_lob_write($blob, "test"));
+var_dump(oci_lob_rewind());
+var_dump(oci_lob_rewind($blob));
+var_dump(oci_lob_write($blob, "str"));
+var_dump(oci_lob_seek(10, OCI_SEEK_SET));
+var_dump(oci_lob_seek($blob, 10, OCI_SEEK_SET));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(oci_lob_append());
+var_dump(oci_lob_append($blob));
+var_dump(oci_lob_append($row[0], $blob));
+var_dump(oci_lob_read(10000));
+var_dump(oci_lob_read($row[0], 10000));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$row = oci_fetch_array($s);
+
+var_dump(oci_lob_read($row[0], 10000));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+int(4)
+
+Warning: oci_lob_rewind() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+bool(true)
+int(3)
+
+Warning: oci_lob_seek() expects parameter 1 to be OCI-Lob, integer given in %s on line %d
+NULL
+bool(true)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+
+Warning: oci_lob_append() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_append() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+bool(true)
+
+Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+string(4) "strt"
+string(8) "strtstrt"
+Done
diff --git a/ext/oci8/tests/pecl_bug8816.phpt b/ext/oci8/tests/pecl_bug8816.phpt
new file mode 100644
index 000000000..c369711fc
--- /dev/null
+++ b/ext/oci8/tests/pecl_bug8816.phpt
@@ -0,0 +1,98 @@
+--TEST--
+PECL Bug #8816 (issue in php_oci_statement_fetch with more than one piecewise column)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$create_1 = "CREATE TABLE t1 (id INTEGER, l1 LONG)";
+$create_2 = "CREATE TABLE t2 (id INTEGER, l2 LONG)";
+$drop_1 = "DROP TABLE t1";
+$drop_2 = "DROP TABLE t2";
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+$s1 = oci_parse($c, $create_1);
+$s2 = oci_parse($c, $create_2);
+oci_execute($s1);
+oci_execute($s2);
+
+$values = array("1234567890111111111", "122222222222222", "985456745674567654567654567654", "123456789", "987654321");
+
+$i = 0;
+foreach ($values as $val) {
+ $i++;
+ $insert = "INSERT INTO t1 VALUES($i, ".$val.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+foreach ($values as $val) {
+ $insert = "INSERT INTO t2 VALUES($i, ".$val.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+ $i--;
+}
+
+$query ="
+SELECT
+ t1.l1, t2.l2
+FROM
+t1, t2
+WHERE
+t1.id = t2.id
+ORDER BY t1.id ASC
+";
+
+$sth = oci_parse($c, $query);
+oci_execute($sth);
+
+while ( $row = oci_fetch_assoc($sth) ) {
+ var_dump($row);
+}
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+array(2) {
+ ["L1"]=>
+ string(19) "1234567890111111111"
+ ["L2"]=>
+ string(9) "987654321"
+}
+array(2) {
+ ["L1"]=>
+ string(15) "122222222222222"
+ ["L2"]=>
+ string(9) "123456789"
+}
+array(2) {
+ ["L1"]=>
+ string(30) "985456745674567654567654567654"
+ ["L2"]=>
+ string(30) "985456745674567654567654567654"
+}
+array(2) {
+ ["L1"]=>
+ string(9) "123456789"
+ ["L2"]=>
+ string(15) "122222222222222"
+}
+array(2) {
+ ["L1"]=>
+ string(9) "987654321"
+ ["L2"]=>
+ string(19) "1234567890111111111"
+}
+Done
diff --git a/ext/oci8/tests/statement_cache.phpt b/ext/oci8/tests/statement_cache.phpt
index e7c8911e8..19e69d4c2 100644
--- a/ext/oci8/tests/statement_cache.phpt
+++ b/ext/oci8/tests/statement_cache.phpt
@@ -9,11 +9,11 @@ require dirname(__FILE__)."/connect.inc";
$pc = oci_pconnect($user, $password, $dbase);
-$stmt = oci_parse($pc, "select 1+3 from dual", true);
+$stmt = oci_parse($pc, "select 1+3 from dual");
oci_execute($stmt);
var_dump(oci_fetch_array($stmt));
-$stmt = oci_parse($pc, "select 1+3 from dual", true);
+$stmt = oci_parse($pc, "select 1+3 from dual");
oci_execute($stmt);
var_dump(oci_fetch_array($stmt));
diff --git a/ext/oci8/tests/test.txt b/ext/oci8/tests/test.txt
new file mode 100644
index 000000000..fa9e8d2c2
--- /dev/null
+++ b/ext/oci8/tests/test.txt
@@ -0,0 +1,9 @@
+Feel so good, I feel so fine
+Love that little lady always on my mind
+She gives me loving every night and day
+Never gonna leave her, never going away
+
+Someone to love me
+You know she makes me feel all right, yeah (all right)
+Someone to need me
+Love me every single night, yeah