mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +00:00
2769ae0444
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
249 lines
6.9 KiB
PHP
249 lines
6.9 KiB
PHP
--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
|
|
|