diff options
Diffstat (limited to 'ext/oci8/tests')
| -rw-r--r-- | ext/oci8/tests/bug42841.phpt | 187 | ||||
| -rw-r--r-- | ext/oci8/tests/debug.phpt | 4 | ||||
| -rw-r--r-- | ext/oci8/tests/details.inc | 13 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_characterset.phpt | 61 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_conn_close1.phpt | 45 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_conn_close2.phpt | 46 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_connect1.phpt | 86 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_connection_class.phpt | 24 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_functions.inc | 93 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_newconnect.phpt | 43 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_pconn_close1.phpt | 44 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_pconn_close2.phpt | 46 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_privileged.phpt | 47 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_scope1.phpt | 91 | ||||
| -rw-r--r-- | ext/oci8/tests/drcp_scope2.phpt | 90 | ||||
| -rw-r--r-- | ext/oci8/tests/password.phpt | 6 | ||||
| -rw-r--r-- | ext/oci8/tests/password_2.phpt | 13 | ||||
| -rw-r--r-- | ext/oci8/tests/password_new.phpt | 6 | ||||
| -rw-r--r-- | ext/oci8/tests/password_old.phpt | 6 |
19 files changed, 939 insertions, 12 deletions
diff --git a/ext/oci8/tests/bug42841.phpt b/ext/oci8/tests/bug42841.phpt new file mode 100644 index 0000000000..921c8149dd --- /dev/null +++ b/ext/oci8/tests/bug42841.phpt @@ -0,0 +1,187 @@ +--TEST-- +Bug #42841 (REF CURSOR and oci_new_cursor PHP crash) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.statement_cache_size=20 +--FILE-- +<?php + +require dirname(__FILE__).'/details.inc'; + +// note a oci_new_connect() occurs lower in the script +$c = oci_connect($user, $password, $dbase); + +// Initialization + +$stmtarray = array( + "create or replace procedure bug42841_proc(out_1 out sys_refcursor) is + begin + open out_1 for select 11 from dual union all select 12 from dual union all select 13 from dual; + end bug42841_proc;", + + "create or replace package bug43449_pkg is + type cursortype is ref Cursor; + function testcursor return cursortype; + end bug43449_pkg;", + + "create or replace package body bug43449_pkg is + function testcursor return cursortype is + retCursor cursorType; + begin + Open retCursor For 'select * from dual'; + return retCursor; + end; + end bug43449_pkg;" +); + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + @oci_execute($s); +} + +// Main code + +function do_bug42841($c) +{ + echo "First attempt\n"; + + $sql = "BEGIN bug42841_proc(:cursor); END;"; + $stmt = oci_parse($c, $sql); + $cursor = oci_new_cursor($c); + oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cursor); + + while($row = oci_fetch_array($cursor, OCI_ASSOC + OCI_RETURN_LOBS)) { + $data1[] = $row; + } + + oci_free_statement($stmt); + oci_free_statement($cursor); + var_dump($data1); + + echo "Second attempt\n"; + + $sql = "BEGIN bug42841_proc(:cursor); END;"; + $stmt = oci_parse($c, $sql); + $cursor = oci_new_cursor($c); + oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cursor); + + while($row = oci_fetch_array($cursor, OCI_ASSOC + OCI_RETURN_LOBS)) { + $data2[] = $row; + } + + oci_free_statement($stmt); + oci_free_statement($cursor); + var_dump($data2); +} + +function do_bug43449($c) +{ + + for ($i = 0; $i < 2; $i++) { + var_dump(bug43449_getCur($c)); + } +} + +function bug43449_getCur($c) +{ + $cur = oci_new_cursor($c); + $stmt = oci_parse($c, 'begin :cur := bug43449_pkg.testcursor; end;'); + oci_bind_by_name($stmt, ':cur', $cur, -1, OCI_B_CURSOR); + oci_execute($stmt, OCI_DEFAULT); + oci_execute($cur, OCI_DEFAULT); + + $ret = array(); + + while (ocifetchinto($cur, $row, OCI_ASSOC)) { + $ret[] = $row; + } + + oci_free_statement($cur); + oci_free_statement($stmt); + return $ret; +} + +echo "Test bug 42841: Procedure with OUT cursor parameter\n"; +do_bug42841($c); + +$c = oci_new_connect($user, $password, $dbase); + +echo "Test bug 43449: Cursor as function result\n"; +do_bug43449($c); + +// Cleanup + +$stmtarray = array( + "drop procedure bug42841_proc", + "drop package bug43449_pkg" +); + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + oci_execute($s); +} + +echo "Done\n"; + +?> +--EXPECT-- +Test bug 42841: Procedure with OUT cursor parameter +First attempt +array(3) { + [0]=> + array(1) { + [11]=> + string(2) "11" + } + [1]=> + array(1) { + [11]=> + string(2) "12" + } + [2]=> + array(1) { + [11]=> + string(2) "13" + } +} +Second attempt +array(3) { + [0]=> + array(1) { + [11]=> + string(2) "11" + } + [1]=> + array(1) { + [11]=> + string(2) "12" + } + [2]=> + array(1) { + [11]=> + string(2) "13" + } +} +Test bug 43449: Cursor as function result +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} +array(1) { + [0]=> + array(1) { + ["DUMMY"]=> + string(1) "X" + } +} +Done diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt index cc771d5319..669c425394 100644 --- a/ext/oci8/tests/debug.phpt +++ b/ext/oci8/tests/debug.phpt @@ -22,10 +22,10 @@ echo "Done\n"; --EXPECTF-- OCI8 DEBUG: OCINlsEnvironmentVariableGet at (%s:%d) Done -OCI8 DEBUG: OCISessionEnd at (%s:%d) +OCI8 DEBUG: OCISessionRelease at (%s:%d) OCI8 DEBUG: OCIHandleFree at (%s:%d) -OCI8 DEBUG: OCIServerDetach at (%s:%d) OCI8 DEBUG: OCIHandleFree at (%s:%d) +OCI8 DEBUG: OCISessionPoolDestroy at (%s:%d) OCI8 DEBUG: OCIHandleFree at (%s:%d) OCI8 DEBUG: OCIHandleFree at (%s:%d) OCI8 DEBUG: OCIHandleFree at (%s:%d) diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc index bfd9f309b7..c09212fd2a 100644 --- a/ext/oci8/tests/details.inc +++ b/ext/oci8/tests/details.inc @@ -2,13 +2,23 @@ /* * Please change $user, $password and $dbase to match your configuration. - * Set $oracle_on_localhost to TRUE if the Oracle Database is installed on your localhost. + * + * Set $oracle_on_localhost to TRUE if the Oracle Database is + * installed on your localhost. + * + * Set $test_drcp to TRUE if you want to run the Oracle Database + * Resident Connection Pooling (DRCP) tests. For these tests to run + * successfully, you need a server and client which is Oracle 11g or + * greater, and $dbase should be set to the tnsnames.ora entry + * corresponding to the POOLED server instance or an Easy Connect + * string like hostname:port/service_name:POOLED */ if (false !== getenv('PHP_OCI8_TEST_DB')) { $user = getenv('PHP_OCI8_TEST_USER'); // Database username for tests $password = getenv('PHP_OCI8_TEST_PASS'); // Password for $user $dbase = getenv('PHP_OCI8_TEST_DB'); // Database connection string + $test_drcp = getenv('PHP_OCI8_TEST_DRCP'); $oracle_on_localhost = getenv('PHP_OCI8_TEST_DB_ON_LOCALHOST'); if (false !== $oracle_on_localhost && 0 == strcasecmp($oracle_on_localhost,'TRUE')) { $oracle_on_localhost = TRUE; @@ -20,6 +30,7 @@ if (false !== getenv('PHP_OCI8_TEST_DB')) { $password = "system"; $dbase = "oracle"; $oracle_on_localhost = FALSE; + $test_drcp = FALSE; } ?> diff --git a/ext/oci8/tests/drcp_characterset.phpt b/ext/oci8/tests/drcp_characterset.phpt new file mode 100644 index 0000000000..657d4c5bab --- /dev/null +++ b/ext/oci8/tests/drcp_characterset.phpt @@ -0,0 +1,61 @@ +--TEST-- +DRCP: oci_pconnect() and oci_connect() with different character sets +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Create connections with oci_connect and oci_pconnect with UTF8 as Charset + +$c1 = oci_connect($user,$password,$dbase,"UTF8"); +var_dump($c1); + +// Now with oci_pconnect() + +$p1 = oci_pconnect($user,$password,$dbase,"UTF8"); +var_dump($p1); + +// Create two more connections with character set US7ASCII + +$c2 = oci_connect($user,$password,$dbase,"US7ASCII"); +var_dump($c2); + +// Now with oci_pconnect() + +$p2 = oci_pconnect($user,$password,$dbase,"US7ASCII"); +var_dump($p2); + +// The two connections c1 and c2 should not share resources as they use different +//character sets + +if((int)$c1 === (int)$c2) + echo "First and third connections share a resource: NOT OK\n"; +else + echo "First and third connections are different: OK\n"; + +// The two connections p1 and p2 should not share resources as they use different +//character sets + +if((int)$p1 === (int)$p2) + echo "Second and fourth connections share a resource: NOT OK\n"; +else + echo "Second and fourth connections are different: OK\n"; + +// Close all the connections +oci_close($c1); +oci_close($c2); +oci_close($p1); +oci_close($p2); + +echo "Done\n"; +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 persistent connection) +First and third connections are different: OK +Second and fourth connections are different: OK +Done diff --git a/ext/oci8/tests/drcp_conn_close1.phpt b/ext/oci8/tests/drcp_conn_close1.phpt new file mode 100644 index 0000000000..697b7e3575 --- /dev/null +++ b/ext/oci8/tests/drcp_conn_close1.phpt @@ -0,0 +1,45 @@ +--TEST-- +DRCP: oci_connect() with oci_close() and oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a connection +// Close the connection +// Open another connection +// With oci_close() being a no-op, the same conneciton will be returned + + +echo "This is with a OCI_CONNECT\n"; +var_dump($conn1 = oci_connect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection + +var_dump($conn2 = oci_connect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : OK \n"; +else + echo "Both connections are different : NOT OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Both connections share a resource : OK +Done diff --git a/ext/oci8/tests/drcp_conn_close2.phpt b/ext/oci8/tests/drcp_conn_close2.phpt new file mode 100644 index 0000000000..0d3f8247f2 --- /dev/null +++ b/ext/oci8/tests/drcp_conn_close2.phpt @@ -0,0 +1,46 @@ +--TEST-- +DRCP: oci_connect() with oci_close() and oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a connection +// Close the connection +// Open another connection +// With oci_close() the connection is released to the pool and hence the +// the second conneciton will be different + + +// OCI_CONNECT +echo "This is with a OCI_CONNECT\n"; +var_dump($conn1 = oci_connect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection +var_dump($conn2 = oci_connect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : NOT OK \n"; +else + echo "Both connections are different : OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Both connections are different : OK +Done diff --git a/ext/oci8/tests/drcp_connect1.phpt b/ext/oci8/tests/drcp_connect1.phpt new file mode 100644 index 0000000000..a49885f1e4 --- /dev/null +++ b/ext/oci8/tests/drcp_connect1.phpt @@ -0,0 +1,86 @@ +--TEST-- +DRCP: oci_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.connection_class=test +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; +require dirname(__FILE__)."/drcp_functions.inc"; + +// Open a number of connections with oci_connect and oci_pconnect and verify +// whether we get a used session with DRCP. +// To verify this, we change the value of a PL/SQL package variable in one +// session and query for this through another connection + +var_dump($conn1 = oci_connect($user,$password,$dbase)); +// Create the package +drcp_create_package($conn1); + +// OCI_CONNECT +echo " This is with OCI_CONNECT.....\n"; +drcp_select_packagevar($conn1); // Returns 0 +drcp_set_packagevar($conn1,1000); +oci_close($conn1); +echo " Connection conn1 closed....\n"; + +// Second connection should return 0 for the package variable. +var_dump($conn2 = oci_connect($user,$password,$dbase)); +echo " Select with connection 2 \n"; +drcp_select_packagevar($conn2); // Returns 0 +drcp_set_packagevar($conn2,100); + +// Third connection. There is no oci_close() for conn2 hence this should +// return the value set by conn2. +var_dump($conn3 = oci_connect($user,$password,$dbase)); +echo " Select with connection 3 \n"; +drcp_select_packagevar($conn3); // Returns 100 + +// Close all the connections +oci_close($conn2); +oci_close($conn3); + +// OCI_PCONNECT +echo "\n This is with oci_pconnect().....\n"; +var_dump($pconn1 = oci_pconnect($user,$password,$dbase)); +drcp_set_packagevar($pconn1,1000); +oci_close($pconn1); +echo " Connection pconn1 closed....\n"; + +// Second conenction with oci_pconnect should return the same session hence the +// value returned is what is set by pconn1 + +var_dump($pconn2 = oci_pconnect($user,$password,$dbase)); +echo " Select with persistent connection 2 \n"; +drcp_select_packagevar($pconn2); // Returns 1000 +oci_close($pconn2); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) + This is with OCI_CONNECT..... + The value of the package variable is 0 + Package variable value set to 1000 + Connection conn1 closed.... +resource(%d) of type (oci8 connection) + Select with connection 2 + The value of the package variable is 0 + Package variable value set to 100 +resource(%d) of type (oci8 connection) + Select with connection 3 + The value of the package variable is 100 + + This is with oci_pconnect()..... +resource(%d) of type (oci8 persistent connection) + Package variable value set to 1000 + Connection pconn1 closed.... +resource(%d) of type (oci8 persistent connection) + Select with persistent connection 2 + The value of the package variable is 1000 +Done + diff --git a/ext/oci8/tests/drcp_connection_class.phpt b/ext/oci8/tests/drcp_connection_class.phpt new file mode 100644 index 0000000000..2aed131c14 --- /dev/null +++ b/ext/oci8/tests/drcp_connection_class.phpt @@ -0,0 +1,24 @@ +--TEST-- +DRCP: oci8.connection_class with ini_get() and ini_set() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.connection_class=test +--FILE-- +<?php + +echo "Setting a new connection class now\n"; +ini_set('oci8.connection_class',"New cc"); + +// Get the New connection class name .Should return New CC + +$new_cc = ini_get('oci8.connection_class'); +echo "The New oci8.connection_class is $new_cc \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +Setting a new connection class now +The New oci8.connection_class is New cc +Done diff --git a/ext/oci8/tests/drcp_functions.inc b/ext/oci8/tests/drcp_functions.inc new file mode 100644 index 0000000000..26adb21f35 --- /dev/null +++ b/ext/oci8/tests/drcp_functions.inc @@ -0,0 +1,93 @@ +<?php + +/* This file contains functions required by the DRCP tests */ + +function drcp_create_table($conn) +{ + $create_sql = "CREATE TABLE DRCPTEST (id NUMBER, name VARCHAR2(10), dept VARCHAR2(10))"; + $statement = oci_parse($conn, $create_sql); + oci_execute($statement); + + $id_values = array(100,101,102,103,104,105,106,107,108); + $name_values = array("WIILIAMS","JOHN","SMITH","JONES","ADAMS","ROBERT", + "BILL","LAWSON","MARY"); + $dept_values = array("ACCOUNTS","HR","HR","ADMIN","ACCOUNTS","HR", + "ACCOUNTS","HR","ACCOUNTS"); + for($i=0; $i<8; $i++) { + $insert = "INSERT INTO DRCPTEST VALUES('".$id_values[$i]."','". $name_values[$i]."','".$dept_values[$i]."')"; + $s = oci_parse($conn, $insert); + oci_execute($s); + } +} + +function drcp_drop_table($conn) +{ + $ora_sql = "DROP TABLE DRCPTEST"; + $statement = oci_parse($conn, $ora_sql); + oci_execute($statement); +} + +function drcp_update_table($conn) +{ + $update_stmt ="Update drcptest set dept ='NEWDEPT' where id = 105"; + $s1 = oci_parse($conn,$update_stmt); + oci_execute($s1,OCI_DEFAULT); + echo "Update done-- DEPT value has been set to NEWDEPT\n"; +} + +function drcp_select_value($conn) +{ + $sel_stmt="select dept from drcptest where id=105"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while(oci_fetch($s2)) { + echo "The value of DEPT for id 105 is ".oci_result($s2,1)."\n"; + } +} + +function drcp_select_packagevar($conn) +{ + $sel_stmt="select drcp_test_package.f1 as f1 from dual"; + $s2 = oci_parse($conn, $sel_stmt); + oci_define_by_name($s2,'f1',$ret_num); + oci_execute($s2); + while(oci_fetch($s2)) { + echo " The value of the package variable is ".oci_result($s2,1)."\n"; + } +} + + +function drcp_set_packagevar($conn,$num) +{ + $set_stmt = "begin drcp_test_package.p1($num); end;"; + $s1 = oci_parse($conn,$set_stmt); + oci_execute($s1); + echo " Package variable value set to " .$num."\n"; +} + +function drcp_create_package($c) +{ + $create_package_stmt = "create or replace package drcp_test_package as + var int :=0; + procedure p1(var1 int); + function f1 return number; + end;"; + $s1 = oci_parse($c, $create_package_stmt); + oci_execute($s1); + + $package_body = "create or replace package body drcp_test_package as + procedure p1(var1 int) is + begin + var :=var1; + end; + function f1 return number is + begin + return drcp_test_package.var; + end; + end;"; + + $s2 = oci_parse($c, $package_body); + oci_execute($s2); +} + +?> diff --git a/ext/oci8/tests/drcp_newconnect.phpt b/ext/oci8/tests/drcp_newconnect.phpt new file mode 100644 index 0000000000..79718f4ee2 --- /dev/null +++ b/ext/oci8/tests/drcp_newconnect.phpt @@ -0,0 +1,43 @@ +--TEST-- +DRCP: oci_new_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.connection_class=test +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Open two connections with oci_new_connect +// Verify they are different by comparing the resource ids + +var_dump($c1 = oci_new_connect($user,$password,$dbase)); +$rn1 = (int)$c1; + +// Another connection now + +var_dump($c2 = oci_new_connect($user,$password,$dbase)); +$rn2 = (int)$c2; + +// rn1 and rn2 should be different. + +if ($rn1 === $rn2) + echo "First and second connections share a resource: Not OK\n"; +else + echo "First and second connections are different OK\n"; + +// Close the connections +oci_close($c1); +oci_close($c2); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +First and second connections are different OK +Done + diff --git a/ext/oci8/tests/drcp_pconn_close1.phpt b/ext/oci8/tests/drcp_pconn_close1.phpt new file mode 100644 index 0000000000..a9b912b26f --- /dev/null +++ b/ext/oci8/tests/drcp_pconn_close1.phpt @@ -0,0 +1,44 @@ +--TEST-- +DRCP: oci_pconnect() with oci_close() and oci8.old_oci_close_semantics ON +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a persistent connection +// Close the connection +// Open another connection +// With oci_close() being a no-op, the same conneciton will be returned + +echo "This is with a OCI_PCONNECT\n"; +var_dump($conn1 = oci_pconnect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Open another connection + +var_dump($conn2 = oci_pconnect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : OK \n"; +else + echo "Both connections are different : NOT OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +Both connections share a resource : OK +Done diff --git a/ext/oci8/tests/drcp_pconn_close2.phpt b/ext/oci8/tests/drcp_pconn_close2.phpt new file mode 100644 index 0000000000..5fd2c2355f --- /dev/null +++ b/ext/oci8/tests/drcp_pconn_close2.phpt @@ -0,0 +1,46 @@ +--TEST-- +DRCP: oci_pconnect() with oci_close() and oci8.old_oci_close_semantics OFF +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +oci8.connection_class=test +--FILE-- +<?php + +require dirname(__FILE__)."/details.inc"; + +// Test will open a persistent connection +// Close the connection +// Open another connection +// With oci_close() the connection is released to the pool and hence the +// the second connection will be different + + +echo "This is with a OCI_PCONNECT\n"; +var_dump($conn1 = oci_pconnect($user,$password,$dbase)); +$rn1 = (int)$conn1; +oci_close($conn1); + +// Query for the row updated. The new value should be returned + +var_dump($conn2 = oci_pconnect($user,$password,$dbase)); +$rn2 = (int)$conn2; +oci_close($conn2); + +// Compare the resource numbers + +if ($rn1 === $rn2) + echo "Both connections share a resource : NOT OK \n"; +else + echo "Both connections are different : OK \n"; + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_PCONNECT +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +Both connections are different : OK +Done diff --git a/ext/oci8/tests/drcp_privileged.phpt b/ext/oci8/tests/drcp_privileged.phpt new file mode 100644 index 0000000000..9af20625ed --- /dev/null +++ b/ext/oci8/tests/drcp_privileged.phpt @@ -0,0 +1,47 @@ +--TEST-- +DRCP: privileged connect +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die("skip no oci8 extension"); +if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +require(dirname(__FILE__)."/details.inc"); +if (empty($oracle_on_localhost)) die("skip this test is unlikely to work with remote Oracle - unless an Oracle password file has been created"); +?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +// Connecting as SYSDBA or SYSOPER through DRCP will give ORA-1031 + +require dirname(__FILE__)."/details.inc"; +var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSOPER)); +var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSOPER)); +var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA)); +var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSOPER)); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) + +Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) + +Warning: oci_new_connect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) + +Warning: oci_new_connect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) + +Warning: oci_pconnect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) + +Warning: oci_pconnect(): ORA-01031: insufficient privileges in %s on line %d +bool(false) +Done + diff --git a/ext/oci8/tests/drcp_scope1.phpt b/ext/oci8/tests/drcp_scope1.phpt new file mode 100644 index 0000000000..01b0a4271e --- /dev/null +++ b/ext/oci8/tests/drcp_scope1.phpt @@ -0,0 +1,91 @@ +--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_create_table($c); + +// OCI_NEW_CONNECT +$conn_type = 1; +echo "This is with a OCI_NEW_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +// OCI_CONNECT +$conn_type = 2; +echo "\n\nThis is with a OCI_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +//This is the first scope for the script + +function function1($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); +} + +// This is the second scope + +function function2($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); +} + +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_NEW_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR + + +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR +Done diff --git a/ext/oci8/tests/drcp_scope2.phpt b/ext/oci8/tests/drcp_scope2.phpt new file mode 100644 index 0000000000..cb5dcd1ac1 --- /dev/null +++ b/ext/oci8/tests/drcp_scope2.phpt @@ -0,0 +1,90 @@ +--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_create_table($c); + +// OCI_NEW_CONNECT +$conn_type = 1; +echo "This is with a OCI_NEW_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +// OCI_CONNECT +$conn_type = 2; +echo "\n\nThis is with a OCI_CONNECT\n"; +function1($user,$password,$dbase,$conn_type); + +// Should return the OLD value +function2($user,$password,$dbase,$conn_type); + +//This is the first scope for the script + +function function1($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); +} + +// This is the second scope + +function function2($user,$password,$dbase,$conn_type) +{ + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); +} +drcp_drop_table($c); +oci_close($c); + +echo "Done\n"; + +?> +--EXPECTF-- +This is with a OCI_NEW_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR + + +This is with a OCI_CONNECT +resource(%d) of type (oci8 connection) +Update done-- DEPT value has been set to NEWDEPT +resource(%d) of type (oci8 connection) +The value of DEPT for id 105 is HR +Done diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt index a31843cfd0..c9ef4c5387 100644 --- a/ext/oci8/tests/password.phpt +++ b/ext/oci8/tests/password.phpt @@ -1,7 +1,11 @@ --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__)."/details.inc"; +if ($test_drcp) die("skip password change not supported in DRCP Mode"); +?> --FILE-- <?php diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt index be5cb85400..3ee2db5b40 100644 --- a/ext/oci8/tests/password_2.phpt +++ b/ext/oci8/tests/password_2.phpt @@ -5,6 +5,7 @@ oci_password_change() for persistent connections if (!extension_loaded('oci8')) die("skip no oci8 extension"); require(dirname(__FILE__)."/details.inc"); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); +if ($test_drcp) die("skip password change not supported in DRCP Mode"); ?> --FILE-- <?php @@ -31,8 +32,8 @@ 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 */ +preg_match("/resource\(([0-9]*)\) of.*/", $r1, $matches); +$rn1 = $matches[0]; /* resource number */ oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); @@ -43,8 +44,8 @@ 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 */ +preg_match("/resource\(([0-9]*)\) of.*/", $r2, $matches); +$rn2 = $matches[0]; /* resource number */ // Despite using the old password this connect should succeed and return the original resource $c3 = oci_pconnect("testuser", "testuserpwd", $dbase); @@ -53,8 +54,8 @@ 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 */ +preg_match("/resource\(([0-9]*)\) of.*/", $r3, $matches); +$rn3 = $matches[0]; /* resource number */ // Connections should differ if ($rn1 == $rn2) { diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt index a31843cfd0..1de3cb4c96 100644 --- a/ext/oci8/tests/password_new.phpt +++ b/ext/oci8/tests/password_new.phpt @@ -1,7 +1,11 @@ --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__)."/details.inc"; +if ($test_drcp) die("skip password change not supported in DRCP Mode"); +?> --FILE-- <?php diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt index d293fce870..7a2df841e7 100644 --- a/ext/oci8/tests/password_old.phpt +++ b/ext/oci8/tests/password_old.phpt @@ -1,7 +1,11 @@ --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__)."/details.inc"; +if ($test_drcp) die("skip password change not supported in DRCP Mode"); +?> --FILE-- <?php |
