--- /dev/null
+--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
--TEST--
Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)
--SKIPIF--
-<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+<?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
--- /dev/null
+--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
--FILE--
<?php
-require dirname(__FILE__).'/connect.inc';
+require(dirname(__FILE__).'/connect.inc');
// Initialization
// 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++)
-{
+for ($x = 0; $x < 70000; $x++) {
if (!($var = oci_new_collection($c, 'BUG44113_LIST_T'))) {
print "Failed new collection creation on $x\n";
break;
--FILE--
<?php
-require(dirname(__FILE__).'/connect.inc');
+require dirname(__FILE__).'/connect.inc';
// Run Test
-for ($x = 0; $x < 400; $x++) {
+for ($x = 0; $x < 400; $x++)
+{
$stmt = "select cursor (select $x from dual) a,
- cursor (select $x from dual) b
- from dual";
+ cursor (select $x from dual) b
+ from dual";
$s = oci_parse($c, $stmt);
$r = oci_execute($s);
- if (!$r) {
- echo "Exiting $x\n";
- exit;
- }
- $result = oci_fetch_array($s, OCI_ASSOC);
+ 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'], OCI_ASSOC);
- oci_fetch_array($result['B'], OCI_ASSOC);
+ 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);
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
+
--- /dev/null
+<?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);
+}
+
+?>
--- /dev/null
+--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
+
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
+
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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 expected behavior of this test is different between PHP 5.2 and
+// PHP 5.3
+//
+// In PHP 5.2, the test opens a connection within function1 and
+// updates a table (without committing). Another connection is opened
+// from function 2, and the table queried. The connections should
+// share the same resource, so the new data is visible in function2.
+
+// 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
--- /dev/null
+--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
--FILE--
<?php
-// test some LOB error messages
-
require(dirname(__FILE__).'/connect.inc');
require(dirname(__FILE__).'/create_table.inc');
--TEST--
-oci_password_change()
+oci_password_change() for non-persistent connections
--SKIPIF--
-<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+<?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");
+?>
--FILE--
<?php
-require dirname(__FILE__)."/connect.inc";
+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");
-$new_password = "test";
-var_dump(oci_password_change($dbase, $user, $password, $new_password));
+// 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";
+}
-if (!empty($dbase)) {
- var_dump($new_c = ocilogon($user,$new_password,$dbase));
+// Connections should be the same
+if ($rn1 == $rn3) {
+ echo "First and third connections share a resource: OK\n";
}
else {
- var_dump($new_c = ocilogon($user,$new_password));
+ echo "First and third connections are different: Not OK\n";
+ var_dump($c1);
+ var_dump($c2);
}
-var_dump(oci_password_change($dbase, $user, $new_password, $password));
+// 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";
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
<?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");
?>
--FILE--
// Connect (persistent) and change the password
$c1 = oci_pconnect("testuser", "testuserpwd", $dbase);
var_dump($c1);
-
-ob_start();
-var_dump($c1);
-$r1 = ob_get_clean();
-preg_match("/resource\(([0-9])\) of.*/", $r1, $matches);
-$rn1 = $matches[1]; /* resource number */
+$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);
-
-ob_start();
-var_dump($c2);
-$r2 = ob_get_clean();
-preg_match("/resource\(([0-9])\) of.*/", $r2, $matches);
-$rn2 = $matches[1]; /* resource number */
+$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);
-
-ob_start();
-var_dump($c3);
-$r3 = ob_get_clean();
-preg_match("/resource\(([0-9])\) of.*/", $r3, $matches);
-$rn3 = $matches[1]; /* resource number */
+$rn3 = (int)$c3;
// Connections should differ
if ($rn1 == $rn2) {
}
// Clean up
-// Can't drop a user that is connected and can't close a persistent
-// connection. So this test will leave the dummy user around, but the
-// schema will not be usable..
-$s = oci_parse($c0, "revoke connect, create session from testuser");
+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";
--TEST--
oci_password_change()
--SKIPIF--
-<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+<?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");
+
+// This test is known to fail with Oracle 10g client libraries
+// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+$sv = oci_server_version($c);
+$sv = preg_match('/11.1/', $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 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+ }
+}
+?>
--FILE--
<?php
--TEST--
ocipasswordchange()
--SKIPIF--
-<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+<?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");
+
+// This test is known to fail with Oracle 10g client libraries
+// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+$sv = oci_server_version($c);
+$sv = preg_match('/11.1/', $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 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+ }
+}
+?>
--FILE--
<?php
require dirname(__FILE__)."/connect.inc";
$new_password = "test";
-var_dump(ocipasswordchange($c, $user, $password, $new_password));
+var_dump(ocipasswordchange($dbase, $user, $password, $new_password));
if (!empty($dbase)) {
var_dump($new_c = ocilogon($user,$new_password,$dbase));
var_dump($new_c = ocilogon($user,$new_password));
}
-var_dump(ocipasswordchange($new_c, $user, $new_password, $password));
+var_dump(ocipasswordchange($dbase, $user, $new_password, $password));
echo "Done\n";
?>
--EXPECTF--
-bool(true)
resource(%d) of type (oci8 connection)
-bool(true)
+resource(%d) of type (oci8 connection)
+resource(%d) of type (oci8 connection)
Done
--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"); ?>
+<?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=10M
+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())
- ";
+$ora_sql = "INSERT INTO ".$schema.$table_name." (blob)
+ VALUES (empty_blob())";
$statement = oci_parse($c,$ora_sql);
oci_execute($statement);
oci_commit($c);
-$ora_sql = "SELECT blob FROM ".$schema.$table_name."";
+$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 */
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
--- /dev/null
+--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
--- /dev/null
+--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