diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
| commit | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch) | |
| tree | 41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/oci8/tests | |
| parent | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff) | |
| download | php-upstream/5.2.2.tar.gz | |
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/oci8/tests')
43 files changed, 3484 insertions, 56 deletions
diff --git a/ext/oci8/tests/array_bind_005.phpt b/ext/oci8/tests/array_bind_005.phpt index 15278532e..58dadc20c 100644 --- a/ext/oci8/tests/array_bind_005.phpt +++ b/ext/oci8/tests/array_bind_005.phpt @@ -59,7 +59,6 @@ var_dump($array); echo "Done\n"; ?> --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 index da8f6fdd1..4da9d8bbe 100644 --- a/ext/oci8/tests/array_bind_013.phpt +++ b/ext/oci8/tests/array_bind_013.phpt @@ -16,7 +16,7 @@ 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); +@oci_execute($statement); var_dump($array); diff --git a/ext/oci8/tests/array_bind_014.phpt b/ext/oci8/tests/array_bind_014.phpt new file mode 100644 index 000000000..bd9fdf133 --- /dev/null +++ b/ext/oci8/tests/array_bind_014.phpt @@ -0,0 +1,73 @@ +--TEST-- +oci_bind_array_by_name() and NUMBERs +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name NUMBER)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +for ($i = 1; $i < 6; $i++) { + $statement = oci_parse($c, "INSERT INTO bind_test VALUES (".$i.")"); + oci_execute($statement); +} + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array = Array(); +oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_INT); +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done diff --git a/ext/oci8/tests/array_bind_int1.phpt b/ext/oci8/tests/array_bind_int1.phpt index eb2072adc..5e06de876 100644 --- a/ext/oci8/tests/array_bind_int1.phpt +++ b/ext/oci8/tests/array_bind_int1.phpt @@ -50,7 +50,7 @@ $statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); $array = Array(1,2,3,4,5); -oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_NUM); +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_INT); oci_execute($statement); diff --git a/ext/oci8/tests/bind_empty.phpt b/ext/oci8/tests/bind_empty.phpt index 9c602b32c..ba50f8617 100644 --- a/ext/oci8/tests/bind_empty.phpt +++ b/ext/oci8/tests/bind_empty.phpt @@ -4,7 +4,7 @@ binding empty values <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> --FILE-- <?php - + require dirname(__FILE__).'/connect.inc'; $drop = "DROP table bind_test"; @@ -16,18 +16,57 @@ $statement = oci_parse($c, $create); oci_execute($statement); +echo "Test 1\n"; + $name = null; $stmt = oci_parse($c, "UPDATE bind_test SET name=:name"); oci_bind_by_name($stmt, ":name", $name); -$res = oci_execute($stmt); +var_dump(oci_execute($stmt)); + +echo "Test 2\n"; $name = ""; $stmt = oci_parse($c, "UPDATE bind_test SET name=:name"); oci_bind_by_name($stmt, ":name", $name); +var_dump(oci_execute($stmt)); + +echo "Test 3\n"; + +$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')"); $res = oci_execute($stmt); +$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')"); +$res = oci_execute($stmt); + +$name = null; +$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'"); +oci_bind_by_name($stmt, ":name", $name); + +var_dump(oci_execute($stmt)); + +$stid = oci_parse($c, "select * from bind_test order by 1"); +oci_execute($stid); +oci_fetch_all($stid, $res); +var_dump($res); + +echo "Test 4\n"; + +$name = ""; +$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'"); +oci_bind_by_name($stmt, ":name", $name); + +var_dump(oci_execute($stmt)); + +$stid = oci_parse($c, "select * from bind_test order by 1"); +oci_execute($stid); +oci_fetch_all($stid, $res); +var_dump($res); + + +// Clean up + $drop = "DROP table bind_test"; $statement = oci_parse($c, $drop); @oci_execute($statement); @@ -36,4 +75,30 @@ echo "Done\n"; ?> --EXPECTF-- +Test 1 +bool(true) +Test 2 +bool(true) +Test 3 +bool(true) +array(1) { + ["NAME"]=> + array(2) { + [0]=> + string(3) "def" + [1]=> + NULL + } +} +Test 4 +bool(true) +array(1) { + ["NAME"]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } +} Done diff --git a/ext/oci8/tests/bug40078.phpt b/ext/oci8/tests/bug40078.phpt new file mode 100644 index 000000000..4a234e176 --- /dev/null +++ b/ext/oci8/tests/bug40078.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE nullbind(c1 OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + PROCEDURE nullbind(c1 OUT ARRTYPE) IS + BEGIN + c1(1) := 'one'; + c1(2) := 'two'; + c1(3) := ''; + c1(4) := 'four'; + c1(5) := 'five'; + END nullbind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.nullbind(:c1); END;"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +array(5) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(0) "" + [3]=> + string(4) "four" + [4]=> + string(4) "five" +} +Done diff --git a/ext/oci8/tests/bug40415.phpt b/ext/oci8/tests/bug40415.phpt new file mode 100644 index 000000000..1ebc249d3 --- /dev/null +++ b/ext/oci8/tests/bug40415.phpt @@ -0,0 +1,200 @@ +--TEST-- +Bug #40415 (Using oci_fetchall with nested cursors) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +// Setup + +$create_1 = "CREATE TABLE t1 (id1 INTEGER)"; +$create_2 = "CREATE TABLE t2 (id2 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=1; $i < 4; $i++) { + $insert = "INSERT INTO t1 VALUES(1".$i.")"; + $s = oci_parse($c, $insert); + oci_execute($s); +} + +for($i=1; $i < 4; $i++) { + $insert = "INSERT INTO t2 VALUES(2".$i.")"; + $s = oci_parse($c, $insert); + oci_execute($s); +} + + +function do_assoc($c) +{ + $query = "SELECT t1.*, CURSOR( SELECT * FROM t2 ) AS CURSOR FROM t1"; + + $stmt = oci_parse($c, $query); + oci_execute($stmt); + + while ($row = oci_fetch_assoc($stmt)) { + print "Got row \"".$row['ID1']."\". Now getting nested cursor:\n"; + var_dump(oci_execute($row['CURSOR'])); + while ($row_n = oci_fetch_assoc($row['CURSOR']) ) { + var_dump($row_n); + } + } +} + +function do_all($c) +{ + $query = "SELECT t1.*, CURSOR( SELECT * FROM t2 ) AS CURSOR FROM t1"; + + $stmt = oci_parse($c, $query); + oci_execute($stmt); + + $rc1 = oci_fetch_all($stmt, $res); + + echo "Rows returned $rc1\n"; + + var_dump($res); + + foreach ($res['CURSOR'] as $cv) { + echo "Getting nested cursor\n"; + var_dump(oci_execute($cv)); + $rc2 = oci_fetch_all($cv, $res2); + var_dump($res2); + } +} + + + +echo "Test 1: Associate fetch of nested cursor\n"; +do_assoc($c); + +echo "\nTest 2: fetchall of nested cursor\n"; +do_all($c); + + +// Cleanup +$s1 = oci_parse($c, $drop_1); +$s2 = oci_parse($c, $drop_2); +@oci_execute($s1); +@oci_execute($s2); + +echo "Done\n"; +?> +--EXPECTF-- +Test 1: Associate fetch of nested cursor +Got row "11". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} +Got row "12". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} +Got row "13". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} + +Test 2: fetchall of nested cursor +Rows returned 3 +array(2) { + ["ID1"]=> + array(3) { + [0]=> + string(2) "11" + [1]=> + string(2) "12" + [2]=> + string(2) "13" + } + ["CURSOR"]=> + array(3) { + [0]=> + resource(%d) of type (oci8 statement) + [1]=> + resource(%d) of type (oci8 statement) + [2]=> + resource(%d) of type (oci8 statement) + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Done diff --git a/ext/oci8/tests/coll_018.phpt b/ext/oci8/tests/coll_018.phpt new file mode 100644 index 000000000..f97cc49e7 --- /dev/null +++ b/ext/oci8/tests/coll_018.phpt @@ -0,0 +1,93 @@ +--TEST-- +Collection trim tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); + +echo "Test 1.\n"; +var_dump($coll1->trim()); + +echo "\nTest 2.\n"; +var_dump($coll1->trim(0)); + +echo "\nTest 3.\n"; +var_dump($coll1->append(1)); +var_dump($coll1->append(2)); +var_dump($coll1->append(3)); +var_dump($coll1->append(4)); + +var_dump($coll1->getElem(-1)); // check before the beginning +var_dump($coll1->getElem(0)); +var_dump($coll1->getElem(1)); +var_dump($coll1->getElem(2)); +var_dump($coll1->getElem(3)); +var_dump($coll1->getElem(4)); // check past the end + +echo "\nTest 4.\n"; +var_dump($coll1->trim(1)); +var_dump($coll1->getElem(2)); // this should be the last element +var_dump($coll1->getElem(3)); // this element should have gone + +echo "\nTest 5.\n"; +var_dump($coll1->trim(2)); +var_dump($coll1->getElem(0)); // this should be the last element +var_dump($coll1->getElem(1)); // this element should have gone + +echo "\nTest 6.\n"; +var_dump($coll1->trim(0)); +var_dump($coll1->getElem(0)); // this should still be the last element + +echo "\nTest 7.\n"; +var_dump($coll1->trim(1)); +var_dump($coll1->getElem(0)); // this should have gone + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +Test 1. + +Warning: OCI-Collection::trim() expects exactly 1 parameter, 0 given in %s on line 9 +NULL + +Test 2. +bool(true) + +Test 3. +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +float(1) +float(2) +float(3) +float(4) +bool(false) + +Test 4. +bool(true) +float(3) +bool(false) + +Test 5. +bool(true) +float(1) +bool(false) + +Test 6. +bool(true) +float(1) + +Test 7. +bool(true) +bool(false) +Done diff --git a/ext/oci8/tests/coll_019.phpt b/ext/oci8/tests/coll_019.phpt new file mode 100644 index 000000000..15a673d71 --- /dev/null +++ b/ext/oci8/tests/coll_019.phpt @@ -0,0 +1,104 @@ +--TEST-- +Test collection Oracle error handling collections and numbers (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE ".$type_name;; +$statement = oci_parse($c,$ora_sql); +@oci_execute($statement); + + +echo "Test 0\n"; +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF BLOB"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->append('a long string')); // invalid type for append +var_dump($coll1->assignElem(1, 'a long string')); // invalid type for assignelem() +var_dump($coll1->getElem(0)); + +require dirname(__FILE__)."/drop_type.inc"; + +echo "Test 1\n"; +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->assignElem(1, null)); // invalid location for null +var_dump($coll1->getElem(0)); + +echo "Test 2\n"; +var_dump($coll1->assignElem(1, 1234)); // invalid location for number +var_dump($coll1->getElem(0)); + +require dirname(__FILE__)."/drop_type.inc"; + +echo "Test 3\n"; +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR2(1)"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->assignElem(1, 'abc')); // invalid location for string +var_dump($coll1->getElem(0)); + +require dirname(__FILE__)."/drop_type.inc"; + +echo "Test 4\n"; +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->append(1)); // invalid date format +var_dump($coll1->assignElem(1, '01-JAN-06')); // invalid location for date +var_dump($coll1->getElem(0)); + +require dirname(__FILE__)."/drop_type.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 0 + +Notice: OCI-Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d +bool(false) + +Notice: OCI-Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d +bool(false) +bool(false) +Test 1 + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +bool(false) +bool(false) +Test 2 + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +bool(false) +bool(false) +Test 3 + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +bool(false) +bool(false) +Test 4 + +Warning: OCI-Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d +bool(false) + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/connect.inc b/ext/oci8/tests/connect.inc index 887c8fdaa..452976e8f 100644 --- a/ext/oci8/tests/connect.inc +++ b/ext/oci8/tests/connect.inc @@ -1,13 +1,6 @@ <?php -/* - * Please, change user, password and dbase to match your configuration. - * - * */ - -$user = "system"; -$password = "system"; -$dbase = "oracle"; +include "details.inc"; /* * You should have privileges to create tables in this schema diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt index 513d60cef..840693476 100644 --- a/ext/oci8/tests/connect_without_oracle_home.phpt +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -1,7 +1,12 @@ --TEST-- oci_connect() without ORACLE_HOME set (OCIServerAttach() segfaults) --SKIPIF-- -<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +<?php +/* disabled for a while */ +die("skip"); + +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +?> --FILE-- <?php diff --git a/ext/oci8/tests/connect_without_oracle_home_old.phpt b/ext/oci8/tests/connect_without_oracle_home_old.phpt index 68b11de15..171ff45f5 100644 --- a/ext/oci8/tests/connect_without_oracle_home_old.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_old.phpt @@ -1,7 +1,11 @@ --TEST-- ocilogon() without ORACLE_HOME set (OCIServerAttach() segfaults) --SKIPIF-- -<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +<?php +/* disabled for a while */ +die("skip"); +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +?> --FILE-- <?php diff --git a/ext/oci8/tests/define2.phpt b/ext/oci8/tests/define2.phpt new file mode 100644 index 000000000..e8c5f8a99 --- /dev/null +++ b/ext/oci8/tests/define2.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test oci_define_by_name types +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmt = oci_parse($c, "create table phptestrawtable( id number(10), fileimage raw(1000))"); +oci_execute($stmt); + +$stmt = oci_parse ($c, "insert into phptestrawtable (id, fileimage) values (:id, :fileimage)"); +$i=1; +$fileimage = file_get_contents( dirname(__FILE__)."/test.gif"); +$fileimage = substr($fileimage, 0, 300); +var_dump(md5($fileimage)); + +oci_bind_by_name( $stmt, ":id", $i, -1); +oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_BIN); +oci_execute($stmt, OCI_DEFAULT); +oci_commit($c); + +echo "Test 1\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; +} + +echo "Test 2\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; +} + +echo "Test 3 - test repeatability\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_STR)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; +} + +echo "Test 4 - wrong type\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_RSET)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; +} + +$stmt = oci_parse($c, "drop table phptestrawtable"); +oci_execute($stmt); + +echo "Done\n"; +?> +--EXPECTF-- +string(32) "88b274d7a257ac6f70435b83abd4e26e" +Test 1 +bool(true) +string(300) "GIF89%s" +file md5:88b274d7a257ac6f70435b83abd4e26e +Test 2 +bool(true) +string(300) "GIF89%s" +file md5:88b274d7a257ac6f70435b83abd4e26e +Test 3 - test repeatability +bool(true) +string(600) "47494638396178004300E66A007F82B839374728252ACCCDE2A1A4CBD3D5E7B2B4D44342588386B98283B35252729092C2C2C4DEAAACD04C4B635B5C83DDDEEC3B383C6E71A56A6D9D61638D7579B17B7EB5E5E6F0999CC68C8DC1B9BAD96B6B924E4E6B7174A97A7AA3888BBD7274A37473988E90C15A5B7EE2E3EF7B7DADA4A5D06D70A27276AC9596C8BBBDD97478AE8588BB9295C3D8D9EA9292C46466926B6E9FA5A8CE9496C52E2B2F535168B3B4D76C6A8C5C5B768A8DBF666896686A9A9C9FC8312E39AEB0D39C9CCD5556789EA1CA9699C58182AF6769973F3D50BCBEDA5E60899899C88C8EBF898ABA57587CB6B7D7D5D7E8221E206C6F9ECED0E4BFC0DC777BB47678A75F5E7D9999CC6E6F987377AE221E1FFFFFFF908E8F595657C7C6C7EEEEF5D5D4D5F6F6" +file md5:80bb3201e2a8bdcb8ab3e1a44a82bb8a +Test 4 - wrong type +bool(true) + +Warning: oci_fetch(): ORA-00932: inconsistent datatypes%s on line %d +Done diff --git a/ext/oci8/tests/define3.phpt b/ext/oci8/tests/define3.phpt new file mode 100644 index 000000000..d30db637c --- /dev/null +++ b/ext/oci8/tests/define3.phpt @@ -0,0 +1,105 @@ +--TEST-- +Test oci_define_by_name() LOB descriptor +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmt = oci_parse($c, "create table phpdefblobtable( id number(10), fileimage blob)"); +oci_execute($stmt); + +// Load data +$stmt = oci_parse ($c, "insert into phpdefblobtable (id, fileimage) values (:id, empty_blob()) returning fileimage into :fileimage"); +$fileimage = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($stmt,":id",$id); +oci_bind_by_name($stmt,":fileimage",$fileimage,-1,OCI_B_BLOB); +$id = 1; +oci_execute($stmt, OCI_DEFAULT); +$fileimage->savefile(dirname(__FILE__)."/test.gif"); +$data = $fileimage->load(); +var_dump(md5($data)); // original md5 +oci_commit($c); + +// New row with different data +$id = 2; +$data = strrev($data); +var_dump(md5($data)); +oci_execute($stmt, OCI_DEFAULT); +$fileimage->save($data); +oci_commit($c); + +echo "Test 1\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $f)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($f); + echo "file md5:" . md5($f->load()) . "\n"; +} + +echo "Test 2\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_STR)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + echo "file md5:" . md5($outdata) . "\n"; +} + +echo "Test 3\n"; +$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_BIN)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + echo "file md5:" . md5($outdata) . "\n"; +} + +echo "Test 4\n"; +$fid = oci_new_descriptor($c,OCI_D_LOB); +$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable"); +var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fid)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + echo "file md5:" . md5($fid->load()) . "\n"; +} + +$stmt = oci_parse($c, "drop table phpdefblobtable"); +oci_execute($stmt); + +echo "Done\n"; + +?> +--EXPECTF-- +string(32) "614fcbba1effb7caa27ef0ef25c27fcf" +string(32) "06d4f219d946c74d748d43932cd9dcb2" +Test 1 +bool(true) +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +file md5:614fcbba1effb7caa27ef0ef25c27fcf +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +file md5:06d4f219d946c74d748d43932cd9dcb2 +Test 2 +bool(true) + +Warning: oci_fetch(): ORA-00932: %s on line %d +Test 3 +bool(true) +file md5:614fcbba1effb7caa27ef0ef25c27fcf +file md5:06d4f219d946c74d748d43932cd9dcb2 +Test 4 +bool(true) +file md5:614fcbba1effb7caa27ef0ef25c27fcf +file md5:06d4f219d946c74d748d43932cd9dcb2 +Done + diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt new file mode 100644 index 000000000..6fd9f5b93 --- /dev/null +++ b/ext/oci8/tests/define4.phpt @@ -0,0 +1,67 @@ +--TEST-- +oci_define_by_name() on partial number of columns +--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." (value, string) VALUES (1234, '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 value, string FROM ".$table_name.""); + +echo "Test 1\n"; +// Only one of the two columns is defined +var_dump(oci_define_by_name($stmt, "STRING", $string)); + +oci_execute($stmt); + +echo "Test 2\n"; + +while (oci_fetch($stmt)) { + var_dump(oci_result($stmt, 'VALUE')); + var_dump($string); + var_dump(oci_result($stmt, 'STRING')); + var_dump($string); + var_dump(oci_result($stmt, 'VALUE')); + var_dump(oci_result($stmt, 'STRING')); +} + +echo "Test 3\n"; +var_dump(oci_free_statement($stmt)); +var_dump($string); +var_dump(oci_result($stmt, 'STRING')); + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +bool(true) +Test 2 +string(4) "1234" +string(4) "some" +string(4) "some" +string(4) "some" +string(4) "1234" +string(4) "some" +Test 3 +bool(true) +string(4) "some" + +Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d +bool(false) +Done + diff --git a/ext/oci8/tests/define5.phpt b/ext/oci8/tests/define5.phpt new file mode 100644 index 000000000..c439b1d64 --- /dev/null +++ b/ext/oci8/tests/define5.phpt @@ -0,0 +1,64 @@ +--TEST-- +oci_define_by_name() for statement re-execution +--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." (id, string) VALUES (1, 'some')"; +$s = oci_parse($c, $insert_sql); +var_dump(oci_execute($s)); + +$insert_sql = "INSERT INTO ".$schema.$table_name." (id, string) VALUES (2, 'thing')"; +$s = oci_parse($c, $insert_sql); +var_dump(oci_execute($s)); + +echo "Test 1 - must do define before execute\n"; +$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1"); +oci_execute($stmt); +var_dump(oci_define_by_name($stmt, "STRING", $string)); +while (oci_fetch($stmt)) { + var_dump($string); // gives NULL + var_dump(oci_result($stmt, 'STRING')); +} + +echo "Test 2 - normal define order\n"; +$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1"); +var_dump(oci_define_by_name($stmt, "STRING", $string)); +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($string); +} + +echo "Test 3 - no new define done\n"; +$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 2"); +oci_execute($stmt); +while (oci_fetch($stmt)) { + var_dump($string); // not updated with new value + var_dump(oci_result($stmt, 'STRING')); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECT-- +bool(true) +bool(true) +Test 1 - must do define before execute +bool(true) +NULL +string(4) "some" +Test 2 - normal define order +bool(true) +string(4) "some" +Test 3 - no new define done +string(4) "some" +string(5) "thing" +Done + diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc new file mode 100644 index 000000000..6cf13ac72 --- /dev/null +++ b/ext/oci8/tests/details.inc @@ -0,0 +1,16 @@ +<?php + +/* +* Please, change user, password and dbase to match your configuration. +* +* */ + +$user = "system"; +$password = "system"; +$dbase = "oracle"; + +/* Set this variable to TRUE if Oracle is installed @ localhost */ + +$oracle_on_localhost = FALSE; + +?> diff --git a/ext/oci8/tests/error2.phpt b/ext/oci8/tests/error2.phpt new file mode 100644 index 000000000..13ea6cebe --- /dev/null +++ b/ext/oci8/tests/error2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Exercise error code for SUCCESS_WITH_INFO +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +ini_set('error_reporting', E_ALL); + +$s = oci_parse($c, "create or replace procedure myproc as begin bogus end;"); +$e = @oci_execute($s); +if (!$e) { + $es = oci_error($s); + echo $es['message']."\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +ORA-24344: success with compilation error +Done diff --git a/ext/oci8/tests/fetch_all2.phpt b/ext/oci8/tests/fetch_all2.phpt new file mode 100644 index 000000000..ff44cac70 --- /dev/null +++ b/ext/oci8/tests/fetch_all2.phpt @@ -0,0 +1,242 @@ +--TEST-- +oci_fetch_all() - 2 +--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." (id, value) VALUES (1,1)"; + +$s = oci_parse($c, $insert_sql); + +for ($i = 0; $i<3; $i++) { + oci_execute($s); +} + +oci_commit($c); + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +$s = oci_parse($c, $select_sql); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all)); +var_dump($all); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, 10, OCI_FETCHSTATEMENT_BY_ROW)); +var_dump($all); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all, -1, -1, OCI_FETCHSTATEMENT_BY_ROW)); +var_dump($all); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, 2, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM)); +var_dump($all); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, 2, OCI_NUM)); +var_dump($all); + +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, 1, OCI_BOTH)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +int(3) +array(5) { + ["ID"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + } + ["VALUE"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + } + ["BLOB"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["CLOB"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["STRING"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } +} +int(3) +array(3) { + [0]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } + [1]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } + [2]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } +} +int(0) +array(0) { +} +int(2) +array(2) { + [0]=> + array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL + } + [1]=> + array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL + } +} +int(2) +array(5) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } + [2]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } + [3]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } + [4]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } +} +int(1) +array(5) { + [0]=> + array(1) { + [0]=> + string(1) "1" + } + [1]=> + array(1) { + [0]=> + string(1) "1" + } + [2]=> + array(1) { + [0]=> + NULL + } + [3]=> + array(1) { + [0]=> + NULL + } + [4]=> + array(1) { + [0]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/fetch_all3.phpt b/ext/oci8/tests/fetch_all3.phpt new file mode 100644 index 000000000..503e5dd88 --- /dev/null +++ b/ext/oci8/tests/fetch_all3.phpt @@ -0,0 +1,577 @@ +--TEST-- +oci_fetch_all() - all combinations of flags +--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." (id, value) VALUES (:idbv,:vbv)"; + +$s = oci_parse($c, $insert_sql); +oci_bind_by_name($s, ":idbv", $idbv, SQLT_INT); +oci_bind_by_name($s, ":vbv", $vbv, SQLT_INT); + +for ($i = 1; $i <= 4; $i++) { + $idbv = $i; + $vbv = -$i; + oci_execute($s, OCI_DEFAULT); +} + +oci_commit($c); + +$select_sql = "SELECT ID, VALUE FROM ".$schema."".$table_name." order by id"; + +$s = oci_parse($c, $select_sql); + +echo "None\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1)); +var_dump($all); + +echo "OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_COLUMN\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM)); +var_dump($all); + +echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC)); +var_dump($all); + +echo "OCI_NUM\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM)); +var_dump($all); + +echo "OCI_NUM|OCI_ASSOC\n"; +oci_execute($s); +var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM|OCI_ASSOC)); +var_dump($all); +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +None +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_ASSOC +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +Done diff --git a/ext/oci8/tests/function_aliases.phpt b/ext/oci8/tests/function_aliases.phpt new file mode 100644 index 000000000..4c6ce8375 --- /dev/null +++ b/ext/oci8/tests/function_aliases.phpt @@ -0,0 +1,198 @@ +--TEST-- +Existence of old function aliases +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +var_dump(oci_free_cursor()); +var_dump(ocifreecursor()); +var_dump(ocibindbyname()); +var_dump(ocidefinebyname()); +var_dump(ocicolumnisnull()); +var_dump(ocicolumnname()); +var_dump(ocicolumnsize()); +var_dump(ocicolumnscale()); +var_dump(ocicolumnprecision()); +var_dump(ocicolumntype()); +var_dump(ocicolumntyperaw()); +var_dump(ociexecute()); +var_dump(ocicancel()); +var_dump(ocifetch()); +var_dump(ocifetchstatement()); +var_dump(ocifreestatement()); +var_dump(ociinternaldebug()); +var_dump(ocinumcols()); +var_dump(ociparse()); +var_dump(ocinewcursor()); +var_dump(ociresult()); +var_dump(ociserverversion()); +var_dump(ocistatementtype()); +var_dump(ocirowcount()); +var_dump(ocilogoff()); +var_dump(ocilogon()); +var_dump(ocinlogon()); +var_dump(ociplogon()); +var_dump(ocierror()); +var_dump(ocifreedesc()); +var_dump(ocisavelob()); +var_dump(ocisavelobfile()); +var_dump(ociwritelobtofile()); +var_dump(ociloadlob()); +var_dump(ocicommit()); +var_dump(ocirollback()); +var_dump(ocinewdescriptor()); +var_dump(ocisetprefetch()); +var_dump(ocipasswordchange()); +var_dump(ocifreecollection()); +var_dump(ocinewcollection()); +var_dump(ocicollappend()); +var_dump(ocicollgetelem()); +var_dump(ocicollassignelem()); +var_dump(ocicollsize()); +var_dump(ocicollmax()); +var_dump(ocicolltrim()); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_free_cursor() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocifreecursor() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocibindbyname() expects at least 3 parameters, 0 given in %s on line %d +NULL + +Warning: ocidefinebyname() expects at least 3 parameters, 0 given in %s on line %d +NULL + +Warning: ocicolumnisnull() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumnname() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumnsize() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumnscale() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumnprecision() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumntype() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ocicolumntyperaw() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ociexecute() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocicancel() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocifetch() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocifetchstatement() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocifreestatement() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ociinternaldebug() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocinumcols() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ociparse() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocinewcursor() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ociresult() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: ociserverversion() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocistatementtype() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocirowcount() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocilogoff() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocilogon() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocinlogon() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ociplogon() expects at least 2 parameters, 0 given in %s on line %d +NULL +bool(false) + +Warning: ocifreedesc() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocisavelob() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocisavelobfile() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ociwritelobtofile() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ociloadlob() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocicommit() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocirollback() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocinewdescriptor() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocisetprefetch() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: Wrong parameter count for ocipasswordchange() in %s on line %d +NULL + +Warning: ocifreecollection() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocinewcollection() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocicollappend() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocicollgetelem() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocicollassignelem() expects exactly 3 parameters, 0 given in %s on line %d +NULL + +Warning: ocicollsize() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocicollmax() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocicolltrim() expects exactly 2 parameters, 0 given in %s on line %d +NULL +Done diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt Binary files differindex edd0f0249..6564dede9 100644 --- a/ext/oci8/tests/lob_020.phpt +++ b/ext/oci8/tests/lob_020.phpt diff --git a/ext/oci8/tests/lob_027.phpt b/ext/oci8/tests/lob_027.phpt new file mode 100644 index 000000000..8b49b1ac5 --- /dev/null +++ b/ext/oci8/tests/lob_027.phpt @@ -0,0 +1,103 @@ +--TEST-- +oci_lob_truncate() +--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); + +$str = "this is a biiiig faaat test string. why are you reading it, I wonder? =)"; +var_dump($blob->write($str)); + +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)); +oci_commit($c); + +for ($i = 5; $i >= 0; $i--) { + + $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($row['BLOB']->load()); + var_dump($row['BLOB']->truncate(($i-1)*10)); + + 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($row['BLOB']->load()); +var_dump($row['BLOB']->truncate(-1)); +var_dump($row['BLOB']->truncate(0)); + +oci_commit($c); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(72) +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(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)" +bool(true) +string(40) "this is a biiiig faaat test string. why " +bool(true) +string(30) "this is a biiiig faaat test st" +bool(true) +string(20) "this is a biiiig faa" +bool(true) +string(10) "this is a " +bool(true) +string(0) "" + +Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +bool(false) +string(0) "" + +Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/oci8/tests/lob_028.phpt b/ext/oci8/tests/lob_028.phpt new file mode 100644 index 000000000..f049abdba --- /dev/null +++ b/ext/oci8/tests/lob_028.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test descriptor types for oci_new_descriptor() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Successful statements + +$d = oci_new_descriptor($c, OCI_D_FILE); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_DTYPE_FILE); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_D_LOB); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_DTYPE_LOB); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_D_ROWID); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_DTYPE_ROWID); +var_dump($d); + +// Unsuccessful statements + +$d = oci_new_descriptor($c, OCI_B_CLOB); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_B_CLOB); +var_dump($d); + +$d = oci_new_descriptor($c, OCI_DEFAULT); +var_dump($d); + +$d = oci_new_descriptor($c, 1); +var_dump($d); + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} + +Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d +NULL + +Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d +NULL + +Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d +NULL + +Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d +NULL +Done diff --git a/ext/oci8/tests/lob_029.phpt b/ext/oci8/tests/lob_029.phpt new file mode 100644 index 000000000..6c310981b --- /dev/null +++ b/ext/oci8/tests/lob_029.phpt @@ -0,0 +1,119 @@ +--TEST-- +reading/writing BFILE LOBs +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +include "details.inc"; +if (empty($oracle_on_localhost)) die("skip this test won't work with remote Oracle"); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$realdirname = dirname(__FILE__); +$realfilename1 = "oci8bfiletest1.txt"; +$fullname1 = $realdirname."/".$realfilename1; +$realfilename2 = "oci8bfiletest2.txt"; +$fullname2 = $realdirname."/".$realfilename2; +$realfilename3 = "oci8bfiletest3.txt"; +$fullname3 = $realdirname."/".$realfilename3; + +// Setup +$s = oci_parse($c, "create directory TestDir as '$realdirname'"); +oci_execute($s); + +file_put_contents($fullname1, 'Some text in the bfile 1'); +file_put_contents($fullname2, 'Some text in the bfile 2'); +file_put_contents($fullname3, 'Some text in the bfile 3'); + +$s = oci_parse($c, "create table FileTest (FileNum number, FileDesc varchar2(30), Image bfile)"); +oci_execute($s); + +$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (1, 'Description 1', bfilename('TESTDIR', '$realfilename1'))"); +oci_execute($s); + +$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename2'))"); +oci_execute($s); + +$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (3, 'Description 3', bfilename('TESTDIR', '$realfilename3'))"); +oci_execute($s); + +// Run tests + +echo "Test 1. Check how many rows in the table\n"; + +$s = oci_parse($c, "select count(*) numrows from FileTest"); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +echo "Test 2\n"; +$s = oci_parse($c, "select * from FileTest order by FileNum"); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +echo "Test 3\n"; +$d = oci_new_descriptor($c, OCI_D_FILE); + +$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename1')) returning Image into :im"); +oci_bind_by_name($s, ":im", $d, -1, OCI_B_BFILE); +oci_execute($s); + +$r = $d->read(40); +var_dump($r); + +unlink($fullname1); +unlink($fullname2); +unlink($fullname3); + +$s = oci_parse($c, "drop table FileTest"); +oci_execute($s); + +$s = oci_parse($c, "drop directory TestDir"); +oci_execute($s); + +echo "Done\n"; +?> +--EXPECTF-- +Test 1. Check how many rows in the table +array(1) { + ["NUMROWS"]=> + array(1) { + [0]=> + string(1) "3" + } +} +Test 2 +array(3) { + ["FILENUM"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + } + ["FILEDESC"]=> + array(3) { + [0]=> + string(13) "Description 1" + [1]=> + string(13) "Description 2" + [2]=> + string(13) "Description 3" + } + ["IMAGE"]=> + array(3) { + [0]=> + string(24) "Some text in the bfile 1" + [1]=> + string(24) "Some text in the bfile 2" + [2]=> + string(24) "Some text in the bfile 3" + } +} +Test 3 +string(24) "Some text in the bfile 1" +Done
\ No newline at end of file diff --git a/ext/oci8/tests/lob_030.phpt b/ext/oci8/tests/lob_030.phpt new file mode 100644 index 000000000..86b2956a5 --- /dev/null +++ b/ext/oci8/tests/lob_030.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +function insert_verify($c, $tn, $id, $length) +{ + // Insert the data + $ora_sql = "INSERT INTO + ".$tn." (id, clob) + VALUES (".$id.", empty_clob()) + RETURNING + clob + INTO :v_clob "; + + $statement = oci_parse($c,$ora_sql); + $clob = oci_new_descriptor($c,OCI_D_LOB); + oci_bind_by_name($statement,":v_clob", $clob, -1, OCI_B_CLOB); + oci_execute($statement, OCI_DEFAULT); + + $data = str_pad("x", $length, "x"); + $clob->write($data); + + // Verify the data + $select_sql = "SELECT clob FROM ".$tn." where id = ".$id; + $s = oci_parse($c, $select_sql); + oci_execute($s); + + $row = oci_fetch_array($s, OCI_RETURN_LOBS); + + var_dump(strlen($row[0])); +} + +echo "Test 1: A CLOB with an even number of bytes\n"; +insert_verify($c, $schema.$table_name, 1, 1050000); + +echo "Test 2: A CLOB with an odd number of bytes\n"; +insert_verify($c, $schema.$table_name, 2, 1050001); + +echo "Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)\n"; +insert_verify($c, $schema.$table_name, 3, 1048576); + +echo "Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)\n"; +insert_verify($c, $schema.$table_name, 4, 1049028); + +echo "Test 5: A CLOB of 1049028-1 bytes\n"; +insert_verify($c, $schema.$table_name, 5, 1049028-1); + +echo "Test 6: A CLOB of 1049028+1 bytes\n"; +insert_verify($c, $schema.$table_name, 6, 1049028+1); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1: A CLOB with an even number of bytes +int(1050000) +Test 2: A CLOB with an odd number of bytes +int(1050001) +Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation) +int(1048576) +Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code) +int(1049028) +Test 5: A CLOB of 1049028-1 bytes +int(1049027) +Test 6: A CLOB of 1049028+1 bytes +int(1049029) +Done diff --git a/ext/oci8/tests/lob_031.phpt b/ext/oci8/tests/lob_031.phpt new file mode 100644 index 000000000..a27d53bb3 --- /dev/null +++ b/ext/oci8/tests/lob_031.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data +--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->write("test"); +$blob->tell(); +$blob->seek(10, OCI_SEEK_CUR); +$blob->write("string"); +$blob->flush(); + +$select_sql = "SELECT blob FROM ".$schema.$table_name; +$s = oci_parse($c, $select_sql); +oci_execute($s); +$row = oci_fetch_array($s); + +$row[0]->read(3); +echo " 1. ".$row[0]->tell(). "\n"; + +$row[0]->read(3); +echo " 2. ".$row[0]->tell(). "\n"; + +$row[0]->read(3); +echo " 3. ".$row[0]->tell(). "\n"; + +$row[0]->read(6); +echo " 4. ".$row[0]->tell(). "\n"; + +$row[0]->read(4); +echo " 5. ".$row[0]->tell(). "\n"; + +// Read past end +$row[0]->read(5); +echo " 6. ".$row[0]->tell(). "\n"; + +$row[0]->read(1); +echo " 8. ".$row[0]->tell(). "\n"; + +// Now seek +$row[0]->seek(1); +echo " 9. ".$row[0]->tell(). "\n"; + +$row[0]->seek(8); +echo "10. ".$row[0]->tell(). "\n"; + +$row[0]->seek(20); +echo "11. ".$row[0]->tell(). "\n"; + +// Seek past end +$row[0]->seek(25); +echo "12. ".$row[0]->tell(). "\n"; + +// Seek past end +$row[0]->seek(2, OCI_SEEK_SET); +echo "13. ".$row[0]->tell(). "\n"; + +// Move on 2 more +$row[0]->seek(2, OCI_SEEK_CUR); +echo "14. ".$row[0]->tell(). "\n"; + +// Move 3 past the end +$row[0]->seek(3, OCI_SEEK_END); +echo "15. ".$row[0]->tell(). "\n"; + +// Move 4 before the end +$row[0]->seek(-4, OCI_SEEK_END); +echo "16. ".$row[0]->tell(). "\n"; + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- + 1. 3 + 2. 6 + 3. 9 + 4. 15 + 5. 19 + 6. 20 + 8. 20 + 9. 1 +10. 8 +11. 20 +12. 25 +13. 2 +14. 4 +15. 23 +16. 16 +Done diff --git a/ext/oci8/tests/lob_032.phpt b/ext/oci8/tests/lob_032.phpt new file mode 100644 index 000000000..5d6ff6ec9 --- /dev/null +++ b/ext/oci8/tests/lob_032.phpt @@ -0,0 +1,33 @@ +--TEST-- +oci_lob_write() and friends +--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." (id, clob) + VALUES (2, empty_clob()) + RETURNING + clob + INTO :v_clob "; + +$statement = oci_parse($c,$ora_sql); +$clob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_clob", $clob,-1,OCI_B_CLOB); +oci_execute($statement, OCI_DEFAULT); + +oci_commit($c); // This will cause subsequent ->write() to fail +$clob->write("data"); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: OCI-Lob::write(): ORA-22990: %s in %s on line 19 +Done diff --git a/ext/oci8/tests/lob_033.phpt b/ext/oci8/tests/lob_033.phpt new file mode 100644 index 000000000..5647cd9a4 --- /dev/null +++ b/ext/oci8/tests/lob_033.phpt @@ -0,0 +1,38 @@ +--TEST-- +various oci_lob_write() error messages +--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." (id, blob) + VALUES (2, empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); + +$blob->save(""); + +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob->save("")); +var_dump($blob->save("data", 100)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in %s on line %d +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/lob_034.phpt b/ext/oci8/tests/lob_034.phpt new file mode 100644 index 000000000..6bf4058e7 --- /dev/null +++ b/ext/oci8/tests/lob_034.phpt @@ -0,0 +1,50 @@ +--TEST-- +lob buffering - 2 +--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->getBuffering()); +var_dump($blob->setBuffering(false)); +var_dump($blob->setBuffering(false)); +var_dump($blob->setBuffering(true)); +var_dump($blob->setBuffering(true)); +var_dump($blob->flush()); +var_dump($blob->flush(0)); +var_dump($blob->flush(-1)); + +oci_commit($c); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: OCI-Lob::flush(): Invalid flag value: -1 in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/lob_035.phpt b/ext/oci8/tests/lob_035.phpt new file mode 100644 index 000000000..6e1f5a735 --- /dev/null +++ b/ext/oci8/tests/lob_035.phpt @@ -0,0 +1,108 @@ +--TEST-- +oci_lob_copy() - 2 +--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." (id, blob) + VALUES (1, 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->write("some string here. string, I said")); +oci_commit($c); + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (id, blob) + VALUES (2, 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); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1"; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row1 = oci_fetch_array($s); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row2 = oci_fetch_array($s); + +$dummy = oci_new_descriptor($c, OCI_D_LOB); + +var_dump(oci_lob_copy($dummy, $row1[0])); +var_dump(oci_lob_copy($row2[0], $dummy)); + +var_dump(oci_lob_copy($row2[0], $row1[0], 0)); +var_dump(oci_lob_copy($row2[0], $row1[0], -1)); +var_dump(oci_lob_copy($row2[0], $row1[0], 100000)); + +var_dump(oci_lob_size()); +var_dump(oci_lob_size($row2[0])); +unset($dummy->descriptor); +var_dump(oci_lob_size($dummy)); + +oci_rollback($c); +oci_rollback($c); +oci_commit($c); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +int(32) + +Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d +bool(false) + +Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d +bool(false) +bool(false) + +Warning: oci_lob_copy(): Length parameter must be greater than 0 in %s on line %d +bool(false) +bool(true) + +Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d +NULL +int(0) + +Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d +bool(false) +array(2) { + [0]=> + string(0) "" + ["BLOB"]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/lob_036.phpt b/ext/oci8/tests/lob_036.phpt new file mode 100644 index 000000000..e72c1cf08 --- /dev/null +++ b/ext/oci8/tests/lob_036.phpt @@ -0,0 +1,40 @@ +--TEST-- +Exercise cleanup code when LOB buffering is on +--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 "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); + +var_dump($blob->write("test")); +var_dump($blob->setBuffering(true)); +var_dump($blob->write("test")); + +$blob = null; + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(4) +bool(true) +int(4) +Done diff --git a/ext/oci8/tests/lob_037.phpt b/ext/oci8/tests/lob_037.phpt new file mode 100644 index 000000000..228f5e812 --- /dev/null +++ b/ext/oci8/tests/lob_037.phpt @@ -0,0 +1,68 @@ +--TEST-- +Fetching two different lobs and using them after fetch +--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 the first LOB */ +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); + +var_dump($blob->write("first lob data")); +oci_commit($c); + +/* insert the second LOB */ +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); + +var_dump($blob->write("second lob data")); +oci_commit($c); + +/* select both */ + +$ora_sql = "SELECT blob FROM ".$schema.$table_name; +$s = oci_parse($c,$ora_sql); +oci_execute($s, OCI_DEFAULT); + +$rows = array(); +$rows[0] = oci_fetch_assoc($s); +$rows[1] = oci_fetch_assoc($s); + +var_dump($rows[0]['BLOB']->read(1000)); +var_dump($rows[1]['BLOB']->read(1000)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(14) +int(15) +string(14) "first lob data" +string(15) "second lob data" +Done diff --git a/ext/oci8/tests/lob_038.phpt b/ext/oci8/tests/lob_038.phpt new file mode 100644 index 000000000..91dac66c0 --- /dev/null +++ b/ext/oci8/tests/lob_038.phpt @@ -0,0 +1,189 @@ +--TEST-- +Array fetch CLOB and BLOB +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +echo "Test 1: CLOB\n"; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (clob) + VALUES (empty_clob()) + RETURNING + clob + INTO :v_clob "; + +$s = oci_parse($c,$ora_sql); +$clob = oci_new_descriptor($c,OCI_DTYPE_LOB); + + +oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("clob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("clob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("clob test 3")); + + +$s = oci_parse($c,"select clob from ".$schema.$table_name); +var_dump(oci_execute($s)); + +oci_fetch_all($s, $res); + +var_dump($res); + + +echo "Test 1b\n"; + +$s = oci_parse($c, "select clob from ".$schema.$table_name); +var_dump(oci_execute($s, OCI_DEFAULT)); +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); + $result = $row['CLOB']->load(); + var_dump($result); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Test 2: BLOB\n"; + +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 3")); + +$s = oci_parse($c, "select blob from ".$schema.$table_name); +var_dump(oci_execute($s)); +oci_fetch_all($s, $res); +var_dump($res); + +echo "Test 2b\n"; + +$s = oci_parse($c, "select blob from ".$schema.$table_name); +var_dump(oci_execute($s, OCI_DEFAULT)); +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); + $result = $row['BLOB']->load(); + var_dump($result); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1: CLOB +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + ["CLOB"]=> + array(3) { + [0]=> + string(11) "clob test 1" + [1]=> + string(11) "clob test 2" + [2]=> + string(11) "clob test 3" + } +} +Test 1b +bool(true) +array(1) { + ["CLOB"]=> + object(OCI-Lob)#2 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 1" +array(1) { + ["CLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 2" +array(1) { + ["CLOB"]=> + object(OCI-Lob)#2 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 3" +Test 2: BLOB +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + ["BLOB"]=> + array(3) { + [0]=> + string(11) "blob test 1" + [1]=> + string(11) "blob test 2" + [2]=> + string(11) "blob test 3" + } +} +Test 2b +bool(true) +array(1) { + ["BLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 1" +array(1) { + ["BLOB"]=> + object(OCI-Lob)#4 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 2" +array(1) { + ["BLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 3" +Done
\ No newline at end of file diff --git a/ext/oci8/tests/lob_039.phpt b/ext/oci8/tests/lob_039.phpt new file mode 100644 index 000000000..93251c8d8 --- /dev/null +++ b/ext/oci8/tests/lob_039.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test CLOB->write() for multiple inserts +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +echo "Test 1: CLOB\n"; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (clob) + VALUES (empty_clob()) + RETURNING + clob + INTO :v_clob "; + +$s = oci_parse($c,$ora_sql); +$clob = oci_new_descriptor($c,OCI_DTYPE_LOB); + + +oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->write("clob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->write("clob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->write("clob test 3")); + +$s = oci_parse($c,"select clob from ".$schema.$table_name); +var_dump(oci_execute($s)); + +oci_fetch_all($s, $res); + +var_dump($res); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +Test 1: CLOB +int(11) +int(11) +int(11) +bool(true) +array(1) { + ["CLOB"]=> + array(3) { + [0]=> + string(11) "clob test 1" + [1]=> + string(11) "clob test 2" + [2]=> + string(11) "clob test 3" + } +} +Done diff --git a/ext/oci8/tests/lob_aliases.phpt b/ext/oci8/tests/lob_aliases.phpt new file mode 100644 index 000000000..faa59bf12 --- /dev/null +++ b/ext/oci8/tests/lob_aliases.phpt @@ -0,0 +1,99 @@ +--TEST-- +LOB method aliases +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +// Function existence +echo "Test 1\n"; +var_dump(oci_lob_load()); +var_dump(oci_lob_tell()); +var_dump(oci_lob_truncate()); +var_dump(oci_lob_erase()); +var_dump(oci_lob_flush()); +var_dump(ocisetbufferinglob()); +var_dump(ocigetbufferinglob()); +var_dump(oci_lob_rewind()); +var_dump(oci_lob_read()); +var_dump(oci_lob_eof()); +var_dump(oci_lob_seek()); +var_dump(oci_lob_write()); +var_dump(oci_lob_append()); +var_dump(oci_lob_size()); +var_dump(oci_lob_export()); +var_dump(oci_lob_export()); +var_dump(oci_lob_import()); +// No PHP_FE for oci_lob_write_temporary() or oci_lob_close() +//var_dump(oci_lob_write_temporary()); +//var_dump(oci_lob_close()); +var_dump(oci_lob_save()); +var_dump(oci_lob_import()); +var_dump(oci_free_descriptor()); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 + +Warning: oci_lob_load() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_tell() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_truncate() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_erase() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_flush() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocisetbufferinglob() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ocigetbufferinglob() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_rewind() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_read() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_eof() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_seek() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_write() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_append() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_export() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_export() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_import() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_save() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_import() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_free_descriptor() expects exactly 1 parameter, 0 given in %s on line %d +NULL +Done diff --git a/ext/oci8/tests/num.phpt b/ext/oci8/tests/num.phpt index 3c333b4e3..458e3774f 100644 --- a/ext/oci8/tests/num.phpt +++ b/ext/oci8/tests/num.phpt @@ -8,32 +8,117 @@ oci_num_*() family require dirname(__FILE__)."/connect.inc"; require dirname(__FILE__).'/create_table.inc'; +echo "Test 1\n"; +var_dump(ocirowcount()); +var_dump(oci_num_rows()); +var_dump(ocinumcols()); +var_dump(oci_num_fields()); + $insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } +echo "Test 2\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + for ($i = 0; $i<3; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } +echo "Test 3\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } +echo "Test 4\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + +// All rows $select_sql = "SELECT * FROM ".$schema.$table_name.""; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); +} + +echo "Test 5a\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +echo "Test 5b\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + + +if (oci_fetch_all($s,$r) === false) { + die("oci_fetch_all(select) failed!\n"); +} + +echo "Test 5c\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + +// One row +$select_sql = "SELECT id, value FROM ".$schema.$table_name." WHERE ROWNUM < 2"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +if (oci_fetch_all($s,$r) === false) { + die("oci_fetch_all(select) failed!\n"); +} + +echo "Test 6\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + +// No rows +$select_sql = "SELECT id FROM ".$schema.$table_name." WHERE 1=0"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); +} + +if (oci_fetch_all($s,$r) === false) { + die("oci_fetch_all(select) failed!\n"); } +echo "Test 7\n"; var_dump(ocirowcount($s)); var_dump(oci_num_rows($s)); var_dump(ocinumcols($s)); @@ -48,19 +133,89 @@ if (!($s = oci_parse($c, $delete_sql))) { if (!oci_execute($s)) { die("oci_execute(delete) failed!\n"); } + +echo "Test 8a\n"; +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + + oci_commit($c); +echo "Test 8b\n"; +var_dump(ocirowcount($s)); var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); require dirname(__FILE__).'/drop_table.inc'; echo "Done\n"; ?> ---EXPECT-- +--EXPECTF-- +Test 1 + +Warning: ocirowcount() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_num_rows() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: ocinumcols() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_num_fields() expects exactly 1 parameter, 0 given in %s on line %d +NULL +Test 2 +int(0) int(0) int(0) +int(0) +Test 3 +int(1) +int(1) +int(0) +int(0) +Test 4 +int(1) +int(1) +int(0) +int(0) +Test 5a +int(0) +int(0) +int(0) +int(0) +Test 5b +int(0) +int(0) +int(5) +int(5) +Test 5c +int(3) +int(3) int(5) int(5) +Test 6 +int(1) +int(1) +int(2) +int(2) +Test 7 +int(0) +int(0) +int(1) +int(1) +Test 8a +int(3) int(3) +int(0) +int(0) +Test 8b +int(3) +int(3) +int(0) +int(0) Done diff --git a/ext/oci8/tests/oci_execute_segfault.phpt b/ext/oci8/tests/oci_execute_segfault.phpt index 3859f4ffe..9ba7d770f 100644 --- a/ext/oci8/tests/oci_execute_segfault.phpt +++ b/ext/oci8/tests/oci_execute_segfault.phpt @@ -1,30 +1,48 @@ --TEST-- -oci_execute() segfault after repeated bind +oci_execute() segfault after repeated bind of LOB descriptor --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 - ".$table_name." (blob, clob) + ".$schema.$table_name." (blob, clob) VALUES (empty_blob(), empty_clob()) RETURNING blob INTO :v_blob "; -$s = oci_parse($c,$ora_sql); -$blob = oci_new_descriptor($c,OCI_D_LOB); -oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); -oci_execute($s); +$s = oci_parse($c, $ora_sql); +$blob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ":v_blob", $blob, -1, OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("some binary data")); + +oci_bind_by_name($s, ":v_blob", $blob, -1, OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("some more binary data")); + +$query = 'SELECT blob, DBMS_LOB.GETLENGTH(blob) FROM '.$schema.$table_name.' ORDER BY 2'; + +$s = oci_parse ($c, $query); +oci_execute($s, OCI_DEFAULT); + +while ($arr = oci_fetch_assoc($s)) { + $result = $arr['BLOB']->load(); + var_dump($result); +} -oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); -oci_execute($s); +require dirname(__FILE__).'/drop_table.inc'; echo "Done\n"; ?> --EXPECT-- +bool(true) +bool(true) +string(16) "some binary data" +string(21) "some more binary data" Done diff --git a/ext/oci8/tests/pecl_bug10194.phpt b/ext/oci8/tests/pecl_bug10194.phpt new file mode 100644 index 000000000..1b937c490 --- /dev/null +++ b/ext/oci8/tests/pecl_bug10194.phpt @@ -0,0 +1,47 @@ +--TEST-- +PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +memory_limit=10M +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (clob) + VALUES (empty_clob()) + "; + +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$ora_sql = "SELECT clob FROM ".$schema.$table_name." FOR UPDATE"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$string = str_repeat("test", 32768*4*4); + +for ($i = 0; $i < 8; $i++) { + $row['CLOB']->write($string); +} + +oci_commit($c); + +$ora_sql = "SELECT clob FROM ".$schema.$table_name.""; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$row = oci_fetch_assoc($statement); +var_dump(strlen($row['CLOB']->load())); /* here it should fail */ + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Allowed memory size of 10485760 bytes exhausted at %s:%d (tried to allocate %d bytes) in %s on line %d diff --git a/ext/oci8/tests/pecl_bug10194_blob.phpt b/ext/oci8/tests/pecl_bug10194_blob.phpt new file mode 100644 index 000000000..4e7be26c7 --- /dev/null +++ b/ext/oci8/tests/pecl_bug10194_blob.phpt @@ -0,0 +1,47 @@ +--TEST-- +PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +memory_limit=10M +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + "; + +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$ora_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$string = str_repeat("test", 32768*4*4); + +for ($i = 0; $i < 8; $i++) { + $row['BLOB']->write($string); +} + +oci_commit($c); + +$ora_sql = "SELECT blob FROM ".$schema.$table_name.""; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement); + +$row = oci_fetch_assoc($statement); +var_dump(strlen($row['BLOB']->load())); /* here it should fail */ + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes) in %s on line %d diff --git a/ext/oci8/tests/privileged_connect1.phpt b/ext/oci8/tests/privileged_connect1.phpt index a05a21093..44bb2f60a 100644 --- a/ext/oci8/tests/privileged_connect1.phpt +++ b/ext/oci8/tests/privileged_connect1.phpt @@ -17,9 +17,9 @@ oci_connect("", "", "", false, "qwe"); echo "Done\n"; ?> --EXPECTF-- -Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d +Warning: oci_connect(): ORA-%d: %s in %s on line %d -Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d +Warning: oci_connect(): ORA-%d: %s in %s on line %d Warning: oci_connect(): Invalid session mode specified (-1) in %s on line %d diff --git a/ext/oci8/tests/statement_type.phpt b/ext/oci8/tests/statement_type.phpt index 45221a6c7..29cdd9440 100644 --- a/ext/oci8/tests/statement_type.phpt +++ b/ext/oci8/tests/statement_type.phpt @@ -7,22 +7,20 @@ oci_statement_type() require dirname(__FILE__)."/connect.inc"; -if (!empty($dbase)) { - var_dump($c = oci_connect($user, $password, $dbase)); -} -else { - var_dump($c = oci_connect($user, $password)); -} - $sqls = Array( - "SELECT * FROM table", - "DELETE FROM table WHERE id = 1", - "INSERT INTO table VALUES(1)", - "UPDATE table SET id = 1", + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", "DROP TABLE table", - "CREATE TABLE table (id NUMBER)", - "WRONG SYNTAX", - "" + "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", + "CREATE TABLE table (id NUMBER)", + "ALTER TABLE table ADD (col1 NUMBER)", + "BEGIN NULL; END;", + "DECLARE myn NUMBER BEGIN myn := 1; END;", + "CALL myproc(1)", + "WRONG SYNTAX", + "" ); foreach ($sqls as $sql) { @@ -34,13 +32,17 @@ echo "Done\n"; ?> --EXPECTF-- -resource(%d) of type (oci8 connection) string(6) "SELECT" string(6) "DELETE" string(6) "INSERT" string(6) "UPDATE" string(4) "DROP" string(6) "CREATE" +string(6) "CREATE" +string(5) "ALTER" +string(5) "BEGIN" +string(7) "DECLARE" +string(4) "CALL" string(7) "UNKNOWN" string(7) "UNKNOWN" Done diff --git a/ext/oci8/tests/statement_type_old.phpt b/ext/oci8/tests/statement_type_old.phpt index 13da41bf7..2626d6203 100644 --- a/ext/oci8/tests/statement_type_old.phpt +++ b/ext/oci8/tests/statement_type_old.phpt @@ -15,14 +15,19 @@ else { } $sqls = Array( - "SELECT * FROM table", - "DELETE FROM table WHERE id = 1", - "INSERT INTO table VALUES(1)", - "UPDATE table SET id = 1", + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", "DROP TABLE table", - "CREATE TABLE table (id NUMBER)", - "WRONG SYNTAX", - "" + "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", + "CREATE TABLE table (id NUMBER)", + "ALTER TABLE table ADD (col1 NUMBER)", + "BEGIN NULL; END;", + "DECLARE myn NUMBER BEGIN myn := 1; END;", + "CALL myproc(1)", + "WRONG SYNTAX", + "" ); foreach ($sqls as $sql) { @@ -41,6 +46,11 @@ string(6) "INSERT" string(6) "UPDATE" string(4) "DROP" string(6) "CREATE" +string(6) "CREATE" +string(5) "ALTER" +string(5) "BEGIN" +string(7) "DECLARE" +string(4) "CALL" string(7) "UNKNOWN" string(7) "UNKNOWN" Done |
