summaryrefslogtreecommitdiff
path: root/ext/oci8/tests
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2009-10-06 22:36:32 +0000
committerChristopher Jones <sixd@php.net>2009-10-06 22:36:32 +0000
commit2769ae044457f19c2adf899f6f159087e60d1af9 (patch)
treee0b3e33b2656d5f60f5b72ee39c23822ee49142e /ext/oci8/tests
parentef2b799a28f1fe94874726935e14b961aaaf74b0 (diff)
downloadphp-git-2769ae044457f19c2adf899f6f159087e60d1af9.tar.gz
1. Introduce connection attribute functions:
oci_set_module_name oci_set_action oci_set_client_info oci_set_client_identifier These functions set values that are visible and used by the database. They aid tracing, authentication and auditing. 2. Introduce connection attribute function: oci_set_edition Oracle 11g R2 "editions" allow multiple versions of DB objects to exist at one time. By setting different editions, two different versions of an application can run concurrently, making upgrades or A/B testing easier. 3. Introduce OCI_NO_AUTO_COMMIT as an alias for the OCI_DEFAULT constant (which is not the default value) used by oci_execute(). 4. Allow the oci_set_prefetch value to be 0. This is important in some cases using REF CURSORS in Oracle 11gR2. 5. Set the DRIVER_NAME attribute of Oracle Database 11gR2 connections to aid application tracing. The value used is to "PHP OCI8" followed by the OCI8 version number. Note the version number may get truncated in DB views such as v$session_connect_info. 6. Generate an error if an invalid resource type is used in oci_bind_by_name [DOC] Documentation will be added for the changes
Diffstat (limited to 'ext/oci8/tests')
-rw-r--r--ext/oci8/tests/bind_error.phpt70
-rw-r--r--ext/oci8/tests/commit.phpt60
-rw-r--r--ext/oci8/tests/conn_attr.inc150
-rw-r--r--ext/oci8/tests/conn_attr_1.phpt104
-rw-r--r--ext/oci8/tests/conn_attr_2.phpt111
-rw-r--r--ext/oci8/tests/conn_attr_3.phpt94
-rw-r--r--ext/oci8/tests/conn_attr_4.phpt121
-rw-r--r--ext/oci8/tests/conn_attr_5.phpt76
-rw-r--r--ext/oci8/tests/debug.phpt10
-rw-r--r--ext/oci8/tests/driver_name.phpt71
-rw-r--r--ext/oci8/tests/edition_1.phpt156
-rw-r--r--ext/oci8/tests/edition_2.phpt248
-rw-r--r--ext/oci8/tests/refcur_prefetch_1.phpt256
-rw-r--r--ext/oci8/tests/refcur_prefetch_2.phpt317
-rw-r--r--ext/oci8/tests/refcur_prefetch_3.phpt161
-rw-r--r--ext/oci8/tests/reflection1.phpt44
16 files changed, 2020 insertions, 29 deletions
diff --git a/ext/oci8/tests/bind_error.phpt b/ext/oci8/tests/bind_error.phpt
new file mode 100644
index 0000000000..ad66ad59fe
--- /dev/null
+++ b/ext/oci8/tests/bind_error.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/ext/oci8/tests/commit.phpt b/ext/oci8/tests/commit.phpt
index 3bef318c85..836d2cd1df 100644
--- a/ext/oci8/tests/commit.phpt
+++ b/ext/oci8/tests/commit.phpt
@@ -1,28 +1,36 @@
--TEST--
-oci_commit()/oci_rollback()
+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';
+require(dirname(__FILE__)."/connect.inc");
+require(dirname(__FILE__).'/create_table.inc');
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$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."";
+$select_sql = "select * from ".$schema.$table_name."";
if (!($select = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
@@ -40,7 +48,7 @@ if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$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");
@@ -62,56 +70,56 @@ var_dump(oci_fetch_all($select, $all));
var_dump($all);
-require dirname(__FILE__).'/drop_table.inc';
+require(dirname(__FILE__).'/drop_table.inc');
echo "Done\n";
?>
---EXPECT--
+--EXPECTF--
bool(true)
int(0)
array(5) {
- ["ID"]=>
+ [%u|b%"ID"]=>
array(0) {
}
- ["VALUE"]=>
+ [%u|b%"VALUE"]=>
array(0) {
}
- ["BLOB"]=>
+ [%u|b%"BLOB"]=>
array(0) {
}
- ["CLOB"]=>
+ [%u|b%"CLOB"]=>
array(0) {
}
- ["STRING"]=>
+ [%u|b%"STRING"]=>
array(0) {
}
}
bool(true)
int(4)
array(5) {
- ["ID"]=>
+ [%u|b%"ID"]=>
array(4) {
[0]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[1]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[2]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[3]=>
- string(1) "1"
+ %string|unicode%(1) "1"
}
- ["VALUE"]=>
+ [%u|b%"VALUE"]=>
array(4) {
[0]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[1]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[2]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[3]=>
- string(1) "1"
+ %string|unicode%(1) "1"
}
- ["BLOB"]=>
+ [%u|b%"BLOB"]=>
array(4) {
[0]=>
NULL
@@ -122,7 +130,7 @@ array(5) {
[3]=>
NULL
}
- ["CLOB"]=>
+ [%u|b%"CLOB"]=>
array(4) {
[0]=>
NULL
@@ -133,7 +141,7 @@ array(5) {
[3]=>
NULL
}
- ["STRING"]=>
+ [%u|b%"STRING"]=>
array(4) {
[0]=>
NULL
diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc
new file mode 100644
index 0000000000..746b6b7ea6
--- /dev/null
+++ b/ext/oci8/tests/conn_attr.inc
@@ -0,0 +1,150 @@
+<?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
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ if ($m['code'] == 38807) {
+ echo "You appear to already have an edition in use that prevents this PHP test from running. Query DBA_EDITIONS to see existing editions.". PHP_EOL;
+ }
+ die;
+ }
+ }
+}
+
+function get_attr($conn,$attr)
+{
+ $sel_stmt="select " .$attr. " from v\$session where sid =
+ (select sid from v\$session where audsid =
+ sys_context('userenv','sessionid')) order by 1";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+ }
+}
+
+/* Pass $conn_type=1 for a connection with oci_connect()
+ Pass $conn_type=2 for ooci_pconnect
+ Default will give a oci_new_connect */
+
+function get_conn($conn_type)
+{
+ $user = 'testuser';
+ $password = 'testuser';
+ $dbase = $GLOBALS['dbase'];
+ switch($conn_type) {
+ case 1:
+ echo "Testing with oci_connect()\n";
+ return(oci_connect($user,$password,$dbase));
+ break;
+ case 2:
+ echo "Testing with oci_pconnect()\n";
+ return(oci_pconnect($user,$password,$dbase));
+ break;
+ default:
+ echo "Testing with oci_new_connect()\n";
+ return(oci_new_connect($user,$password,$dbase));
+ break;
+ }
+}
+
+function set_attr($conn,$attr,$sufix)
+{
+ if (!strcmp($attr,'MODULE'))
+ $r = oci_set_module_name($conn,'PHP TEST'.$sufix);
+ else if (!strcmp($attr,'ACTION'))
+ $r = oci_set_action($conn,'TASK'.$sufix);
+ else if (!strcmp($attr,'CLIENT_INFO'))
+ $r = oci_set_client_info($conn,'INFO1'.$sufix);
+ else if (!strcmp($attr,'CLIENT_IDENTIFIER'))
+ $r = oci_set_client_identifier($conn,'ID00'.$sufix);
+ else
+ echo "Pass one of the above four attibutes!!!\n";
+ if ($r) {
+ echo "Value of $attr has been set successfully\n";
+ }
+
+ //Do a round-trip here
+ oci_server_version($conn);
+ return $r;
+}
+
+function set_edit_attr($value)
+{
+ $r = oci_set_edition($value);
+ if ($r) {
+ echo " The value of edition has been successfully set\n";
+ }
+ return $r;
+}
+
+function get_edit_attr ($conn) {
+ $sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of current EDITION is ".oci_result($s2,1)."\n";
+ }
+}
+
+function get_sys_attr($conn,$attr)
+{
+ $sel_stmt="select " .$attr. " from v\$session where sid =
+ (select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+ }
+}
+
+function clean_up($c) {
+ $stmtarray = array(
+ "drop user testuser cascade",
+ "drop edition myedition1",
+ "drop edition myedition",
+ );
+
+ foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+ }
+}
diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt
new file mode 100644
index 0000000000..c7c1b870e5
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt
new file mode 100644
index 0000000000..4765d5eb7b
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/conn_attr_3.phpt b/ext/oci8/tests/conn_attr_3.phpt
new file mode 100644
index 0000000000..8b6d921230
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt
new file mode 100644
index 0000000000..2ef2673fd1
--- /dev/null
+++ b/ext/oci8/tests/conn_attr_4.phpt
@@ -0,0 +1,121 @@
+--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");
+
+$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/ext/oci8/tests/conn_attr_5.phpt b/ext/oci8/tests/conn_attr_5.phpt
new file mode 100644
index 0000000000..9f6b6c7247
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt
index cdd56a0816..49e3d4cfd1 100644
--- a/ext/oci8/tests/debug.phpt
+++ b/ext/oci8/tests/debug.phpt
@@ -6,9 +6,9 @@ if (!extension_loaded('oci8')) die("skip no oci8 extension");
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_clean();
-$iv = preg_match('/Oracle .*Version => 11/', $phpinfo);
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
if ($iv !== 1) {
- die ("skip expected output only valid when using Oracle 11g client libraries");
+ die ("skip expected output only valid when using Oracle 11gR2+ client libraries");
}
?>
--FILE--
@@ -34,8 +34,12 @@ 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)
@@ -44,7 +48,7 @@ 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: (%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)
diff --git a/ext/oci8/tests/driver_name.phpt b/ext/oci8/tests/driver_name.phpt
new file mode 100644
index 0000000000..a5076a5c12
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt
new file mode 100644
index 0000000000..9a4b0f3b61
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt
new file mode 100644
index 0000000000..f7ab979bcf
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/refcur_prefetch_1.phpt b/ext/oci8/tests/refcur_prefetch_1.phpt
new file mode 100644
index 0000000000..c603fdd5bb
--- /dev/null
+++ b/ext/oci8/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 "SYSTEM.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 "SYSTEM.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/ext/oci8/tests/refcur_prefetch_2.phpt b/ext/oci8/tests/refcur_prefetch_2.phpt
new file mode 100644
index 0000000000..751ffa78f0
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/refcur_prefetch_3.phpt b/ext/oci8/tests/refcur_prefetch_3.phpt
new file mode 100644
index 0000000000..0666a96e90
--- /dev/null
+++ b/ext/oci8/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/ext/oci8/tests/reflection1.phpt b/ext/oci8/tests/reflection1.phpt
index 62ee02b840..5f2e73d80b 100644
--- a/ext/oci8/tests/reflection1.phpt
+++ b/ext/oci8/tests/reflection1.phpt
@@ -121,6 +121,11 @@ 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===
@@ -1049,4 +1054,43 @@ Function [ <internal%s> function ocicolltrim ] {
}
}
+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===