diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/oci8/tests | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/oci8/tests')
329 files changed, 32382 insertions, 0 deletions
diff --git a/ext/oci8/tests/array_bind_001.phpt b/ext/oci8/tests/array_bind_001.phpt new file mode 100644 index 0000000..6a3746c --- /dev/null +++ b/ext/oci8/tests/array_bind_001.phpt @@ -0,0 +1,69 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 1 +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = ""; + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): OCI-21560: argument 3 is null, invalid, or out of range in %s on line %d + +Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d +array(1) { + [0]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_002.phpt b/ext/oci8/tests/array_bind_002.phpt new file mode 100644 index 0000000..82b57dc --- /dev/null +++ b/ext/oci8/tests/array_bind_002.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 2 +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Maximum array length must be greater than zero in %s on line %d + +Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d +array(5) { + [0]=> + string(9) "06-DEC-05" + [1]=> + string(9) "10-DEC-80" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "26-OCT-17" + [4]=> + string(9) "05-NOV-05" +} +Done diff --git a/ext/oci8/tests/array_bind_003.phpt b/ext/oci8/tests/array_bind_003.phpt new file mode 100644 index 0000000..0875c69 --- /dev/null +++ b/ext/oci8/tests/array_bind_003.phpt @@ -0,0 +1,78 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 3 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): ORA-01403: %s +ORA-06512: at "SYSTEM.ARRAYBINDPKG1", line %d +ORA-06512: at line %d in %sarray_bind_003.php on line %d +array(4) { + [0]=> + string(9) "06-DEC-05" + [1]=> + string(9) "10-DEC-80" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "26-OCT-17" +} +Done diff --git a/ext/oci8/tests/array_bind_004.phpt b/ext/oci8/tests/array_bind_004.phpt new file mode 100644 index 0000000..df74025 --- /dev/null +++ b/ext/oci8/tests/array_bind_004.phpt @@ -0,0 +1,70 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 4 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): ORA-01403: %s +ORA-06512: at "SYSTEM.ARRAYBINDPKG1", line %d +ORA-06512: at line %d in %sarray_bind_004.php on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_005.phpt b/ext/oci8/tests/array_bind_005.phpt new file mode 100644 index 0000000..eaa3c4e --- /dev/null +++ b/ext/oci8/tests/array_bind_005.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 5 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("", "", "", "", ""); + +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(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_006.phpt b/ext/oci8/tests/array_bind_006.phpt new file mode 100644 index 0000000..f13aca3 --- /dev/null +++ b/ext/oci8/tests/array_bind_006.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name(), SQLT_CHR and default max_length +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/array_bind_007.phpt b/ext/oci8/tests/array_bind_007.phpt new file mode 100644 index 0000000..c926bc0 --- /dev/null +++ b/ext/oci8/tests/array_bind_007.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 7 +--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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, -1); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: -1 in %s on line %d + +Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) +} +Done diff --git a/ext/oci8/tests/array_bind_008.phpt b/ext/oci8/tests/array_bind_008.phpt new file mode 100644 index 0000000..df2c35c --- /dev/null +++ b/ext/oci8/tests/array_bind_008.phpt @@ -0,0 +1,81 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 8 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): ORA-06550: line %d, column %d: +PLS-00418: %s +ORA-06550: %s +PL/SQL: %s +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" +} +Done diff --git a/ext/oci8/tests/array_bind_009.phpt b/ext/oci8/tests/array_bind_009.phpt new file mode 100644 index 0000000..8e83b09 --- /dev/null +++ b/ext/oci8/tests/array_bind_009.phpt @@ -0,0 +1,17 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 9 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +var_dump(oci_bind_array_by_name($c, ":c1", $array, 5, 5, SQLT_CHR)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/array_bind_010.phpt b/ext/oci8/tests/array_bind_010.phpt new file mode 100644 index 0000000..ede82c9 --- /dev/null +++ b/ext/oci8/tests/array_bind_010.phpt @@ -0,0 +1,36 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 8 +--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 all_objects'); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): ORA-01036: illegal variable name/number in %s on line %d +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" +} +Done diff --git a/ext/oci8/tests/array_bind_011.phpt b/ext/oci8/tests/array_bind_011.phpt new file mode 100644 index 0000000..9f43d1a --- /dev/null +++ b/ext/oci8/tests/array_bind_011.phpt @@ -0,0 +1,67 @@ +--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'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d + +Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_012.phpt b/ext/oci8/tests/array_bind_012.phpt new file mode 100644 index 0000000..38e1701 --- /dev/null +++ b/ext/oci8/tests/array_bind_012.phpt @@ -0,0 +1,26 @@ +--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 all_objects'); + +$array = array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -10, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Invalid max length value (-10) in %s on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_013.phpt b/ext/oci8/tests/array_bind_013.phpt new file mode 100644 index 0000000..4da9d8b --- /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/array_bind_014.phpt b/ext/oci8/tests/array_bind_014.phpt new file mode 100644 index 0000000..9ab0236 --- /dev/null +++ b/ext/oci8/tests/array_bind_014.phpt @@ -0,0 +1,76 @@ +--TEST-- +oci_bind_array_by_name() and NUMBERs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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_bdouble.phpt b/ext/oci8/tests/array_bind_bdouble.phpt new file mode 100644 index 0000000..fb17365 --- /dev/null +++ b/ext/oci8/tests/array_bind_bdouble.phpt @@ -0,0 +1,22 @@ +--TEST-- +Unsupported type: oci_bind_array_by_name() and SQLT_BDOUBLE +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (!defined('SQLT_BDOUBLE')) die('skip SQLT_BDOUBLE type not available on older Oracle clients'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_BDOUBLE); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: 22 in %sarray_bind_bdouble.php on line %d +Done diff --git a/ext/oci8/tests/array_bind_bfloat.phpt b/ext/oci8/tests/array_bind_bfloat.phpt new file mode 100644 index 0000000..fdd4395 --- /dev/null +++ b/ext/oci8/tests/array_bind_bfloat.phpt @@ -0,0 +1,22 @@ +--TEST-- +Unsupported type: oci_bind_array_by_name() and SQLT_BFLOAT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (!defined('SQLT_BFLOAT')) die('skip SQLT_BFLOAT type not available on older Oracle clients'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_BFLOAT); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: 21 in %sarray_bind_bfloat.php on line %d +Done diff --git a/ext/oci8/tests/array_bind_date.phpt b/ext/oci8/tests/array_bind_date.phpt new file mode 100644 index 0000000..926d7cf --- /dev/null +++ b/ext/oci8/tests/array_bind_date.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_ODT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(9) "05-NOV-05" + [1]=> + string(9) "26-OCT-17" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "10-DEC-80" + [4]=> + string(9) "06-DEC-05" +} +Done diff --git a/ext/oci8/tests/array_bind_date1.phpt b/ext/oci8/tests/array_bind_date1.phpt new file mode 100644 index 0000000..c8c1f1a --- /dev/null +++ b/ext/oci8/tests/array_bind_date1.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_ODT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(9) "05-NOV-05" + [1]=> + string(9) "26-OCT-17" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "10-DEC-80" + [4]=> + string(9) "06-DEC-05" +} +Done diff --git a/ext/oci8/tests/array_bind_float.phpt b/ext/oci8/tests/array_bind_float.phpt new file mode 100644 index 0000000..5246f63 --- /dev/null +++ b/ext/oci8/tests/array_bind_float.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_FLT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 FLOAT)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF FLOAT 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_FLT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + float(5.9999) + [1]=> + float(4.2123) + [2]=> + float(3.4234) + [3]=> + float(2.5658) + [4]=> + float(1.243) +} +Done diff --git a/ext/oci8/tests/array_bind_float1.phpt b/ext/oci8/tests/array_bind_float1.phpt new file mode 100644 index 0000000..53b551f --- /dev/null +++ b/ext/oci8/tests/array_bind_float1.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_FLT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 FLOAT)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF FLOAT 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_FLT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + float(5.9999) + [1]=> + float(4.2123) + [2]=> + float(3.4234) + [3]=> + float(2.5658) + [4]=> + float(1.243) +} +Done diff --git a/ext/oci8/tests/array_bind_int.phpt b/ext/oci8/tests/array_bind_int.phpt new file mode 100644 index 0000000..2f34979 --- /dev/null +++ b/ext/oci8/tests/array_bind_int.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_INT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_NUM); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +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 new file mode 100644 index 0000000..49fea2a --- /dev/null +++ b/ext/oci8/tests/array_bind_int1.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_INT +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$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_INT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +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_str.phpt b/ext/oci8/tests/array_bind_str.phpt new file mode 100644 index 0000000..87291bd --- /dev/null +++ b/ext/oci8/tests/array_bind_str.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_CHR +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/array_bind_str1.phpt b/ext/oci8/tests/array_bind_str1.phpt new file mode 100644 index 0000000..3f60ee8 --- /dev/null +++ b/ext/oci8/tests/array_bind_str1.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_CHR +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/array_bind_uin.phpt b/ext/oci8/tests/array_bind_uin.phpt new file mode 100644 index 0000000..3ce039e --- /dev/null +++ b/ext/oci8/tests/array_bind_uin.phpt @@ -0,0 +1,21 @@ +--TEST-- +Unsupported type: oci_bind_array_by_name() and SQLT_UIN +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_UIN); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: 68 in %sarray_bind_uin.php on line %d +Done diff --git a/ext/oci8/tests/b47243_1.phpt b/ext/oci8/tests/b47243_1.phpt new file mode 100644 index 0000000..2911229 --- /dev/null +++ b/ext/oci8/tests/b47243_1.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #47243 (Crash on exit with ZTS mode) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +$s = oci_parse($c, "select cursor(select dummy from dual) from dual"); +oci_execute($s); +oci_fetch_all($s, $r); + +// No explicit free or close + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +===DONE=== diff --git a/ext/oci8/tests/b47243_2.phpt b/ext/oci8/tests/b47243_2.phpt new file mode 100644 index 0000000..ae96953 --- /dev/null +++ b/ext/oci8/tests/b47243_2.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #47243 (Crash on exit with ZTS mode) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +$s = oci_parse($c, "select cursor(select dummy from dual) from dual"); +oci_execute($s); +oci_fetch_all($s, $r); + +oci_free_statement($s); +// no explicit close + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +===DONE=== diff --git a/ext/oci8/tests/b47243_3.phpt b/ext/oci8/tests/b47243_3.phpt new file mode 100644 index 0000000..cc57c20 --- /dev/null +++ b/ext/oci8/tests/b47243_3.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #47243 (Crash on exit with ZTS mode) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +$s = oci_parse($c, "select cursor(select dummy from dual) from dual"); +oci_execute($s); +oci_fetch_all($s, $r); + +// With explicit free and close +oci_free_statement($s); +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +===DONE=== diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt new file mode 100644 index 0000000..91fa4b7 --- /dev/null +++ b/ext/oci8/tests/bind_char_1.phpt @@ -0,0 +1,301 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); + } +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", + "insert into bind_char_tab values (1, 'abc', NULL)", + "insert into bind_char_tab values (2, NULL, 'abc')", + "insert into bind_char_tab values (3, NULL, 'abc ')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "*** Non-null Data Tests against CHAR***\n"; + +$bv1 = 'abc'; + +echo "Test 1.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 1.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "\n\n*** NULL data tests against CHAR ***\n"; + +$bv1 = null; + +echo "Test 2.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 2.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +echo "\n\n*** Non-null Data Tests against VARCHAR2***\n"; + +$bv1 = 'abc'; + +echo "Test 3.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 3.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +echo "\n\n*** NULL data tests against VARCHAR2 ***\n"; + +$bv1 = null; + +echo "Test 4.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 4.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + + +function do_e_q($s) +{ + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } +} + +// Cleanup +$stmtarray = array( + "drop table bind_char_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +*** Non-null Data Tests against CHAR*** +Test 1.1: Type: default. Length: default + Querying: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :abc : + :: +Test 1.3: Type: AFC: Length: 0 + Querying: + :1: + :abc : + :: +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :abc : + :: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + :1: + :abc : + :: +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :abc : + :: + + +*** NULL data tests against CHAR *** +Test 2.1: Type: default. Length: default + Querying: +Test 2.2: Type: AFC. Length: default + Querying: +Test 2.3: Type: AFC: Length: 0 + Querying: +Test 2.4: Type: AFC: Length: strlen + Querying: +Test 2.5: Type: AFC. Length: strlen-1 + Querying: +Test 2.6: Type: AFC. Length: strlen+1 + Querying: + + +*** Non-null Data Tests against VARCHAR2*** +Test 3.1: Type: default. Length: default + Querying: + :2: + :: + :abc: +Test 3.2: Type: AFC. Length: default + Querying: + :2: + :: + :abc: +Test 3.3: Type: AFC: Length: 0 + Querying: + :2: + :: + :abc: +Test 3.4: Type: AFC: Length: strlen + Querying: + :2: + :: + :abc: +Test 3.5: Type: AFC. Length: strlen-1 + Querying: + :2: + :: + :abc: +Test 3.6: Type: AFC. Length: strlen+1 + Querying: + :2: + :: + :abc: + + +*** NULL data tests against VARCHAR2 *** +Test 4.1: Type: default. Length: default + Querying: +Test 4.2: Type: AFC. Length: default + Querying: +Test 4.3: Type: AFC: Length: 0 + Querying: +Test 4.4: Type: AFC: Length: strlen + Querying: +Test 4.5: Type: AFC. Length: strlen-1 + Querying: +Test 4.6: Type: AFC. Length: strlen+1 + Querying: +Done diff --git a/ext/oci8/tests/bind_char_1_11gR1.phpt b/ext/oci8/tests/bind_char_1_11gR1.phpt new file mode 100644 index 0000000..a7feff9 --- /dev/null +++ b/ext/oci8/tests/bind_char_1_11gR1.phpt @@ -0,0 +1,292 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); + } +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +// Output is for 32 bit client to 64bit 11.1.0.6 + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", + "insert into bind_char_tab values (1, 'abc', NULL)", + "insert into bind_char_tab values (2, NULL, 'abc')", + "insert into bind_char_tab values (3, NULL, 'abc ')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "*** Non-null Data Tests against CHAR***\n"; + +$bv1 = 'abc'; + +echo "Test 1.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 1.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "\n\n*** NULL data tests against CHAR ***\n"; + +$bv1 = null; + +echo "Test 2.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 2.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 2.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +echo "\n\n*** Non-null Data Tests against VARCHAR2***\n"; + +$bv1 = 'abc'; + +echo "Test 3.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 3.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 3.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +echo "\n\n*** NULL data tests against VARCHAR2 ***\n"; + +$bv1 = null; + +echo "Test 4.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 4.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 4.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + + +function do_e_q($s) +{ + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } +} + +// Cleanup +$stmtarray = array( + "drop table bind_char_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +*** Non-null Data Tests against CHAR*** +Test 1.1: Type: default. Length: default + Querying: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :abc : + :: +Test 1.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :abc : + :: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :abc : + :: + + +*** NULL data tests against CHAR *** +Test 2.1: Type: default. Length: default + Querying: +Test 2.2: Type: AFC. Length: default + Querying: +Test 2.3: Type: AFC: Length: 0 + Querying: +Test 2.4: Type: AFC: Length: strlen + Querying: +Test 2.5: Type: AFC. Length: strlen-1 + Querying: +Test 2.6: Type: AFC. Length: strlen+1 + Querying: + + +*** Non-null Data Tests against VARCHAR2*** +Test 3.1: Type: default. Length: default + Querying: + :2: + :: + :abc: +Test 3.2: Type: AFC. Length: default + Querying: + :2: + :: + :abc: +Test 3.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 3.4: Type: AFC: Length: strlen + Querying: + :2: + :: + :abc: +Test 3.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 3.6: Type: AFC. Length: strlen+1 + Querying: + :2: + :: + :abc: + + +*** NULL data tests against VARCHAR2 *** +Test 4.1: Type: default. Length: default + Querying: +Test 4.2: Type: AFC. Length: default + Querying: +Test 4.3: Type: AFC: Length: 0 + Querying: +Test 4.4: Type: AFC: Length: strlen + Querying: +Test 4.5: Type: AFC. Length: strlen-1 + Querying: +Test 4.6: Type: AFC. Length: strlen+1 + Querying: +Done diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt new file mode 100644 index 0000000..43661a0 --- /dev/null +++ b/ext/oci8/tests/bind_char_2.phpt @@ -0,0 +1,122 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); + } +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "alter session set nls_date_format='YYYY-MM-DD'", + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 date)", + "insert into bind_char_tab values (1, '2008-04-20')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$bv1 = '2008-04-20'; + +echo "Test 1.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 1.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +function do_e_q($s) +{ + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } +} + +// Cleanup +$stmtarray = array( + "drop table bind_char_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Test 1.1: Type: default. Length: default + Querying: + :1: + :2008-04-20: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :2008-04-20: +Test 1.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :2008-04-20: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + :1: + :2008-04-20: +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :2008-04-20: +Done diff --git a/ext/oci8/tests/bind_char_2_11gR1.phpt b/ext/oci8/tests/bind_char_2_11gR1.phpt new file mode 100644 index 0000000..edb2a12 --- /dev/null +++ b/ext/oci8/tests/bind_char_2_11gR1.phpt @@ -0,0 +1,118 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); + } +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "alter session set nls_date_format='YYYY-MM-DD'", + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 date)", + "insert into bind_char_tab values (1, '2008-04-20')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$bv1 = '2008-04-20'; + +echo "Test 1.1: Type: default. Length: default\n"; +$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); +$r = oci_bind_by_name($s, ":bv", $bv1); +if ($r) + do_e_q($s); + +echo "Test 1.2: Type: AFC. Length: default\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.3: Type: AFC: Length: 0\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.4: Type: AFC: Length: strlen\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.5: Type: AFC. Length: strlen-1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e_q($s); + +echo "Test 1.6: Type: AFC. Length: strlen+1\n"; +$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e_q($s); + + +function do_e_q($s) +{ + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } +} + +// Cleanup +$stmtarray = array( + "drop table bind_char_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Test 1.1: Type: default. Length: default + Querying: + :1: + :2008-04-20: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :2008-04-20: +Test 1.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :2008-04-20: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :2008-04-20: +Done diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt new file mode 100644 index 0000000..2511583 --- /dev/null +++ b/ext/oci8/tests/bind_char_3.phpt @@ -0,0 +1,338 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); + } +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default\n"; + +$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + +echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "\n\nTests with ''\n\n"; + +echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "\n\nTests with NULL\n"; + +echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +function do_e($s) +{ + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } +} + +// Cleanup + +$stmtarray = array( + "drop function bind_char_3_fn" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(30) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(9) "abc " +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: +string(3) "abc" +string(6) "abc " +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(12) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bind_char_3_11gR1.phpt b/ext/oci8/tests/bind_char_3_11gR1.phpt new file mode 100644 index 0000000..fea7775 --- /dev/null +++ b/ext/oci8/tests/bind_char_3_11gR1.phpt @@ -0,0 +1,337 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); + } +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default\n"; + +$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + +echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "\n\nTests with ''\n\n"; + +echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "\n\nTests with NULL\n"; + +echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +function do_e($s) +{ + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } +} + +// Cleanup + +$stmtarray = array( + "drop function bind_char_3_fn" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +NULL +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(10) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(3) "abc" +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +string(3) "abc" +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(4) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt new file mode 100644 index 0000000..36765f8 --- /dev/null +++ b/ext/oci8/tests/bind_char_4.phpt @@ -0,0 +1,340 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); + } +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +// Same test as bind_char_3 but the PL/SQL function uses VARCHAR2 instead of CHAR + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default\n"; + +$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + +echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "\n\nTests with ''\n\n"; + +echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "\n\nTests with NULL\n"; + +echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +function do_e($s) +{ + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } +} + +// Cleanup + +$stmtarray = array( + "drop function bind_char_3_fn" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(30) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(9) "abc " +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: +string(3) "abc" +string(6) "abc " +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(12) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bind_char_4_11gR1.phpt b/ext/oci8/tests/bind_char_4_11gR1.phpt new file mode 100644 index 0000000..2bc2f14 --- /dev/null +++ b/ext/oci8/tests/bind_char_4_11gR1.phpt @@ -0,0 +1,339 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); + } +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +// Same test as bind_char_3 but the PL/SQL function uses VARCHAR2 instead of CHAR + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default\n"; + +$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + +echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC\n"; + +$bv1 = 'abc'; +$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "\n\nTests with ''\n\n"; + +echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = ''; +$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "\n\nTests with NULL\n"; + +echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + + +echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC\n"; + +$bv1 = null; +$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); +if ($r) + do_e($s); +var_dump($bv1, $bv2); + + +function do_e($s) +{ + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } +} + +// Cleanup + +$stmtarray = array( + "drop function bind_char_3_fn" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +NULL +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(10) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(3) "abc" +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +string(3) "abc" +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(4) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bind_empty.phpt b/ext/oci8/tests/bind_empty.phpt new file mode 100644 index 0000000..4c6c07e --- /dev/null +++ b/ext/oci8/tests/bind_empty.phpt @@ -0,0 +1,127 @@ +--TEST-- +binding empty values +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_empty_tab"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_empty_tab(name VARCHAR(10))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + + +echo "Test 1\n"; + +$name = null; +$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name"); +oci_bind_by_name($stmt, ":name", $name); + +var_dump(oci_execute($stmt)); + +echo "Test 2\n"; + +$name = ""; +$stmt = oci_parse($c, "UPDATE bind_empty_tab 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_empty_tab (NAME) VALUES ('abc')"); +$res = oci_execute($stmt); + +$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')"); +$res = oci_execute($stmt); + +$name = null; +$stmt = oci_parse($c, "UPDATE bind_empty_tab 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_empty_tab 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_empty_tab 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_empty_tab order by 1"); +oci_execute($stid); +oci_fetch_all($stid, $res); +var_dump($res); + +echo "Test 5\n"; + +$av = $bv = 'old'; +$s = oci_parse($c, "begin :bv := null; end; "); +oci_bind_by_name($s, ":bv", $bv); +oci_execute($s); +var_dump($av); +var_dump($bv); + +echo "Test 6\n"; + +$av = $bv = null; +$s = oci_parse($c, "begin :bv := null; end; "); +oci_bind_by_name($s, ":bv", $bv); +oci_execute($s); +var_dump($av); +var_dump($bv); + +// Clean up + +$drop = "DROP table bind_empty_tab"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +?> +===DONE=== +<?php exit(0); ?> +--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 + } +} +Test 5 +string(3) "old" +NULL +Test 6 +NULL +NULL +===DONE=== diff --git a/ext/oci8/tests/bind_long.phpt b/ext/oci8/tests/bind_long.phpt new file mode 100644 index 0000000..40c5799 --- /dev/null +++ b/ext/oci8/tests/bind_long.phpt @@ -0,0 +1,69 @@ +--TEST-- +bind LONG field +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmt = oci_parse($c, "drop table phptestlng"); +@oci_execute($stmt); + +$stmt = oci_parse($c, "create table phptestlng( id number(10), filetxt long)"); +oci_execute($stmt); + +echo "Test 1\n"; + +$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)"); +$i=1; +$filetxt = file_get_contents( dirname(__FILE__)."/test.txt"); + + +oci_bind_by_name( $stmt, ":id", $i, -1); +oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG); +oci_execute($stmt, OCI_DEFAULT); +oci_commit($c); + +$stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 1"); +oci_execute($stmt); + +$row = oci_fetch_row($stmt); +var_dump(md5($row[0])); +var_dump(strlen($row[0])); + +echo "Test 2 - test multi chunk fetch\n"; + +$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)"); +$i=2; +$filetxt = str_repeat($filetxt, 600); + +oci_bind_by_name( $stmt, ":id", $i, -1); +oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG); +oci_execute($stmt, OCI_DEFAULT); +oci_commit($c); + +$stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 2"); +oci_execute($stmt); + +$row = oci_fetch_row($stmt); +var_dump(md5($row[0])); +var_dump(strlen($row[0])); + +$stmt = oci_parse($c, "drop table phptestlng"); +oci_execute($stmt); + +echo "Done\n"; + +?> +--EXPECT-- +Test 1 +string(32) "5c7c34abf7ea51936785062dbfcaeddc" +int(394) +Test 2 - test multi chunk fetch +string(32) "ee2e98b977341cfb8e037066e5fcb909" +int(236400) +Done diff --git a/ext/oci8/tests/bind_long_raw.phpt b/ext/oci8/tests/bind_long_raw.phpt new file mode 100644 index 0000000..e48bbd3 --- /dev/null +++ b/ext/oci8/tests/bind_long_raw.phpt @@ -0,0 +1,41 @@ +--TEST-- +bind LONG RAW field +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmt = oci_parse($c, "create table phptestlngraw( id number(10), fileimage long raw)"); +oci_execute($stmt); + +$stmt = oci_parse ($c, "insert into phptestlngraw (id, fileimage) values (:id, :fileimage)"); +$i=1; +$fileimage = file_get_contents( dirname(__FILE__)."/test.gif"); + +oci_bind_by_name( $stmt, ":id", $i, -1); +oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LBI); +oci_execute($stmt, OCI_DEFAULT); +oci_commit($c); + +$stmt = oci_parse($c, "SELECT fileimage FROM phptestlngraw"); +oci_execute($stmt); + +$row = oci_fetch_row($stmt); +var_dump(md5($row[0])); +var_dump(strlen($row[0])); + +$stmt = oci_parse($c, "drop table phptestlngraw"); +oci_execute($stmt); + +echo "Done\n"; + +?> +--EXPECT-- +string(32) "614fcbba1effb7caa27ef0ef25c27fcf" +int(2523) +Done diff --git a/ext/oci8/tests/bind_misccoltypes.phpt b/ext/oci8/tests/bind_misccoltypes.phpt new file mode 100644 index 0000000..0da8c8b --- /dev/null +++ b/ext/oci8/tests/bind_misccoltypes.phpt @@ -0,0 +1,369 @@ +--TEST-- +Bind miscellaneous column types using default types +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (preg_match('/^1[012]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + + "alter session set nls_date_format = 'DD-MON-YY'", + + "drop table bind_misccoltypes_tab", + + "create table bind_misccoltypes_tab ( + id number, + char_t char(1), + char_t10 char(10), + varchar2_t10 varchar2(10), + number_t number, + number_t92 number(9,2), + number_t6 number(6), + date_t date, + timestamp_t timestamp, + float_t float, + binary_float_t binary_float, + binary_double_t binary_double, + decimal_t decimal, + integer_t integer, + nchar_t nchar(10), + nvarchar2_t10 nvarchar2(10), + varchar_t10 varchar(10) )", +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_misccoltypes_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +// Tests + +echo "\nTEST86 insert all ORATYPE values\n"; + +$insert_sql = "INSERT INTO bind_misccoltypes_tab ( id, " + . " char_t, " + . " char_t10, " + . " varchar2_t10, " + . " number_t, " + . " number_t92, " + . " number_t6, " + . " date_t, " + . " timestamp_t, " + . " float_t, " + . " binary_float_t, " + . " binary_double_t, " + . " decimal_t, " + . " integer_t, " + . " nchar_t, " + . " nvarchar2_t10, " + . " varchar_t10) " + . " VALUES (:n1, " + . " :c1, " + . " :c2, " + . " :c3, " + . " :n2, " + . " :n3, " + . " :n4, " + . " to_date(:d1, 'YYYY-MM-DD HH24:MI:SS'), " + . " to_timestamp(:d1, 'YYYY-MM-DD HH24:MI:SS'), " + . " :n5, " + . " :n5, " + . " :n5, " + . " :n1, " + . " :n1, " + . " :c4, " + . " :c5, " + . " :c6) "; + + +$n1 = "86"; +$c1 = "C"; +$c2 = "char10"; +$c3 = "varchar210"; +$n2 = "-123.456"; +$n3 = "789.346"; +$n4 = "123456.023"; +$n5 = "12345678901234567890123456789012345678.723"; +$d1 = "2010-03-29 13:09:15"; +$c4 = "nchar10"; +$c5 = "nvarchar2x"; +$c6 = "varchar"; + +$s = oci_parse($c, $insert_sql); +oci_bind_by_name($s, ":n1", $n1); +oci_bind_by_name($s, ":c1", $c1); +oci_bind_by_name($s, ":c2", $c2); +oci_bind_by_name($s, ":c3", $c3); +oci_bind_by_name($s, ":n2", $n2); +oci_bind_by_name($s, ":n3", $n3); +oci_bind_by_name($s, ":n4", $n4); +oci_bind_by_name($s, ":d1", $d1); +oci_bind_by_name($s, ":n5", $n5); +oci_bind_by_name($s, ":c4", $c4); +oci_bind_by_name($s, ":c5", $c5); +oci_bind_by_name($s, ":c6", $c6); + +oci_execute($s); + +echo "\nTEST87 SELECT all values using DEFINEs\n"; +$select_sql = "select " + . "id, " + . "char_t, " + . "char_t10, " + . "varchar2_t10, " + . "number_t, " + . "number_t92, " + . "number_t6, " + . "date_t, " + . "timestamp_t, " + . "float_t, " + . "binary_float_t, " + . "binary_double_t, " + . "decimal_t, " + . "integer_t, " + . "nchar_t, " + . "nvarchar2_t10, " + . "varchar_t10 " + . "from bind_misccoltypes_tab where id = 86"; + +$s = oci_parse($c, $select_sql); + +oci_define_by_name($s, "ID", $ID); +oci_define_by_name($s, "CHAR_T", $CHAR_T); +oci_define_by_name($s, "CHAR_T10", $CHAR_T10); +oci_define_by_name($s, "VARCHAR2_T10", $VARCHAR2_T10); +oci_define_by_name($s, "NUMBER_T", $NUMBER_T); +oci_define_by_name($s, "NUMBER_T92", $NUMBER_T92); +oci_define_by_name($s, "NUMBER_T6", $NUMBER_T6); +oci_define_by_name($s, "DATE_T", $DATE_T); +oci_define_by_name($s, "TIMESTAMP_T", $TIMESTAMP_T); +oci_define_by_name($s, "FLOAT_T", $FLOAT_T); +oci_define_by_name($s, "BINARY_FLOAT_T", $BINARY_FLOAT_T); +oci_define_by_name($s, "BINARY_DOUBLE_T", $BINARY_DOUBLE_T); +oci_define_by_name($s, "DECIMAL_T", $DECIMAL_T); +oci_define_by_name($s, "INTEGER_T", $INTEGER_T); +oci_define_by_name($s, "NCHAR_T", $NCHAR_T); +oci_define_by_name($s, "NVARCHAR2_T10", $NVARCHAR2_T10); +oci_define_by_name($s, "VARCHAR_T10", $VARCHAR_T10); + +oci_execute($s); + +while (oci_fetch($s)) { + echo "ID is " . "$ID\n"; + echo "CHAR_T is " . "$CHAR_T\n"; + echo "CHAR_T10 is " . "$CHAR_T10\n"; + echo "VARCHAR2_T10 is " . "$VARCHAR2_T10\n"; + echo "NUMBER_T is " . "$NUMBER_T\n"; + echo "NUMBER_T92 is " . "$NUMBER_T92\n"; + echo "NUMBER_T6 is " . "$NUMBER_T6\n"; + echo "DATE_T is " . "$DATE_T\n"; + echo "TIMESTAMP_T is " . "$TIMESTAMP_T\n"; + echo "FLOAT_T is " . "$FLOAT_T\n"; + echo "BINARY_FLOAT_T is " . "$BINARY_FLOAT_T\n"; + echo "BINARY_DOUBLE_T is " . "$BINARY_DOUBLE_T\n"; + echo "DECIMAL_T is " . "$DECIMAL_T\n"; + echo "INTEGER_T is " . "$INTEGER_T\n"; + echo "NCHAR_T is " . "$NCHAR_T\n"; + echo "NVARCHAR2_T10 is " . "$NVARCHAR2_T10\n"; + echo "VARCHAR_T10 is " . "$VARCHAR_T10\n"; +} + +echo "\nTEST52 insert numbers\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, number_t92) VALUES (52, :n1)"); +$n1 = 3; +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t92', 52); + + +echo "\nTEST53 insert numbers \n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, number_t92) VALUES (53, :n1)"); +$n1 = 8.67; +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t92', 53); + + +echo "\nTEST54 insert numbers \n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, number_t) VALUES (54, :n1)"); +$n1 = 4.67; +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t', 54); + +echo "\nTEST55 insert numbers \n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, number_t) VALUES (55, :n1)"); +$n1 = "7.67"; +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t', 55); + +echo "\nTEST56 insert numbers \n"; + +$n1 = -5.67; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, number_t) VALUES (56, :n1)"); +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t', 56); + +echo "\nTEST58 insert a VARCHAR2\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, varchar2_t10) VALUES (58, :c2)"); +$c2 = "Hood"; +oci_bind_by_name($s, ":c2", $c2); +oci_execute($s); + +check_col($c, 'varchar2_t10', 58); + +echo "\nTEST59 insert a VARCHAR2\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, char_t10) VALUES (59, :c2)"); +$c2 = "Hood"; +oci_bind_by_name($s, ":c2", $c2); +oci_execute($s); + +check_col($c, 'char_t10', 59); + +echo "\nTEST60 insert a date\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_tab (id, date_t) VALUES (60, to_date(:c2, 'YYYY-MM-DD'))"); +$c2 = '2010-04-09'; +oci_bind_by_name($s, ":c2", $c2); +oci_execute($s); + +check_col($c, 'date_t', 60); + + +// Clean up + +$stmtarray = array( + "drop table bind_misccoltypes_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +TEST86 insert all ORATYPE values + +TEST87 SELECT all values using DEFINEs +ID is 86 +CHAR_T is C +CHAR_T10 is char10 +VARCHAR2_T10 is varchar210 +NUMBER_T is -123.456 +NUMBER_T92 is 789.35 +NUMBER_T6 is 123456 +DATE_T is 29-MAR-10 +TIMESTAMP_T is 29-MAR-10 01.09.15.000000 PM +FLOAT_T is 12345678901234567890123456789012345679 +BINARY_FLOAT_T is 1.23456784E+037 +BINARY_DOUBLE_T is 1.2345678901234568E+037 +DECIMAL_T is 86 +INTEGER_T is 86 +NCHAR_T is nchar10 +NVARCHAR2_T10 is nvarchar2x +VARCHAR_T10 is varchar + +TEST52 insert numbers +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "3" + } +} + +TEST53 insert numbers +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(4) "8.67" + } +} + +TEST54 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(4) "4.67" + } +} + +TEST55 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(4) "7.67" + } +} + +TEST56 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(5) "-5.67" + } +} + +TEST58 insert a VARCHAR2 +array(1) { + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(4) "Hood" + } +} + +TEST59 insert a VARCHAR2 +array(1) { + ["CHAR_T10"]=> + array(1) { + [0]=> + string(10) "Hood " + } +} + +TEST60 insert a date +array(1) { + ["DATE_T"]=> + array(1) { + [0]=> + string(9) "09-APR-10" + } +} +===DONE=== diff --git a/ext/oci8/tests/bind_misccoltypes_errs.phpt b/ext/oci8/tests/bind_misccoltypes_errs.phpt new file mode 100644 index 0000000..20401fb --- /dev/null +++ b/ext/oci8/tests/bind_misccoltypes_errs.phpt @@ -0,0 +1,169 @@ +--TEST-- +Bind miscellaneous column types and generating errors +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_misccoltypes_errs_tab", + + "create table bind_misccoltypes_errs_tab ( + id number, + char_t char(1), + char_t10 char(10), + varchar2_t10 varchar2(10), + number_t number, + number_t92 number(9,2), + number_t6 number(6), + date_t date, + timestamp_t timestamp, + float_t float, + binary_float_t binary_float, + binary_double_t binary_double, + decimal_t decimal, + integer_t integer, + nchar_t nchar(10), + nvarchar2_t10 nvarchar2(10), + varchar_t10 varchar(10) )", +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_misccoltypes_errs_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +// Tests + +echo "\nTest 1 insert numbers \n"; + +$n1 = -23253245.3432467; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t6) VALUES (1, :n1)"); +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t6', 57); + +echo "\nTest 2 insert numbers \n"; + +$n1 = "Hello"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t6) VALUES (2, :n1)"); +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, 'number_t6', 57); + +echo "\nTest 3 - too long CHAR\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, char_t) VALUES (3, :c2)"); +$c2 = "AB"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_execute($s); + +echo "\nTest 4 - too long VARCHAR2\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (4, :c2)"); +$c2 = "AAAAAAAAAAB"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_execute($s); + +echo "\nTest 5 - invalid number\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t) VALUES (5, :c2)"); +$c2 = "ABC"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_execute($s); + +echo "\nTest 6 - insert a VARCHAR2 with SQLT_BIN\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (6, :c2)"); +$c2 = "Hood 6"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_BIN); +oci_execute($s); + +check_col($c, 'varchar2_t10', 6); + +echo "\nTest 7 - insert a VARCHAR2 with SQLT_LBI\n"; + +$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (7, :c2)"); +$c2 = "Hood 7"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_LBI); +oci_execute($s); + +check_col($c, 'varchar2_t10', 7); + + +// Clean up + +$stmtarray = array( + "drop table bind_misccoltypes_errs_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 insert numbers + +Warning: oci_execute(): ORA-01438: %s in %sbind_misccoltypes_errs.php on line %d +array(1) { + ["NUMBER_T6"]=> + array(0) { + } +} + +Test 2 insert numbers + +Warning: oci_execute(): ORA-01722: %s in %sbind_misccoltypes_errs.php on line %d +array(1) { + ["NUMBER_T6"]=> + array(0) { + } +} + +Test 3 - too long CHAR + +Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."CHAR_T" \(%s: 2, %s: 1\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d + +Test 4 - too long VARCHAR2 + +Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 11, %s: 10\)|%s data right truncation)%r in %sbind_misccoltypes_errs.php on line %d + +Test 5 - invalid number + +Warning: oci_execute(): ORA-01722: %s in %sbind_misccoltypes_errs.php on line %d + +Test 6 - insert a VARCHAR2 with SQLT_BIN + +Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 12, %s: 10\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d +array(1) { + ["VARCHAR2_T10"]=> + array(0) { + } +} + +Test 7 - insert a VARCHAR2 with SQLT_LBI + +Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 12, %s: 10\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d +array(1) { + ["VARCHAR2_T10"]=> + array(0) { + } +} +===DONE=== diff --git a/ext/oci8/tests/bind_number.phpt b/ext/oci8/tests/bind_number.phpt new file mode 100644 index 0000000..6412b5f --- /dev/null +++ b/ext/oci8/tests/bind_number.phpt @@ -0,0 +1,220 @@ +--TEST-- +Bind with NUMBER column variants +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (preg_match('/^1[012]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--INI-- +precision = 14 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_number_tab", + "create table bind_number_tab ( + id number, + number_t6 number(6), + float_t float, + binary_float_t binary_float, + binary_double_t binary_double, + decimal_t decimal, + integer_t integer)" +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_number_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +// Run Test + +echo "Test 1 - invalid number\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, number_t6) VALUES (1, :n1)"); +$n1 = "Hello"; +oci_bind_by_name($s, ":n1", $n1); +oci_execute($s); + +check_col($c, "number_t6", 1); + +echo "\nTEST66 insert a float\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, float_t) VALUES (66, :f1)"); +$f1 = 123.456; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'float_t', 66); + +echo "\nTEST67 insert a binary float\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_float_t) VALUES (67, :f1)"); +$f1 = 567.456; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'binary_float_t', 67); + +echo "\nTEST69 insert a binary double\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (69, :f1)"); +$f1 = 567.456; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'binary_double_t', 69); + +echo "\nTEST71 insert a decimal\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (71, :f1)"); +$f1 = 123.789; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'decimal_t', 71); + +echo "\nTEST72 insert a decimal\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (72, :f1)"); +$f1 = 123.789; +oci_bind_by_name($s, ":f1", $f1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'decimal_t', 72); + +echo "\nTEST73 insert a double\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (73, :f1)"); +$f1 = 483.589; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'binary_double_t', 73); + +echo "\nTEST75 insert a INTEGER\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (75, :f1)"); +$f1 = 589; +oci_bind_by_name($s, ":f1", $f1); +oci_execute($s); + +check_col($c, 'integer_t', 75); + +echo "\nTEST76 insert a INTEGER\n"; + +$s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (76, :f1)"); +$f1 = 42; +oci_bind_by_name($s, ":f1", $f1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'integer_t', 76); + + +// Clean up + +$stmtarray = array( + "drop table bind_number_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - invalid number + +Warning: oci_execute(): ORA-01722: %s in %sbind_number.php on line %d +array(1) { + ["NUMBER_T6"]=> + array(0) { + } +} + +TEST66 insert a float +array(1) { + ["FLOAT_T"]=> + array(1) { + [0]=> + string(7) "123.456" + } +} + +TEST67 insert a binary float +array(1) { + ["BINARY_FLOAT_T"]=> + array(1) { + [0]=> + string(%r15|8%r) "%r(5.67455994E\+002|567.4560)%r" + } +} + +TEST69 insert a binary double +array(1) { + ["BINARY_DOUBLE_T"]=> + array(1) { + [0]=> + string(%r23|16%r) "%r(5.6745600000000002E\+002|567.456000000000)%r" + } +} + +TEST71 insert a decimal +array(1) { + ["DECIMAL_T"]=> + array(1) { + [0]=> + string(3) "124" + } +} + +TEST72 insert a decimal +array(1) { + ["DECIMAL_T"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST73 insert a double +array(1) { + ["BINARY_DOUBLE_T"]=> + array(1) { + [0]=> + string(%r12|16%r) "%r(4.83589E\+002|483.589000000000)%r" + } +} + +TEST75 insert a INTEGER +array(1) { + ["INTEGER_T"]=> + array(1) { + [0]=> + string(3) "589" + } +} + +TEST76 insert a INTEGER +array(1) { + ["INTEGER_T"]=> + array(1) { + [0]=> + string(2) "42" + } +} +===DONE=== + + diff --git a/ext/oci8/tests/bind_query.phpt b/ext/oci8/tests/bind_query.phpt new file mode 100644 index 0000000..e4edc93 --- /dev/null +++ b/ext/oci8/tests/bind_query.phpt @@ -0,0 +1,78 @@ +--TEST-- +Bind with various WHERE conditions +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_query_tab", + "create table bind_query_tab (empno number(4), ename varchar2(10), sal number(7,2))", + "insert into bind_query_tab values (7934, 'MILLER', 1300)", + "insert into bind_query_tab values (7902, 'FORD', 3000)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$e = 7934; + +$s = oci_parse($c, "select ename from bind_query_tab where empno = :eno"); +oci_bind_by_name( $s, ":eno", $e, -1, SQLT_INT); +oci_execute($s); +var_dump(oci_fetch_row($s)); + +echo "Test 2\n"; + +$v = 1000; +$s = oci_parse($c, 'select ename from bind_query_tab where sal > :v order by ename'); +oci_bind_by_name( $s, ":v", $v); +oci_define_by_name($s, "ENAME", $ename, 20); +oci_execute($s); +while (oci_fetch($s)) { + var_dump($ename); +} + + +echo "Test 3\n"; + +$s = oci_parse($c, 'select ename from bind_query_tab where sal > :v order by ename'); +oci_bind_by_name( $s, ":v", $v); +$v = 2000; +oci_define_by_name($s, "ENAME", $ename, 20); +oci_execute($s); +while (oci_fetch($s)) { + var_dump($ename); +} + + +// Clean up + +$stmtarray = array( + "drop table bind_query_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(1) { + [0]=> + string(6) "MILLER" +} +Test 2 +string(4) "FORD" +string(6) "MILLER" +Test 3 +string(4) "FORD" +===DONE=== diff --git a/ext/oci8/tests/bind_raw.phpt b/ext/oci8/tests/bind_raw.phpt new file mode 100644 index 0000000..c2e8e08 --- /dev/null +++ b/ext/oci8/tests/bind_raw.phpt @@ -0,0 +1,42 @@ +--TEST-- +bind RAW field +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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); + +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); + +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +oci_execute($stmt); + +$row = oci_fetch_row($stmt); +var_dump(md5($row[0])); +var_dump(strlen($row[0])); + +$stmt = oci_parse($c, "drop table phptestrawtable"); +oci_execute($stmt); + +echo "Done\n"; + +?> +--EXPECT-- +string(32) "88b274d7a257ac6f70435b83abd4e26e" +int(300) +Done diff --git a/ext/oci8/tests/bind_raw_2.phpt b/ext/oci8/tests/bind_raw_2.phpt new file mode 100644 index 0000000..035c184 --- /dev/null +++ b/ext/oci8/tests/bind_raw_2.phpt @@ -0,0 +1,42 @@ +--TEST-- +bind RAW field with OCI_B_BIN +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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); + +oci_bind_by_name( $stmt, ":id", $i, -1); +oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, OCI_B_BIN); +oci_execute($stmt, OCI_DEFAULT); +oci_commit($c); + +$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); +oci_execute($stmt); + +$row = oci_fetch_row($stmt); +var_dump(md5($row[0])); +var_dump(strlen($row[0])); + +$stmt = oci_parse($c, "drop table phptestrawtable"); +oci_execute($stmt); + +echo "Done\n"; + +?> +--EXPECT-- +string(32) "88b274d7a257ac6f70435b83abd4e26e" +int(300) +Done diff --git a/ext/oci8/tests/bind_rowid.phpt b/ext/oci8/tests/bind_rowid.phpt new file mode 100644 index 0000000..122ad5e --- /dev/null +++ b/ext/oci8/tests/bind_rowid.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test ROWID bind +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +function do_query($c) +{ + $s = oci_parse($c, 'select address from rid_tab order by id'); + $id = 1; + oci_execute($s, OCI_DEFAULT); + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + var_dump($row); + } +} + +$stmtarray = array( + "drop table rid_tab", + "create table rid_tab (id number, address varchar2(40))", + "insert into rid_tab (id, address) values (1, 'original text #1')", + "insert into rid_tab (id, address) values (2, 'original text #2')" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Initial Data\n"; +do_query($c); + +$s = oci_parse($c, 'select rowid, address from rid_tab where id = :l_bv for update'); +$id = 1; +oci_bind_by_name($s, ':l_bv', $id); +oci_execute($s, OCI_DEFAULT); +$row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS); + +$rid = $row['ROWID']; +$addr = $row['ADDRESS']; + +$addr = 'Some new text'; + +// Save changes +$s = oci_parse($c,'update rid_tab set address = :a_bv where rowid = :r_bv'); +oci_bind_by_name($s, ':r_bv', $rid, -1, OCI_B_ROWID); +oci_bind_by_name($s, ':a_bv', $addr); +oci_execute($s); + +echo "Verify Change\n"; +do_query($c); + +// Cleanup + +$stmtarray = array( + "drop table rid_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Initial Data +array(1) { + ["ADDRESS"]=> + string(16) "original text #1" +} +array(1) { + ["ADDRESS"]=> + string(16) "original text #2" +} +Verify Change +array(1) { + ["ADDRESS"]=> + string(13) "Some new text" +} +array(1) { + ["ADDRESS"]=> + string(16) "original text #2" +} +Done diff --git a/ext/oci8/tests/bind_sqltafc.phpt b/ext/oci8/tests/bind_sqltafc.phpt new file mode 100644 index 0000000..8d2ce2a --- /dev/null +++ b/ext/oci8/tests/bind_sqltafc.phpt @@ -0,0 +1,208 @@ +--TEST-- +Bind tests with SQLT_AFC +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_sqltafc_tab", + "create table bind_sqltafc_tab (id number, char_t char(1), char_t10 char(10), varchar2_t10 varchar2(10), number_t number)", + "insert into bind_sqltafc_tab values (0, 'a', 'abcd', 'efghij', 1.1)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +function q($c, $id) +{ + $s = oci_parse($c, "select * from bind_sqltafc_tab where id = $id"); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +echo "Test 0 - base table creation without binds\n"; + +q($c, 0); + +echo "\nTest 1 - successful insert\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltafc_tab (id, char_t, char_t10, varchar2_t10, number_t) VALUES (1, :c2, :c3, :c4, :c5)"); +$c2 = "H"; +$c3 = "AAAAAAAAAA"; // max length allowed in column +$c4 = "BBBBBBBBBB"; // max length allowed in column +$c5 = "123.45"; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_bind_by_name($s, ":c3", $c3, -1, SQLT_AFC); +oci_bind_by_name($s, ":c4", $c4, -1, SQLT_AFC); +oci_bind_by_name($s, ":c5", $c5, -1, SQLT_AFC); +oci_execute($s); + +q($c, 1); + +echo "\nTest 2 - Empty Strings\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltafc_tab (id, char_t, char_t10, varchar2_t10, number_t) VALUES (5, :c2, :c3, :c4, :c5)"); +$c2 = ""; +$c3 = ""; +$c4 = ""; +$c5 = ""; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_bind_by_name($s, ":c3", $c3, -1, SQLT_AFC); +oci_bind_by_name($s, ":c4", $c4, -1, SQLT_AFC); +oci_bind_by_name($s, ":c5", $c5, -1, SQLT_AFC); +oci_execute($s); + +q($c, 5); + +echo "\nTest 3 - NULLs\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltafc_tab (id, char_t, char_t10, varchar2_t10, number_t) VALUES (6, :c2, :c3, :c4, :c5)"); +$c2 = null; +$c3 = null; +$c4 = null; +$c5 = null; +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); +oci_bind_by_name($s, ":c3", $c3, -1, SQLT_AFC); +oci_bind_by_name($s, ":c4", $c4, -1, SQLT_AFC); +oci_bind_by_name($s, ":c5", $c5, -1, SQLT_AFC); +oci_execute($s); + +q($c, 6); + +// Clean up + +$stmtarray = array( + "drop table bind_sqltafc_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 0 - base table creation without binds +array(5) { + ["ID"]=> + array(1) { + [0]=> + string(1) "0" + } + ["CHAR_T"]=> + array(1) { + [0]=> + string(1) "a" + } + ["CHAR_T10"]=> + array(1) { + [0]=> + string(10) "abcd " + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(6) "efghij" + } + ["NUMBER_T"]=> + array(1) { + [0]=> + string(3) "1.1" + } +} + +Test 1 - successful insert +array(5) { + ["ID"]=> + array(1) { + [0]=> + string(1) "1" + } + ["CHAR_T"]=> + array(1) { + [0]=> + string(1) "H" + } + ["CHAR_T10"]=> + array(1) { + [0]=> + string(10) "AAAAAAAAAA" + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(10) "BBBBBBBBBB" + } + ["NUMBER_T"]=> + array(1) { + [0]=> + string(6) "123.45" + } +} + +Test 2 - Empty Strings +array(5) { + ["ID"]=> + array(1) { + [0]=> + string(1) "5" + } + ["CHAR_T"]=> + array(1) { + [0]=> + NULL + } + ["CHAR_T10"]=> + array(1) { + [0]=> + NULL + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + NULL + } + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +Test 3 - NULLs +array(5) { + ["ID"]=> + array(1) { + [0]=> + string(1) "6" + } + ["CHAR_T"]=> + array(1) { + [0]=> + NULL + } + ["CHAR_T10"]=> + array(1) { + [0]=> + NULL + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + NULL + } + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} +===DONE=== diff --git a/ext/oci8/tests/bind_sqltchr_1.phpt b/ext/oci8/tests/bind_sqltchr_1.phpt new file mode 100644 index 0000000..aabf9bd --- /dev/null +++ b/ext/oci8/tests/bind_sqltchr_1.phpt @@ -0,0 +1,228 @@ +--TEST-- +Bind with SQLT_CHR +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_sqltchr_tab", + + "create table bind_sqltchr_tab ( + id number, + varchar2_t10 varchar2(10), + number_t number, + number_t92 number(9,2))" + +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_sqltchr_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +// Run Test + +echo "\nTEST241 bind SQLT_CHR\n"; + +$c2 = "Hood241"; +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, varchar2_t10) VALUES (241, :c2)"); +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'varchar2_t10', 241); + + +echo "\nTEST242 insert numbers SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (242, :n1)"); +$n1 = 42; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 242); + +echo "\nTEST243 insert numbers, SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (243, :n1)"); +$n1 = 42.69; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 243); + +echo "\nTEST244 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (244, :n1)"); +$n1 = 0; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 244); + +echo "\nTEST245 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (245, :n1)"); +$n1 = -23; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 245); + +echo "\nTEST246 insert numbers\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (246, :n1)"); +$n1 = "-23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 246); + +echo "\nTEST247 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (247, :n1)"); +$n1 = "23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t', 247); + +echo "\nTEST248 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (248, :n1)"); +$n1 = 123.56; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t92', 248); + +echo "\nTEST249 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (249, :n1)"); +$n1 = "123.56"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t92', 249); + +echo "\nTEST250 insert numbers with SQLT_CHR\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (250, :n1)"); +$n1 = ""; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR); +oci_execute($s); + +check_col($c, 'number_t92', 250); + +// Clean up + +$stmtarray = array( + "drop table bind_sqltchr_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +TEST241 bind SQLT_CHR +array(1) { + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(7) "Hood241" + } +} + +TEST242 insert numbers SQLT_CHR +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(2) "42" + } +} + +TEST243 insert numbers, SQLT_CHR +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(5) "42.69" + } +} + +TEST244 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST245 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(3) "-23" + } +} + +TEST246 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(3) "-23" + } +} + +TEST247 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(2) "23" + } +} + +TEST248 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(6) "123.56" + } +} + +TEST249 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(6) "123.56" + } +} + +TEST250 insert numbers with SQLT_CHR +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + NULL + } +} +===DONE=== diff --git a/ext/oci8/tests/bind_sqltchr_2.phpt b/ext/oci8/tests/bind_sqltchr_2.phpt new file mode 100644 index 0000000..47d08d2 --- /dev/null +++ b/ext/oci8/tests/bind_sqltchr_2.phpt @@ -0,0 +1,50 @@ +--TEST-- +PL/SQL bind with SQLT_CHR +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure bind_sqltchr_proc (msg_in in varchar2, msg_out out varchar2) + as + begin + msg_out := upper(msg_in); + end;" + +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - PL/SQL IN and OUT variables\n"; + +$stmt = oci_parse($c, "BEGIN bind_sqltchr_proc(:a, :b); END;"); +$msg_in = "Cat got your keyboard?"; +oci_bind_by_name($stmt, ":a", $msg_in, -1, SQLT_CHR); +oci_bind_by_name($stmt, ":b", $msg_out, 800, SQLT_CHR); +oci_execute($stmt); +var_dump($msg_in); +var_dump($msg_out); + +// Clean up + +$stmtarray = array( + "drop procedure bind_sqltchr_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - PL/SQL IN and OUT variables +string(22) "Cat got your keyboard?" +string(22) "CAT GOT YOUR KEYBOARD?" +===DONE=== diff --git a/ext/oci8/tests/bind_sqltint.phpt b/ext/oci8/tests/bind_sqltint.phpt new file mode 100644 index 0000000..ac8518e --- /dev/null +++ b/ext/oci8/tests/bind_sqltint.phpt @@ -0,0 +1,336 @@ +--TEST-- +Bind with SQLT_INT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_sqltint_tab", + + "create table bind_sqltint_tab ( + id number, + varchar2_t10 varchar2(10), + number_t number, + number_t92 number(9,2))", + +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_sqltint_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + +// Run Test + +echo "\nTEST141 wrong bind type SQLT_INT\n"; + +$c2 = "Hood141"; +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, varchar2_t10) VALUES (141, :c2)"); +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'varchar2_t10', 141); + +echo "\nTEST142 insert numbers SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (142, :n1)"); +$n1 = 42; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 142); + +echo "\nTEST143 insert numbers, SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (143, :n1)"); +$n1 = 42.69; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 143); + +echo "\nTEST144 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (144, :n1)"); +$n1 = 0; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 144); + +echo "\nTEST145 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (145, :n1)"); +$n1 = -23; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 145); + +echo "\nTEST146 insert numbers\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (146, :n1)"); +$n1 = "-23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 146); + +echo "\nTEST147 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t) VALUES (147, :n1)"); +$n1 = "23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t', 147); + +echo "\nTEST148 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t92) VALUES (148, :n1)"); +$n1 = 123.56; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t92', 148); + +echo "\nTEST149 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t92) VALUES (149, :n1)"); +$n1 = "123.56"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t92', 149); + +echo "\nTEST150 insert numbers with SQLT_INT\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltint_tab (id, number_t92) VALUES (150, :n1)"); +$n1 = ""; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_INT); +oci_execute($s); + +check_col($c, 'number_t92', 150); + +echo "\nTEST151 - 159 Initialization tests\n"; + +$s = oci_parse($c, "begin :p2 := :p1; end;"); +unset($p1); +unset($p2); +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST152\n"; + +unset($p1); +$p2 = null; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST153\n"; + +unset($p1); +$p2 = 1111; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST154\n"; + +$p1 = null; +unset($p2); +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST155\n"; + +$p1 = null; +$p2 = null; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST156\n"; + +$p1 = null; +$p2 = 2222; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST157\n"; + +$p1 = 3333; +unset($p2); +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST158\n"; + +$p1 = 4444; +$p2 = null; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +echo "\nTEST159\n"; + +$p1 = 5555; +$p2 = 6666; +oci_bind_by_name($s, ":p1", $p1, 10); +oci_bind_by_name($s, ":p2", $p2, -1, SQLT_INT); +oci_execute($s); +var_dump($p2); + +// Clean up + +$stmtarray = array( + "drop table bind_sqltint_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +TEST141 wrong bind type SQLT_INT +array(1) { + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST142 insert numbers SQLT_INT +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(2) "42" + } +} + +TEST143 insert numbers, SQLT_INT +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(2) "42" + } +} + +TEST144 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST145 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(3) "-23" + } +} + +TEST146 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(3) "-23" + } +} + +TEST147 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(2) "23" + } +} + +TEST148 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(3) "123" + } +} + +TEST149 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(3) "123" + } +} + +TEST150 insert numbers with SQLT_INT +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST151 - 159 Initialization tests +NULL + +TEST152 +NULL + +TEST153 +NULL + +TEST154 +NULL + +TEST155 +NULL + +TEST156 +NULL + +TEST157 +int(3333) + +TEST158 +int(4444) + +TEST159 +int(5555) +===DONE=== diff --git a/ext/oci8/tests/bind_sqltnum.phpt b/ext/oci8/tests/bind_sqltnum.phpt new file mode 100644 index 0000000..d3828b7 --- /dev/null +++ b/ext/oci8/tests/bind_sqltnum.phpt @@ -0,0 +1,278 @@ +--TEST-- +Bind with SQLT_NUM +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (preg_match('/^1[012]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bind_sqltnum_tab", + + "create table bind_sqltnum_tab ( + id number, + varchar2_t10 varchar2(10), + number_t number, + number_t92 number(9,2))" +); + +oci8_test_sql_execute($c, $stmtarray); + +function check_col($c, $colname, $id) +{ + $s = oci_parse($c, "select $colname from bind_sqltnum_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); +} + + +// Run Test + +echo "Test 1 - baseline test\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, varchar2_t10) VALUES (100, :c2)"); +$c2 = "Hood"; +$r = oci_bind_by_name($s, ":c2", $c2, -1); +if (!$r) { + $e = oci_error($s); + var_dump($e); +} +$r = oci_execute($s, OCI_DEFAULT); +if (!$r) { + $e = oci_error($s); + var_dump($e); +} + +$s = oci_parse($c, "select id, varchar2_t10 from bind_sqltnum_tab"); +oci_execute($s); +oci_fetch_all($s, $data); +var_dump($data); + +echo "Test 2 - SQLT_NUM to a VARCHAR2 column\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, varchar2_t10) VALUES (100, :c2)"); +$c2 = "Hood"; +$r = oci_bind_by_name($s, ":c2", $c2, -1, SQLT_NUM); +if (!$r) { + $e = oci_error($s); + var_dump($e['message']); +} +$r = oci_execute($s, OCI_DEFAULT); +if (!$r) { + $e = oci_error($s); + var_dump($e['message']); +} + +echo "\nTEST41 wrong bind type SQLT_NUM\n"; + +$c2 = "Hood41"; +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, varchar2_t10) VALUES (41, :c2)"); +oci_bind_by_name($s, ":c2", $c2, -1, SQLT_NUM); +oci_execute($s); + +echo "\nTEST42 insert numbers SQLT_NUM\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (42, :n1)"); +$n1 = 42; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 42); + +echo "\nTEST43 insert numbers SQLT_NUM\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (43, :n1)"); +$n1 = 42.69; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 43); + +echo "\nTEST44\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (44, :n1)"); +$n1 = 0; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 44); + +echo "\nTEST45\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (45, :n1)"); +$n1 = -23; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 45); + +echo "\nTEST46 insert numbers\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (46, :n1)"); +$n1 = "-23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 46); + +echo "\nTEST47\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t) VALUES (47, :n1)"); +$n1 = "23"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t', 47); + +echo "\nTEST48\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t92) VALUES (48, :n1)"); +$n1 = 123.56; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t92', 48); + +echo "\nTEST49\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t92) VALUES (49, :n1)"); +$n1 = "123.56"; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t92', 49); + +echo "\nTEST50\n"; + +$s = oci_parse($c, "INSERT INTO bind_sqltnum_tab (id, number_t92) VALUES (50, :n1)"); +$n1 = ""; +oci_bind_by_name($s, ":n1", $n1, -1, SQLT_NUM); +oci_execute($s); + +check_col($c, 'number_t92', 50); + +// Clean up + +$stmtarray = array( + "drop table bind_sqltnum_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - baseline test +array(2) { + ["ID"]=> + array(1) { + [0]=> + string(3) "100" + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(4) "Hood" + } +} +Test 2 - SQLT_NUM to a VARCHAR2 column + +Warning: oci_execute(): ORA-12899: %s (%s: 40, %s: 10) in %sbind_sqltnum.php on line %d +string(%d) "ORA-12899: %s" + +TEST41 wrong bind type SQLT_NUM + +Warning: oci_execute(): ORA-12899: %s "%s"."BIND_SQLTNUM_TAB"."VARCHAR2_T10" (%s: 40, %s: 10) in %sbind_sqltnum.php on line %d + +TEST42 insert numbers SQLT_NUM +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST43 insert numbers SQLT_NUM +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST44 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(127) "-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } +} + +TEST45 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST46 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST47 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST48 +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST49 +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST50 + +Warning: oci_execute(): ORA-01438: %s in %sbind_sqltnum.php on line %d +array(1) { + ["NUMBER_T92"]=> + array(0) { + } +} +===DONE=== diff --git a/ext/oci8/tests/bind_unsupported_1.phpt b/ext/oci8/tests/bind_unsupported_1.phpt new file mode 100644 index 0000000..544b446 --- /dev/null +++ b/ext/oci8/tests/bind_unsupported_1.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bind with various unsupported bind types +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// These types are defined in oci8.c + +$types = array( + "SQLT_AVC" => SQLT_AVC, + "SQLT_STR" => SQLT_STR, + "SQLT_VCS" => SQLT_VCS, + "SQLT_AVC" => SQLT_AVC, + "SQLT_STR" => SQLT_STR, + "SQLT_LVC" => SQLT_LVC, + "SQLT_FLT" => SQLT_FLT, + "SQLT_UIN" => SQLT_UIN, + "SQLT_ODT" => SQLT_ODT, +); + +foreach ($types as $t => $v) { + + echo "Test - $t\n"; + + $s = oci_parse($c, "select * from dual where dummy = :c1"); + $c1 = "Doug"; + oci_bind_by_name($s, ":c1", $c1, -1, $v); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test - SQLT_AVC + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 97 in %sbind_unsupported_1.php on line %d +Test - SQLT_STR + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 5 in %sbind_unsupported_1.php on line %d +Test - SQLT_VCS + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 9 in %sbind_unsupported_1.php on line %d +Test - SQLT_LVC + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 94 in %sbind_unsupported_1.php on line %d +Test - SQLT_FLT + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 4 in %sbind_unsupported_1.php on line %d +Test - SQLT_UIN + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 68 in %sbind_unsupported_1.php on line %d +Test - SQLT_ODT + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 156 in %sbind_unsupported_1.php on line %d +===DONE=== diff --git a/ext/oci8/tests/bind_unsupported_2.phpt b/ext/oci8/tests/bind_unsupported_2.phpt new file mode 100644 index 0000000..d3e5375 --- /dev/null +++ b/ext/oci8/tests/bind_unsupported_2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bind with various unsupported 10g+ bind types +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (preg_match('/^1[01]\./', oci_client_version()) !== 1) { + die ("skip expected output only valid for Oracle 10g+ clients"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$types = array( + "SQLT_BDOUBLE" => SQLT_BDOUBLE, + "SQLT_BFLOAT" => SQLT_BFLOAT, +); + +foreach ($types as $t => $v) { + + echo "Test - $t\n"; + + $s = oci_parse($c, "select * from dual where dummy = :c1"); + $c1 = "Doug"; + oci_bind_by_name($s, ":c1", $c1, -1, $v); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test - SQLT_BDOUBLE + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 22 in %sbind_unsupported_2.php on line %d +Test - SQLT_BFLOAT + +Warning: oci_bind_by_name(): Unknown or unsupported datatype given: 21 in %sbind_unsupported_2.php on line %d +===DONE=== diff --git a/ext/oci8/tests/bind_unsupported_3.phpt b/ext/oci8/tests/bind_unsupported_3.phpt new file mode 100644 index 0000000..5c9dec3 --- /dev/null +++ b/ext/oci8/tests/bind_unsupported_3.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bind with various bind types not supported by TimesTen +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => false, 'timesten' => true); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$types = array( + "SQLT_CLOB" => SQLT_CLOB, + "SQLT_BLOB" => SQLT_BLOB, + "OCI_B_CLOB" => OCI_B_CLOB, + "OCI_B_BLOB" => OCI_B_BLOB, +); + +foreach ($types as $t => $v) { + + echo "Test - $t\n"; + + $s = oci_parse($c, "select * from dual where dummy = :c1"); + $c1 = "Doug"; + oci_bind_by_name($s, ":c1", $c1, -1, $v); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test - SQLT_CLOB + +Warning: oci_bind_by_name(): Unable to find descriptor property in %sbind_unsupported_3.php on line %d +Test - SQLT_BLOB + +Warning: oci_bind_by_name(): Unable to find descriptor property in %sbind_unsupported_3.php on line %d +Test - OCI_B_CLOB + +Warning: oci_bind_by_name(): Unable to find descriptor property in %sbind_unsupported_3.php on line %d +Test - OCI_B_BLOB + +Warning: oci_bind_by_name(): Unable to find descriptor property in %sbind_unsupported_3.php on line %d +===DONE=== diff --git a/ext/oci8/tests/bug26133.phpt b/ext/oci8/tests/bug26133.phpt new file mode 100644 index 0000000..59f8a17 --- /dev/null +++ b/ext/oci8/tests/bug26133.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #26133 (ocifreedesc() segfault) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialize + +$stmtarray = array( + "drop table bug26133_tab", + "create table bug26133_tab (id number, value number)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$ora_sql = "INSERT INTO bug26133_tab (id, value) VALUES (1,'1') RETURNING ROWID INTO :v_rowid "; + +$statement = OCIParse($c,$ora_sql); +$rowid = OCINewDescriptor($c,OCI_D_ROWID); +OCIBindByName($statement,":v_rowid", $rowid,-1,OCI_B_ROWID); +if (OCIExecute($statement)) { + OCICommit($c); +} +OCIFreeStatement($statement); +$rowid->free(); + +// Cleanup + +$stmtarray = array( + "drop table bug26133_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/ext/oci8/tests/bug27303_1.phpt b/ext/oci8/tests/bug27303_1.phpt new file mode 100644 index 0000000..40ab4eb --- /dev/null +++ b/ext/oci8/tests/bug27303_1.phpt @@ -0,0 +1,260 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && + preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); + // Other point releases may also work +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab", + "create sequence myseq", + "create table mytab (mydata varchar2(20), seqcol number)" +); + +oci8_test_sql_execute($c, $stmtarray); + +define('MYLIMIT', 200); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$r = OCIBindByName($stid, ':MYBV', $mybv); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_1_11gR1.phpt b/ext/oci8/tests/bug27303_1_11gR1.phpt new file mode 100644 index 0000000..6de9b99 --- /dev/null +++ b/ext/oci8/tests/bug27303_1_11gR1.phpt @@ -0,0 +1,257 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using specific Oracle database versions"); + } + } +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab", + "create sequence myseq", + "create table mytab (mydata varchar2(20), seqcol number)" +); + +oci8_test_sql_execute($c, $stmtarray); + +define('MYLIMIT', 200); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$r = OCIBindByName($stid, ':MYBV', $mybv); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +Done diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt new file mode 100644 index 0000000..1fb2b31 --- /dev/null +++ b/ext/oci8/tests/bug27303_2.phpt @@ -0,0 +1,262 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && + preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); + // Other point releases may also work +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab", + "create sequence myseq", + "create table mytab (mydata varchar2(20), seqcol number)" +); + +oci8_test_sql_execute($c, $stmtarray); + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$mybv = INITMYBV; +$r = OCIBindByName($stid, ':MYBV', $mybv); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_2_11gR1.phpt b/ext/oci8/tests/bug27303_2_11gR1.phpt new file mode 100644 index 0000000..1e3e310 --- /dev/null +++ b/ext/oci8/tests/bug27303_2_11gR1.phpt @@ -0,0 +1,259 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using specific Oracle database versions"); + } + } +} +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab", + "create sequence myseq", + "create table mytab (mydata varchar2(20), seqcol number)" +); + +oci8_test_sql_execute($c, $stmtarray); + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$mybv = INITMYBV; +$r = OCIBindByName($stid, ':MYBV', $mybv); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$stmtarray = array( + "drop sequence myseq", + "drop table mytab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "10" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "11" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "12" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "13" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "14" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "15" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "16" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "17" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "18" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +string(2) "19" +Done diff --git a/ext/oci8/tests/bug27303_3.phpt b/ext/oci8/tests/bug27303_3.phpt new file mode 100644 index 0000000..6395388 --- /dev/null +++ b/ext/oci8/tests/bug27303_3.phpt @@ -0,0 +1,252 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + @oci_execute($stmt); +} + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$mybv = INITMYBV; +$r = OCIBindByName($stid, ':MYBV', $mybv, 5, SQLT_INT); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(2) +int(3) +int(4) +int(5) +int(6) +int(7) +int(8) +int(9) +int(10) +int(11) +int(12) +int(13) +int(14) +int(15) +int(16) +int(17) +int(18) +int(19) +int(20) +int(21) +int(22) +int(23) +int(24) +int(25) +int(26) +int(27) +int(28) +int(29) +int(30) +int(31) +int(32) +int(33) +int(34) +int(35) +int(36) +int(37) +int(38) +int(39) +int(40) +int(41) +int(42) +int(43) +int(44) +int(45) +int(46) +int(47) +int(48) +int(49) +int(50) +int(51) +int(52) +int(53) +int(54) +int(55) +int(56) +int(57) +int(58) +int(59) +int(60) +int(61) +int(62) +int(63) +int(64) +int(65) +int(66) +int(67) +int(68) +int(69) +int(70) +int(71) +int(72) +int(73) +int(74) +int(75) +int(76) +int(77) +int(78) +int(79) +int(80) +int(81) +int(82) +int(83) +int(84) +int(85) +int(86) +int(87) +int(88) +int(89) +int(90) +int(91) +int(92) +int(93) +int(94) +int(95) +int(96) +int(97) +int(98) +int(99) +int(100) +int(101) +int(102) +int(103) +int(104) +int(105) +int(106) +int(107) +int(108) +int(109) +int(110) +int(111) +int(112) +int(113) +int(114) +int(115) +int(116) +int(117) +int(118) +int(119) +int(120) +int(121) +int(122) +int(123) +int(124) +int(125) +int(126) +int(127) +int(128) +int(129) +int(130) +int(131) +int(132) +int(133) +int(134) +int(135) +int(136) +int(137) +int(138) +int(139) +int(140) +int(141) +int(142) +int(143) +int(144) +int(145) +int(146) +int(147) +int(148) +int(149) +int(150) +int(151) +int(152) +int(153) +int(154) +int(155) +int(156) +int(157) +int(158) +int(159) +int(160) +int(161) +int(162) +int(163) +int(164) +int(165) +int(166) +int(167) +int(168) +int(169) +int(170) +int(171) +int(172) +int(173) +int(174) +int(175) +int(176) +int(177) +int(178) +int(179) +int(180) +int(181) +int(182) +int(183) +int(184) +int(185) +int(186) +int(187) +int(188) +int(189) +int(190) +int(191) +int(192) +int(193) +int(194) +int(195) +int(196) +int(197) +int(198) +int(199) +Done diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt new file mode 100644 index 0000000..3137db8 --- /dev/null +++ b/ext/oci8/tests/bug27303_4.phpt @@ -0,0 +1,258 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && + preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); + // Other point releases may also work +} +if (preg_match('/^11\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} +?> +--ENV-- +NLS_LANG= +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +oci8_test_sql_execute($c, $create_st); + +define('MYLIMIT', 200); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$r = OCIBindByName($stid, ':MYBV', $mybv, 0 ); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +oci8_test_sql_execute($c, $drop_st); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_4_11gR1.phpt b/ext/oci8/tests/bug27303_4_11gR1.phpt new file mode 100644 index 0000000..f9bc2da --- /dev/null +++ b/ext/oci8/tests/bug27303_4_11gR1.phpt @@ -0,0 +1,255 @@ +--TEST-- +Bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +// The bind buffer size edge cases seem to change each DB version. +if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { + if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using specific Oracle database versions"); + } + } +} +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +oci8_test_sql_execute($c, $create_st); + +define('MYLIMIT', 200); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$r = OCIBindByName($stid, ':MYBV', $mybv, 0 ); +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +oci8_test_sql_execute($c, $drop_st); + +echo "Done\n"; +?> +--EXPECT-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "2" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "3" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "4" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "5" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "6" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "7" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "8" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "9" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +Done diff --git a/ext/oci8/tests/bug32325.phpt b/ext/oci8/tests/bug32325.phpt new file mode 100644 index 0000000..854e5c1 --- /dev/null +++ b/ext/oci8/tests/bug32325.phpt @@ -0,0 +1,52 @@ +--TEST-- +Bug #32325 (Cannot retrieve collection using OCI8) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialize + +$stmtarray = array( + "create or replace type bug32325_t as table of number" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$collection = oci_new_collection($c, "BUG32325_T"); + +$sql = "begin + select bug32325_t(1,2,3,4) into :list from dual; + end;"; + +$stmt = oci_parse($c, $sql); + +oci_bind_by_name($stmt, ":list", $collection, -1, OCI_B_NTY); +oci_execute($stmt); + +var_dump($collection->size()); +var_dump($collection->getelem(1)); +var_dump($collection->getelem(2)); + +// Cleanup + +$stmtarray = array( + "drop type bug32325_t" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +int(4) +float(2) +float(3) +Done diff --git a/ext/oci8/tests/bug35973.phpt b/ext/oci8/tests/bug35973.phpt new file mode 100644 index 0000000..3f4299e --- /dev/null +++ b/ext/oci8/tests/bug35973.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #35973 (Error ORA-24806 occurs when trying to fetch a NCLOB field) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/bug36010.phpt b/ext/oci8/tests/bug36010.phpt new file mode 100644 index 0000000..d181046 --- /dev/null +++ b/ext/oci8/tests/bug36010.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #36010 (Crash when executing SQL statment with lob parameter twice) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +function f($conn) +{ + $sql = "begin :p_clob := 'lob string'; end;"; + $stid = oci_parse($conn, $sql); + $clob = oci_new_descriptor($conn, OCI_D_LOB); + oci_bind_by_name($stid, ":p_clob", $clob, -1, OCI_B_CLOB); + $r = oci_execute($stid, OCI_DEFAULT); +} + +f($c); +f($c); + +echo "Done\n"; + +?> +--EXPECT-- +Done diff --git a/ext/oci8/tests/bug36096.phpt b/ext/oci8/tests/bug36096.phpt new file mode 100644 index 0000000..2ec366b --- /dev/null +++ b/ext/oci8/tests/bug36096.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #36096 (oci_result() returns garbage after oci_fetch() failed) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$sql = "SELECT 'ABC' FROM DUAL WHERE 1<>1"; +$stmt = oci_parse($c, $sql); + +if(oci_execute($stmt, OCI_COMMIT_ON_SUCCESS)){ + var_dump(oci_fetch($stmt)); + var_dump(oci_result($stmt, 1)); + var_dump(oci_field_name($stmt, 1)); + var_dump(oci_field_type($stmt, 1)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +bool(false) +bool(false) +string(%r[53]%r) "%r('ABC'|EXP)%r" +string(4) "CHAR" +Done diff --git a/ext/oci8/tests/bug36403.phpt b/ext/oci8/tests/bug36403.phpt new file mode 100644 index 0000000..53dae69 --- /dev/null +++ b/ext/oci8/tests/bug36403.phpt @@ -0,0 +1,60 @@ +--TEST-- +Bug #36403 (oci_execute no longer supports OCI_DESCRIBE_ONLY) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip expected output only valid with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table bug36403_tab", + "create table bug36403_tab (c1 number, col2 number, column3 number, col4 number)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from bug36403_tab"); +oci_execute($s, OCI_DESCRIBE_ONLY); +for ($i = oci_num_fields($s); $i > 0; $i--) { + echo oci_field_name($s, $i) . "\n"; +} + +echo "Test 2\n"; + +// Should generate an error: ORA-24338: statement handle not executed +// since the statement handle was only described and not executed +$row = oci_fetch_array($s); + +// Clean up + +$stmtarray = array( + "drop table bug36403_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +COL4 +COLUMN3 +COL2 +C1 +Test 2 + +Warning: oci_fetch_array(): ORA-%r(24338|01002)%r: %sbug36403.php on line %d +===DONE=== diff --git a/ext/oci8/tests/bug37220.phpt b/ext/oci8/tests/bug37220.phpt new file mode 100644 index 0000000..fd91dc7 --- /dev/null +++ b/ext/oci8/tests/bug37220.phpt @@ -0,0 +1,65 @@ +--TEST-- +Bug #37220 (LOB Type mismatch when using windows & oci8.dll) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$stmtarray = array( + "create table bug37220_tab( mycolumn xmltype not null)", + "insert into bug37220_tab values(xmltype('<THETAG myID=\"1234\"></THETAG>'))" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Now let's update the row where myId = 1234 and change the tag +// 'THETAG' to 'MYTAG' (mycolumn is an XMLTYPE datatype and +// bug37220_tab a normal Oracle table) + +$query = "UPDATE bug37220_tab + SET bug37220_tab.mycolumn = updateXML(bug37220_tab.mycolumn,'/THETAG',xmltype.createXML(:data)) + WHERE existsNode(bug37220_tab.mycolumn,'/THETAG[@myID=\"1234\"]') = 1"; +$stmt = oci_parse ($c, $query); +$clob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB); +$clob->writetemporary("<MYTAG/>", OCI_TEMP_CLOB); +$success = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS); +oci_free_statement($stmt); +$clob->close(); + +// Query back the change + +$query = "select * from bug37220_tab"; +$stmt = oci_parse ($c, $query); + +oci_execute($stmt); + +while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo trim($item)."\n"; + } + echo "\n"; +} + +// Cleanup + +$stmtarray = array( + "drop table bug37220_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +<MYTAG/> + +Done diff --git a/ext/oci8/tests/bug37581.phpt b/ext/oci8/tests/bug37581.phpt new file mode 100644 index 0000000..1c00f68 --- /dev/null +++ b/ext/oci8/tests/bug37581.phpt @@ -0,0 +1,72 @@ +--TEST-- +Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..e0fbba8 --- /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 0000000..901f6f7 --- /dev/null +++ b/ext/oci8/tests/bug38173.phpt @@ -0,0 +1,82 @@ +--TEST-- +Bug #38173 (Freeing nested cursors causes OCI8 to segfault) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/bug40078.phpt b/ext/oci8/tests/bug40078.phpt new file mode 100644 index 0000000..4070221 --- /dev/null +++ b/ext/oci8/tests/bug40078.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..fcccfe7 --- /dev/null +++ b/ext/oci8/tests/bug40415.phpt @@ -0,0 +1,203 @@ +--TEST-- +Bug #40415 (Using oci_fetchall with nested cursors) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/bug41069.phpt b/ext/oci8/tests/bug41069.phpt new file mode 100644 index 0000000..5daa46d --- /dev/null +++ b/ext/oci8/tests/bug41069.phpt @@ -0,0 +1,267 @@ +--TEST-- +Bug #41069 (Oracle crash with certain data over a DB-link when prefetch memory limit used - Oracle bug 6039623) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (empty($dbase)) die ("skip requires network connection alias for DB link loopback"); +if ($test_drcp) die("skip DRCP does not support shared database links"); +?> +--INI-- +oci8.default_prefetch=5 +--FILE-- + <?php + + require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "alter session set nls_date_format = 'MM/DD/YYYY'", + + "drop database link bug41069_dblink", + + "drop table bug41069_tab", + + "create shared database link bug41069_dblink authenticated by $user identified by $password using '$dbase'", + + "create table bug41069_tab + ( + c1 number(20), + c2 varchar2(60 byte), + c3 varchar2(1000 byte), + c4 varchar2(255 byte), + c5 varchar2(2 byte), + c6 varchar2(1 byte), + c7 varchar2(255 byte), + c8 varchar2(50 byte), + c9 date, + c10 date, + c12 number(20), + c13 varchar2(20 byte), + c15 varchar2(50 byte) + )", + + "insert into bug41069_tab (c1, c2, c5, c6, c9, c10, c12, c15) values + (111, 'aaaaaaa', 'b', 'c', '01/17/2008', '01/07/2017', 2222, 'zzzzzzzzzz')", + + "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, c13, c15) values + (112, 'aaaaaaa', 'bbbbbbbb', 'ccccccc', 'd', 'e', 'rrrrrrr', '04/16/2007', '04/16/2007', 2223, 'xxxxxxxx', 'zzzzzzzz')", + + "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, c15) values + (113, 'aaaaaaa', 'bbbbbbbbbb', 'cccccc', 'e', 'f', 'dddd', '12/04/2006', '12/04/2006', 2224, 'zzzzzzz')" +); + +oci8_test_sql_execute($c, $stmtarray); + + +// Run Tests + +echo "Test 1: non-DB link case that always worked\n"; +$stid = oci_parse($c, 'select * from bug41069_tab order by c1'); +oci_execute($stid, OCI_DEFAULT); +oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW); +var_dump($results); + +echo "Test 2: Should not crash\n"; +$stid = oci_parse($c, 'select * from bug41069_tab@bug41069_dblink order by c1'); +oci_execute($stid, OCI_DEFAULT); +oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW); +var_dump($results); + +// Cleanup + +$c = oci_new_connect($user, $password, $dbase); + +$stmtarray = array( + "drop database link bug41069_dblink", + "drop table bug41069_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Test 1: non-DB link case that always worked +array(3) { + [0]=> + array(13) { + ["C1"]=> + string(3) "111" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + NULL + ["C4"]=> + NULL + ["C5"]=> + string(1) "b" + ["C6"]=> + string(1) "c" + ["C7"]=> + NULL + ["C8"]=> + NULL + ["C9"]=> + string(10) "01/17/2008" + ["C10"]=> + string(10) "01/07/2017" + ["C12"]=> + string(4) "2222" + ["C13"]=> + NULL + ["C15"]=> + string(10) "zzzzzzzzzz" + } + [1]=> + array(13) { + ["C1"]=> + string(3) "112" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(8) "bbbbbbbb" + ["C4"]=> + string(7) "ccccccc" + ["C5"]=> + string(1) "d" + ["C6"]=> + string(1) "e" + ["C7"]=> + string(7) "rrrrrrr" + ["C8"]=> + NULL + ["C9"]=> + string(10) "04/16/2007" + ["C10"]=> + string(10) "04/16/2007" + ["C12"]=> + string(4) "2223" + ["C13"]=> + string(8) "xxxxxxxx" + ["C15"]=> + string(8) "zzzzzzzz" + } + [2]=> + array(13) { + ["C1"]=> + string(3) "113" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(10) "bbbbbbbbbb" + ["C4"]=> + string(6) "cccccc" + ["C5"]=> + string(1) "e" + ["C6"]=> + string(1) "f" + ["C7"]=> + string(4) "dddd" + ["C8"]=> + NULL + ["C9"]=> + string(10) "12/04/2006" + ["C10"]=> + string(10) "12/04/2006" + ["C12"]=> + string(4) "2224" + ["C13"]=> + NULL + ["C15"]=> + string(7) "zzzzzzz" + } +} +Test 2: Should not crash +array(3) { + [0]=> + array(13) { + ["C1"]=> + string(3) "111" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + NULL + ["C4"]=> + NULL + ["C5"]=> + string(1) "b" + ["C6"]=> + string(1) "c" + ["C7"]=> + NULL + ["C8"]=> + NULL + ["C9"]=> + string(10) "01/17/2008" + ["C10"]=> + string(10) "01/07/2017" + ["C12"]=> + string(4) "2222" + ["C13"]=> + NULL + ["C15"]=> + string(10) "zzzzzzzzzz" + } + [1]=> + array(13) { + ["C1"]=> + string(3) "112" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(8) "bbbbbbbb" + ["C4"]=> + string(7) "ccccccc" + ["C5"]=> + string(1) "d" + ["C6"]=> + string(1) "e" + ["C7"]=> + string(7) "rrrrrrr" + ["C8"]=> + NULL + ["C9"]=> + string(10) "04/16/2007" + ["C10"]=> + string(10) "04/16/2007" + ["C12"]=> + string(4) "2223" + ["C13"]=> + string(8) "xxxxxxxx" + ["C15"]=> + string(8) "zzzzzzzz" + } + [2]=> + array(13) { + ["C1"]=> + string(3) "113" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(10) "bbbbbbbbbb" + ["C4"]=> + string(6) "cccccc" + ["C5"]=> + string(1) "e" + ["C6"]=> + string(1) "f" + ["C7"]=> + string(4) "dddd" + ["C8"]=> + NULL + ["C9"]=> + string(10) "12/04/2006" + ["C10"]=> + string(10) "12/04/2006" + ["C12"]=> + string(4) "2224" + ["C13"]=> + NULL + ["C15"]=> + string(7) "zzzzzzz" + } +} +Done diff --git a/ext/oci8/tests/bug42134.phpt b/ext/oci8/tests/bug42134.phpt new file mode 100644 index 0000000..10b7ef1 --- /dev/null +++ b/ext/oci8/tests/bug42134.phpt @@ -0,0 +1,103 @@ +--TEST-- +Bug #42134 (Collection error for invalid collection name) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Test collection creation error for normal connection + +if (!empty($dbase)) { + $c = oci_connect($user,$password,$dbase); +} +else { + $c = oci_connect($user,$password); +} + +$collection = oci_new_collection($c, "ABC"); +if (!$collection) { + echo "Normal connection: New Collection error\n"; + $m = oci_error($c); + var_dump($m); +} + +// Test collection creation error for new connection + +if (!empty($dbase)) { + $c = oci_new_connect($user,$password,$dbase); +} +else { + $c = oci_new_connect($user,$password); +} + +$collection = oci_new_collection($c, "DEF"); +if (!$collection) { + echo "New connection: New Collection error\n"; + $m = oci_error($c); + var_dump($m); +} + +// Test collection creation error for persistent connection + +if (!empty($dbase)) { + $c = oci_pconnect($user,$password,$dbase); +} +else { + $c = oci_pconnect($user,$password); +} + +$collection = oci_new_collection($c, "GHI"); +if (!$collection) { + echo "Persistent connection: New Collection error\n"; + $m = oci_error($c); + var_dump($m); +} + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_new_collection(): OCI-22303: type ""."ABC" not found in %s on line %d +Normal connection: New Collection error +array(4) { + ["code"]=> + int(22303) + ["message"]=> + string(34) "OCI-22303: type ""."ABC" not found" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} + +Warning: oci_new_collection(): OCI-22303: type ""."DEF" not found in %s on line %d +New connection: New Collection error +array(4) { + ["code"]=> + int(22303) + ["message"]=> + string(34) "OCI-22303: type ""."DEF" not found" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} + +Warning: oci_new_collection(): OCI-22303: type ""."GHI" not found in %s on line %d +Persistent connection: New Collection error +array(4) { + ["code"]=> + int(22303) + ["message"]=> + string(34) "OCI-22303: type ""."GHI" not found" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/bug42173.phpt b/ext/oci8/tests/bug42173.phpt new file mode 100644 index 0000000..d5e2f70 --- /dev/null +++ b/ext/oci8/tests/bug42173.phpt @@ -0,0 +1,171 @@ +--TEST-- +Bug #42173 (TIMESTAMP and INTERVAL query and field functions) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$stmts = array( + +"drop table ts_test", + +"create table ts_test ( +c1 TIMESTAMP, +c2 TIMESTAMP (5), +c3 TIMESTAMP WITH TIME ZONE, +c4 TIMESTAMP (2) WITH TIME ZONE, +c5 TIMESTAMP WITH LOCAL TIME ZONE, +c6 INTERVAL YEAR TO MONTH, +c7 INTERVAL YEAR(2) TO MONTH, +c8 INTERVAL DAY TO SECOND, +c9 INTERVAL DAY(2) TO SECOND(3) +)", + +"insert into ts_test values ( +timestamp'1999-01-03 10:00:00.123', +timestamp'1999-01-04 10:00:00.123456', +timestamp'1999-01-05 10:00:00.123456+1:0', +timestamp'1999-01-06 10:00:00.123456-1:0', +timestamp'1999-01-06 10:00:00.123456-1:0', +interval'1-2' year to month, +interval'10-4' year to month, +interval'1 2:20:20.123' day to second, +interval'1 2:20:20.12345' day to second)"); + +foreach ($stmts as $sql) { + $s = oci_parse($c, $sql); + $r = @oci_execute($s); +} + +$s = oci_parse($c, "select * from ts_test"); +$r = oci_execute($s); +$row = oci_fetch_array($s, OCI_ASSOC); +var_dump($row); + +foreach ($row as $name => $field) { + echo "\nColumn $name\n"; + var_dump(oci_field_is_null($s, $name)); + var_dump(oci_field_name($s, $name)); + var_dump(oci_field_type($s, $name)); + var_dump(oci_field_type_raw($s, $name)); + var_dump(oci_field_scale($s, $name)); + var_dump(oci_field_precision($s, $name)); + var_dump(oci_field_size($s, $name)); +} + +// Cleanup + +$s = oci_parse($c, "drop table ts_test"); +$r = @oci_execute($s); + +echo "Done\n"; + +?> +--EXPECTF-- +array(9) { + ["C1"]=> + string(28) "03-JAN-99 10.00.00.123000 AM" + ["C2"]=> + string(27) "04-JAN-99 10.00.00.12346 AM" + ["C3"]=> + string(35) "05-JAN-99 10.00.00.123456 AM +01:00" + ["C4"]=> + string(31) "06-JAN-99 10.00.00.12 AM -01:00" + ["C5"]=> + string(28) "%s" + ["C6"]=> + string(6) "+01-02" + ["C7"]=> + string(6) "+10-04" + ["C8"]=> + string(19) "+01 02:20:20.123000" + ["C9"]=> + string(16) "+01 02:20:20.123" +} + +Column C1 +bool(false) +string(2) "C1" +string(9) "TIMESTAMP" +int(187) +int(6) +int(0) +int(11) + +Column C2 +bool(false) +string(2) "C2" +string(9) "TIMESTAMP" +int(187) +int(5) +int(0) +int(11) + +Column C3 +bool(false) +string(2) "C3" +string(23) "TIMESTAMP WITH TIMEZONE" +int(188) +int(6) +int(0) +int(13) + +Column C4 +bool(false) +string(2) "C4" +string(23) "TIMESTAMP WITH TIMEZONE" +int(188) +int(2) +int(0) +int(13) + +Column C5 +bool(false) +string(2) "C5" +string(29) "TIMESTAMP WITH LOCAL TIMEZONE" +int(232) +int(6) +int(0) +int(11) + +Column C6 +bool(false) +string(2) "C6" +string(22) "INTERVAL YEAR TO MONTH" +int(189) +int(0) +int(2) +int(5) + +Column C7 +bool(false) +string(2) "C7" +string(22) "INTERVAL YEAR TO MONTH" +int(189) +int(0) +int(2) +int(5) + +Column C8 +bool(false) +string(2) "C8" +string(22) "INTERVAL DAY TO SECOND" +int(190) +int(6) +int(2) +int(11) + +Column C9 +bool(false) +string(2) "C9" +string(22) "INTERVAL DAY TO SECOND" +int(190) +int(3) +int(2) +int(11) +Done diff --git a/ext/oci8/tests/bug42496_1.phpt b/ext/oci8/tests/bug42496_1.phpt new file mode 100644 index 0000000..d430474 --- /dev/null +++ b/ext/oci8/tests/bug42496_1.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$stmtarray = array( + "DROP table bug42496_1_tab", + "CREATE table bug42496_1_tab(c1 CLOB, c2 CLOB)", + "INSERT INTO bug42496_1_tab VALUES('test1', 'test1')", + "INSERT INTO bug42496_1_tab VALUES('test2', 'test2')", + "INSERT INTO bug42496_1_tab VALUES('test3', 'test3')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +for ($i = 0; $i < 15000; $i++) { + $s = oci_parse($c, "SELECT * from bug42496_1_tab"); + oci_define_by_name($s, "C1", $col1); + oci_define_by_name($s, "C2", $col2); + if (oci_execute($s)) { + $arr = array(); + while ($arr = oci_fetch_assoc($s)) { + $arr['C1']->free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug42496_1_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECTF-- +Test 1 +Done diff --git a/ext/oci8/tests/bug42496_2.phpt b/ext/oci8/tests/bug42496_2.phpt new file mode 100644 index 0000000..71854f3 --- /dev/null +++ b/ext/oci8/tests/bug42496_2.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$stmtarray = array( + "DROP table bug42496_2_tab", + "CREATE table bug42496_2_tab(c1 CLOB, c2 CLOB)", + "INSERT INTO bug42496_2_tab VALUES('test1', 'test1')", + "INSERT INTO bug42496_2_tab VALUES('test2', 'test2')", + "INSERT INTO bug42496_2_tab VALUES('test3', 'test3')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 2\n"; + +for ($i = 0; $i < 15000; $i++) { + $s = oci_parse($c, "SELECT * from bug42496_2_tab"); + if (oci_execute($s)) { + $arr = array(); + while ($arr = oci_fetch_assoc($s)) { + $arr['C1']->free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug42496_2_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECTF-- +Test 2 +Done diff --git a/ext/oci8/tests/bug42841.phpt b/ext/oci8/tests/bug42841.phpt new file mode 100644 index 0000000..a86d1ca --- /dev/null +++ b/ext/oci8/tests/bug42841.phpt @@ -0,0 +1,184 @@ +--TEST-- +Bug #42841 (REF CURSOR and oci_new_cursor PHP crash) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--INI-- +oci8.statement_cache_size=20 +--FILE-- +<?php + +require dirname(__FILE__).'/details.inc'; + +// note a oci_new_connect() occurs lower in the script +$c = oci_connect($user, $password, $dbase); + +// Initialization + +$stmtarray = array( + "create or replace procedure bug42841_proc(out_1 out sys_refcursor) is + begin + open out_1 for select 11 from dual union all select 12 from dual union all select 13 from dual; + end bug42841_proc;", + + "create or replace package bug43449_pkg is + type cursortype is ref Cursor; + function testcursor return cursortype; + end bug43449_pkg;", + + "create or replace package body bug43449_pkg is + function testcursor return cursortype is + retCursor cursorType; + begin + Open retCursor For 'select * from dual'; + return retCursor; + end; + end bug43449_pkg;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Main code + +function do_bug42841($c) +{ + echo "First attempt\n"; + + $sql = "BEGIN bug42841_proc(:cursor); END;"; + $stmt = oci_parse($c, $sql); + $cursor = oci_new_cursor($c); + oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cursor); + + while($row = oci_fetch_array($cursor, OCI_ASSOC + OCI_RETURN_LOBS)) { + $data1[] = $row; + } + + oci_free_statement($stmt); + oci_free_statement($cursor); + var_dump($data1); + + echo "Second attempt\n"; + + $sql = "BEGIN bug42841_proc(:cursor); END;"; + $stmt = oci_parse($c, $sql); + $cursor = oci_new_cursor($c); + oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cursor); + + while($row = oci_fetch_array($cursor, OCI_ASSOC + OCI_RETURN_LOBS)) { + $data2[] = $row; + } + + oci_free_statement($stmt); + oci_free_statement($cursor); + var_dump($data2); +} + +function do_bug43449($c) +{ + + for ($i = 0; $i < 2; $i++) { + var_dump(bug43449_getCur($c)); + } +} + +function bug43449_getCur($c) +{ + $cur = oci_new_cursor($c); + $stmt = oci_parse($c, 'begin :cur := bug43449_pkg.testcursor; end;'); + oci_bind_by_name($stmt, ':cur', $cur, -1, OCI_B_CURSOR); + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cur, OCI_DEFAULT); + + $ret = array(); + + while (ocifetchinto($cur, $row, OCI_ASSOC)) { + $ret[] = $row; + } + + oci_free_statement($cur); + oci_free_statement($stmt); + return $ret; +} + +echo "Test bug 42841: Procedure with OUT cursor parameter\n"; +do_bug42841($c); + +$c = oci_new_connect($user, $password, $dbase); + +echo "Test bug 43449: Cursor as function result\n"; +do_bug43449($c); + +// Cleanup + +$stmtarray = array( + "drop procedure bug42841_proc", + "drop package bug43449_pkg" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Test bug 42841: Procedure with OUT cursor parameter +First attempt +array(3) { + [0]=> + array(1) { + [11]=> + string(2) "11" + } + [1]=> + array(1) { + [11]=> + string(2) "12" + } + [2]=> + array(1) { + [11]=> + string(2) "13" + } +} +Second attempt +array(3) { + [0]=> + array(1) { + [11]=> + string(2) "11" + } + [1]=> + array(1) { + [11]=> + string(2) "12" + } + [2]=> + array(1) { + [11]=> + string(2) "13" + } +} +Test bug 43449: Cursor as function result +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} +Done diff --git a/ext/oci8/tests/bug43492.phpt b/ext/oci8/tests/bug43492.phpt new file mode 100644 index 0000000..e84fa42 --- /dev/null +++ b/ext/oci8/tests/bug43492.phpt @@ -0,0 +1,373 @@ +--TEST-- +Bug #43492 (Nested cursor leaks) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$stmtarray = array( + "DROP table bug43492_tab", + "CREATE TABLE bug43492_tab(col1 VARCHAR2(1))", + "INSERT INTO bug43492_tab VALUES ('A')", + "INSERT INTO bug43492_tab VALUES ('B')", + "INSERT INTO bug43492_tab VALUES ('C')", + "INSERT INTO bug43492_tab VALUES ('D')", + "INSERT INTO bug43492_tab VALUES ('E')", + "INSERT INTO bug43492_tab VALUES ('F')", + "INSERT INTO bug43492_tab VALUES ('G')", + "INSERT INTO bug43492_tab VALUES ('H')", + "INSERT INTO bug43492_tab VALUES ('I')", + "INSERT INTO bug43492_tab VALUES ('J')" +); + +oci8_test_sql_execute($c, $stmtarray); + +/* + +While fetching data from a ref cursor, the parent statement needs to +be around. Also when the parent statement goes out of scope, it is +not automatically released which causes a cursor leak. + +If either or both of the lines marked (*) are removed, then the script +will fail with the error "ORA-01000: maximum open cursors exceeded". + +*/ + +function fetch($c, $i) { + global $s; // (*) Allow parent statement to be available when child is used + $s = ociparse($c, 'select cursor(select * from bug43492_tab) c from bug43492_tab'); + ociexecute($s, OCI_DEFAULT); + ocifetchinto($s, $result, OCI_ASSOC); + ociexecute($result['C'], OCI_DEFAULT); + return $result['C']; +} + +for($i = 0; $i < 300; $i++) { + $cur = fetch($c, $i); + for($j = 0; $j < 10; $j++) { + ocifetchinto($cur, $row, OCI_NUM); + echo "$row[0] "; + } + echo "\n"; + ocifreestatement($cur); + ocifreestatement($s); // (*) Free the parent statement cleanly +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug43492_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECT-- +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +Done diff --git a/ext/oci8/tests/bug43492_2.phpt b/ext/oci8/tests/bug43492_2.phpt new file mode 100644 index 0000000..61511cf --- /dev/null +++ b/ext/oci8/tests/bug43492_2.phpt @@ -0,0 +1,364 @@ +--TEST-- +Bug #43492 (Nested cursor leaks after related bug #44206 fixed) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +// This test is similar to bug43492.phpt without the explict free. +// Now that bug 44206 is fixed an automatic clean up will occur - +// though it is still recommended in practice. + +require dirname(__FILE__).'/connect.inc'; + +$stmtarray = array( + "DROP table bug43492_tab", + "CREATE TABLE bug43492_tab(col1 VARCHAR2(1))", + "INSERT INTO bug43492_tab VALUES ('A')", + "INSERT INTO bug43492_tab VALUES ('B')", + "INSERT INTO bug43492_tab VALUES ('C')", + "INSERT INTO bug43492_tab VALUES ('D')", + "INSERT INTO bug43492_tab VALUES ('E')", + "INSERT INTO bug43492_tab VALUES ('F')", + "INSERT INTO bug43492_tab VALUES ('G')", + "INSERT INTO bug43492_tab VALUES ('H')", + "INSERT INTO bug43492_tab VALUES ('I')", + "INSERT INTO bug43492_tab VALUES ('J')" +); + +oci8_test_sql_execute($c, $stmtarray); + +function fetch($c, $i) { + $s = ociparse($c, 'select cursor(select * from bug43492_tab) c from bug43492_tab'); + ociexecute($s, OCI_DEFAULT); + ocifetchinto($s, $result, OCI_ASSOC); + ociexecute($result['C'], OCI_DEFAULT); + return $result['C']; +} + +for($i = 0; $i < 300; $i++) { + $cur = fetch($c, $i); + for($j = 0; $j < 10; $j++) { + ocifetchinto($cur, $row, OCI_NUM); + echo "$row[0] "; + } + echo "\n"; + ocifreestatement($cur); +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug43492_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECT-- +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +A B C D E F G H I J +Done diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt new file mode 100644 index 0000000..8c57fab --- /dev/null +++ b/ext/oci8/tests/bug43497.phpt @@ -0,0 +1,301 @@ +--TEST-- +Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip expected output only valid with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +function sessionid($c) // determines and returns current session ID +{ + $query = "select sid from v\$session where audsid = userenv('sessionid')"; + + $stmt = oci_parse($c, $query); + + if (oci_execute($stmt, OCI_DEFAULT)) { + $row = oci_fetch($stmt); + return oci_result($stmt, 1); + } + + return null; +} + + +function templobs($c, $sid) // returns number of temporary LOBs +{ + $query = "select abstract_lobs from v\$temporary_lobs where sid = " . $sid; + + $stmt = oci_parse($c, $query); + + if (oci_execute($stmt, OCI_DEFAULT)) { + $row = oci_fetch($stmt); + $val = oci_result($stmt, 1); + oci_free_statement($stmt); + return $val; + } + return null; +} + + +// Read all XML data using explicit LOB locator +function readxmltab_ex($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + $result[0]->free(); // cleanup properly + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +// Read all XML data using explicit LOB locator but without freeing the temp lobs +function readxmltab_ex_nofree($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +// Read all XML data using implicit LOB locator +function readxmltab_im($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM+OCI_RETURN_LOBS)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +function createxmltab($c) // create table w/ field of XML type +{ + @dropxmltab($c); + $stmt = oci_parse($c, "create table bug43497_tab (id number primary key, xml xmltype)"); + oci_execute($stmt); +} + +function dropxmltab($c) // delete table +{ + $stmt = oci_parse($c, "drop table bug43497_tab"); + oci_execute($stmt); +} + + +function fillxmltab($c) +{ + for ($id = 1; $id <= 100; $id++) { + + // create an XML element string with random data + $s = "<data>"; + for ($j = 0; $j < 128; $j++) { + $s .= rand(); + } + $s .= "</data>\n"; + for ($j = 0; $j < 4; $j++) { + $s .= $s; + } + $data = "<?xml version=\"1.0\"?><records>" . $s . "</records>"; + + // insert XML data into database + + $stmt = oci_parse($c, "insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))"); + oci_bind_by_name($stmt, ":id", $id); + $clob = oci_new_descriptor($c, OCI_D_LOB); + oci_bind_by_name($stmt, ":xml", $clob, -1, OCI_B_CLOB); + $clob->writetemporary($data); + oci_execute($stmt); + + $clob->close(); + $clob->free(); + } +} + + +// Initialize + +createxmltab($c); +fillxmltab($c); + +// Run Test + +$sid = sessionid($c); + +echo "Explicit LOB use\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_ex($c); +} + +echo "\nImplicit LOB use\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_im($c); +} + +echo "\nExplicit LOB with no free\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_ex_nofree($c); +} + + + +// Cleanup + +dropxmltab($c); + +oci_close($c); + +echo "Done\n"; +?> +--EXPECT-- +Explicit LOB use + +Run = 1 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 0 +Loop count check = 100 + +Implicit LOB use + +Run = 1 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 0 +Loop count check = 100 + +Explicit LOB with no free + +Run = 1 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 0 +Loop count check = 100 +Done diff --git a/ext/oci8/tests/bug43497_92.phpt b/ext/oci8/tests/bug43497_92.phpt new file mode 100644 index 0000000..cc2a963 --- /dev/null +++ b/ext/oci8/tests/bug43497_92.phpt @@ -0,0 +1,305 @@ +--TEST-- +Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$iv = preg_match('/Oracle .*Version => (9\.2)/', $phpinfo); +if ($iv != 1) { + die ("skip tests a feature that works only with Oracle 9iR2 client"); +} +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +function sessionid($c) // determines and returns current session ID +{ + $query = "select sid from v\$session where audsid = userenv('sessionid')"; + + $stmt = oci_parse($c, $query); + + if (oci_execute($stmt, OCI_DEFAULT)) { + $row = oci_fetch($stmt); + return oci_result($stmt, 1); + } + + return null; +} + + +function templobs($c, $sid) // returns number of temporary LOBs +{ + $query = "select abstract_lobs from v\$temporary_lobs where sid = " . $sid; + + $stmt = oci_parse($c, $query); + + if (oci_execute($stmt, OCI_DEFAULT)) { + $row = oci_fetch($stmt); + $val = oci_result($stmt, 1); + oci_free_statement($stmt); + return $val; + } + return null; +} + + +// Read all XML data using explicit LOB locator +function readxmltab_ex($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + $result[0]->free(); // cleanup properly + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +// Read all XML data using explicit LOB locator but without freeing the temp lobs +function readxmltab_ex_nofree($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +// Read all XML data using implicit LOB locator +function readxmltab_im($c) +{ + $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); + + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM+OCI_RETURN_LOBS)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; +} + +function createxmltab($c) // create table w/ field of XML type +{ + @dropxmltab($c); + $stmt = oci_parse($c, "create table bug43497_tab (id number primary key, xml xmltype)"); + oci_execute($stmt); +} + +function dropxmltab($c) // delete table +{ + $stmt = oci_parse($c, "drop table bug43497_tab"); + oci_execute($stmt); +} + + +function fillxmltab($c) +{ + for ($id = 1; $id <= 100; $id++) { + + // create an XML element string with random data + $s = "<data>"; + for ($j = 0; $j < 128; $j++) { + $s .= rand(); + } + $s .= "</data>\n"; + for ($j = 0; $j < 4; $j++) { + $s .= $s; + } + $data = "<?xml version=\"1.0\"?><records>" . $s . "</records>"; + + // insert XML data into database + + $stmt = oci_parse($c, "insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))"); + oci_bind_by_name($stmt, ":id", $id); + $clob = oci_new_descriptor($c, OCI_D_LOB); + oci_bind_by_name($stmt, ":xml", $clob, -1, OCI_B_CLOB); + $clob->writetemporary($data); + oci_execute($stmt); + + $clob->close(); + $clob->free(); + } +} + + +// Initialize + +createxmltab($c); +fillxmltab($c); + +// Run Test + +$sid = sessionid($c); + +echo "Explicit LOB use\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_ex($c); +} + +echo "\nImplicit LOB use\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_im($c); +} + +echo "\nExplicit LOB with no free (i.e. a temp lob leak)\n"; +for ($i = 1; $i <= 10; $i++) { + echo "\nRun = " . $i . "\n"; + echo "Temporary LOBs = " . templobs($c, $sid) . "\n"; + readxmltab_ex_nofree($c); +} + + + +// Cleanup + +dropxmltab($c); + +oci_close($c); + +echo "Done\n"; +?> +--EXPECT-- +Explicit LOB use + +Run = 1 +Temporary LOBs = 0 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 100 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 200 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 300 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 400 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 500 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 600 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 700 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 800 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 900 +Loop count check = 100 + +Implicit LOB use + +Run = 1 +Temporary LOBs = 1000 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 1100 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 1200 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 1300 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 1400 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 1500 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 1600 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 1700 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 1800 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 1900 +Loop count check = 100 + +Explicit LOB with no free (i.e. a temp lob leak) + +Run = 1 +Temporary LOBs = 2000 +Loop count check = 100 + +Run = 2 +Temporary LOBs = 2100 +Loop count check = 100 + +Run = 3 +Temporary LOBs = 2200 +Loop count check = 100 + +Run = 4 +Temporary LOBs = 2300 +Loop count check = 100 + +Run = 5 +Temporary LOBs = 2400 +Loop count check = 100 + +Run = 6 +Temporary LOBs = 2500 +Loop count check = 100 + +Run = 7 +Temporary LOBs = 2600 +Loop count check = 100 + +Run = 8 +Temporary LOBs = 2700 +Loop count check = 100 + +Run = 9 +Temporary LOBs = 2800 +Loop count check = 100 + +Run = 10 +Temporary LOBs = 2900 +Loop count check = 100 +Done
\ No newline at end of file diff --git a/ext/oci8/tests/bug44008.phpt b/ext/oci8/tests/bug44008.phpt new file mode 100644 index 0000000..faacdc6 --- /dev/null +++ b/ext/oci8/tests/bug44008.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #44008 (Incorrect usage of OCI-Lob->close crashes PHP) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$stmtarray = array( + "create or replace procedure bug44008_proc (p in out clob) + as begin p := 'A'; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$s = oci_parse($c, 'begin bug44008_proc(:data); end;'); +$textLob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ":data", $textLob, -1, OCI_B_CLOB); +oci_execute($s, OCI_DEFAULT); +$r = $textLob->load(); +echo "$r\n"; + +// Incorrectly closing the lob doesn't cause a crash. +// OCI-LOB->close() is documented for use only with OCI-Lob->writeTemporary() +$textLob->close(); + +// Cleanup + +$stmtarray = array( + "drop procedure bug44008_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +A +Done diff --git a/ext/oci8/tests/bug44113.phpt b/ext/oci8/tests/bug44113.phpt new file mode 100644 index 0000000..d441715 --- /dev/null +++ b/ext/oci8/tests/bug44113.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #44113 (New collection creation can fail with OCI-22303) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace type bug44113_list_t as table of number" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test +// The test can take some time to complete and can exceed PHP's test +// timout limit on slow networks. + +for ($x = 0; $x < 70000; $x++) { + if (!($var = oci_new_collection($c, 'BUG44113_LIST_T'))) { + print "Failed new collection creation on $x\n"; + break; + } +} + +print "Completed $x\n"; + +// Cleanup + +$stmtarray = array( + "drop type bug44113_list_t" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Completed 70000 +Done diff --git a/ext/oci8/tests/bug44206.phpt b/ext/oci8/tests/bug44206.phpt new file mode 100644 index 0000000..63805bf --- /dev/null +++ b/ext/oci8/tests/bug44206.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #44206 (Test if selecting ref cursors leads to ORA-1000 maximum open cursors reached) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Run Test + +for ($x = 0; $x < 400; $x++) +{ + $stmt = "select cursor (select $x from dual) a, + cursor (select $x from dual) b + from dual"; + $s = oci_parse($c, $stmt); + $r = oci_execute($s); + if (!$r) { + echo "Exiting $x\n"; + exit; + } + $mode = OCI_ASSOC | OCI_RETURN_NULLS; + $result = oci_fetch_array($s, $mode); + oci_execute($result['A']); + oci_execute($result['B']); + oci_fetch_array($result['A'], $mode); + oci_fetch_array($result['B'], $mode); + oci_free_statement($result['A']); + oci_free_statement($result['B']); + oci_free_statement($s); +} + +echo "Completed $x\n"; + +oci_close($c); + +echo "Done\n"; + +?> +--EXPECT-- +Completed 400 +Done diff --git a/ext/oci8/tests/bug45458.phpt b/ext/oci8/tests/bug45458.phpt new file mode 100644 index 0000000..b257f1f --- /dev/null +++ b/ext/oci8/tests/bug45458.phpt @@ -0,0 +1,84 @@ +--TEST-- +Bug #45458 (OCI8: Numeric keys for associative arrays are not handled properly) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1\n"; + +$stmt = 'select dummy "A", dummy "20" from dual'; + +$s = oci_parse($c, $stmt); +oci_execute($s); +$r = oci_fetch_all($s, $data, 0, -1, OCI_FETCHSTATEMENT_BY_ROW); +var_dump($data); +var_dump($data[0]); +var_dump($data[0]["A"]); +var_dump($data[0]["20"]); +oci_free_statement($s); + +echo "Test 2\n"; + +$s = oci_parse($c, $stmt); +oci_execute($s); +$r = oci_fetch_all($s, $data, 0, -1, OCI_ASSOC); +var_dump($data); +var_dump($data["A"]); +var_dump($data["20"]); +var_dump($data["A"][0]); +var_dump($data["20"][0]); +oci_free_statement($s); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +Test 1 +array(1) { + [0]=> + array(2) { + ["A"]=> + string(1) "X" + [20]=> + string(1) "X" + } +} +array(2) { + ["A"]=> + string(1) "X" + [20]=> + string(1) "X" +} +string(1) "X" +string(1) "X" +Test 2 +array(2) { + ["A"]=> + array(1) { + [0]=> + string(1) "X" + } + [20]=> + array(1) { + [0]=> + string(1) "X" + } +} +array(1) { + [0]=> + string(1) "X" +} +array(1) { + [0]=> + string(1) "X" +} +string(1) "X" +string(1) "X" +===DONE=== diff --git a/ext/oci8/tests/bug46994.phpt b/ext/oci8/tests/bug46994.phpt new file mode 100644 index 0000000..604b57f --- /dev/null +++ b/ext/oci8/tests/bug46994.phpt @@ -0,0 +1,83 @@ +--TEST-- +Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure bug46994_proc1(p1 in out nocopy clob) is + begin + dbms_lob.trim(p1, 0); + dbms_lob.writeappend(p1, 26, 'This should be the output.'); + end bug46994_proc1;", + "create or replace procedure bug46994_proc2(p1 in out nocopy clob) is + begin + dbms_lob.trim(p1, 0); + dbms_lob.writeappend(p1, 37, 'The output should be even longer now.'); + end bug46994_proc2;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$myclob = oci_new_descriptor($c, OCI_D_LOB); +$myclob->writeTemporary("some data", OCI_TEMP_CLOB); + +echo "Test 1\n"; + +$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;"); +oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($myclob->load()); + +echo "Test 2\n"; + +$s = oci_parse($c, "begin bug46994_proc2(:myclob); end;"); +oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($myclob->load()); + +echo "Test 3\n"; + +$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;"); +oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($myclob->load()); + +echo "Test 4\n"; + +var_dump($myclob->load()); // Use cached size code path + +// Cleanup + +$stmtarray = array( + "drop procedure bug46994_proc1", + "drop procedure bug46994_proc2" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +string(26) "This should be the output." +Test 2 +string(37) "The output should be even longer now." +Test 3 +string(26) "This should be the output." +Test 4 +string(26) "This should be the output." +===DONE=== diff --git a/ext/oci8/tests/bug47189.phpt b/ext/oci8/tests/bug47189.phpt new file mode 100644 index 0000000..c82d2cd --- /dev/null +++ b/ext/oci8/tests/bug47189.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #47189 (Multiple oci_fetch_all calls) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs: different error handling for this undefined behavior +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from dual"); +oci_execute($s); +oci_fetch_all($s, $rs, 0, -1, OCI_FETCHSTATEMENT_BY_ROW); +var_dump($rs); +oci_fetch_all($s, $rs1, 0, -1, OCI_FETCHSTATEMENT_BY_ROW); +var_dump($rs1); + +echo "Test 2\n"; + +$s = oci_parse($c, "select * from dual"); +oci_execute($s); +oci_fetch_all($s, $rs, 0, 1, OCI_FETCHSTATEMENT_BY_ROW); +var_dump($rs); +oci_fetch_all($s, $rs1, 0, 1, OCI_FETCHSTATEMENT_BY_ROW); +var_dump($rs1); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} +array(0) { +} +Test 2 +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} + +Warning: oci_fetch_all(): ORA-01002: %s in %s on line %d +array(0) { +} +===DONE=== diff --git a/ext/oci8/tests/bug47281.phpt b/ext/oci8/tests/bug47281.phpt new file mode 100644 index 0000000..d0e0023 --- /dev/null +++ b/ext/oci8/tests/bug47281.phpt @@ -0,0 +1,66 @@ +--TEST-- +Bug #47281 ($php_errormsg is limited in size of characters) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +// error3.phpt obsoletes this test for newer Oracle client versions +// Assume runtime client version is >= compile time client version +$cv = explode('.', oci_client_version()); +if ($cv[0] > 11 || ($cv[0] == 11 && $cv[1] > 2) || ($cv[0] == 11 && $cv[1] == 2 && $cv[3] >= 3)) { + die("skip test works only with Oracle 11.2.0.2 or earlier Oracle client libraries"); +} + +?> +--ENV-- +NLS_LANG=.AL32UTF8 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure bug47281_sp as + begin + raise_application_error(-20000, + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeFggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhIjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjKlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllM'); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, 'begin bug47281_sp; end;'); +$r = @oci_execute($s); + +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} + +echo "Test 2\n"; + +echo $php_errormsg. "\n"; + +// Clean up + +$stmtarray = array( + "drop procedure bug47281_sp" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeee +Test 2 +oci_execute(): ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +===DONE=== diff --git a/ext/oci8/tests/bug47281_tt.phpt b/ext/oci8/tests/bug47281_tt.phpt new file mode 100644 index 0000000..4b4e92e --- /dev/null +++ b/ext/oci8/tests/bug47281_tt.phpt @@ -0,0 +1,59 @@ +--TEST-- +Bug #47281 ($php_errormsg is limited in size of characters) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => false, 'timesten' => true); // test runs on these DBs: shorter message length in TimesTen +require(dirname(__FILE__).'/skipif.inc'); +?> +--ENV-- +NLS_LANG=.AL32UTF8 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure bug47281_sp as + begin + raise_application_error(-20000, + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeFggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhIjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjKlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllM'); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, 'begin bug47281_sp; end;'); +$r = @oci_execute($s); + +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} + +echo "Test 2\n"; + +echo $php_errormsg. "\n"; + +// Clean up + +$stmtarray = array( + "drop procedure bug47281_sp" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +ORA-57000: TT8507: ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +Test 2 +oci_execute(): ORA-57000: TT8507: ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +===DONE=== diff --git a/ext/oci8/tests/bug51253.phpt b/ext/oci8/tests/bug51253.phpt new file mode 100644 index 0000000..a97272f --- /dev/null +++ b/ext/oci8/tests/bug51253.phpt @@ -0,0 +1,168 @@ +--TEST-- +Bug #51253 (oci_bind_array_by_name() array references) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) 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 + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + 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); + +echo "Test 1\n"; +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array1 = array("one", "two", "three", "four", "five"); +$array2 = $array1; +oci_bind_array_by_name($statement, ":c1", $array2, 5, -1, SQLT_CHR); +oci_execute($statement); + +var_dump($array1); +var_dump($array2); + + +echo "Test 2\n"; +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array1 = array("one", "two", "three", "four", "five"); +$array2 = &$array1; +oci_bind_array_by_name($statement, ":c1", $array2, 5, -1, SQLT_CHR); +oci_execute($statement); + +var_dump($array1); +var_dump($array2); + + +echo "Test 3\n"; +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); +$array1 = array("one", "two", "three", "four", "five"); +$array2 = &$array1; +oci_bind_array_by_name($statement, ":c1", $array1, 5, -1, SQLT_CHR); +oci_execute($statement); + +var_dump($array1); +var_dump($array2); + +// Cleanup +$statement = oci_parse($c, "DROP PACKAGE ARRAYBINDPKG1"); +@oci_execute($statement); +$statement = oci_parse($c, "DROP TABLE BIND_TEST"); +@oci_execute($statement); + +echo "Done\n"; +?> +--EXPECT-- +Test 1 +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Test 2 +array(5) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + [3]=> + string(4) "four" + [4]=> + string(4) "five" +} +array(5) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + [3]=> + string(4) "four" + [4]=> + string(4) "five" +} +Test 3 +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/bug51291_1.phpt b/ext/oci8/tests/bug51291_1.phpt new file mode 100644 index 0000000..789b94e --- /dev/null +++ b/ext/oci8/tests/bug51291_1.phpt @@ -0,0 +1,394 @@ +--TEST-- +Bug #51291 (oci_error() doesn't report last error when called two times) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +echo "Test 1 - Parse\n"; + +$s = @oci_parse($c, "select ' from dual"); +if (!$s) { + var_dump(oci_error($c)); + echo "2nd call\n"; + var_dump(oci_error($c)); +} + +echo "\nTest 2 - Parse\n"; + +$s = @oci_parse($c, "select ' from dual"); +if (!$s) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + echo "2nd call\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + +echo "\nTest 3 - Execute\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error($s)); + echo "2nd call\n"; + var_dump(oci_error($s)); +} + +echo "\nTest 4 - Execute - consecutive oci_error calls of different kinds\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + echo "2nd call\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + + +echo "\nTest 5 - Execute - after oci_rollback\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $r = oci_rollback($c); + echo "Rollback status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after oci_rollback\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + + +echo "\nTest 6 - Execute - after successful 2nd query with new handle\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $s2 = oci_parse($c, 'select 1 from dual'); + $r = oci_execute($s2, OCI_DEFAULT); + echo "Execute status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after successful execute\n"; + var_dump(oci_error(), oci_error($c), oci_error($s), oci_error($s2)); +} + + +echo "\nTest 7 - Execute - after successful 2nd query with same handle\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $s = oci_parse($c, 'select 1 from dual'); + $r = oci_execute($s, OCI_DEFAULT); + echo "Execute status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after successful execute\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + + +echo "\nTest 8 - Execute - after unsuccessful 2nd query with new handle\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $s2 = oci_parse($c, 'select reallynothere from dual'); + $r = oci_execute($s2, OCI_DEFAULT); + echo "Execute status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after unsuccessful execute\n"; + var_dump(oci_error(), oci_error($c), oci_error($s), oci_error($s2)); +} + +echo "\nTest 9 - Execute - after unsuccessful 2nd query with same handle\n"; + +$s = @oci_parse($c, 'select doesnotexist from dual'); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $s = oci_parse($c, 'select reallynothere from dual'); + $r = oci_execute($s, OCI_DEFAULT); + echo "Execute status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after unsuccessful execute\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - Parse +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +2nd call +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} + +Test 2 - Parse + +Warning: oci_error() expects parameter 1 to be resource, boolean given in %sbug51291_1.php on line %d +bool(false) +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +NULL +2nd call + +Warning: oci_error() expects parameter 1 to be resource, boolean given in %sbug51291_1.php on line %d +bool(false) +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +NULL + +Test 3 - Execute +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +2nd call +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} + +Test 4 - Execute - consecutive oci_error calls of different kinds +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +2nd call +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} + +Test 5 - Execute - after oci_rollback +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +Rollback status is true +2nd call after oci_rollback +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} + +Test 6 - Execute - after successful 2nd query with new handle +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +Execute status is true +2nd call after successful execute +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +bool(false) + +Test 7 - Execute - after successful 2nd query with same handle +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +Execute status is true +2nd call after successful execute +bool(false) +bool(false) +bool(false) + +Test 8 - Execute - after unsuccessful 2nd query with new handle +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} + +Warning: oci_execute(): ORA-00904: %sREALLYNOTHERE%s in %sbug51291_1.php on line %d +Execute status is false +2nd call after unsuccessful execute +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904%sREALLYNOTHERE%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(30) "select reallynothere from dual" +} + +Test 9 - Execute - after unsuccessful 2nd query with same handle +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904:%sDOESNOTEXIST%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(29) "select doesnotexist from dual" +} + +Warning: oci_execute(): ORA-00904: %sREALLYNOTHERE%s in %sbug51291_1.php on line %d +Execute status is false +2nd call after unsuccessful execute +bool(false) +bool(false) +array(4) { + ["code"]=> + int(904) + ["message"]=> + string(%d) "ORA-00904%sREALLYNOTHERE%s" + ["offset"]=> + int(%d) + ["sqltext"]=> + string(30) "select reallynothere from dual" +} +===DONE=== diff --git a/ext/oci8/tests/bug51291_2.phpt b/ext/oci8/tests/bug51291_2.phpt new file mode 100644 index 0000000..d5dbf6f --- /dev/null +++ b/ext/oci8/tests/bug51291_2.phpt @@ -0,0 +1,56 @@ +--TEST-- +Bug #51291 (oci_error() doesn't report last error when called two times) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs: different error messages from TimesTen +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +echo "\nTest 1 - Execute - after successful 2nd query with same statement\n"; + +$s = oci_parse($c, "declare e exception; begin if :bv = 1 then raise e; end if; end;"); +$bv = 1; +oci_bind_by_name($s, ":bv", $bv); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + var_dump(oci_error(), oci_error($c), oci_error($s)); + $bv = 0; + $r = oci_execute($s, OCI_DEFAULT); + echo "Execute status is "; + if (is_null($r)) echo "null"; + else if ($r === false) echo "false"; + else if ($r === true) echo "true"; + else echo $r; + echo "\n"; + echo "2nd call after successful execute\n"; + var_dump(oci_error(), oci_error($c), oci_error($s)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - Execute - after successful 2nd query with same statement +bool(false) +bool(false) +array(4) { + ["code"]=> + int(6510) + ["message"]=> + string(72) "ORA-06510: PL/SQL: %s +ORA-06512: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(64) "declare e exception; begin if :bv = 1 then raise e; end if; end;" +} +Execute status is true +2nd call after successful execute +bool(false) +bool(false) +bool(false) +===DONE=== diff --git a/ext/oci8/tests/clientversion.phpt b/ext/oci8/tests/clientversion.phpt new file mode 100644 index 0000000..db70b5a --- /dev/null +++ b/ext/oci8/tests/clientversion.phpt @@ -0,0 +1,20 @@ +--TEST-- +oci_client_version() +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (preg_match('/^1[012]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + +echo oci_client_version(), "\n"; + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +%d.%d.%d.%d.%d +===DONE=== diff --git a/ext/oci8/tests/clientversion_92.phpt b/ext/oci8/tests/clientversion_92.phpt new file mode 100644 index 0000000..d4b92cd --- /dev/null +++ b/ext/oci8/tests/clientversion_92.phpt @@ -0,0 +1,20 @@ +--TEST-- +oci_client_version() for Oracle 9.2 client libraries +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (preg_match('/Unknown/', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 9gR2 client libraries"); +} +?> +--FILE-- +<?php + +echo oci_client_version(), "\n"; + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Unknown +===DONE=== diff --git a/ext/oci8/tests/close.phpt b/ext/oci8/tests/close.phpt new file mode 100644 index 0000000..55bb4ea --- /dev/null +++ b/ext/oci8/tests/close.phpt @@ -0,0 +1,17 @@ +--TEST-- +connect/close/connect +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +oci_close($c); + +oci_connect($user, $password, $dbase); + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/coll_001.phpt b/ext/oci8/tests/coll_001.phpt new file mode 100644 index 0000000..625d71a --- /dev/null +++ b/ext/oci8/tests/coll_001.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_new_collection() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump(oci_new_collection($c, $type_name)); +var_dump(oci_new_collection($c, "NONEXISTENT")); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} + +Warning: oci_new_collection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_002.phpt b/ext/oci8/tests/coll_002.phpt new file mode 100644 index 0000000..cd068ff --- /dev/null +++ b/ext/oci8/tests/coll_002.phpt @@ -0,0 +1,33 @@ +--TEST-- +oci_new_collection() + free() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = oci_new_collection($c, $type_name)); + +var_dump($coll1->free()); +var_dump($coll1->size()); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_002_func.phpt b/ext/oci8/tests/coll_002_func.phpt new file mode 100644 index 0000000..9d8e4cf --- /dev/null +++ b/ext/oci8/tests/coll_002_func.phpt @@ -0,0 +1,33 @@ +--TEST-- +oci_new_collection() + free() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = oci_new_collection($c, $type_name)); + +var_dump(oci_free_collection($coll1)); +var_dump(oci_collection_size($coll1)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_003.phpt b/ext/oci8/tests/coll_003.phpt new file mode 100644 index 0000000..d7c52fe --- /dev/null +++ b/ext/oci8/tests/coll_003.phpt @@ -0,0 +1,37 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->size()); +var_dump($coll1->max()); +var_dump($coll1->trim(3)); +var_dump($coll1->append(1)); +var_dump($coll1->getElem(0)); +var_dump($coll1->assignElem(0,2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: OCI-Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_003_func.phpt b/ext/oci8/tests/coll_003_func.phpt new file mode 100644 index 0000000..58655a5 --- /dev/null +++ b/ext/oci8/tests/coll_003_func.phpt @@ -0,0 +1,37 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); + +var_dump(oci_collection_size($coll1)); +var_dump(oci_collection_max($coll1)); +var_dump(oci_collection_trim($coll1, 3)); +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_get($coll1, 0)); +var_dump(oci_collection_element_assign($coll1, 0, 2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: oci_collection_trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_004.phpt b/ext/oci8/tests/coll_004.phpt new file mode 100644 index 0000000..f71db4d --- /dev/null +++ b/ext/oci8/tests/coll_004.phpt @@ -0,0 +1,32 @@ +--TEST-- +oci_collection_assign() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); +$coll2 = oci_new_collection($c, $type_name); + +var_dump($coll1->append(1)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_004_func.phpt b/ext/oci8/tests/coll_004_func.phpt new file mode 100644 index 0000000..8f24363 --- /dev/null +++ b/ext/oci8/tests/coll_004_func.phpt @@ -0,0 +1,32 @@ +--TEST-- +oci_collection_assign() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); +$coll2 = oci_new_collection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_005.phpt b/ext/oci8/tests/coll_005.phpt new file mode 100644 index 0000000..84084e7 --- /dev/null +++ b/ext/oci8/tests/coll_005.phpt @@ -0,0 +1,30 @@ +--TEST-- +ocinewcollection() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump(ocinewcollection($c, $type_name)); +var_dump(ocinewcollection($c, "NONEXISTENT")); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} + +Warning: ocinewcollection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_006.phpt b/ext/oci8/tests/coll_006.phpt new file mode 100644 index 0000000..4799eb6 --- /dev/null +++ b/ext/oci8/tests/coll_006.phpt @@ -0,0 +1,33 @@ +--TEST-- +ocinewcollection() + free() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = ocinewcollection($c, $type_name)); + +var_dump($coll1->free()); +var_dump($coll1->size()); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_006_func.phpt b/ext/oci8/tests/coll_006_func.phpt new file mode 100644 index 0000000..3d65606 --- /dev/null +++ b/ext/oci8/tests/coll_006_func.phpt @@ -0,0 +1,33 @@ +--TEST-- +ocinewcollection() + free() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = ocinewcollection($c, $type_name)); + +var_dump(oci_free_collection($coll1)); +var_dump(oci_collection_size($coll1)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_007.phpt b/ext/oci8/tests/coll_007.phpt new file mode 100644 index 0000000..86ce62f --- /dev/null +++ b/ext/oci8/tests/coll_007.phpt @@ -0,0 +1,37 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->size()); +var_dump($coll1->max()); +var_dump($coll1->trim(3)); +var_dump($coll1->append(1)); +var_dump($coll1->getElem(0)); +var_dump($coll1->assignElem(0,2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: OCI-Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_008.phpt b/ext/oci8/tests/coll_008.phpt new file mode 100644 index 0000000..431d5d6 --- /dev/null +++ b/ext/oci8/tests/coll_008.phpt @@ -0,0 +1,32 @@ +--TEST-- +ocicollassign() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_009.phpt b/ext/oci8/tests/coll_009.phpt new file mode 100644 index 0000000..917af5f --- /dev/null +++ b/ext/oci8/tests/coll_009.phpt @@ -0,0 +1,45 @@ +--TEST-- +collections and wrong dates +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("2005-07-28")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +Warning: OCI-Collection::append(): OCI-01861: literal does not match format string in %s on line %d +bool(false) +bool(true) +bool(false) +Done diff --git a/ext/oci8/tests/coll_009_func.phpt b/ext/oci8/tests/coll_009_func.phpt new file mode 100644 index 0000000..0c5b46d --- /dev/null +++ b/ext/oci8/tests/coll_009_func.phpt @@ -0,0 +1,45 @@ +--TEST-- +collections and wrong dates +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "2005-07-28")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +Warning: oci_collection_append(): OCI-01861: literal does not match format string in %s on line %d +bool(false) +bool(true) +bool(false) +Done diff --git a/ext/oci8/tests/coll_010.phpt b/ext/oci8/tests/coll_010.phpt new file mode 100644 index 0000000..da088e9 --- /dev/null +++ b/ext/oci8/tests/coll_010.phpt @@ -0,0 +1,44 @@ +--TEST-- +collections and nulls +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(null)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_010_func.phpt b/ext/oci8/tests/coll_010_func.phpt new file mode 100644 index 0000000..c5379ac --- /dev/null +++ b/ext/oci8/tests/coll_010_func.phpt @@ -0,0 +1,44 @@ +--TEST-- +collections and nulls +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, null)); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_011.phpt b/ext/oci8/tests/coll_011.phpt new file mode 100644 index 0000000..3e8aa9d --- /dev/null +++ b/ext/oci8/tests/coll_011.phpt @@ -0,0 +1,46 @@ +--TEST-- +collections and strings +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("string")); +var_dump($coll1->append("string")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +string(6) "string" +Done diff --git a/ext/oci8/tests/coll_011_func.phpt b/ext/oci8/tests/coll_011_func.phpt new file mode 100644 index 0000000..3871dd9 --- /dev/null +++ b/ext/oci8/tests/coll_011_func.phpt @@ -0,0 +1,46 @@ +--TEST-- +collections and strings +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "string")); +var_dump(oci_collection_append($coll1, "string")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +string(6) "string" +Done diff --git a/ext/oci8/tests/coll_012.phpt b/ext/oci8/tests/coll_012.phpt new file mode 100644 index 0000000..4b912a8 --- /dev/null +++ b/ext/oci8/tests/coll_012.phpt @@ -0,0 +1,44 @@ +--TEST-- +collections and correct dates +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("28-JUL-05")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_012_func.phpt b/ext/oci8/tests/coll_012_func.phpt new file mode 100644 index 0000000..574281d --- /dev/null +++ b/ext/oci8/tests/coll_012_func.phpt @@ -0,0 +1,44 @@ +--TEST-- +collections and correct dates +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "28-JUL-05")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_013.phpt b/ext/oci8/tests/coll_013.phpt new file mode 100644 index 0000000..04f5498 --- /dev/null +++ b/ext/oci8/tests/coll_013.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and correct dates (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("28-JUL-05")); +var_dump($coll1->assignElem(0,"01-JAN-05")); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_013_func.phpt b/ext/oci8/tests/coll_013_func.phpt new file mode 100644 index 0000000..1992b94 --- /dev/null +++ b/ext/oci8/tests/coll_013_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and correct dates (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "28-JUL-05")); +var_dump(oci_collection_element_assign($coll1, 0, "01-JAN-05")); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_014.phpt b/ext/oci8/tests/coll_014.phpt new file mode 100644 index 0000000..e89f4a3 --- /dev/null +++ b/ext/oci8/tests/coll_014.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and strings (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("striing")); +var_dump($coll1->assignElem(0,"blah")); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(4) "blah" +Done diff --git a/ext/oci8/tests/coll_014_func.phpt b/ext/oci8/tests/coll_014_func.phpt new file mode 100644 index 0000000..7d77163 --- /dev/null +++ b/ext/oci8/tests/coll_014_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and strings (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "striing")); +var_dump(oci_collection_element_assign($coll1, 0,"blah")); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(4) "blah" +Done diff --git a/ext/oci8/tests/coll_015.phpt b/ext/oci8/tests/coll_015.phpt new file mode 100644 index 0000000..c422d21 --- /dev/null +++ b/ext/oci8/tests/coll_015.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and numbers (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); +var_dump($coll1->assignElem(0,2345)); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(2345) +Done diff --git a/ext/oci8/tests/coll_015_func.phpt b/ext/oci8/tests/coll_015_func.phpt new file mode 100644 index 0000000..18e21dd --- /dev/null +++ b/ext/oci8/tests/coll_015_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and numbers (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_assign($coll1,0,2345)); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(2345) +Done diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt new file mode 100644 index 0000000..2e06e29 --- /dev/null +++ b/ext/oci8/tests/coll_016.phpt @@ -0,0 +1,51 @@ +--TEST-- +collections and negative/too big element indexes +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); +var_dump($coll1->assignElem(-1,2345)); +var_dump($coll1->assignElem(5000,2345)); +var_dump($coll1->getElem(-1)); +var_dump($coll1->getElem(-100)); +var_dump($coll1->getElem(500)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +bool(true) + +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 %s to [0] in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/coll_016_func.phpt b/ext/oci8/tests/coll_016_func.phpt new file mode 100644 index 0000000..67830af --- /dev/null +++ b/ext/oci8/tests/coll_016_func.phpt @@ -0,0 +1,51 @@ +--TEST-- +collections and negative/too big element indexes +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_assign($coll1,-1,2345)); +var_dump(oci_collection_element_assign($coll1,5000,2345)); +var_dump(oci_collection_element_get($coll1, -1)); +var_dump(oci_collection_element_get($coll1, -100)); +var_dump(oci_collection_element_get($coll1, 500)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +bool(true) + +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%s0%sto [0] in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/coll_017.phpt b/ext/oci8/tests/coll_017.phpt new file mode 100644 index 0000000..56f5099 --- /dev/null +++ b/ext/oci8/tests/coll_017.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and nulls (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("string")); +var_dump($coll1->assignElem(0, null)); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_017_func.phpt b/ext/oci8/tests/coll_017_func.phpt new file mode 100644 index 0000000..3440195 --- /dev/null +++ b/ext/oci8/tests/coll_017_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and nulls (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "string")); +var_dump(oci_collection_element_assign($coll1, 0, null)); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_018.phpt b/ext/oci8/tests/coll_018.phpt new file mode 100644 index 0000000..a3f0b29 --- /dev/null +++ b/ext/oci8/tests/coll_018.phpt @@ -0,0 +1,96 @@ +--TEST-- +Collection trim tests +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..371c802 --- /dev/null +++ b/ext/oci8/tests/coll_019.phpt @@ -0,0 +1,110 @@ +--TEST-- +Test collection Oracle error handling collections and numbers (2) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/commit_001.phpt b/ext/oci8/tests/commit_001.phpt new file mode 100644 index 0000000..806fb19 --- /dev/null +++ b/ext/oci8/tests/commit_001.phpt @@ -0,0 +1,159 @@ +--TEST-- +Test OCI_NO_AUTO_COMMIT constant +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +/* check with OCI_NO_AUTO_COMMIT mode */ +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) { + die("oci_execute(insert) failed!\n"); + } +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s, OCI_DEFAULT)) { + die("oci_execute(insert) failed!\n"); + } +} + + +var_dump(oci_rollback($c)); + +$select_sql = "select * from ".$schema.$table_name.""; + +if (!($select = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($select)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($select, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$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"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s, OCI_DEFAULT)) { + die("oci_execute(insert) failed!\n"); + } +} + +var_dump(oci_commit($c)); + +/* oci_fetch_all */ +if (!oci_execute($select)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($select, $all)); +var_dump($all); + + +require(dirname(__FILE__).'/drop_table.inc'); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +int(0) +array(5) { + [%u|b%"ID"]=> + array(0) { + } + [%u|b%"VALUE"]=> + array(0) { + } + [%u|b%"BLOB"]=> + array(0) { + } + [%u|b%"CLOB"]=> + array(0) { + } + [%u|b%"STRING"]=> + array(0) { + } +} +bool(true) +int(4) +array(5) { + [%u|b%"ID"]=> + array(4) { + [0]=> + %string|unicode%(1) "1" + [1]=> + %string|unicode%(1) "1" + [2]=> + %string|unicode%(1) "1" + [3]=> + %string|unicode%(1) "1" + } + [%u|b%"VALUE"]=> + array(4) { + [0]=> + %string|unicode%(1) "1" + [1]=> + %string|unicode%(1) "1" + [2]=> + %string|unicode%(1) "1" + [3]=> + %string|unicode%(1) "1" + } + [%u|b%"BLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + [%u|b%"CLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + [%u|b%"STRING"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/commit_002.phpt b/ext/oci8/tests/commit_002.phpt new file mode 100644 index 0000000..4079ac0 --- /dev/null +++ b/ext/oci8/tests/commit_002.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test oci_commit failure +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table commit_002_tab", + "create table commit_002_tab + ( x int constraint commit_002_tab_check_x check ( x > 0 ) deferrable initially immediate, + y int constraint commit_002_tab_check_y check ( y > 0 ) deferrable initially deferred)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "First Insert\n"; +$s = oci_parse($c, "insert into commit_002_tab values (-1, 1)"); +$r = @oci_execute($s, OCI_DEFAULT); +if (!$r) { + $m = oci_error($s); + echo 'Could not execute: '. $m['message'] . "\n"; +} +$r = oci_commit($c); +if (!$r) { + $m = oci_error($c); + echo 'Could not commit: '. $m['message'] . "\n"; +} + + +echo "Second Insert\n"; +$s = oci_parse($c, "insert into commit_002_tab values (1, -1)"); +$r = @oci_execute($s, OCI_NO_AUTO_COMMIT); +if (!$r) { + $m = oci_error($s); + echo 'Could not execute: '. $m['message'] . "\n"; +} +$r = oci_commit($c); +if (!$r) { + $m = oci_error($c); + echo 'Could not commit: '. $m['message'] . "\n"; +} + + +// Clean up + +$stmtarray = array( + "drop table commit_002_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +First Insert +Could not execute: ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_X) %s +Second Insert + +Warning: oci_commit(): ORA-02091: %s +ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s in %scommit_002.php on line %d +Could not commit: ORA-02091: %s +ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s +===DONE=== diff --git a/ext/oci8/tests/commit_old.phpt b/ext/oci8/tests/commit_old.phpt new file mode 100644 index 0000000..012fc02 --- /dev/null +++ b/ext/oci8/tests/commit_old.phpt @@ -0,0 +1,149 @@ +--TEST-- +ocicommit()/ocirollback() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s, OCI_DEFAULT)) { + die("ociexecute(insert) failed!\n"); + } +} + +var_dump(ocirollback($c)); + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($select = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +if (!oci_execute($select)) { + die("ociexecute(select) failed!\n"); +} +var_dump(ocifetchstatement($select, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; + +if (!($s = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s, OCI_DEFAULT)) { + die("ociexecute(insert) failed!\n"); + } +} + +var_dump(ocicommit($c)); + +if (!ociexecute($select)) { + die("ociexecute(select) failed!\n"); +} +var_dump(ocifetchstatement($select, $all)); +var_dump($all); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(0) +array(5) { + ["ID"]=> + array(0) { + } + ["VALUE"]=> + array(0) { + } + ["BLOB"]=> + array(0) { + } + ["CLOB"]=> + array(0) { + } + ["STRING"]=> + array(0) { + } +} +bool(true) +int(4) +array(5) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["VALUE"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["BLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["CLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["STRING"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc new file mode 100644 index 0000000..2c086b1 --- /dev/null +++ b/ext/oci8/tests/conn_attr.inc @@ -0,0 +1,151 @@ +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$sv = oci_server_version($c); +$sv = preg_match('/Release (11\.2|12)\./', $sv, $matches); +if ($sv == 1) { + // Server is Oracle 11.2+ + $stmtarray = array( + "drop user testuser cascade", + "create user testuser identified by testuser", + "grant connect,resource,dba to testuser", + "alter user testuser enable editions", + "drop edition myedition1", + "drop edition myedition", + "grant create any edition to testuser", + "create edition myedition", + "create edition myedition1 as child of myedition", + "grant use on edition myedition to testuser", + "grant use on edition myedition1 to testuser", + ); +} +else { + // Server is Pre 11.2 + $stmtarray = array( + "drop user testuser cascade", + "create user testuser identified by testuser", + "grant connect,resource,dba to testuser", + ); +} + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + if (!in_array($m['code'], array( // ignore expected errors + 942 // table or view does not exist + , 1918 // user does not exist + , 2289 // sequence does not exist + , 4080 // trigger does not exist + , 38802 // edition does not exist + ))) { + echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL; + if ($m['code'] == 38807) { + echo "You appear to already have an edition in use that prevents this PHP test from running. Query DBA_EDITIONS to see existing editions.". PHP_EOL; + } + die; + } + } +} + +function get_attr($conn,$attr) +{ + $sel_stmt="select " .$attr. " from v\$session where sid = + (select sid from v\$session where audsid = + sys_context('userenv','sessionid')) order by 1"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while (oci_fetch($s2)) { + echo "The value of ".$attr ." is ".oci_result($s2,1)."\n"; + } +} + +/* Pass $conn_type=1 for a connection with oci_connect() + Pass $conn_type=2 for ooci_pconnect + Default will give a oci_new_connect */ + +function get_conn($conn_type) +{ + $user = 'testuser'; + $password = 'testuser'; + $dbase = $GLOBALS['dbase']; + switch($conn_type) { + case 1: + echo "Testing with oci_connect()\n"; + return(oci_connect($user,$password,$dbase)); + break; + case 2: + echo "Testing with oci_pconnect()\n"; + return(oci_pconnect($user,$password,$dbase)); + break; + default: + echo "Testing with oci_new_connect()\n"; + return(oci_new_connect($user,$password,$dbase)); + break; + } +} + +function set_attr($conn,$attr,$sufix) +{ + if (!strcmp($attr,'MODULE')) + $r = oci_set_module_name($conn,'PHP TEST'.$sufix); + else if (!strcmp($attr,'ACTION')) + $r = oci_set_action($conn,'TASK'.$sufix); + else if (!strcmp($attr,'CLIENT_INFO')) + $r = oci_set_client_info($conn,'INFO1'.$sufix); + else if (!strcmp($attr,'CLIENT_IDENTIFIER')) + $r = oci_set_client_identifier($conn,'ID00'.$sufix); + else + echo "Pass one of the above four attibutes!!!\n"; + if ($r) { + echo "Value of $attr has been set successfully\n"; + } + + //Do a round-trip here + oci_server_version($conn); + return $r; +} + +function set_edit_attr($value) +{ + $r = oci_set_edition($value); + if ($r) { + echo " The value of edition has been successfully set\n"; + } + return $r; +} + +function get_edit_attr ($conn) { + $sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while (oci_fetch($s2)) { + echo "The value of current EDITION is ".oci_result($s2,1)."\n"; + } +} + +function get_sys_attr($conn,$attr) +{ + $sel_stmt="select " .$attr. " from v\$session where sid = + (select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while (oci_fetch($s2)) { + echo "The value of ".$attr ." is ".oci_result($s2,1)."\n"; + } +} + +function clean_up($c) { + $stmtarray = array( + "drop user testuser cascade", + "drop edition myedition1", + "drop edition myedition", + ); + + foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + @oci_execute($s); + } +} diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt new file mode 100644 index 0000000..ad508a2 --- /dev/null +++ b/ext/oci8/tests/conn_attr_1.phpt @@ -0,0 +1,97 @@ +--TEST-- +Set and get of connection attributes with all types of connections. +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); + +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) + die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip output might vary with DRCP"); + +if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater database server"); +} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} + +?> +--FILE-- +<?php +require(dirname(__FILE__)."/conn_attr.inc"); + +$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); + +echo"**Test 1.1 - Default values for the attributes **************\n"; +$c = get_conn(1); +foreach($attr_array as $attr) { + get_attr($c,$attr); +} + +echo"**Test 1.2 - Set and get values for the attributes **************\n"; + +// With oci_connect, oci_pconnect, oci_new_connect + +$conn1 = get_conn(1); //oci_connect() +foreach($attr_array as $attr) { + set_attr($conn1,$attr,1); + get_attr($conn1,$attr); +} + +$conn2 = get_conn(2); //oci_pconnect() +foreach($attr_array as $attr) { + set_attr($conn2,$attr,2); + get_attr($conn2,$attr); +} + +$conn3 = get_conn(3); //oci_new_connect() +foreach($attr_array as $attr) { + set_attr($conn3,$attr,3); + get_attr($conn3,$attr); +} + +// clean up +oci_close($conn1); +oci_close($conn2); +oci_close($conn3); +clean_up($c); + +echo "Done\n"; + +?> +--EXPECTF-- +**Test 1.1 - Default values for the attributes ************** +Testing with oci_connect() +The value of MODULE is %s +The value of ACTION is +The value of CLIENT_INFO is +The value of CLIENT_IDENTIFIER is +**Test 1.2 - Set and get values for the attributes ************** +Testing with oci_connect() +Value of MODULE has been set successfully +The value of MODULE is PHP TEST1 +Value of ACTION has been set successfully +The value of ACTION is TASK1 +Value of CLIENT_INFO has been set successfully +The value of CLIENT_INFO is INFO11 +Value of CLIENT_IDENTIFIER has been set successfully +The value of CLIENT_IDENTIFIER is ID001 +Testing with oci_pconnect() +Value of MODULE has been set successfully +The value of MODULE is PHP TEST2 +Value of ACTION has been set successfully +The value of ACTION is TASK2 +Value of CLIENT_INFO has been set successfully +The value of CLIENT_INFO is INFO12 +Value of CLIENT_IDENTIFIER has been set successfully +The value of CLIENT_IDENTIFIER is ID002 +Testing with oci_new_connect() +Value of MODULE has been set successfully +The value of MODULE is PHP TEST3 +Value of ACTION has been set successfully +The value of ACTION is TASK3 +Value of CLIENT_INFO has been set successfully +The value of CLIENT_INFO is INFO13 +Value of CLIENT_IDENTIFIER has been set successfully +The value of CLIENT_IDENTIFIER is ID003 +Done diff --git a/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt new file mode 100644 index 0000000..1072503 --- /dev/null +++ b/ext/oci8/tests/conn_attr_2.phpt @@ -0,0 +1,105 @@ +--TEST-- +Set and get of connection attributes across persistent connections and sysdba connection. +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); + +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip output might vary with DRCP"); + +if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater database server"); +} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} + +?> +--INI-- +oci8.privileged_connect = On +--FILE-- + +<?php +require(dirname(__FILE__)."/conn_attr.inc"); +$user='testuser'; +$password='testuser'; +$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); + +echo"**Set values using pconnect-1**\n"; + +var_dump($pc1 = oci_pconnect($user,$password,$dbase)); +foreach($attr_array as $attr) { + set_attr($pc1,$attr,100); +} + +// using pc1 again +echo"\n**Get values using pconnect-2**\n"; +var_dump($pc3 = oci_pconnect($user,$password,$dbase)); +foreach($attr_array as $attr) { + get_attr($pc3,$attr); +} + +// Get with different pconnect +echo"\n**Get values using pconnect-3**\n"; +var_dump($pc2 = oci_pconnect($user,$password,$dbase,'UTF8')); +foreach($attr_array as $attr) { + get_attr($pc2,$attr); +} + +oci_close($pc1); +oci_close($pc2); +oci_close($pc3); + +// Re-open a persistent connection and check for the attr values. +echo "\n**Re-open a pconnect()**\n"; +var_dump($pc4 = oci_pconnect($user,$password,$dbase)); +foreach($attr_array as $attr) { + get_attr($pc4,$attr); +} +oci_close($pc4); + +// Test with SYSDBA connection. +var_dump($sys_c1 = oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA)); +if ($sys_c1) { + set_attr($sys_c1,'ACTION',10); + get_sys_attr($sys_c1,'ACTION'); + get_attr($pc2,'ACTION'); + oci_close($sys_c1); +} + +clean_up($c); + +echo "Done\n"; +?> +--EXPECTF-- +**Set values using pconnect-1** +resource(%d) of type (oci8 persistent connection) +Value of MODULE has been set successfully +Value of ACTION has been set successfully +Value of CLIENT_INFO has been set successfully +Value of CLIENT_IDENTIFIER has been set successfully + +**Get values using pconnect-2** +resource(%d) of type (oci8 persistent connection) +The value of MODULE is PHP TEST100 +The value of ACTION is TASK100 +The value of CLIENT_INFO is INFO1100 +The value of CLIENT_IDENTIFIER is ID00100 + +**Get values using pconnect-3** +resource(%d) of type (oci8 persistent connection) +The value of MODULE is %s +The value of ACTION is +The value of CLIENT_INFO is +The value of CLIENT_IDENTIFIER is + +**Re-open a pconnect()** +resource(%d) of type (oci8 persistent connection) +The value of MODULE is PHP TEST100 +The value of ACTION is TASK100 +The value of CLIENT_INFO is INFO1100 +The value of CLIENT_IDENTIFIER is ID00100 + +Warning: oci_pconnect(): ORA-01031: %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/conn_attr_3.phpt b/ext/oci8/tests/conn_attr_3.phpt new file mode 100644 index 0000000..be8d330 --- /dev/null +++ b/ext/oci8/tests/conn_attr_3.phpt @@ -0,0 +1,87 @@ +--TEST-- +Set and get of connection attributes with oci_close(). +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); + +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip output might vary with DRCP"); + +if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater database server"); +} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php +require(dirname(__FILE__)."/conn_attr.inc"); + +echo"**Test Set and get values for the attributes with oci_close() ************\n"; +// With oci_connect ,oci_pconnect ,oci_new_connect + +var_dump($conn1 = get_conn(1)); //oci_connect() +set_attr($conn1,'ACTION',1); +get_attr($conn1,'ACTION'); +oci_close($conn1); + +// Open another connect and verify the value. +var_dump($conn1 = get_conn(1)); //oci_connect() +get_attr($conn1,'ACTION'); +oci_close($conn1); + +var_dump($pconn1 = get_conn(2)); //oci_pconnect() +set_attr($pconn1,'MODULE',2); +get_attr($pconn1,'MODULE'); +oci_close($pconn1); + +// Open another connect and verify the value. +var_dump($pconn1 = get_conn(2)); //oci_pconnect() +get_attr($pconn1,'MODULE'); +oci_close($pconn1); + +var_dump($nconn1 = get_conn(3)); //oci_new_connect() +set_attr($nconn1,'CLIENT_INFO',3); +set_attr($nconn1,'CLIENT_IDENTIFIER',3); +get_attr($nconn1,'CLIENT_INFO'); +get_attr($nconn1,'CLIENT_IDENTIFIER'); +oci_close($nconn1); + +// Open another connect and verify the value. +var_dump($nconn1 = get_conn(3)); //oci_new_connect() +get_attr($nconn1,'CLIENT_INFO'); +get_attr($nconn1,'CLIENT_IDENTIFIER'); +oci_close($nconn1); + +clean_up($c); +echo "Done\n"; + +?> +--EXPECTF-- +**Test Set and get values for the attributes with oci_close() ************ +Testing with oci_connect() +resource(%d) of type (oci8 connection) +Value of ACTION has been set successfully +The value of ACTION is TASK1 +Testing with oci_connect() +resource(%d) of type (oci8 connection) +The value of ACTION is +Testing with oci_pconnect() +resource(%d) of type (oci8 persistent connection) +Value of MODULE has been set successfully +The value of MODULE is PHP TEST2 +Testing with oci_pconnect() +resource(%d) of type (oci8 persistent connection) +The value of MODULE is PHP TEST2 +Testing with oci_new_connect() +resource(%d) of type (oci8 connection) +Value of CLIENT_INFO has been set successfully +Value of CLIENT_IDENTIFIER has been set successfully +The value of CLIENT_INFO is INFO13 +The value of CLIENT_IDENTIFIER is ID003 +Testing with oci_new_connect() +resource(%d) of type (oci8 connection) +The value of CLIENT_INFO is +The value of CLIENT_IDENTIFIER is +Done diff --git a/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt new file mode 100644 index 0000000..d15b7a3 --- /dev/null +++ b/ext/oci8/tests/conn_attr_4.phpt @@ -0,0 +1,119 @@ +--TEST-- +Set and get of connection attributes with errors. +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); + +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip output might vary with DRCP"); + +if (preg_match('/Release (11\.2|12)\./', oci_server_version($c), $matches) !== 1) { + // Bug fixed in 11.2 prevents client_info being rest + die("skip expected output only valid when using Oracle 11gR2 or greater database server"); +} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php + + +require(dirname(__FILE__)."/conn_attr.inc"); + +$user='testuser'; +$password='testuser'; +$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); + +echo"**Test Negative cases************\n"; + +echo "\nInvalid Connection resource\n"; +$nc1=NULL; +// Invalid connection handle. +var_dump(oci_set_action($nc1,$nc1)); + +// Variable instead of a connection resource. +echo "\nInvalid Connection resource 2\n"; +$str1= 'not a conn'; +var_dump(oci_set_client_info($str1,$str1)); + +// Setting an Invalid value. +echo "\nInvalid Value \n"; +$c1=oci_connect($user,$password,$dbase); +var_dump(oci_set_action($c1,$c1)); + +// Setting values multiple times. +echo "\nSet Values multiple times \n"; +var_dump(oci_set_action($c1,'ACTION1')); +var_dump(oci_set_action($c1,'ACTION1')); +var_dump(oci_set_action($c1,'ACTION2')); +var_dump(oci_set_action($c1,'ACTION1')); +get_attr($c1,'ACTION'); + +// Testing with different types of values +// NB. This may diff in 11.1.0.6 due to a bug causing CLIENT_INFO of NULL to be ignored. +echo "\nSetting to different values \n"; +$values_array = array(1000,NULL,'this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!'); + +foreach($values_array as $val ) { + oci_set_module_name($c1,$val); + oci_set_client_identifier($c1,$val); + oci_set_client_info($c1,$val); + $r = oci_set_action($c1,$val); + if ($r) { + echo "Values set succesfully to $val\n"; + foreach($attr_array as $attr) { + get_attr($c1,$attr); + } + } +} + +clean_up($c); +echo "Done\n"; +?> +--EXPECTF-- +**Test Negative cases************ + +Invalid Connection resource + +Warning: oci_set_action() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Invalid Connection resource 2 + +Warning: oci_set_client_info() expects parameter 1 to be resource, %s given in %s on line %d +NULL + +Invalid Value + +Warning: oci_set_action() expects parameter 2 to be %s, resource given in %s on line %d +NULL + +Set Values multiple times +bool(true) +bool(true) +bool(true) +bool(true) +The value of ACTION is ACTION1 + +Setting to different values +Values set succesfully to 1000 +The value of MODULE is 1000 +The value of ACTION is 1000 +The value of CLIENT_INFO is 1000 +The value of CLIENT_IDENTIFIER is 1000 +Values set succesfully to +The value of MODULE is +The value of ACTION is +The value of CLIENT_INFO is +The value of CLIENT_IDENTIFIER is + +Warning: oci_set_module_name(): ORA-24960: %s OCI_ATTR_MODULE %s on line %d + +Warning: oci_set_client_identifier(): ORA-24960: %s OCI_ATTR_CLIENT_IDENTIFIER %s on line %d + +Warning: oci_set_client_info(): ORA-24960: %s OCI_ATTR_CLIENT_INFO %s on line %d + +Warning: oci_set_action(): ORA-24960: %s OCI_ATTR_ACTION %s on line %d +Done diff --git a/ext/oci8/tests/conn_attr_5.phpt b/ext/oci8/tests/conn_attr_5.phpt new file mode 100644 index 0000000..d694ec0 --- /dev/null +++ b/ext/oci8/tests/conn_attr_5.phpt @@ -0,0 +1,69 @@ +--TEST-- +Set and get connection attributes with scope end. +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); + +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip output might vary with DRCP"); + +if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater database server"); +} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10g or greater version of client"); +} +?> +--FILE-- +<?php +require(dirname(__FILE__)."/conn_attr.inc"); + +echo"**Test - Set and get values for the attributes with scope end ************\n"; + +// Set the attributes in one scope and verify the values from another scope. +set_scope(); + +echo "Get the Values from a different scope \n"; +get_scope(); + +function set_scope() { + $conn1 = get_conn(1); + set_attr($conn1,'CLIENT_INFO',50); + set_attr($conn1,'CLIENT_IDENTIFIER',50); + $conn2 = get_conn(3); + set_attr($conn2,'ACTION',50); + $conn3 = get_conn(2); + set_attr($conn3,'MODULE',50); + +} + +function get_scope() { + $conn1 = get_conn(1); + get_attr($conn1,'CLIENT_INFO'); + get_attr($conn1,'CLIENT_IDENTIFIER'); + $conn2 = get_conn(3); + get_attr($conn2,'ACTION'); + $conn3 = get_conn(2); + get_attr($conn3,'MODULE'); +} +clean_up($c); +echo "Done"; +?> +--EXPECTF-- +**Test - Set and get values for the attributes with scope end ************ +Testing with oci_connect() +Value of CLIENT_INFO has been set successfully +Value of CLIENT_IDENTIFIER has been set successfully +Testing with oci_new_connect() +Value of ACTION has been set successfully +Testing with oci_pconnect() +Value of MODULE has been set successfully +Get the Values from a different scope +Testing with oci_connect() +The value of CLIENT_INFO is +The value of CLIENT_IDENTIFIER is +Testing with oci_new_connect() +The value of ACTION is +Testing with oci_pconnect() +The value of MODULE is PHP TEST50 +Done diff --git a/ext/oci8/tests/connect.inc b/ext/oci8/tests/connect.inc new file mode 100644 index 0000000..06d1348 --- /dev/null +++ b/ext/oci8/tests/connect.inc @@ -0,0 +1,17 @@ +<?php + +require("details.inc"); + +if (!empty($dbase)) { + $c = @oci_connect($user, $password, $dbase); +} +else { + $c = @oci_connect($user, $password); +} + +if (!$c) { + $m = oci_error(); + trigger_error("connect.inc: Failed to connect as '$user' to '$dbase': ". $m['message'], E_USER_ERROR); +} + +?> diff --git a/ext/oci8/tests/connect.phpt b/ext/oci8/tests/connect.phpt new file mode 100644 index 0000000..6ce4c53 --- /dev/null +++ b/ext/oci8/tests/connect.phpt @@ -0,0 +1,22 @@ +--TEST-- +oci_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/connect_1.phpt b/ext/oci8/tests/connect_1.phpt new file mode 100644 index 0000000..647a92c --- /dev/null +++ b/ext/oci8/tests/connect_1.phpt @@ -0,0 +1,35 @@ +--TEST-- +oci_pconnect() & oci_new_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c1 = oci_pconnect($user, $password, $dbase)); +} +else { + var_dump($c1 = oci_pconnect($user, $password)); +} + +if (!empty($dbase)) { + var_dump($c2 = oci_new_connect($user, $password, $dbase)); +} +else { + var_dump($c2 = oci_new_connect($user, $password)); +} + +var_dump(oci_close($c1)); +var_dump(ocilogoff($c2)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/connect_1_old.phpt b/ext/oci8/tests/connect_1_old.phpt new file mode 100644 index 0000000..8210b82 --- /dev/null +++ b/ext/oci8/tests/connect_1_old.phpt @@ -0,0 +1,35 @@ +--TEST-- +ociplogon() & ocinlogon() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c1 = ociplogon($user, $password, $dbase)); +} +else { + var_dump($c1 = ociplogon($user, $password)); +} + +if (!empty($dbase)) { + var_dump($c2 = ocinlogon($user, $password, $dbase)); +} +else { + var_dump($c2 = ocinlogon($user, $password)); +} + +var_dump(ocilogoff($c1)); +var_dump(ocilogoff($c2)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/connect_old.phpt b/ext/oci8/tests/connect_old.phpt new file mode 100644 index 0000000..55f1734 --- /dev/null +++ b/ext/oci8/tests/connect_old.phpt @@ -0,0 +1,22 @@ +--TEST-- +ocilogon() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/connect_scope1.phpt b/ext/oci8/tests/connect_scope1.phpt new file mode 100644 index 0000000..d265d1d --- /dev/null +++ b/ext/oci8/tests/connect_scope1.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test oci_connect end-of-scope when statement returned +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table connect_scope1_tab", + "create table connect_scope1_tab (c1 number)", +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1 - oci_connect\n"; + +function f() +{ + global $user, $password, $dbase; + + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into connect_scope1_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + return($s); // this keeps the connection refcount positive so the connection isn't closed +} + +$s2 = f(); + +// Check nothing committed yet + +$s1 = oci_parse($c1, "select * from connect_scope1_tab"); +oci_execute($s1, OCI_DEFAULT); +oci_fetch_all($s1, $r); +var_dump($r); + +// insert 2nd row on returned statement, committing both rows +oci_execute($s2); + +// Verify data was committed + +$s1 = oci_parse($c1, "select * from connect_scope1_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table connect_scope1_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 - oci_connect +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope2.phpt b/ext/oci8/tests/connect_scope2.phpt new file mode 100644 index 0000000..7d05c11 --- /dev/null +++ b/ext/oci8/tests/connect_scope2.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test oci_pconnect end-of-scope when statement returned +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table connect_scope2_tab", + "create table connect_scope2_tab (c1 number)", +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1 - oci_pconnect\n"; + +function f() +{ + global $user, $password, $dbase; + + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into connect_scope2_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + return($s); // this keeps the connection refcount positive so the connection isn't closed +} + +$s2 = f(); + +// Check nothing committed yet + +$s1 = oci_parse($c1, "select * from connect_scope2_tab"); +oci_execute($s1, OCI_DEFAULT); +oci_fetch_all($s1, $r); +var_dump($r); + +// insert 2nd row on returned statement, committing both rows +oci_execute($s2); + +// Verify data was committed + +$s1 = oci_parse($c1, "select * from connect_scope2_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table connect_scope2_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 - oci_pconnect +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try1.phpt b/ext/oci8/tests/connect_scope_try1.phpt new file mode 100644 index 0000000..7f26d43 --- /dev/null +++ b/ext/oci8/tests/connect_scope_try1.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_connect try/catch end-of-scope with old_oci_close_semantics Off +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try1_tab", + "create table scope_try1_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into scope_try1_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try1_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try1_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try1_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try1_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try2.phpt b/ext/oci8/tests/connect_scope_try2.phpt new file mode 100644 index 0000000..94adb85 --- /dev/null +++ b/ext/oci8/tests/connect_scope_try2.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_connect try/catch end-of-scope with old_oci_close_semantics On +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try2_tab", + "create table scope_try2_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into scope_try2_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try2_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try2_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try2_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try2_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try3.phpt b/ext/oci8/tests/connect_scope_try3.phpt new file mode 100644 index 0000000..e7891a1 --- /dev/null +++ b/ext/oci8/tests/connect_scope_try3.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_new_connect try/catch end-of-scope with old_oci_close_semantics Off +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try3_tab", + "create table scope_try3_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_new_connect($user,$password,$dbase); + else + $c = oci_new_connect($user,$password); + $s = oci_parse($c, "insert into scope_try3_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try3_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try3_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try3_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try3_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try4.phpt b/ext/oci8/tests/connect_scope_try4.phpt new file mode 100644 index 0000000..40369c6 --- /dev/null +++ b/ext/oci8/tests/connect_scope_try4.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_new_connect try/catch end-of-scope with old_oci_close_semantics On +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try4_tab", + "create table scope_try4_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_new_connect($user,$password,$dbase); + else + $c = oci_new_connect($user,$password); + $s = oci_parse($c, "insert into scope_try4_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try4_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try4_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try4_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try4_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try5.phpt b/ext/oci8/tests/connect_scope_try5.phpt new file mode 100644 index 0000000..3afc87b --- /dev/null +++ b/ext/oci8/tests/connect_scope_try5.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_pconnect try/catch end-of-scope with old_oci_close_semantics Off +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try5_tab", + "create table scope_try5_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into scope_try5_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try5_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try5_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try5_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try5_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 persistent connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done diff --git a/ext/oci8/tests/connect_scope_try6.phpt b/ext/oci8/tests/connect_scope_try6.phpt new file mode 100644 index 0000000..d7b4edf --- /dev/null +++ b/ext/oci8/tests/connect_scope_try6.phpt @@ -0,0 +1,94 @@ +--TEST-- +Check oci_pconnect try/catch end-of-scope with old_oci_close_semantics On +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +// Initialization + +$stmtarray = array( + "drop table scope_try6_tab", + "create table scope_try6_tab (c1 number)" +); + +if (!empty($dbase)) + $c1 = oci_new_connect($user,$password,$dbase); +else + $c1 = oci_new_connect($user,$password); + +oci8_test_sql_execute($c1, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +// Make errors throw exceptions + +set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);')); + +try +{ + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into scope_try6_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try6_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit +} +catch (Exception $e) +{ + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); + + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try6_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); + + // Now commit + oci_commit($c); +} + +// Verify data was committed in the Catch block + +$s1 = oci_parse($c1, "select * from scope_try6_tab"); +oci_execute($s1); +oci_fetch_all($s1, $r); +var_dump($r); + +// Cleanup + +$stmtarray = array( + "drop table scope_try6_tab" +); + +oci8_test_sql_execute($c1, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s +resource(%d) of type (oci8 persistent connection) +array(1) { + ["C1"]=> + array(0) { + } +} +array(1) { + ["C1"]=> + array(1) { + [0]=> + string(1) "1" + } +} +Done 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 0000000..9149747 --- /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/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt new file mode 100644 index 0000000..e14fb93 --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -0,0 +1,38 @@ +--TEST-- +oci_connect() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); +if ($ov !== 1) { + die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); +} +$iv = preg_match('/Oracle .*Version => (10\.2)/', $phpinfo); +if ($iv != 1) { + die ("skip tests a feature that works only with Oracle 10gR2"); +} +?> +--ENV-- +ORACLE_HOME="" +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d +bool(false) +===DONE=== diff --git a/ext/oci8/tests/connect_without_oracle_home_11.phpt b/ext/oci8/tests/connect_without_oracle_home_11.phpt new file mode 100644 index 0000000..1620803 --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home_11.phpt @@ -0,0 +1,40 @@ +--TEST-- +oci_connect() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); +if ($ov != 1) { + die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); +} +if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--ENV-- +ORACLE_HOME="" +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d + +Warning: oci_connect(): Error while trying to retrieve text for error ORA-01804 + in %s on line %d +bool(false) +===DONE=== diff --git a/ext/oci8/tests/connect_without_oracle_home_old.phpt b/ext/oci8/tests/connect_without_oracle_home_old.phpt new file mode 100644 index 0000000..5a73133 --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home_old.phpt @@ -0,0 +1,37 @@ +--TEST-- +ocilogon() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); +if ($ov !== 1) { + die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); +} +if (preg_match('/^10\.2\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 10gR2 client libraries"); +} +?> +--ENV-- +ORACLE_HOME="" +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Warning: ocilogon(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d +bool(false) +===DONE=== diff --git a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt new file mode 100644 index 0000000..c7cfecf --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt @@ -0,0 +1,40 @@ +--TEST-- +ocilogon() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); +if ($ov !== 1) { + die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); +} +if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--ENV-- +ORACLE_HOME="" +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Warning: ocilogon(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d + +Warning: ocilogon(): Error while trying to retrieve text for error ORA-01804 + in %sconnect_without_oracle_home_old_11.php on line %d +bool(false) +===DONE=== diff --git a/ext/oci8/tests/create_table.inc b/ext/oci8/tests/create_table.inc new file mode 100644 index 0000000..7335980 --- /dev/null +++ b/ext/oci8/tests/create_table.inc @@ -0,0 +1,13 @@ +<?php +if ($c) { + + + $stmtarray = array( + "DROP TABLE ".$schema.$table_name, + "CREATE TABLE ".$schema.$table_name." (id NUMBER, value NUMBER, blob BLOB, clob CLOB, string VARCHAR(10))" + ); + + oci8_test_sql_execute($c, $stmtarray); + +} +?> diff --git a/ext/oci8/tests/create_type.inc b/ext/oci8/tests/create_type.inc new file mode 100644 index 0000000..e23f7cb --- /dev/null +++ b/ext/oci8/tests/create_type.inc @@ -0,0 +1,17 @@ +<?php + + if ($c) { + $ora_sql = "DROP TYPE + ".$type_name." + "; + + $statement = OCIParse($c,$ora_sql); + @OCIExecute($statement); + + $ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER(11)"; + + $statement = OCIParse($c,$ora_sql); + OCIExecute($statement); + } + +?> diff --git a/ext/oci8/tests/cursor_bind.phpt b/ext/oci8/tests/cursor_bind.phpt new file mode 100644 index 0000000..740402e --- /dev/null +++ b/ext/oci8/tests/cursor_bind.phpt @@ -0,0 +1,79 @@ +--TEST-- +bind and fetch cursor from a statement +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialization + +$stmtarray = array( + "drop table cursor_bind_tab", + "create table cursor_bind_tab (id NUMBER, value VARCHAR(20))", + "insert into cursor_bind_tab values (1, '1')", + "insert into cursor_bind_tab values (1, '1')", + "insert into cursor_bind_tab values (1, '1')" +); + +oci8_test_sql_execute($c, $stmtarray); + +$sql = " +DECLARE +TYPE curtype IS REF CURSOR; +cursor_var curtype; +BEGIN + OPEN cursor_var FOR SELECT id, value FROM cursor_bind_tab; + :curs := cursor_var; +END; +"; + +$stmt = oci_parse($c, $sql); + +$cursor = oci_new_cursor($c); +oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR); + +oci_execute($stmt); + +oci_execute($cursor); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); + +// Clean up + +$stmtarray = array( + "drop table cursor_bind_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +bool(false) +===DONE=== diff --git a/ext/oci8/tests/cursor_bind_err.phpt b/ext/oci8/tests/cursor_bind_err.phpt new file mode 100644 index 0000000..197aad1 --- /dev/null +++ b/ext/oci8/tests/cursor_bind_err.phpt @@ -0,0 +1,54 @@ +--TEST-- +binding a cursor (with errors) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table cursor_bind_err_tab", + "create table cursor_bind_err_tab (id number, value number)", + "insert into cursor_bind_err_tab (id, value) values (1,1)", + "insert into cursor_bind_err_tab (id, value) values (1,1)", + "insert into cursor_bind_err_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$sql = "select cursor(select * from cursor_bind_err_tab) into :cursor from dual"; +$stmt = oci_parse($c, $sql); + +$cursor = oci_new_cursor($c); +oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + +oci_execute($stmt); + +oci_execute($cursor); +var_dump(oci_fetch_assoc($cursor)); + +// Cleanup + +$stmtarray = array( + "drop table cursor_bind_err_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_bind_by_name(): ORA-01036: %s in %s on line %d + +Warning: oci_fetch_assoc(): ORA-24338: %s in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/cursors.phpt b/ext/oci8/tests/cursors.phpt new file mode 100644 index 0000000..0919e44 --- /dev/null +++ b/ext/oci8/tests/cursors.phpt @@ -0,0 +1,68 @@ +--TEST-- +fetching cursor from a statement +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual"; +$stmt = oci_parse($c, $sql); + +oci_execute($stmt); + +while ($data = oci_fetch_assoc($stmt)) { + oci_execute($data["CURS"]); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL +} +bool(true) + +Warning: oci_fetch_assoc(): ORA-01002: fetch out of sequence in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt new file mode 100644 index 0000000..d60e2ff --- /dev/null +++ b/ext/oci8/tests/cursors_old.phpt @@ -0,0 +1,70 @@ +--TEST-- +fetching cursor from a statement +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table cursors_old_tab", + "create table cursors_old_tab (id number, value number)", + "insert into cursors_old_tab (id, value) values (1,1)", + "insert into cursors_old_tab (id, value) values (1,1)", + "insert into cursors_old_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$sql = "select cursor(select * from cursors_old_tab) as curs from dual"; +$stmt = ociparse($c, $sql); + +ociexecute($stmt); + +while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) { + ociexecute($data["CURS"]); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); +} + +// Cleanup + +$stmtarray = array( + "drop table cursors_old_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(1) "1" +} +bool(true) + +Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d +array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(1) "1" +} +bool(true) +Done diff --git a/ext/oci8/tests/dbmsoutput.phpt b/ext/oci8/tests/dbmsoutput.phpt new file mode 100644 index 0000000..eaace0f --- /dev/null +++ b/ext/oci8/tests/dbmsoutput.phpt @@ -0,0 +1,750 @@ +--TEST-- +PL/SQL: dbms_output +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure dbmsoutput_proc as + begin + dbms_output.put_line('Hello World!'); + end;", + + "create or replace type dorow as table of varchar2(4000)", + + "create or replace function mydofetch return dorow pipelined is + line varchar2(4000); + status integer; + begin + loop + dbms_output.get_line(line, status); + exit when status = 1; + pipe row (line); + end loop; + return; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +// Turn DBMS_OUTPUT on +function setserveroutputon($c) +{ + $s = oci_parse($c, "begin dbms_output.enable(null); end;"); + oci_execute($s); +} + +// Create some output +function createoutput($c, $prefix) +{ + $s = oci_parse($c, "call dbms_output.put_line(:bv1 || ' ' || :bv2 || ' Hello, world! Lots and lots and ... of text')"); + oci_bind_by_name($s, ":bv1", $i, -1, SQLT_INT); + oci_bind_by_name($s, ":bv2", $prefix); + for ($i = 0; $i < 100; ++$i) { + oci_execute($s); + } +} + +// Call dbms_output.get_line() +// Returns an array of DBMS_OUTPUT lines, or false. +function getdbmsoutput_do($c) +{ + $s = oci_parse($c, "begin dbms_output.get_line(:ln, :st); end;"); + oci_bind_by_name($s, ":ln", $ln, 100); + oci_bind_by_name($s, ":st", $st, -1, SQLT_INT); + $res = false; + while (($succ = oci_execute($s)) && !$st) { + $res[] = $ln; // append each line to the array + } + return $res; +} + +function getdbmsoutput_do2($c) +{ + $orignumlines = $numlines = 100; + $s = oci_parse($c, "begin dbms_output.get_lines(:lines, :numlines); end;"); + $r = oci_bind_by_name($s, ":numlines", $numlines); + $res = array(); + while ($numlines >= $orignumlines) { + oci_bind_array_by_name($s, ":lines", $lines, $numlines, 255, SQLT_CHR); + oci_execute($s); + if ($numlines == 0) { + break; + } + $res = array_merge($res, array_slice($lines, 0, $numlines)); + unset($lines); + } + return $res; +} + +function getdbmsoutput_pl($c) +{ + $s = oci_parse($c, "select * from table(mydofetch())"); + oci_execute($s); + $res = false; + while ($row = oci_fetch_array($s, OCI_NUM)) { + $res[] = $row[0]; + } + return $res; +} + +echo "Test 1\n"; + +setserveroutputon($c); // Turn output buffering on + +$s = oci_parse($c, 'call dbmsoutput_proc()'); +oci_execute($s); +var_dump(getdbmsoutput_do($c)); + +echo "Test 2\n"; + +createoutput($c, 'test 2'); +var_dump(getdbmsoutput_do($c)); + +echo "Test 3\n"; + +createoutput($c, 'test 3'); +var_dump(getdbmsoutput_do2($c)); + +echo "Test 4\n"; + +createoutput($c, 'test 4'); +var_dump(getdbmsoutput_pl($c)); + +// Clean up + +$stmtarray = array( + "drop procedure dbmsoutput_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(1) { + [0]=> + string(12) "Hello World!" +} +Test 2 +array(100) { + [0]=> + string(52) "0 test 2 Hello, world! Lots and lots and ... of text" + [1]=> + string(52) "1 test 2 Hello, world! Lots and lots and ... of text" + [2]=> + string(52) "2 test 2 Hello, world! Lots and lots and ... of text" + [3]=> + string(52) "3 test 2 Hello, world! Lots and lots and ... of text" + [4]=> + string(52) "4 test 2 Hello, world! Lots and lots and ... of text" + [5]=> + string(52) "5 test 2 Hello, world! Lots and lots and ... of text" + [6]=> + string(52) "6 test 2 Hello, world! Lots and lots and ... of text" + [7]=> + string(52) "7 test 2 Hello, world! Lots and lots and ... of text" + [8]=> + string(52) "8 test 2 Hello, world! Lots and lots and ... of text" + [9]=> + string(52) "9 test 2 Hello, world! Lots and lots and ... of text" + [10]=> + string(53) "10 test 2 Hello, world! Lots and lots and ... of text" + [11]=> + string(53) "11 test 2 Hello, world! Lots and lots and ... of text" + [12]=> + string(53) "12 test 2 Hello, world! Lots and lots and ... of text" + [13]=> + string(53) "13 test 2 Hello, world! Lots and lots and ... of text" + [14]=> + string(53) "14 test 2 Hello, world! Lots and lots and ... of text" + [15]=> + string(53) "15 test 2 Hello, world! Lots and lots and ... of text" + [16]=> + string(53) "16 test 2 Hello, world! Lots and lots and ... of text" + [17]=> + string(53) "17 test 2 Hello, world! Lots and lots and ... of text" + [18]=> + string(53) "18 test 2 Hello, world! Lots and lots and ... of text" + [19]=> + string(53) "19 test 2 Hello, world! Lots and lots and ... of text" + [20]=> + string(53) "20 test 2 Hello, world! Lots and lots and ... of text" + [21]=> + string(53) "21 test 2 Hello, world! Lots and lots and ... of text" + [22]=> + string(53) "22 test 2 Hello, world! Lots and lots and ... of text" + [23]=> + string(53) "23 test 2 Hello, world! Lots and lots and ... of text" + [24]=> + string(53) "24 test 2 Hello, world! Lots and lots and ... of text" + [25]=> + string(53) "25 test 2 Hello, world! Lots and lots and ... of text" + [26]=> + string(53) "26 test 2 Hello, world! Lots and lots and ... of text" + [27]=> + string(53) "27 test 2 Hello, world! Lots and lots and ... of text" + [28]=> + string(53) "28 test 2 Hello, world! Lots and lots and ... of text" + [29]=> + string(53) "29 test 2 Hello, world! Lots and lots and ... of text" + [30]=> + string(53) "30 test 2 Hello, world! Lots and lots and ... of text" + [31]=> + string(53) "31 test 2 Hello, world! Lots and lots and ... of text" + [32]=> + string(53) "32 test 2 Hello, world! Lots and lots and ... of text" + [33]=> + string(53) "33 test 2 Hello, world! Lots and lots and ... of text" + [34]=> + string(53) "34 test 2 Hello, world! Lots and lots and ... of text" + [35]=> + string(53) "35 test 2 Hello, world! Lots and lots and ... of text" + [36]=> + string(53) "36 test 2 Hello, world! Lots and lots and ... of text" + [37]=> + string(53) "37 test 2 Hello, world! Lots and lots and ... of text" + [38]=> + string(53) "38 test 2 Hello, world! Lots and lots and ... of text" + [39]=> + string(53) "39 test 2 Hello, world! Lots and lots and ... of text" + [40]=> + string(53) "40 test 2 Hello, world! Lots and lots and ... of text" + [41]=> + string(53) "41 test 2 Hello, world! Lots and lots and ... of text" + [42]=> + string(53) "42 test 2 Hello, world! Lots and lots and ... of text" + [43]=> + string(53) "43 test 2 Hello, world! Lots and lots and ... of text" + [44]=> + string(53) "44 test 2 Hello, world! Lots and lots and ... of text" + [45]=> + string(53) "45 test 2 Hello, world! Lots and lots and ... of text" + [46]=> + string(53) "46 test 2 Hello, world! Lots and lots and ... of text" + [47]=> + string(53) "47 test 2 Hello, world! Lots and lots and ... of text" + [48]=> + string(53) "48 test 2 Hello, world! Lots and lots and ... of text" + [49]=> + string(53) "49 test 2 Hello, world! Lots and lots and ... of text" + [50]=> + string(53) "50 test 2 Hello, world! Lots and lots and ... of text" + [51]=> + string(53) "51 test 2 Hello, world! Lots and lots and ... of text" + [52]=> + string(53) "52 test 2 Hello, world! Lots and lots and ... of text" + [53]=> + string(53) "53 test 2 Hello, world! Lots and lots and ... of text" + [54]=> + string(53) "54 test 2 Hello, world! Lots and lots and ... of text" + [55]=> + string(53) "55 test 2 Hello, world! Lots and lots and ... of text" + [56]=> + string(53) "56 test 2 Hello, world! Lots and lots and ... of text" + [57]=> + string(53) "57 test 2 Hello, world! Lots and lots and ... of text" + [58]=> + string(53) "58 test 2 Hello, world! Lots and lots and ... of text" + [59]=> + string(53) "59 test 2 Hello, world! Lots and lots and ... of text" + [60]=> + string(53) "60 test 2 Hello, world! Lots and lots and ... of text" + [61]=> + string(53) "61 test 2 Hello, world! Lots and lots and ... of text" + [62]=> + string(53) "62 test 2 Hello, world! Lots and lots and ... of text" + [63]=> + string(53) "63 test 2 Hello, world! Lots and lots and ... of text" + [64]=> + string(53) "64 test 2 Hello, world! Lots and lots and ... of text" + [65]=> + string(53) "65 test 2 Hello, world! Lots and lots and ... of text" + [66]=> + string(53) "66 test 2 Hello, world! Lots and lots and ... of text" + [67]=> + string(53) "67 test 2 Hello, world! Lots and lots and ... of text" + [68]=> + string(53) "68 test 2 Hello, world! Lots and lots and ... of text" + [69]=> + string(53) "69 test 2 Hello, world! Lots and lots and ... of text" + [70]=> + string(53) "70 test 2 Hello, world! Lots and lots and ... of text" + [71]=> + string(53) "71 test 2 Hello, world! Lots and lots and ... of text" + [72]=> + string(53) "72 test 2 Hello, world! Lots and lots and ... of text" + [73]=> + string(53) "73 test 2 Hello, world! Lots and lots and ... of text" + [74]=> + string(53) "74 test 2 Hello, world! Lots and lots and ... of text" + [75]=> + string(53) "75 test 2 Hello, world! Lots and lots and ... of text" + [76]=> + string(53) "76 test 2 Hello, world! Lots and lots and ... of text" + [77]=> + string(53) "77 test 2 Hello, world! Lots and lots and ... of text" + [78]=> + string(53) "78 test 2 Hello, world! Lots and lots and ... of text" + [79]=> + string(53) "79 test 2 Hello, world! Lots and lots and ... of text" + [80]=> + string(53) "80 test 2 Hello, world! Lots and lots and ... of text" + [81]=> + string(53) "81 test 2 Hello, world! Lots and lots and ... of text" + [82]=> + string(53) "82 test 2 Hello, world! Lots and lots and ... of text" + [83]=> + string(53) "83 test 2 Hello, world! Lots and lots and ... of text" + [84]=> + string(53) "84 test 2 Hello, world! Lots and lots and ... of text" + [85]=> + string(53) "85 test 2 Hello, world! Lots and lots and ... of text" + [86]=> + string(53) "86 test 2 Hello, world! Lots and lots and ... of text" + [87]=> + string(53) "87 test 2 Hello, world! Lots and lots and ... of text" + [88]=> + string(53) "88 test 2 Hello, world! Lots and lots and ... of text" + [89]=> + string(53) "89 test 2 Hello, world! Lots and lots and ... of text" + [90]=> + string(53) "90 test 2 Hello, world! Lots and lots and ... of text" + [91]=> + string(53) "91 test 2 Hello, world! Lots and lots and ... of text" + [92]=> + string(53) "92 test 2 Hello, world! Lots and lots and ... of text" + [93]=> + string(53) "93 test 2 Hello, world! Lots and lots and ... of text" + [94]=> + string(53) "94 test 2 Hello, world! Lots and lots and ... of text" + [95]=> + string(53) "95 test 2 Hello, world! Lots and lots and ... of text" + [96]=> + string(53) "96 test 2 Hello, world! Lots and lots and ... of text" + [97]=> + string(53) "97 test 2 Hello, world! Lots and lots and ... of text" + [98]=> + string(53) "98 test 2 Hello, world! Lots and lots and ... of text" + [99]=> + string(53) "99 test 2 Hello, world! Lots and lots and ... of text" +} +Test 3 +array(100) { + [0]=> + string(52) "0 test 3 Hello, world! Lots and lots and ... of text" + [1]=> + string(52) "1 test 3 Hello, world! Lots and lots and ... of text" + [2]=> + string(52) "2 test 3 Hello, world! Lots and lots and ... of text" + [3]=> + string(52) "3 test 3 Hello, world! Lots and lots and ... of text" + [4]=> + string(52) "4 test 3 Hello, world! Lots and lots and ... of text" + [5]=> + string(52) "5 test 3 Hello, world! Lots and lots and ... of text" + [6]=> + string(52) "6 test 3 Hello, world! Lots and lots and ... of text" + [7]=> + string(52) "7 test 3 Hello, world! Lots and lots and ... of text" + [8]=> + string(52) "8 test 3 Hello, world! Lots and lots and ... of text" + [9]=> + string(52) "9 test 3 Hello, world! Lots and lots and ... of text" + [10]=> + string(53) "10 test 3 Hello, world! Lots and lots and ... of text" + [11]=> + string(53) "11 test 3 Hello, world! Lots and lots and ... of text" + [12]=> + string(53) "12 test 3 Hello, world! Lots and lots and ... of text" + [13]=> + string(53) "13 test 3 Hello, world! Lots and lots and ... of text" + [14]=> + string(53) "14 test 3 Hello, world! Lots and lots and ... of text" + [15]=> + string(53) "15 test 3 Hello, world! Lots and lots and ... of text" + [16]=> + string(53) "16 test 3 Hello, world! Lots and lots and ... of text" + [17]=> + string(53) "17 test 3 Hello, world! Lots and lots and ... of text" + [18]=> + string(53) "18 test 3 Hello, world! Lots and lots and ... of text" + [19]=> + string(53) "19 test 3 Hello, world! Lots and lots and ... of text" + [20]=> + string(53) "20 test 3 Hello, world! Lots and lots and ... of text" + [21]=> + string(53) "21 test 3 Hello, world! Lots and lots and ... of text" + [22]=> + string(53) "22 test 3 Hello, world! Lots and lots and ... of text" + [23]=> + string(53) "23 test 3 Hello, world! Lots and lots and ... of text" + [24]=> + string(53) "24 test 3 Hello, world! Lots and lots and ... of text" + [25]=> + string(53) "25 test 3 Hello, world! Lots and lots and ... of text" + [26]=> + string(53) "26 test 3 Hello, world! Lots and lots and ... of text" + [27]=> + string(53) "27 test 3 Hello, world! Lots and lots and ... of text" + [28]=> + string(53) "28 test 3 Hello, world! Lots and lots and ... of text" + [29]=> + string(53) "29 test 3 Hello, world! Lots and lots and ... of text" + [30]=> + string(53) "30 test 3 Hello, world! Lots and lots and ... of text" + [31]=> + string(53) "31 test 3 Hello, world! Lots and lots and ... of text" + [32]=> + string(53) "32 test 3 Hello, world! Lots and lots and ... of text" + [33]=> + string(53) "33 test 3 Hello, world! Lots and lots and ... of text" + [34]=> + string(53) "34 test 3 Hello, world! Lots and lots and ... of text" + [35]=> + string(53) "35 test 3 Hello, world! Lots and lots and ... of text" + [36]=> + string(53) "36 test 3 Hello, world! Lots and lots and ... of text" + [37]=> + string(53) "37 test 3 Hello, world! Lots and lots and ... of text" + [38]=> + string(53) "38 test 3 Hello, world! Lots and lots and ... of text" + [39]=> + string(53) "39 test 3 Hello, world! Lots and lots and ... of text" + [40]=> + string(53) "40 test 3 Hello, world! Lots and lots and ... of text" + [41]=> + string(53) "41 test 3 Hello, world! Lots and lots and ... of text" + [42]=> + string(53) "42 test 3 Hello, world! Lots and lots and ... of text" + [43]=> + string(53) "43 test 3 Hello, world! Lots and lots and ... of text" + [44]=> + string(53) "44 test 3 Hello, world! Lots and lots and ... of text" + [45]=> + string(53) "45 test 3 Hello, world! Lots and lots and ... of text" + [46]=> + string(53) "46 test 3 Hello, world! Lots and lots and ... of text" + [47]=> + string(53) "47 test 3 Hello, world! Lots and lots and ... of text" + [48]=> + string(53) "48 test 3 Hello, world! Lots and lots and ... of text" + [49]=> + string(53) "49 test 3 Hello, world! Lots and lots and ... of text" + [50]=> + string(53) "50 test 3 Hello, world! Lots and lots and ... of text" + [51]=> + string(53) "51 test 3 Hello, world! Lots and lots and ... of text" + [52]=> + string(53) "52 test 3 Hello, world! Lots and lots and ... of text" + [53]=> + string(53) "53 test 3 Hello, world! Lots and lots and ... of text" + [54]=> + string(53) "54 test 3 Hello, world! Lots and lots and ... of text" + [55]=> + string(53) "55 test 3 Hello, world! Lots and lots and ... of text" + [56]=> + string(53) "56 test 3 Hello, world! Lots and lots and ... of text" + [57]=> + string(53) "57 test 3 Hello, world! Lots and lots and ... of text" + [58]=> + string(53) "58 test 3 Hello, world! Lots and lots and ... of text" + [59]=> + string(53) "59 test 3 Hello, world! Lots and lots and ... of text" + [60]=> + string(53) "60 test 3 Hello, world! Lots and lots and ... of text" + [61]=> + string(53) "61 test 3 Hello, world! Lots and lots and ... of text" + [62]=> + string(53) "62 test 3 Hello, world! Lots and lots and ... of text" + [63]=> + string(53) "63 test 3 Hello, world! Lots and lots and ... of text" + [64]=> + string(53) "64 test 3 Hello, world! Lots and lots and ... of text" + [65]=> + string(53) "65 test 3 Hello, world! Lots and lots and ... of text" + [66]=> + string(53) "66 test 3 Hello, world! Lots and lots and ... of text" + [67]=> + string(53) "67 test 3 Hello, world! Lots and lots and ... of text" + [68]=> + string(53) "68 test 3 Hello, world! Lots and lots and ... of text" + [69]=> + string(53) "69 test 3 Hello, world! Lots and lots and ... of text" + [70]=> + string(53) "70 test 3 Hello, world! Lots and lots and ... of text" + [71]=> + string(53) "71 test 3 Hello, world! Lots and lots and ... of text" + [72]=> + string(53) "72 test 3 Hello, world! Lots and lots and ... of text" + [73]=> + string(53) "73 test 3 Hello, world! Lots and lots and ... of text" + [74]=> + string(53) "74 test 3 Hello, world! Lots and lots and ... of text" + [75]=> + string(53) "75 test 3 Hello, world! Lots and lots and ... of text" + [76]=> + string(53) "76 test 3 Hello, world! Lots and lots and ... of text" + [77]=> + string(53) "77 test 3 Hello, world! Lots and lots and ... of text" + [78]=> + string(53) "78 test 3 Hello, world! Lots and lots and ... of text" + [79]=> + string(53) "79 test 3 Hello, world! Lots and lots and ... of text" + [80]=> + string(53) "80 test 3 Hello, world! Lots and lots and ... of text" + [81]=> + string(53) "81 test 3 Hello, world! Lots and lots and ... of text" + [82]=> + string(53) "82 test 3 Hello, world! Lots and lots and ... of text" + [83]=> + string(53) "83 test 3 Hello, world! Lots and lots and ... of text" + [84]=> + string(53) "84 test 3 Hello, world! Lots and lots and ... of text" + [85]=> + string(53) "85 test 3 Hello, world! Lots and lots and ... of text" + [86]=> + string(53) "86 test 3 Hello, world! Lots and lots and ... of text" + [87]=> + string(53) "87 test 3 Hello, world! Lots and lots and ... of text" + [88]=> + string(53) "88 test 3 Hello, world! Lots and lots and ... of text" + [89]=> + string(53) "89 test 3 Hello, world! Lots and lots and ... of text" + [90]=> + string(53) "90 test 3 Hello, world! Lots and lots and ... of text" + [91]=> + string(53) "91 test 3 Hello, world! Lots and lots and ... of text" + [92]=> + string(53) "92 test 3 Hello, world! Lots and lots and ... of text" + [93]=> + string(53) "93 test 3 Hello, world! Lots and lots and ... of text" + [94]=> + string(53) "94 test 3 Hello, world! Lots and lots and ... of text" + [95]=> + string(53) "95 test 3 Hello, world! Lots and lots and ... of text" + [96]=> + string(53) "96 test 3 Hello, world! Lots and lots and ... of text" + [97]=> + string(53) "97 test 3 Hello, world! Lots and lots and ... of text" + [98]=> + string(53) "98 test 3 Hello, world! Lots and lots and ... of text" + [99]=> + string(53) "99 test 3 Hello, world! Lots and lots and ... of text" +} +Test 4 +array(100) { + [0]=> + string(52) "0 test 4 Hello, world! Lots and lots and ... of text" + [1]=> + string(52) "1 test 4 Hello, world! Lots and lots and ... of text" + [2]=> + string(52) "2 test 4 Hello, world! Lots and lots and ... of text" + [3]=> + string(52) "3 test 4 Hello, world! Lots and lots and ... of text" + [4]=> + string(52) "4 test 4 Hello, world! Lots and lots and ... of text" + [5]=> + string(52) "5 test 4 Hello, world! Lots and lots and ... of text" + [6]=> + string(52) "6 test 4 Hello, world! Lots and lots and ... of text" + [7]=> + string(52) "7 test 4 Hello, world! Lots and lots and ... of text" + [8]=> + string(52) "8 test 4 Hello, world! Lots and lots and ... of text" + [9]=> + string(52) "9 test 4 Hello, world! Lots and lots and ... of text" + [10]=> + string(53) "10 test 4 Hello, world! Lots and lots and ... of text" + [11]=> + string(53) "11 test 4 Hello, world! Lots and lots and ... of text" + [12]=> + string(53) "12 test 4 Hello, world! Lots and lots and ... of text" + [13]=> + string(53) "13 test 4 Hello, world! Lots and lots and ... of text" + [14]=> + string(53) "14 test 4 Hello, world! Lots and lots and ... of text" + [15]=> + string(53) "15 test 4 Hello, world! Lots and lots and ... of text" + [16]=> + string(53) "16 test 4 Hello, world! Lots and lots and ... of text" + [17]=> + string(53) "17 test 4 Hello, world! Lots and lots and ... of text" + [18]=> + string(53) "18 test 4 Hello, world! Lots and lots and ... of text" + [19]=> + string(53) "19 test 4 Hello, world! Lots and lots and ... of text" + [20]=> + string(53) "20 test 4 Hello, world! Lots and lots and ... of text" + [21]=> + string(53) "21 test 4 Hello, world! Lots and lots and ... of text" + [22]=> + string(53) "22 test 4 Hello, world! Lots and lots and ... of text" + [23]=> + string(53) "23 test 4 Hello, world! Lots and lots and ... of text" + [24]=> + string(53) "24 test 4 Hello, world! Lots and lots and ... of text" + [25]=> + string(53) "25 test 4 Hello, world! Lots and lots and ... of text" + [26]=> + string(53) "26 test 4 Hello, world! Lots and lots and ... of text" + [27]=> + string(53) "27 test 4 Hello, world! Lots and lots and ... of text" + [28]=> + string(53) "28 test 4 Hello, world! Lots and lots and ... of text" + [29]=> + string(53) "29 test 4 Hello, world! Lots and lots and ... of text" + [30]=> + string(53) "30 test 4 Hello, world! Lots and lots and ... of text" + [31]=> + string(53) "31 test 4 Hello, world! Lots and lots and ... of text" + [32]=> + string(53) "32 test 4 Hello, world! Lots and lots and ... of text" + [33]=> + string(53) "33 test 4 Hello, world! Lots and lots and ... of text" + [34]=> + string(53) "34 test 4 Hello, world! Lots and lots and ... of text" + [35]=> + string(53) "35 test 4 Hello, world! Lots and lots and ... of text" + [36]=> + string(53) "36 test 4 Hello, world! Lots and lots and ... of text" + [37]=> + string(53) "37 test 4 Hello, world! Lots and lots and ... of text" + [38]=> + string(53) "38 test 4 Hello, world! Lots and lots and ... of text" + [39]=> + string(53) "39 test 4 Hello, world! Lots and lots and ... of text" + [40]=> + string(53) "40 test 4 Hello, world! Lots and lots and ... of text" + [41]=> + string(53) "41 test 4 Hello, world! Lots and lots and ... of text" + [42]=> + string(53) "42 test 4 Hello, world! Lots and lots and ... of text" + [43]=> + string(53) "43 test 4 Hello, world! Lots and lots and ... of text" + [44]=> + string(53) "44 test 4 Hello, world! Lots and lots and ... of text" + [45]=> + string(53) "45 test 4 Hello, world! Lots and lots and ... of text" + [46]=> + string(53) "46 test 4 Hello, world! Lots and lots and ... of text" + [47]=> + string(53) "47 test 4 Hello, world! Lots and lots and ... of text" + [48]=> + string(53) "48 test 4 Hello, world! Lots and lots and ... of text" + [49]=> + string(53) "49 test 4 Hello, world! Lots and lots and ... of text" + [50]=> + string(53) "50 test 4 Hello, world! Lots and lots and ... of text" + [51]=> + string(53) "51 test 4 Hello, world! Lots and lots and ... of text" + [52]=> + string(53) "52 test 4 Hello, world! Lots and lots and ... of text" + [53]=> + string(53) "53 test 4 Hello, world! Lots and lots and ... of text" + [54]=> + string(53) "54 test 4 Hello, world! Lots and lots and ... of text" + [55]=> + string(53) "55 test 4 Hello, world! Lots and lots and ... of text" + [56]=> + string(53) "56 test 4 Hello, world! Lots and lots and ... of text" + [57]=> + string(53) "57 test 4 Hello, world! Lots and lots and ... of text" + [58]=> + string(53) "58 test 4 Hello, world! Lots and lots and ... of text" + [59]=> + string(53) "59 test 4 Hello, world! Lots and lots and ... of text" + [60]=> + string(53) "60 test 4 Hello, world! Lots and lots and ... of text" + [61]=> + string(53) "61 test 4 Hello, world! Lots and lots and ... of text" + [62]=> + string(53) "62 test 4 Hello, world! Lots and lots and ... of text" + [63]=> + string(53) "63 test 4 Hello, world! Lots and lots and ... of text" + [64]=> + string(53) "64 test 4 Hello, world! Lots and lots and ... of text" + [65]=> + string(53) "65 test 4 Hello, world! Lots and lots and ... of text" + [66]=> + string(53) "66 test 4 Hello, world! Lots and lots and ... of text" + [67]=> + string(53) "67 test 4 Hello, world! Lots and lots and ... of text" + [68]=> + string(53) "68 test 4 Hello, world! Lots and lots and ... of text" + [69]=> + string(53) "69 test 4 Hello, world! Lots and lots and ... of text" + [70]=> + string(53) "70 test 4 Hello, world! Lots and lots and ... of text" + [71]=> + string(53) "71 test 4 Hello, world! Lots and lots and ... of text" + [72]=> + string(53) "72 test 4 Hello, world! Lots and lots and ... of text" + [73]=> + string(53) "73 test 4 Hello, world! Lots and lots and ... of text" + [74]=> + string(53) "74 test 4 Hello, world! Lots and lots and ... of text" + [75]=> + string(53) "75 test 4 Hello, world! Lots and lots and ... of text" + [76]=> + string(53) "76 test 4 Hello, world! Lots and lots and ... of text" + [77]=> + string(53) "77 test 4 Hello, world! Lots and lots and ... of text" + [78]=> + string(53) "78 test 4 Hello, world! Lots and lots and ... of text" + [79]=> + string(53) "79 test 4 Hello, world! Lots and lots and ... of text" + [80]=> + string(53) "80 test 4 Hello, world! Lots and lots and ... of text" + [81]=> + string(53) "81 test 4 Hello, world! Lots and lots and ... of text" + [82]=> + string(53) "82 test 4 Hello, world! Lots and lots and ... of text" + [83]=> + string(53) "83 test 4 Hello, world! Lots and lots and ... of text" + [84]=> + string(53) "84 test 4 Hello, world! Lots and lots and ... of text" + [85]=> + string(53) "85 test 4 Hello, world! Lots and lots and ... of text" + [86]=> + string(53) "86 test 4 Hello, world! Lots and lots and ... of text" + [87]=> + string(53) "87 test 4 Hello, world! Lots and lots and ... of text" + [88]=> + string(53) "88 test 4 Hello, world! Lots and lots and ... of text" + [89]=> + string(53) "89 test 4 Hello, world! Lots and lots and ... of text" + [90]=> + string(53) "90 test 4 Hello, world! Lots and lots and ... of text" + [91]=> + string(53) "91 test 4 Hello, world! Lots and lots and ... of text" + [92]=> + string(53) "92 test 4 Hello, world! Lots and lots and ... of text" + [93]=> + string(53) "93 test 4 Hello, world! Lots and lots and ... of text" + [94]=> + string(53) "94 test 4 Hello, world! Lots and lots and ... of text" + [95]=> + string(53) "95 test 4 Hello, world! Lots and lots and ... of text" + [96]=> + string(53) "96 test 4 Hello, world! Lots and lots and ... of text" + [97]=> + string(53) "97 test 4 Hello, world! Lots and lots and ... of text" + [98]=> + string(53) "98 test 4 Hello, world! Lots and lots and ... of text" + [99]=> + string(53) "99 test 4 Hello, world! Lots and lots and ... of text" +} +===DONE=== diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt new file mode 100644 index 0000000..fe96e6e --- /dev/null +++ b/ext/oci8/tests/debug.phpt @@ -0,0 +1,25 @@ +--TEST-- +oci_internal_debug() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/details.inc"); + +oci_internal_debug(true); + +if (!empty($dbase)) { + oci_connect($user, $password, $dbase); +} +else { + oci_connect($user, $password); +} + +echo "Done\n"; + +oci_internal_debug(false); + +?> +--EXPECTREGEX-- +^OCI8 DEBUG: .*Done$ diff --git a/ext/oci8/tests/default_prefetch.phpt b/ext/oci8/tests/default_prefetch.phpt new file mode 100644 index 0000000..cc70c6e --- /dev/null +++ b/ext/oci8/tests/default_prefetch.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=20 +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table default_prefetch_tab", + "create table default_prefetch_tab (id number, value number)", + "insert into default_prefetch_tab (id, value) values (1,1)", + "insert into default_prefetch_tab (id, value) values (1,1)", + "insert into default_prefetch_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from default_prefetch_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +// Cleanup + +$stmtarray = array( + "drop table default_prefetch_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/default_prefetch0.phpt b/ext/oci8/tests/default_prefetch0.phpt new file mode 100644 index 0000000..cc70c6e --- /dev/null +++ b/ext/oci8/tests/default_prefetch0.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=20 +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table default_prefetch_tab", + "create table default_prefetch_tab (id number, value number)", + "insert into default_prefetch_tab (id, value) values (1,1)", + "insert into default_prefetch_tab (id, value) values (1,1)", + "insert into default_prefetch_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from default_prefetch_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +// Cleanup + +$stmtarray = array( + "drop table default_prefetch_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/default_prefetch1.phpt b/ext/oci8/tests/default_prefetch1.phpt new file mode 100644 index 0000000..bc78829 --- /dev/null +++ b/ext/oci8/tests/default_prefetch1.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=100 +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table default_prefetch1_tab", + "create table default_prefetch1_tab (id number, value number)", + "insert into default_prefetch1_tab (id, value) values (1,1)", + "insert into default_prefetch1_tab (id, value) values (1,1)", + "insert into default_prefetch1_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from default_prefetch1_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); +var_dump(oci_num_rows($s)); + + +// Cleanup + +$stmtarray = array( + "drop table default_prefetch1_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/default_prefetch2.phpt b/ext/oci8/tests/default_prefetch2.phpt new file mode 100644 index 0000000..d8a76db --- /dev/null +++ b/ext/oci8/tests/default_prefetch2.phpt @@ -0,0 +1,55 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=100 +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table default_prefetch2_tab", + "create table default_prefetch2_tab (id number, value number)", + "insert into default_prefetch2_tab (id, value) values (1,1)", + "insert into default_prefetch2_tab (id, value) values (1,1)", + "insert into default_prefetch2_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from default_prefetch2_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +var_dump(oci_set_prefetch($s, 10)); + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); +var_dump(oci_num_rows($s)); + +// Cleanup + +$stmtarray = array( + "drop table default_prefetch2_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt new file mode 100644 index 0000000..c6ce7bd --- /dev/null +++ b/ext/oci8/tests/define.phpt @@ -0,0 +1,48 @@ +--TEST-- +oci_define_by_name() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table define_tab", + "create table define_tab (string varchar(10))", + "insert into define_tab (string) values ('some')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$stmt = oci_parse($c, "select string from define_tab"); + +/* the define MUST be done BEFORE ociexecute! */ + +$string = ''; +oci_define_by_name($stmt, "STRING", $string, 20); + +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($string); +} + +// Cleanup + +$stmtarray = array( + "drop table define_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +%unicode|string%(%d) "some" +Done diff --git a/ext/oci8/tests/define0.phpt b/ext/oci8/tests/define0.phpt new file mode 100644 index 0000000..f2f06e3 --- /dev/null +++ b/ext/oci8/tests/define0.phpt @@ -0,0 +1,61 @@ +--TEST-- +oci_define_by_name() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table define0_tab", + "create table define0_tab (string varchar(10))", + "insert into define0_tab (string) values ('some')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$stmt = oci_parse($c, "select string from define0_tab"); + +/* the define MUST be done BEFORE ociexecute! */ + +echo "Test 1\n"; + +$string = ''; +oci_define_by_name($stmt, "STRING", $string, 20); +oci_execute($stmt); +while (oci_fetch($stmt)) { + var_dump($string); +} + +echo "Test 2\n"; + +$string = ''; +$s2 = oci_parse($c, 'select string from define0_tab'); +oci_define_by_name($s2, 'STRING', $string); +oci_execute($s2); +while (oci_fetch($s2)) { + var_dump($string); +} + +// Cleanup + +$stmtarray = array( + "drop table define0_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +string(%d) "some" +Test 2 +string(%d) "some" +===DONE=== diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt new file mode 100644 index 0000000..6e4b74e --- /dev/null +++ b/ext/oci8/tests/define1.phpt @@ -0,0 +1,59 @@ +--TEST-- +oci_define_by_name() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table define1_tab", + "create table define1_tab (string varchar(10))", + "insert into define1_tab (string) values ('some')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$stmt = oci_parse($c, "select string from define1_tab"); + +/* the define MUST be done BEFORE ociexecute! */ + +$string = ''; +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); +} + +// Cleanup + +$stmtarray = array( + "drop table define1_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +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 +%unicode|string%(4) "some" +Done diff --git a/ext/oci8/tests/define2.phpt b/ext/oci8/tests/define2.phpt new file mode 100644 index 0000000..c53bebd --- /dev/null +++ b/ext/oci8/tests/define2.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test oci_define_by_name types +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop table phptestrawtable", + "create table phptestrawtable( id number(10), fileimage raw(1000))" +); + +oci8_test_sql_execute($c, $stmtarray); + +$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"; +} + +// Cleanup + +$stmtarray = array( + "drop table phptestrawtable" +); + +oci8_test_sql_execute($c, $stmtarray); + +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 0000000..77714a9 --- /dev/null +++ b/ext/oci8/tests/define3.phpt @@ -0,0 +1,115 @@ +--TEST-- +Test oci_define_by_name() LOB descriptor +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop table phpdefblobtable", + "create table phpdefblobtable (id number(10), fileimage blob)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// 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"; +} + +$stmtarray = array( + "drop table phpdefblobtable" +); + +oci8_test_sql_execute($c, $stmtarray); + +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 0000000..266fd7e --- /dev/null +++ b/ext/oci8/tests/define4.phpt @@ -0,0 +1,74 @@ +--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"); + +// Initialize + +$stmtarray = array( + "drop table define4_tab", + "create table define4_tab (value number, string varchar(10))", + "insert into define4_tab (value, string) values (1234, 'some')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$stmt = oci_parse($c, "select value, string from define4_tab"); + +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')); + +// Cleanup + +$stmtarray = array( + "drop table define4_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +bool(true) +Test 2 +%unicode|string%(4) "1234" +%unicode|string%(4) "some" +%unicode|string%(4) "some" +%unicode|string%(4) "some" +%unicode|string%(4) "1234" +%unicode|string%(4) "some" +Test 3 +bool(true) +%unicode|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 0000000..68fa01d --- /dev/null +++ b/ext/oci8/tests/define5.phpt @@ -0,0 +1,72 @@ +--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"); + +// Initialize + +$stmtarray = array( + "drop table define5_tab", + "create table define5_tab (id number, string varchar(10))", + "insert into define5_tab (id, string) values (1, 'some')", + "insert into define5_tab (id, string) values (2, 'thing')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +echo "Test 1 - must do define before execute\n"; +$stmt = oci_parse($c, "select string from define5_tab 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 define5_tab 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 define5_tab where id = 2"); +oci_execute($stmt); +while (oci_fetch($stmt)) { + var_dump($string); // not updated with new value + var_dump(oci_result($stmt, 'STRING')); +} + +// Cleanup + +$stmtarray = array( + "drop table define5_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 - must do define before execute +bool(true) +NULL +%unicode|string%(4) "some" +Test 2 - normal define order +bool(true) +%unicode|string%(4) "some" +Test 3 - no new define done +%unicode|string%(4) "some" +%unicode|string%(5) "thing" +Done + diff --git a/ext/oci8/tests/define6.phpt b/ext/oci8/tests/define6.phpt new file mode 100644 index 0000000..50e23ec --- /dev/null +++ b/ext/oci8/tests/define6.phpt @@ -0,0 +1,138 @@ +--TEST-- +oci_define_by_name tests with REF CURSORs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table define6_tab", + "create table define6_tab (id number)", + "insert into define6_tab values (1)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$sql = +"DECLARE + TYPE curtype IS REF CURSOR; + cursor_var curtype; +BEGIN + OPEN cursor_var FOR SELECT id FROM define6_tab; + :curs := cursor_var; +END;"; + +echo "Test 1 - define last\n"; + +$s1 = oci_parse($c, $sql); +$cursor1 = oci_new_cursor($c); +oci_bind_by_name($s1, ":curs", $cursor1, -1, OCI_B_CURSOR); +oci_execute($s1); +oci_execute($cursor1); +oci_define_by_name($cursor1, 'ID', $id1); +while (oci_fetch_row($cursor1)) { + var_dump($id1); +} + + +echo "Test 2 - define last with preset var\n"; + +$s2 = oci_parse($c, $sql); +$cursor2 = oci_new_cursor($c); +oci_bind_by_name($s2, ":curs", $cursor2, -1, OCI_B_CURSOR); +oci_execute($s2); +oci_execute($cursor2); +$id2 = ''; +oci_define_by_name($cursor2, 'ID', $id2); +while (oci_fetch_row($cursor2)) { + var_dump($id2); +} + + +echo "Test 3 - define before cursor execute\n"; + +$s3 = oci_parse($c, $sql); +$cursor3 = oci_new_cursor($c); +oci_bind_by_name($s3, ":curs", $cursor3, -1, OCI_B_CURSOR); +oci_execute($s3); +oci_define_by_name($cursor3, 'ID', $id3); +oci_execute($cursor3); +while (oci_fetch_row($cursor3)) { + var_dump($id3); +} + + +echo "Test 4 - define before top level execute\n"; + +$s4 = oci_parse($c, $sql); +$cursor4 = oci_new_cursor($c); +oci_bind_by_name($s4, ":curs", $cursor4, -1, OCI_B_CURSOR); +oci_define_by_name($cursor4, 'ID', $id4); +oci_execute($s4); +oci_execute($cursor4); +while (oci_fetch_row($cursor4)) { + var_dump($id4); +} + + +echo "Test 5 - define before bind\n"; + +$s5 = oci_parse($c, $sql); +$cursor5 = oci_new_cursor($c); +oci_define_by_name($cursor5, 'ID', $id5); +oci_bind_by_name($s5, ":curs", $cursor5, -1, OCI_B_CURSOR); +oci_execute($s5); +oci_execute($cursor5); +while (oci_fetch_row($cursor5)) { + var_dump($id5); +} + + +echo "Test 6 - fetch on wrong handle\n"; + +$s6 = oci_parse($c, $sql); +$cursor6 = oci_new_cursor($c); +oci_define_by_name($cursor6, 'ID', $id6); +oci_bind_by_name($s6, ":curs", $cursor6, -1, OCI_B_CURSOR); +oci_execute($s6); +oci_execute($cursor6); +while (oci_fetch_row($s6)) { + var_dump($id6); +} + + +// Clean up + +$stmtarray = array( + "drop table define6_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - define last +NULL +Test 2 - define last with preset var +string(0) "" +Test 3 - define before cursor execute +string(1) "1" +Test 4 - define before top level execute +string(1) "1" +Test 5 - define before bind +string(1) "1" +Test 6 - fetch on wrong handle + +Warning: oci_fetch_row(): ORA-24374: %s in %sdefine6.php on line %d +===DONE=== diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt new file mode 100644 index 0000000..f65e6b8 --- /dev/null +++ b/ext/oci8/tests/define_old.phpt @@ -0,0 +1,48 @@ +--TEST-- +ocidefinebyname() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table define_old_tab", + "create table define_old_tab (string varchar(10))", + "insert into define_old_tab (string) values ('some')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run test + +$stmt = ociparse($c, "select string from define_old_tab"); + +/* the define MUST be done BEFORE ociexecute! */ + +$string = ''; +ocidefinebyname($stmt, "STRING", $string, 20); + +ociexecute($stmt); + +while (ocifetch($stmt)) { + var_dump($string); +} + +// Cleanup + +$stmtarray = array( + "drop table define_old_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +%unicode|string%(4) "some" +Done diff --git a/ext/oci8/tests/descriptors.phpt b/ext/oci8/tests/descriptors.phpt new file mode 100644 index 0000000..9193fdd --- /dev/null +++ b/ext/oci8/tests/descriptors.phpt @@ -0,0 +1,52 @@ +--TEST-- +commit connection after destroying the descriptor +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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); + +unset($blob); +unset($statement); + +oci_commit($c); + +$ora_sql = "SELECT blob FROM ".$schema.$table_name." "; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement, OCI_DEFAULT); + +var_dump($row = oci_fetch_assoc($statement)); +unset($row['BLOB']); + +oci_commit($c); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +array(1) { + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +Done diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc new file mode 100644 index 0000000..9a86c46 --- /dev/null +++ b/ext/oci8/tests/details.inc @@ -0,0 +1,78 @@ +<?php + +/* + * Please change $user, $password and $dbase to match your configuration. + * + * Set $test_drcp to TRUE if you want to run the Oracle Database + * Resident Connection Pooling (DRCP) tests. For these tests to run + * successfully, you need a server and client which is Oracle 11g or + * greater, and $dbase should be set to the tnsnames.ora entry + * corresponding to the POOLED server instance or an Easy Connect + * string like hostname:port/service_name:POOLED + */ + +if (file_exists(dirname(__FILE__)."/details_local.inc")) { + include(dirname(__FILE__)."/details_local.inc"); // this file is not part of the source distribution; make it your own local variant of details.inc +} else { + if (false !== getenv('PHP_OCI8_TEST_DB')) { + $user = getenv('PHP_OCI8_TEST_USER'); // Database username for tests + $password = getenv('PHP_OCI8_TEST_PASS'); // Password for $user + $dbase = getenv('PHP_OCI8_TEST_DB'); // Database connection string + $test_drcp = getenv('PHP_OCI8_TEST_DRCP'); + if (false !== $test_drcp && 0 == strcasecmp($test_drcp,'TRUE')) { + $test_drcp = TRUE; + } else { + $test_drcp = FALSE; + } + } else { + $user = "system"; + $password = "oracle"; + $dbase = "localhost/XE"; + $test_drcp = FALSE; + } + + /* + * Common object names for scripts to use + */ + + $table_name = "tb".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5); + $type_name = strtoupper("tp".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5)); + $schema = ''; +} + + +/* + * Used for creating/dropping schema objects used by a test + */ + +if (!function_exists('oci8_test_sql_execute')) { + function oci8_test_sql_execute($c, $stmtarray) + { + foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + if (!$s) { + $m = oci_error($c); + echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + } + else { + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + if (!in_array($m['code'], array( // ignore expected errors + 942 // table or view does not exist + , 1918 // user does not exist + , 2024 // database link not found + , 2289 // sequence does not exist + , 4080 // trigger does not exist + , 38802 // edition does not exist + ))) { + echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + } + } + } + } + } + +} + +?> diff --git a/ext/oci8/tests/drcp_cclass1.phpt b/ext/oci8/tests/drcp_cclass1.phpt new file mode 100644 index 0000000..068331e --- /dev/null +++ b/ext/oci8/tests/drcp_cclass1.phpt @@ -0,0 +1,80 @@ +--TEST-- +DRCP: Test setting connection class inline +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +require(dirname(__FILE__)."/details.inc"); +if (!$test_drcp) die("skip testing DRCP connection class only works in DRCP mode"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/details.inc"); + +// Initialization + +$t = time(); +$cc1 = 'cc1_'.$t; +$cc2 = 'cc2_'.$t; + +// Run Test + +echo "Test 1\n"; + +ini_set('oci8.connection_class', $cc1); +$c = oci_pconnect($user, $password, $dbase); +$s = oci_parse($c, "select * from dual"); +oci_execute($s); +oci_fetch_all($s, $r); +var_dump($r); + +echo "Test 2\n"; + +ini_set('oci8.connection_class', $cc2); +$c = oci_pconnect($user, $password, $dbase); +$s = oci_parse($c, "select * from dual"); +oci_execute($s); +oci_fetch_all($s, $r); +var_dump($r); + +echo "Test 3\n"; + +$s = oci_parse($c, "select cclass_name from v\$cpool_cc_stats where cclass_name like '%.cc__$t' order by cclass_name"); +oci_execute($s); +oci_fetch_all($s, $r); +var_dump($r); + +// Cleanup + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +array(1) { + ["DUMMY"]=> + array(1) { + [0]=> + string(1) "X" + } +} +Test 2 +array(1) { + ["DUMMY"]=> + array(1) { + [0]=> + string(1) "X" + } +} +Test 3 +array(1) { + ["CCLASS_NAME"]=> + array(2) { + [0]=> + string(21) "%s.cc1_%d" + [1]=> + string(21) "%s.cc2_%d" + } +} +Done diff --git a/ext/oci8/tests/drcp_characterset.phpt b/ext/oci8/tests/drcp_characterset.phpt new file mode 100644 index 0000000..657d4c5 --- /dev/null +++ b/ext/oci8/tests/drcp_characterset.phpt @@ -0,0 +1,61 @@ +--TEST-- +DRCP: oci_pconnect() and oci_connect() with different character sets +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Create connections with oci_connect and oci_pconnect with UTF8 as Charset + +$c1 = oci_connect($user,$password,$dbase,"UTF8"); +var_dump($c1); + +// Now with oci_pconnect() + +$p1 = oci_pconnect($user,$password,$dbase,"UTF8"); +var_dump($p1); + +// Create two more connections with character set US7ASCII + +$c2 = oci_connect($user,$password,$dbase,"US7ASCII"); +var_dump($c2); + +// Now with oci_pconnect() + +$p2 = oci_pconnect($user,$password,$dbase,"US7ASCII"); +var_dump($p2); + +// The two connections c1 and c2 should not share resources as they use different +//character sets + +if((int)$c1 === (int)$c2) + echo "First and third connections share a resource: NOT OK\n"; +else + echo "First and third connections are different: OK\n"; + +// The two connections p1 and p2 should not share resources as they use different +//character sets + +if((int)$p1 === (int)$p2) + echo "Second and fourth connections share a resource: NOT OK\n"; +else + echo "Second and fourth connections are different: OK\n"; + +// Close all the connections +oci_close($c1); +oci_close($c2); +oci_close($p1); +oci_close($p2); + +echo "Done\n"; +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 persistent connection) +First and third connections are different: OK +Second and fourth connections are different: OK +Done diff --git a/ext/oci8/tests/drcp_conn_close1.phpt b/ext/oci8/tests/drcp_conn_close1.phpt new file mode 100644 index 0000000..697b7e3 --- /dev/null +++ b/ext/oci8/tests/drcp_conn_close1.phpt @@ -0,0 +1,45 @@ +--TEST-- +DRCP: oci_connect() with oci_close() and oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a connection +// Close the connection +// Open another connection +// With oci_close() being a no-op, the same conneciton will be returned + + +echo "This is with a OCI_CONNECT\n"; +var_dump($conn1 = oci_connect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection + +var_dump($conn2 = oci_connect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : OK \n"; +else + echo "Both connections are different : NOT OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Both connections share a resource : OK +Done diff --git a/ext/oci8/tests/drcp_conn_close2.phpt b/ext/oci8/tests/drcp_conn_close2.phpt new file mode 100644 index 0000000..0d3f824 --- /dev/null +++ b/ext/oci8/tests/drcp_conn_close2.phpt @@ -0,0 +1,46 @@ +--TEST-- +DRCP: oci_connect() with oci_close() and oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a connection +// Close the connection +// Open another connection +// With oci_close() the connection is released to the pool and hence the +// the second conneciton will be different + + +// OCI_CONNECT +echo "This is with a OCI_CONNECT\n"; +var_dump($conn1 = oci_connect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection +var_dump($conn2 = oci_connect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : NOT OK \n"; +else + echo "Both connections are different : OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Both connections are different : OK +Done diff --git a/ext/oci8/tests/drcp_connect1.phpt b/ext/oci8/tests/drcp_connect1.phpt new file mode 100644 index 0000000..25395dc --- /dev/null +++ b/ext/oci8/tests/drcp_connect1.phpt @@ -0,0 +1,100 @@ +--TEST-- +DRCP: oci_connect() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs (Calling PL/SQL from SQL is not supported in TimesTen) +require(dirname(__FILE__).'/skipif.inc'); +?> +--INI-- +oci8.connection_class=test +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; +require dirname(__FILE__)."/drcp_functions.inc"; + +// Open a number of connections with oci_connect and oci_pconnect and verify +// whether we get a used session with DRCP. +// To verify this, we change the value of a PL/SQL package variable in one +// session and query for this through another connection + +echo "Test 1a\n"; +var_dump($conn1 = oci_connect($user,$password,$dbase)); +// Create the package +drcp_create_package($conn1); + +echo "Test 1b\n"; +// OCI_CONNECT +echo " This is with OCI_CONNECT.....\n"; +drcp_select_packagevar($conn1); // Returns 0 +drcp_set_packagevar($conn1,1000); +oci_close($conn1); +echo " Connection conn1 closed....\n"; + +echo "Test 2\n"; +// Second connection should return 0 for the package variable. +var_dump($conn2 = oci_connect($user,$password,$dbase)); +echo " Select with connection 2 \n"; +drcp_select_packagevar($conn2); // Returns 0 +drcp_set_packagevar($conn2,100); + +echo "Test 3\n"; +// Third connection. There is no oci_close() for conn2 hence this should +// return the value set by conn2. +var_dump($conn3 = oci_connect($user,$password,$dbase)); +echo " Select with connection 3 \n"; +drcp_select_packagevar($conn3); // Returns 100 + +// Close all the connections +oci_close($conn2); +oci_close($conn3); + +echo "Test 4\n"; +// OCI_PCONNECT +echo " This is with oci_pconnect().....\n"; +var_dump($pconn1 = oci_pconnect($user,$password,$dbase)); +drcp_set_packagevar($pconn1,1000); +oci_close($pconn1); +echo " Connection pconn1 closed....\n"; + +// Second connection with oci_pconnect should return the same session hence the +// value returned is what is set by pconn1 + +echo "Test 5\n"; +var_dump($pconn2 = oci_pconnect($user,$password,$dbase)); +echo " Select with persistent connection 2 \n"; +drcp_select_packagevar($pconn2); // Returns 1000 +oci_close($pconn2); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1a +resource(%d) of type (oci8 connection) +Test 1b + This is with OCI_CONNECT..... + The value of the package variable is 0 + Package variable value set to 1000 + Connection conn1 closed.... +Test 2 +resource(%d) of type (oci8 connection) + Select with connection 2 + The value of the package variable is 0 + Package variable value set to 100 +Test 3 +resource(%d) of type (oci8 connection) + Select with connection 3 + The value of the package variable is 100 +Test 4 + This is with oci_pconnect()..... +resource(%d) of type (oci8 persistent connection) + Package variable value set to 1000 + Connection pconn1 closed.... +Test 5 +resource(%d) of type (oci8 persistent connection) + Select with persistent connection 2 + The value of the package variable is 1000 +Done + diff --git a/ext/oci8/tests/drcp_connection_class.phpt b/ext/oci8/tests/drcp_connection_class.phpt new file mode 100644 index 0000000..2aed131 --- /dev/null +++ b/ext/oci8/tests/drcp_connection_class.phpt @@ -0,0 +1,24 @@ +--TEST-- +DRCP: oci8.connection_class with ini_get() and ini_set() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.connection_class=test +--FILE-- +<?php + +echo "Setting a new connection class now\n"; +ini_set('oci8.connection_class',"New cc"); + +// Get the New connection class name .Should return New CC + +$new_cc = ini_get('oci8.connection_class'); +echo "The New oci8.connection_class is $new_cc \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +Setting a new connection class now +The New oci8.connection_class is New cc +Done diff --git a/ext/oci8/tests/drcp_functions.inc b/ext/oci8/tests/drcp_functions.inc new file mode 100644 index 0000000..f6b2444 --- /dev/null +++ b/ext/oci8/tests/drcp_functions.inc @@ -0,0 +1,93 @@ +<?php + +/* This file contains functions required by the DRCP tests */ + +function drcp_create_table($conn) +{ + $create_sql = "CREATE TABLE DRCPTEST (id NUMBER, name VARCHAR2(10), dept VARCHAR2(10))"; + $statement = oci_parse($conn, $create_sql); + oci_execute($statement); + + $id_values = array(100,101,102,103,104,105,106,107,108); + $name_values = array("WIILIAMS","JOHN","SMITH","JONES","ADAMS","ROBERT", + "BILL","LAWSON","MARY"); + $dept_values = array("ACCOUNTS","HR","HR","ADMIN","ACCOUNTS","HR", + "ACCOUNTS","HR","ACCOUNTS"); + for($i=0; $i<8; $i++) { + $insert = "INSERT INTO DRCPTEST VALUES(".$id_values[$i].",'". $name_values[$i]."','".$dept_values[$i]."')"; + $s = oci_parse($conn, $insert); + oci_execute($s); + } +} + +function drcp_drop_table($conn) +{ + $ora_sql = "DROP TABLE DRCPTEST"; + $statement = oci_parse($conn, $ora_sql); + oci_execute($statement); +} + +function drcp_update_table($conn) +{ + $update_stmt ="Update drcptest set dept ='NEWDEPT' where id = 105"; + $s1 = oci_parse($conn,$update_stmt); + oci_execute($s1,OCI_DEFAULT); + echo "Update done-- DEPT value has been set to NEWDEPT\n"; +} + +function drcp_select_value($conn) +{ + $sel_stmt="select dept from drcptest where id=105"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while(oci_fetch($s2)) { + echo "The value of DEPT for id 105 is ".oci_result($s2,1)."\n"; + } +} + +function drcp_select_packagevar($conn) +{ + $sel_stmt="select drcp_test_package.f1 as f1 from dual"; + $s2 = oci_parse($conn, $sel_stmt); + oci_define_by_name($s2,'f1',$ret_num); + oci_execute($s2); + while(oci_fetch($s2)) { + echo " The value of the package variable is ".oci_result($s2,1)."\n"; + } +} + + +function drcp_set_packagevar($conn,$num) +{ + $set_stmt = "begin drcp_test_package.p1($num); end;"; + $s1 = oci_parse($conn,$set_stmt); + oci_execute($s1); + echo " Package variable value set to " .$num."\n"; +} + +function drcp_create_package($c) +{ + $create_package_stmt = "create or replace package drcp_test_package as + var int :=0; + procedure p1(var1 int); + function f1 return number; + end;"; + $s1 = oci_parse($c, $create_package_stmt); + oci_execute($s1); + + $package_body = "create or replace package body drcp_test_package as + procedure p1(var1 int) is + begin + var :=var1; + end; + function f1 return number is + begin + return drcp_test_package.var; + end; + end;"; + + $s2 = oci_parse($c, $package_body); + oci_execute($s2); +} + +?> diff --git a/ext/oci8/tests/drcp_newconnect.phpt b/ext/oci8/tests/drcp_newconnect.phpt new file mode 100644 index 0000000..79718f4 --- /dev/null +++ b/ext/oci8/tests/drcp_newconnect.phpt @@ -0,0 +1,43 @@ +--TEST-- +DRCP: oci_new_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.connection_class=test +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Open two connections with oci_new_connect +// Verify they are different by comparing the resource ids + +var_dump($c1 = oci_new_connect($user,$password,$dbase)); +$rn1 = (int)$c1; + +// Another connection now + +var_dump($c2 = oci_new_connect($user,$password,$dbase)); +$rn2 = (int)$c2; + +// rn1 and rn2 should be different. + +if ($rn1 === $rn2) + echo "First and second connections share a resource: Not OK\n"; +else + echo "First and second connections are different OK\n"; + +// Close the connections +oci_close($c1); +oci_close($c2); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +First and second connections are different OK +Done + diff --git a/ext/oci8/tests/drcp_pconn_close1.phpt b/ext/oci8/tests/drcp_pconn_close1.phpt new file mode 100644 index 0000000..a9b912b --- /dev/null +++ b/ext/oci8/tests/drcp_pconn_close1.phpt @@ -0,0 +1,44 @@ +--TEST-- +DRCP: oci_pconnect() with oci_close() and oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a persistent connection +// Close the connection +// Open another connection +// With oci_close() being a no-op, the same conneciton will be returned + +echo "This is with a OCI_PCONNECT\n"; +var_dump($conn1 = oci_pconnect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection + +var_dump($conn2 = oci_pconnect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : OK \n"; +else + echo "Both connections are different : NOT OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +Both connections share a resource : OK +Done diff --git a/ext/oci8/tests/drcp_pconn_close2.phpt b/ext/oci8/tests/drcp_pconn_close2.phpt new file mode 100644 index 0000000..5fd2c23 --- /dev/null +++ b/ext/oci8/tests/drcp_pconn_close2.phpt @@ -0,0 +1,46 @@ +--TEST-- +DRCP: oci_pconnect() with oci_close() and oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a persistent connection +// Close the connection +// Open another connection +// With oci_close() the connection is released to the pool and hence the +// the second connection will be different + + +echo "This is with a OCI_PCONNECT\n"; +var_dump($conn1 = oci_pconnect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Query for the row updated. The new value should be returned + +var_dump($conn2 = oci_pconnect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : NOT OK \n"; +else + echo "Both connections are different : OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +Both connections are different : OK +Done diff --git a/ext/oci8/tests/drcp_privileged.phpt b/ext/oci8/tests/drcp_privileged.phpt new file mode 100644 index 0000000..da8702e --- /dev/null +++ b/ext/oci8/tests/drcp_privileged.phpt @@ -0,0 +1,53 @@ +--TEST-- +DRCP: privileged connect +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/details.inc"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) { + // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP + die("skip this test is unlikely to work with a remote database - unless an Oracle password file has been created"); +} +?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +// Connecting as SYSDBA or SYSOPER through DRCP will give ORA-1031 + +require dirname(__FILE__)."/details.inc"; +var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSOPER)); +var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSOPER)); +var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSOPER)); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_connect(): ORA-01031: %s in %s on line %d +bool(false) + +Warning: oci_connect(): ORA-01031: %s in %s on line %d +bool(false) + +Warning: oci_new_connect(): ORA-01031: %s in %s on line %d +bool(false) + +Warning: oci_new_connect(): ORA-01031: %s in %s on line %d +bool(false) + +Warning: oci_pconnect(): ORA-01031: %s in %s on line %d +bool(false) + +Warning: oci_pconnect(): ORA-01031: %s in %s on line %d +bool(false) +Done + diff --git a/ext/oci8/tests/drcp_scope1.phpt b/ext/oci8/tests/drcp_scope1.phpt new file mode 100644 index 0000000..57f1abe --- /dev/null +++ b/ext/oci8/tests/drcp_scope1.phpt @@ -0,0 +1,92 @@ +--TEST-- +DRCP: oci_new_connect() and oci_connect() with scope end when oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require dirname(__FILE__)."/drcp_functions.inc"; +require dirname(__FILE__)."/details.inc"; + +// Scope considered here is the functional scope +// Test will open a connection within a function (function 1). +// Update a table +// Open another connection from function 2. +// When the scope ends the txn is rolled back and hence the updated value +// will not be reflected for oci_connect and oci_new_connect. + +// Create the table +$c = oci_new_connect($user,$password,$dbase); +@drcp_drop_table($c); +drcp_create_table($c); + +// OCI_NEW_CONNECT +$conn_type = 1; +echo "This is with a OCI_NEW_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +// OCI_CONNECT +$conn_type = 2; +echo "\n\nThis is with a OCI_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +//This is the first scope for the script + +function function1($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); +} + +// This is the second scope + +function function2($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); +} + +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_NEW_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR + + +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR +Done diff --git a/ext/oci8/tests/drcp_scope2.phpt b/ext/oci8/tests/drcp_scope2.phpt new file mode 100644 index 0000000..b72e00d --- /dev/null +++ b/ext/oci8/tests/drcp_scope2.phpt @@ -0,0 +1,91 @@ +--TEST-- +DRCP: oci_new_connect() and oci_connect with scope end when oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/drcp_functions.inc"; +require dirname(__FILE__)."/details.inc"; + +// Scope considered here is the functional scope +// Test will open a connection within a function (function 1). +// Update a table +// Open another connection from function 2. +// When the scope ends the txn is rolled back and hence the updated value +// will not be reflected for oci_connect and oci_new_connect. + +// Create the table +$c = oci_new_connect($user,$password,$dbase); +@drcp_drop_table($c); +drcp_create_table($c); + +// OCI_NEW_CONNECT +$conn_type = 1; +echo "This is with a OCI_NEW_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +// OCI_CONNECT +$conn_type = 2; +echo "\n\nThis is with a OCI_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +//This is the first scope for the script + +function function1($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); +} + +// This is the second scope + +function function2($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); +} +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_NEW_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR + + +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR +Done diff --git a/ext/oci8/tests/drcp_scope3.phpt b/ext/oci8/tests/drcp_scope3.phpt new file mode 100644 index 0000000..b448a51 --- /dev/null +++ b/ext/oci8/tests/drcp_scope3.phpt @@ -0,0 +1,61 @@ +--TEST-- +DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require dirname(__FILE__)."/drcp_functions.inc"; +require dirname(__FILE__)."/details.inc"; + +// The test opens a connection within function1 and updates a table +// (without committing). Another connection is opened from function +// 2, and the table queried. When function1 ends, the connection from +// function1 is not closed, so the updated value will be seen in +// function2. Also the table can't be dropped because an uncommitted +// transaction exists. + +// Create the table +$c = oci_new_connect($user,$password,$dbase); +@drcp_drop_table($c); +drcp_create_table($c); + +echo "This is with a OCI_PCONNECT\n"; +function1($user,$password,$dbase); + +// Should return the OLD value +function2($user,$password,$dbase); + +// This is the first scope for the script + +function function1($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); +} + +// This is the second scope + +function function2($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); +} + +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 persistent connection) +The value of DEPT for id 105 is NEWDEPT + +Warning: oci_execute(): ORA-00054: %s +Done
\ No newline at end of file diff --git a/ext/oci8/tests/drcp_scope4.phpt b/ext/oci8/tests/drcp_scope4.phpt new file mode 100644 index 0000000..87eaf0c --- /dev/null +++ b/ext/oci8/tests/drcp_scope4.phpt @@ -0,0 +1,62 @@ +--TEST-- +DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/drcp_functions.inc"; +require dirname(__FILE__)."/details.inc"; + +// The default expected behavior of this test is different between PHP +// 5.2 and PHP 5.3 +// +// In PHP 5.3, the test opens a connection within function1 and +// updates a table (without committing). Another connection is opened +// from function 2, and the table queried. When function1 ends, the +// txn is rolled back and hence the updated value will not be +// reflected in function2. Use oci8.old_oci_close_semantics=1 to +// get old behavior + +// Create the table +$c = oci_new_connect($user,$password,$dbase); +@drcp_drop_table($c); +drcp_create_table($c); + +echo "This is with a OCI_PCONNECT\n"; +function1($user,$password,$dbase); + +// Should return the OLD value +function2($user,$password,$dbase); + +// This is the first scope for the script + +function function1($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); +} + +// This is the second scope + +function function2($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); +} + +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 persistent connection) +The value of DEPT for id 105 is HR +Done diff --git a/ext/oci8/tests/drcp_scope5.phpt b/ext/oci8/tests/drcp_scope5.phpt new file mode 100644 index 0000000..832e6aa --- /dev/null +++ b/ext/oci8/tests/drcp_scope5.phpt @@ -0,0 +1,63 @@ +--TEST-- +DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require dirname(__FILE__)."/drcp_functions.inc"; +require dirname(__FILE__)."/details.inc"; + +// Similar to drcp_scope3.phpt but does a commit before end of +// function2, allowing the table to be dropped cleanly at the end. + +// The test opens a connection within function1 and updates a table +// (without committing). Another connection is opened from function +// 2, and the table queried. When function1 ends, the connection from +// function1 is not closed, so the updated value will be seen in +// function2. Also the table can't be dropped because an uncommitted +// transaction exists. + +// Create the table +$c = oci_new_connect($user,$password,$dbase); +@drcp_drop_table($c); +drcp_create_table($c); + +echo "This is with a OCI_PCONNECT\n"; +function1($user,$password,$dbase); + +// Should return the OLD value +function2($user,$password,$dbase); + +// This is the first scope for the script + +function function1($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); +} + +// This is the second scope + +function function2($user,$password,$dbase) +{ + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); + oci_commit($c); +} + +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 persistent connection) +The value of DEPT for id 105 is NEWDEPT +Done
\ No newline at end of file diff --git a/ext/oci8/tests/driver_name.phpt b/ext/oci8/tests/driver_name.phpt new file mode 100644 index 0000000..bf86e66 --- /dev/null +++ b/ext/oci8/tests/driver_name.phpt @@ -0,0 +1,61 @@ +--TEST-- +Verify that the Driver Name attribute is set +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); + +require(dirname(__FILE__)."/connect.inc"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip as Output might vary with DRCP"); + +if (preg_match('/Release (11\.2|12)/', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR2 or greater databases"); +} else if (preg_match('/^(11\.2|12\.)/', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11g or greater version of client"); +} + +?> +--FILE-- +<?php +require(dirname(__FILE__)."/connect.inc"); + +echo"**Test 1.1 - Default values for the attribute **************\n"; +get_attr($c); +oci_close($c); + +echo"\n***Test 1.2 - Get the values from different connections **************\n"; +// with oci_pconnect() +echo "Testing with oci_pconnect()\n"; +$pc1=oci_pconnect($user,$password,$dbase); +get_attr($pc1); +oci_close($pc1); + +echo "Testing with oci_new_connect()\n"; +$nc1=oci_new_connect($user,$password,$dbase); +get_attr($nc1); +oci_close($nc1); +echo "Done\n"; + +function get_attr($conn) +{ + $sel_stmt = "select client_driver + from v\$session_connect_info sci, v\$session s + where sci.client_driver is not null + and sci.sid = s.sid + and s.audsid = userenv('SESSIONID')"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + oci_fetch($s2); + echo "The value of DRIVER_NAME is ".oci_result($s2,1)."\n"; +} + +?> +--EXPECT-- +**Test 1.1 - Default values for the attribute ************** +The value of DRIVER_NAME is PHP OCI8 + +***Test 1.2 - Get the values from different connections ************** +Testing with oci_pconnect() +The value of DRIVER_NAME is PHP OCI8 +Testing with oci_new_connect() +The value of DRIVER_NAME is PHP OCI8 +Done diff --git a/ext/oci8/tests/drop_table.inc b/ext/oci8/tests/drop_table.inc new file mode 100644 index 0000000..592a95a --- /dev/null +++ b/ext/oci8/tests/drop_table.inc @@ -0,0 +1,7 @@ +<?php +if ($c) { + $ora_sql = "DROP TABLE ".$schema.$table_name; + $statement = oci_parse($c,$ora_sql); + oci_execute($statement); +} +?> diff --git a/ext/oci8/tests/drop_type.inc b/ext/oci8/tests/drop_type.inc new file mode 100644 index 0000000..98542a8 --- /dev/null +++ b/ext/oci8/tests/drop_type.inc @@ -0,0 +1,7 @@ +<?php +if ($c) { + $ora_sql = "DROP TYPE ".$type_name; + $statement = oci_parse($c,$ora_sql); + oci_execute($statement); +} +?> diff --git a/ext/oci8/tests/dupcolnames.phpt b/ext/oci8/tests/dupcolnames.phpt new file mode 100644 index 0000000..bf07497 --- /dev/null +++ b/ext/oci8/tests/dupcolnames.phpt @@ -0,0 +1,102 @@ +--TEST-- +SELECT tests with duplicate column anmes +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table dupcolnames_tab1", + "drop table dupcolnames_tab2", + + "create table dupcolnames_tab1 (c1 number, dupnamecol varchar2(20))", + "create table dupcolnames_tab2 (c2 number, dupnamecol varchar2(20))", + + "insert into dupcolnames_tab1 (c1, dupnamecol) values (1, 'chris')", + "insert into dupcolnames_tab2 (c2, dupnamecol) values (2, 'jones')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - OCI_ASSOC\n"; +$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2"); +oci_execute($s); +while (($r = oci_fetch_array($s, OCI_ASSOC)) != false) { + var_dump($r); +} + + +echo "\nTest 2 - OCI_NUM\n"; +$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2"); +oci_execute($s); +while (($r = oci_fetch_array($s, OCI_NUM)) != false) { + var_dump($r); +} + + +echo "\nTest 3 - OCI_ASSOC+OCI_NUM\n"; +$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2"); +oci_execute($s); +while (($r = oci_fetch_array($s, OCI_ASSOC+OCI_NUM)) != false) { + var_dump($r); +} + +// Clean up + +$stmtarray = array( + "drop table dupcolnames_tab1", + "drop table dupcolnames_tab2", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - OCI_ASSOC +array(3) { + ["C1"]=> + string(1) "1" + ["DUPNAMECOL"]=> + string(5) "jones" + ["C2"]=> + string(1) "2" +} + +Test 2 - OCI_NUM +array(4) { + [0]=> + string(1) "1" + [1]=> + string(5) "chris" + [2]=> + string(1) "2" + [3]=> + string(5) "jones" +} + +Test 3 - OCI_ASSOC+OCI_NUM +array(7) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "chris" + ["DUPNAMECOL"]=> + string(5) "jones" + [2]=> + string(1) "2" + ["C2"]=> + string(1) "2" + [3]=> + string(5) "jones" +} +===DONE=== diff --git a/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt new file mode 100644 index 0000000..b9c8fd8 --- /dev/null +++ b/ext/oci8/tests/edition_1.phpt @@ -0,0 +1,144 @@ +--TEST-- +Basic test for setting Oracle 11gR2 "edition" attribute +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) { + die("skip needs to be run as a DBA user"); +} +if ($test_drcp) { + die("skip as Output might vary with DRCP"); +} +if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR2 or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--FILE-- +<?php + +/* In 11.2, there can only be one child edition. So this test will + * fail to create the necessary editions if a child edition exists + * already + */ + +require(dirname(__FILE__)."/conn_attr.inc"); + +function select_fn($conn) { + $s = oci_parse($conn,"select * from view_ed"); + oci_execute($s); + while ($row = oci_fetch_row($s)) { + var_dump($row); + } +} +/* Create a editon MYEDITION + create a view view_ed in MYEDITION1. + create the same view 'view_ed' with a different definition in MYEDITION. + select from both the editions and verify the contents. */ + +set_edit_attr('MYEDITION'); +$conn = oci_connect('testuser','testuser',$dbase); +if ($conn === false) { + $m = oci_error(); + die("Error:" . $m['message']); +} + +$stmtarray = array( + "drop table edit_tab", + "create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)", + "insert into edit_tab values('mike',30,'Senior engineer',200)", + "insert into edit_tab values('juan',25,'engineer',100)", + "create or replace editioning view view_ed as select name,age,job from edit_tab", +); + +oci8_test_sql_execute($conn, $stmtarray); + +// Check the current edition of the DB and the contents of view_ed. +get_edit_attr($conn); +select_fn($conn); + +// Create a different version of view_ed in MYEDITION1. +set_edit_attr('MYEDITION1'); +$conn2 = oci_new_connect('testuser','testuser',$dbase); +$stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab"; +$s = oci_parse($conn2, $stmt); +oci_execute($s); + +// Check the current edition of the DB and the contents of view_ed. +get_edit_attr($conn2); +select_fn($conn2); + +// Verify the contents in MYEDITION EDITION. +echo "version of view_ed in MYEDITION \n"; +get_edit_attr($conn); +select_fn($conn); + +clean_up($c); + +oci_close($conn); +oci_close($conn2); +echo "Done\n"; + +?> +--EXPECTF-- +The value of edition has been successfully set +The value of current EDITION is MYEDITION +array(3) { + [0]=> + %unicode|string%(%d) "mike" + [1]=> + %unicode|string%(%d) "30" + [2]=> + %unicode|string%(%d) "Senior engineer" +} +array(3) { + [0]=> + %unicode|string%(%d) "juan" + [1]=> + %unicode|string%(%d) "25" + [2]=> + %unicode|string%(%d) "engineer" +} + The value of edition has been successfully set +The value of current EDITION is MYEDITION1 +array(4) { + [0]=> + %unicode|string%(%d) "mike" + [1]=> + %unicode|string%(%d) "30" + [2]=> + %unicode|string%(%d) "Senior engineer" + [3]=> + %unicode|string%(%d) "200" +} +array(4) { + [0]=> + %unicode|string%(%d) "juan" + [1]=> + %unicode|string%(%d) "25" + [2]=> + %unicode|string%(%d) "engineer" + [3]=> + %unicode|string%(%d) "100" +} +version of view_ed in MYEDITION +The value of current EDITION is MYEDITION +array(3) { + [0]=> + %unicode|string%(%d) "mike" + [1]=> + %unicode|string%(%d) "30" + [2]=> + %unicode|string%(%d) "Senior engineer" +} +array(3) { + [0]=> + %unicode|string%(%d) "juan" + [1]=> + %unicode|string%(%d) "25" + [2]=> + %unicode|string%(%d) "engineer" +} +Done diff --git a/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt new file mode 100644 index 0000000..030e6a6 --- /dev/null +++ b/ext/oci8/tests/edition_2.phpt @@ -0,0 +1,239 @@ +--TEST-- +Set and check Oracle 11gR2 "edition" attribute +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) + die("skip needs to be run as a DBA user"); +if ($test_drcp) + die("skip as Output might vary with DRCP"); + +if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR2 or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} + +?> +--FILE-- +<?php + +/* In 11.2, there can only be one child edition. So this test will + * fail to create the necessary editions if a child edition exists + * already + */ + +require(dirname(__FILE__)."/conn_attr.inc"); + +$user = 'testuser'; +$password = 'testuser'; + +echo"**Test 1.1 - Default value for the attribute **************\n"; +get_edit_attr($c); + +echo"\n\n**Test 1.2 - Set a value and get the same with different connections *********\n"; +set_edit_attr('MYEDITION'); + +// With oci_connect, oci_pconnect, oci_new_connect +$conn1 = get_conn(1); +get_edit_attr($conn1); + +//pconnect +$conn2 = get_conn(2); +get_edit_attr($conn2); + +//new_connect +$conn3 = get_conn(3); +get_edit_attr($conn3); + +oci_close($conn1); + +// With a oci_pconnect with a different charset. +$pc1 = oci_pconnect($user,$password,$dbase,"utf8"); +get_edit_attr($pc1); +oci_close($pc1); + + +echo"\n\n**Test 1.3 change the value and verify with existing conenctions.*********\n"; +set_edit_attr('MYEDITION1'); +get_edit_attr($conn2); +get_edit_attr($conn3); // Old value +oci_close($conn2); +oci_close($conn3); + +//open a new connection and get the edition value . This will have the updated value. +$c3 = get_conn(3); //oci_new_connect() +get_edit_attr($c3); + +$c4 = get_conn(2); //oci_pconnect() +get_edit_attr($c4); + +$c5 = get_conn(1); //oci_connect() +get_edit_attr($c5); + +oci_close($c3); +oci_close($c4); +oci_close($c5); + +echo "\n\n**Test 1.4 - with different type of values *********\n"; +$values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!'); +foreach ($values_array as $val ) { + set_edit_attr($val); + $c1 = get_conn(1); //oci_connect() + if ($c1) { + get_edit_attr($c1); + oci_close($c1); + } +} + +echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n"; +$c1 = get_conn(3); +$r = set_edit_attr($c1); + +echo"\n\n**Test 1.6 - Set Multiple times.*****\n"; +set_edit_attr('MYEDITION'); +set_edit_attr('MYEDITION1'); +$c1 = get_conn(1); +get_edit_attr($c1); +oci_close($c1); + +echo "\n\n**Test 1.7 - Test with ALTER SESSION statement to change the edition *******\n"; +// Set the edition value to MYEDITION. open a conn .get the value. +// execute the alter system set edition ='MYEDITION' .get the value . +// set it back to MYEDITION using oci_set_edition. and get the value. + +set_edit_attr('MYEDITION'); +$c1 = get_conn(3); +echo "get the value set to MYEDITION with oci_set_edition \n"; +get_edit_attr($c1); + +$alter_stmt = "alter session set edition = MYEDITION1"; +$s = oci_parse($c1,$alter_stmt); +oci_execute($s); +oci_commit($c1); +echo "Get the value set to MYEDITION1 with alter session\n"; +get_edit_attr($c1); + +echo " Get the value with a new connection \n"; +$c2 = get_conn(1); +get_edit_attr($c2); + +echo " Set the value back using oci-set_edition\n"; +set_edit_attr('MYEDITION'); +get_edit_attr($c2); + +echo " Get the value with a new conenction \n"; +$c3 = get_conn(1); +get_edit_attr($c3); + +oci_close($c1); +oci_close($c2); +oci_close($c3); + + +echo "\n\n**Test 1.8 - Test setting the attribute with scope ends*******\n"; +set_scope(); +get_scope(); + +clean_up($c); +echo "Done\n"; + + +function set_scope() { + $r = set_edit_attr('MYEDITION1'); +} + +function get_scope() { + $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']); + if ($sc1 === false) { + $m = oci_error(); + die("Error:" . $m['message']); + } + get_edit_attr($sc1); + oci_close($sc1); +} +?> +--EXPECTF-- +**Test 1.1 - Default value for the attribute ************** +The value of current EDITION is ORA$BASE + + +**Test 1.2 - Set a value and get the same with different connections ********* + The value of edition has been successfully set +Testing with oci_connect() +The value of current EDITION is MYEDITION +Testing with oci_pconnect() +The value of current EDITION is MYEDITION +Testing with oci_new_connect() +The value of current EDITION is MYEDITION +The value of current EDITION is MYEDITION + + +**Test 1.3 change the value and verify with existing conenctions.********* + The value of edition has been successfully set +The value of current EDITION is MYEDITION +The value of current EDITION is MYEDITION +Testing with oci_new_connect() +The value of current EDITION is MYEDITION1 +Testing with oci_pconnect() +The value of current EDITION is MYEDITION1 +Testing with oci_connect() +The value of current EDITION is MYEDITION1 + + +**Test 1.4 - with different type of values ********* + The value of edition has been successfully set +Testing with oci_connect() + +Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d + The value of edition has been successfully set +Testing with oci_connect() +The value of current EDITION is ORA$BASE + The value of edition has been successfully set +Testing with oci_connect() + +Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d + The value of edition has been successfully set +Testing with oci_connect() + +Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d + + +**Test 1.5 - Negative case with an invalid string value. ********* +Testing with oci_new_connect() + +Warning: oci_new_connect(): ORA-38801: %s ORA_EDITION in %s on line %d + The value of edition has been successfully set + + +**Test 1.6 - Set Multiple times.***** + The value of edition has been successfully set + The value of edition has been successfully set +Testing with oci_connect() +The value of current EDITION is MYEDITION1 + + +**Test 1.7 - Test with ALTER SESSION statement to change the edition ******* + The value of edition has been successfully set +Testing with oci_new_connect() +get the value set to MYEDITION with oci_set_edition +The value of current EDITION is MYEDITION +Get the value set to MYEDITION1 with alter session +The value of current EDITION is MYEDITION1 + Get the value with a new connection +Testing with oci_connect() +The value of current EDITION is MYEDITION + Set the value back using oci-set_edition + The value of edition has been successfully set +The value of current EDITION is MYEDITION + Get the value with a new conenction +Testing with oci_connect() +The value of current EDITION is MYEDITION + + +**Test 1.8 - Test setting the attribute with scope ends******* + The value of edition has been successfully set +The value of current EDITION is MYEDITION1 +Done + diff --git a/ext/oci8/tests/error.phpt b/ext/oci8/tests/error.phpt new file mode 100644 index 0000000..7fedd0d --- /dev/null +++ b/ext/oci8/tests/error.phpt @@ -0,0 +1,43 @@ +--TEST-- +oci_error() error message for parsing error +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs: different error messages from TimesTen +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +var_dump($s = oci_parse($c, "WRONG SYNTAX")); +var_dump(oci_execute($s)); +var_dump(oci_error($s)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%s) of type (oci8 connection) +resource(%s) of type (oci8 statement) + +Warning: oci_execute(): ORA-00900: %s in %s on line %d +bool(false) +array(4) { + ["code"]=> + int(900) + ["message"]=> + string(%d) "ORA-00900: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(12) "WRONG SYNTAX" +} +Done diff --git a/ext/oci8/tests/error1.phpt b/ext/oci8/tests/error1.phpt new file mode 100644 index 0000000..c6fba2e --- /dev/null +++ b/ext/oci8/tests/error1.phpt @@ -0,0 +1,27 @@ +--TEST-- +oci_error() when oci_connect() fails +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +var_dump(oci_connect("some", "some", "some")); +var_dump(oci_error()); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_connect(): ORA-12154: %s in %s on line %d +bool(false) +array(4) { + ["code"]=> + int(12154) + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/error2.phpt b/ext/oci8/tests/error2.phpt new file mode 100644 index 0000000..48f21f4 --- /dev/null +++ b/ext/oci8/tests/error2.phpt @@ -0,0 +1,28 @@ +--TEST-- +Exercise error code for SUCCESS_WITH_INFO +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--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: %s +Done diff --git a/ext/oci8/tests/error3.phpt b/ext/oci8/tests/error3.phpt new file mode 100644 index 0000000..8540db2 --- /dev/null +++ b/ext/oci8/tests/error3.phpt @@ -0,0 +1,40 @@ +--TEST-- +Maximum Oracle error length +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +// Assume runtime client version is >= compile time client version +$cv = explode('.', oci_client_version()); +if ($cv[0] < 11 || ($cv[0] == 11 && $cv[1] < 2) || ($cv[0] == 11 && $cv[1] == 2 && $cv[3] < 3)) { + die("skip test works only with Oracle 11.2.0.3 or greater version of Oracle client libraries"); +} +?> +--INI-- +log_errors_max_len=4096 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +echo "Test 1\n"; + +error_reporting(E_ALL); + +$s = oci_parse($c, "declare +s varchar2(4000); +begin +s := 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBabcdefghBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'; +raise_application_error(-20333, s); +end;"); + +oci_execute($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_execute(): ORA-20333: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBab in %serror3.php on line %d +===DONE=== diff --git a/ext/oci8/tests/error_bind.phpt b/ext/oci8/tests/error_bind.phpt new file mode 100644 index 0000000..6ee26ee --- /dev/null +++ b/ext/oci8/tests/error_bind.phpt @@ -0,0 +1,70 @@ +--TEST-- +Test some oci_bind_by_name error conditions +--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 varchar(10))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + + +echo "Insert value\n"; + +$name = 'abc'; +$stmt = oci_parse($c, "insert into bind_test values (:name)"); +oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR); +var_dump(oci_execute($stmt)); + +echo "Test 1 - Assign a resource to the bind variable and execute \n"; +$name=$c; +var_dump(oci_execute($stmt)); + +echo "Test 2 - Re-bind a resource\n"; +oci_bind_by_name($stmt, ":name", $c); +var_dump(oci_execute($stmt)); +var_dump($c); + +// Use a connection resource instead of a ROWID. +echo "Test 3 - Resource mismatch !!\n"; +$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id"); +oci_bind_by_name($stmt, ":r_id", $c); +var_dump(oci_execute($stmt)); + +// Clean up + +$drop = "drop table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +Insert value +bool(true) +Test 1 - Assign a resource to the bind variable and execute + +Warning: oci_execute(): Invalid variable used for bind in %s on line %d +bool(false) +Test 2 - Re-bind a resource + +Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d + +Warning: oci_execute(): Invalid variable used for bind in %s on line %d +bool(false) +resource(%d) of type (oci8 connection) +Test 3 - Resource mismatch !! + +Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d + +Warning: oci_execute(): ORA-%r(01008|57000)%r: %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/error_old.phpt b/ext/oci8/tests/error_old.phpt new file mode 100644 index 0000000..c6f9cd3 --- /dev/null +++ b/ext/oci8/tests/error_old.phpt @@ -0,0 +1,43 @@ +--TEST-- +ocierror() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs: different error messages from TimesTen +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +var_dump($s = ociparse($c, "WRONG SYNTAX")); +var_dump(ociexecute($s)); +var_dump(ocierror($s)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%s) of type (oci8 connection) +resource(%s) of type (oci8 statement) + +Warning: ociexecute(): ORA-00900: %s in %s on line %d +bool(false) +array(4) { + ["code"]=> + int(900) + ["message"]=> + string(%d) "ORA-00900: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(12) "WRONG SYNTAX" +} +Done diff --git a/ext/oci8/tests/error_parse.phpt b/ext/oci8/tests/error_parse.phpt new file mode 100644 index 0000000..458df87 --- /dev/null +++ b/ext/oci8/tests/error_parse.phpt @@ -0,0 +1,142 @@ +--TEST-- +Test error handling when persistent connection is passed to oci_error() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +// As part of the fix for Bug 42134, an error handling difference was +// noticed when oci_error() was passed a persistent connection. This +// was fixed and the behavior of oci_error() for all connections types +// was made consistent. + +require(dirname(__FILE__).'/details.inc'); + +// Test parse error for normal connection + +if (!empty($dbase)) { + $c1 = oci_connect($user,$password,$dbase); +} +else { + $c1 = oci_connect($user,$password); +} + +$s = @oci_parse($c1, "select ' from dual"); +if (!$s) { + echo "Normal connection: Parse error\n"; + $m = oci_error($c1); + var_dump($m); +} + +// Test parse error for new connection + +if (!empty($dbase)) { + $c2 = oci_new_connect($user,$password,$dbase); +} +else { + $c2 = oci_new_connect($user,$password); +} + +$s = @oci_parse($c2, "select ' from dual"); +if (!$s) { + echo "New connection: Parse error\n"; + $m = oci_error($c2); + var_dump($m); +} + +// Test parse error for persistent connection + +if (!empty($dbase)) { + $c3 = oci_pconnect($user,$password,$dbase); +} +else { + $c3 = oci_pconnect($user,$password); +} + +$s = @oci_parse($c3, "select ' from dual"); +if (!$s) { + echo "Persistent connection: Parse error\n"; + $m = oci_error($c3); + var_dump($m); +} + +// Verify that passing no connection doesn't affect future calls + +$m = oci_error(); +echo "No connection: error: "; +var_dump($m); + +// Check the errors are still accessible in the respective handles + +$m = oci_error($c1); +echo "Normal connection (take #2): Parse error: "; +echo $m["message"], "\n"; + +$m = oci_error($c2); +echo "New connection (take #2): Parse error: "; +echo $m["message"], "\n"; + +$m = oci_error($c3); +echo "Persistent connection (take #2): Parse error: "; +echo $m["message"], "\n"; + +// Now create a new error for a normal connection and check all again + +$s = @oci_new_collection($c1, "ABC"); +$m = oci_error($c1); +echo "Normal connection: New Collection error: "; +echo $m["message"], "\n"; + +$m = oci_error($c2); +echo "New connection (take #3): Parse error: "; +echo $m["message"], "\n"; + +$m = oci_error($c3); +echo "Persistent connection (take #3): Parse error: "; +echo $m["message"], "\n"; + +echo "Done\n"; + +?> +--EXPECTF-- +Normal connection: Parse error +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +New connection: Parse error +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +Persistent connection: Parse error +array(4) { + ["code"]=> + int(1756) + ["message"]=> + string(48) "ORA-01756: %s" + ["offset"]=> + int(0) + ["sqltext"]=> + string(0) "" +} +No connection: error: bool(false) +Normal connection (take #2): Parse error: ORA-01756: %s +New connection (take #2): Parse error: ORA-01756: %s +Persistent connection (take #2): Parse error: ORA-01756: %s +Normal connection: New Collection error: OCI-22303: type ""."ABC" not found +New connection (take #3): Parse error: ORA-01756: %s +Persistent connection (take #3): Parse error: ORA-01756: %s +Done diff --git a/ext/oci8/tests/exec_fetch.phpt b/ext/oci8/tests/exec_fetch.phpt new file mode 100644 index 0000000..52d515f --- /dev/null +++ b/ext/oci8/tests/exec_fetch.phpt @@ -0,0 +1,24 @@ +--TEST-- +fetch after failed oci_execute() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$sql = "select 2 from nonex_dual"; +$stmt = oci_parse($c, $sql); + +var_dump(oci_execute($stmt)); +var_dump(oci_fetch_array($stmt)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): ORA-00942: %s in %s on line %d +bool(false) + +Warning: oci_fetch_array(): ORA-24374: %s in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/execute_mode.phpt b/ext/oci8/tests/execute_mode.phpt new file mode 100644 index 0000000..90570ca --- /dev/null +++ b/ext/oci8/tests/execute_mode.phpt @@ -0,0 +1,19 @@ +--TEST-- +oci_execute() and invalid execute mode +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$stmt = oci_parse($pc, "select NULL from dual"); +oci_execute($stmt, -1); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): Invalid execute mode given: -1 in %s on line %d +Done diff --git a/ext/oci8/tests/extauth_01.phpt b/ext/oci8/tests/extauth_01.phpt new file mode 100644 index 0000000..37f8f38 --- /dev/null +++ b/ext/oci8/tests/extauth_01.phpt @@ -0,0 +1,198 @@ +--TEST-- +Test External Authentication errors with oci_connect +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms"); +require(dirname(__FILE__).'/details.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +// Run Test + +echo "Test 1\n"; + +$c = oci_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 2\n"; + +$c = oci_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 3\n"; + +$c = oci_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 4\n"; + +$c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 5\n"; + +$c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 6\n"; + +$c = oci_connect('', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 7\n"; + +$c = oci_connect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 8\n"; + +$c = oci_connect('/', null, 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 9\n"; + +$c = oci_connect('/', '', 'c', null, OCI_SYSDBA+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 10\n"; + +$c = oci_connect('/', '', 'c', null, OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 2 + +Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 3 + +Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 4 + +Warning: oci_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 5 + +Warning: oci_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 6 + +Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 7 + +Warning: oci_connect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 8 + +Warning: oci_connect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 9 + +Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 10 + +Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +===DONE=== diff --git a/ext/oci8/tests/extauth_02.phpt b/ext/oci8/tests/extauth_02.phpt new file mode 100644 index 0000000..f3b517f --- /dev/null +++ b/ext/oci8/tests/extauth_02.phpt @@ -0,0 +1,197 @@ +--TEST-- +Test External Authentication errors with oci_new_connect +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms"); +?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +// Run Test + +echo "Test 1\n"; + +$c = oci_new_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 2\n"; + +$c = oci_new_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 3\n"; + +$c = oci_new_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 4\n"; + +$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 5\n"; + +$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 6\n"; + +$c = oci_new_connect('', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 7\n"; + +$c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 8\n"; + +$c = oci_new_connect('/', null, 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 9\n"; + +$c = oci_new_connect('/', '', 'c', null, OCI_SYSDBA+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 10\n"; + +$c = oci_new_connect('/', '', 'c', null, OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 2 + +Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 3 + +Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 4 + +Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 5 + +Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 6 + +Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 7 + +Warning: oci_new_connect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 8 + +Warning: oci_new_connect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 9 + +Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 10 + +Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +===DONE=== diff --git a/ext/oci8/tests/extauth_03.phpt b/ext/oci8/tests/extauth_03.phpt new file mode 100644 index 0000000..e6685eb --- /dev/null +++ b/ext/oci8/tests/extauth_03.phpt @@ -0,0 +1,197 @@ +--TEST-- +Test External Authentication errors with oci_pconnect +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms"); +?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +// Run Test + +echo "Test 1\n"; + +$c = oci_pconnect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 2\n"; + +$c = oci_pconnect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 3\n"; + +$c = oci_pconnect('notemtpy', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 4\n"; + +$c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 5\n"; + +$c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 6\n"; + +$c = oci_pconnect('', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 7\n"; + +$c = oci_pconnect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 8\n"; + +$c = oci_pconnect('/', null, 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 9\n"; + +$c = oci_pconnect('/', '', 'c', null, OCI_SYSDBA+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 10\n"; + +$c = oci_pconnect('/', '', 'c', null, OCI_SYSOPER+OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 2 + +Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 3 + +Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 4 + +Warning: oci_pconnect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 5 + +Warning: oci_pconnect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d +bool(false) +bool(false) +Test 6 + +Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d +bool(false) +bool(false) +Test 7 + +Warning: oci_pconnect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 8 + +Warning: oci_pconnect(): ORA-12154: %s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(12154) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-12154: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 9 + +Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +Test 10 + +Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d +array(4) { + [%u|b%"code"]=> + int(%d) + [%u|b%"message"]=> + %unicode|string%(%d) "ORA-%d: %s" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(0) "" +} +bool(false) +===DONE=== diff --git a/ext/oci8/tests/extauth_04.phpt b/ext/oci8/tests/extauth_04.phpt new file mode 100644 index 0000000..e502435 --- /dev/null +++ b/ext/oci8/tests/extauth_04.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test External Authentication errors on Windows +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only"); +?> +--FILE-- +<?php + +// Run Test + +echo "Test 1\n"; + +$c = oci_connect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 2\n"; + +$c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +echo "Test 3\n"; + +$c = oci_pconnect('/', '', 'anything', null, OCI_CRED_EXT); +if (!$c) { + $m = oci_error(); + var_dump($m); +} +var_dump($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +Warning: oci_connect(): External Authentication is not supported on Windows in %s on line %d +bool(false) +bool(false) +Test 2 +Warning: oci_new_connect(): External Authentication is not supported on Windows in %s on line %d +bool(false) +bool(false) +Test 3 +Warning: oci_pconnect(): External Authentication is not supported on Windows in %s on line %d +bool(false) +bool(false) +===DONE=== diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt new file mode 100644 index 0000000..e48aeef --- /dev/null +++ b/ext/oci8/tests/fetch.phpt @@ -0,0 +1,56 @@ +--TEST-- +ocifetch() & ociresult() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table fetch_tab", + "create table fetch_tab (id number, value number)", + "insert into fetch_tab (id, value) values (1,1)", + "insert into fetch_tab (id, value) values (1,1)", + "insert into fetch_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +if (!($s = oci_parse($c, "select * from fetch_tab"))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while(ocifetch($s)) { + $row = ociresult($s, 1); + $row1 = ociresult($s, 2); + var_dump($row); + var_dump($row1); +} + +// Cleanup + +$stmtarray = array( + "drop table fetch_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +%unicode|string%(1) "1" +%unicode|string%(1) "1" +%unicode|string%(1) "1" +%unicode|string%(1) "1" +%unicode|string%(1) "1" +%unicode|string%(1) "1" +Done diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt new file mode 100644 index 0000000..4fc41da --- /dev/null +++ b/ext/oci8/tests/fetch_all.phpt @@ -0,0 +1,94 @@ +--TEST-- +oci_fetch_all() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table fetch_all_tab", + "create table fetch_all_tab (id number, value number)", + "insert into fetch_all_tab (id, value) values (1,1)", + "insert into fetch_all_tab (id, value) values (1,1)", + "insert into fetch_all_tab (id, value) values (1,1)" +); + +oci8_test_sql_execute($c, $stmtarray); + +if (!($s = oci_parse($c, "select * from fetch_all_tab"))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($s, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(ocifetchstatement($s, $all)); +var_dump($all); + +// Cleanup + +$stmtarray = array( + "drop table fetch_all_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +int(3) +array(2) { + [%u|b%"ID"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } + [%u|b%"VALUE"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } +} +int(3) +array(2) { + [%u|b%"ID"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } + [%u|b%"VALUE"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } +} +Done diff --git a/ext/oci8/tests/fetch_all1.phpt b/ext/oci8/tests/fetch_all1.phpt new file mode 100644 index 0000000..4fc41da --- /dev/null +++ b/ext/oci8/tests/fetch_all1.phpt @@ -0,0 +1,94 @@ +--TEST-- +oci_fetch_all() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table fetch_all_tab", + "create table fetch_all_tab (id number, value number)", + "insert into fetch_all_tab (id, value) values (1,1)", + "insert into fetch_all_tab (id, value) values (1,1)", + "insert into fetch_all_tab (id, value) values (1,1)" +); + +oci8_test_sql_execute($c, $stmtarray); + +if (!($s = oci_parse($c, "select * from fetch_all_tab"))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($s, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(ocifetchstatement($s, $all)); +var_dump($all); + +// Cleanup + +$stmtarray = array( + "drop table fetch_all_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +int(3) +array(2) { + [%u|b%"ID"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } + [%u|b%"VALUE"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } +} +int(3) +array(2) { + [%u|b%"ID"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } + [%u|b%"VALUE"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [2]=> + %unicode|string%(1) "1" + } +} +Done diff --git a/ext/oci8/tests/fetch_all2.phpt b/ext/oci8/tests/fetch_all2.phpt new file mode 100644 index 0000000..483e515 --- /dev/null +++ b/ext/oci8/tests/fetch_all2.phpt @@ -0,0 +1,245 @@ +--TEST-- +oci_fetch_all() - 2 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..1748ea5 --- /dev/null +++ b/ext/oci8/tests/fetch_all3.phpt @@ -0,0 +1,593 @@ +--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"); + +// Initialize + +$stmtarray = array( + "drop table fetch_all3_tab", + "create table fetch_all3_tab (id number, value number)", +); + +oci8_test_sql_execute($c, $stmtarray); + +$insert_sql = "insert into fetch_all3_tab (id, value) values (:idbv,:vbv)"; +$s = oci_parse($c, $insert_sql); +oci_bind_by_name($s, ":idbv", $idbv, -1, SQLT_INT); +oci_bind_by_name($s, ":vbv", $vbv, -1, SQLT_INT); + +for ($i = 1; $i <= 4; $i++) { + $idbv = $i; + $vbv = -$i; + oci_execute($s, OCI_DEFAULT); +} + +oci_commit($c); + +// Run Test + +$select_sql = "select id, value from fetch_all3_tab 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); + +// Cleanup + +$stmtarray = array( + "drop table fetch_all3_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +None +int(4) +array(2) { + [%u|b%"ID"]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [%u|b%"VALUE"]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_ASSOC +int(4) +array(2) { + [%u|b%"ID"]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [%u|b%"VALUE"]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(2) { + [%u|b%"ID"]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [%u|b%"VALUE"]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(2) { + [%u|b%"ID"]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [%u|b%"VALUE"]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [1]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [1]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW +int(4) +array(4) { + [0]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "2" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "3" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "4" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "2" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "3" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "4" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(4) { + [0]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "2" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "3" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "4" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "2" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "3" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [%u|b%"ID"]=> + %unicode|string%(1) "4" + [%u|b%"VALUE"]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [0]=> + %unicode|string%(1) "2" + [1]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [0]=> + %unicode|string%(1) "3" + [1]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [0]=> + %unicode|string%(1) "4" + [1]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [0]=> + %unicode|string%(1) "2" + [1]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [0]=> + %unicode|string%(1) "3" + [1]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [0]=> + %unicode|string%(1) "4" + [1]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [0]=> + %unicode|string%(1) "2" + [1]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [0]=> + %unicode|string%(1) "3" + [1]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [0]=> + %unicode|string%(1) "4" + [1]=> + %unicode|string%(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(2) "-1" + } + [1]=> + array(2) { + [0]=> + %unicode|string%(1) "2" + [1]=> + %unicode|string%(2) "-2" + } + [2]=> + array(2) { + [0]=> + %unicode|string%(1) "3" + [1]=> + %unicode|string%(2) "-3" + } + [3]=> + array(2) { + [0]=> + %unicode|string%(1) "4" + [1]=> + %unicode|string%(2) "-4" + } +} +OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [1]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + [3]=> + %unicode|string%(1) "4" + } + [1]=> + array(4) { + [0]=> + %unicode|string%(2) "-1" + [1]=> + %unicode|string%(2) "-2" + [2]=> + %unicode|string%(2) "-3" + [3]=> + %unicode|string%(2) "-4" + } +} +Done diff --git a/ext/oci8/tests/fetch_all4.phpt b/ext/oci8/tests/fetch_all4.phpt new file mode 100644 index 0000000..1d3c967 --- /dev/null +++ b/ext/oci8/tests/fetch_all4.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test oci_fetch_* array overwriting when query returns no rows +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table fetch_all4_tab", + "create table fetch_all4_tab (mycol1 number, mycol2 varchar2(20))", + "insert into fetch_all4_tab values (1, 'abc')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0"); +oci_execute($s); +$res = array(1,2,3); // this array is replaced as a result of the query +$r = oci_fetch_all($s, $res); +var_dump($r); +var_dump($res); + +echo "Test 2\n"; + +$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0"); +oci_execute($s); +$row = array(1,2,3); // this array is replaced as a result of the query +$row = oci_fetch_array($s); +var_dump($row); + +// Clean up + +$stmtarray = array( + "drop table fetch_all4_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +int(0) +array(2) { + [%u|b%"MYCOL1"]=> + array(0) { + } + [%u|b%"MYCOL2"]=> + array(0) { + } +} +Test 2 +bool(false) +===DONE=== diff --git a/ext/oci8/tests/fetch_all5.phpt b/ext/oci8/tests/fetch_all5.phpt new file mode 100644 index 0000000..a6bb3c3 --- /dev/null +++ b/ext/oci8/tests/fetch_all5.phpt @@ -0,0 +1,110 @@ +--TEST-- +Test oci_fetch_all with 0 and -1 skip & maxrows +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table fetch_all5_tab", + "create table fetch_all5_tab (mycol1 number, mycol2 varchar2(20))", + "insert into fetch_all5_tab values (1, 'abc')", + "insert into fetch_all5_tab values (2, 'def')", + "insert into fetch_all5_tab values (3, 'ghi')" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from fetch_all5_tab order by 1"); +oci_execute($s); +$r = oci_fetch_all($s, $res, 0, -1); +var_dump($r); +var_dump($res); + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from fetch_all5_tab order by 1"); +oci_execute($s); +$r = oci_fetch_all($s, $res, 0, 0); +var_dump($r); +var_dump($res); + +echo "Test 3\n"; + +$s = oci_parse($c, "select * from fetch_all5_tab order by 1"); +oci_execute($s); +$r = oci_fetch_all($s, $res, -1, 0); +var_dump($r); +var_dump($res); + +// Clean up + +$stmtarray = array( + "drop table fetch_all5_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +int(3) +array(2) { + [%u|b%"MYCOL1"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + } + [%u|b%"MYCOL2"]=> + array(3) { + [0]=> + %unicode|string%(3) "abc" + [1]=> + %unicode|string%(3) "def" + [2]=> + %unicode|string%(3) "ghi" + } +} +Test 1 +int(3) +array(2) { + [%u|b%"MYCOL1"]=> + array(3) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "2" + [2]=> + %unicode|string%(1) "3" + } + [%u|b%"MYCOL2"]=> + array(3) { + [0]=> + %unicode|string%(3) "abc" + [1]=> + %unicode|string%(3) "def" + [2]=> + %unicode|string%(3) "ghi" + } +} +Test 3 +int(0) +array(0) { +} +===DONE=== diff --git a/ext/oci8/tests/fetch_array.phpt b/ext/oci8/tests/fetch_array.phpt new file mode 100644 index 0000000..db5c6c5 --- /dev/null +++ b/ext/oci8/tests/fetch_array.phpt @@ -0,0 +1,376 @@ +--TEST-- +oci_fetch_array() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +echo "Test 1\n"; + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s)) { + var_dump($row); +} + +echo "Test 2\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_NUM)) { + var_dump($row); +} + +echo "Test 3\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); +} + +echo "Test 4\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_BOTH)) { + var_dump($row); +} + +echo "Test 5\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_RETURN_LOBS)) { + var_dump($row); +} + +echo "Test 6\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) { + var_dump($row); +} + +echo "Test 7\n"; + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) { + var_dump($row); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +Test 1 +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +Test 2 +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +Test 3 +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +Test 4 +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +Test 5 +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +Test 6 +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +Test 7 +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +Done + diff --git a/ext/oci8/tests/fetch_assoc.phpt b/ext/oci8/tests/fetch_assoc.phpt new file mode 100644 index 0000000..5c4c91e --- /dev/null +++ b/ext/oci8/tests/fetch_assoc.phpt @@ -0,0 +1,69 @@ +--TEST-- +oci_fetch_assoc() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmtarray = array( + "drop table fetch_assoc_tab", + "create table fetch_assoc_tab (id number, value number, dummy varchar2(20))", + "insert into fetch_assoc_tab values (1,1,null)", + "insert into fetch_assoc_tab values (1,1,null)", + "insert into fetch_assoc_tab values (1,1,null)" +); + +oci8_test_sql_execute($c, $stmtarray); + +$select_sql = "select * from fetch_assoc_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_assoc($s)) { + var_dump($row); +} + +// Clean up + +$stmtarray = array( + "drop table fetch_assoc_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +array(3) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["DUMMY"]=> + NULL +} +array(3) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["DUMMY"]=> + NULL +} +array(3) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["DUMMY"]=> + NULL +} +Done diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt new file mode 100644 index 0000000..45a6a81 --- /dev/null +++ b/ext/oci8/tests/fetch_into.phpt @@ -0,0 +1,71 @@ +--TEST-- +ocifetchinto() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table fetch_into_tab", + "create table fetch_into_tab (id number, value number)", + "insert into fetch_into_tab (id, value) values (1,1)", + "insert into fetch_into_tab (id, value) values (1,1)", + "insert into fetch_into_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +if (!($s = oci_parse($c, "select * from fetch_into_tab"))) { + die("oci_parse(select) failed!\n"); +} + +/* ocifetchinto */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s, $all)); +var_dump($all); + +/* ocifetchinto */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); + +// Cleanup + +$stmtarray = array( + "drop table fetch_into_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +int(2) +array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" +} +int(2) +array(4) { + [0]=> + %unicode|string%(1) "1" + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" + [%u|b%"VALUE"]=> + %unicode|string%(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_into1.phpt b/ext/oci8/tests/fetch_into1.phpt new file mode 100644 index 0000000..8f7a6bd --- /dev/null +++ b/ext/oci8/tests/fetch_into1.phpt @@ -0,0 +1,195 @@ +--TEST-- +various ocifetchinto() tests +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__).'/create_table.inc'; + +$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<20; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s, $all, OCI_NUM)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_NULLS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +int(5) +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +int(5) +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +int(5) +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +int(5) +array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +Done diff --git a/ext/oci8/tests/fetch_into2.phpt b/ext/oci8/tests/fetch_into2.phpt new file mode 100644 index 0000000..7bef2c0 --- /dev/null +++ b/ext/oci8/tests/fetch_into2.phpt @@ -0,0 +1,73 @@ +--TEST-- +ocifetchinto() & wrong number of params +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__).'/create_table.inc'; + +$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<20; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC, 5)); +var_dump($all); +var_dump(ocifetchinto($c, $all, OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, 1000000)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +Warning: ocifetchinto() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Notice: Undefined variable: all in %s on line %d +NULL + +Warning: ocifetchinto() expects at most 3 parameters, 4 given in %s on line %d +NULL +NULL + +Warning: ocifetchinto(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +NULL +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt new file mode 100644 index 0000000..1c290d5 --- /dev/null +++ b/ext/oci8/tests/fetch_object.phpt @@ -0,0 +1,123 @@ +--TEST-- +oci_fetch_object() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table fetch_object_tab", + "create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))", + "insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')", + "insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')", + "insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + var_dump($row); +} + +echo "Test 2\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + echo $row->caseSensitive . "\n"; + echo $row->SECONDCOL . "\n"; + echo $row->ANOTHERCOL . "\n"; +} + +echo "Test 3\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_object($s); +echo $row->caseSensitive . "\n"; +echo $row->CASESENSITIVE . "\n"; + +// Clean up + +$stmtarray = array( + "drop table fetch_object_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +object(stdClass)#1 (3) { + [%u|b%"caseSensitive"]=> + %unicode|string%(3) "123" + [%u|b%"SECONDCOL"]=> + %unicode|string%(19) "1st row col2 string" + [%u|b%"ANOTHERCOL"]=> + %unicode|string%(15) "1 more text " +} +object(stdClass)#2 (3) { + [%u|b%"caseSensitive"]=> + %unicode|string%(3) "456" + [%u|b%"SECONDCOL"]=> + %unicode|string%(19) "2nd row col2 string" + [%u|b%"ANOTHERCOL"]=> + %unicode|string%(15) "2 more text " +} +object(stdClass)#1 (3) { + [%u|b%"caseSensitive"]=> + %unicode|string%(3) "789" + [%u|b%"SECONDCOL"]=> + %unicode|string%(19) "3rd row col2 string" + [%u|b%"ANOTHERCOL"]=> + %unicode|string%(15) "3 more text " +} +Test 2 +123 +1st row col2 string +1 more text +456 +2nd row col2 string +2 more text +789 +3rd row col2 string +3 more text +Test 3 +123 + +Notice: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object.php on line %d + +===DONE=== diff --git a/ext/oci8/tests/fetch_object_1.phpt b/ext/oci8/tests/fetch_object_1.phpt new file mode 100644 index 0000000..4f14a5e --- /dev/null +++ b/ext/oci8/tests/fetch_object_1.phpt @@ -0,0 +1,123 @@ +--TEST-- +oci_fetch_object() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table fetch_object_tab", + "create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))", + "insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')", + "insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')", + "insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + var_dump($row); +} + +echo "Test 2\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + echo $row->caseSensitive . "\n"; + echo $row->SECONDCOL . "\n"; + echo $row->ANOTHERCOL . "\n"; +} + +echo "Test 3\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_object($s); +echo $row->caseSensitive . "\n"; +echo $row->CASESENSITIVE . "\n"; + +// Clean up + +$stmtarray = array( + "drop table fetch_object_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +object(stdClass)#%d (3) { + ["caseSensitive"]=> + string(3) "123" + ["SECONDCOL"]=> + string(19) "1st row col2 string" + ["ANOTHERCOL"]=> + string(15) "1 more text " +} +object(stdClass)#%d (3) { + ["caseSensitive"]=> + string(3) "456" + ["SECONDCOL"]=> + string(19) "2nd row col2 string" + ["ANOTHERCOL"]=> + string(15) "2 more text " +} +object(stdClass)#%d (3) { + ["caseSensitive"]=> + string(3) "789" + ["SECONDCOL"]=> + string(19) "3rd row col2 string" + ["ANOTHERCOL"]=> + string(15) "3 more text " +} +Test 2 +123 +1st row col2 string +1 more text +456 +2nd row col2 string +2 more text +789 +3rd row col2 string +3 more text +Test 3 +123 + +Notice: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object_1.php on line %d + +===DONE=== diff --git a/ext/oci8/tests/fetch_object_2.phpt b/ext/oci8/tests/fetch_object_2.phpt new file mode 100644 index 0000000..1814446 --- /dev/null +++ b/ext/oci8/tests/fetch_object_2.phpt @@ -0,0 +1,113 @@ +--TEST-- +oci_fetch_object() with CLOB and NULL +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table fetch_object_2_tab", + "create table fetch_object_2_tab (col1 number, col2 CLOB, col3 varchar2(15))", + "insert into fetch_object_2_tab values (123, '1st row col2 string', '1 more text')", + "insert into fetch_object_2_tab values (456, '2nd row col2 string', NULL)", + "insert into fetch_object_2_tab values (789, '3rd row col2 string', '3 more text')", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_2_tab order by 1'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + var_dump($row); +} + +echo "Test 2\n"; + +if (!($s = oci_parse($c, 'select * from fetch_object_2_tab order by 1'))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while ($row = oci_fetch_object($s)) { + echo $row->COL1 . "\n"; + echo $row->COL2->load(100) . "\n"; + echo $row->COL3 . "\n"; +} + +// Clean up + +$stmtarray = array( + "drop table fetch_object_2_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +object(stdClass)#%d (3) { + ["COL1"]=> + string(3) "123" + ["COL2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["COL3"]=> + string(11) "1 more text" +} +object(stdClass)#%d (3) { + ["COL1"]=> + string(3) "456" + ["COL2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["COL3"]=> + NULL +} +object(stdClass)#%d (3) { + ["COL1"]=> + string(3) "789" + ["COL2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["COL3"]=> + string(11) "3 more text" +} +Test 2 +123 +1st row col2 string +1 more text +456 +2nd row col2 string + +789 +3rd row col2 string +3 more text +===DONE=== diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt new file mode 100644 index 0000000..2b28634 --- /dev/null +++ b/ext/oci8/tests/fetch_row.phpt @@ -0,0 +1,65 @@ +--TEST-- +oci_fetch_row() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table fetch_row_tab", + "create table fetch_row_tab (id number, value number)", + "insert into fetch_row_tab (id, value) values (1,1)", + "insert into fetch_row_tab (id, value) values (1,1)", + "insert into fetch_row_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +if (!($s = oci_parse($c, "select * from fetch_row_tab"))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_row($s)) { + var_dump($row); +} + +// Cleanup + +$stmtarray = array( + "drop table fetch_row_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" +} +array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" +} +array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" +} +Done diff --git a/ext/oci8/tests/field_funcs.phpt b/ext/oci8/tests/field_funcs.phpt new file mode 100644 index 0000000..92b7718 --- /dev/null +++ b/ext/oci8/tests/field_funcs.phpt @@ -0,0 +1,108 @@ +--TEST-- +oci_field_*() family +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +string(2) "ID" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(false) +string(5) "VALUE" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(true) +string(4) "BLOB" +string(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +string(4) "CLOB" +string(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +string(6) "STRING" +string(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/field_funcs0.phpt b/ext/oci8/tests/field_funcs0.phpt new file mode 100644 index 0000000..5448fcb --- /dev/null +++ b/ext/oci8/tests/field_funcs0.phpt @@ -0,0 +1,108 @@ +--TEST-- +oci_field_*() family +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +string(2) "ID" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(false) +string(5) "VALUE" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(true) +string(4) "BLOB" +string(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +string(4) "CLOB" +string(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +string(6) "STRING" +string(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt new file mode 100644 index 0000000..c14ee89 --- /dev/null +++ b/ext/oci8/tests/field_funcs1.phpt @@ -0,0 +1,183 @@ +--TEST-- +oci_field_*() family: error cases +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table field_funcs1_tab", + "create table field_funcs1_tab (id number, value number)", + "insert into field_funcs1_tab (id, value) values (1,1)", + "insert into field_funcs1_tab (id, value) values (1,1)", + "insert into field_funcs1_tab (id, value) values (1,1)" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +if (!($s = oci_parse($c, "select * from field_funcs1_tab"))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +echo "Test 1\n"; +var_dump(oci_field_is_null($s, -1)); +var_dump(oci_field_name($s, -1)); +var_dump(oci_field_type($s, -1)); +var_dump(oci_field_type_raw($s, -1)); +var_dump(oci_field_scale($s, -1)); +var_dump(oci_field_precision($s, -1)); +var_dump(oci_field_size($s, -1)); + +echo "Test 2\n"; +var_dump(oci_field_is_null($s, "none")); +var_dump(oci_field_name($s, "none")); +var_dump(oci_field_type($s, "none")); +var_dump(oci_field_type_raw($s, "none")); +var_dump(oci_field_scale($s, "none")); +var_dump(oci_field_precision($s, "none")); +var_dump(oci_field_size($s, "none")); + +echo "Test 3\n"; +var_dump(oci_field_is_null($c, -1)); +var_dump(oci_field_name($c, -1)); +var_dump(oci_field_type($c, -1)); +var_dump(oci_field_type_raw($c, -1)); +var_dump(oci_field_scale($c, -1)); +var_dump(oci_field_precision($c, -1)); +var_dump(oci_field_size($c, -1)); + +echo "Test 4\n"; +var_dump(oci_field_is_null($s, array())); +var_dump(oci_field_name($s, array())); +var_dump(oci_field_type($s, array())); +var_dump(oci_field_type_raw($s, array())); +var_dump(oci_field_scale($s, array())); +var_dump(oci_field_precision($s, array())); +var_dump(oci_field_size($s, array())); + +var_dump(oci_field_size($s)); + + +// Cleanup + +$stmtarray = array( + "drop table field_funcs1_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + [0]=> + %unicode|string%(1) "1" + [1]=> + %unicode|string%(1) "1" +} +Test 1 + +Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "-1" in %s on line %d +bool(false) +Test 2 + +Warning: oci_field_is_null(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column name "none" in %s on line %d +bool(false) +Test 3 + +Warning: oci_field_is_null(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_name(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_scale(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_precision(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_size(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +Test 4 + +Warning: oci_field_is_null(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/field_funcs2.phpt b/ext/oci8/tests/field_funcs2.phpt new file mode 100644 index 0000000..502d079 --- /dev/null +++ b/ext/oci8/tests/field_funcs2.phpt @@ -0,0 +1,69 @@ +--TEST-- +Bug #41917 (invalid scale and precision) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$s = oci_parse($c, 'drop table field_funcs2_tab'); +@oci_execute($s); + +$t = array("C01" => "NUMBER", + "C02" => "NUMBER(*,1)", + "C03" => "NUMBER(9)", + "C04" => "NUMBER(9,2)", + "C05" => "NUMBER(9,1)", + "C06" => "NUMBER(7,-2)", + "C07" => "DECIMAL(4,9)", + "C08" => "NUMERIC(4,9)", + "C09" => "DECIMAL(4)", + "C10" => "INTEGER", + "C11" => "INT", + "C12" => "SMALLINT", + "C13" => "FLOAT", + "C14" => "FLOAT(9)", + "C15" => "DOUBLE PRECISION", + "C16" => "REAL", + ); + +$stmt = "create table field_funcs2_tab (\n"; +foreach ($t as $colname => $type) { + $stmt .= "$colname $type,\n"; +} +$stmt[strlen($stmt)-2] = ")"; + +$s = oci_parse($c, $stmt); +oci_execute($s); + +$s = oci_parse($c, "select * from field_funcs2_tab"); +oci_execute($s); + +for ($i = 1; $i <= oci_num_fields($s); $i++) { + $name = oci_field_name($s, $i); + $precision = oci_field_precision($s, $i); + $scale = oci_field_scale($s, $i); + echo "$name ".$t[$name] .": precision $precision, scale $scale\n"; +} + +echo "Done\n"; +?> +--EXPECT-- +C01 NUMBER: precision 0, scale -127 +C02 NUMBER(*,1): precision 38, scale 1 +C03 NUMBER(9): precision 9, scale 0 +C04 NUMBER(9,2): precision 9, scale 2 +C05 NUMBER(9,1): precision 9, scale 1 +C06 NUMBER(7,-2): precision 7, scale -2 +C07 DECIMAL(4,9): precision 4, scale 9 +C08 NUMERIC(4,9): precision 4, scale 9 +C09 DECIMAL(4): precision 4, scale 0 +C10 INTEGER: precision 38, scale 0 +C11 INT: precision 38, scale 0 +C12 SMALLINT: precision 38, scale 0 +C13 FLOAT: precision 126, scale -127 +C14 FLOAT(9): precision 9, scale -127 +C15 DOUBLE PRECISION: precision 126, scale -127 +C16 REAL: precision 63, scale -127 +Done diff --git a/ext/oci8/tests/field_funcs3.phpt b/ext/oci8/tests/field_funcs3.phpt new file mode 100644 index 0000000..e51949c --- /dev/null +++ b/ext/oci8/tests/field_funcs3.phpt @@ -0,0 +1,99 @@ +--TEST-- +oci_field_*() family: basic column types +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialization +$stmtarray = array( + "drop table field_funcs3_tab", + "create table field_funcs3_tab(c1_c char(2), c2_v varchar2(2), c3_n number, c4_d date)", + "insert into field_funcs3_tab values ('c1', 'c2', 3, '01-Jan-2010')" +); + +$v = oci_server_version($c); +if (strpos($v, 'Oracle TimesTen') === false) { + oci8_test_sql_execute($c, array("alter session set nls_date_format = 'DD-MON-YYYY'")); +} +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from field_funcs3_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); +} + +// Clean up + +$stmtarray = array( + "drop table field_funcs3_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +array(4) { + [0]=> + string(2) "c1" + [1]=> + string(2) "c2" + [2]=> + string(1) "3" + [3]=> + string(1%r[19]%r) "%r(01-JAN-2010|0001-01-20 10:00:00)%r" +} +bool(false) +string(4) "C1_C" +string(4) "CHAR" +int(96) +int(0) +int(0) +int(2) +bool(false) +string(4) "C2_V" +string(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(2) +bool(false) +string(4) "C3_N" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(false) +string(4) "C4_D" +string(4) "DATE" +int(12) +int(0) +int(0) +int(7) +===DONE=== diff --git a/ext/oci8/tests/field_funcs_old.phpt b/ext/oci8/tests/field_funcs_old.phpt new file mode 100644 index 0000000..629c550 --- /dev/null +++ b/ext/oci8/tests/field_funcs_old.phpt @@ -0,0 +1,108 @@ +--TEST-- +ocicolumn*() family +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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)"; + +if (!($s = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s)) { + die("ociexecute(insert) failed!\n"); + } +} + +if (!ocicommit($c)) { + die("ocicommit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +ocifetchinto($s, $row, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(ocicolumnisnull($s, $num)); + var_dump(ocicolumnname($s, $num)); + var_dump(ocicolumntype($s, $num)); + var_dump(ocicolumntyperaw($s, $num)); + var_dump(ocicolumnscale($s, $num)); + var_dump(ocicolumnprecision($s, $num)); + var_dump(ocicolumnsize($s, $num)); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +string(2) "ID" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(false) +string(5) "VALUE" +string(6) "NUMBER" +int(2) +int(-127) +int(0) +int(22) +bool(true) +string(4) "BLOB" +string(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +string(4) "CLOB" +string(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +string(6) "STRING" +string(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/function_aliases.phpt b/ext/oci8/tests/function_aliases.phpt new file mode 100644 index 0000000..4c6ce83 --- /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/ini_1.phpt b/ext/oci8/tests/ini_1.phpt new file mode 100644 index 0000000..4c23b72 --- /dev/null +++ b/ext/oci8/tests/ini_1.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test OCI8 php.ini settings +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.privileged_connect = On +oci8.max_persistent = 111 +oci8.persistent_timeout = 222 +oci8.ping_interval = 333 +oci8.connection_class = MyCC +oci8.events = On +oci8.statement_cache_size = 444 +oci8.default_prefetch = 555 +oci8.old_oci_close_semantics = On +--FILE-- +<?php + +echo "Test 1 - check initialization\n"; +echo 'oci8.privileged_connect = ' . ini_get('oci8.privileged_connect') . "\n"; +echo 'oci8.max_persistent = ' . ini_get('oci8.max_persistent') . "\n"; +echo 'oci8.persistent_timeout = ' . ini_get('oci8.persistent_timeout') . "\n"; +echo 'oci8.ping_interval = ' . ini_get('oci8.ping_interval') . "\n"; +echo 'oci8.connection_class = ' . ini_get('oci8.connection_class') . "\n"; +echo 'oci8.events = ' . ini_get('oci8.events') . "\n"; +echo 'oci8.statement_cache_size = ' . ini_get('oci8.statement_cache_size') . "\n"; +echo 'oci8.default_prefetch = ' . ini_get('oci8.default_prefetch') . "\n"; +echo 'oci8.old_oci_close_semantics = ' . ini_get('oci8.old_oci_close_semantics') . "\n"; + +echo "Test 2 - check what can be changed at runtime\n"; +var_dump(ini_set('oci8.privileged_connect', 'Off')); +echo 'oci8.privileged_connect = ' . ini_get('oci8.privileged_connect') . "\n"; +var_dump(ini_set('oci8.max_persistent', '999')); +echo 'oci8.max_persistent = ' . ini_get('oci8.max_persistent') . "\n"; +var_dump(ini_set('oci8.persistent_timeout', '888')); +echo 'oci8.persistent_timeout = ' . ini_get('oci8.persistent_timeout') . "\n"; +var_dump(ini_set('oci8.ping_interval', '777')); +echo 'oci8.ping_interval = ' . ini_get('oci8.ping_interval') . "\n"; +var_dump(ini_set('oci8.connection_class', 'OtherCC')); +echo 'oci8.connection_class = ' . ini_get('oci8.connection_class') . "\n"; +var_dump(ini_set('oci8.events', 'Off')); +echo 'oci8.events = ' . ini_get('oci8.events') . "\n"; +var_dump(ini_set('oci8.statement_cache_size', '666')); +echo 'oci8.statement_cache_size = ' . ini_get('oci8.statement_cache_size') . "\n"; +var_dump(ini_set('oci8.default_prefetch', '111')); +echo 'oci8.default_prefetch = ' . ini_get('oci8.default_prefetch') . "\n"; +var_dump(ini_set('oci8.old_oci_close_semantics', 'Off')); +echo 'oci8.old_oci_close_semantics = ' . ini_get('oci8.old_oci_close_semantics') . "\n"; + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - check initialization +oci8.privileged_connect = 1 +oci8.max_persistent = 111 +oci8.persistent_timeout = 222 +oci8.ping_interval = 333 +oci8.connection_class = MyCC +oci8.events = 1 +oci8.statement_cache_size = 444 +oci8.default_prefetch = 555 +oci8.old_oci_close_semantics = 1 +Test 2 - check what can be changed at runtime +bool(false) +oci8.privileged_connect = 1 +bool(false) +oci8.max_persistent = 111 +bool(false) +oci8.persistent_timeout = 222 +bool(false) +oci8.ping_interval = 333 +string(4) "MyCC" +oci8.connection_class = OtherCC +bool(false) +oci8.events = 1 +bool(false) +oci8.statement_cache_size = 444 +bool(false) +oci8.default_prefetch = 555 +bool(false) +oci8.old_oci_close_semantics = 1 +===DONE=== diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt Binary files differnew file mode 100644 index 0000000..cb94bfa --- /dev/null +++ b/ext/oci8/tests/lob_001.phpt diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt new file mode 100644 index 0000000..7417f9c --- /dev/null +++ b/ext/oci8/tests/lob_002.phpt @@ -0,0 +1,75 @@ +--TEST-- +oci_lob_write() and friends (with errors) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table lob_002_tab", + "create table lob_002_tab (id number, b1 BLOB)", +); + +oci8_test_sql_execute($c, $stmtarray); + +$statement = oci_parse($c, "insert into lob_002_tab (id, b1) values (1, empty_blob()) returning b1 INTO :v_blob "); +$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->write("test", -1)); +var_dump($blob->write("test", "str")); +var_dump($blob->write("test", 1000000)); +var_dump($blob->write(str_repeat("test", 10000), 1000000)); +var_dump($blob->tell()); +var_dump($blob->seek("str", -5)); +var_dump($blob->flush()); + +oci_commit($c); + +$select_sql = "select b1 from lob_002_tab where id = 1"; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row = oci_fetch_array($s, OCI_RETURN_LOBS); + +var_dump(strlen($row[0])); + +// Cleanup + +$stmtarray = array( + "drop table lob_002_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(0) + +Warning: OCI-Lob::write() expects parameter 2 to be long, string given in %slob_002.php on line %d +NULL +int(4) +int(40000) +int(40004) + +Warning: OCI-Lob::seek() expects parameter 1 to be long, string given in %slob_002.php on line %d +NULL +bool(false) +int(40004) +===DONE=== diff --git a/ext/oci8/tests/lob_003.phpt b/ext/oci8/tests/lob_003.phpt Binary files differnew file mode 100644 index 0000000..4775444 --- /dev/null +++ b/ext/oci8/tests/lob_003.phpt diff --git a/ext/oci8/tests/lob_004.phpt b/ext/oci8/tests/lob_004.phpt new file mode 100644 index 0000000..3f583c6 --- /dev/null +++ b/ext/oci8/tests/lob_004.phpt @@ -0,0 +1,83 @@ +--TEST-- +oci_lob_seek()/rewind()/append() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->write("test")); +var_dump($blob->rewind()); +var_dump($blob->write("str")); +var_dump($blob->seek(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($row[0]->append($blob)); +var_dump($row[0]->read(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($row[0]->read(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) +bool(true) +int(3) +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) + } +} +bool(true) +string(4) "strt" +string(8) "strtstrt" +Done diff --git a/ext/oci8/tests/lob_005.phpt b/ext/oci8/tests/lob_005.phpt new file mode 100644 index 0000000..a1e3c3b --- /dev/null +++ b/ext/oci8/tests/lob_005.phpt @@ -0,0 +1,55 @@ +--TEST-- +oci_lob_is_equal() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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); + +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_is_equal($row[0], $row['BLOB'])); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +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) + } +} +bool(true) +Done diff --git a/ext/oci8/tests/lob_006.phpt b/ext/oci8/tests/lob_006.phpt Binary files differnew file mode 100644 index 0000000..ae6b37c --- /dev/null +++ b/ext/oci8/tests/lob_006.phpt diff --git a/ext/oci8/tests/lob_007.phpt b/ext/oci8/tests/lob_007.phpt new file mode 100644 index 0000000..1ca236e --- /dev/null +++ b/ext/oci8/tests/lob_007.phpt @@ -0,0 +1,69 @@ +--TEST-- +oci_lob_write()/size()/load() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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($row[0]->size()); +var_dump(strlen($row[0]->load())); + +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) +Done diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt new file mode 100644 index 0000000..6f4cc05 --- /dev/null +++ b/ext/oci8/tests/lob_008.phpt @@ -0,0 +1,68 @@ +--TEST-- +oci_lob_write()/read()/eof() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->write(str_repeat("string.", 1000))); +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)); + + +$len = 0; +while (!$row[0]->eof()) { + $len += strlen($row[0]->read(1024)); +} +var_dump($len); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +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) +Done diff --git a/ext/oci8/tests/lob_009.phpt b/ext/oci8/tests/lob_009.phpt new file mode 100644 index 0000000..4702e61 --- /dev/null +++ b/ext/oci8/tests/lob_009.phpt @@ -0,0 +1,72 @@ +--TEST-- +oci_lob_import()/read() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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")); +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) +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_009.txt b/ext/oci8/tests/lob_009.txt new file mode 100644 index 0000000..f57bc8a --- /dev/null +++ b/ext/oci8/tests/lob_009.txt @@ -0,0 +1,6 @@ +this +is +a +test +file for +test lob_009.phpt diff --git a/ext/oci8/tests/lob_010.phpt b/ext/oci8/tests/lob_010.phpt new file mode 100644 index 0000000..3361c4b --- /dev/null +++ b/ext/oci8/tests/lob_010.phpt @@ -0,0 +1,49 @@ +--TEST-- +oci_lob_save() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->save("string")); +var_dump($blob->save("string", 3)); +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); + +while (!$row[0]->eof()) { + var_dump($row[0]->read(1024)); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "strstring" +Done diff --git a/ext/oci8/tests/lob_011.phpt b/ext/oci8/tests/lob_011.phpt new file mode 100644 index 0000000..7580d4c --- /dev/null +++ b/ext/oci8/tests/lob_011.phpt @@ -0,0 +1,81 @@ +--TEST-- +oci_lob_copy() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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); + +var_dump(oci_lob_copy($row2[0], $row1[0])); +var_dump($row1[0]->read(100)); + +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"; + +?> +--EXPECT-- +int(32) +bool(true) +string(32) "some string here. string, I said" +array(2) { + [0]=> + string(32) "some string here. string, I said" + ["BLOB"]=> + string(32) "some string here. string, I said" +} +Done diff --git a/ext/oci8/tests/lob_012.phpt b/ext/oci8/tests/lob_012.phpt new file mode 100644 index 0000000..99b971a --- /dev/null +++ b/ext/oci8/tests/lob_012.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci_lob_export() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 string is here\nnew string")); + +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[0]->export(dirname(__FILE__)."/lob_012.tmp", 3, 10)); + +var_dump(file_get_contents(dirname(__FILE__)."/lob_012.tmp")); + +@unlink(dirname(__FILE__)."/lob_012.tmp"); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(30) +bool(true) +string(10) "t string i" +Done diff --git a/ext/oci8/tests/lob_013.phpt b/ext/oci8/tests/lob_013.phpt new file mode 100644 index 0000000..556e56d --- /dev/null +++ b/ext/oci8/tests/lob_013.phpt @@ -0,0 +1,57 @@ +--TEST-- +lob buffering +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->write("test")); +var_dump($blob->getBuffering()); +var_dump($blob->setBuffering(true)); +var_dump($blob->write("test")); +var_dump($blob->getBuffering()); +var_dump($blob->flush()); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name.""; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row = oci_fetch_array($s, OCI_RETURN_LOBS); + +var_dump($row[0]); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(4) +bool(false) +bool(true) +int(4) +bool(true) +bool(true) +string(8) "testtest" +Done diff --git a/ext/oci8/tests/lob_014.phpt b/ext/oci8/tests/lob_014.phpt new file mode 100644 index 0000000..2a1a6be --- /dev/null +++ b/ext/oci8/tests/lob_014.phpt @@ -0,0 +1,59 @@ +--TEST-- +oci_lob_free()/close() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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($blob->free()); +var_dump($blob->write("test")); + +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) +bool(true) +int(4) +bool(true) + +Warning: OCI-Lob::write(): %d is not a valid oci8 descriptor resource in %slob_014.php on line %d +bool(false) +array(1) { + [0]=> + string(8) "testtest" +} +Done diff --git a/ext/oci8/tests/lob_015.phpt b/ext/oci8/tests/lob_015.phpt new file mode 100644 index 0000000..b4a1968 --- /dev/null +++ b/ext/oci8/tests/lob_015.phpt @@ -0,0 +1,56 @@ +--TEST-- +various tests with wrong param count +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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,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", $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); + +var_dump($blob); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +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 %s on line %d + +Warning: oci_bind_by_name() expects at most 5 parameters, 7 given in %s 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, 1 given in %s on line %d + +Warning: oci_execute(): ORA-00932: %s NUMBER %s 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_016.phpt b/ext/oci8/tests/lob_016.phpt new file mode 100644 index 0000000..e0f78e6 --- /dev/null +++ b/ext/oci8/tests/lob_016.phpt @@ -0,0 +1,70 @@ +--TEST-- +returning multiple lobs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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(lob_1 BLOB, lob_2 BLOB)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$init = "INSERT INTO lob_test VALUES(EMPTY_BLOB(), EMPTY_BLOB())"; +$statement = oci_parse($c, $init); +oci_execute($statement); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$row['LOB_1']->write("first"); +$row['LOB_2']->write("second"); + +unset($row); + +oci_commit($c); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +var_dump($row); +var_dump($row['LOB_1']->load()); +var_dump($row['LOB_2']->load()); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["LOB_1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["LOB_2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(5) "first" +string(6) "second" +Done diff --git a/ext/oci8/tests/lob_017.phpt b/ext/oci8/tests/lob_017.phpt new file mode 100644 index 0000000..d27a090 --- /dev/null +++ b/ext/oci8/tests/lob_017.phpt @@ -0,0 +1,72 @@ +--TEST-- +returning multiple lobs (using persistent connection) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$c = oci_pconnect($user, $password, $dbase); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table lob_test(lob_1 BLOB, lob_2 BLOB)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$init = "INSERT INTO lob_test VALUES(EMPTY_BLOB(), EMPTY_BLOB())"; +$statement = oci_parse($c, $init); +oci_execute($statement); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$row['LOB_1']->write("first"); +$row['LOB_2']->write("second"); + +unset($row); + +oci_commit($c); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +var_dump($row); +var_dump($row['LOB_1']->load()); +var_dump($row['LOB_2']->load()); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["LOB_1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["LOB_2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(5) "first" +string(6) "second" +Done diff --git a/ext/oci8/tests/lob_018.phpt b/ext/oci8/tests/lob_018.phpt new file mode 100644 index 0000000..352cd50 --- /dev/null +++ b/ext/oci8/tests/lob_018.phpt @@ -0,0 +1,103 @@ +--TEST-- +fetching the same lob several times +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table lob_018_tab", + "create table lob_018_tab (mykey number, lob_1 clob)", +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Test 1\n"; + +$init = "insert into lob_018_tab (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("data"); + +oci_commit($c); + +$init = "insert into lob_018_tab (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"); + +oci_commit($c); + + +$query = 'select * from lob_018_tab 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); +} + +echo "Test 2\n"; + +$query = 'select * from lob_018_tab 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); +} + +echo "Test 3 - bind with SQLT_CLOB (an alias for OCI_B_CLOB)\n"; + +$init = "insert into lob_018_tab (mykey, lob_1) values(3, 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, SQLT_CLOB); +oci_execute($statement, OCI_DEFAULT); +$clob->save("more stuff"); + +oci_commit($c); + +$query = 'select * from lob_018_tab where mykey = 3'; +$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); +} + +// Cleanup + +$stmtarray = array( + "drop table lob_018_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +string(4) "data" +string(9) "long data" +Test 2 +string(9) "long data" +string(4) "data" +Test 3 - bind with SQLT_CLOB (an alias for OCI_B_CLOB) +string(10) "more stuff" +===DONE=== diff --git a/ext/oci8/tests/lob_019.phpt b/ext/oci8/tests/lob_019.phpt Binary files differnew file mode 100644 index 0000000..19c21f4 --- /dev/null +++ b/ext/oci8/tests/lob_019.phpt diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt Binary files differnew file mode 100644 index 0000000..3faa89f --- /dev/null +++ b/ext/oci8/tests/lob_020.phpt diff --git a/ext/oci8/tests/lob_021.phpt b/ext/oci8/tests/lob_021.phpt new file mode 100644 index 0000000..b748927 --- /dev/null +++ b/ext/oci8/tests/lob_021.phpt @@ -0,0 +1,73 @@ +--TEST-- +oci_lob_free()/close() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->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) +bool(true) +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 0000000..94d175b --- /dev/null +++ b/ext/oci8/tests/lob_022.phpt @@ -0,0 +1,83 @@ +--TEST-- +fetching the same lob several times +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..6416fb4 --- /dev/null +++ b/ext/oci8/tests/lob_023.phpt @@ -0,0 +1,87 @@ +--TEST-- +oci_lob_import()/read() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..ed9b567 --- /dev/null +++ b/ext/oci8/tests/lob_024.phpt @@ -0,0 +1,78 @@ +--TEST-- +oci_lob_load() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..1566944 --- /dev/null +++ b/ext/oci8/tests/lob_025.phpt @@ -0,0 +1,85 @@ +--TEST-- +oci_lob_read() tests +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..aa4c254 --- /dev/null +++ b/ext/oci8/tests/lob_026.phpt @@ -0,0 +1,103 @@ +--TEST-- +oci_lob_seek()/rewind()/append() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/lob_027.phpt b/ext/oci8/tests/lob_027.phpt new file mode 100644 index 0000000..4985063 --- /dev/null +++ b/ext/oci8/tests/lob_027.phpt @@ -0,0 +1,106 @@ +--TEST-- +oci_lob_truncate() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..8da7a8a --- /dev/null +++ b/ext/oci8/tests/lob_028.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test descriptor types for oci_new_descriptor() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..85b230e --- /dev/null +++ b/ext/oci8/tests/lob_029.phpt @@ -0,0 +1,133 @@ +--TEST-- +reading/writing BFILE LOBs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) { + // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP + die("skip this test won't work with remote Oracle"); +} +if (substr(PHP_OS, 0, 3) == 'WIN') die("skip Test script not ported to Windows"); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$realdirname = "/tmp"; // Use /tmp because a local dir can give ORA-22288 depending on perms +$realfilename1 = "oci8bfiletest1.txt"; +$fullname1 = $realdirname."/".$realfilename1; +$realfilename2 = "oci8bfiletest2.txt"; +$fullname2 = $realdirname."/".$realfilename2; +$realfilename3 = "oci8bfiletest3.txt"; +$fullname3 = $realdirname."/".$realfilename3; + +// Setup +$s = oci_parse($c, "drop table FileTest"); +@oci_execute($s); + +$s = oci_parse($c, "drop directory TestDir"); +@oci_execute($s); + +$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 diff --git a/ext/oci8/tests/lob_030.phpt b/ext/oci8/tests/lob_030.phpt new file mode 100644 index 0000000..d7fd21b --- /dev/null +++ b/ext/oci8/tests/lob_030.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..39d27fd --- /dev/null +++ b/ext/oci8/tests/lob_031.phpt @@ -0,0 +1,110 @@ +--TEST-- +Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..97b63c9 --- /dev/null +++ b/ext/oci8/tests/lob_032.phpt @@ -0,0 +1,36 @@ +--TEST-- +oci_lob_write() and friends +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..cdce2d0 --- /dev/null +++ b/ext/oci8/tests/lob_033.phpt @@ -0,0 +1,41 @@ +--TEST-- +various oci_lob_write() error messages +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..7561f64 --- /dev/null +++ b/ext/oci8/tests/lob_034.phpt @@ -0,0 +1,53 @@ +--TEST-- +lob buffering - 2 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..37e010c --- /dev/null +++ b/ext/oci8/tests/lob_035.phpt @@ -0,0 +1,111 @@ +--TEST-- +oci_lob_copy() - 2 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..060b171 --- /dev/null +++ b/ext/oci8/tests/lob_036.phpt @@ -0,0 +1,43 @@ +--TEST-- +Exercise cleanup code when LOB buffering is on +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..75db589 --- /dev/null +++ b/ext/oci8/tests/lob_037.phpt @@ -0,0 +1,71 @@ +--TEST-- +Fetching two different lobs and using them after fetch +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..34b7b48 --- /dev/null +++ b/ext/oci8/tests/lob_038.phpt @@ -0,0 +1,192 @@ +--TEST-- +Array fetch CLOB and BLOB +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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 0000000..02d057e --- /dev/null +++ b/ext/oci8/tests/lob_039.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test CLOB->write() for multiple inserts +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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(22) " clob test 2" + [2]=> + string(33) " clob test 3" + } +} +Done diff --git a/ext/oci8/tests/lob_040.phpt b/ext/oci8/tests/lob_040.phpt new file mode 100644 index 0000000..0a29dc1 --- /dev/null +++ b/ext/oci8/tests/lob_040.phpt @@ -0,0 +1,1044 @@ +--TEST-- +Bug #37706 (Test LOB locator reuse. Extends simple test of lob_037.phpt) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +define('NUMLOBS', 200); + +require(dirname(__FILE__).'/connect.inc'); +require(dirname(__FILE__).'/create_table.inc'); + +for ($i = 0; $i < NUMLOBS; $i++) { + $s = oci_parse($c, "insert into ".$schema.$table_name." (id, clob) values(".$i.", '".$i."aaaa".$i.$i."aaaaaaaaaaaaaaaaaaaaaaaaaaaz')"); + oci_execute($s); +} + +echo "Test 1: CLOB as locator\n"; + +$s = oci_parse($c, "select clob from ".$schema.$table_name." order by id"); +oci_execute($s); + +$row = array(); +for ($i = 0; $i < NUMLOBS; $i++) { + $row[$i] = oci_fetch_array($s, OCI_NUM); +} + +for ($i = 0; $i < NUMLOBS; $i++) { + echo "Row $i Size: " . $row[$i][0]->size() . "\n";; + echo "Pos 1: " . $row[$i][0]->tell() . "\n"; + echo "Data: " . $row[$i][0]->read(5) . "\n";; + echo "Pos 2: " . $row[$i][0]->tell() . "\n"; + echo "Data: " . $row[$i][0]->read(12) . "\n"; +} + +echo "Done\n"; + +?> +--EXPECT-- +Test 1: CLOB as locator +Row 0 Size: 35 +Pos 1: 0 +Data: 0aaaa +Pos 2: 5 +Data: 00aaaaaaaaaa +Row 1 Size: 35 +Pos 1: 0 +Data: 1aaaa +Pos 2: 5 +Data: 11aaaaaaaaaa +Row 2 Size: 35 +Pos 1: 0 +Data: 2aaaa +Pos 2: 5 +Data: 22aaaaaaaaaa +Row 3 Size: 35 +Pos 1: 0 +Data: 3aaaa +Pos 2: 5 +Data: 33aaaaaaaaaa +Row 4 Size: 35 +Pos 1: 0 +Data: 4aaaa +Pos 2: 5 +Data: 44aaaaaaaaaa +Row 5 Size: 35 +Pos 1: 0 +Data: 5aaaa +Pos 2: 5 +Data: 55aaaaaaaaaa +Row 6 Size: 35 +Pos 1: 0 +Data: 6aaaa +Pos 2: 5 +Data: 66aaaaaaaaaa +Row 7 Size: 35 +Pos 1: 0 +Data: 7aaaa +Pos 2: 5 +Data: 77aaaaaaaaaa +Row 8 Size: 35 +Pos 1: 0 +Data: 8aaaa +Pos 2: 5 +Data: 88aaaaaaaaaa +Row 9 Size: 35 +Pos 1: 0 +Data: 9aaaa +Pos 2: 5 +Data: 99aaaaaaaaaa +Row 10 Size: 38 +Pos 1: 0 +Data: 10aaa +Pos 2: 5 +Data: a1010aaaaaaa +Row 11 Size: 38 +Pos 1: 0 +Data: 11aaa +Pos 2: 5 +Data: a1111aaaaaaa +Row 12 Size: 38 +Pos 1: 0 +Data: 12aaa +Pos 2: 5 +Data: a1212aaaaaaa +Row 13 Size: 38 +Pos 1: 0 +Data: 13aaa +Pos 2: 5 +Data: a1313aaaaaaa +Row 14 Size: 38 +Pos 1: 0 +Data: 14aaa +Pos 2: 5 +Data: a1414aaaaaaa +Row 15 Size: 38 +Pos 1: 0 +Data: 15aaa +Pos 2: 5 +Data: a1515aaaaaaa +Row 16 Size: 38 +Pos 1: 0 +Data: 16aaa +Pos 2: 5 +Data: a1616aaaaaaa +Row 17 Size: 38 +Pos 1: 0 +Data: 17aaa +Pos 2: 5 +Data: a1717aaaaaaa +Row 18 Size: 38 +Pos 1: 0 +Data: 18aaa +Pos 2: 5 +Data: a1818aaaaaaa +Row 19 Size: 38 +Pos 1: 0 +Data: 19aaa +Pos 2: 5 +Data: a1919aaaaaaa +Row 20 Size: 38 +Pos 1: 0 +Data: 20aaa +Pos 2: 5 +Data: a2020aaaaaaa +Row 21 Size: 38 +Pos 1: 0 +Data: 21aaa +Pos 2: 5 +Data: a2121aaaaaaa +Row 22 Size: 38 +Pos 1: 0 +Data: 22aaa +Pos 2: 5 +Data: a2222aaaaaaa +Row 23 Size: 38 +Pos 1: 0 +Data: 23aaa +Pos 2: 5 +Data: a2323aaaaaaa +Row 24 Size: 38 +Pos 1: 0 +Data: 24aaa +Pos 2: 5 +Data: a2424aaaaaaa +Row 25 Size: 38 +Pos 1: 0 +Data: 25aaa +Pos 2: 5 +Data: a2525aaaaaaa +Row 26 Size: 38 +Pos 1: 0 +Data: 26aaa +Pos 2: 5 +Data: a2626aaaaaaa +Row 27 Size: 38 +Pos 1: 0 +Data: 27aaa +Pos 2: 5 +Data: a2727aaaaaaa +Row 28 Size: 38 +Pos 1: 0 +Data: 28aaa +Pos 2: 5 +Data: a2828aaaaaaa +Row 29 Size: 38 +Pos 1: 0 +Data: 29aaa +Pos 2: 5 +Data: a2929aaaaaaa +Row 30 Size: 38 +Pos 1: 0 +Data: 30aaa +Pos 2: 5 +Data: a3030aaaaaaa +Row 31 Size: 38 +Pos 1: 0 +Data: 31aaa +Pos 2: 5 +Data: a3131aaaaaaa +Row 32 Size: 38 +Pos 1: 0 +Data: 32aaa +Pos 2: 5 +Data: a3232aaaaaaa +Row 33 Size: 38 +Pos 1: 0 +Data: 33aaa +Pos 2: 5 +Data: a3333aaaaaaa +Row 34 Size: 38 +Pos 1: 0 +Data: 34aaa +Pos 2: 5 +Data: a3434aaaaaaa +Row 35 Size: 38 +Pos 1: 0 +Data: 35aaa +Pos 2: 5 +Data: a3535aaaaaaa +Row 36 Size: 38 +Pos 1: 0 +Data: 36aaa +Pos 2: 5 +Data: a3636aaaaaaa +Row 37 Size: 38 +Pos 1: 0 +Data: 37aaa +Pos 2: 5 +Data: a3737aaaaaaa +Row 38 Size: 38 +Pos 1: 0 +Data: 38aaa +Pos 2: 5 +Data: a3838aaaaaaa +Row 39 Size: 38 +Pos 1: 0 +Data: 39aaa +Pos 2: 5 +Data: a3939aaaaaaa +Row 40 Size: 38 +Pos 1: 0 +Data: 40aaa +Pos 2: 5 +Data: a4040aaaaaaa +Row 41 Size: 38 +Pos 1: 0 +Data: 41aaa +Pos 2: 5 +Data: a4141aaaaaaa +Row 42 Size: 38 +Pos 1: 0 +Data: 42aaa +Pos 2: 5 +Data: a4242aaaaaaa +Row 43 Size: 38 +Pos 1: 0 +Data: 43aaa +Pos 2: 5 +Data: a4343aaaaaaa +Row 44 Size: 38 +Pos 1: 0 +Data: 44aaa +Pos 2: 5 +Data: a4444aaaaaaa +Row 45 Size: 38 +Pos 1: 0 +Data: 45aaa +Pos 2: 5 +Data: a4545aaaaaaa +Row 46 Size: 38 +Pos 1: 0 +Data: 46aaa +Pos 2: 5 +Data: a4646aaaaaaa +Row 47 Size: 38 +Pos 1: 0 +Data: 47aaa +Pos 2: 5 +Data: a4747aaaaaaa +Row 48 Size: 38 +Pos 1: 0 +Data: 48aaa +Pos 2: 5 +Data: a4848aaaaaaa +Row 49 Size: 38 +Pos 1: 0 +Data: 49aaa +Pos 2: 5 +Data: a4949aaaaaaa +Row 50 Size: 38 +Pos 1: 0 +Data: 50aaa +Pos 2: 5 +Data: a5050aaaaaaa +Row 51 Size: 38 +Pos 1: 0 +Data: 51aaa +Pos 2: 5 +Data: a5151aaaaaaa +Row 52 Size: 38 +Pos 1: 0 +Data: 52aaa +Pos 2: 5 +Data: a5252aaaaaaa +Row 53 Size: 38 +Pos 1: 0 +Data: 53aaa +Pos 2: 5 +Data: a5353aaaaaaa +Row 54 Size: 38 +Pos 1: 0 +Data: 54aaa +Pos 2: 5 +Data: a5454aaaaaaa +Row 55 Size: 38 +Pos 1: 0 +Data: 55aaa +Pos 2: 5 +Data: a5555aaaaaaa +Row 56 Size: 38 +Pos 1: 0 +Data: 56aaa +Pos 2: 5 +Data: a5656aaaaaaa +Row 57 Size: 38 +Pos 1: 0 +Data: 57aaa +Pos 2: 5 +Data: a5757aaaaaaa +Row 58 Size: 38 +Pos 1: 0 +Data: 58aaa +Pos 2: 5 +Data: a5858aaaaaaa +Row 59 Size: 38 +Pos 1: 0 +Data: 59aaa +Pos 2: 5 +Data: a5959aaaaaaa +Row 60 Size: 38 +Pos 1: 0 +Data: 60aaa +Pos 2: 5 +Data: a6060aaaaaaa +Row 61 Size: 38 +Pos 1: 0 +Data: 61aaa +Pos 2: 5 +Data: a6161aaaaaaa +Row 62 Size: 38 +Pos 1: 0 +Data: 62aaa +Pos 2: 5 +Data: a6262aaaaaaa +Row 63 Size: 38 +Pos 1: 0 +Data: 63aaa +Pos 2: 5 +Data: a6363aaaaaaa +Row 64 Size: 38 +Pos 1: 0 +Data: 64aaa +Pos 2: 5 +Data: a6464aaaaaaa +Row 65 Size: 38 +Pos 1: 0 +Data: 65aaa +Pos 2: 5 +Data: a6565aaaaaaa +Row 66 Size: 38 +Pos 1: 0 +Data: 66aaa +Pos 2: 5 +Data: a6666aaaaaaa +Row 67 Size: 38 +Pos 1: 0 +Data: 67aaa +Pos 2: 5 +Data: a6767aaaaaaa +Row 68 Size: 38 +Pos 1: 0 +Data: 68aaa +Pos 2: 5 +Data: a6868aaaaaaa +Row 69 Size: 38 +Pos 1: 0 +Data: 69aaa +Pos 2: 5 +Data: a6969aaaaaaa +Row 70 Size: 38 +Pos 1: 0 +Data: 70aaa +Pos 2: 5 +Data: a7070aaaaaaa +Row 71 Size: 38 +Pos 1: 0 +Data: 71aaa +Pos 2: 5 +Data: a7171aaaaaaa +Row 72 Size: 38 +Pos 1: 0 +Data: 72aaa +Pos 2: 5 +Data: a7272aaaaaaa +Row 73 Size: 38 +Pos 1: 0 +Data: 73aaa +Pos 2: 5 +Data: a7373aaaaaaa +Row 74 Size: 38 +Pos 1: 0 +Data: 74aaa +Pos 2: 5 +Data: a7474aaaaaaa +Row 75 Size: 38 +Pos 1: 0 +Data: 75aaa +Pos 2: 5 +Data: a7575aaaaaaa +Row 76 Size: 38 +Pos 1: 0 +Data: 76aaa +Pos 2: 5 +Data: a7676aaaaaaa +Row 77 Size: 38 +Pos 1: 0 +Data: 77aaa +Pos 2: 5 +Data: a7777aaaaaaa +Row 78 Size: 38 +Pos 1: 0 +Data: 78aaa +Pos 2: 5 +Data: a7878aaaaaaa +Row 79 Size: 38 +Pos 1: 0 +Data: 79aaa +Pos 2: 5 +Data: a7979aaaaaaa +Row 80 Size: 38 +Pos 1: 0 +Data: 80aaa +Pos 2: 5 +Data: a8080aaaaaaa +Row 81 Size: 38 +Pos 1: 0 +Data: 81aaa +Pos 2: 5 +Data: a8181aaaaaaa +Row 82 Size: 38 +Pos 1: 0 +Data: 82aaa +Pos 2: 5 +Data: a8282aaaaaaa +Row 83 Size: 38 +Pos 1: 0 +Data: 83aaa +Pos 2: 5 +Data: a8383aaaaaaa +Row 84 Size: 38 +Pos 1: 0 +Data: 84aaa +Pos 2: 5 +Data: a8484aaaaaaa +Row 85 Size: 38 +Pos 1: 0 +Data: 85aaa +Pos 2: 5 +Data: a8585aaaaaaa +Row 86 Size: 38 +Pos 1: 0 +Data: 86aaa +Pos 2: 5 +Data: a8686aaaaaaa +Row 87 Size: 38 +Pos 1: 0 +Data: 87aaa +Pos 2: 5 +Data: a8787aaaaaaa +Row 88 Size: 38 +Pos 1: 0 +Data: 88aaa +Pos 2: 5 +Data: a8888aaaaaaa +Row 89 Size: 38 +Pos 1: 0 +Data: 89aaa +Pos 2: 5 +Data: a8989aaaaaaa +Row 90 Size: 38 +Pos 1: 0 +Data: 90aaa +Pos 2: 5 +Data: a9090aaaaaaa +Row 91 Size: 38 +Pos 1: 0 +Data: 91aaa +Pos 2: 5 +Data: a9191aaaaaaa +Row 92 Size: 38 +Pos 1: 0 +Data: 92aaa +Pos 2: 5 +Data: a9292aaaaaaa +Row 93 Size: 38 +Pos 1: 0 +Data: 93aaa +Pos 2: 5 +Data: a9393aaaaaaa +Row 94 Size: 38 +Pos 1: 0 +Data: 94aaa +Pos 2: 5 +Data: a9494aaaaaaa +Row 95 Size: 38 +Pos 1: 0 +Data: 95aaa +Pos 2: 5 +Data: a9595aaaaaaa +Row 96 Size: 38 +Pos 1: 0 +Data: 96aaa +Pos 2: 5 +Data: a9696aaaaaaa +Row 97 Size: 38 +Pos 1: 0 +Data: 97aaa +Pos 2: 5 +Data: a9797aaaaaaa +Row 98 Size: 38 +Pos 1: 0 +Data: 98aaa +Pos 2: 5 +Data: a9898aaaaaaa +Row 99 Size: 38 +Pos 1: 0 +Data: 99aaa +Pos 2: 5 +Data: a9999aaaaaaa +Row 100 Size: 41 +Pos 1: 0 +Data: 100aa +Pos 2: 5 +Data: aa100100aaaa +Row 101 Size: 41 +Pos 1: 0 +Data: 101aa +Pos 2: 5 +Data: aa101101aaaa +Row 102 Size: 41 +Pos 1: 0 +Data: 102aa +Pos 2: 5 +Data: aa102102aaaa +Row 103 Size: 41 +Pos 1: 0 +Data: 103aa +Pos 2: 5 +Data: aa103103aaaa +Row 104 Size: 41 +Pos 1: 0 +Data: 104aa +Pos 2: 5 +Data: aa104104aaaa +Row 105 Size: 41 +Pos 1: 0 +Data: 105aa +Pos 2: 5 +Data: aa105105aaaa +Row 106 Size: 41 +Pos 1: 0 +Data: 106aa +Pos 2: 5 +Data: aa106106aaaa +Row 107 Size: 41 +Pos 1: 0 +Data: 107aa +Pos 2: 5 +Data: aa107107aaaa +Row 108 Size: 41 +Pos 1: 0 +Data: 108aa +Pos 2: 5 +Data: aa108108aaaa +Row 109 Size: 41 +Pos 1: 0 +Data: 109aa +Pos 2: 5 +Data: aa109109aaaa +Row 110 Size: 41 +Pos 1: 0 +Data: 110aa +Pos 2: 5 +Data: aa110110aaaa +Row 111 Size: 41 +Pos 1: 0 +Data: 111aa +Pos 2: 5 +Data: aa111111aaaa +Row 112 Size: 41 +Pos 1: 0 +Data: 112aa +Pos 2: 5 +Data: aa112112aaaa +Row 113 Size: 41 +Pos 1: 0 +Data: 113aa +Pos 2: 5 +Data: aa113113aaaa +Row 114 Size: 41 +Pos 1: 0 +Data: 114aa +Pos 2: 5 +Data: aa114114aaaa +Row 115 Size: 41 +Pos 1: 0 +Data: 115aa +Pos 2: 5 +Data: aa115115aaaa +Row 116 Size: 41 +Pos 1: 0 +Data: 116aa +Pos 2: 5 +Data: aa116116aaaa +Row 117 Size: 41 +Pos 1: 0 +Data: 117aa +Pos 2: 5 +Data: aa117117aaaa +Row 118 Size: 41 +Pos 1: 0 +Data: 118aa +Pos 2: 5 +Data: aa118118aaaa +Row 119 Size: 41 +Pos 1: 0 +Data: 119aa +Pos 2: 5 +Data: aa119119aaaa +Row 120 Size: 41 +Pos 1: 0 +Data: 120aa +Pos 2: 5 +Data: aa120120aaaa +Row 121 Size: 41 +Pos 1: 0 +Data: 121aa +Pos 2: 5 +Data: aa121121aaaa +Row 122 Size: 41 +Pos 1: 0 +Data: 122aa +Pos 2: 5 +Data: aa122122aaaa +Row 123 Size: 41 +Pos 1: 0 +Data: 123aa +Pos 2: 5 +Data: aa123123aaaa +Row 124 Size: 41 +Pos 1: 0 +Data: 124aa +Pos 2: 5 +Data: aa124124aaaa +Row 125 Size: 41 +Pos 1: 0 +Data: 125aa +Pos 2: 5 +Data: aa125125aaaa +Row 126 Size: 41 +Pos 1: 0 +Data: 126aa +Pos 2: 5 +Data: aa126126aaaa +Row 127 Size: 41 +Pos 1: 0 +Data: 127aa +Pos 2: 5 +Data: aa127127aaaa +Row 128 Size: 41 +Pos 1: 0 +Data: 128aa +Pos 2: 5 +Data: aa128128aaaa +Row 129 Size: 41 +Pos 1: 0 +Data: 129aa +Pos 2: 5 +Data: aa129129aaaa +Row 130 Size: 41 +Pos 1: 0 +Data: 130aa +Pos 2: 5 +Data: aa130130aaaa +Row 131 Size: 41 +Pos 1: 0 +Data: 131aa +Pos 2: 5 +Data: aa131131aaaa +Row 132 Size: 41 +Pos 1: 0 +Data: 132aa +Pos 2: 5 +Data: aa132132aaaa +Row 133 Size: 41 +Pos 1: 0 +Data: 133aa +Pos 2: 5 +Data: aa133133aaaa +Row 134 Size: 41 +Pos 1: 0 +Data: 134aa +Pos 2: 5 +Data: aa134134aaaa +Row 135 Size: 41 +Pos 1: 0 +Data: 135aa +Pos 2: 5 +Data: aa135135aaaa +Row 136 Size: 41 +Pos 1: 0 +Data: 136aa +Pos 2: 5 +Data: aa136136aaaa +Row 137 Size: 41 +Pos 1: 0 +Data: 137aa +Pos 2: 5 +Data: aa137137aaaa +Row 138 Size: 41 +Pos 1: 0 +Data: 138aa +Pos 2: 5 +Data: aa138138aaaa +Row 139 Size: 41 +Pos 1: 0 +Data: 139aa +Pos 2: 5 +Data: aa139139aaaa +Row 140 Size: 41 +Pos 1: 0 +Data: 140aa +Pos 2: 5 +Data: aa140140aaaa +Row 141 Size: 41 +Pos 1: 0 +Data: 141aa +Pos 2: 5 +Data: aa141141aaaa +Row 142 Size: 41 +Pos 1: 0 +Data: 142aa +Pos 2: 5 +Data: aa142142aaaa +Row 143 Size: 41 +Pos 1: 0 +Data: 143aa +Pos 2: 5 +Data: aa143143aaaa +Row 144 Size: 41 +Pos 1: 0 +Data: 144aa +Pos 2: 5 +Data: aa144144aaaa +Row 145 Size: 41 +Pos 1: 0 +Data: 145aa +Pos 2: 5 +Data: aa145145aaaa +Row 146 Size: 41 +Pos 1: 0 +Data: 146aa +Pos 2: 5 +Data: aa146146aaaa +Row 147 Size: 41 +Pos 1: 0 +Data: 147aa +Pos 2: 5 +Data: aa147147aaaa +Row 148 Size: 41 +Pos 1: 0 +Data: 148aa +Pos 2: 5 +Data: aa148148aaaa +Row 149 Size: 41 +Pos 1: 0 +Data: 149aa +Pos 2: 5 +Data: aa149149aaaa +Row 150 Size: 41 +Pos 1: 0 +Data: 150aa +Pos 2: 5 +Data: aa150150aaaa +Row 151 Size: 41 +Pos 1: 0 +Data: 151aa +Pos 2: 5 +Data: aa151151aaaa +Row 152 Size: 41 +Pos 1: 0 +Data: 152aa +Pos 2: 5 +Data: aa152152aaaa +Row 153 Size: 41 +Pos 1: 0 +Data: 153aa +Pos 2: 5 +Data: aa153153aaaa +Row 154 Size: 41 +Pos 1: 0 +Data: 154aa +Pos 2: 5 +Data: aa154154aaaa +Row 155 Size: 41 +Pos 1: 0 +Data: 155aa +Pos 2: 5 +Data: aa155155aaaa +Row 156 Size: 41 +Pos 1: 0 +Data: 156aa +Pos 2: 5 +Data: aa156156aaaa +Row 157 Size: 41 +Pos 1: 0 +Data: 157aa +Pos 2: 5 +Data: aa157157aaaa +Row 158 Size: 41 +Pos 1: 0 +Data: 158aa +Pos 2: 5 +Data: aa158158aaaa +Row 159 Size: 41 +Pos 1: 0 +Data: 159aa +Pos 2: 5 +Data: aa159159aaaa +Row 160 Size: 41 +Pos 1: 0 +Data: 160aa +Pos 2: 5 +Data: aa160160aaaa +Row 161 Size: 41 +Pos 1: 0 +Data: 161aa +Pos 2: 5 +Data: aa161161aaaa +Row 162 Size: 41 +Pos 1: 0 +Data: 162aa +Pos 2: 5 +Data: aa162162aaaa +Row 163 Size: 41 +Pos 1: 0 +Data: 163aa +Pos 2: 5 +Data: aa163163aaaa +Row 164 Size: 41 +Pos 1: 0 +Data: 164aa +Pos 2: 5 +Data: aa164164aaaa +Row 165 Size: 41 +Pos 1: 0 +Data: 165aa +Pos 2: 5 +Data: aa165165aaaa +Row 166 Size: 41 +Pos 1: 0 +Data: 166aa +Pos 2: 5 +Data: aa166166aaaa +Row 167 Size: 41 +Pos 1: 0 +Data: 167aa +Pos 2: 5 +Data: aa167167aaaa +Row 168 Size: 41 +Pos 1: 0 +Data: 168aa +Pos 2: 5 +Data: aa168168aaaa +Row 169 Size: 41 +Pos 1: 0 +Data: 169aa +Pos 2: 5 +Data: aa169169aaaa +Row 170 Size: 41 +Pos 1: 0 +Data: 170aa +Pos 2: 5 +Data: aa170170aaaa +Row 171 Size: 41 +Pos 1: 0 +Data: 171aa +Pos 2: 5 +Data: aa171171aaaa +Row 172 Size: 41 +Pos 1: 0 +Data: 172aa +Pos 2: 5 +Data: aa172172aaaa +Row 173 Size: 41 +Pos 1: 0 +Data: 173aa +Pos 2: 5 +Data: aa173173aaaa +Row 174 Size: 41 +Pos 1: 0 +Data: 174aa +Pos 2: 5 +Data: aa174174aaaa +Row 175 Size: 41 +Pos 1: 0 +Data: 175aa +Pos 2: 5 +Data: aa175175aaaa +Row 176 Size: 41 +Pos 1: 0 +Data: 176aa +Pos 2: 5 +Data: aa176176aaaa +Row 177 Size: 41 +Pos 1: 0 +Data: 177aa +Pos 2: 5 +Data: aa177177aaaa +Row 178 Size: 41 +Pos 1: 0 +Data: 178aa +Pos 2: 5 +Data: aa178178aaaa +Row 179 Size: 41 +Pos 1: 0 +Data: 179aa +Pos 2: 5 +Data: aa179179aaaa +Row 180 Size: 41 +Pos 1: 0 +Data: 180aa +Pos 2: 5 +Data: aa180180aaaa +Row 181 Size: 41 +Pos 1: 0 +Data: 181aa +Pos 2: 5 +Data: aa181181aaaa +Row 182 Size: 41 +Pos 1: 0 +Data: 182aa +Pos 2: 5 +Data: aa182182aaaa +Row 183 Size: 41 +Pos 1: 0 +Data: 183aa +Pos 2: 5 +Data: aa183183aaaa +Row 184 Size: 41 +Pos 1: 0 +Data: 184aa +Pos 2: 5 +Data: aa184184aaaa +Row 185 Size: 41 +Pos 1: 0 +Data: 185aa +Pos 2: 5 +Data: aa185185aaaa +Row 186 Size: 41 +Pos 1: 0 +Data: 186aa +Pos 2: 5 +Data: aa186186aaaa +Row 187 Size: 41 +Pos 1: 0 +Data: 187aa +Pos 2: 5 +Data: aa187187aaaa +Row 188 Size: 41 +Pos 1: 0 +Data: 188aa +Pos 2: 5 +Data: aa188188aaaa +Row 189 Size: 41 +Pos 1: 0 +Data: 189aa +Pos 2: 5 +Data: aa189189aaaa +Row 190 Size: 41 +Pos 1: 0 +Data: 190aa +Pos 2: 5 +Data: aa190190aaaa +Row 191 Size: 41 +Pos 1: 0 +Data: 191aa +Pos 2: 5 +Data: aa191191aaaa +Row 192 Size: 41 +Pos 1: 0 +Data: 192aa +Pos 2: 5 +Data: aa192192aaaa +Row 193 Size: 41 +Pos 1: 0 +Data: 193aa +Pos 2: 5 +Data: aa193193aaaa +Row 194 Size: 41 +Pos 1: 0 +Data: 194aa +Pos 2: 5 +Data: aa194194aaaa +Row 195 Size: 41 +Pos 1: 0 +Data: 195aa +Pos 2: 5 +Data: aa195195aaaa +Row 196 Size: 41 +Pos 1: 0 +Data: 196aa +Pos 2: 5 +Data: aa196196aaaa +Row 197 Size: 41 +Pos 1: 0 +Data: 197aa +Pos 2: 5 +Data: aa197197aaaa +Row 198 Size: 41 +Pos 1: 0 +Data: 198aa +Pos 2: 5 +Data: aa198198aaaa +Row 199 Size: 41 +Pos 1: 0 +Data: 199aa +Pos 2: 5 +Data: aa199199aaaa +Done diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt new file mode 100644 index 0000000..aa1ea98 --- /dev/null +++ b/ext/oci8/tests/lob_041.phpt @@ -0,0 +1,87 @@ +--TEST-- +Check LOBS are valid after statement free +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$stmtarray = array( + "DROP table lob_041_tab", + "CREATE table lob_041_tab(c1 CLOB)", + "INSERT INTO lob_041_tab VALUES('test data')" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Test 1 - explicit statement close\n"; + +$s = oci_parse($c, "SELECT C1 FROM lob_041_tab"); +$desc = oci_new_descriptor($c, OCI_DTYPE_LOB); +oci_define_by_name($s, "C1", $desc); +oci_execute($s); +$data = oci_fetch_assoc($s); +oci_free_statement($s); +echo $data['C1']->load(), "\n"; +oci_free_descriptor($desc); + +echo "\nTest 2 - implicit statement close\n"; + +$s = oci_parse($c, "SELECT C1 FROM lob_041_tab"); +$desc = oci_new_descriptor($c, OCI_DTYPE_LOB); +oci_define_by_name($s, "C1", $desc); +oci_execute($s); +$data = oci_fetch_assoc($s); +$s = null; +echo $data['C1']->load(), "\n"; +oci_free_descriptor($desc); +var_dump($desc); + +echo "\nTest 3 - no preallocated descriptor\n"; + +$s = oci_parse($c, "SELECT C1 FROM lob_041_tab"); +oci_execute($s); +$data = oci_fetch_assoc($s); +$s = null; +echo $data['C1']->load(), "\n"; +var_dump($data); + +// Cleanup + +echo "Done\n"; + +$stmtarray = array( + "DROP table lob_041_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> + +--EXPECTF-- +Test 1 - explicit statement close +test data + +Test 2 - implicit statement close +test data +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} + +Test 3 - no preallocated descriptor +test data +array(1) { + ["C1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +Done diff --git a/ext/oci8/tests/lob_042.phpt b/ext/oci8/tests/lob_042.phpt new file mode 100644 index 0000000..264c610 --- /dev/null +++ b/ext/oci8/tests/lob_042.phpt @@ -0,0 +1,72 @@ +--TEST-- +Check various LOB error messages +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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->writeTemporary("test", OCI_D_LOB)); + +$str = "string"; +var_dump($blob->write($str)); +var_dump($blob->truncate(1)); +var_dump($blob->truncate(1)); +var_dump($blob->truncate(2)); +var_dump($blob->truncate(-1)); +var_dump($blob->read(2)); + +var_dump($blob->import("does_not_exist")); +var_dump($blob->saveFile("does_not_exist")); + +require(dirname(__FILE__).'/drop_table.inc'); + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} + +Warning: OCI-Lob::writetemporary(): Invalid temporary lob type: %d in %s on line %d +bool(false) +int(6) +bool(true) +bool(true) + +Warning: OCI-Lob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d +bool(false) + +Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +bool(false) + +Warning: OCI-Lob::read(): Offset must be less than size of the LOB in %s on line %d +bool(false) + +Warning: OCI-Lob::import(): Can't open file %s in %s on line %d +bool(false) + +Warning: OCI-Lob::savefile(): Can't open file %s in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/lob_043.phpt b/ext/oci8/tests/lob_043.phpt new file mode 100644 index 0000000..4cd1595 --- /dev/null +++ b/ext/oci8/tests/lob_043.phpt @@ -0,0 +1,88 @@ +--TEST-- +Bug #49560 (LOB resource destructor and refcount test) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table lob_043_tab", + "create table lob_043_tab(id number, c1 clob)", + "begin + for i in 1..50000 loop + insert into lob_043_tab (id, c1) values (i, i || ' abcdefghijklmnopq'); + end loop; + end;", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +function f1($c) +{ + $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id'); + oci_execute($s); + $r = array(); + while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC+OCI_RETURN_LOBS)) !== false) { + $r[] = $row['C1']; + } + echo "f1 ended\n"; + return $r; +} + +function f2($c) +{ + $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id'); + oci_execute($s); + $r = array(); + while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC)) !== false) { + $r[] = $row['C1']; + } + echo "f2 ended\n"; + return $r; +} + +echo "Test 1\n"; +$r = f1($c); +/* + foreach ($r as $v) { + echo $v, "\n"; + } +*/ + +echo "Test 2\n"; +$r = f2($c); +/* + foreach ($r as $v) { + echo $v->load(), "\n"; + } +*/ + +// Clean up + +$stmtarray = array( + "drop table lob_043_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +f1 ended +Test 2 +f2 ended +===DONE=== diff --git a/ext/oci8/tests/lob_044.phpt b/ext/oci8/tests/lob_044.phpt new file mode 100644 index 0000000..28599cc --- /dev/null +++ b/ext/oci8/tests/lob_044.phpt @@ -0,0 +1,73 @@ +--TEST-- +oci_lob_truncate() with default parameter value +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table lob_044_tab", + "create table lob_044_tab (blob BLOB)", +); + +oci8_test_sql_execute($c, $stmtarray); + + +// Run Test + +echo "Test 1 - truncate on insert\n"; + +$s = oci_parse($c, "INSERT INTO lob_044_tab (blob) VALUES (empty_blob()) RETURNING blob INTO :v_blob "); +$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->write("this is a biiiig faaat test string. why are you reading it, I wonder? =)")); +var_dump($blob->seek(0)); +var_dump($blob->read(10000)); +var_dump($blob->truncate()); +var_dump($blob->seek(0)); +var_dump($blob->read(10000)); + +oci_commit($c); + + +// Read it back + +echo "\nTest 2 - read it back\n"; + +$s = oci_parse($c, "SELECT blob FROM lob_044_tab FOR UPDATE"); +oci_execute($s, OCI_DEFAULT); +$row = oci_fetch_array($s); +var_dump($row[0]->read(10000)); + +// Clean up + +$stmtarray = array( + "drop table lob_044_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - truncate on insert +int(72) +bool(true) +string(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)" +bool(true) +bool(true) +string(0) "" + +Test 2 - read it back +string(0) "" +===DONE=== diff --git a/ext/oci8/tests/lob_aliases.phpt b/ext/oci8/tests/lob_aliases.phpt new file mode 100644 index 0000000..3ece9a5 --- /dev/null +++ b/ext/oci8/tests/lob_aliases.phpt @@ -0,0 +1,102 @@ +--TEST-- +LOB method aliases +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/lob_null.phpt b/ext/oci8/tests/lob_null.phpt new file mode 100644 index 0000000..be3e534 --- /dev/null +++ b/ext/oci8/tests/lob_null.phpt @@ -0,0 +1,268 @@ +--TEST-- +Test null data for CLOBs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +// Initialization + +$s = oci_parse($c, 'drop table lob_null_tab'); +@oci_execute($s); + +$s = oci_parse($c, 'create table lob_null_tab (id number, data clob)'); +oci_execute($s); + +$s = oci_parse($c, +'create or replace procedure lob_null_proc_in (pid in number, pdata in CLOB) + as begin + insert into lob_null_tab (id, data) values (pid, pdata); + end;'); +oci_execute($s); + +$s = oci_parse($c, +'create or replace procedure lob_null_proc_out (pid in number, pdata out clob) + as begin + select data into pdata from lob_null_tab where id = pid; + end;'); +oci_execute($s); + +// TEMPORARY CLOB + +echo "Temporary CLOB: NULL\n"; +$s = oci_parse($c, "insert into lob_null_tab values (1, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary(null); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +echo "Temporary CLOB: ''\n"; +$s = oci_parse($c, "insert into lob_null_tab values (2, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary(''); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +echo "Temporary CLOB: text\n"; +$s = oci_parse($c, "insert into lob_null_tab values (3, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary('Inserted via SQL statement'); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +// PROCEDURE PARAMETER + +echo "Procedure parameter: NULL\n"; +$s = oci_parse($c, "call lob_null_proc_in(4, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary(null); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +echo "Procedure parameter: ''\n"; +$s = oci_parse($c, "call lob_null_proc_in(5, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary(''); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +echo "Procedure parameter: text\n"; +$s = oci_parse($c, "call lob_null_proc_in(6, :b)"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary('Inserted via procedure parameter'); +$r = @oci_execute($s); +if (!$r) { + $m = oci_error($s); + echo $m['message'], "\n"; +} +else { + $lob->close(); +} + +// RETURNING INTO + +echo "RETURNING INTO: null\n"; +$s = oci_parse($c, "insert into lob_null_tab values (7, empty_clob()) returning data into :b"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +oci_execute($s, OCI_DEFAULT); // Must have OCI_DEFAULT here so locator is still valid +$lob->save(null); + +echo "RETURNING INTO: ''\n"; +$s = oci_parse($c, "insert into lob_null_tab values (8, empty_clob()) returning data into :b"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +oci_execute($s, OCI_DEFAULT); // Must have OCI_DEFAULT here so locator is still valid +$lob->save(''); + +echo "RETURNING INTO: text\n"; +$s = oci_parse($c, "insert into lob_null_tab values (9, empty_clob()) returning data into :b"); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); +oci_execute($s, OCI_DEFAULT); // Must have OCI_DEFAULT here so locator is still valid +$lob->save('Inserted with RETURNING INTO'); + +echo "Fetch as string\n"; +$s = oci_parse ($c, 'select id, data from lob_null_tab order by id'); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +echo "\nFetch as a descriptor\n"; +$s = oci_parse ($c, 'select id, data from lob_null_tab order by id'); +oci_execute($s); +while ($arr = oci_fetch_assoc($s)) { + if (is_object($arr['DATA'])) { + echo $arr['ID'] . " is an object: "; + $r = $arr['DATA']->load(); + var_dump($r); + } + else { + echo $arr['ID'] . " is not an object\n"; + } +} + +echo "\nFetch via the procedure parameter\n"; +for ($i = 1; $i <= 9; $i++) +{ + $s = oci_parse ($c, "call lob_null_proc_out($i, :b)"); + $lob = oci_new_descriptor($c, OCI_D_LOB); + oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB); + oci_execute($s); + if (is_object($lob)) { + echo $i . " is an object: "; + $r = $lob->load(); + var_dump($r); + } + else { + echo $i . " is not an object\n"; + } +} + +// Cleanup + +$s = oci_parse($c, 'drop table lob_null_tab'); +@oci_execute($s); + +echo "Done\n"; + +?> +--EXPECTF-- +Temporary CLOB: NULL +Temporary CLOB: '' +Temporary CLOB: text +Procedure parameter: NULL +Procedure parameter: '' +Procedure parameter: text +RETURNING INTO: null +RETURNING INTO: '' +RETURNING INTO: text +Fetch as string +array(2) { + ["ID"]=> + array(9) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" + [5]=> + string(1) "6" + [6]=> + string(1) "7" + [7]=> + string(1) "8" + [8]=> + string(1) "9" + } + ["DATA"]=> + array(9) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(26) "Inserted via SQL statement" + [3]=> + string(0) "" + [4]=> + string(0) "" + [5]=> + string(32) "Inserted via procedure parameter" + [6]=> + string(0) "" + [7]=> + string(0) "" + [8]=> + string(28) "Inserted with RETURNING INTO" + } +} + +Fetch as a descriptor +1 is an object: string(0) "" +2 is an object: string(0) "" +3 is an object: string(26) "Inserted via SQL statement" +4 is an object: string(0) "" +5 is an object: string(0) "" +6 is an object: string(32) "Inserted via procedure parameter" +7 is an object: string(0) "" +8 is an object: string(0) "" +9 is an object: string(28) "Inserted with RETURNING INTO" + +Fetch via the procedure parameter +1 is an object: string(0) "" +2 is an object: string(0) "" +3 is an object: string(26) "Inserted via SQL statement" +4 is an object: string(0) "" +5 is an object: string(0) "" +6 is an object: string(32) "Inserted via procedure parameter" +7 is an object: string(0) "" +8 is an object: string(0) "" +9 is an object: string(28) "Inserted with RETURNING INTO" +Done
\ No newline at end of file diff --git a/ext/oci8/tests/lob_temp.phpt b/ext/oci8/tests/lob_temp.phpt new file mode 100644 index 0000000..9a07fb5 --- /dev/null +++ b/ext/oci8/tests/lob_temp.phpt @@ -0,0 +1,39 @@ +--TEST-- +temporary lobs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->seek(0, SEEK_SET)); +var_dump($blob->read(2)); + +$c = oci_pconnect($user, $password, $dbase); + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->seek(0, SEEK_SET)); +var_dump($blob->read(2)); + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +string(4) "test" +bool(true) +string(2) "te" +bool(true) +string(4) "test" +bool(true) +string(2) "te" +Done diff --git a/ext/oci8/tests/lob_temp1.phpt b/ext/oci8/tests/lob_temp1.phpt new file mode 100644 index 0000000..e27ea6d --- /dev/null +++ b/ext/oci8/tests/lob_temp1.phpt @@ -0,0 +1,35 @@ +--TEST-- +closing temporary lobs +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->close()); + +$c = oci_pconnect($user, $password, $dbase); + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->close()); + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +string(4) "test" +bool(true) +bool(true) +string(4) "test" +bool(true) +Done diff --git a/ext/oci8/tests/minfo.phpt b/ext/oci8/tests/minfo.phpt new file mode 100644 index 0000000..f6b95ff --- /dev/null +++ b/ext/oci8/tests/minfo.phpt @@ -0,0 +1,19 @@ +--TEST-- +Code coverage for PHP_MINFO_FUNCTION(oci) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +ob_start(); +phpinfo(INFO_MODULES); +$v = ob_get_clean(); +$r = strpos($v, 'OCI8 Support => enabled'); +var_dump($r); + +echo "Done\n"; + +?> +--EXPECTF-- +int(%d) +Done diff --git a/ext/oci8/tests/null_byte_1.phpt b/ext/oci8/tests/null_byte_1.phpt new file mode 100644 index 0000000..0869d94 --- /dev/null +++ b/ext/oci8/tests/null_byte_1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Protect against null bytes in LOB filenames +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) + die ("skip no oci8 extension"); +if (PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4)) + die ("skip Test only valid for PHP 5.4 onwards"); +?> +--INI-- +display_errors = On +error_reporting = E_WARNING +--FILE-- +<?php + +// See http://news.php.net/php.internals/50202 +// http://svn.php.net/viewvc?view=revision&revision=311870 + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1: Import\n"; + +$lob = oci_new_descriptor($c, OCI_D_LOB); +$r = $lob->savefile("/tmp/abc\0def"); +var_dump($r); + +echo "Test 2: Export\n"; + +$r = $lob->export("/tmp/abc\0def"); +var_dump($r); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1: Import + +Warning: OCI-Lob::savefile() expects parameter 1 to be a valid path, string given in %snull_byte_1.php on line %d +NULL +Test 2: Export + +Warning: OCI-Lob::export() expects parameter 1 to be a valid path, string given in %snull_byte_1.php on line %d +NULL +===DONE=== diff --git a/ext/oci8/tests/null_byte_2.phpt b/ext/oci8/tests/null_byte_2.phpt new file mode 100644 index 0000000..01fb872 --- /dev/null +++ b/ext/oci8/tests/null_byte_2.phpt @@ -0,0 +1,50 @@ +--TEST-- +Null bytes in SQL statements +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--INI-- +display_errors = On +error_reporting = E_WARNING +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1: Valid use of a null byte\n"; + +$s = oci_parse($c, "select * \0from dual"); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +echo "Test 3: Using a null byte in a bind variable name\n"; + +$s = oci_parse($c, "select * from dual where :bv = 1"); +$bv = 1; +oci_bind_by_name($s, ":bv\0:bv", $bv); +oci_execute($s); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1: Valid use of a null byte +array(1) { + ["DUMMY"]=> + array(1) { + [0]=> + string(1) "X" + } +} +Test 3: Using a null byte in a bind variable name + +Warning: oci_bind_by_name(): ORA-01036: %s in %snull_byte_2.php on line %d + +Warning: oci_execute(): ORA-01008: %s in %snull_byte_2.php on line %d +===DONE=== diff --git a/ext/oci8/tests/null_byte_3.phpt b/ext/oci8/tests/null_byte_3.phpt new file mode 100644 index 0000000..73d5c26 --- /dev/null +++ b/ext/oci8/tests/null_byte_3.phpt @@ -0,0 +1,42 @@ +--TEST-- +Null bytes in SQL statements +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +display_errors = On +error_reporting = E_WARNING +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1: Invalid use of a null byte\n"; + +$s = oci_parse($c, "select * from du\0al"); +oci_execute($s); + +echo "Test 2: Using a null byte in a bind variable value causing WHERE clause to fail\n"; + +$s = oci_parse($c, "select * from dual where :bv = 'abc'"); +$bv = 'abc\0abc'; +oci_bind_by_name($s, ":bv", $bv); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1: Invalid use of a null byte + +Warning: oci_execute(): ORA-00942: %s in %snull_byte_3.php on line %d +Test 2: Using a null byte in a bind variable value causing WHERE clause to fail +array(1) { + ["DUMMY"]=> + array(0) { + } +} +===DONE=== diff --git a/ext/oci8/tests/num.phpt b/ext/oci8/tests/num.phpt new file mode 100644 index 0000000..0fe85cc --- /dev/null +++ b/ext/oci8/tests/num.phpt @@ -0,0 +1,237 @@ +--TEST-- +oci_num_*() family +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table num_tab", + "create table num_tab (id number, value number)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +var_dump(ocirowcount()); +var_dump(oci_num_rows()); +var_dump(ocinumcols()); +var_dump(oci_num_fields()); + +echo "Test 2\n"; +$insert_sql = "insert into num_tab (id, value) values (1,1)"; +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\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"); + } +} + +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"); +} + +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 num_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + 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 num_tab 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 num_tab 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"); +} + +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)); +var_dump(oci_num_fields($s)); + +$delete_sql = "delete from num_tab"; + +if (!($s = oci_parse($c, $delete_sql))) { + die("oci_parse(delete) failed!\n"); +} + +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)); + + +// Cleanup + +$stmtarray = array( + "drop table num_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--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(2) +int(2) +Test 5c +int(3) +int(3) +int(2) +int(2) +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 new file mode 100644 index 0000000..59eb801 --- /dev/null +++ b/ext/oci8/tests/oci_execute_segfault.phpt @@ -0,0 +1,51 @@ +--TEST-- +oci_execute() segfault after repeated bind of LOB descriptor +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$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, 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); +} + +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/old_oci_close.phpt b/ext/oci8/tests/old_oci_close.phpt new file mode 100644 index 0000000..f15b7fe --- /dev/null +++ b/ext/oci8/tests/old_oci_close.phpt @@ -0,0 +1,23 @@ +--TEST-- +oci8.old_oci_close_semantics On +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump($c); +var_dump(oci_close($c)); +var_dump(oci_parse($c, "select 1 from dual")); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +NULL +resource(%d) of type (oci8 statement) +Done diff --git a/ext/oci8/tests/old_oci_close1.phpt b/ext/oci8/tests/old_oci_close1.phpt new file mode 100644 index 0000000..9af2eeb --- /dev/null +++ b/ext/oci8/tests/old_oci_close1.phpt @@ -0,0 +1,25 @@ +--TEST-- +oci8.old_oci_close_semantics Off +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump($c); +var_dump(oci_close($c)); +var_dump(oci_parse($c, "select 1 from dual")); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +bool(true) + +Warning: oci_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt new file mode 100644 index 0000000..1738702 --- /dev/null +++ b/ext/oci8/tests/password.phpt @@ -0,0 +1,82 @@ +--TEST-- +oci_password_change() for non-persistent connections +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/details.inc"); +if (empty($dbase)) die ("skip requires database connection string be set"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip password change not supported in DRCP Mode"); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop user testuser cascade", + "create user testuser identified by testuserpwd", + "grant connect, create session to testuser" +); + +oci8_test_sql_execute($c, $stmtarray); + + +// Connect and change the password +$c1 = oci_connect("testuser", "testuserpwd", $dbase); +var_dump($c1); +$rn1 = (int)$c1; + +oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); + +// Second connect should return a new resource because the hash string will be different from $c1 +$c2 = oci_connect("testuser", "testuserpwd2", $dbase); +var_dump($c2); +$rn2 = (int)$c2; + +// Despite using the old password this connect should succeed and return the original resource +$c3 = oci_connect("testuser", "testuserpwd", $dbase); +var_dump($c3); +$rn3 = (int)$c3; + +// Connections should differ +if ($rn1 == $rn2) { + echo "First and second connections share a resource: Not OK\n"; + var_dump($c1); +} +else { + echo "First and second connections are different: OK\n"; +} + +// Connections should be the same +if ($rn1 == $rn3) { + echo "First and third connections share a resource: OK\n"; +} +else { + echo "First and third connections are different: Not OK\n"; + var_dump($c1); + var_dump($c2); +} + +echo "Done\n"; + +?> +--CLEAN-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop user testuser cascade" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +First and second connections are different: OK +First and third connections share a resource: OK +Done diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt new file mode 100644 index 0000000..ceba0bb --- /dev/null +++ b/ext/oci8/tests/password_2.phpt @@ -0,0 +1,81 @@ +--TEST-- +oci_password_change() for persistent connections +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/details.inc"); +if (empty($dbase)) die ("skip requires database connection string be set"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip password change not supported in DRCP Mode"); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop user testuser cascade", + "create user testuser identified by testuserpwd", + "grant connect, create session to testuser" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Connect (persistent) and change the password +$c1 = oci_pconnect("testuser", "testuserpwd", $dbase); +var_dump($c1); +$rn1 = (int)$c1; + +oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); + +// Second connect should return a new resource because the hash string will be different from $c1 +$c2 = oci_pconnect("testuser", "testuserpwd2", $dbase); +var_dump($c2); +$rn2 = (int)$c2; + +// Despite using the old password this connect should succeed and return the original resource +$c3 = oci_pconnect("testuser", "testuserpwd", $dbase); +var_dump($c3); +$rn3 = (int)$c3; + +// Connections should differ +if ($rn1 == $rn2) { + echo "First and second connections share a resource: Not OK\n"; + var_dump($c1); +} +else { + echo "First and second connections are different: OK\n"; +} + +// Connections should be the same +if ($rn1 == $rn3) { + echo "First and third connections share a resource: OK\n"; +} +else { + echo "First and third connections are different: Not OK\n"; + var_dump($c1); + var_dump($c2); +} + +echo "Done\n"; + +?> +--CLEAN-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop user testuser cascade" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +First and second connections are different: OK +First and third connections share a resource: OK +Done diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt new file mode 100644 index 0000000..c218d90 --- /dev/null +++ b/ext/oci8/tests/password_new.phpt @@ -0,0 +1,46 @@ +--TEST-- +oci_password_change() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes +require(dirname(__FILE__).'/skipif.inc'); +if (empty($dbase)) die ("skip requires database connection string be set"); +if ($test_drcp) die("skip password change not supported in DRCP Mode"); + +// This test is known to fail with Oracle 10.2.0.4 client libraries +// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) +if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && + preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +} +?> +--FILE-- +<?php + +// This test will diff if either the client or the server is 11.2.0.3 +// (or greater) and the other is 11.2.0.2 (or earlier). Both client +// and server must be upgraded at the same time. + +require dirname(__FILE__)."/connect.inc"; + +$new_password = "test"; +var_dump(oci_password_change($dbase, $user, $password, $new_password)); + +if (!empty($dbase)) { + var_dump($new_c = ocilogon($user,$new_password,$dbase)); +} +else { + var_dump($new_c = ocilogon($user,$new_password)); +} + +var_dump(oci_password_change($dbase, $user, $new_password, $password)); + + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt new file mode 100644 index 0000000..fdbb1f9 --- /dev/null +++ b/ext/oci8/tests/password_old.phpt @@ -0,0 +1,48 @@ +--TEST-- +ocipasswordchange() +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes +require(dirname(__FILE__).'/skipif.inc'); +if (empty($dbase)) die ("skip requires database connection string be set"); +if ($test_drcp) die("skip password change not supported in DRCP Mode"); + +// This test is known to fail with Oracle 10.2.0.4 client libraries +// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) +if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && + preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +} + + +?> +--FILE-- +<?php + +// This test will diff if either the client or the server is 11.2.0.3 +// (or greater) and the other is 11.2.0.2 (or earlier). Both client +// and server must be upgraded at the same time. + +require dirname(__FILE__)."/connect.inc"; + +$new_password = "test"; +var_dump(ocipasswordchange($dbase, $user, $password, $new_password)); + +if (!empty($dbase)) { + var_dump($new_c = ocilogon($user,$new_password,$dbase)); +} +else { + var_dump($new_c = ocilogon($user,$new_password)); +} + +var_dump(ocipasswordchange($dbase, $user, $new_password, $password)); + + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/pecl_bug10194.phpt b/ext/oci8/tests/pecl_bug10194.phpt new file mode 100644 index 0000000..3c1c788 --- /dev/null +++ b/ext/oci8/tests/pecl_bug10194.phpt @@ -0,0 +1,54 @@ +--TEST-- +PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} +?> +--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%s(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 0000000..96f94bc --- /dev/null +++ b/ext/oci8/tests/pecl_bug10194_blob.phpt @@ -0,0 +1,58 @@ +--TEST-- +PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only"); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} +?> +--INI-- +memory_limit=3M +--FILE-- +<?php + +// This test is dependent on the behavior of the memory manager + +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); + +echo "Before load()\n"; + +$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-- +Before load() + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/ext/oci8/tests/pecl_bug10194_blob_64.phpt b/ext/oci8/tests/pecl_bug10194_blob_64.phpt new file mode 100644 index 0000000..e1a4cc0 --- /dev/null +++ b/ext/oci8/tests/pecl_bug10194_blob_64.phpt @@ -0,0 +1,59 @@ +--TEST-- +PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes +require(dirname(__FILE__).'/skipif.inc'); +if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} +?> +--INI-- +memory_limit=6M +--FILE-- +<?php + +// This test is dependent on the behavior of the memory manager + +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); + +echo "Before load()\n"; + +$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-- +Before load() + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/ext/oci8/tests/pecl_bug16035.phpt b/ext/oci8/tests/pecl_bug16035.phpt new file mode 100644 index 0000000..ddd0038 --- /dev/null +++ b/ext/oci8/tests/pecl_bug16035.phpt @@ -0,0 +1,32 @@ +--TEST-- +PECL Bug #16035 (Crash with Oracle 10.2 connecting with a character set but ORACLE_HOME is not set) +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +ob_start(); +phpinfo(INFO_MODULES); +$phpinfo = ob_get_clean(); +$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); +if ($ov !== 1) { + die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); +} +if (preg_match('/Unknown/', oci_client_version()) == 1) { + die("skip expected output only valid with Oracle clients > 9gR2"); +} +?> +--ENV-- +ORACLE_HOME="" +--FILE-- +<?php + +oci_connect('abc', 'def', 'ghi', 'jkl'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d + +Warning: oci_connect(): Error while trying to retrieve text for error ORA-01804 + in %specl_bug16035.php on line %d +===DONE=== diff --git a/ext/oci8/tests/pecl_bug16842.phpt b/ext/oci8/tests/pecl_bug16842.phpt new file mode 100644 index 0000000..ca24d0d --- /dev/null +++ b/ext/oci8/tests/pecl_bug16842.phpt @@ -0,0 +1,73 @@ +--TEST-- +PECL Bug #16842 (NO_DATA_FOUND exception is a warning) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--INI-- +error_reporting = E_WARNING +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1\n"; + +echo "Raises NO_DATA_FOUND\n"; +$s = oci_parse($c, 'begin raise NO_DATA_FOUND; end;'); +$e = oci_execute($s); +var_dump($e); +var_dump(oci_error($s)); + +echo "Test 2\n"; + +echo "Raises ZERO_DIVIDE\n"; +$s = oci_parse($c, 'begin raise ZERO_DIVIDE; end;'); +$e = oci_execute($s); +var_dump($e); +var_dump(oci_error($s)); + +oci_close($c); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +Raises NO_DATA_FOUND + +Warning: oci_execute(): ORA-01403: %s +ORA-06512: at line %d in %specl_bug16842.php on line %d +bool(false) +array(4) { + ["code"]=> + int(1403) + ["message"]=> + string(%d) "ORA-01403: %s +ORA-06512: at line 1" + ["offset"]=> + int(0) + ["sqltext"]=> + string(31) "begin raise NO_DATA_FOUND; end;" +} +Test 2 +Raises ZERO_DIVIDE + +Warning: oci_execute(): ORA-01476: %s +ORA-06512: at line 1 in %s on line 19 +bool(false) +array(4) { + ["code"]=> + int(1476) + ["message"]=> + string(%d) "ORA-01476: %s +ORA-06512: at line 1" + ["offset"]=> + int(0) + ["sqltext"]=> + string(29) "begin raise ZERO_DIVIDE; end;" +} +===DONE=== diff --git a/ext/oci8/tests/pecl_bug6109.phpt b/ext/oci8/tests/pecl_bug6109.phpt new file mode 100644 index 0000000..d0762fa --- /dev/null +++ b/ext/oci8/tests/pecl_bug6109.phpt @@ -0,0 +1,40 @@ +--TEST-- +PECL Bug #6109 (Error messages not kept) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, 'delete from table_does_not_exist'); +$r = @oci_execute($s); + +if ($r) { + echo "whoops - table does exist\n"; +} else { + for ($i = 0; $i < 5; $i++) { + $err = oci_error($s); + echo ($i) .' -> '.$err['message'] ."\n"; + } +} + +// Cleanup + +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1 +0 -> ORA-00942: %s +1 -> ORA-00942: %s +2 -> ORA-00942: %s +3 -> ORA-00942: %s +4 -> ORA-00942: %s +Done diff --git a/ext/oci8/tests/pecl_bug8816.phpt b/ext/oci8/tests/pecl_bug8816.phpt new file mode 100644 index 0000000..71771b2 --- /dev/null +++ b/ext/oci8/tests/pecl_bug8816.phpt @@ -0,0 +1,101 @@ +--TEST-- +PECL Bug #8816 (issue in php_oci_statement_fetch with more than one piecewise column) +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--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/persistent.phpt b/ext/oci8/tests/persistent.phpt new file mode 100644 index 0000000..884cd35 --- /dev/null +++ b/ext/oci8/tests/persistent.phpt @@ -0,0 +1,26 @@ +--TEST-- +reusing persistent connections +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); + +echo "Done\n"; +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/prefetch.phpt b/ext/oci8/tests/prefetch.phpt new file mode 100644 index 0000000..b163a89 --- /dev/null +++ b/ext/oci8/tests/prefetch.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci_set_prefetch() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialize + +$stmtarray = array( + "drop table prefetch_tab", + "create table prefetch_tab (id number, value number)", + "insert into prefetch_tab (id, value) values (1,1)", + "insert into prefetch_tab (id, value) values (1,1)", + "insert into prefetch_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +$select_sql = "select * from prefetch_tab"; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +var_dump(oci_set_prefetch($s, 10)); + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); +var_dump(oci_num_rows($s)); + +// Cleanup + +$stmtarray = array( + "drop table prefetch_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/prefetch_old.phpt b/ext/oci8/tests/prefetch_old.phpt new file mode 100644 index 0000000..ac43771 --- /dev/null +++ b/ext/oci8/tests/prefetch_old.phpt @@ -0,0 +1,56 @@ +--TEST-- +ocisetprefetch() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +$stmtarray = array( + "drop table prefetch_old_tab", + "create table prefetch_old_tab (id number, value number)", + "insert into prefetch_old_tab (id, value) values (1,1)", + "insert into prefetch_old_tab (id, value) values (1,1)", + "insert into prefetch_old_tab (id, value) values (1,1)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +if (!ocicommit($c)) { + die("ocicommit() failed!\n"); +} + +$select_sql = "select * from prefetch_old_tab"; + +if (!($s = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +var_dump(ocisetprefetch($s, 10)); + +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +var_dump(ocifetch($s)); +var_dump(ocirowcount($s)); + + +// Cleanup + +$stmtarray = array( + "drop table prefetch_old_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/privileged_connect.phpt b/ext/oci8/tests/privileged_connect.phpt new file mode 100644 index 0000000..3912224 --- /dev/null +++ b/ext/oci8/tests/privileged_connect.phpt @@ -0,0 +1,25 @@ +--TEST-- +privileged connect tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +oci_connect("", "", "", false, OCI_SYSOPER); +oci_connect("", "", "", false, OCI_SYSDBA); +oci_connect("", "", "", false, -1); +oci_connect("", "", "", false, "qwe"); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_connect(): Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA in %s on line %d + +Warning: oci_connect(): Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA in %s on line %d + +Warning: oci_connect(): Invalid session mode specified (-1) in %s on line %d + +Warning: oci_connect() expects parameter 5 to be long, string given in %s on line %d +Done diff --git a/ext/oci8/tests/privileged_connect1.phpt b/ext/oci8/tests/privileged_connect1.phpt new file mode 100644 index 0000000..44bb2f6 --- /dev/null +++ b/ext/oci8/tests/privileged_connect1.phpt @@ -0,0 +1,27 @@ +--TEST-- +privileged connect tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +oci_connect("", "", "", false, OCI_SYSOPER); +oci_connect("", "", "", false, OCI_SYSDBA); +oci_connect("", "", "", false, -1); +oci_connect("", "", "", false, "qwe"); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_connect(): ORA-%d: %s 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 + +Warning: oci_connect() expects parameter 5 to be long, string given in %s on line %d +Done diff --git a/ext/oci8/tests/refcur_prefetch_1.phpt b/ext/oci8/tests/refcur_prefetch_1.phpt new file mode 100644 index 0000000..ea09fbc --- /dev/null +++ b/ext/oci8/tests/refcur_prefetch_1.phpt @@ -0,0 +1,231 @@ +--TEST-- +Prefetch with REF cursor. Test different values for prefetch with oci_set_prefetch(). +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (preg_match('/Release 1[012]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--FILE-- +<?php +require(dirname(__FILE__)."/connect.inc"); + +// Creates the necessary package and tables. +$stmtarray = array( + "DROP TABLE refcurtest", + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + "CREATE or REPLACE PACKAGE refcurpkg is + type refcursortype is ref cursor; + procedure open_ref_cur(cur1 out refcursortype); + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2); + end refcurpkg;", + "CREATE or REPLACE PACKAGE body refcurpkg is + procedure open_ref_cur(cur1 out refcursortype) is + begin + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, + c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; + end refcurpkg;" + ); + +oci8_test_sql_execute($c, $stmtarray); + +// Insert 500 rows into the table. +$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)"; +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<=500; $i++) { + $val2 = 'test'.$i; + oci_bind_by_name($s,':c1',$i); + oci_bind_by_name($s,':c2',$val2); + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +// Various values for prefetch +$pref = array(0,1,501,499,250,12345,-12345,-1); +foreach($pref as $value) { + echo"-----------------------------------------------\n"; + echo "Test with Prefetch value set to $value \n"; + echo"-----------------------------------------------\n"; + $cur1 = oci_new_cursor($c); + fetch_frm_php($c,$cur1,$value); + fetch_frm_plsql($c,$cur1); +} + + +// This function sets the prefetch count to the given $value and fetches one row . + +function fetch_frm_php($c,$cur1,$value) { + $sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;"; + $s1 = oci_parse($c,$sql1); + if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); + } + oci_execute($s1); + oci_set_prefetch($cur1,$value); + oci_execute($cur1); + echo "Fetch Row from PHP\n"; + var_dump(oci_fetch_row($cur1)); +} + +// This function calls the fetch_ref_cur procedure to get the values from the REF cur. + +function fetch_frm_plsql($c,$cur1) { + $sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;"; + $s2 = oci_parse($c,$sql2); + if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); + } + if (!oci_bind_by_name($s2,":c1",$c1,-1,SQLT_INT)) { + die("oci_bind_by_name(sql2) failed!\n"); + } + if (!oci_bind_by_name($s2,":c2",$c2,20,SQLT_CHR)) { + die("oci_bind_by_name(sql2) failed!\n"); + } + oci_execute($s2); + echo "Fetch Row from PL/SQL\n"; + var_dump($c1); + var_dump($c2); +} + +// Clean up here + +$stmtarray = array( + "drop package refcurpkg", + "drop table refcurtest" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +----------------------------------------------- +Test with Prefetch value set to 0 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(1) +string(%d) "test1" +----------------------------------------------- +Test with Prefetch value set to 1 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(2) +string(%d) "test2" +----------------------------------------------- +Test with Prefetch value set to 501 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} + +Warning: oci_execute(): ORA-01002: %s +ORA-06512: at "%s.REFCURPKG", line %d +ORA-06512: at line %d in %s on line %d +Fetch Row from PL/SQL +int(0) +NULL +----------------------------------------------- +Test with Prefetch value set to 499 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(500) +string(%d) "test500" +----------------------------------------------- +Test with Prefetch value set to 250 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(251) +string(%d) "test251" +----------------------------------------------- +Test with Prefetch value set to 12345 +----------------------------------------------- +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} + +Warning: oci_execute(): ORA-01002: %s +ORA-06512: at "%s.REFCURPKG", line %d +ORA-06512: at line %d in %s on line %d +Fetch Row from PL/SQL +int(0) +NULL +----------------------------------------------- +Test with Prefetch value set to -12345 +----------------------------------------------- + +Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(101) +string(%d) "test101" +----------------------------------------------- +Test with Prefetch value set to -1 +----------------------------------------------- + +Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d +Fetch Row from PHP +array(2) { + [0]=> + string(%d) "0" + [1]=> + string(%d) "test0" +} +Fetch Row from PL/SQL +int(101) +string(%d) "test101" +Done diff --git a/ext/oci8/tests/refcur_prefetch_2.phpt b/ext/oci8/tests/refcur_prefetch_2.phpt new file mode 100644 index 0000000..8d65251 --- /dev/null +++ b/ext/oci8/tests/refcur_prefetch_2.phpt @@ -0,0 +1,220 @@ +--TEST-- +Prefetch with REF cursor. Test No 2 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (preg_match('/Release 1[012]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--FILE-- +<?php +require dirname(__FILE__)."/connect.inc"; + +// Creates the necessary package and tables. +$stmtarray = array( + "DROP TABLE refcurtest", + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + "CREATE or REPLACE PACKAGE refcurpkg is + type refcursortype is ref cursor; + procedure open_ref_cur(cur1 out refcursortype); + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2); + end refcurpkg;", + "CREATE or REPLACE PACKAGE body refcurpkg is + procedure open_ref_cur(cur1 out refcursortype) is + begin + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, + c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; + end refcurpkg;" + ); + +oci8_test_sql_execute($c, $stmtarray); + +// Insert 500 rows into the table. +$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)"; +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i <= 500; $i++) { + $val2 = 'test'.$i; + oci_bind_by_name($s,':c1',$i); + oci_bind_by_name($s,':c2',$val2); + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +// Steps to Fetch from PHP . For every sub-test,the cursor is bound and then executed. + +$sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;"; +$s1 = oci_parse($c,$sql1); +$cur1 = oci_new_cursor($c); +if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); +} + + +// Steps to Fetch from PL/SQL . For every sub-test,the cursor is bound and then executed. + +$sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;"; +$s2 = oci_parse($c,$sql2); +if (!oci_bind_by_name($s2, ":curs1", $cur1, -1, SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +if (!oci_bind_by_name($s2, ":c1", $c1, -1, SQLT_INT)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +if (!oci_bind_by_name($s2, ":c2", $c2, 20, SQLT_CHR)) { + die("oci_bind_by_name(sql2) failed!\n"); +} + + +echo "------Test 1- Check Roundtrips with prefetch 0 and 5 -----------\n"; +oci_execute($s1); +oci_execute($cur1); +$initial_rt = print_roundtrips($c); +oci_set_prefetch($cur1,0); +for ($i = 0;$i<5;$i++) { + var_dump(oci_fetch_row($cur1)); +} + +$cnt = (print_roundtrips($c) - $initial_rt); +echo "Number of roundtrips made with prefetch count 0 for 5 rows is $cnt\n"; + +$initial_rt = print_roundtrips($c); +oci_set_prefetch($cur1,5); +for ($i = 0;$i<5;$i++) { + var_dump(oci_fetch_row($cur1)); +} + +$cnt = (print_roundtrips($c) - $initial_rt ); +echo "Number of roundtrips made with prefetch count 5 for 5 rows is $cnt\n"; + +echo "------Test 2 - Set Prefetch before PL/SQL fetch ----------\n"; +// Fetch from PHP +$cur1 = oci_new_cursor($c); +if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); +} + +echo "Fetch Row from PHP\n"; +oci_execute($s1); +oci_execute($cur1); +var_dump(oci_fetch_row($cur1)); +oci_set_prefetch($cur1,5); + +// Fetch from PL/SQL +if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +oci_execute($s2); +echo "Fetch Row from PL/SQL\n"; +var_dump($c1); +var_dump($c2); + +function print_roundtrips($c) { + $sql_stmt = "select value from v\$mystat a,v\$statname c where + a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; + $s = oci_parse($c,$sql_stmt); + oci_define_by_name($s,"VALUE",$value); + oci_execute($s); + oci_fetch($s); + return $value; +} + +// Clean up here + +$stmtarray = array( + "drop package refcurpkg", + "drop table refcurtest" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +------Test 1- Check Roundtrips with prefetch 0 and 5 ----------- +array(2) { + [0]=> + string(1) "0" + [1]=> + string(5) "test0" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "test1" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "test2" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "test3" +} +array(2) { + [0]=> + string(1) "4" + [1]=> + string(5) "test4" +} +Number of roundtrips made with prefetch count 0 for 5 rows is 6 +array(2) { + [0]=> + string(1) "5" + [1]=> + string(5) "test5" +} +array(2) { + [0]=> + string(1) "6" + [1]=> + string(5) "test6" +} +array(2) { + [0]=> + string(1) "7" + [1]=> + string(5) "test7" +} +array(2) { + [0]=> + string(1) "8" + [1]=> + string(5) "test8" +} +array(2) { + [0]=> + string(1) "9" + [1]=> + string(5) "test9" +} +Number of roundtrips made with prefetch count 5 for 5 rows is 2 +------Test 2 - Set Prefetch before PL/SQL fetch ---------- +Fetch Row from PHP +array(2) { + [0]=> + string(1) "0" + [1]=> + string(5) "test0" +} +Fetch Row from PL/SQL +int(101) +string(%d) "test101" +Done diff --git a/ext/oci8/tests/refcur_prefetch_3.phpt b/ext/oci8/tests/refcur_prefetch_3.phpt new file mode 100644 index 0000000..8c04140 --- /dev/null +++ b/ext/oci8/tests/refcur_prefetch_3.phpt @@ -0,0 +1,137 @@ +--TEST-- +Prefetch with Nested cursors with INI setting. +--INI-- +oci8.default_prefetch=5 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (preg_match('/Release (11\.2|12)\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 11gR2 or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} + +?> +--FILE-- +<?php +require dirname(__FILE__)."/connect.inc"; + +//Create tables here +$stmtarray = array( + "drop table nescurtest", + "create table nescurtest(c1 varchar2(10))" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Insert 500 rows into the table. +$insert_sql = "INSERT INTO nescurtest (c1) VALUES (:c1)"; +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<=500; $i++) { + $val2 = 'test'.$i; + oci_bind_by_name($s,':c1',$val2); + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +echo"-----------------------------------------------\n"; +echo "Test with Nested Cursors\n"; +echo"-----------------------------------------------\n"; +$cur1 = oci_new_cursor($c); +$sqlstmt = "select cursor(select * from nescurtest) curs1 from dual"; +$s = oci_parse($c,$sqlstmt); +oci_execute($s); +$data = oci_fetch_array($s); +oci_execute($data['CURS1']); + +// Calculate round-trips +$initial_rt = print_roundtrips($c); +for ($i = 0;$i<10;$i++) { + echo "Fetch Row using Nested cursor Query\n"; + var_dump(oci_fetch_row($data['CURS1'])); +} + +$cnt = (print_roundtrips($c) - $initial_rt); +echo "Number of roundtrips made with prefetch count 5 for 10 rows is $cnt\n"; + +function print_roundtrips($c) { + $sql_stmt = "select value from v\$mystat a,v\$statname c where + a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; + $s = oci_parse($c,$sql_stmt); + oci_define_by_name($s,"VALUE",$value); + oci_execute($s); + oci_fetch($s); + return $value; +} + +// Clean up here + +$stmtarray = array( + "drop table nescurtest" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +----------------------------------------------- +Test with Nested Cursors +----------------------------------------------- +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test0" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test1" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test2" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test3" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test4" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test5" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test6" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test7" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test8" +} +Fetch Row using Nested cursor Query +array(1) { + [0]=> + %unicode|string%(%d) "test9" +} +Number of roundtrips made with prefetch count 5 for 10 rows is 3 +Done diff --git a/ext/oci8/tests/refcur_prefetch_4.phpt b/ext/oci8/tests/refcur_prefetch_4.phpt new file mode 100644 index 0000000..d24398c --- /dev/null +++ b/ext/oci8/tests/refcur_prefetch_4.phpt @@ -0,0 +1,176 @@ +--TEST-- +Prefetch with REF cursor. Test No 4 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +require(dirname(__FILE__)."/connect.inc"); +if (preg_match('/Release 1[012]\./', oci_server_version($c), $matches) !== 1) { + die("skip expected output only valid when using Oracle 10g or greater databases"); +} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) { + die("skip test expected to work only with Oracle 11gR2 or greater version of client"); +} +?> +--FILE-- +<?php +require dirname(__FILE__)."/connect.inc"; + +// Creates the necessary package and tables. +$stmtarray = array( + "DROP TABLE refcurtest", + + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + + "CREATE or REPLACE PACKAGE refcurpkg is + type refcursortype is ref cursor; + procedure open_ref_cur(cur1 out refcursortype); + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, c2 out varchar2); + end refcurpkg;", + + "CREATE or REPLACE PACKAGE body refcurpkg is + procedure open_ref_cur(cur1 out refcursortype) is + begin + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; + end refcurpkg;" + ); + +oci8_test_sql_execute($c, $stmtarray); + +// Insert 500 rows into the table. +$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)"; +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i <= 500; $i++) { + $val2 = 'test'.$i; + oci_bind_by_name($s,':c1',$i); + oci_bind_by_name($s,':c2',$val2); + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +// Steps to Fetch from PHP . For every sub-test,the cursor is bound and then executed. + +$sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;"; +$s1 = oci_parse($c,$sql1); +$cur1 = oci_new_cursor($c); +if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); +} + + +// Steps to Fetch from PL/SQL . For every sub-test,the cursor is bound and then executed. + +$sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;"; +$s2 = oci_parse($c,$sql2); +if (!oci_bind_by_name($s2, ":curs1", $cur1, -1, SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +if (!oci_bind_by_name($s2, ":c1", $c1, -1, SQLT_INT)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +if (!oci_bind_by_name($s2, ":c2", $c2, 20, SQLT_CHR)) { + die("oci_bind_by_name(sql2) failed!\n"); +} + + +echo "------Test 1 - Set Prefetch after PL/SQL fetch ----------\n"; +$cur1 = oci_new_cursor($c); +// Fetch from PL/SQL +if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +oci_execute($s2); +echo "Fetch Row from PL/SQL\n"; +var_dump($c1); +var_dump($c2); + +// Fetch from PHP +echo "Fetch Row from PHP\n"; +if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); +} +oci_set_prefetch($cur1,5); +oci_execute($s1); +oci_execute($cur1); +var_dump(oci_fetch_row($cur1)); + +echo "------Test 2- Overwrite prefetch-----------\n"; +// Fetch from PHP +$cur1 = oci_new_cursor($c); +if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql1) failed!\n"); +} +echo "Fetch Row from PHP\n"; +oci_execute($s1); +oci_execute($cur1); +var_dump(oci_fetch_row($cur1)); +oci_set_prefetch($cur1,5); +oci_set_prefetch($cur1,0); +oci_set_prefetch($cur1,100); + +// Fetch from PL/SQL +if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) { + die("oci_bind_by_name(sql2) failed!\n"); +} +oci_execute($s2); +echo "Fetch Row from PL/SQL\n"; +var_dump($c1); +var_dump($c2); + + +function print_roundtrips($c) { + $sql_stmt = "select value from v\$mystat a,v\$statname c where + a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; + $s = oci_parse($c,$sql_stmt); + oci_define_by_name($s,"VALUE",$value); + oci_execute($s); + oci_fetch($s); + return $value; +} + +// Clean up here + +$stmtarray = array( + "drop package refcurpkg", + "drop table refcurtest" +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; +?> +--EXPECTF-- +------Test 1 - Set Prefetch after PL/SQL fetch ---------- + +Warning: oci_execute(): ORA-01001: %s +ORA-06512: at "SYSTEM.REFCURPKG", line %d +ORA-06512: at line %d in %s on line %d +Fetch Row from PL/SQL +int(0) +NULL +Fetch Row from PHP +array(2) { + [0]=> + string(1) "0" + [1]=> + string(5) "test0" +} +------Test 2- Overwrite prefetch----------- +Fetch Row from PHP +array(2) { + [0]=> + string(1) "0" + [1]=> + string(5) "test0" +} +Fetch Row from PL/SQL +int(101) +string(%d) "test101" +Done diff --git a/ext/oci8/tests/reflection1.phpt b/ext/oci8/tests/reflection1.phpt new file mode 100644 index 0000000..5f2e73d --- /dev/null +++ b/ext/oci8/tests/reflection1.phpt @@ -0,0 +1,1096 @@ +--TEST-- +Test OCI8 Reflection +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +/* ALL PHP_FE or PHP_ALIAS user callable functions should appear here */ + +reflection::export(new reflectionfunction('oci_define_by_name')); +reflection::export(new reflectionfunction('oci_bind_by_name')); +reflection::export(new reflectionfunction('oci_bind_array_by_name')); +reflection::export(new reflectionfunction('oci_field_is_null')); +reflection::export(new reflectionfunction('oci_field_name')); +reflection::export(new reflectionfunction('oci_field_size')); +reflection::export(new reflectionfunction('oci_field_scale')); +reflection::export(new reflectionfunction('oci_field_precision')); +reflection::export(new reflectionfunction('oci_field_type')); +reflection::export(new reflectionfunction('oci_field_type_raw')); +reflection::export(new reflectionfunction('oci_execute')); +reflection::export(new reflectionfunction('oci_cancel')); +reflection::export(new reflectionfunction('oci_fetch')); +reflection::export(new reflectionfunction('oci_fetch_object')); +reflection::export(new reflectionfunction('oci_fetch_row')); +reflection::export(new reflectionfunction('oci_fetch_assoc')); +reflection::export(new reflectionfunction('oci_fetch_array')); +reflection::export(new reflectionfunction('ocifetchinto')); +reflection::export(new reflectionfunction('oci_fetch_all')); +reflection::export(new reflectionfunction('oci_free_statement')); +reflection::export(new reflectionfunction('oci_internal_debug')); +reflection::export(new reflectionfunction('oci_num_fields')); +reflection::export(new reflectionfunction('oci_parse')); +reflection::export(new reflectionfunction('oci_new_cursor')); +reflection::export(new reflectionfunction('oci_result')); +reflection::export(new reflectionfunction('oci_server_version')); +reflection::export(new reflectionfunction('oci_statement_type')); +reflection::export(new reflectionfunction('oci_num_rows')); +reflection::export(new reflectionfunction('oci_close')); +reflection::export(new reflectionfunction('oci_connect')); +reflection::export(new reflectionfunction('oci_new_connect')); +reflection::export(new reflectionfunction('oci_pconnect')); +reflection::export(new reflectionfunction('oci_error')); +reflection::export(new reflectionfunction('oci_free_descriptor')); +reflection::export(new reflectionfunction('oci_lob_save')); +reflection::export(new reflectionfunction('oci_lob_import')); +reflection::export(new reflectionfunction('oci_lob_size')); +reflection::export(new reflectionfunction('oci_lob_load')); +reflection::export(new reflectionfunction('oci_lob_read')); +reflection::export(new reflectionfunction('oci_lob_eof')); +reflection::export(new reflectionfunction('oci_lob_tell')); +reflection::export(new reflectionfunction('oci_lob_truncate')); +reflection::export(new reflectionfunction('oci_lob_erase')); +reflection::export(new reflectionfunction('oci_lob_flush')); +reflection::export(new reflectionfunction('ocisetbufferinglob')); +reflection::export(new reflectionfunction('ocigetbufferinglob')); +reflection::export(new reflectionfunction('oci_lob_is_equal')); +reflection::export(new reflectionfunction('oci_lob_rewind')); +reflection::export(new reflectionfunction('oci_lob_write')); +reflection::export(new reflectionfunction('oci_lob_append')); +reflection::export(new reflectionfunction('oci_lob_copy')); +reflection::export(new reflectionfunction('oci_lob_export')); +reflection::export(new reflectionfunction('oci_lob_seek')); +reflection::export(new reflectionfunction('oci_commit')); +reflection::export(new reflectionfunction('oci_rollback')); +reflection::export(new reflectionfunction('oci_new_descriptor')); +reflection::export(new reflectionfunction('oci_set_prefetch')); +reflection::export(new reflectionfunction('oci_password_change')); +reflection::export(new reflectionfunction('oci_free_collection')); +reflection::export(new reflectionfunction('oci_collection_append')); +reflection::export(new reflectionfunction('oci_collection_element_get')); +reflection::export(new reflectionfunction('oci_collection_element_assign')); +reflection::export(new reflectionfunction('oci_collection_assign')); +reflection::export(new reflectionfunction('oci_collection_size')); +reflection::export(new reflectionfunction('oci_collection_max')); +reflection::export(new reflectionfunction('oci_collection_trim')); +reflection::export(new reflectionfunction('oci_new_collection')); +reflection::export(new reflectionfunction('oci_free_cursor')); +reflection::export(new reflectionfunction('ocifreecursor')); +reflection::export(new reflectionfunction('ocibindbyname')); +reflection::export(new reflectionfunction('ocidefinebyname')); +reflection::export(new reflectionfunction('ocicolumnisnull')); +reflection::export(new reflectionfunction('ocicolumnname')); +reflection::export(new reflectionfunction('ocicolumnsize')); +reflection::export(new reflectionfunction('ocicolumnscale')); +reflection::export(new reflectionfunction('ocicolumnprecision')); +reflection::export(new reflectionfunction('ocicolumntype')); +reflection::export(new reflectionfunction('ocicolumntyperaw')); +reflection::export(new reflectionfunction('ociexecute')); +reflection::export(new reflectionfunction('ocicancel')); +reflection::export(new reflectionfunction('ocifetch')); +reflection::export(new reflectionfunction('ocifetchstatement')); +reflection::export(new reflectionfunction('ocifreestatement')); +reflection::export(new reflectionfunction('ociinternaldebug')); +reflection::export(new reflectionfunction('ocinumcols')); +reflection::export(new reflectionfunction('ociparse')); +reflection::export(new reflectionfunction('ocinewcursor')); +reflection::export(new reflectionfunction('ociresult')); +reflection::export(new reflectionfunction('ociserverversion')); +reflection::export(new reflectionfunction('ocistatementtype')); +reflection::export(new reflectionfunction('ocirowcount')); +reflection::export(new reflectionfunction('ocilogoff')); +reflection::export(new reflectionfunction('ocilogon')); +reflection::export(new reflectionfunction('ocinlogon')); +reflection::export(new reflectionfunction('ociplogon')); +reflection::export(new reflectionfunction('ocierror')); +reflection::export(new reflectionfunction('ocifreedesc')); +reflection::export(new reflectionfunction('ocisavelob')); +reflection::export(new reflectionfunction('ocisavelobfile')); +reflection::export(new reflectionfunction('ociwritelobtofile')); +reflection::export(new reflectionfunction('ociloadlob')); +reflection::export(new reflectionfunction('ocicommit')); +reflection::export(new reflectionfunction('ocirollback')); +reflection::export(new reflectionfunction('ocinewdescriptor')); +reflection::export(new reflectionfunction('ocisetprefetch')); +reflection::export(new reflectionfunction('ocipasswordchange')); +reflection::export(new reflectionfunction('ocifreecollection')); +reflection::export(new reflectionfunction('ocinewcollection')); +reflection::export(new reflectionfunction('ocicollappend')); +reflection::export(new reflectionfunction('ocicollgetelem')); +reflection::export(new reflectionfunction('ocicollassignelem')); +reflection::export(new reflectionfunction('ocicollsize')); +reflection::export(new reflectionfunction('ocicollmax')); +reflection::export(new reflectionfunction('ocicolltrim')); +reflection::export(new reflectionfunction('oci_set_edition')); +reflection::export(new reflectionfunction('oci_set_module_name')); +reflection::export(new reflectionfunction('oci_set_action')); +reflection::export(new reflectionfunction('oci_set_client_info')); +reflection::export(new reflectionfunction('oci_set_client_identifier')); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Function [ <internal%s> function oci_define_by_name ] { + + - Parameters [4] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_name ] + Parameter #2 [ <required> &$variable ] + Parameter #3 [ <optional> $type ] + } +} + +Function [ <internal%s> function oci_bind_by_name ] { + + - Parameters [5] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_name ] + Parameter #2 [ <required> &$variable ] + Parameter #3 [ <optional> $maximum_length ] + Parameter #4 [ <optional> $type ] + } +} + +Function [ <internal%s> function oci_bind_array_by_name ] { + + - Parameters [6] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_name ] + Parameter #2 [ <required> &$variable ] + Parameter #3 [ <required> $maximum_array_length ] + Parameter #4 [ <optional> $maximum_item_length ] + Parameter #5 [ <optional> $type ] + } +} + +Function [ <internal%s> function oci_field_is_null ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function oci_field_name ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function oci_field_size ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function oci_field_scale ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function oci_field_precision ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function oci_field_type ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function oci_field_type_raw ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function oci_execute ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <optional> $mode ] + } +} + +Function [ <internal%s> function oci_cancel ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_fetch ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_fetch_object ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_fetch_row ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_fetch_assoc ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_fetch_array ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <optional> $mode ] + } +} + +Function [ <internal%s> function ocifetchinto ] { + + - Parameters [3] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> &$result ] + Parameter #2 [ <optional> $mode ] + } +} + +Function [ <internal%s> function oci_fetch_all ] { + + - Parameters [5] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> &$output ] + Parameter #2 [ <optional> $skip ] + Parameter #3 [ <optional> $maximum_rows ] + Parameter #4 [ <optional> $flags ] + } +} + +Function [ <internal%s> function oci_free_statement ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_internal_debug ] { + + - Parameters [1] { + Parameter #0 [ <required> $mode ] + } +} + +Function [ <internal%s> function oci_num_fields ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_parse ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $sql_text ] + } +} + +Function [ <internal%s> function oci_new_cursor ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function oci_result ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function oci_server_version ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function oci_statement_type ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_num_rows ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function oci_close ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function oci_connect ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function oci_new_connect ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function oci_pconnect ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function oci_error ] { + + - Parameters [1] { + Parameter #0 [ <optional> $connection_or_statement_resource ] + } +} + +Function [ <internal%s> function oci_free_descriptor ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_save ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $data ] + Parameter #2 [ <optional> $offset ] + } +} + +Function [ <internal%s> function oci_lob_import ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $filename ] + } +} + +Function [ <internal%s> function oci_lob_size ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_load ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_read ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $length ] + } +} + +Function [ <internal%s> function oci_lob_eof ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_tell ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_truncate ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <optional> $length ] + } +} + +Function [ <internal%s> function oci_lob_erase ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <optional> $offset ] + Parameter #2 [ <optional> $length ] + } +} + +Function [ <internal%s> function oci_lob_flush ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <optional> $flag ] + } +} + +Function [ <internal%s> function ocisetbufferinglob ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $mode ] + } +} + +Function [ <internal%s> function ocigetbufferinglob ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_is_equal ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_rewind ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function oci_lob_write ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $string ] + Parameter #2 [ <optional> $length ] + } +} + +Function [ <internal%s> function oci_lob_append ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor_to ] + Parameter #1 [ <required> $lob_descriptor_from ] + } +} + +Function [ <internal%s> function oci_lob_copy ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor_to ] + Parameter #1 [ <required> $lob_descriptor_from ] + Parameter #2 [ <optional> $length ] + } +} + +Function [ <internal%s> function oci_lob_export ] { + + - Parameters [4] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $filename ] + Parameter #2 [ <optional> $start ] + Parameter #3 [ <optional> $length ] + } +} + +Function [ <internal%s> function oci_lob_seek ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $offset ] + Parameter #2 [ <optional> $whence ] + } +} + +Function [ <internal%s> function oci_commit ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function oci_rollback ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function oci_new_descriptor ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <optional> $type ] + } +} + +Function [ <internal%s> function oci_set_prefetch ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $number_of_rows ] + } +} + +Function [ <internal%s> function oci_password_change ] { + + - Parameters [4] { + Parameter #0 [ <required> $connection_resource_or_connection_string ] + Parameter #1 [ <required> $username ] + Parameter #2 [ <required> $old_password ] + Parameter #3 [ <required> $new_password ] + } +} + +Function [ <internal%s> function oci_free_collection ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function oci_collection_append ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $value ] + } +} + +Function [ <internal%s> function oci_collection_element_get ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $index ] + } +} + +Function [ <internal%s> function oci_collection_element_assign ] { + + - Parameters [3] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $index ] + Parameter #2 [ <required> $value ] + } +} + +Function [ <internal%s> function oci_collection_assign ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection_to ] + Parameter #1 [ <required> $collection_from ] + } +} + +Function [ <internal%s> function oci_collection_size ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function oci_collection_max ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function oci_collection_trim ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $number ] + } +} + +Function [ <internal%s> function oci_new_collection ] { + + - Parameters [3] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $type_name ] + Parameter #2 [ <optional> $schema_name ] + } +} + +Function [ <internal%s> function oci_free_cursor ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocifreecursor ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocibindbyname ] { + + - Parameters [5] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_name ] + Parameter #2 [ <required> &$variable ] + Parameter #3 [ <optional> $maximum_length ] + Parameter #4 [ <optional> $type ] + } +} + +Function [ <internal%s> function ocidefinebyname ] { + + - Parameters [4] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_name ] + Parameter #2 [ <required> &$variable ] + Parameter #3 [ <optional> $type ] + } +} + +Function [ <internal%s> function ocicolumnisnull ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function ocicolumnname ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function ocicolumnsize ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function ocicolumnscale ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function ocicolumnprecision ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function ocicolumntype ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function ocicolumntyperaw ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number ] + } +} + +Function [ <internal%s> function ociexecute ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <optional> $mode ] + } +} + +Function [ <internal%s> function ocicancel ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocifetch ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocifetchstatement ] { + + - Parameters [5] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> &$output ] + Parameter #2 [ <optional> $skip ] + Parameter #3 [ <optional> $maximum_rows ] + Parameter #4 [ <optional> $flags ] + } +} + +Function [ <internal%s> function ocifreestatement ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ociinternaldebug ] { + + - Parameters [1] { + Parameter #0 [ <required> $mode ] + } +} + +Function [ <internal%s> function ocinumcols ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ociparse ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $sql_text ] + } +} + +Function [ <internal%s> function ocinewcursor ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function ociresult ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $column_number_or_name ] + } +} + +Function [ <internal%s> function ociserverversion ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function ocistatementtype ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocirowcount ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + +Function [ <internal%s> function ocilogoff ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function ocilogon ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function ocinlogon ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function ociplogon ] { + + - Parameters [5] { + Parameter #0 [ <required> $username ] + Parameter #1 [ <required> $password ] + Parameter #2 [ <optional> $connection_string ] + Parameter #3 [ <optional> $character_set ] + Parameter #4 [ <optional> $session_mode ] + } +} + +Function [ <internal%s> function ocierror ] { + + - Parameters [1] { + Parameter #0 [ <optional> $connection_or_statement_resource ] + } +} + +Function [ <internal%s> function ocifreedesc ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function ocisavelob ] { + + - Parameters [3] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $data ] + Parameter #2 [ <optional> $offset ] + } +} + +Function [ <internal%s> function ocisavelobfile ] { + + - Parameters [2] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $filename ] + } +} + +Function [ <internal%s> function ociwritelobtofile ] { + + - Parameters [4] { + Parameter #0 [ <required> $lob_descriptor ] + Parameter #1 [ <required> $filename ] + Parameter #2 [ <optional> $start ] + Parameter #3 [ <optional> $length ] + } +} + +Function [ <internal%s> function ociloadlob ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor ] + } +} + +Function [ <internal%s> function ocicommit ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function ocirollback ] { + + - Parameters [1] { + Parameter #0 [ <required> $connection_resource ] + } +} + +Function [ <internal%s> function ocinewdescriptor ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <optional> $type ] + } +} + +Function [ <internal%s> function ocisetprefetch ] { + + - Parameters [2] { + Parameter #0 [ <required> $statement_resource ] + Parameter #1 [ <required> $number_of_rows ] + } +} + +Function [ <internal%s> function ocipasswordchange ] { + + - Parameters [4] { + Parameter #0 [ <required> $connection_resource_or_connection_string ] + Parameter #1 [ <required> $username ] + Parameter #2 [ <required> $old_password ] + Parameter #3 [ <required> $new_password ] + } +} + +Function [ <internal%s> function ocifreecollection ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function ocinewcollection ] { + + - Parameters [3] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $type_name ] + Parameter #2 [ <optional> $schema_name ] + } +} + +Function [ <internal%s> function ocicollappend ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $value ] + } +} + +Function [ <internal%s> function ocicollgetelem ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $index ] + } +} + +Function [ <internal%s> function ocicollassignelem ] { + + - Parameters [3] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $index ] + Parameter #2 [ <required> $value ] + } +} + +Function [ <internal%s> function ocicollsize ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function ocicollmax ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection ] + } +} + +Function [ <internal%s> function ocicolltrim ] { + + - Parameters [2] { + Parameter #0 [ <required> $collection ] + Parameter #1 [ <required> $number ] + } +} + +Function [ <internal%s> function oci_set_edition ] { + + - Parameters [1] { + Parameter #0 [ <required> $edition_name ] + } +} + +Function [ <internal%s> function oci_set_module_name ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $module_name ] + } +} + +Function [ <internal%s> function oci_set_action ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $action ] + } +} + +Function [ <internal%s> function oci_set_client_info ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $client_information ] + } +} + +Function [ <internal%s> function oci_set_client_identifier ] { + + - Parameters [2] { + Parameter #0 [ <required> $connection_resource ] + Parameter #1 [ <required> $client_identifier ] + } +} + +===DONE=== diff --git a/ext/oci8/tests/reflection2.phpt b/ext/oci8/tests/reflection2.phpt new file mode 100644 index 0000000..9e63db1 --- /dev/null +++ b/ext/oci8/tests/reflection2.phpt @@ -0,0 +1,258 @@ +--TEST-- +Test OCI8 LOB & Collection Class Reflection +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +reflection::export(new reflectionclass('OCI-Lob')); +reflection::export(new reflectionclass('OCI-Collection')); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Class [ <internal:oci8> class OCI-Lob ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [22] { + Method [ <internal%s> public method load ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method tell ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method truncate ] { + + - Parameters [1] { + Parameter #0 [ <optional> $length ] + } + } + + Method [ <internal%s> public method erase ] { + + - Parameters [2] { + Parameter #0 [ <optional> $offset ] + Parameter #1 [ <optional> $length ] + } + } + + Method [ <internal%s> public method flush ] { + + - Parameters [1] { + Parameter #0 [ <optional> $flag ] + } + } + + Method [ <internal%s> public method setbuffering ] { + + - Parameters [1] { + Parameter #0 [ <required> $mode ] + } + } + + Method [ <internal%s> public method getbuffering ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method rewind ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method read ] { + + - Parameters [1] { + Parameter #0 [ <required> $length ] + } + } + + Method [ <internal%s> public method eof ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method seek ] { + + - Parameters [2] { + Parameter #0 [ <required> $offset ] + Parameter #1 [ <optional> $whence ] + } + } + + Method [ <internal%s> public method write ] { + + - Parameters [2] { + Parameter #0 [ <required> $string ] + Parameter #1 [ <optional> $length ] + } + } + + Method [ <internal%s> public method append ] { + + - Parameters [1] { + Parameter #0 [ <required> $lob_descriptor_from ] + } + } + + Method [ <internal%s> public method size ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method writetofile ] { + + - Parameters [3] { + Parameter #0 [ <required> $filename ] + Parameter #1 [ <optional> $start ] + Parameter #2 [ <optional> $length ] + } + } + + Method [ <internal%s> public method export ] { + + - Parameters [3] { + Parameter #0 [ <required> $filename ] + Parameter #1 [ <optional> $start ] + Parameter #2 [ <optional> $length ] + } + } + + Method [ <internal%s> public method import ] { + + - Parameters [1] { + Parameter #0 [ <required> $filename ] + } + } + + Method [ <internal%s> public method writetemporary ] { + + - Parameters [2] { + Parameter #0 [ <required> $data ] + Parameter #1 [ <optional> $type ] + } + } + + Method [ <internal%s> public method close ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method save ] { + + - Parameters [2] { + Parameter #0 [ <required> $data ] + Parameter #1 [ <optional> $offset ] + } + } + + Method [ <internal%s> public method savefile ] { + + - Parameters [1] { + Parameter #0 [ <required> $filename ] + } + } + + Method [ <internal%s> public method free ] { + + - Parameters [0] { + } + } + } +} + +Class [ <internal%s> class OCI-Collection ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [8] { + Method [ <internal%s> public method append ] { + + - Parameters [1] { + Parameter #0 [ <required> $value ] + } + } + + Method [ <internal%s> public method getelem ] { + + - Parameters [1] { + Parameter #0 [ <required> $index ] + } + } + + Method [ <internal%s> public method assignelem ] { + + - Parameters [2] { + Parameter #0 [ <required> $index ] + Parameter #1 [ <required> $value ] + } + } + + Method [ <internal%s> public method assign ] { + + - Parameters [1] { + Parameter #0 [ <required> $collection_from ] + } + } + + Method [ <internal%s> public method size ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method max ] { + + - Parameters [0] { + } + } + + Method [ <internal%s> public method trim ] { + + - Parameters [1] { + Parameter #0 [ <required> $number ] + } + } + + Method [ <internal%s> public method free ] { + + - Parameters [0] { + } + } + } +} + +===DONE=== diff --git a/ext/oci8/tests/select_null.phpt b/ext/oci8/tests/select_null.phpt new file mode 100644 index 0000000..450c81a --- /dev/null +++ b/ext/oci8/tests/select_null.phpt @@ -0,0 +1,25 @@ +--TEST-- +SELECTing NULL values +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$stmt = oci_parse($pc, "select NULL from dual"); +oci_execute($stmt); +var_dump(oci_fetch_array($stmt, OCI_RETURN_NULLS)); + +echo "Done\n"; +?> +--EXPECTF-- +array(2) { + [0]=> + NULL + ["%r(NULL|EXP)%r"]=> + NULL +} +Done diff --git a/ext/oci8/tests/serverversion.phpt b/ext/oci8/tests/serverversion.phpt new file mode 100644 index 0000000..6cbb5aa --- /dev/null +++ b/ext/oci8/tests/serverversion.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_server_version() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c = oci_connect($user, $password, $dbase)); +} +else { + var_dump($c = oci_connect($user, $password)); +} + +$v = oci_server_version($c); +var_dump(str_replace("\n", "", $v)); + +$v = ociserverversion($c); +var_dump(str_replace("\n", "", $v)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +string(%d) "Oracle %s" +string(%d) "Oracle %s" +Done diff --git a/ext/oci8/tests/skipif.inc b/ext/oci8/tests/skipif.inc new file mode 100644 index 0000000..0ae2876 --- /dev/null +++ b/ext/oci8/tests/skipif.inc @@ -0,0 +1,18 @@ +<?php + +if (!extension_loaded('oci8')) die("skip oci8 extension is not available\n"); + +// Check the test file is valid for this DB type +require(dirname(__FILE__).'/connect.inc'); +$v = oci_server_version($c); +if (strpos($v, 'Oracle Database') !== false) + $dbtype = 'oracledb'; +else if (strpos($v, 'Oracle TimesTen') !== false) + $dbtype = 'timesten'; +else { + die("skip Unknown database type $v\n"); +} +if (!array_key_exists($dbtype, $target_dbs) || $target_dbs[$dbtype] !== true) + die("skip Test not valid for $v\n"); + +?> diff --git a/ext/oci8/tests/statement_cache.phpt b/ext/oci8/tests/statement_cache.phpt new file mode 100644 index 0000000..4c48d3f --- /dev/null +++ b/ext/oci8/tests/statement_cache.phpt @@ -0,0 +1,40 @@ +--TEST-- +statement cache +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => true); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +// Note: with TimesTen, the column will be called "EXP" + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$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"); +oci_execute($stmt); +var_dump(oci_fetch_array($stmt)); + +echo "Done\n"; +?> +--EXPECTF-- +array(2) { + [0]=> + string(1) "4" + ["%r(1\+3|EXP)%r"]=> + string(1) "4" +} +array(2) { + [0]=> + string(1) "4" + ["%r(1\+3|EXP)%r"]=> + string(1) "4" +} +Done diff --git a/ext/oci8/tests/statement_type.phpt b/ext/oci8/tests/statement_type.phpt new file mode 100644 index 0000000..29cdd94 --- /dev/null +++ b/ext/oci8/tests/statement_type.phpt @@ -0,0 +1,48 @@ +--TEST-- +oci_statement_type() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$sqls = Array( + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", + "DROP TABLE table", + "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) { + $s = oci_parse($c, $sql); + var_dump(oci_statement_type($s)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +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 new file mode 100644 index 0000000..2626d62 --- /dev/null +++ b/ext/oci8/tests/statement_type_old.phpt @@ -0,0 +1,56 @@ +--TEST-- +ocistatementtype() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c = ocilogon($user, $password, $dbase)); +} +else { + var_dump($c = ocilogon($user, $password)); +} + +$sqls = Array( + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", + "DROP TABLE table", + "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) { + $s = ociparse($c, $sql); + var_dump(ocistatementtype($s)); +} + +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/test.gif b/ext/oci8/tests/test.gif Binary files differnew file mode 100644 index 0000000..f352c73 --- /dev/null +++ b/ext/oci8/tests/test.gif diff --git a/ext/oci8/tests/test.txt b/ext/oci8/tests/test.txt new file mode 100644 index 0000000..4b89727 --- /dev/null +++ b/ext/oci8/tests/test.txt @@ -0,0 +1,9 @@ +Ipsum lorem, IPSUM Lorem Ipsum lorem Ipsum lorem +Ipsum lorem IPSum Lorem Ipsum lorem ipsum Lorem +Ipsum Lorem ipsum Lorem - ipsum Lorem ipsum lorem +Ipsum lorem IPSUM Lorem Ipsum lorem, Ipsum lorem. + +Ipsum LOREM, ipsum Lorem Ipsum lorem Ipsum lorem +Ipsum lorem Ipsum Lorem Ipsum lorem ipsum Lorem +Ipsum Lorem ipsum Lorem ipsum Lorem; ipsum lorem +Ipsum lorem ipsum LOREM Ipsum lorem Ipsum lorem! diff --git a/ext/oci8/tests/testping.phpt b/ext/oci8/tests/testping.phpt new file mode 100644 index 0000000..a0d65a3 --- /dev/null +++ b/ext/oci8/tests/testping.phpt @@ -0,0 +1,25 @@ +--TEST-- +Exercise OCIPing functionality on reconnect (code coverage test) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--INI-- +oci8.ping_interval=0 +--FILE-- +<?php + +require(dirname(__FILE__).'/details.inc'); + +for ($i = 0; $i < 2; $i++) { + if (!empty($dbase)) { + $c = oci_pconnect($user,$password,$dbase); + } + else { + $c = oci_pconnect($user,$password); + } +} + +echo "Done\n"; + +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/uncommitted.phpt b/ext/oci8/tests/uncommitted.phpt new file mode 100644 index 0000000..3c341c8 --- /dev/null +++ b/ext/oci8/tests/uncommitted.phpt @@ -0,0 +1,16 @@ +--TEST-- +uncommitted connection +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmt = oci_parse($c, "select 1 from dual"); +oci_execute($stmt, OCI_DEFAULT); + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/xmltype_01.phpt b/ext/oci8/tests/xmltype_01.phpt new file mode 100644 index 0000000..ebbbb31 --- /dev/null +++ b/ext/oci8/tests/xmltype_01.phpt @@ -0,0 +1,112 @@ +--TEST-- +Basic XMLType test +--SKIPIF-- +<?php +if (!extension_loaded("simplexml")) die("skip no simplexml extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__)."/connect.inc"); + +// Initialization + +$stmtarray = array( + "drop table xtt", + "create table xtt + (xt_id number, xt_spec xmltype) + xmltype xt_spec store as clob", + "insert into xtt (xt_id, xt_spec) values + (1, + xmltype('<?xml version=\"1.0\"?> + <Xt> + <XtId>1</XtId> + <Size>Big</Size> + <Area>12345</Area> + <Hardness>20</Hardness> + <Lip>Curved</Lip> + <Color>Red</Color> + <Nice>N</Nice> + <Compact>Tiny</Compact> + <Material>Steel</Material> + </Xt>'))" +); + +oci8_test_sql_execute($c, $stmtarray); + +function do_query($c) +{ + $s = oci_parse($c, 'select XMLType.getClobVal(xt_spec) + from xtt where xt_id = 1'); + oci_execute($s); + $row = oci_fetch_row($s); + $data = $row[0]->load(); + var_dump($data); + return($data); +} + +// Check +echo "Initial Data\n"; +$data = do_query($c); + +// Manipulate the data using SimpleXML +$sx = simplexml_load_string($data); +$sx->Hardness = $sx->Hardness - 1; +$sx->Nice = 'Y'; + +// Insert changes using a temporary CLOB +$s = oci_parse($c, 'update xtt + set xt_spec = XMLType(:clob) + where xt_id = 1'); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary($sx->asXml()); +oci_execute($s); +$lob->close(); + +// Verify +echo "Verify\n"; +$data = do_query($c); + +// Cleanup + +$stmtarray = array( + "drop table xtt", +); + +oci8_test_sql_execute($c, $stmtarray); + +echo "Done\n"; + +?> +--EXPECT-- +Initial Data +string(250) "<?xml version="1.0"?> + <Xt> + <XtId>1</XtId> + <Size>Big</Size> + <Area>12345</Area> + <Hardness>20</Hardness> + <Lip>Curved</Lip> + <Color>Red</Color> + <Nice>N</Nice> + <Compact>Tiny</Compact> + <Material>Steel</Material> + </Xt>" +Verify +string(249) "<?xml version="1.0"?> +<Xt> + <XtId>1</XtId> + <Size>Big</Size> + <Area>12345</Area> + <Hardness>19</Hardness> + <Lip>Curved</Lip> + <Color>Red</Color> + <Nice>Y</Nice> + <Compact>Tiny</Compact> + <Material>Steel</Material> + </Xt> +" +Done diff --git a/ext/oci8/tests/xmltype_02.phpt b/ext/oci8/tests/xmltype_02.phpt new file mode 100644 index 0000000..28e9401 --- /dev/null +++ b/ext/oci8/tests/xmltype_02.phpt @@ -0,0 +1,181 @@ +--TEST-- +Basic XMLType test #2 +--SKIPIF-- +<?php +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +if (!extension_loaded("simplexml")) die ("skip no simplexml extension"); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table xmltype_02_tab", + "create table xmltype_02_tab (warehouse_id number, warehouse_spec xmltype)", +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + + +$id = 1; + +// Delete any current entry +$s = oci_parse($c, "delete from xmltype_02_tab where warehouse_id = :id"); +oci_bind_by_name($s, ':id', $id); +oci_execute($s); + +// XML data to be inserted +$xml =<<<EOF +<?xml version="1.0"?> +<Warehouse> +<WarehouseId>1</WarehouseId> +<WarehouseName>Southlake, Texas</WarehouseName> +<Building>Owned</Building> +<Area>25000</Area> +<Docks>2</Docks> +<DockType>Rear load</DockType> +<WaterAccess>true</WaterAccess> +<RailAccess>N</RailAccess> +<Parking>Street</Parking> +<VClearance>10</VClearance> +</Warehouse> +EOF; + +echo "Test 1 Insert new XML data using a temporary CLOB\n"; +$s = oci_parse($c, + "insert into xmltype_02_tab (warehouse_id, warehouse_spec) + values (:id, XMLType(:clob))"); +oci_bind_by_name($s, ':id', $id); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary($xml); +oci_execute($s); +$lob->close(); + +// Query the row back +$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec) + from xmltype_02_tab where warehouse_id = :id'); +$r = oci_bind_by_name($s, ':id', $id); +oci_execute($s); +$row = oci_fetch_array($s, OCI_NUM); + +var_dump($row); + +echo "Test 2 Manipulate the data using SimpleXML\n"; + +$sx = simplexml_load_string((binary)$row[0]->load()); +$row[0]->free(); +var_dump($sx); + +$sx->Docks -= 1; // change the data + +var_dump($sx); + +echo "Test 3: Update changes using a temporary CLOB\n"; + +$s = oci_parse($c, 'update xmltype_02_tab + set warehouse_spec = XMLType(:clob) + where warehouse_id = :id'); +oci_bind_by_name($s, ':id', $id); +$lob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB); +$lob->writeTemporary($sx->asXml()); +oci_execute($s); +$lob->close(); + +// Query the changed row back and print it +$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec) + from xmltype_02_tab where warehouse_id = :id'); +$r = oci_bind_by_name($s, ':id', $id); +oci_execute($s); +$row = oci_fetch_array($s, OCI_NUM); +var_dump($row[0]->load()); +$row[0]->free(); + +// Clean up + +$stmtarray = array( + "drop table xmltype_02_tab" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 Insert new XML data using a temporary CLOB +array(1) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +Test 2 Manipulate the data using SimpleXML +object(SimpleXMLElement)#%d (10) { + ["WarehouseId"]=> + string(1) "1" + ["WarehouseName"]=> + string(16) "Southlake, Texas" + ["Building"]=> + string(5) "Owned" + ["Area"]=> + string(5) "25000" + ["Docks"]=> + string(1) "2" + ["DockType"]=> + string(9) "Rear load" + ["WaterAccess"]=> + string(4) "true" + ["RailAccess"]=> + string(1) "N" + ["Parking"]=> + string(6) "Street" + ["VClearance"]=> + string(2) "10" +} +object(SimpleXMLElement)#%d (10) { + ["WarehouseId"]=> + string(1) "1" + ["WarehouseName"]=> + string(16) "Southlake, Texas" + ["Building"]=> + string(5) "Owned" + ["Area"]=> + string(5) "25000" + ["Docks"]=> + string(1) "1" + ["DockType"]=> + string(9) "Rear load" + ["WaterAccess"]=> + string(4) "true" + ["RailAccess"]=> + string(1) "N" + ["Parking"]=> + string(6) "Street" + ["VClearance"]=> + string(2) "10" +} +Test 3: Update changes using a temporary CLOB +string(%d) "<?xml version="1.0"?> +<Warehouse> +%sWarehouseId>1</WarehouseId> +%sWarehouseName>Southlake, Texas</WarehouseName> +%sBuilding>Owned</Building> +%sArea>25000</Area> +%sDocks>1</Docks> +%sDockType>Rear load</DockType> +%sWaterAccess>true</WaterAccess> +%sRailAccess>N</RailAccess> +%sParking>Street</Parking> +%sVClearance>10</VClearance> +</Warehouse> +" +===DONE===
\ No newline at end of file |