summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/array_bind_001.phpt69
-rw-r--r--tests/array_bind_002.phpt77
-rw-r--r--tests/array_bind_003.phpt73
-rw-r--r--tests/array_bind_004.phpt65
-rw-r--r--tests/array_bind_005.phpt74
-rw-r--r--tests/array_bind_006.phpt74
-rw-r--r--tests/array_bind_007.phpt77
-rw-r--r--tests/array_bind_008.phpt78
-rw-r--r--tests/array_bind_009.phpt17
-rw-r--r--tests/array_bind_010.phpt36
-rw-r--r--tests/array_bind_011.phpt67
-rw-r--r--tests/array_bind_012.phpt26
-rw-r--r--tests/array_bind_013.phpt39
-rw-r--r--tests/array_bind_014.phpt73
-rw-r--r--tests/array_bind_date.phpt74
-rw-r--r--tests/array_bind_date1.phpt74
-rw-r--r--tests/array_bind_float.phpt74
-rw-r--r--tests/array_bind_float1.phpt74
-rw-r--r--tests/array_bind_int.phpt74
-rw-r--r--tests/array_bind_int1.phpt74
-rw-r--r--tests/array_bind_str.phpt74
-rw-r--r--tests/array_bind_str1.phpt74
-rw-r--r--tests/b47243_1.phpt22
-rw-r--r--tests/b47243_2.phpt23
-rw-r--r--tests/b47243_3.phpt24
-rw-r--r--tests/bind_char_1.phpt306
-rw-r--r--tests/bind_char_1_11gR1.phpt297
-rw-r--r--tests/bind_char_2.phpt127
-rw-r--r--tests/bind_char_2_11gR1.phpt123
-rw-r--r--tests/bind_char_3.phpt345
-rw-r--r--tests/bind_char_3_11gR1.phpt344
-rw-r--r--tests/bind_char_4.phpt347
-rw-r--r--tests/bind_char_4_11gR1.phpt346
-rw-r--r--tests/bind_empty.phpt127
-rw-r--r--tests/bind_long.phpt41
-rw-r--r--tests/bind_long_raw.phpt38
-rw-r--r--tests/bind_raw.phpt39
-rw-r--r--tests/bind_rowid.phpt86
-rw-r--r--tests/bug26133.phpt62
-rw-r--r--tests/bug27303_1.phpt261
-rw-r--r--tests/bug27303_1_11gR1.phpt258
-rw-r--r--tests/bug27303_2.phpt263
-rw-r--r--tests/bug27303_2_11gR1.phpt260
-rw-r--r--tests/bug27303_3.phpt252
-rw-r--r--tests/bug27303_4.phpt261
-rw-r--r--tests/bug27303_4_11gR1.phpt258
-rw-r--r--tests/bug32325.phpt63
-rw-r--r--tests/bug35973.phpt43
-rw-r--r--tests/bug36010.phpt26
-rw-r--r--tests/bug36096.phpt28
-rw-r--r--tests/bug36403.phpt76
-rw-r--r--tests/bug37220.phpt68
-rw-r--r--tests/bug37581.phpt69
-rw-r--r--tests/bug38161.phpt30
-rw-r--r--tests/bug38173.phpt79
-rw-r--r--tests/bug40078.phpt55
-rw-r--r--tests/bug40415.phpt200
-rw-r--r--tests/bug41069.phpt275
-rw-r--r--tests/bug42134.phpt100
-rw-r--r--tests/bug42173.phpt168
-rw-r--r--tests/bug42496_1.phpt61
-rw-r--r--tests/bug42496_2.phpt59
-rw-r--r--tests/bug42841.phpt187
-rw-r--r--tests/bug43492.phpt378
-rw-r--r--tests/bug43492_2.phpt369
-rw-r--r--tests/bug43497.phpt303
-rw-r--r--tests/bug43497_92.phpt303
-rw-r--r--tests/bug44008.phpt54
-rw-r--r--tests/bug44113.phpt56
-rw-r--r--tests/bug44206.phpt43
-rw-r--r--tests/bug45458.phpt84
-rw-r--r--tests/bug46994.phpt86
-rw-r--r--tests/bug47189.phpt48
-rw-r--r--tests/bug47281.phpt73
-rw-r--r--tests/bug51253.phpt165
-rw-r--r--tests/bug51291.phpt434
-rw-r--r--tests/close.phpt17
-rw-r--r--tests/coll_001.phpt27
-rw-r--r--tests/coll_002.phpt30
-rw-r--r--tests/coll_002_func.phpt30
-rw-r--r--tests/coll_003.phpt34
-rw-r--r--tests/coll_003_func.phpt34
-rw-r--r--tests/coll_004.phpt29
-rw-r--r--tests/coll_004_func.phpt29
-rw-r--r--tests/coll_005.phpt27
-rw-r--r--tests/coll_006.phpt30
-rw-r--r--tests/coll_006_func.phpt30
-rw-r--r--tests/coll_007.phpt34
-rw-r--r--tests/coll_008.phpt29
-rw-r--r--tests/coll_009.phpt42
-rw-r--r--tests/coll_009_func.phpt42
-rw-r--r--tests/coll_010.phpt41
-rw-r--r--tests/coll_010_func.phpt41
-rw-r--r--tests/coll_011.phpt43
-rw-r--r--tests/coll_011_func.phpt43
-rw-r--r--tests/coll_012.phpt41
-rw-r--r--tests/coll_012_func.phpt41
-rw-r--r--tests/coll_013.phpt38
-rw-r--r--tests/coll_013_func.phpt38
-rw-r--r--tests/coll_014.phpt38
-rw-r--r--tests/coll_014_func.phpt38
-rw-r--r--tests/coll_015.phpt38
-rw-r--r--tests/coll_015_func.phpt38
-rw-r--r--tests/coll_016.phpt48
-rw-r--r--tests/coll_016_func.phpt48
-rw-r--r--tests/coll_017.phpt38
-rw-r--r--tests/coll_017_func.phpt38
-rw-r--r--tests/coll_018.phpt93
-rw-r--r--tests/coll_019.phpt104
-rw-r--r--tests/commit_001.phpt156
-rw-r--r--tests/commit_002.phpt90
-rw-r--r--tests/commit_old.phpt146
-rw-r--r--tests/conn_attr.inc151
-rw-r--r--tests/conn_attr_1.phpt104
-rw-r--r--tests/conn_attr_2.phpt111
-rw-r--r--tests/conn_attr_3.phpt94
-rw-r--r--tests/conn_attr_4.phpt122
-rw-r--r--tests/conn_attr_5.phpt76
-rw-r--r--tests/connect.inc18
-rw-r--r--tests/connect.phpt22
-rw-r--r--tests/connect_1.phpt35
-rw-r--r--tests/connect_1_old.phpt35
-rw-r--r--tests/connect_old.phpt22
-rw-r--r--tests/connect_scope1.phpt93
-rw-r--r--tests/connect_scope2.phpt93
-rw-r--r--tests/connect_scope_try1.phpt100
-rw-r--r--tests/connect_scope_try2.phpt100
-rw-r--r--tests/connect_scope_try3.phpt100
-rw-r--r--tests/connect_scope_try4.phpt100
-rw-r--r--tests/connect_scope_try5.phpt100
-rw-r--r--tests/connect_scope_try6.phpt100
-rw-r--r--tests/connect_with_charset_001.phpt37
-rw-r--r--tests/connect_without_oracle_home.phpt34
-rw-r--r--tests/connect_without_oracle_home_old.phpt34
-rw-r--r--tests/create_table.inc11
-rw-r--r--tests/create_type.inc17
-rw-r--r--tests/cursor_bind.phpt99
-rw-r--r--tests/cursor_bind_err.phpt70
-rw-r--r--tests/cursors.phpt65
-rw-r--r--tests/cursors_old.phpt86
-rw-r--r--tests/debug.phpt71
-rw-r--r--tests/default_prefetch.phpt73
-rw-r--r--tests/default_prefetch1.phpt72
-rw-r--r--tests/default_prefetch2.phpt74
-rw-r--r--tests/define.phpt62
-rw-r--r--tests/define1.phpt73
-rw-r--r--tests/define2.phpt94
-rw-r--r--tests/define3.phpt112
-rw-r--r--tests/define4.phpt88
-rw-r--r--tests/define5.phpt86
-rw-r--r--tests/define_old.phpt63
-rw-r--r--tests/descriptors.phpt49
-rw-r--r--tests/details.inc63
-rw-r--r--tests/drcp_cclass1.phpt80
-rw-r--r--tests/drcp_characterset.phpt61
-rw-r--r--tests/drcp_conn_close1.phpt45
-rw-r--r--tests/drcp_conn_close2.phpt46
-rw-r--r--tests/drcp_connect1.phpt86
-rw-r--r--tests/drcp_connection_class.phpt24
-rw-r--r--tests/drcp_functions.inc93
-rw-r--r--tests/drcp_newconnect.phpt43
-rw-r--r--tests/drcp_pconn_close1.phpt44
-rw-r--r--tests/drcp_pconn_close2.phpt46
-rw-r--r--tests/drcp_privileged.phpt47
-rw-r--r--tests/drcp_scope1.phpt92
-rw-r--r--tests/drcp_scope2.phpt91
-rw-r--r--tests/drcp_scope3.phpt61
-rw-r--r--tests/drcp_scope4.phpt62
-rw-r--r--tests/drcp_scope5.phpt63
-rw-r--r--tests/driver_name.phpt71
-rw-r--r--tests/drop_table.inc7
-rw-r--r--tests/drop_type.inc7
-rw-r--r--tests/edition_1.phpt156
-rw-r--r--tests/edition_2.phpt248
-rw-r--r--tests/error.phpt40
-rw-r--r--tests/error1.phpt27
-rw-r--r--tests/error2.phpt24
-rw-r--r--tests/error_bind.phpt70
-rw-r--r--tests/error_old.phpt40
-rw-r--r--tests/error_parse.phpt142
-rw-r--r--tests/exec_fetch.phpt24
-rw-r--r--tests/execute_mode.phpt19
-rw-r--r--tests/extauth_01.phpt198
-rw-r--r--tests/extauth_02.phpt198
-rw-r--r--tests/extauth_03.phpt198
-rw-r--r--tests/extauth_04.phpt56
-rw-r--r--tests/fetch.phpt76
-rw-r--r--tests/fetch_all.phpt108
-rw-r--r--tests/fetch_all2.phpt242
-rw-r--r--tests/fetch_all3.phpt612
-rw-r--r--tests/fetch_all4.phpt82
-rw-r--r--tests/fetch_all5.phpt127
-rw-r--r--tests/fetch_array.phpt308
-rw-r--r--tests/fetch_assoc.phpt82
-rw-r--r--tests/fetch_into.phpt90
-rw-r--r--tests/fetch_into1.phpt192
-rw-r--r--tests/fetch_into2.phpt70
-rw-r--r--tests/fetch_object.phpt137
-rw-r--r--tests/fetch_object_2.phpt127
-rw-r--r--tests/fetch_row.phpt84
-rw-r--r--tests/field_funcs.phpt105
-rw-r--r--tests/field_funcs1.phpt194
-rw-r--r--tests/field_funcs2.phpt69
-rw-r--r--tests/field_funcs_old.phpt105
-rw-r--r--tests/function_aliases.phpt198
-rw-r--r--tests/lob_001.phptbin0 -> 1305 bytes
-rw-r--r--tests/lob_002.phpt66
-rw-r--r--tests/lob_003.phptbin0 -> 1628 bytes
-rw-r--r--tests/lob_004.phpt80
-rw-r--r--tests/lob_005.phpt52
-rw-r--r--tests/lob_006.phptbin0 -> 1694 bytes
-rw-r--r--tests/lob_007.phpt66
-rw-r--r--tests/lob_008.phpt65
-rw-r--r--tests/lob_009.phpt69
-rw-r--r--tests/lob_009.txt6
-rw-r--r--tests/lob_010.phpt46
-rw-r--r--tests/lob_011.phpt78
-rw-r--r--tests/lob_012.phpt50
-rw-r--r--tests/lob_013.phpt54
-rw-r--r--tests/lob_014.phpt56
-rw-r--r--tests/lob_015.phpt53
-rw-r--r--tests/lob_016.phpt67
-rw-r--r--tests/lob_017.phpt69
-rw-r--r--tests/lob_018.phpt67
-rw-r--r--tests/lob_019.phptbin0 -> 1548 bytes
-rw-r--r--tests/lob_020.phptbin0 -> 3076 bytes
-rw-r--r--tests/lob_021.phpt70
-rw-r--r--tests/lob_022.phpt80
-rw-r--r--tests/lob_023.phpt84
-rw-r--r--tests/lob_024.phpt75
-rw-r--r--tests/lob_025.phpt82
-rw-r--r--tests/lob_026.phpt100
-rw-r--r--tests/lob_027.phpt103
-rw-r--r--tests/lob_028.phpt84
-rw-r--r--tests/lob_029.phpt125
-rw-r--r--tests/lob_030.phpt75
-rw-r--r--tests/lob_031.phpt107
-rw-r--r--tests/lob_032.phpt33
-rw-r--r--tests/lob_033.phpt38
-rw-r--r--tests/lob_034.phpt50
-rw-r--r--tests/lob_035.phpt108
-rw-r--r--tests/lob_036.phpt40
-rw-r--r--tests/lob_037.phpt68
-rw-r--r--tests/lob_038.phpt189
-rw-r--r--tests/lob_039.phpt65
-rw-r--r--tests/lob_040.phpt1041
-rw-r--r--tests/lob_041.phpt92
-rw-r--r--tests/lob_042.phpt69
-rw-r--r--tests/lob_043.phpt104
-rw-r--r--tests/lob_aliases.phpt99
-rw-r--r--tests/lob_null.phpt265
-rw-r--r--tests/lob_temp.phpt36
-rw-r--r--tests/lob_temp1.phpt32
-rw-r--r--tests/minfo.phpt19
-rw-r--r--tests/num.phpt256
-rw-r--r--tests/oci8safemode.phpt23
-rw-r--r--tests/oci_execute_segfault.phpt48
-rw-r--r--tests/old_oci_close.phpt23
-rw-r--r--tests/old_oci_close1.phpt25
-rw-r--r--tests/password.phpt83
-rw-r--r--tests/password_2.phpt83
-rw-r--r--tests/password_new.phpt49
-rw-r--r--tests/password_old.phpt49
-rw-r--r--tests/pecl_bug10194.phpt47
-rw-r--r--tests/pecl_bug10194_blob.phpt54
-rw-r--r--tests/pecl_bug10194_blob_64.phpt54
-rw-r--r--tests/pecl_bug16035.phpt26
-rw-r--r--tests/pecl_bug16842.phpt69
-rw-r--r--tests/pecl_bug6109.phpt40
-rw-r--r--tests/pecl_bug8816.phpt98
-rw-r--r--tests/persistent.phpt26
-rw-r--r--tests/prefetch.phpt72
-rw-r--r--tests/prefetch_old.phpt75
-rw-r--r--tests/privileged_connect.phpt25
-rw-r--r--tests/privileged_connect1.phpt27
-rw-r--r--tests/refcur_prefetch_1.phpt256
-rw-r--r--tests/refcur_prefetch_2.phpt317
-rw-r--r--tests/refcur_prefetch_3.phpt161
-rw-r--r--tests/reflection1.phpt1096
-rw-r--r--tests/reflection2.phpt258
-rw-r--r--tests/select_null.phpt25
-rw-r--r--tests/serverversion.phpt30
-rw-r--r--tests/skipif.inc10
-rw-r--r--tests/statement_cache.phpt35
-rw-r--r--tests/statement_type.phpt48
-rw-r--r--tests/statement_type_old.phpt56
-rw-r--r--tests/test.gifbin0 -> 2523 bytes
-rw-r--r--tests/test.txt9
-rw-r--r--tests/testping.phpt25
-rw-r--r--tests/uncommitted.phpt16
-rw-r--r--tests/xmltype_01.phpt121
-rw-r--r--tests/xmltype_02.phpt197
292 files changed, 28348 insertions, 0 deletions
diff --git a/tests/array_bind_001.phpt b/tests/array_bind_001.phpt
new file mode 100644
index 0000000000..1310325ad4
--- /dev/null
+++ b/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-01008: not all variables bound in %s on line %d
+array(1) {
+ [0]=>
+ string(0) ""
+}
+Done
diff --git a/tests/array_bind_002.phpt b/tests/array_bind_002.phpt
new file mode 100644
index 0000000000..4c76df42f9
--- /dev/null
+++ b/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-01008: not all variables bound 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/tests/array_bind_003.phpt b/tests/array_bind_003.phpt
new file mode 100644
index 0000000000..497e46e496
--- /dev/null
+++ b/tests/array_bind_003.phpt
@@ -0,0 +1,73 @@
+--TEST--
+oci_bind_array_by_name() and invalid values 3
+--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");
+
+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(): OCI_NO_DATA in %s 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/tests/array_bind_004.phpt b/tests/array_bind_004.phpt
new file mode 100644
index 0000000000..1ddf85149b
--- /dev/null
+++ b/tests/array_bind_004.phpt
@@ -0,0 +1,65 @@
+--TEST--
+oci_bind_array_by_name() and invalid values 4
+--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();
+
+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(): OCI_NO_DATA in %s on line %d
+array(0) {
+}
+Done
diff --git a/tests/array_bind_005.phpt b/tests/array_bind_005.phpt
new file mode 100644
index 0000000000..58dadc20ca
--- /dev/null
+++ b/tests/array_bind_005.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and invalid values 5
+--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, 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/tests/array_bind_006.phpt b/tests/array_bind_006.phpt
new file mode 100644
index 0000000000..e229dd8722
--- /dev/null
+++ b/tests/array_bind_006.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name(), SQLT_CHR and default max_length
+--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("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/tests/array_bind_007.phpt b/tests/array_bind_007.phpt
new file mode 100644
index 0000000000..10c92a8e7d
--- /dev/null
+++ b/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-01008: not all variables bound 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/tests/array_bind_008.phpt b/tests/array_bind_008.phpt
new file mode 100644
index 0000000000..c44304c11c
--- /dev/null
+++ b/tests/array_bind_008.phpt
@@ -0,0 +1,78 @@
+--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';
+
+$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: array bind type must match PL/SQL table row type
+ORA-06550: line %d, column %d:
+PL/SQL: Statement ignored 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/tests/array_bind_009.phpt b/tests/array_bind_009.phpt
new file mode 100644
index 0000000000..8e83b0982c
--- /dev/null
+++ b/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/tests/array_bind_010.phpt b/tests/array_bind_010.phpt
new file mode 100644
index 0000000000..a77ed913ea
--- /dev/null
+++ b/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 v$session');
+
+$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/tests/array_bind_011.phpt b/tests/array_bind_011.phpt
new file mode 100644
index 0000000000..e8e00a8091
--- /dev/null
+++ b/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-01008: not all variables bound in %s on line %d
+array(0) {
+}
+Done
diff --git a/tests/array_bind_012.phpt b/tests/array_bind_012.phpt
new file mode 100644
index 0000000000..2208f0b3b9
--- /dev/null
+++ b/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 v$session');
+
+$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/tests/array_bind_013.phpt b/tests/array_bind_013.phpt
new file mode 100644
index 0000000000..4da9d8bbed
--- /dev/null
+++ b/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/tests/array_bind_014.phpt b/tests/array_bind_014.phpt
new file mode 100644
index 0000000000..bd9fdf1335
--- /dev/null
+++ b/tests/array_bind_014.phpt
@@ -0,0 +1,73 @@
+--TEST--
+oci_bind_array_by_name() and NUMBERs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$drop = "DROP table bind_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "CREATE table bind_test(name NUMBER)";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+$create_pkg = "
+CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
+ TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
+ PROCEDURE iobind(c1 IN OUT ARRTYPE);
+END ARRAYBINDPKG1;";
+$statement = oci_parse($c, $create_pkg);
+oci_execute($statement);
+
+$create_pkg_body = "
+CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
+ CURSOR CUR IS SELECT name FROM bind_test;
+ PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
+ BEGIN
+ IF NOT CUR%ISOPEN THEN
+ OPEN CUR;
+ END IF;
+ FOR i IN REVERSE 1..5 LOOP
+ FETCH CUR INTO c1(i);
+ IF CUR%NOTFOUND THEN
+ CLOSE CUR;
+ EXIT;
+ END IF;
+ END LOOP;
+ END iobind;
+END ARRAYBINDPKG1;";
+$statement = oci_parse($c, $create_pkg_body);
+oci_execute($statement);
+
+for ($i = 1; $i < 6; $i++) {
+ $statement = oci_parse($c, "INSERT INTO bind_test VALUES (".$i.")");
+ oci_execute($statement);
+}
+
+$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
+$array = Array();
+oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_INT);
+oci_execute($statement);
+
+var_dump($array);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(5) {
+ [0]=>
+ int(5)
+ [1]=>
+ int(4)
+ [2]=>
+ int(3)
+ [3]=>
+ int(2)
+ [4]=>
+ int(1)
+}
+Done
diff --git a/tests/array_bind_date.phpt b/tests/array_bind_date.phpt
new file mode 100644
index 0000000000..63da558f91
--- /dev/null
+++ b/tests/array_bind_date.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_ODT
+--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, 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/tests/array_bind_date1.phpt b/tests/array_bind_date1.phpt
new file mode 100644
index 0000000000..ebf767570b
--- /dev/null
+++ b/tests/array_bind_date1.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_ODT
+--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, 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/tests/array_bind_float.phpt b/tests/array_bind_float.phpt
new file mode 100644
index 0000000000..1aafb24317
--- /dev/null
+++ b/tests/array_bind_float.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_FLT
+--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 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/tests/array_bind_float1.phpt b/tests/array_bind_float1.phpt
new file mode 100644
index 0000000000..ead85890fa
--- /dev/null
+++ b/tests/array_bind_float1.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_FLT
+--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 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/tests/array_bind_int.phpt b/tests/array_bind_int.phpt
new file mode 100644
index 0000000000..3c8bfd4f57
--- /dev/null
+++ b/tests/array_bind_int.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_INT
+--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, 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/tests/array_bind_int1.phpt b/tests/array_bind_int1.phpt
new file mode 100644
index 0000000000..5e06de876b
--- /dev/null
+++ b/tests/array_bind_int1.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_INT
+--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, 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/tests/array_bind_str.phpt b/tests/array_bind_str.phpt
new file mode 100644
index 0000000000..c8e1e0cdb5
--- /dev/null
+++ b/tests/array_bind_str.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_AVC
+--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("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/tests/array_bind_str1.phpt b/tests/array_bind_str1.phpt
new file mode 100644
index 0000000000..af4dbfe220
--- /dev/null
+++ b/tests/array_bind_str1.phpt
@@ -0,0 +1,74 @@
+--TEST--
+oci_bind_array_by_name() and SQLT_AVC
+--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("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/tests/b47243_1.phpt b/tests/b47243_1.phpt
new file mode 100644
index 0000000000..9f04f302cb
--- /dev/null
+++ b/tests/b47243_1.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #47243 (Crash on exit with ZTS mode)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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/tests/b47243_2.phpt b/tests/b47243_2.phpt
new file mode 100644
index 0000000000..08f5f528c3
--- /dev/null
+++ b/tests/b47243_2.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #47243 (Crash on exit with ZTS mode)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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/tests/b47243_3.phpt b/tests/b47243_3.phpt
new file mode 100644
index 0000000000..0decb34872
--- /dev/null
+++ b/tests/b47243_3.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #47243 (Crash on exit with ZTS mode)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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/tests/bind_char_1.phpt b/tests/bind_char_1.phpt
new file mode 100644
index 0000000000..71cccbfc50
--- /dev/null
+++ b/tests/bind_char_1.phpt
@@ -0,0 +1,306 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
+
+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 ')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_1_11gR1.phpt b/tests/bind_char_1_11gR1.phpt
new file mode 100644
index 0000000000..60b7142ff1
--- /dev/null
+++ b/tests/bind_char_1_11gR1.phpt
@@ -0,0 +1,297 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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 ')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_2.phpt b/tests/bind_char_2.phpt
new file mode 100644
index 0000000000..6c7dbafcc5
--- /dev/null
+++ b/tests/bind_char_2.phpt
@@ -0,0 +1,127 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
+
+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')",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_2_11gR1.phpt b/tests/bind_char_2_11gR1.phpt
new file mode 100644
index 0000000000..68a872fc46
--- /dev/null
+++ b/tests/bind_char_2_11gR1.phpt
@@ -0,0 +1,123 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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')",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_3.phpt b/tests/bind_char_3.phpt
new file mode 100644
index 0000000000..8d4e95f6bf
--- /dev/null
+++ b/tests/bind_char_3.phpt
@@ -0,0 +1,345 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
+
+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;",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop function bind_char_3_fn"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_3_11gR1.phpt b/tests/bind_char_3_11gR1.phpt
new file mode 100644
index 0000000000..aaa5371195
--- /dev/null
+++ b/tests/bind_char_3_11gR1.phpt
@@ -0,0 +1,344 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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;",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop function bind_char_3_fn"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_4.phpt b/tests/bind_char_4.phpt
new file mode 100644
index 0000000000..40221b266f
--- /dev/null
+++ b/tests/bind_char_4.phpt
@@ -0,0 +1,347 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
+
+// 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;",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop function bind_char_3_fn"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_char_4_11gR1.phpt b/tests/bind_char_4_11gR1.phpt
new file mode 100644
index 0000000000..c4f7968e14
--- /dev/null
+++ b/tests/bind_char_4_11gR1.phpt
@@ -0,0 +1,346 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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;",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop function bind_char_3_fn"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bind_empty.phpt b/tests/bind_empty.phpt
new file mode 100644
index 0000000000..4c6c07e3c0
--- /dev/null
+++ b/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/tests/bind_long.phpt b/tests/bind_long.phpt
new file mode 100644
index 0000000000..ba6bd4d044
--- /dev/null
+++ b/tests/bind_long.phpt
@@ -0,0 +1,41 @@
+--TEST--
+bind LONG field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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);
+
+$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");
+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--
+string(32) "5c7c34abf7ea51936785062dbfcaeddc"
+int(394)
+Done
diff --git a/tests/bind_long_raw.phpt b/tests/bind_long_raw.phpt
new file mode 100644
index 0000000000..2a9962eace
--- /dev/null
+++ b/tests/bind_long_raw.phpt
@@ -0,0 +1,38 @@
+--TEST--
+bind LONG RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/bind_raw.phpt b/tests/bind_raw.phpt
new file mode 100644
index 0000000000..c9087e552b
--- /dev/null
+++ b/tests/bind_raw.phpt
@@ -0,0 +1,39 @@
+--TEST--
+bind RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestrawtable( id number(10), fileimage raw(1000))");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestrawtable (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+$fileimage = substr($fileimage, 0, 300);
+
+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/tests/bind_rowid.phpt b/tests/bind_rowid.phpt
new file mode 100644
index 0000000000..f15d8f8bbb
--- /dev/null
+++ b/tests/bind_rowid.phpt
@@ -0,0 +1,86 @@
+--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);
+ }
+}
+
+$stmts = 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')"
+);
+
+foreach ($stmts as $q) {
+ $s = oci_parse($c, $q);
+ @oci_execute($s);
+}
+
+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
+
+$stmts = array("drop table rid_tab");
+
+foreach ($stmts as $q) {
+ $s = oci_parse($c, $q);
+ @oci_execute($s);
+}
+
+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/tests/bug26133.phpt b/tests/bug26133.phpt
new file mode 100644
index 0000000000..2463e70c76
--- /dev/null
+++ b/tests/bug26133.phpt
@@ -0,0 +1,62 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+Done
diff --git a/tests/bug27303_1.phpt b/tests/bug27303_1.phpt
new file mode 100644
index 0000000000..82c2d6f506
--- /dev/null
+++ b/tests/bug27303_1.phpt
@@ -0,0 +1,261 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 19gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff with a 32bit 11.2.0.1 DB
+
+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);
+
+$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);
+
+$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";
+?>
+--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 \ No newline at end of file
diff --git a/tests/bug27303_1_11gR1.phpt b/tests/bug27303_1_11gR1.phpt
new file mode 100644
index 0000000000..fe5c17c3ee
--- /dev/null
+++ b/tests/bug27303_1_11gR1.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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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);
+
+$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);
+
+$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";
+?>
+--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/tests/bug27303_2.phpt b/tests/bug27303_2.phpt
new file mode 100644
index 0000000000..44b9ce6c61
--- /dev/null
+++ b/tests/bug27303_2.phpt
@@ -0,0 +1,263 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 database");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff with a 32bit 11.2.0.1 DB
+
+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);
+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";
+?>
+--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 \ No newline at end of file
diff --git a/tests/bug27303_2_11gR1.phpt b/tests/bug27303_2_11gR1.phpt
new file mode 100644
index 0000000000..e1daef0537
--- /dev/null
+++ b/tests/bug27303_2_11gR1.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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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);
+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";
+?>
+--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/tests/bug27303_3.phpt b/tests/bug27303_3.phpt
new file mode 100644
index 0000000000..6395388471
--- /dev/null
+++ b/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/tests/bug27303_4.phpt b/tests/bug27303_4.phpt
new file mode 100644
index 0000000000..3c35c65b77
--- /dev/null
+++ b/tests/bug27303_4.phpt
@@ -0,0 +1,261 @@
+--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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff with a 32bit 11.2.0.1 DB
+
+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);
+
+$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";
+
+foreach ($create_st as $statement) {
+ $stmt = oci_parse($c, $statement);
+ oci_execute($stmt);
+}
+
+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/tests/bug27303_4_11gR1.phpt b/tests/bug27303_4_11gR1.phpt
new file mode 100644
index 0000000000..0c88360be2
--- /dev/null
+++ b/tests/bug27303_4_11gR1.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");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 11\.1\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR1 database");
+}
+?>
+--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);
+
+$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";
+
+foreach ($create_st as $statement) {
+ $stmt = oci_parse($c, $statement);
+ oci_execute($stmt);
+}
+
+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/tests/bug32325.phpt b/tests/bug32325.phpt
new file mode 100644
index 0000000000..257c6977b8
--- /dev/null
+++ b/tests/bug32325.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Bug #32325 (Cannot retrieve collection using OCI8)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialize
+
+$stmtarray = array(
+ "create or replace type bug32325_t as table of number"
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+int(4)
+float(2)
+float(3)
+Done
diff --git a/tests/bug35973.phpt b/tests/bug35973.phpt
new file mode 100644
index 0000000000..81e1e58ba2
--- /dev/null
+++ b/tests/bug35973.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #35973 (Error ORA-24806 occurs when trying to fetch a NCLOB field)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$s1 = oci_parse($c, "drop table test_nclob");
+@oci_execute($s1);
+
+$s2 = oci_parse($c, "create table test_nclob (nc NCLOB)");
+oci_execute($s2);
+
+$s3 = oci_parse($c, "insert into test_nclob (nc) values ('12345data')");
+oci_execute($s3);
+
+$s3 = oci_parse($c, "select * from test_nclob");
+oci_execute($s3);
+
+var_dump($data = oci_fetch_assoc($s3));
+$d = $data['NC'];
+
+var_dump($d->read(5));
+var_dump($d->read(4));
+
+$s1 = oci_parse($c, "drop table test_nclob");
+@oci_execute($s1);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(1) {
+ ["NC"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(%d) "%s5"
+string(%d) "%sa"
+Done
diff --git a/tests/bug36010.phpt b/tests/bug36010.phpt
new file mode 100644
index 0000000000..d451f3f2f4
--- /dev/null
+++ b/tests/bug36010.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #36010 (Crash when executing SQL statment with lob parameter twice)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/bug36096.phpt b/tests/bug36096.phpt
new file mode 100644
index 0000000000..44b3a6ddca
--- /dev/null
+++ b/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";
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+string(5) "'ABC'"
+string(4) "CHAR"
+Done
diff --git a/tests/bug36403.phpt b/tests/bug36403.phpt
new file mode 100644
index 0000000000..68c5f7b0a1
--- /dev/null
+++ b/tests/bug36403.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Bug #36403 (oci_execute no longer supports OCI_DESCRIBE_ONLY)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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)"
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop table bug36403_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+COL4
+COLUMN3
+COL2
+C1
+Test 2
+
+Warning: oci_fetch_array(): ORA-24338: %sbug36403.php on line %d
+===DONE===
diff --git a/tests/bug37220.phpt b/tests/bug37220.phpt
new file mode 100644
index 0000000000..6743165b70
--- /dev/null
+++ b/tests/bug37220.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Bug #37220 (LOB Type mismatch when using windows & oci8.dll)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--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>'))"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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 $item."\n";
+ }
+ echo "\n";
+}
+
+// Cleanup
+
+$stmtarray = array(
+ "drop table bug37220_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+
+?>
+--EXPECT--
+<MYTAG/>
+
+Done
diff --git a/tests/bug37581.phpt b/tests/bug37581.phpt
new file mode 100644
index 0000000000..ec86c51959
--- /dev/null
+++ b/tests/bug37581.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC)
+--SKIPIF--
+<?php if (!extension_loaded("oci8")) print "skip"; ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$p1 = "create or replace package ARRAYBINDPKG1 as
+type str_array is table of char(2) index by binary_integer;
+procedure array_bind(in_str in str_array, out_str out string);
+end ARRAYBINDPKG1;";
+
+$p2 = "create or replace package body ARRAYBINDPKG1 as
+ procedure array_bind(in_str in str_array, out_str out string) is
+ begin
+ for i in 1 .. in_str.count loop
+ out_str := in_str(i);
+ end loop;
+ end array_bind;
+end ARRAYBINDPKG1;";
+
+$s1 = oci_parse($c, $p1);
+$s2 = oci_parse($c, $p2);
+oci_execute($s1);
+oci_execute($s2);
+
+
+$stmt = oci_parse($c,'begin ARRAYBINDPKG1.array_bind(:in_arr, :out_str); end;');
+$strings = array('A','B','C','D','E');
+
+oci_bind_array_by_name($stmt,':in_arr',$strings,5,1,SQLT_AFC);
+oci_bind_by_name($stmt,':out_str',$result,10);
+
+oci_execute($stmt);
+var_dump($strings);
+
+oci_execute($stmt);
+var_dump($strings);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(5) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(1) "B"
+ [2]=>
+ string(1) "C"
+ [3]=>
+ string(1) "D"
+ [4]=>
+ string(1) "E"
+}
+array(5) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(1) "B"
+ [2]=>
+ string(1) "C"
+ [3]=>
+ string(1) "D"
+ [4]=>
+ string(1) "E"
+}
+Done
diff --git a/tests/bug38161.phpt b/tests/bug38161.phpt
new file mode 100644
index 0000000000..e0fbba816a
--- /dev/null
+++ b/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/tests/bug38173.phpt b/tests/bug38173.phpt
new file mode 100644
index 0000000000..b92df9e39e
--- /dev/null
+++ b/tests/bug38173.phpt
@@ -0,0 +1,79 @@
+--TEST--
+Bug #38173 (Freeing nested cursors causes OCI8 to segfault)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$create_1 = "CREATE TABLE t1 (id INTEGER)";
+$create_2 = "CREATE TABLE t2 (id INTEGER)";
+$drop_1 = "DROP TABLE t1";
+$drop_2 = "DROP TABLE t2";
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+$s1 = oci_parse($c, $create_1);
+$s2 = oci_parse($c, $create_2);
+oci_execute($s1);
+oci_execute($s2);
+
+for($i=0; $i < 5; $i++) {
+ $insert = "INSERT INTO t1 VALUES(".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+for($i=0; $i < 5; $i++) {
+ $insert = "INSERT INTO t2 VALUES(".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+$query ="
+SELECT
+ t1.*,
+ CURSOR( SELECT * FROM t2 ) as cursor
+FROM
+ t1
+";
+
+$sth = oci_parse($c, $query);
+oci_execute($sth);
+
+// dies on oci_free_statement on 2nd pass through loop
+while ( $row = oci_fetch_assoc($sth) ) {
+ print "Got row!\n";
+ var_dump(oci_execute($row['CURSOR']));
+ var_dump(oci_free_statement($row['CURSOR']));
+}
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Got row!
+bool(true)
+bool(true)
+Done
diff --git a/tests/bug40078.phpt b/tests/bug40078.phpt
new file mode 100644
index 0000000000..4a234e176d
--- /dev/null
+++ b/tests/bug40078.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name())
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$create_pkg = "
+CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
+ TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
+ PROCEDURE nullbind(c1 OUT ARRTYPE);
+END ARRAYBINDPKG1;";
+$statement = oci_parse($c, $create_pkg);
+oci_execute($statement);
+
+$create_pkg_body = "
+CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
+ PROCEDURE nullbind(c1 OUT ARRTYPE) IS
+ BEGIN
+ c1(1) := 'one';
+ c1(2) := 'two';
+ c1(3) := '';
+ c1(4) := 'four';
+ c1(5) := 'five';
+ END nullbind;
+END ARRAYBINDPKG1;";
+$statement = oci_parse($c, $create_pkg_body);
+oci_execute($statement);
+
+$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.nullbind(:c1); END;");
+
+oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR);
+
+oci_execute($statement);
+
+var_dump($array);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(5) {
+ [0]=>
+ string(3) "one"
+ [1]=>
+ string(3) "two"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(4) "four"
+ [4]=>
+ string(4) "five"
+}
+Done
diff --git a/tests/bug40415.phpt b/tests/bug40415.phpt
new file mode 100644
index 0000000000..1ebc249d38
--- /dev/null
+++ b/tests/bug40415.phpt
@@ -0,0 +1,200 @@
+--TEST--
+Bug #40415 (Using oci_fetchall with nested cursors)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+// Setup
+
+$create_1 = "CREATE TABLE t1 (id1 INTEGER)";
+$create_2 = "CREATE TABLE t2 (id2 INTEGER)";
+$drop_1 = "DROP TABLE t1";
+$drop_2 = "DROP TABLE t2";
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+$s1 = oci_parse($c, $create_1);
+$s2 = oci_parse($c, $create_2);
+oci_execute($s1);
+oci_execute($s2);
+
+for($i=1; $i < 4; $i++) {
+ $insert = "INSERT INTO t1 VALUES(1".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+for($i=1; $i < 4; $i++) {
+ $insert = "INSERT INTO t2 VALUES(2".$i.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+
+function do_assoc($c)
+{
+ $query = "SELECT t1.*, CURSOR( SELECT * FROM t2 ) AS CURSOR FROM t1";
+
+ $stmt = oci_parse($c, $query);
+ oci_execute($stmt);
+
+ while ($row = oci_fetch_assoc($stmt)) {
+ print "Got row \"".$row['ID1']."\". Now getting nested cursor:\n";
+ var_dump(oci_execute($row['CURSOR']));
+ while ($row_n = oci_fetch_assoc($row['CURSOR']) ) {
+ var_dump($row_n);
+ }
+ }
+}
+
+function do_all($c)
+{
+ $query = "SELECT t1.*, CURSOR( SELECT * FROM t2 ) AS CURSOR FROM t1";
+
+ $stmt = oci_parse($c, $query);
+ oci_execute($stmt);
+
+ $rc1 = oci_fetch_all($stmt, $res);
+
+ echo "Rows returned $rc1\n";
+
+ var_dump($res);
+
+ foreach ($res['CURSOR'] as $cv) {
+ echo "Getting nested cursor\n";
+ var_dump(oci_execute($cv));
+ $rc2 = oci_fetch_all($cv, $res2);
+ var_dump($res2);
+ }
+}
+
+
+
+echo "Test 1: Associate fetch of nested cursor\n";
+do_assoc($c);
+
+echo "\nTest 2: fetchall of nested cursor\n";
+do_all($c);
+
+
+// Cleanup
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Test 1: Associate fetch of nested cursor
+Got row "11". Now getting nested cursor:
+bool(true)
+array(1) {
+ ["ID2"]=>
+ string(2) "21"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "22"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "23"
+}
+Got row "12". Now getting nested cursor:
+bool(true)
+array(1) {
+ ["ID2"]=>
+ string(2) "21"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "22"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "23"
+}
+Got row "13". Now getting nested cursor:
+bool(true)
+array(1) {
+ ["ID2"]=>
+ string(2) "21"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "22"
+}
+array(1) {
+ ["ID2"]=>
+ string(2) "23"
+}
+
+Test 2: fetchall of nested cursor
+Rows returned 3
+array(2) {
+ ["ID1"]=>
+ array(3) {
+ [0]=>
+ string(2) "11"
+ [1]=>
+ string(2) "12"
+ [2]=>
+ string(2) "13"
+ }
+ ["CURSOR"]=>
+ array(3) {
+ [0]=>
+ resource(%d) of type (oci8 statement)
+ [1]=>
+ resource(%d) of type (oci8 statement)
+ [2]=>
+ resource(%d) of type (oci8 statement)
+ }
+}
+Getting nested cursor
+bool(true)
+array(1) {
+ ["ID2"]=>
+ array(3) {
+ [0]=>
+ string(2) "21"
+ [1]=>
+ string(2) "22"
+ [2]=>
+ string(2) "23"
+ }
+}
+Getting nested cursor
+bool(true)
+array(1) {
+ ["ID2"]=>
+ array(3) {
+ [0]=>
+ string(2) "21"
+ [1]=>
+ string(2) "22"
+ [2]=>
+ string(2) "23"
+ }
+}
+Getting nested cursor
+bool(true)
+array(1) {
+ ["ID2"]=>
+ array(3) {
+ [0]=>
+ string(2) "21"
+ [1]=>
+ string(2) "22"
+ [2]=>
+ string(2) "23"
+ }
+}
+Done
diff --git a/tests/bug41069.phpt b/tests/bug41069.phpt
new file mode 100644
index 0000000000..b3a1b9969c
--- /dev/null
+++ b/tests/bug41069.phpt
@@ -0,0 +1,275 @@
+--TEST--
+Bug #41069 (Oracle crash with certain data over a DB-link when prefetch memory limit used - Oracle bug 6039623)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+require(dirname(__FILE__).'/details.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')"
+ );
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+
+// 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"
+ );
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+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/tests/bug42134.phpt b/tests/bug42134.phpt
new file mode 100644
index 0000000000..2b0e3707d6
--- /dev/null
+++ b/tests/bug42134.phpt
@@ -0,0 +1,100 @@
+--TEST--
+Bug #42134 (Collection error for invalid collection name)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/bug42173.phpt b/tests/bug42173.phpt
new file mode 100644
index 0000000000..501ed75cd0
--- /dev/null
+++ b/tests/bug42173.phpt
@@ -0,0 +1,168 @@
+--TEST--
+Bug #42173 (TIMESTAMP and INTERVAL query and field functions)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/bug42496_1.phpt b/tests/bug42496_1.phpt
new file mode 100644
index 0000000000..4d7e2c5852
--- /dev/null
+++ b/tests/bug42496_1.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+// Initialization
+
+$stmtarray = array(
+ "DROP table bug42496_tab",
+ "CREATE table bug42496_tab(c1 CLOB, c2 CLOB)",
+ "INSERT INTO bug42496_tab VALUES('test1', 'test1')",
+ "INSERT INTO bug42496_tab VALUES('test2', 'test2')",
+ "INSERT INTO bug42496_tab VALUES('test3', 'test3')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// Run Test
+
+echo "Test 1\n";
+
+for ($i = 0; $i < 15000; $i++) {
+ $s = oci_parse($c, "SELECT * from bug42496_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_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+--EXPECTF--
+Test 1
+Done
diff --git a/tests/bug42496_2.phpt b/tests/bug42496_2.phpt
new file mode 100644
index 0000000000..e2800bbd8a
--- /dev/null
+++ b/tests/bug42496_2.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+// Initialization
+
+$stmtarray = array(
+ "DROP table bug42496_tab",
+ "CREATE table bug42496_tab(c1 CLOB, c2 CLOB)",
+ "INSERT INTO bug42496_tab VALUES('test1', 'test1')",
+ "INSERT INTO bug42496_tab VALUES('test2', 'test2')",
+ "INSERT INTO bug42496_tab VALUES('test3', 'test3')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// Run Test
+
+echo "Test 2\n";
+
+for ($i = 0; $i < 15000; $i++) {
+ $s = oci_parse($c, "SELECT * from bug42496_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_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+--EXPECTF--
+Test 2
+Done
diff --git a/tests/bug42841.phpt b/tests/bug42841.phpt
new file mode 100644
index 0000000000..921c8149dd
--- /dev/null
+++ b/tests/bug42841.phpt
@@ -0,0 +1,187 @@
+--TEST--
+Bug #42841 (REF CURSOR and oci_new_cursor PHP crash)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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;"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/bug43492.phpt b/tests/bug43492.phpt
new file mode 100644
index 0000000000..d28aabfced
--- /dev/null
+++ b/tests/bug43492.phpt
@@ -0,0 +1,378 @@
+--TEST--
+Bug #43492 (Nested cursor leaks)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+/*
+
+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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+--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/tests/bug43492_2.phpt b/tests/bug43492_2.phpt
new file mode 100644
index 0000000000..fcf96e984e
--- /dev/null
+++ b/tests/bug43492_2.phpt
@@ -0,0 +1,369 @@
+--TEST--
+Bug #43492 (Nested cursor leaks after related bug #44206 fixed)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+--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/tests/bug43497.phpt b/tests/bug43497.phpt
new file mode 100644
index 0000000000..1ea46b40d7
--- /dev/null
+++ b/tests/bug43497.phpt
@@ -0,0 +1,303 @@
+--TEST--
+Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Oracle Version => 9/', $phpinfo);
+if ($ov === 1) {
+ die ("skip expected output only valid for Oracle clients from 10g onwards");
+}
+?>
+--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/tests/bug43497_92.phpt b/tests/bug43497_92.phpt
new file mode 100644
index 0000000000..e2cb1ce486
--- /dev/null
+++ b/tests/bug43497_92.phpt
@@ -0,0 +1,303 @@
+--TEST--
+Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Oracle Version => 9.2/', $phpinfo);
+if ($ov !== 1) {
+ die ("skip expected output only valid for Oracle 9.2 clients");
+}
+?>
+--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/tests/bug44008.phpt b/tests/bug44008.phpt
new file mode 100644
index 0000000000..fd10b26b8b
--- /dev/null
+++ b/tests/bug44008.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Bug #44008 (Incorrect usage of OCI-Lob->close doesn't crash PHP)
+--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 bug44008_proc (p in out clob)
+ as begin p := 'A';
+ end;"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+A
+Done
diff --git a/tests/bug44113.phpt b/tests/bug44113.phpt
new file mode 100644
index 0000000000..eee21c3aef
--- /dev/null
+++ b/tests/bug44113.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Bug #44113 (New collection creation can fail with OCI-22303)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+require(dirname(__FILE__).'/details.inc');
+if ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+ "create or replace type bug44113_list_t as table of number"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Completed 70000
+Done
diff --git a/tests/bug44206.phpt b/tests/bug44206.phpt
new file mode 100644
index 0000000000..e5771e4182
--- /dev/null
+++ b/tests/bug44206.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #44206 (Test if selecting ref cursors leads to ORA-1000 maximum open cursors reached)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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/tests/bug45458.phpt b/tests/bug45458.phpt
new file mode 100644
index 0000000000..b1dc7720ce
--- /dev/null
+++ b/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/tests/bug46994.phpt b/tests/bug46994.phpt
new file mode 100644
index 0000000000..0504952f69
--- /dev/null
+++ b/tests/bug46994.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
+--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 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;"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/bug47189.phpt b/tests/bug47189.phpt
new file mode 100644
index 0000000000..073b410fcd
--- /dev/null
+++ b/tests/bug47189.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #47189 (Multiple oci_fetch_all calls)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+$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);
+
+$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--
+array(1) {
+ [0]=>
+ array(1) {
+ ["DUMMY"]=>
+ string(1) "X"
+ }
+}
+array(0) {
+}
+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/tests/bug47281.phpt b/tests/bug47281.phpt
new file mode 100644
index 0000000000..710246738e
--- /dev/null
+++ b/tests/bug47281.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Bug #47281 ($php_errormsg is limited in size of characters)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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;"
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccDeeeeeeeeeeee
+Test 2
+oci_execute(): ORA-20000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+===DONE===
diff --git a/tests/bug51253.phpt b/tests/bug51253.phpt
new file mode 100644
index 0000000000..fea3333ccf
--- /dev/null
+++ b/tests/bug51253.phpt
@@ -0,0 +1,165 @@
+--TEST--
+Bug #51253 (oci_bind_array_by_name() array references)
+--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);
+
+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/tests/bug51291.phpt b/tests/bug51291.phpt
new file mode 100644
index 0000000000..75851d63b1
--- /dev/null
+++ b/tests/bug51291.phpt
@@ -0,0 +1,434 @@
+--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));
+}
+
+echo "\nTest 10 - 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 - 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.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.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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+2nd call
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+2nd call
+bool(false)
+bool(false)
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+
+Test 5 - Execute - after oci_rollback
+bool(false)
+bool(false)
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+
+Warning: oci_execute(): ORA-00904: "REALLYNOTHERE": %s in %sbug51291.php on line %d
+Execute status is false
+2nd call after unsuccessful execute
+bool(false)
+bool(false)
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(46) "ORA-00904: "REALLYNOTHERE": %s"
+ ["offset"]=>
+ int(7)
+ ["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(45) "ORA-00904: "DOESNOTEXIST": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(29) "select doesnotexist from dual"
+}
+
+Warning: oci_execute(): ORA-00904: "REALLYNOTHERE": %s in %sbug51291.php on line %d
+Execute status is false
+2nd call after unsuccessful execute
+bool(false)
+bool(false)
+array(4) {
+ ["code"]=>
+ int(904)
+ ["message"]=>
+ string(46) "ORA-00904: "REALLYNOTHERE": %s"
+ ["offset"]=>
+ int(7)
+ ["sqltext"]=>
+ string(30) "select reallynothere from dual"
+}
+
+Test 10 - 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/tests/close.phpt b/tests/close.phpt
new file mode 100644
index 0000000000..55bb4ea364
--- /dev/null
+++ b/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/tests/coll_001.phpt b/tests/coll_001.phpt
new file mode 100644
index 0000000000..57d3cf1b47
--- /dev/null
+++ b/tests/coll_001.phpt
@@ -0,0 +1,27 @@
+--TEST--
+oci_new_collection()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_002.phpt b/tests/coll_002.phpt
new file mode 100644
index 0000000000..6d30519897
--- /dev/null
+++ b/tests/coll_002.phpt
@@ -0,0 +1,30 @@
+--TEST--
+oci_new_collection() + free()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_002_func.phpt b/tests/coll_002_func.phpt
new file mode 100644
index 0000000000..58e641ee24
--- /dev/null
+++ b/tests/coll_002_func.phpt
@@ -0,0 +1,30 @@
+--TEST--
+oci_new_collection() + free()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_003.phpt b/tests/coll_003.phpt
new file mode 100644
index 0000000000..b5236ef6f6
--- /dev/null
+++ b/tests/coll_003.phpt
@@ -0,0 +1,34 @@
+--TEST--
+collection methods
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+
+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/tests/coll_003_func.phpt b/tests/coll_003_func.phpt
new file mode 100644
index 0000000000..f5c6dc7f38
--- /dev/null
+++ b/tests/coll_003_func.phpt
@@ -0,0 +1,34 @@
+--TEST--
+collection methods
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+
+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/tests/coll_004.phpt b/tests/coll_004.phpt
new file mode 100644
index 0000000000..eb2ac7e26d
--- /dev/null
+++ b/tests/coll_004.phpt
@@ -0,0 +1,29 @@
+--TEST--
+oci_collection_assign()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+$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/tests/coll_004_func.phpt b/tests/coll_004_func.phpt
new file mode 100644
index 0000000000..57dff2eb35
--- /dev/null
+++ b/tests/coll_004_func.phpt
@@ -0,0 +1,29 @@
+--TEST--
+oci_collection_assign()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+$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/tests/coll_005.phpt b/tests/coll_005.phpt
new file mode 100644
index 0000000000..0f40069964
--- /dev/null
+++ b/tests/coll_005.phpt
@@ -0,0 +1,27 @@
+--TEST--
+ocinewcollection()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_006.phpt b/tests/coll_006.phpt
new file mode 100644
index 0000000000..cf258cbe34
--- /dev/null
+++ b/tests/coll_006.phpt
@@ -0,0 +1,30 @@
+--TEST--
+ocinewcollection() + free()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_006_func.phpt b/tests/coll_006_func.phpt
new file mode 100644
index 0000000000..56707d6087
--- /dev/null
+++ b/tests/coll_006_func.phpt
@@ -0,0 +1,30 @@
+--TEST--
+ocinewcollection() + free()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/coll_007.phpt b/tests/coll_007.phpt
new file mode 100644
index 0000000000..31e10c065e
--- /dev/null
+++ b/tests/coll_007.phpt
@@ -0,0 +1,34 @@
+--TEST--
+collection methods
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = 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/tests/coll_008.phpt b/tests/coll_008.phpt
new file mode 100644
index 0000000000..57d44cc9ab
--- /dev/null
+++ b/tests/coll_008.phpt
@@ -0,0 +1,29 @@
+--TEST--
+ocicollassign()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = 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/tests/coll_009.phpt b/tests/coll_009.phpt
new file mode 100644
index 0000000000..296d6493e2
--- /dev/null
+++ b/tests/coll_009.phpt
@@ -0,0 +1,42 @@
+--TEST--
+collections and wrong dates
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_009_func.phpt b/tests/coll_009_func.phpt
new file mode 100644
index 0000000000..3ed416ce09
--- /dev/null
+++ b/tests/coll_009_func.phpt
@@ -0,0 +1,42 @@
+--TEST--
+collections and wrong dates
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_010.phpt b/tests/coll_010.phpt
new file mode 100644
index 0000000000..6f72dd16c1
--- /dev/null
+++ b/tests/coll_010.phpt
@@ -0,0 +1,41 @@
+--TEST--
+collections and nulls
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_010_func.phpt b/tests/coll_010_func.phpt
new file mode 100644
index 0000000000..7b63a276f3
--- /dev/null
+++ b/tests/coll_010_func.phpt
@@ -0,0 +1,41 @@
+--TEST--
+collections and nulls
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_011.phpt b/tests/coll_011.phpt
new file mode 100644
index 0000000000..7d805d3f70
--- /dev/null
+++ b/tests/coll_011.phpt
@@ -0,0 +1,43 @@
+--TEST--
+collections and strings
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_011_func.phpt b/tests/coll_011_func.phpt
new file mode 100644
index 0000000000..dca640e846
--- /dev/null
+++ b/tests/coll_011_func.phpt
@@ -0,0 +1,43 @@
+--TEST--
+collections and strings
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_012.phpt b/tests/coll_012.phpt
new file mode 100644
index 0000000000..543dafd902
--- /dev/null
+++ b/tests/coll_012.phpt
@@ -0,0 +1,41 @@
+--TEST--
+collections and correct dates
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_012_func.phpt b/tests/coll_012_func.phpt
new file mode 100644
index 0000000000..fd1019e411
--- /dev/null
+++ b/tests/coll_012_func.phpt
@@ -0,0 +1,41 @@
+--TEST--
+collections and correct dates
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_013.phpt b/tests/coll_013.phpt
new file mode 100644
index 0000000000..00d88bb9a4
--- /dev/null
+++ b/tests/coll_013.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and correct dates (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_013_func.phpt b/tests/coll_013_func.phpt
new file mode 100644
index 0000000000..0d01bc1744
--- /dev/null
+++ b/tests/coll_013_func.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and correct dates (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_014.phpt b/tests/coll_014.phpt
new file mode 100644
index 0000000000..8458525ae5
--- /dev/null
+++ b/tests/coll_014.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and strings (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_014_func.phpt b/tests/coll_014_func.phpt
new file mode 100644
index 0000000000..a0fe555b61
--- /dev/null
+++ b/tests/coll_014_func.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and strings (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_015.phpt b/tests/coll_015.phpt
new file mode 100644
index 0000000000..64b0aea106
--- /dev/null
+++ b/tests/coll_015.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and numbers (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_015_func.phpt b/tests/coll_015_func.phpt
new file mode 100644
index 0000000000..eeed7839a7
--- /dev/null
+++ b/tests/coll_015_func.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and numbers (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_016.phpt b/tests/coll_016.phpt
new file mode 100644
index 0000000000..c2af9cc22d
--- /dev/null
+++ b/tests/coll_016.phpt
@@ -0,0 +1,48 @@
+--TEST--
+collections and negative/too big element indexes
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_016_func.phpt b/tests/coll_016_func.phpt
new file mode 100644
index 0000000000..cde26f22f0
--- /dev/null
+++ b/tests/coll_016_func.phpt
@@ -0,0 +1,48 @@
+--TEST--
+collections and negative/too big element indexes
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_017.phpt b/tests/coll_017.phpt
new file mode 100644
index 0000000000..42347ba6f8
--- /dev/null
+++ b/tests/coll_017.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and nulls (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_017_func.phpt b/tests/coll_017_func.phpt
new file mode 100644
index 0000000000..914844ae61
--- /dev/null
+++ b/tests/coll_017_func.phpt
@@ -0,0 +1,38 @@
+--TEST--
+collections and nulls (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE
+ ".$type_name."
+ ";
+
+$statement = 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/tests/coll_018.phpt b/tests/coll_018.phpt
new file mode 100644
index 0000000000..f97cc49e7c
--- /dev/null
+++ b/tests/coll_018.phpt
@@ -0,0 +1,93 @@
+--TEST--
+Collection trim tests
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+
+echo "Test 1.\n";
+var_dump($coll1->trim());
+
+echo "\nTest 2.\n";
+var_dump($coll1->trim(0));
+
+echo "\nTest 3.\n";
+var_dump($coll1->append(1));
+var_dump($coll1->append(2));
+var_dump($coll1->append(3));
+var_dump($coll1->append(4));
+
+var_dump($coll1->getElem(-1)); // check before the beginning
+var_dump($coll1->getElem(0));
+var_dump($coll1->getElem(1));
+var_dump($coll1->getElem(2));
+var_dump($coll1->getElem(3));
+var_dump($coll1->getElem(4)); // check past the end
+
+echo "\nTest 4.\n";
+var_dump($coll1->trim(1));
+var_dump($coll1->getElem(2)); // this should be the last element
+var_dump($coll1->getElem(3)); // this element should have gone
+
+echo "\nTest 5.\n";
+var_dump($coll1->trim(2));
+var_dump($coll1->getElem(0)); // this should be the last element
+var_dump($coll1->getElem(1)); // this element should have gone
+
+echo "\nTest 6.\n";
+var_dump($coll1->trim(0));
+var_dump($coll1->getElem(0)); // this should still be the last element
+
+echo "\nTest 7.\n";
+var_dump($coll1->trim(1));
+var_dump($coll1->getElem(0)); // this should have gone
+
+echo "Done\n";
+
+require dirname(__FILE__)."/drop_type.inc";
+
+?>
+--EXPECTF--
+Test 1.
+
+Warning: OCI-Collection::trim() expects exactly 1 parameter, 0 given in %s on line 9
+NULL
+
+Test 2.
+bool(true)
+
+Test 3.
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+float(1)
+float(2)
+float(3)
+float(4)
+bool(false)
+
+Test 4.
+bool(true)
+float(3)
+bool(false)
+
+Test 5.
+bool(true)
+float(1)
+bool(false)
+
+Test 6.
+bool(true)
+float(1)
+
+Test 7.
+bool(true)
+bool(false)
+Done
diff --git a/tests/coll_019.phpt b/tests/coll_019.phpt
new file mode 100644
index 0000000000..15a673d718
--- /dev/null
+++ b/tests/coll_019.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Test collection Oracle error handling collections and numbers (2)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$ora_sql = "DROP TYPE ".$type_name;;
+$statement = oci_parse($c,$ora_sql);
+@oci_execute($statement);
+
+
+echo "Test 0\n";
+$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF BLOB";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$coll1 = oci_new_collection($c, $type_name);
+
+var_dump($coll1->append('a long string')); // invalid type for append
+var_dump($coll1->assignElem(1, 'a long string')); // invalid type for assignelem()
+var_dump($coll1->getElem(0));
+
+require dirname(__FILE__)."/drop_type.inc";
+
+echo "Test 1\n";
+$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$coll1 = oci_new_collection($c, $type_name);
+
+var_dump($coll1->assignElem(1, null)); // invalid location for null
+var_dump($coll1->getElem(0));
+
+echo "Test 2\n";
+var_dump($coll1->assignElem(1, 1234)); // invalid location for number
+var_dump($coll1->getElem(0));
+
+require dirname(__FILE__)."/drop_type.inc";
+
+echo "Test 3\n";
+$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR2(1)";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$coll1 = oci_new_collection($c, $type_name);
+
+var_dump($coll1->assignElem(1, 'abc')); // invalid location for string
+var_dump($coll1->getElem(0));
+
+require dirname(__FILE__)."/drop_type.inc";
+
+echo "Test 4\n";
+$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$coll1 = oci_new_collection($c, $type_name);
+
+var_dump($coll1->append(1)); // invalid date format
+var_dump($coll1->assignElem(1, '01-JAN-06')); // invalid location for date
+var_dump($coll1->getElem(0));
+
+require dirname(__FILE__)."/drop_type.inc";
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 0
+
+Notice: OCI-Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d
+bool(false)
+
+Notice: OCI-Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d
+bool(false)
+bool(false)
+Test 1
+
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
+bool(false)
+bool(false)
+Test 2
+
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
+bool(false)
+bool(false)
+Test 3
+
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
+bool(false)
+bool(false)
+Test 4
+
+Warning: OCI-Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d
+bool(false)
+
+Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
+bool(false)
+bool(false)
+Done
diff --git a/tests/commit_001.phpt b/tests/commit_001.phpt
new file mode 100644
index 0000000000..836d2cd1df
--- /dev/null
+++ b/tests/commit_001.phpt
@@ -0,0 +1,156 @@
+--TEST--
+Test OCI_NO_AUTO_COMMIT constant
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+require(dirname(__FILE__).'/create_table.inc');
+
+$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
+
+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/tests/commit_002.phpt b/tests/commit_002.phpt
new file mode 100644
index 0000000000..1819fe116b
--- /dev/null
+++ b/tests/commit_002.phpt
@@ -0,0 +1,90 @@
+--TEST--
+Test oci_commit failure
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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)"
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===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/tests/commit_old.phpt b/tests/commit_old.phpt
new file mode 100644
index 0000000000..196e0650cc
--- /dev/null
+++ b/tests/commit_old.phpt
@@ -0,0 +1,146 @@
+--TEST--
+ocicommit()/ocirollback()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+
+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/tests/conn_attr.inc b/tests/conn_attr.inc
new file mode 100644
index 0000000000..2c086b1892
--- /dev/null
+++ b/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/tests/conn_attr_1.phpt b/tests/conn_attr_1.phpt
new file mode 100644
index 0000000000..c7c1b870e5
--- /dev/null
+++ b/tests/conn_attr_1.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Set and get of connection attributes with all types of connections.
+--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 output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater client ");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater server");
+}
+
+?>
+--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/tests/conn_attr_2.phpt b/tests/conn_attr_2.phpt
new file mode 100644
index 0000000000..4765d5eb7b
--- /dev/null
+++ b/tests/conn_attr_2.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Set and get of connection attributes across persistent connections and sysdba connection.
+--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 output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--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/tests/conn_attr_3.phpt b/tests/conn_attr_3.phpt
new file mode 100644
index 0000000000..8b6d921230
--- /dev/null
+++ b/tests/conn_attr_3.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Set and get of connection attributes with oci_close().
+--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 output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--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/tests/conn_attr_4.phpt b/tests/conn_attr_4.phpt
new file mode 100644
index 0000000000..9f55f53263
--- /dev/null
+++ b/tests/conn_attr_4.phpt
@@ -0,0 +1,122 @@
+--TEST--
+Set and get of connection attributes with errors.
+--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 output might vary with DRCP");
+if ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--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
+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/tests/conn_attr_5.phpt b/tests/conn_attr_5.phpt
new file mode 100644
index 0000000000..9f6b6c7247
--- /dev/null
+++ b/tests/conn_attr_5.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Set and get connection attributes with scope end.
+--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 output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--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/tests/connect.inc b/tests/connect.inc
new file mode 100644
index 0000000000..5e340cf6fa
--- /dev/null
+++ b/tests/connect.inc
@@ -0,0 +1,18 @@
+<?php
+
+require("details.inc");
+
+if (!empty($dbase)) {
+ $c = @oci_connect($user, $password, $dbase);
+}
+else {
+ $c = @oci_connect($user, $password);
+}
+
+if (!$c) {
+ echo "connect.inc: Failed to connect as '$user' to '$dbase'\n";
+ $e = oci_error();
+ echo $e['message']."\n";
+}
+
+?>
diff --git a/tests/connect.phpt b/tests/connect.phpt
new file mode 100644
index 0000000000..6ce4c533ba
--- /dev/null
+++ b/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/tests/connect_1.phpt b/tests/connect_1.phpt
new file mode 100644
index 0000000000..647a92ceeb
--- /dev/null
+++ b/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/tests/connect_1_old.phpt b/tests/connect_1_old.phpt
new file mode 100644
index 0000000000..8210b82d6c
--- /dev/null
+++ b/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/tests/connect_old.phpt b/tests/connect_old.phpt
new file mode 100644
index 0000000000..55f1734a5a
--- /dev/null
+++ b/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/tests/connect_scope1.phpt b/tests/connect_scope1.phpt
new file mode 100644
index 0000000000..d6d16f17ee
--- /dev/null
+++ b/tests/connect_scope1.phpt
@@ -0,0 +1,93 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+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/tests/connect_scope2.phpt b/tests/connect_scope2.phpt
new file mode 100644
index 0000000000..7017493f5a
--- /dev/null
+++ b/tests/connect_scope2.phpt
@@ -0,0 +1,93 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+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/tests/connect_scope_try1.phpt b/tests/connect_scope_try1.phpt
new file mode 100644
index 0000000000..a881ea6ead
--- /dev/null
+++ b/tests/connect_scope_try1.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_scope_try2.phpt b/tests/connect_scope_try2.phpt
new file mode 100644
index 0000000000..9e6b5ce2e0
--- /dev/null
+++ b/tests/connect_scope_try2.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_scope_try3.phpt b/tests/connect_scope_try3.phpt
new file mode 100644
index 0000000000..1cd44b0218
--- /dev/null
+++ b/tests/connect_scope_try3.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_scope_try4.phpt b/tests/connect_scope_try4.phpt
new file mode 100644
index 0000000000..9b4cd1f278
--- /dev/null
+++ b/tests/connect_scope_try4.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_scope_try5.phpt b/tests/connect_scope_try5.phpt
new file mode 100644
index 0000000000..121fb33dc5
--- /dev/null
+++ b/tests/connect_scope_try5.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_scope_try6.phpt b/tests/connect_scope_try6.phpt
new file mode 100644
index 0000000000..3347543ab8
--- /dev/null
+++ b/tests/connect_scope_try6.phpt
@@ -0,0 +1,100 @@
+--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);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ @oci_execute($s1);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s1 = oci_parse($c1, $stmt);
+ oci_execute($s1);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+Caught Exception: oci_execute(): ORA-00984: %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/tests/connect_with_charset_001.phpt b/tests/connect_with_charset_001.phpt
new file mode 100644
index 0000000000..9149747cdb
--- /dev/null
+++ b/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/tests/connect_without_oracle_home.phpt b/tests/connect_without_oracle_home.phpt
new file mode 100644
index 0000000000..42cbde8b48
--- /dev/null
+++ b/tests/connect_without_oracle_home.phpt
@@ -0,0 +1,34 @@
+--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");
+}
+?>
+--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/tests/connect_without_oracle_home_old.phpt b/tests/connect_without_oracle_home_old.phpt
new file mode 100644
index 0000000000..82d8ae451b
--- /dev/null
+++ b/tests/connect_without_oracle_home_old.phpt
@@ -0,0 +1,34 @@
+--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");
+}
+?>
+--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/tests/create_table.inc b/tests/create_table.inc
new file mode 100644
index 0000000000..afd1fceb9b
--- /dev/null
+++ b/tests/create_table.inc
@@ -0,0 +1,11 @@
+<?php
+ if ($c) {
+ $ora_sql = "DROP TABLE ".$schema.$table_name;
+ $statement = oci_parse($c, $ora_sql);
+ @oci_execute($statement);
+
+ $ora_sql = "CREATE TABLE ".$schema.$table_name." (id NUMBER, value NUMBER, blob BLOB, clob CLOB, string VARCHAR(10))";
+ $statement = oci_parse($c, $ora_sql);
+ oci_execute($statement);
+ }
+?>
diff --git a/tests/create_type.inc b/tests/create_type.inc
new file mode 100644
index 0000000000..e23f7cb903
--- /dev/null
+++ b/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/tests/cursor_bind.phpt b/tests/cursor_bind.phpt
new file mode 100644
index 0000000000..c2ce15cb38
--- /dev/null
+++ b/tests/cursor_bind.phpt
@@ -0,0 +1,99 @@
+--TEST--
+bind and fetch cursor from a statement
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$drop_table = "DROP TABLE ".$schema.$table_name."";
+
+if (!($s = oci_parse($c, $drop_table))) {
+ die("oci_parse(drop) failed!\n");
+}
+
+@oci_execute($s);
+
+$create_table = "CREATE TABLE ".$schema.$table_name." (id NUMBER, value VARCHAR(20))";
+
+if (!($s = oci_parse($c, $create_table))) {
+ die("oci_parse(create) failed!\n");
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(create) 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)) {
+ die("oci_execute(insert) failed!\n");
+ }
+}
+
+if (!oci_commit($c)) {
+ die("oci_commit() failed!\n");
+}
+
+
+$sql = "
+DECLARE
+TYPE curtype IS REF CURSOR;
+cursor_var curtype;
+BEGIN
+ OPEN cursor_var FOR SELECT id, value FROM ".$schema.$table_name.";
+ :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));
+
+echo "Done\n";
+
+$drop_table = "DROP TABLE ".$schema.$table_name."";
+
+if (!($s = oci_parse($c, $drop_table))) {
+ die("oci_parse(drop) failed!\n");
+}
+
+@oci_execute($s);
+
+?>
+--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/tests/cursor_bind_err.phpt b/tests/cursor_bind_err.phpt
new file mode 100644
index 0000000000..33bd04b6d2
--- /dev/null
+++ b/tests/cursor_bind_err.phpt
@@ -0,0 +1,70 @@
+--TEST--
+binding a cursor (with errors)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/cursors.phpt b/tests/cursors.phpt
new file mode 100644
index 0000000000..22c89c9c54
--- /dev/null
+++ b/tests/cursors.phpt
@@ -0,0 +1,65 @@
+--TEST--
+fetching cursor from a statement
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_table.inc";
+
+$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+
+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/tests/cursors_old.phpt b/tests/cursors_old.phpt
new file mode 100644
index 0000000000..73447c82b4
--- /dev/null
+++ b/tests/cursors_old.phpt
@@ -0,0 +1,86 @@
+--TEST--
+fetching cursor from a statement
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/debug.phpt b/tests/debug.phpt
new file mode 100644
index 0000000000..49e3d4cfd1
--- /dev/null
+++ b/tests/debug.phpt
@@ -0,0 +1,71 @@
+--TEST--
+oci_internal_debug()
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv !== 1) {
+ die ("skip expected output only valid when using Oracle 11gR2+ client libraries");
+}
+?>
+--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";
+
+?>
+--EXPECTF--
+OCI8 DEBUG: OCINlsEnvironmentVariableGet at (%s:%d)
+OCI8 DEBUG L1: Got NO cached connection at (%s:%d)
+OCI8 DEBUG: OCIEnvNlsCreate at (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCISessionPoolCreate at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG L1: create_spool: (%s:%d)
+OCI8 DEBUG L1: using shared pool: (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIAttrGet at (%s:%d)
+OCI8 DEBUG: OCIAttrGet at (%s:%d)
+OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (%s:%d)
+OCI8 DEBUG: OCISessionGet at (%s:%d)
+OCI8 DEBUG: OCIAttrGet at (%s:%d)
+OCI8 DEBUG: OCIAttrGet at (%s:%d)
+OCI8 DEBUG: OCIContextGetValue at (%s:%d)
+OCI8 DEBUG: OCIContextGetValue at (%s:%d)
+OCI8 DEBUG: OCIMemoryAlloc at (%s:%d)
+OCI8 DEBUG: OCIContextSetValue at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG L1: New Non-Persistent Connection address: (%s) at (%s:%d)
+OCI8 DEBUG L1: num_persistent=(%s:%d)
+OCI8 DEBUG: OCISessionRelease at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+Done
+OCI8 DEBUG: OCISessionPoolDestroy at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
diff --git a/tests/default_prefetch.phpt b/tests/default_prefetch.phpt
new file mode 100644
index 0000000000..47191c8585
--- /dev/null
+++ b/tests/default_prefetch.phpt
@@ -0,0 +1,73 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(true)
+int(1)
+Done
diff --git a/tests/default_prefetch1.phpt b/tests/default_prefetch1.phpt
new file mode 100644
index 0000000000..bcd66fa381
--- /dev/null
+++ b/tests/default_prefetch1.phpt
@@ -0,0 +1,72 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(true)
+int(1)
+Done
diff --git a/tests/default_prefetch2.phpt b/tests/default_prefetch2.phpt
new file mode 100644
index 0000000000..7b3f29f296
--- /dev/null
+++ b/tests/default_prefetch2.phpt
@@ -0,0 +1,74 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(true)
+bool(true)
+int(1)
+Done
diff --git a/tests/define.phpt b/tests/define.phpt
new file mode 100644
index 0000000000..d99bc7e1a6
--- /dev/null
+++ b/tests/define.phpt
@@ -0,0 +1,62 @@
+--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')",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+%unicode|string%(%d) "some"
+Done
diff --git a/tests/define1.phpt b/tests/define1.phpt
new file mode 100644
index 0000000000..341bc9ed83
--- /dev/null
+++ b/tests/define1.phpt
@@ -0,0 +1,73 @@
+--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')",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/define2.phpt b/tests/define2.phpt
new file mode 100644
index 0000000000..46e11bf886
--- /dev/null
+++ b/tests/define2.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Test oci_define_by_name types
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+
+$stmtarray = array(
+ "drop table phptestrawtable",
+ "create table phptestrawtable( id number(10), fileimage raw(1000))"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+$stmt = oci_parse ($c, "insert into phptestrawtable (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+$fileimage = substr($fileimage, 0, 300);
+var_dump(md5($fileimage));
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_BIN);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+echo "Test 1\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($fi);
+ echo "file md5:" . md5($fi) . "\n";
+}
+
+echo "Test 2\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($fi);
+ echo "file md5:" . md5($fi) . "\n";
+}
+
+echo "Test 3 - test repeatability\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_STR));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($fi);
+ echo "file md5:" . md5($fi) . "\n";
+}
+
+echo "Test 4 - wrong type\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_RSET));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($fi);
+ echo "file md5:" . md5($fi) . "\n";
+}
+
+$stmt = oci_parse($c, "drop table phptestrawtable");
+oci_execute($stmt);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(32) "88b274d7a257ac6f70435b83abd4e26e"
+Test 1
+bool(true)
+string(300) "GIF89%s"
+file md5:88b274d7a257ac6f70435b83abd4e26e
+Test 2
+bool(true)
+string(300) "GIF89%s"
+file md5:88b274d7a257ac6f70435b83abd4e26e
+Test 3 - test repeatability
+bool(true)
+string(600) "47494638396178004300E66A007F82B839374728252ACCCDE2A1A4CBD3D5E7B2B4D44342588386B98283B35252729092C2C2C4DEAAACD04C4B635B5C83DDDEEC3B383C6E71A56A6D9D61638D7579B17B7EB5E5E6F0999CC68C8DC1B9BAD96B6B924E4E6B7174A97A7AA3888BBD7274A37473988E90C15A5B7EE2E3EF7B7DADA4A5D06D70A27276AC9596C8BBBDD97478AE8588BB9295C3D8D9EA9292C46466926B6E9FA5A8CE9496C52E2B2F535168B3B4D76C6A8C5C5B768A8DBF666896686A9A9C9FC8312E39AEB0D39C9CCD5556789EA1CA9699C58182AF6769973F3D50BCBEDA5E60899899C88C8EBF898ABA57587CB6B7D7D5D7E8221E206C6F9ECED0E4BFC0DC777BB47678A75F5E7D9999CC6E6F987377AE221E1FFFFFFF908E8F595657C7C6C7EEEEF5D5D4D5F6F6"
+file md5:80bb3201e2a8bdcb8ab3e1a44a82bb8a
+Test 4 - wrong type
+bool(true)
+
+Warning: oci_fetch(): ORA-00932: inconsistent datatypes%s on line %d
+Done
diff --git a/tests/define3.phpt b/tests/define3.phpt
new file mode 100644
index 0000000000..892e8e3809
--- /dev/null
+++ b/tests/define3.phpt
@@ -0,0 +1,112 @@
+--TEST--
+Test oci_define_by_name() LOB descriptor
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+
+$stmtarray = array(
+ "drop table phpdefblobtable",
+ "create table phpdefblobtable (id number(10), fileimage blob)"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// Load data
+$stmt = oci_parse ($c, "insert into phpdefblobtable (id, fileimage) values (:id, empty_blob()) returning fileimage into :fileimage");
+$fileimage = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($stmt,":id",$id);
+oci_bind_by_name($stmt,":fileimage",$fileimage,-1,OCI_B_BLOB);
+$id = 1;
+oci_execute($stmt, OCI_DEFAULT);
+$fileimage->savefile(dirname(__FILE__)."/test.gif");
+$data = $fileimage->load();
+var_dump(md5($data)); // original md5
+oci_commit($c);
+
+// New row with different data
+$id = 2;
+$data = strrev($data);
+var_dump(md5($data));
+oci_execute($stmt, OCI_DEFAULT);
+$fileimage->save($data);
+oci_commit($c);
+
+echo "Test 1\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $f));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ var_dump($f);
+ echo "file md5:" . md5($f->load()) . "\n";
+}
+
+echo "Test 2\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_STR));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ echo "file md5:" . md5($outdata) . "\n";
+}
+
+echo "Test 3\n";
+$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_BIN));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ echo "file md5:" . md5($outdata) . "\n";
+}
+
+echo "Test 4\n";
+$fid = oci_new_descriptor($c,OCI_D_LOB);
+$stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
+var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fid));
+oci_execute($stmt);
+
+while (oci_fetch($stmt)) {
+ echo "file md5:" . md5($fid->load()) . "\n";
+}
+
+$stmt = oci_parse($c, "drop table phpdefblobtable");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+string(32) "614fcbba1effb7caa27ef0ef25c27fcf"
+string(32) "06d4f219d946c74d748d43932cd9dcb2"
+Test 1
+bool(true)
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+file md5:614fcbba1effb7caa27ef0ef25c27fcf
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+file md5:06d4f219d946c74d748d43932cd9dcb2
+Test 2
+bool(true)
+
+Warning: oci_fetch(): ORA-00932: %s on line %d
+Test 3
+bool(true)
+file md5:614fcbba1effb7caa27ef0ef25c27fcf
+file md5:06d4f219d946c74d748d43932cd9dcb2
+Test 4
+bool(true)
+file md5:614fcbba1effb7caa27ef0ef25c27fcf
+file md5:06d4f219d946c74d748d43932cd9dcb2
+Done
+
diff --git a/tests/define4.phpt b/tests/define4.phpt
new file mode 100644
index 0000000000..8d83f73ac3
--- /dev/null
+++ b/tests/define4.phpt
@@ -0,0 +1,88 @@
+--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')",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/define5.phpt b/tests/define5.phpt
new file mode 100644
index 0000000000..63541ce9dd
--- /dev/null
+++ b/tests/define5.phpt
@@ -0,0 +1,86 @@
+--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')",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/define_old.phpt b/tests/define_old.phpt
new file mode 100644
index 0000000000..618f9d5f57
--- /dev/null
+++ b/tests/define_old.phpt
@@ -0,0 +1,63 @@
+--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')",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+%unicode|string%(4) "some"
+Done
diff --git a/tests/descriptors.phpt b/tests/descriptors.phpt
new file mode 100644
index 0000000000..8be4f3a06d
--- /dev/null
+++ b/tests/descriptors.phpt
@@ -0,0 +1,49 @@
+--TEST--
+commit connection after destroying the descriptor
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$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/tests/details.inc b/tests/details.inc
new file mode 100644
index 0000000000..922b8c4f49
--- /dev/null
+++ b/tests/details.inc
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * Please change $user, $password and $dbase to match your configuration.
+ *
+ * Set $oracle_on_localhost to TRUE if the Oracle Database is
+ * installed on your localhost.
+ *
+ * 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
+ *
+ * Set $stress_test to TRUE if you want to run some longer/slower/more
+ * memory intensive tests.
+ */
+
+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;
+ }
+ $oracle_on_localhost = getenv('PHP_OCI8_TEST_DB_ON_LOCALHOST');
+ if (false !== $oracle_on_localhost && 0 == strcasecmp($oracle_on_localhost,'TRUE')) {
+ $oracle_on_localhost = TRUE;
+ } else {
+ $oracle_on_localhost = FALSE;
+ }
+ $stress_test = getenv('PHP_OCI8_STRESS_TEST');
+ if (false !== $stress_test && 0 == strcasecmp($stress_test,'TRUE')) {
+ $stress_test = TRUE;
+ } else {
+ $stress_test = FALSE;
+ }
+ } else {
+ $user = "system";
+ $password = "oracle";
+ $dbase = "localhost/XE";
+ $oracle_on_localhost = TRUE;
+ $test_drcp = FALSE;
+ $stress_test = 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 = '';
+}
+
+?>
diff --git a/tests/drcp_cclass1.phpt b/tests/drcp_cclass1.phpt
new file mode 100644
index 0000000000..068331e5a9
--- /dev/null
+++ b/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/tests/drcp_characterset.phpt b/tests/drcp_characterset.phpt
new file mode 100644
index 0000000000..657d4c5bab
--- /dev/null
+++ b/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/tests/drcp_conn_close1.phpt b/tests/drcp_conn_close1.phpt
new file mode 100644
index 0000000000..697b7e3575
--- /dev/null
+++ b/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/tests/drcp_conn_close2.phpt b/tests/drcp_conn_close2.phpt
new file mode 100644
index 0000000000..0d3f8247f2
--- /dev/null
+++ b/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/tests/drcp_connect1.phpt b/tests/drcp_connect1.phpt
new file mode 100644
index 0000000000..bf619a4efd
--- /dev/null
+++ b/tests/drcp_connect1.phpt
@@ -0,0 +1,86 @@
+--TEST--
+DRCP: oci_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";
+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
+
+var_dump($conn1 = oci_connect($user,$password,$dbase));
+// Create the package
+drcp_create_package($conn1);
+
+// 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";
+
+// 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);
+
+// 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);
+
+// OCI_PCONNECT
+echo "\n 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
+
+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--
+resource(%d) of type (oci8 connection)
+ This is with OCI_CONNECT.....
+ The value of the package variable is 0
+ Package variable value set to 1000
+ Connection conn1 closed....
+resource(%d) of type (oci8 connection)
+ Select with connection 2
+ The value of the package variable is 0
+ Package variable value set to 100
+resource(%d) of type (oci8 connection)
+ Select with connection 3
+ The value of the package variable is 100
+
+ This is with oci_pconnect().....
+resource(%d) of type (oci8 persistent connection)
+ Package variable value set to 1000
+ Connection pconn1 closed....
+resource(%d) of type (oci8 persistent connection)
+ Select with persistent connection 2
+ The value of the package variable is 1000
+Done
+
diff --git a/tests/drcp_connection_class.phpt b/tests/drcp_connection_class.phpt
new file mode 100644
index 0000000000..2aed131c14
--- /dev/null
+++ b/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/tests/drcp_functions.inc b/tests/drcp_functions.inc
new file mode 100644
index 0000000000..26adb21f35
--- /dev/null
+++ b/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/tests/drcp_newconnect.phpt b/tests/drcp_newconnect.phpt
new file mode 100644
index 0000000000..79718f4ee2
--- /dev/null
+++ b/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/tests/drcp_pconn_close1.phpt b/tests/drcp_pconn_close1.phpt
new file mode 100644
index 0000000000..a9b912b26f
--- /dev/null
+++ b/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/tests/drcp_pconn_close2.phpt b/tests/drcp_pconn_close2.phpt
new file mode 100644
index 0000000000..5fd2c2355f
--- /dev/null
+++ b/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/tests/drcp_privileged.phpt b/tests/drcp_privileged.phpt
new file mode 100644
index 0000000000..9af20625ed
--- /dev/null
+++ b/tests/drcp_privileged.phpt
@@ -0,0 +1,47 @@
+--TEST--
+DRCP: privileged connect
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+require(dirname(__FILE__)."/details.inc");
+if (empty($oracle_on_localhost)) die("skip this test is unlikely to work with remote Oracle - 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: insufficient privileges in %s on line %d
+bool(false)
+
+Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d
+bool(false)
+
+Warning: oci_new_connect(): ORA-01031: insufficient privileges in %s on line %d
+bool(false)
+
+Warning: oci_new_connect(): ORA-01031: insufficient privileges in %s on line %d
+bool(false)
+
+Warning: oci_pconnect(): ORA-01031: insufficient privileges in %s on line %d
+bool(false)
+
+Warning: oci_pconnect(): ORA-01031: insufficient privileges in %s on line %d
+bool(false)
+Done
+
diff --git a/tests/drcp_scope1.phpt b/tests/drcp_scope1.phpt
new file mode 100644
index 0000000000..57f1abe327
--- /dev/null
+++ b/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/tests/drcp_scope2.phpt b/tests/drcp_scope2.phpt
new file mode 100644
index 0000000000..b72e00dbb0
--- /dev/null
+++ b/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/tests/drcp_scope3.phpt b/tests/drcp_scope3.phpt
new file mode 100644
index 0000000000..b448a518ad
--- /dev/null
+++ b/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/tests/drcp_scope4.phpt b/tests/drcp_scope4.phpt
new file mode 100644
index 0000000000..87eaf0cbe6
--- /dev/null
+++ b/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/tests/drcp_scope5.phpt b/tests/drcp_scope5.phpt
new file mode 100644
index 0000000000..832e6aa8cb
--- /dev/null
+++ b/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/tests/driver_name.phpt b/tests/driver_name.phpt
new file mode 100644
index 0000000000..187d7e1862
--- /dev/null
+++ b/tests/driver_name.phpt
@@ -0,0 +1,71 @@
+--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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11.2|12)/', $sv, $matches);
+
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11.2|12)/', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 11g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 11g or greater version of server");
+}
+
+?>
+--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/tests/drop_table.inc b/tests/drop_table.inc
new file mode 100644
index 0000000000..592a95a3db
--- /dev/null
+++ b/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/tests/drop_type.inc b/tests/drop_type.inc
new file mode 100644
index 0000000000..98542a8085
--- /dev/null
+++ b/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/tests/edition_1.phpt b/tests/edition_1.phpt
new file mode 100644
index 0000000000..9a4b0f3b61
--- /dev/null
+++ b/tests/edition_1.phpt
@@ -0,0 +1,156 @@
+--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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+ if ($iv != 1) {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+ }
+}
+else {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--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",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($conn, $stmt);
+ @oci_execute($s);
+}
+
+// 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/tests/edition_2.phpt b/tests/edition_2.phpt
new file mode 100644
index 0000000000..f7ab979bcf
--- /dev/null
+++ b/tests/edition_2.phpt
@@ -0,0 +1,248 @@
+--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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+ if ($iv != 1) {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+ }
+}
+else {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--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/tests/error.phpt b/tests/error.phpt
new file mode 100644
index 0000000000..743820f901
--- /dev/null
+++ b/tests/error.phpt
@@ -0,0 +1,40 @@
+--TEST--
+oci_error()
+--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));
+}
+
+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: invalid SQL statement in %s on line %d
+bool(false)
+array(4) {
+ ["code"]=>
+ int(900)
+ ["message"]=>
+ string(32) "ORA-00900: invalid SQL statement"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(12) "WRONG SYNTAX"
+}
+Done
diff --git a/tests/error1.phpt b/tests/error1.phpt
new file mode 100644
index 0000000000..25a3f09e92
--- /dev/null
+++ b/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: TNS:could not resolve %s in %s on line %d
+bool(false)
+array(4) {
+ ["code"]=>
+ int(12154)
+ ["message"]=>
+ string(%d) "ORA-12154: TNS:could not resolve %s"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(0) ""
+}
+Done
diff --git a/tests/error2.phpt b/tests/error2.phpt
new file mode 100644
index 0000000000..13ea6cebe2
--- /dev/null
+++ b/tests/error2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Exercise error code for SUCCESS_WITH_INFO
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+ini_set('error_reporting', E_ALL);
+
+$s = oci_parse($c, "create or replace procedure myproc as begin bogus end;");
+$e = @oci_execute($s);
+if (!$e) {
+ $es = oci_error($s);
+ echo $es['message']."\n";
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+ORA-24344: success with compilation error
+Done
diff --git a/tests/error_bind.phpt b/tests/error_bind.phpt
new file mode 100644
index 0000000000..ad66ad59fe
--- /dev/null
+++ b/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-01008: %s on line %d
+bool(false)
+Done
diff --git a/tests/error_old.phpt b/tests/error_old.phpt
new file mode 100644
index 0000000000..a6889c897a
--- /dev/null
+++ b/tests/error_old.phpt
@@ -0,0 +1,40 @@
+--TEST--
+ocierror()
+--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));
+}
+
+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: invalid SQL statement in %s on line %d
+bool(false)
+array(4) {
+ ["code"]=>
+ int(900)
+ ["message"]=>
+ string(32) "ORA-00900: invalid SQL statement"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(12) "WRONG SYNTAX"
+}
+Done
diff --git a/tests/error_parse.phpt b/tests/error_parse.phpt
new file mode 100644
index 0000000000..8100e31706
--- /dev/null
+++ b/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: quoted string not properly terminated"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(0) ""
+}
+New connection: Parse error
+array(4) {
+ ["code"]=>
+ int(1756)
+ ["message"]=>
+ string(48) "ORA-01756: quoted string not properly terminated"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(0) ""
+}
+Persistent connection: Parse error
+array(4) {
+ ["code"]=>
+ int(1756)
+ ["message"]=>
+ string(48) "ORA-01756: quoted string not properly terminated"
+ ["offset"]=>
+ int(0)
+ ["sqltext"]=>
+ string(0) ""
+}
+No connection: error: bool(false)
+Normal connection (take #2): Parse error: ORA-01756: quoted string not properly terminated
+New connection (take #2): Parse error: ORA-01756: quoted string not properly terminated
+Persistent connection (take #2): Parse error: ORA-01756: quoted string not properly terminated
+Normal connection: New Collection error: OCI-22303: type ""."ABC" not found
+New connection (take #3): Parse error: ORA-01756: quoted string not properly terminated
+Persistent connection (take #3): Parse error: ORA-01756: quoted string not properly terminated
+Done
diff --git a/tests/exec_fetch.phpt b/tests/exec_fetch.phpt
new file mode 100644
index 0000000000..83aae69f7d
--- /dev/null
+++ b/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: table or view does not exist in %s on line %d
+bool(false)
+
+Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in %s on line %d
+bool(false)
+Done
diff --git a/tests/execute_mode.phpt b/tests/execute_mode.phpt
new file mode 100644
index 0000000000..90570cae80
--- /dev/null
+++ b/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/tests/extauth_01.phpt b/tests/extauth_01.phpt
new file mode 100644
index 0000000000..993198c4de
--- /dev/null
+++ b/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 ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+?>
+--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/tests/extauth_02.phpt b/tests/extauth_02.phpt
new file mode 100644
index 0000000000..d3bee0bfc3
--- /dev/null
+++ b/tests/extauth_02.phpt
@@ -0,0 +1,198 @@
+--TEST--
+Test External Authentication errors with oci_new_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 ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+?>
+--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/tests/extauth_03.phpt b/tests/extauth_03.phpt
new file mode 100644
index 0000000000..e159c50f90
--- /dev/null
+++ b/tests/extauth_03.phpt
@@ -0,0 +1,198 @@
+--TEST--
+Test External Authentication errors with oci_pconnect
+--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 ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+?>
+--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/tests/extauth_04.phpt b/tests/extauth_04.phpt
new file mode 100644
index 0000000000..e502435bb0
--- /dev/null
+++ b/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/tests/fetch.phpt b/tests/fetch.phpt
new file mode 100644
index 0000000000..5206324940
--- /dev/null
+++ b/tests/fetch.phpt
@@ -0,0 +1,76 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+
+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/tests/fetch_all.phpt b/tests/fetch_all.phpt
new file mode 100644
index 0000000000..a007bac830
--- /dev/null
+++ b/tests/fetch_all.phpt
@@ -0,0 +1,108 @@
+--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)"
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/fetch_all2.phpt b/tests/fetch_all2.phpt
new file mode 100644
index 0000000000..ff44cac70d
--- /dev/null
+++ b/tests/fetch_all2.phpt
@@ -0,0 +1,242 @@
+--TEST--
+oci_fetch_all() - 2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+
+$s = oci_parse($c, $insert_sql);
+
+for ($i = 0; $i<3; $i++) {
+ oci_execute($s);
+}
+
+oci_commit($c);
+
+$select_sql = "SELECT * FROM ".$schema."".$table_name."";
+
+$s = oci_parse($c, $select_sql);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all));
+var_dump($all);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all, 0, 10, OCI_FETCHSTATEMENT_BY_ROW));
+var_dump($all);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all, -1, -1, OCI_FETCHSTATEMENT_BY_ROW));
+var_dump($all);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all, 0, 2, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM));
+var_dump($all);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all, 0, 2, OCI_NUM));
+var_dump($all);
+
+oci_execute($s);
+var_dump(oci_fetch_all($s, $all, 0, 1, OCI_BOTH));
+var_dump($all);
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+?>
+--EXPECT--
+int(3)
+array(5) {
+ ["ID"]=>
+ array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(1) "1"
+ }
+ ["VALUE"]=>
+ array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(1) "1"
+ }
+ ["BLOB"]=>
+ array(3) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ [2]=>
+ NULL
+ }
+ ["CLOB"]=>
+ array(3) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ [2]=>
+ NULL
+ }
+ ["STRING"]=>
+ array(3) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ [2]=>
+ NULL
+ }
+}
+int(3)
+array(3) {
+ [0]=>
+ array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+ }
+ [1]=>
+ array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+ }
+ [2]=>
+ array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+ }
+}
+int(0)
+array(0) {
+}
+int(2)
+array(2) {
+ [0]=>
+ array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ NULL
+ [3]=>
+ NULL
+ [4]=>
+ NULL
+ }
+ [1]=>
+ array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ NULL
+ [3]=>
+ NULL
+ [4]=>
+ NULL
+ }
+}
+int(2)
+array(5) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+ [4]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+}
+int(1)
+array(5) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [2]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ [3]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ [4]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+}
+Done
diff --git a/tests/fetch_all3.phpt b/tests/fetch_all3.phpt
new file mode 100644
index 0000000000..42fe617dc9
--- /dev/null
+++ b/tests/fetch_all3.phpt
@@ -0,0 +1,612 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+$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, SQLT_INT);
+oci_bind_by_name($s, ":vbv", $vbv, SQLT_INT);
+
+for ($i = 1; $i <= 4; $i++) {
+ $idbv = $i;
+ $vbv = -$i;
+ oci_execute($s, OCI_DEFAULT);
+}
+
+oci_commit($c);
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/fetch_all4.phpt b/tests/fetch_all4.phpt
new file mode 100644
index 0000000000..9b82262e3f
--- /dev/null
+++ b/tests/fetch_all4.phpt
@@ -0,0 +1,82 @@
+--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')"
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===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/tests/fetch_all5.phpt b/tests/fetch_all5.phpt
new file mode 100644
index 0000000000..bb9061a445
--- /dev/null
+++ b/tests/fetch_all5.phpt
@@ -0,0 +1,127 @@
+--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')"
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/fetch_array.phpt b/tests/fetch_array.phpt
new file mode 100644
index 0000000000..e2f32483d5
--- /dev/null
+++ b/tests/fetch_array.phpt
@@ -0,0 +1,308 @@
+--TEST--
+oci_fetch_array()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+
+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");
+}
+while ($row = oci_fetch_array($s)) {
+ var_dump($row);
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(select) failed!\n");
+}
+while ($row = oci_fetch_array($s, OCI_NUM)) {
+ var_dump($row);
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(select) failed!\n");
+}
+while ($row = oci_fetch_array($s, OCI_ASSOC)) {
+ var_dump($row);
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(select) failed!\n");
+}
+while ($row = oci_fetch_array($s, OCI_BOTH)) {
+ var_dump($row);
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(select) failed!\n");
+}
+while ($row = oci_fetch_array($s, OCI_RETURN_LOBS)) {
+ var_dump($row);
+}
+
+if (!oci_execute($s)) {
+ die("oci_execute(select) failed!\n");
+}
+while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) {
+ var_dump($row);
+}
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+?>
+--EXPECT--
+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
+}
+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"
+}
+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"
+}
+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"
+}
+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"
+}
+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
+}
+Done
diff --git a/tests/fetch_assoc.phpt b/tests/fetch_assoc.phpt
new file mode 100644
index 0000000000..7dacf2e5b2
--- /dev/null
+++ b/tests/fetch_assoc.phpt
@@ -0,0 +1,82 @@
+--TEST--
+oci_fetch_assoc()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+
+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");
+}
+while ($row = oci_fetch_assoc($s)) {
+ var_dump($row);
+}
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECT--
+array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+}
+array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+}
+array(5) {
+ ["ID"]=>
+ string(1) "1"
+ ["VALUE"]=>
+ string(1) "1"
+ ["BLOB"]=>
+ NULL
+ ["CLOB"]=>
+ NULL
+ ["STRING"]=>
+ NULL
+}
+Done
diff --git a/tests/fetch_into.phpt b/tests/fetch_into.phpt
new file mode 100644
index 0000000000..17e06e1cf8
--- /dev/null
+++ b/tests/fetch_into.phpt
@@ -0,0 +1,90 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/fetch_into1.phpt b/tests/fetch_into1.phpt
new file mode 100644
index 0000000000..263590d140
--- /dev/null
+++ b/tests/fetch_into1.phpt
@@ -0,0 +1,192 @@
+--TEST--
+various ocifetchinto() tests
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$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/tests/fetch_into2.phpt b/tests/fetch_into2.phpt
new file mode 100644
index 0000000000..c196d39f62
--- /dev/null
+++ b/tests/fetch_into2.phpt
@@ -0,0 +1,70 @@
+--TEST--
+ocifetchinto() & wrong number of params
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, 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/tests/fetch_object.phpt b/tests/fetch_object.phpt
new file mode 100644
index 0000000000..674a88ff28
--- /dev/null
+++ b/tests/fetch_object.phpt
@@ -0,0 +1,137 @@
+--TEST--
+oci_fetch_object()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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')",
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+?>
+===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/tests/fetch_object_2.phpt b/tests/fetch_object_2.phpt
new file mode 100644
index 0000000000..b078ebb1d3
--- /dev/null
+++ b/tests/fetch_object_2.phpt
@@ -0,0 +1,127 @@
+--TEST--
+oci_fetch_object() with CLOB and NULL
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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')",
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+object(stdClass)#%d (3) {
+ [%u|b%"COL1"]=>
+ %unicode|string%(3) "123"
+ [%u|b%"COL2"]=>
+ object(OCI-Lob)#%d (1) {
+ [%u|b%"descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ [%u|b%"COL3"]=>
+ %unicode|string%(11) "1 more text"
+}
+object(stdClass)#%d (3) {
+ [%u|b%"COL1"]=>
+ %unicode|string%(3) "456"
+ [%u|b%"COL2"]=>
+ object(OCI-Lob)#%d (1) {
+ [%u|b%"descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ [%u|b%"COL3"]=>
+ NULL
+}
+object(stdClass)#%d (3) {
+ [%u|b%"COL1"]=>
+ %unicode|string%(3) "789"
+ [%u|b%"COL2"]=>
+ object(OCI-Lob)#%d (1) {
+ [%u|b%"descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ [%u|b%"COL3"]=>
+ %unicode|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/tests/fetch_row.phpt b/tests/fetch_row.phpt
new file mode 100644
index 0000000000..c6084d4fe2
--- /dev/null
+++ b/tests/fetch_row.phpt
@@ -0,0 +1,84 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/field_funcs.phpt b/tests/field_funcs.phpt
new file mode 100644
index 0000000000..18143f6f1b
--- /dev/null
+++ b/tests/field_funcs.phpt
@@ -0,0 +1,105 @@
+--TEST--
+oci_field_*() family
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+
+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/tests/field_funcs1.phpt b/tests/field_funcs1.phpt
new file mode 100644
index 0000000000..0b4ad76b39
--- /dev/null
+++ b/tests/field_funcs1.phpt
@@ -0,0 +1,194 @@
+--TEST--
+oci_field_*() family
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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);
+
+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));
+
+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"));
+
+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));
+
+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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ %unicode|string%(1) "1"
+ [1]=>
+ %unicode|string%(1) "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)
+
+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)
+
+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)
+
+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/tests/field_funcs2.phpt b/tests/field_funcs2.phpt
new file mode 100644
index 0000000000..502d079139
--- /dev/null
+++ b/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/tests/field_funcs_old.phpt b/tests/field_funcs_old.phpt
new file mode 100644
index 0000000000..e0d24cd7b7
--- /dev/null
+++ b/tests/field_funcs_old.phpt
@@ -0,0 +1,105 @@
+--TEST--
+ocicolumn*() family
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__).'/create_table.inc';
+
+$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
+
+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/tests/function_aliases.phpt b/tests/function_aliases.phpt
new file mode 100644
index 0000000000..4c6ce83759
--- /dev/null
+++ b/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/tests/lob_001.phpt b/tests/lob_001.phpt
new file mode 100644
index 0000000000..cbcb92e7ec
--- /dev/null
+++ b/tests/lob_001.phpt
Binary files differ
diff --git a/tests/lob_002.phpt b/tests/lob_002.phpt
new file mode 100644
index 0000000000..ebbef1815e
--- /dev/null
+++ b/tests/lob_002.phpt
@@ -0,0 +1,66 @@
+--TEST--
+oci_lob_write() and friends (with errors)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($blob->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 blob FROM ".$schema.$table_name."";
+$s = oci_parse($c, $select_sql);
+oci_execute($s);
+
+$row = oci_fetch_array($s, OCI_RETURN_LOBS);
+
+var_dump(strlen($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)
+
+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/tests/lob_003.phpt b/tests/lob_003.phpt
new file mode 100644
index 0000000000..8a492d16ca
--- /dev/null
+++ b/tests/lob_003.phpt
Binary files differ
diff --git a/tests/lob_004.phpt b/tests/lob_004.phpt
new file mode 100644
index 0000000000..32de4a0120
--- /dev/null
+++ b/tests/lob_004.phpt
@@ -0,0 +1,80 @@
+--TEST--
+oci_lob_seek()/rewind()/append()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($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/tests/lob_005.phpt b/tests/lob_005.phpt
new file mode 100644
index 0000000000..e1ac6e5340
--- /dev/null
+++ b/tests/lob_005.phpt
@@ -0,0 +1,52 @@
+--TEST--
+oci_lob_is_equal()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+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/tests/lob_006.phpt b/tests/lob_006.phpt
new file mode 100644
index 0000000000..3192ebc906
--- /dev/null
+++ b/tests/lob_006.phpt
Binary files differ
diff --git a/tests/lob_007.phpt b/tests/lob_007.phpt
new file mode 100644
index 0000000000..1fe63092c6
--- /dev/null
+++ b/tests/lob_007.phpt
@@ -0,0 +1,66 @@
+--TEST--
+oci_lob_write()/size()/load()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($blob->size());
+var_dump($blob->write(str_repeat("string.", 1000)));
+var_dump($blob->size());
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump($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/tests/lob_008.phpt b/tests/lob_008.phpt
new file mode 100644
index 0000000000..a36bb4a340
--- /dev/null
+++ b/tests/lob_008.phpt
@@ -0,0 +1,65 @@
+--TEST--
+oci_lob_write()/read()/eof()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($blob->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/tests/lob_009.phpt b/tests/lob_009.phpt
new file mode 100644
index 0000000000..b9f7401128
--- /dev/null
+++ b/tests/lob_009.phpt
@@ -0,0 +1,69 @@
+--TEST--
+oci_lob_import()/read()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+var_dump($blob->seek(10, OCI_SEEK_CUR));
+var_dump($blob->import(dirname(__FILE__)."/lob_009.txt"));
+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/tests/lob_009.txt b/tests/lob_009.txt
new file mode 100644
index 0000000000..f57bc8af37
--- /dev/null
+++ b/tests/lob_009.txt
@@ -0,0 +1,6 @@
+this
+is
+a
+test
+file for
+test lob_009.phpt
diff --git a/tests/lob_010.phpt b/tests/lob_010.phpt
new file mode 100644
index 0000000000..59f3e145f2
--- /dev/null
+++ b/tests/lob_010.phpt
@@ -0,0 +1,46 @@
+--TEST--
+oci_lob_save()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->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/tests/lob_011.phpt b/tests/lob_011.phpt
new file mode 100644
index 0000000000..b074e1730e
--- /dev/null
+++ b/tests/lob_011.phpt
@@ -0,0 +1,78 @@
+--TEST--
+oci_lob_copy()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, blob)
+ VALUES (1, empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->write("some string here. string, I said"));
+oci_commit($c);
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, blob)
+ VALUES (2, empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1";
+$s = oci_parse($c, $select_sql);
+oci_execute($s);
+
+$row1 = oci_fetch_array($s);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$row2 = oci_fetch_array($s);
+
+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/tests/lob_012.phpt b/tests/lob_012.phpt
new file mode 100644
index 0000000000..2061969bc4
--- /dev/null
+++ b/tests/lob_012.phpt
@@ -0,0 +1,50 @@
+--TEST--
+oci_lob_export()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+$blob;
+
+var_dump($blob->write("test 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/tests/lob_013.phpt b/tests/lob_013.phpt
new file mode 100644
index 0000000000..c56de56198
--- /dev/null
+++ b/tests/lob_013.phpt
@@ -0,0 +1,54 @@
+--TEST--
+lob buffering
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->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/tests/lob_014.phpt b/tests/lob_014.phpt
new file mode 100644
index 0000000000..1ba29ee649
--- /dev/null
+++ b/tests/lob_014.phpt
@@ -0,0 +1,56 @@
+--TEST--
+oci_lob_free()/close()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+$blob;
+
+var_dump($blob->write("test"));
+var_dump($blob->close());
+var_dump($blob->write("test"));
+var_dump($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/tests/lob_015.phpt b/tests/lob_015.phpt
new file mode 100644
index 0000000000..297d5b4971
--- /dev/null
+++ b/tests/lob_015.phpt
@@ -0,0 +1,53 @@
+--TEST--
+various tests with wrong param count
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB,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: inconsistent datatypes: expected NUMBER got BLOB in %s on line %d
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+Done
diff --git a/tests/lob_016.phpt b/tests/lob_016.phpt
new file mode 100644
index 0000000000..642e7195ef
--- /dev/null
+++ b/tests/lob_016.phpt
@@ -0,0 +1,67 @@
+--TEST--
+returning multiple lobs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "CREATE table lob_test(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/tests/lob_017.phpt b/tests/lob_017.phpt
new file mode 100644
index 0000000000..ed12cc4685
--- /dev/null
+++ b/tests/lob_017.phpt
@@ -0,0 +1,69 @@
+--TEST--
+returning multiple lobs (using persistent connection)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/lob_018.phpt b/tests/lob_018.phpt
new file mode 100644
index 0000000000..35cec4bd7d
--- /dev/null
+++ b/tests/lob_018.phpt
@@ -0,0 +1,67 @@
+--TEST--
+fetching the same lob several times
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "CREATE table lob_test(mykey NUMBER, lob_1 CLOB)";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(1, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob";
+$statement = oci_parse($c, $init);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+$clob->save("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");
+
+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--
+string(4) "data"
+string(9) "long data"
+string(9) "long data"
+string(4) "data"
+Done
diff --git a/tests/lob_019.phpt b/tests/lob_019.phpt
new file mode 100644
index 0000000000..fb9a3c8188
--- /dev/null
+++ b/tests/lob_019.phpt
Binary files differ
diff --git a/tests/lob_020.phpt b/tests/lob_020.phpt
new file mode 100644
index 0000000000..6564dede9b
--- /dev/null
+++ b/tests/lob_020.phpt
Binary files differ
diff --git a/tests/lob_021.phpt b/tests/lob_021.phpt
new file mode 100644
index 0000000000..0ae6b377ab
--- /dev/null
+++ b/tests/lob_021.phpt
@@ -0,0 +1,70 @@
+--TEST--
+oci_lob_free()/close()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+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/tests/lob_022.phpt b/tests/lob_022.phpt
new file mode 100644
index 0000000000..5fb9dfab0e
--- /dev/null
+++ b/tests/lob_022.phpt
@@ -0,0 +1,80 @@
+--TEST--
+fetching the same lob several times
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "CREATE table lob_test(mykey NUMBER, lob_1 CLOB)";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(1, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob";
+$statement = oci_parse($c, $init);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+$clob->save();
+oci_lob_save();
+oci_lob_save($clob, "data");
+unset($clob->descriptor);
+oci_lob_save($clob, "data");
+
+oci_commit($c);
+
+$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(2, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob";
+$statement = oci_parse($c, $init);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+$clob->save("long data");
+$clob->save("long data", -1);
+$clob->save("long data", 0);
+
+oci_commit($c);
+
+
+$query = 'SELECT * FROM lob_test ORDER BY mykey ASC';
+$statement = oci_parse ($c, $query);
+oci_execute($statement, OCI_DEFAULT);
+
+while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
+ $result = $row['LOB_1']->load();
+ var_dump($result);
+}
+
+$query = 'SELECT * FROM lob_test ORDER BY mykey DESC';
+$statement = oci_parse ($c, $query);
+oci_execute($statement, OCI_DEFAULT);
+
+while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
+ $result = $row['LOB_1']->load();
+ var_dump($result);
+}
+
+$drop = "DROP table lob_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Warning: OCI-Lob::save() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: oci_lob_save() expects at least 2 parameters, 0 given in %s on line %d
+
+Warning: oci_lob_save(): Unable to find descriptor property in %s on line %d
+
+Warning: OCI-Lob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d
+string(4) "data"
+string(9) "long data"
+string(9) "long data"
+string(4) "data"
+Done
diff --git a/tests/lob_023.phpt b/tests/lob_023.phpt
new file mode 100644
index 0000000000..0c352956de
--- /dev/null
+++ b/tests/lob_023.phpt
@@ -0,0 +1,84 @@
+--TEST--
+oci_lob_import()/read()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+var_dump($blob->seek(10, OCI_SEEK_CUR));
+var_dump($blob->import(dirname(__FILE__)."/lob_009.txt"));
+var_dump($blob->import());
+var_dump(oci_lob_import($blob));
+var_dump(oci_lob_import($blob, dirname(__FILE__)."/lob_009.txt"));
+unset($blob->descriptor);
+var_dump(oci_lob_import($blob, dirname(__FILE__)."/lob_009.txt"));
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+while (!$row[0]->eof()) {
+ var_dump($row[0]->read(1024));
+}
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+bool(true)
+bool(true)
+
+Warning: OCI-Lob::import() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_import() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+bool(true)
+
+Warning: oci_lob_import(): Unable to find descriptor property in %s on line %d
+bool(false)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(43) "this
+is
+a
+test
+file for
+test lob_009.phpt
+"
+Done
diff --git a/tests/lob_024.phpt b/tests/lob_024.phpt
new file mode 100644
index 0000000000..9a7f53240d
--- /dev/null
+++ b/tests/lob_024.phpt
@@ -0,0 +1,75 @@
+--TEST--
+oci_lob_load()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump($blob->size());
+var_dump($blob->write(str_repeat("string.", 1000)));
+var_dump($blob->size());
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(strlen($row[0]->load()));
+var_dump(strlen(oci_lob_load($row[0])));
+var_dump(oci_lob_load());
+unset($row[0]->descriptor);
+var_dump(oci_lob_load($row[0]));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+int(0)
+int(7000)
+int(7000)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+int(7000)
+int(7000)
+
+Warning: oci_lob_load() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_load(): Unable to find descriptor property in %s on line %d
+bool(false)
+Done
diff --git a/tests/lob_025.phpt b/tests/lob_025.phpt
new file mode 100644
index 0000000000..5b5e845a7a
--- /dev/null
+++ b/tests/lob_025.phpt
@@ -0,0 +1,82 @@
+--TEST--
+oci_lob_read() tests
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->size());
+var_dump($blob->write(str_repeat("string.", 1000)));
+var_dump($blob->size());
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(oci_lob_read($row[0], 2));
+var_dump(oci_lob_read($row[0]));
+var_dump(oci_lob_read());
+var_dump(oci_lob_eof($row[0]));
+var_dump(oci_lob_eof());
+
+unset($row[0]->descriptor);
+var_dump(oci_lob_read($row[0],1));
+var_dump(oci_lob_eof($row[0]));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+int(0)
+int(7000)
+int(7000)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(2) "st"
+
+Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: oci_lob_read() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+bool(false)
+
+Warning: oci_lob_eof() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_read(): Unable to find descriptor property in %s on line %d
+bool(false)
+
+Warning: oci_lob_eof(): Unable to find descriptor property in %s on line %d
+bool(false)
+Done
diff --git a/tests/lob_026.phpt b/tests/lob_026.phpt
new file mode 100644
index 0000000000..157d78a2b6
--- /dev/null
+++ b/tests/lob_026.phpt
@@ -0,0 +1,100 @@
+--TEST--
+oci_lob_seek()/rewind()/append()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+var_dump(oci_lob_write($blob, "test"));
+var_dump(oci_lob_rewind());
+var_dump(oci_lob_rewind($blob));
+var_dump(oci_lob_write($blob, "str"));
+var_dump(oci_lob_seek(10, OCI_SEEK_SET));
+var_dump(oci_lob_seek($blob, 10, OCI_SEEK_SET));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+
+var_dump(oci_lob_append());
+var_dump(oci_lob_append($blob));
+var_dump(oci_lob_append($row[0], $blob));
+var_dump(oci_lob_read(10000));
+var_dump(oci_lob_read($row[0], 10000));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$row = oci_fetch_array($s);
+
+var_dump(oci_lob_read($row[0], 10000));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+int(4)
+
+Warning: oci_lob_rewind() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+bool(true)
+int(3)
+
+Warning: oci_lob_seek() expects parameter 1 to be OCI-Lob, integer given in %s on line %d
+NULL
+bool(true)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+
+Warning: oci_lob_append() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_append() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+bool(true)
+
+Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+string(4) "strt"
+string(8) "strtstrt"
+Done
diff --git a/tests/lob_027.phpt b/tests/lob_027.phpt
new file mode 100644
index 0000000000..8b49b1ac5b
--- /dev/null
+++ b/tests/lob_027.phpt
@@ -0,0 +1,103 @@
+--TEST--
+oci_lob_truncate()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob);
+
+$str = "this is a biiiig faaat test string. why are you reading it, I wonder? =)";
+var_dump($blob->write($str));
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row = oci_fetch_array($s));
+oci_commit($c);
+
+for ($i = 5; $i >= 0; $i--) {
+
+ $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+ $s = oci_parse($c, $select_sql);
+ oci_execute($s, OCI_DEFAULT);
+
+ $row = oci_fetch_array($s);
+ var_dump($row['BLOB']->load());
+ var_dump($row['BLOB']->truncate(($i-1)*10));
+
+ oci_commit($c);
+}
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$row = oci_fetch_array($s);
+var_dump($row['BLOB']->load());
+var_dump($row['BLOB']->truncate(-1));
+var_dump($row['BLOB']->truncate(0));
+
+oci_commit($c);
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+int(72)
+array(2) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+ ["BLOB"]=>
+ object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)"
+bool(true)
+string(40) "this is a biiiig faaat test string. why "
+bool(true)
+string(30) "this is a biiiig faaat test st"
+bool(true)
+string(20) "this is a biiiig faa"
+bool(true)
+string(10) "this is a "
+bool(true)
+string(0) ""
+
+Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d
+bool(false)
+string(0) ""
+
+Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d
+bool(false)
+bool(true)
+Done
diff --git a/tests/lob_028.phpt b/tests/lob_028.phpt
new file mode 100644
index 0000000000..8ac2da3a32
--- /dev/null
+++ b/tests/lob_028.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Test descriptor types for oci_new_descriptor()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+// Successful statements
+
+$d = oci_new_descriptor($c, OCI_D_FILE);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_FILE);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_D_LOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_LOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_D_ROWID);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_ROWID);
+var_dump($d);
+
+// Unsuccessful statements
+
+$d = oci_new_descriptor($c, OCI_B_CLOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_B_CLOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DEFAULT);
+var_dump($d);
+
+$d = oci_new_descriptor($c, 1);
+var_dump($d);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+}
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+Done
diff --git a/tests/lob_029.phpt b/tests/lob_029.phpt
new file mode 100644
index 0000000000..6826f36cda
--- /dev/null
+++ b/tests/lob_029.phpt
@@ -0,0 +1,125 @@
+--TEST--
+reading/writing BFILE LOBs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+include "details.inc";
+if (empty($oracle_on_localhost)) die("skip this test won't work with remote Oracle");
+?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$realdirname = dirname(__FILE__);
+$realfilename1 = "oci8bfiletest1.txt";
+$fullname1 = $realdirname."/".$realfilename1;
+$realfilename2 = "oci8bfiletest2.txt";
+$fullname2 = $realdirname."/".$realfilename2;
+$realfilename3 = "oci8bfiletest3.txt";
+$fullname3 = $realdirname."/".$realfilename3;
+
+// Setup
+$s = oci_parse($c, "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/tests/lob_030.phpt b/tests/lob_030.phpt
new file mode 100644
index 0000000000..86b2956a51
--- /dev/null
+++ b/tests/lob_030.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+function insert_verify($c, $tn, $id, $length)
+{
+ // Insert the data
+ $ora_sql = "INSERT INTO
+ ".$tn." (id, clob)
+ VALUES (".$id.", empty_clob())
+ RETURNING
+ clob
+ INTO :v_clob ";
+
+ $statement = oci_parse($c,$ora_sql);
+ $clob = oci_new_descriptor($c,OCI_D_LOB);
+ oci_bind_by_name($statement,":v_clob", $clob, -1, OCI_B_CLOB);
+ oci_execute($statement, OCI_DEFAULT);
+
+ $data = str_pad("x", $length, "x");
+ $clob->write($data);
+
+ // Verify the data
+ $select_sql = "SELECT clob FROM ".$tn." where id = ".$id;
+ $s = oci_parse($c, $select_sql);
+ oci_execute($s);
+
+ $row = oci_fetch_array($s, OCI_RETURN_LOBS);
+
+ var_dump(strlen($row[0]));
+}
+
+echo "Test 1: A CLOB with an even number of bytes\n";
+insert_verify($c, $schema.$table_name, 1, 1050000);
+
+echo "Test 2: A CLOB with an odd number of bytes\n";
+insert_verify($c, $schema.$table_name, 2, 1050001);
+
+echo "Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)\n";
+insert_verify($c, $schema.$table_name, 3, 1048576);
+
+echo "Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)\n";
+insert_verify($c, $schema.$table_name, 4, 1049028);
+
+echo "Test 5: A CLOB of 1049028-1 bytes\n";
+insert_verify($c, $schema.$table_name, 5, 1049028-1);
+
+echo "Test 6: A CLOB of 1049028+1 bytes\n";
+insert_verify($c, $schema.$table_name, 6, 1049028+1);
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1: A CLOB with an even number of bytes
+int(1050000)
+Test 2: A CLOB with an odd number of bytes
+int(1050001)
+Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)
+int(1048576)
+Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)
+int(1049028)
+Test 5: A CLOB of 1049028-1 bytes
+int(1049027)
+Test 6: A CLOB of 1049028+1 bytes
+int(1049029)
+Done
diff --git a/tests/lob_031.phpt b/tests/lob_031.phpt
new file mode 100644
index 0000000000..a27d53bb38
--- /dev/null
+++ b/tests/lob_031.phpt
@@ -0,0 +1,107 @@
+--TEST--
+Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+$blob->write("test");
+$blob->tell();
+$blob->seek(10, OCI_SEEK_CUR);
+$blob->write("string");
+$blob->flush();
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name;
+$s = oci_parse($c, $select_sql);
+oci_execute($s);
+$row = oci_fetch_array($s);
+
+$row[0]->read(3);
+echo " 1. ".$row[0]->tell(). "\n";
+
+$row[0]->read(3);
+echo " 2. ".$row[0]->tell(). "\n";
+
+$row[0]->read(3);
+echo " 3. ".$row[0]->tell(). "\n";
+
+$row[0]->read(6);
+echo " 4. ".$row[0]->tell(). "\n";
+
+$row[0]->read(4);
+echo " 5. ".$row[0]->tell(). "\n";
+
+// Read past end
+$row[0]->read(5);
+echo " 6. ".$row[0]->tell(). "\n";
+
+$row[0]->read(1);
+echo " 8. ".$row[0]->tell(). "\n";
+
+// Now seek
+$row[0]->seek(1);
+echo " 9. ".$row[0]->tell(). "\n";
+
+$row[0]->seek(8);
+echo "10. ".$row[0]->tell(). "\n";
+
+$row[0]->seek(20);
+echo "11. ".$row[0]->tell(). "\n";
+
+// Seek past end
+$row[0]->seek(25);
+echo "12. ".$row[0]->tell(). "\n";
+
+// Seek past end
+$row[0]->seek(2, OCI_SEEK_SET);
+echo "13. ".$row[0]->tell(). "\n";
+
+// Move on 2 more
+$row[0]->seek(2, OCI_SEEK_CUR);
+echo "14. ".$row[0]->tell(). "\n";
+
+// Move 3 past the end
+$row[0]->seek(3, OCI_SEEK_END);
+echo "15. ".$row[0]->tell(). "\n";
+
+// Move 4 before the end
+$row[0]->seek(-4, OCI_SEEK_END);
+echo "16. ".$row[0]->tell(). "\n";
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+ 1. 3
+ 2. 6
+ 3. 9
+ 4. 15
+ 5. 19
+ 6. 20
+ 8. 20
+ 9. 1
+10. 8
+11. 20
+12. 25
+13. 2
+14. 4
+15. 23
+16. 16
+Done
diff --git a/tests/lob_032.phpt b/tests/lob_032.phpt
new file mode 100644
index 0000000000..5d6ff6ec90
--- /dev/null
+++ b/tests/lob_032.phpt
@@ -0,0 +1,33 @@
+--TEST--
+oci_lob_write() and friends
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, clob)
+ VALUES (2, empty_clob())
+ RETURNING
+ clob
+ INTO :v_clob ";
+
+$statement = oci_parse($c,$ora_sql);
+$clob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_clob", $clob,-1,OCI_B_CLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+oci_commit($c); // This will cause subsequent ->write() to fail
+$clob->write("data");
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Warning: OCI-Lob::write(): ORA-22990: %s in %s on line 19
+Done
diff --git a/tests/lob_033.phpt b/tests/lob_033.phpt
new file mode 100644
index 0000000000..5647cd9a41
--- /dev/null
+++ b/tests/lob_033.phpt
@@ -0,0 +1,38 @@
+--TEST--
+various oci_lob_write() error messages
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, blob)
+ VALUES (2, empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+
+$blob->save("");
+
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->save(""));
+var_dump($blob->save("data", 100));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in %s on line %d
+bool(true)
+bool(true)
+Done
diff --git a/tests/lob_034.phpt b/tests/lob_034.phpt
new file mode 100644
index 0000000000..6bf4058e74
--- /dev/null
+++ b/tests/lob_034.phpt
@@ -0,0 +1,50 @@
+--TEST--
+lob buffering - 2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->getBuffering());
+var_dump($blob->setBuffering(false));
+var_dump($blob->setBuffering(false));
+var_dump($blob->setBuffering(true));
+var_dump($blob->setBuffering(true));
+var_dump($blob->flush());
+var_dump($blob->flush(0));
+var_dump($blob->flush(-1));
+
+oci_commit($c);
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+Warning: OCI-Lob::flush(): Invalid flag value: -1 in %s on line %d
+bool(false)
+Done
diff --git a/tests/lob_035.phpt b/tests/lob_035.phpt
new file mode 100644
index 0000000000..6e1f5a7359
--- /dev/null
+++ b/tests/lob_035.phpt
@@ -0,0 +1,108 @@
+--TEST--
+oci_lob_copy() - 2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, blob)
+ VALUES (1, empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+var_dump($blob->write("some string here. string, I said"));
+oci_commit($c);
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (id, blob)
+ VALUES (2, empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$statement = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_D_LOB);
+oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($statement, OCI_DEFAULT);
+
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1";
+$s = oci_parse($c, $select_sql);
+oci_execute($s);
+
+$row1 = oci_fetch_array($s);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$row2 = oci_fetch_array($s);
+
+$dummy = oci_new_descriptor($c, OCI_D_LOB);
+
+var_dump(oci_lob_copy($dummy, $row1[0]));
+var_dump(oci_lob_copy($row2[0], $dummy));
+
+var_dump(oci_lob_copy($row2[0], $row1[0], 0));
+var_dump(oci_lob_copy($row2[0], $row1[0], -1));
+var_dump(oci_lob_copy($row2[0], $row1[0], 100000));
+
+var_dump(oci_lob_size());
+var_dump(oci_lob_size($row2[0]));
+unset($dummy->descriptor);
+var_dump(oci_lob_size($dummy));
+
+oci_rollback($c);
+oci_rollback($c);
+oci_commit($c);
+oci_commit($c);
+
+$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
+$s = oci_parse($c, $select_sql);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+int(32)
+
+Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
+bool(false)
+
+Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
+bool(false)
+bool(false)
+
+Warning: oci_lob_copy(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+bool(true)
+
+Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+int(0)
+
+Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d
+bool(false)
+array(2) {
+ [0]=>
+ string(0) ""
+ ["BLOB"]=>
+ string(0) ""
+}
+Done
diff --git a/tests/lob_036.phpt b/tests/lob_036.phpt
new file mode 100644
index 0000000000..e72c1cf081
--- /dev/null
+++ b/tests/lob_036.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Exercise cleanup code when LOB buffering is on
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$s = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+
+oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($blob->write("test"));
+var_dump($blob->setBuffering(true));
+var_dump($blob->write("test"));
+
+$blob = null;
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECT--
+int(4)
+bool(true)
+int(4)
+Done
diff --git a/tests/lob_037.phpt b/tests/lob_037.phpt
new file mode 100644
index 0000000000..228f5e8123
--- /dev/null
+++ b/tests/lob_037.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Fetching two different lobs and using them after fetch
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+/* insert the first LOB */
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$s = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($blob->write("first lob data"));
+oci_commit($c);
+
+/* insert the second LOB */
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$s = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($blob->write("second lob data"));
+oci_commit($c);
+
+/* select both */
+
+$ora_sql = "SELECT blob FROM ".$schema.$table_name;
+$s = oci_parse($c,$ora_sql);
+oci_execute($s, OCI_DEFAULT);
+
+$rows = array();
+$rows[0] = oci_fetch_assoc($s);
+$rows[1] = oci_fetch_assoc($s);
+
+var_dump($rows[0]['BLOB']->read(1000));
+var_dump($rows[1]['BLOB']->read(1000));
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECT--
+int(14)
+int(15)
+string(14) "first lob data"
+string(15) "second lob data"
+Done
diff --git a/tests/lob_038.phpt b/tests/lob_038.phpt
new file mode 100644
index 0000000000..91dac66c0d
--- /dev/null
+++ b/tests/lob_038.phpt
@@ -0,0 +1,189 @@
+--TEST--
+Array fetch CLOB and BLOB
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+echo "Test 1: CLOB\n";
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (clob)
+ VALUES (empty_clob())
+ RETURNING
+ clob
+ INTO :v_clob ";
+
+$s = oci_parse($c,$ora_sql);
+$clob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+
+oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB);
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->save("clob test 1"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->save("clob test 2"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->save("clob test 3"));
+
+
+$s = oci_parse($c,"select clob from ".$schema.$table_name);
+var_dump(oci_execute($s));
+
+oci_fetch_all($s, $res);
+
+var_dump($res);
+
+
+echo "Test 1b\n";
+
+$s = oci_parse($c, "select clob from ".$schema.$table_name);
+var_dump(oci_execute($s, OCI_DEFAULT));
+while ($row = oci_fetch_array($s, OCI_ASSOC)) {
+ var_dump($row);
+ $result = $row['CLOB']->load();
+ var_dump($result);
+}
+
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Test 2: BLOB\n";
+
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (blob)
+ VALUES (empty_blob())
+ RETURNING
+ blob
+ INTO :v_blob ";
+
+$s = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+
+oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($blob->save("blob test 1"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($blob->save("blob test 2"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($blob->save("blob test 3"));
+
+$s = oci_parse($c, "select blob from ".$schema.$table_name);
+var_dump(oci_execute($s));
+oci_fetch_all($s, $res);
+var_dump($res);
+
+echo "Test 2b\n";
+
+$s = oci_parse($c, "select blob from ".$schema.$table_name);
+var_dump(oci_execute($s, OCI_DEFAULT));
+while ($row = oci_fetch_array($s, OCI_ASSOC)) {
+ var_dump($row);
+ $result = $row['BLOB']->load();
+ var_dump($result);
+}
+
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1: CLOB
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+ ["CLOB"]=>
+ array(3) {
+ [0]=>
+ string(11) "clob test 1"
+ [1]=>
+ string(11) "clob test 2"
+ [2]=>
+ string(11) "clob test 3"
+ }
+}
+Test 1b
+bool(true)
+array(1) {
+ ["CLOB"]=>
+ object(OCI-Lob)#2 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "clob test 1"
+array(1) {
+ ["CLOB"]=>
+ object(OCI-Lob)#3 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "clob test 2"
+array(1) {
+ ["CLOB"]=>
+ object(OCI-Lob)#2 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "clob test 3"
+Test 2: BLOB
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+ ["BLOB"]=>
+ array(3) {
+ [0]=>
+ string(11) "blob test 1"
+ [1]=>
+ string(11) "blob test 2"
+ [2]=>
+ string(11) "blob test 3"
+ }
+}
+Test 2b
+bool(true)
+array(1) {
+ ["BLOB"]=>
+ object(OCI-Lob)#3 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "blob test 1"
+array(1) {
+ ["BLOB"]=>
+ object(OCI-Lob)#4 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "blob test 2"
+array(1) {
+ ["BLOB"]=>
+ object(OCI-Lob)#3 (1) {
+ ["descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+string(11) "blob test 3"
+Done \ No newline at end of file
diff --git a/tests/lob_039.phpt b/tests/lob_039.phpt
new file mode 100644
index 0000000000..5675f5a928
--- /dev/null
+++ b/tests/lob_039.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test CLOB->write() for multiple inserts
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+echo "Test 1: CLOB\n";
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (clob)
+ VALUES (empty_clob())
+ RETURNING
+ clob
+ INTO :v_clob ";
+
+$s = oci_parse($c,$ora_sql);
+$clob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+
+oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB);
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->write("clob test 1"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->write("clob test 2"));
+
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->write("clob test 3"));
+
+$s = oci_parse($c,"select clob from ".$schema.$table_name);
+var_dump(oci_execute($s));
+
+oci_fetch_all($s, $res);
+
+var_dump($res);
+
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Test 1: CLOB
+int(11)
+int(11)
+int(11)
+bool(true)
+array(1) {
+ ["CLOB"]=>
+ array(3) {
+ [0]=>
+ string(11) "clob test 1"
+ [1]=>
+ string(22) " clob test 2"
+ [2]=>
+ string(33) " clob test 3"
+ }
+}
+Done
diff --git a/tests/lob_040.phpt b/tests/lob_040.phpt
new file mode 100644
index 0000000000..3f8a73dc5a
--- /dev/null
+++ b/tests/lob_040.phpt
@@ -0,0 +1,1041 @@
+--TEST--
+Bug #37706 (Test LOB locator reuse. Extends simple test of lob_037.phpt)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/lob_041.phpt b/tests/lob_041.phpt
new file mode 100644
index 0000000000..d04b43606a
--- /dev/null
+++ b/tests/lob_041.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Check LOBS are valid after statement free
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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')"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+
+--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/tests/lob_042.phpt b/tests/lob_042.phpt
new file mode 100644
index 0000000000..25309d6fc0
--- /dev/null
+++ b/tests/lob_042.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Check various LOB error messages
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+require(dirname(__FILE__).'/create_table.inc');
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (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/tests/lob_043.phpt b/tests/lob_043.phpt
new file mode 100644
index 0000000000..0280ef6de8
--- /dev/null
+++ b/tests/lob_043.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Bug #49560 (LOB resource destructor and refcount test)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+require(dirname(__FILE__).'/details.inc');
+if ($stress_test !== true) die ('skip Slow test not run when $stress_test is FALSE');
+?>
+--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;",
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1
+f1 ended
+Test 2
+f2 ended
+===DONE===
diff --git a/tests/lob_aliases.phpt b/tests/lob_aliases.phpt
new file mode 100644
index 0000000000..faa59bf12d
--- /dev/null
+++ b/tests/lob_aliases.phpt
@@ -0,0 +1,99 @@
+--TEST--
+LOB method aliases
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+// Function existence
+echo "Test 1\n";
+var_dump(oci_lob_load());
+var_dump(oci_lob_tell());
+var_dump(oci_lob_truncate());
+var_dump(oci_lob_erase());
+var_dump(oci_lob_flush());
+var_dump(ocisetbufferinglob());
+var_dump(ocigetbufferinglob());
+var_dump(oci_lob_rewind());
+var_dump(oci_lob_read());
+var_dump(oci_lob_eof());
+var_dump(oci_lob_seek());
+var_dump(oci_lob_write());
+var_dump(oci_lob_append());
+var_dump(oci_lob_size());
+var_dump(oci_lob_export());
+var_dump(oci_lob_export());
+var_dump(oci_lob_import());
+// No PHP_FE for oci_lob_write_temporary() or oci_lob_close()
+//var_dump(oci_lob_write_temporary());
+//var_dump(oci_lob_close());
+var_dump(oci_lob_save());
+var_dump(oci_lob_import());
+var_dump(oci_free_descriptor());
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Test 1
+
+Warning: oci_lob_load() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_tell() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_truncate() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_erase() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_flush() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: ocisetbufferinglob() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ocigetbufferinglob() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_rewind() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_read() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_eof() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_seek() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_write() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_append() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_export() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_export() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_import() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_save() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_lob_import() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: oci_free_descriptor() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+Done
diff --git a/tests/lob_null.phpt b/tests/lob_null.phpt
new file mode 100644
index 0000000000..227ebb89fb
--- /dev/null
+++ b/tests/lob_null.phpt
@@ -0,0 +1,265 @@
+--TEST--
+Test null data for CLOBs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/lob_temp.phpt b/tests/lob_temp.phpt
new file mode 100644
index 0000000000..cad2d39058
--- /dev/null
+++ b/tests/lob_temp.phpt
@@ -0,0 +1,36 @@
+--TEST--
+temporary lobs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/lob_temp1.phpt b/tests/lob_temp1.phpt
new file mode 100644
index 0000000000..2482d65f64
--- /dev/null
+++ b/tests/lob_temp1.phpt
@@ -0,0 +1,32 @@
+--TEST--
+closing temporary lobs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--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/tests/minfo.phpt b/tests/minfo.phpt
new file mode 100644
index 0000000000..f6b95ff296
--- /dev/null
+++ b/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/tests/num.phpt b/tests/num.phpt
new file mode 100644
index 0000000000..e9dc6a8ac2
--- /dev/null
+++ b/tests/num.phpt
@@ -0,0 +1,256 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+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/tests/oci8safemode.phpt b/tests/oci8safemode.phpt
new file mode 100644
index 0000000000..1c62f36d39
--- /dev/null
+++ b/tests/oci8safemode.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test functionality disabled in safe mode
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--INI--
+safe_mode=On
+oci8.privileged_connect=On
+--FILE--
+<?php
+
+$c = oci_connect("hr", "hrpwd", "//localhost/XE", null, OCI_SYSDBA);
+
+$r = oci_password_change($c, "hr", "hrpwd", "hrpwd");
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sarning:%sDirective 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+
+Warning: oci_connect(): Privileged connect is disabled in Safe Mode in %s on line %d
+
+Warning: oci_password_change(): is disabled in Safe Mode in %s on line %d
+Done
diff --git a/tests/oci_execute_segfault.phpt b/tests/oci_execute_segfault.phpt
new file mode 100644
index 0000000000..9ba7d770fd
--- /dev/null
+++ b/tests/oci_execute_segfault.phpt
@@ -0,0 +1,48 @@
+--TEST--
+oci_execute() segfault after repeated bind of LOB descriptor
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$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/tests/old_oci_close.phpt b/tests/old_oci_close.phpt
new file mode 100644
index 0000000000..f15b7febea
--- /dev/null
+++ b/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/tests/old_oci_close1.phpt b/tests/old_oci_close1.phpt
new file mode 100644
index 0000000000..9af2eeb398
--- /dev/null
+++ b/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/tests/password.phpt b/tests/password.phpt
new file mode 100644
index 0000000000..7133d8bae8
--- /dev/null
+++ b/tests/password.phpt
@@ -0,0 +1,83 @@
+--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__)."/details.inc");
+
+// Create a user we can stuff around with and not affect subsequent tests
+$c0 = oci_connect($user, $password, $dbase);
+$stmts = array(
+ "drop user testuser",
+ "begin
+ execute immediate 'create user testuser identified by testuserpwd';
+ execute immediate 'grant connect, create session to testuser';
+ end;");
+foreach ($stmts as $sql) {
+ $s = oci_parse($c0, $sql);
+ @oci_execute($s);
+}
+
+// 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);
+}
+
+// Clean up
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+
+// Clean up
+$s = oci_parse($c0, "drop user cascade testuser");
+@oci_execute($s);
+
+echo "Done\n";
+
+?>
+--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/tests/password_2.phpt b/tests/password_2.phpt
new file mode 100644
index 0000000000..71423e717b
--- /dev/null
+++ b/tests/password_2.phpt
@@ -0,0 +1,83 @@
+--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__)."/details.inc");
+
+// Create a user we can stuff around with and not affect subsequent tests
+$c0 = oci_connect($user, $password, $dbase);
+$stmts = array(
+ "drop user testuser",
+ "begin
+ execute immediate 'create user testuser identified by testuserpwd';
+ execute immediate 'grant connect, create session to testuser';
+ end;");
+foreach ($stmts as $sql) {
+ $s = oci_parse($c0, $sql);
+ @oci_execute($s);
+}
+
+// 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);
+}
+
+// Clean up
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+
+// Clean up
+$s = oci_parse($c0, "drop user cascade testuser");
+@oci_execute($s);
+
+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)
+First and second connections are different: OK
+First and third connections share a resource: OK
+Done
diff --git a/tests/password_new.phpt b/tests/password_new.phpt
new file mode 100644
index 0000000000..ba6baa964b
--- /dev/null
+++ b/tests/password_new.phpt
@@ -0,0 +1,49 @@
+--TEST--
+oci_password_change()
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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)
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11|12)\./', $sv, $matches);
+if ($sv === 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
+ if ($iv === 1) {
+ die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)");
+ }
+}
+?>
+--FILE--
+<?php
+
+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/tests/password_old.phpt b/tests/password_old.phpt
new file mode 100644
index 0000000000..abcaeb1e56
--- /dev/null
+++ b/tests/password_old.phpt
@@ -0,0 +1,49 @@
+--TEST--
+ocipasswordchange()
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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)
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11|12)\./', $sv, $matches);
+if ($sv === 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
+ if ($iv === 1) {
+ die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)");
+ }
+}
+?>
+--FILE--
+<?php
+
+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/tests/pecl_bug10194.phpt b/tests/pecl_bug10194.phpt
new file mode 100644
index 0000000000..4714fadcd4
--- /dev/null
+++ b/tests/pecl_bug10194.phpt
@@ -0,0 +1,47 @@
+--TEST--
+PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--INI--
+memory_limit=10M
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+require dirname(__FILE__).'/create_table.inc';
+
+$ora_sql = "INSERT INTO
+ ".$schema.$table_name." (clob)
+ VALUES (empty_clob())
+ ";
+
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$ora_sql = "SELECT clob FROM ".$schema.$table_name." FOR UPDATE";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement, OCI_DEFAULT);
+
+$row = oci_fetch_assoc($statement);
+
+$string = str_repeat("test", 32768*4*4);
+
+for ($i = 0; $i < 8; $i++) {
+ $row['CLOB']->write($string);
+}
+
+oci_commit($c);
+
+$ora_sql = "SELECT clob FROM ".$schema.$table_name."";
+$statement = oci_parse($c,$ora_sql);
+oci_execute($statement);
+
+$row = oci_fetch_assoc($statement);
+var_dump(strlen($row['CLOB']->load())); /* here it should fail */
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+?>
+--EXPECTF--
+Fatal error: Allowed memory size of 10485760 bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
diff --git a/tests/pecl_bug10194_blob.phpt b/tests/pecl_bug10194_blob.phpt
new file mode 100644
index 0000000000..4c6aa4f1c9
--- /dev/null
+++ b/tests/pecl_bug10194_blob.phpt
@@ -0,0 +1,54 @@
+--TEST--
+PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
+?>
+--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/tests/pecl_bug10194_blob_64.phpt b/tests/pecl_bug10194_blob_64.phpt
new file mode 100644
index 0000000000..433d586a4e
--- /dev/null
+++ b/tests/pecl_bug10194_blob_64.phpt
@@ -0,0 +1,54 @@
+--TEST--
+PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
+?>
+--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/tests/pecl_bug16035.phpt b/tests/pecl_bug16035.phpt
new file mode 100644
index 0000000000..fc91bc91bc
--- /dev/null
+++ b/tests/pecl_bug16035.phpt
@@ -0,0 +1,26 @@
+--TEST--
+PECL Bug #16035 (Crash with Oracle 10.2 connecting with a character set but ORACLE_HOME isn't 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");
+}
+?>
+--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
+===DONE===
diff --git a/tests/pecl_bug16842.phpt b/tests/pecl_bug16842.phpt
new file mode 100644
index 0000000000..d796d2506e
--- /dev/null
+++ b/tests/pecl_bug16842.phpt
@@ -0,0 +1,69 @@
+--TEST--
+PECL Bug #16842 (NO_DATA_FOUND exception is a warning)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--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(): OCI_NO_DATA in %s on line 11
+bool(false)
+array(4) {
+ [%u|b%"code"]=>
+ int(1403)
+ [%u|b%"message"]=>
+ %unicode|string%(45) "ORA-01403: %s
+ORA-06512: at line 1"
+ [%u|b%"offset"]=>
+ int(0)
+ [%u|b%"sqltext"]=>
+ %unicode|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) {
+ [%u|b%"code"]=>
+ int(1476)
+ [%u|b%"message"]=>
+ %unicode|string%(56) "ORA-01476: %s
+ORA-06512: at line 1"
+ [%u|b%"offset"]=>
+ int(0)
+ [%u|b%"sqltext"]=>
+ %unicode|string%(29) "begin raise ZERO_DIVIDE; end;"
+}
+===DONE===
diff --git a/tests/pecl_bug6109.phpt b/tests/pecl_bug6109.phpt
new file mode 100644
index 0000000000..d0762fa883
--- /dev/null
+++ b/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/tests/pecl_bug8816.phpt b/tests/pecl_bug8816.phpt
new file mode 100644
index 0000000000..c369711fcf
--- /dev/null
+++ b/tests/pecl_bug8816.phpt
@@ -0,0 +1,98 @@
+--TEST--
+PECL Bug #8816 (issue in php_oci_statement_fetch with more than one piecewise column)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$create_1 = "CREATE TABLE t1 (id INTEGER, l1 LONG)";
+$create_2 = "CREATE TABLE t2 (id INTEGER, l2 LONG)";
+$drop_1 = "DROP TABLE t1";
+$drop_2 = "DROP TABLE t2";
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+$s1 = oci_parse($c, $create_1);
+$s2 = oci_parse($c, $create_2);
+oci_execute($s1);
+oci_execute($s2);
+
+$values = array("1234567890111111111", "122222222222222", "985456745674567654567654567654", "123456789", "987654321");
+
+$i = 0;
+foreach ($values as $val) {
+ $i++;
+ $insert = "INSERT INTO t1 VALUES($i, ".$val.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+}
+
+foreach ($values as $val) {
+ $insert = "INSERT INTO t2 VALUES($i, ".$val.")";
+ $s = oci_parse($c, $insert);
+ oci_execute($s);
+ $i--;
+}
+
+$query ="
+SELECT
+ t1.l1, t2.l2
+FROM
+t1, t2
+WHERE
+t1.id = t2.id
+ORDER BY t1.id ASC
+";
+
+$sth = oci_parse($c, $query);
+oci_execute($sth);
+
+while ( $row = oci_fetch_assoc($sth) ) {
+ var_dump($row);
+}
+
+$s1 = oci_parse($c, $drop_1);
+$s2 = oci_parse($c, $drop_2);
+@oci_execute($s1);
+@oci_execute($s2);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+array(2) {
+ ["L1"]=>
+ string(19) "1234567890111111111"
+ ["L2"]=>
+ string(9) "987654321"
+}
+array(2) {
+ ["L1"]=>
+ string(15) "122222222222222"
+ ["L2"]=>
+ string(9) "123456789"
+}
+array(2) {
+ ["L1"]=>
+ string(30) "985456745674567654567654567654"
+ ["L2"]=>
+ string(30) "985456745674567654567654567654"
+}
+array(2) {
+ ["L1"]=>
+ string(9) "123456789"
+ ["L2"]=>
+ string(15) "122222222222222"
+}
+array(2) {
+ ["L1"]=>
+ string(9) "987654321"
+ ["L2"]=>
+ string(19) "1234567890111111111"
+}
+Done
diff --git a/tests/persistent.phpt b/tests/persistent.phpt
new file mode 100644
index 0000000000..884cd35a4c
--- /dev/null
+++ b/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/tests/prefetch.phpt b/tests/prefetch.phpt
new file mode 100644
index 0000000000..26762601df
--- /dev/null
+++ b/tests/prefetch.phpt
@@ -0,0 +1,72 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(true)
+bool(true)
+int(1)
+Done
diff --git a/tests/prefetch_old.phpt b/tests/prefetch_old.phpt
new file mode 100644
index 0000000000..c2ac8fe841
--- /dev/null
+++ b/tests/prefetch_old.phpt
@@ -0,0 +1,75 @@
+--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)",
+);
+
+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
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+// 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"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(true)
+bool(true)
+int(1)
+Done
diff --git a/tests/privileged_connect.phpt b/tests/privileged_connect.phpt
new file mode 100644
index 0000000000..39122240a7
--- /dev/null
+++ b/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/tests/privileged_connect1.phpt b/tests/privileged_connect1.phpt
new file mode 100644
index 0000000000..44bb2f60a8
--- /dev/null
+++ b/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/tests/refcur_prefetch_1.phpt b/tests/refcur_prefetch_1.phpt
new file mode 100644
index 0000000000..904e4da1ff
--- /dev/null
+++ b/tests/refcur_prefetch_1.phpt
@@ -0,0 +1,256 @@
+--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");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release 1[012]\./', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 10g or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.2 or greater 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;"
+ );
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] != 942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+
+// 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,SQLT_INT)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+ }
+ if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+ 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"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+-----------------------------------------------
+Test with Prefetch value set to 0
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "1"
+%unicode|string%(%d) "test1"
+-----------------------------------------------
+Test with Prefetch value set to 1
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "2"
+%unicode|string%(%d) "test2"
+-----------------------------------------------
+Test with Prefetch value set to 501
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|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
+NULL
+NULL
+-----------------------------------------------
+Test with Prefetch value set to 499
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "500"
+%unicode|string%(%d) "test500"
+-----------------------------------------------
+Test with Prefetch value set to 250
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "251"
+%unicode|string%(%d) "test251"
+-----------------------------------------------
+Test with Prefetch value set to 12345
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|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
+NULL
+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]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|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]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
diff --git a/tests/refcur_prefetch_2.phpt b/tests/refcur_prefetch_2.phpt
new file mode 100644
index 0000000000..751ffa78f0
--- /dev/null
+++ b/tests/refcur_prefetch_2.phpt
@@ -0,0 +1,317 @@
+--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");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release 1[012]\./', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 10g or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.1 or greater 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;"
+ );
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] != 942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+
+// 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,SQLT_INT)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+ 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);
+
+echo "------Test 3 - 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 4- 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"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+------Test 1- Check Roundtrips with prefetch 0 and 5 -----------
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "1"
+ [1]=>
+ %unicode|string%(%d) "test1"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "2"
+ [1]=>
+ %unicode|string%(%d) "test2"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "3"
+ [1]=>
+ %unicode|string%(%d) "test3"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "4"
+ [1]=>
+ %unicode|string%(%d) "test4"
+}
+Number of roundtrips made with prefetch count 0 for 5 rows is 6
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "5"
+ [1]=>
+ %unicode|string%(%d) "test5"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "6"
+ [1]=>
+ %unicode|string%(%d) "test6"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "7"
+ [1]=>
+ %unicode|string%(%d) "test7"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "8"
+ [1]=>
+ %unicode|string%(%d) "test8"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "9"
+ [1]=>
+ %unicode|string%(%d) "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]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+------Test 3 - 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
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+------Test 4- Overwrite prefetch-----------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
diff --git a/tests/refcur_prefetch_3.phpt b/tests/refcur_prefetch_3.phpt
new file mode 100644
index 0000000000..0666a96e90
--- /dev/null
+++ b/tests/refcur_prefetch_3.phpt
@@ -0,0 +1,161 @@
+--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");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release (11\.2|12\.)/', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 11.2 or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.2 or greater client");
+}
+
+?>
+--FILE--
+<?php
+require dirname(__FILE__)."/connect.inc";
+
+//Create tables here
+$stmtarray = array(
+ "drop table nescurtest",
+ "create table nescurtest(c1 varchar2(10))"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] !=942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+// 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"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+oci_close($c);
+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/tests/reflection1.phpt b/tests/reflection1.phpt
new file mode 100644
index 0000000000..5f2e73d80b
--- /dev/null
+++ b/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/tests/reflection2.phpt b/tests/reflection2.phpt
new file mode 100644
index 0000000000..9e63db1d63
--- /dev/null
+++ b/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/tests/select_null.phpt b/tests/select_null.phpt
new file mode 100644
index 0000000000..87c5b815fd
--- /dev/null
+++ b/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";
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ NULL
+ ["NULL"]=>
+ NULL
+}
+Done
diff --git a/tests/serverversion.phpt b/tests/serverversion.phpt
new file mode 100644
index 0000000000..bf32fe4b54
--- /dev/null
+++ b/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) "%s"
+string(%d) "%s"
+Done
diff --git a/tests/skipif.inc b/tests/skipif.inc
new file mode 100644
index 0000000000..ed0992c8d9
--- /dev/null
+++ b/tests/skipif.inc
@@ -0,0 +1,10 @@
+<?php
+
+if (!extension_loaded('oci8')) die("skip oci8 extension is not available\n");
+
+/*
+ * Remove or comment this line to run tests
+ *
+ * */
+die("skip change default login/password\n");
+?>
diff --git a/tests/statement_cache.phpt b/tests/statement_cache.phpt
new file mode 100644
index 0000000000..19e69d4c21
--- /dev/null
+++ b/tests/statement_cache.phpt
@@ -0,0 +1,35 @@
+--TEST--
+statement cache
+--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 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"
+ ["1+3"]=>
+ string(1) "4"
+}
+array(2) {
+ [0]=>
+ string(1) "4"
+ ["1+3"]=>
+ string(1) "4"
+}
+Done
diff --git a/tests/statement_type.phpt b/tests/statement_type.phpt
new file mode 100644
index 0000000000..29cdd94402
--- /dev/null
+++ b/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/tests/statement_type_old.phpt b/tests/statement_type_old.phpt
new file mode 100644
index 0000000000..2626d6203c
--- /dev/null
+++ b/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/tests/test.gif b/tests/test.gif
new file mode 100644
index 0000000000..f352c7308f
--- /dev/null
+++ b/tests/test.gif
Binary files differ
diff --git a/tests/test.txt b/tests/test.txt
new file mode 100644
index 0000000000..4b89727035
--- /dev/null
+++ b/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/tests/testping.phpt b/tests/testping.phpt
new file mode 100644
index 0000000000..a0d65a30c3
--- /dev/null
+++ b/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/tests/uncommitted.phpt b/tests/uncommitted.phpt
new file mode 100644
index 0000000000..3c341c8cb4
--- /dev/null
+++ b/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/tests/xmltype_01.phpt b/tests/xmltype_01.phpt
new file mode 100644
index 0000000000..a9458c83d4
--- /dev/null
+++ b/tests/xmltype_01.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Basic XMLType test
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+<?php if (!extension_loaded("simplexml")) die("skip no simplexml extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialization
+
+$stmts = 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>'))"
+);
+
+foreach ($stmts as $q) {
+ $s = oci_parse($c, $q);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $m = oci_error($s);
+ if ($m['code'] != 942) { // table or view doesn't exist
+ echo $m['message'], "\n";
+ }
+ }
+}
+
+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
+
+$stmts = array(
+ "drop table xtt",
+);
+
+foreach ($stmts as $q) {
+ $s = oci_parse($c, $q);
+ @oci_execute($s);
+}
+
+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/tests/xmltype_02.phpt b/tests/xmltype_02.phpt
new file mode 100644
index 0000000000..9b6fa8ad32
--- /dev/null
+++ b/tests/xmltype_02.phpt
@@ -0,0 +1,197 @@
+--TEST--
+Basic XMLType test #2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 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)",
+);
+
+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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
+ }
+}
+
+// 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
+
+//require(dirname(__FILE__).'/drop_table.inc');
+
+$stmtarray = array(
+ "drop table xmltype_02_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1 Insert new XML data using a temporary CLOB
+array(1) {
+ [0]=>
+ object(OCI-Lob)#%d (1) {
+ [%u|b%"descriptor"]=>
+ resource(%d) of type (oci8 descriptor)
+ }
+}
+Test 2 Manipulate the data using SimpleXML
+object(SimpleXMLElement)#%d (10) {
+ [%u|b%"WarehouseId"]=>
+ %unicode|string%(1) "1"
+ [%u|b%"WarehouseName"]=>
+ %unicode|string%(16) "Southlake, Texas"
+ [%u|b%"Building"]=>
+ %unicode|string%(5) "Owned"
+ [%u|b%"Area"]=>
+ %unicode|string%(5) "25000"
+ [%u|b%"Docks"]=>
+ %unicode|string%(1) "2"
+ [%u|b%"DockType"]=>
+ %unicode|string%(9) "Rear load"
+ [%u|b%"WaterAccess"]=>
+ %unicode|string%(4) "true"
+ [%u|b%"RailAccess"]=>
+ %unicode|string%(1) "N"
+ [%u|b%"Parking"]=>
+ %unicode|string%(6) "Street"
+ [%u|b%"VClearance"]=>
+ %unicode|string%(2) "10"
+}
+object(SimpleXMLElement)#%d (10) {
+ [%u|b%"WarehouseId"]=>
+ %unicode|string%(1) "1"
+ [%u|b%"WarehouseName"]=>
+ %unicode|string%(16) "Southlake, Texas"
+ [%u|b%"Building"]=>
+ %unicode|string%(5) "Owned"
+ [%u|b%"Area"]=>
+ %unicode|string%(5) "25000"
+ [%u|b%"Docks"]=>
+ %unicode|string%(1) "1"
+ [%u|b%"DockType"]=>
+ %unicode|string%(9) "Rear load"
+ [%u|b%"WaterAccess"]=>
+ %unicode|string%(4) "true"
+ [%u|b%"RailAccess"]=>
+ %unicode|string%(1) "N"
+ [%u|b%"Parking"]=>
+ %unicode|string%(6) "Street"
+ [%u|b%"VClearance"]=>
+ %unicode|string%(2) "10"
+}
+Test 3: Update changes using a temporary CLOB
+%unicode|string%(331) "<?xml version="1.0"?>
+<Warehouse>
+<WarehouseId>1</WarehouseId>
+<WarehouseName>Southlake, Texas</WarehouseName>
+<Building>Owned</Building>
+<Area>25000</Area>
+<Docks>1</Docks>
+<DockType>Rear load</DockType>
+<WaterAccess>true</WaterAccess>
+<RailAccess>N</RailAccess>
+<Parking>Street</Parking>
+<VClearance>10</VClearance>
+</Warehouse>
+"
+===DONE=== \ No newline at end of file