php-src/ext/oci8/tests/edition_1.phpt
Christopher Jones 2769ae0444 1. Introduce connection attribute functions:
oci_set_module_name
         oci_set_action
         oci_set_client_info
         oci_set_client_identifier
      
       These functions set values that are visible and used by the
       database.  They aid tracing, authentication and auditing.

    2. Introduce connection attribute function:

         oci_set_edition

       Oracle 11g R2 "editions" allow multiple versions of DB objects
       to exist at one time.  By setting different editions, two
       different versions of an application can run concurrently,
       making upgrades or A/B testing easier.

    3. Introduce OCI_NO_AUTO_COMMIT as an alias for the OCI_DEFAULT
       constant (which is not the default value) used by oci_execute().

    4. Allow the oci_set_prefetch value to be 0.  This is important in
       some cases using REF CURSORS in Oracle 11gR2.

    5. Set the DRIVER_NAME attribute of Oracle Database 11gR2
       connections to aid application tracing.  The value used is to
       "PHP OCI8" followed by the OCI8 version number.  Note the
       version number may get truncated in DB views such as
       v$session_connect_info.

    6. Generate an error if an invalid resource type is used in
       oci_bind_by_name

[DOC] Documentation will be added for the changes
2009-10-06 22:36:32 +00:00

157 lines
3.8 KiB
PHP

--TEST--
Basic test for setting Oracle 11gR2 "edition" attribute
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
require(dirname(__FILE__)."/connect.inc");
if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
die("skip needs to be run as a DBA user");
if ($test_drcp)
die("skip as Output might vary with DRCP");
$sv = oci_server_version($c);
$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
if ($sv == 1) {
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_clean();
$iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
if ($iv != 1) {
die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
}
}
else {
die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
}
?>
--FILE--
<?php
/* In 11.2, there can only be one child edition. So this test will
* fail to create the necessary editions if a child edition exists
* already
*/
require(dirname(__FILE__)."/conn_attr.inc");
function select_fn($conn) {
$s = oci_parse($conn,"select * from view_ed");
oci_execute($s);
while ($row = oci_fetch_row($s)) {
var_dump($row);
}
}
/* Create a editon MYEDITION
create a view view_ed in MYEDITION1.
create the same view 'view_ed' with a different definition in MYEDITION.
select from both the editions and verify the contents. */
set_edit_attr('MYEDITION');
$conn = oci_connect('testuser','testuser',$dbase);
if ($conn === false) {
$m = oci_error();
die("Error:" . $m['message']);
}
$stmtarray = array(
"drop table edit_tab",
"create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)",
"insert into edit_tab values('mike',30,'Senior engineer',200)",
"insert into edit_tab values('juan',25,'engineer',100)",
"create or replace editioning view view_ed as select name,age,job from edit_tab",
);
foreach ($stmtarray as $stmt) {
$s = oci_parse($conn, $stmt);
@oci_execute($s);
}
// Check the current edition of the DB and the contents of view_ed.
get_edit_attr($conn);
select_fn($conn);
// Create a different version of view_ed in MYEDITION1.
set_edit_attr('MYEDITION1');
$conn2 = oci_new_connect('testuser','testuser',$dbase);
$stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab";
$s = oci_parse($conn2, $stmt);
oci_execute($s);
// Check the current edition of the DB and the contents of view_ed.
get_edit_attr($conn2);
select_fn($conn2);
// Verify the contents in MYEDITION EDITION.
echo "version of view_ed in MYEDITION \n";
get_edit_attr($conn);
select_fn($conn);
clean_up($c);
oci_close($conn);
oci_close($conn2);
echo "Done\n";
?>
--EXPECTF--
The value of edition has been successfully set
The value of current EDITION is MYEDITION
array(3) {
[0]=>
%unicode|string%(%d) "mike"
[1]=>
%unicode|string%(%d) "30"
[2]=>
%unicode|string%(%d) "Senior engineer"
}
array(3) {
[0]=>
%unicode|string%(%d) "juan"
[1]=>
%unicode|string%(%d) "25"
[2]=>
%unicode|string%(%d) "engineer"
}
The value of edition has been successfully set
The value of current EDITION is MYEDITION1
array(4) {
[0]=>
%unicode|string%(%d) "mike"
[1]=>
%unicode|string%(%d) "30"
[2]=>
%unicode|string%(%d) "Senior engineer"
[3]=>
%unicode|string%(%d) "200"
}
array(4) {
[0]=>
%unicode|string%(%d) "juan"
[1]=>
%unicode|string%(%d) "25"
[2]=>
%unicode|string%(%d) "engineer"
[3]=>
%unicode|string%(%d) "100"
}
version of view_ed in MYEDITION
The value of current EDITION is MYEDITION
array(3) {
[0]=>
%unicode|string%(%d) "mike"
[1]=>
%unicode|string%(%d) "30"
[2]=>
%unicode|string%(%d) "Senior engineer"
}
array(3) {
[0]=>
%unicode|string%(%d) "juan"
[1]=>
%unicode|string%(%d) "25"
[2]=>
%unicode|string%(%d) "engineer"
}
Done