Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressed review comments.
Refactored install scripts to avoid duplication.
Added check for `oracle_maintained` schema when firing DDL trigger.
  • Loading branch information
jgebal committed Jun 9, 2019
commit 8f6d6c20bf070dac879a65a41cf3f60397124eb4
2 changes: 1 addition & 1 deletion docs/userguide/advanced_data_comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ Unable to join sets:
Please make sure that your join clause is not refferring to collection element
```

***Note***
**Note**
>`join_by` option is slower to process as it needs to perform a cursor join.

## Defining item lists in option
Expand Down
39 changes: 25 additions & 14 deletions docs/userguide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,23 @@ The headless scripts accept three optional parameters that define:

The scripts need to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages.

*Note:* Grant on `DBMS_LOCK` is required only for installation on Oracle versions below 18c. For versions 18c and above, utPLSQL uses `DBMS_SESSION.SLEEP` so access to `DBMS_LOCK` package is no longer needed.

*Note:* The user performing the installation must have the `ADMINISTER DATABASE TRIGGER` privilege. This is required for installation of trigger that is responsible for parsing annotations at at compile-time of a package.

**Note:**
> Grant on `DBMS_LOCK` is required only for installation on Oracle versions below 18c. For versions 18c and above, utPLSQL uses `DBMS_SESSION.SLEEP` so access to `DBMS_LOCK` package is no longer needed.

**Note:**
> The user performing the installation must have the `ADMINISTER DATABASE TRIGGER` privilege. This is required for installation of trigger that is responsible for parsing annotations at at compile-time of a package.

**Note:**
> When installing with DDL trigger, utPLSQL will not be registering unit tests for any of oracle-maintained schemas.
For Oracle 11g following users are excluded:
> ANONYMOUS, APPQOSSYS, AUDSYS, DBSFWUSER, DBSNMP, DIP, GGSYS, GSMADMIN_INTERNAL, GSMCATUSER, GSMUSER, ORACLE_OCM, OUTLN, REMOTE_SCHEDULER_AGENT, SYS, SYS$UMF, SYSBACKUP, SYSDG, SYSKM, SYSRAC, SYSTEM, WMSYS, XDB, XS$NULL
>
> For Oracle 12c and above the users returned by below query are excluded by utPLSQL:
>
>```sql
> select username from all_users where oracle_maintained='Y';
>```

## Installation without DDL trigger

To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql` as SYSDBA.
Expand Down Expand Up @@ -125,15 +138,12 @@ cd source
sqlplus sys/sys_pass@db as sysdba @install_headless_with_trigger.sql utp3 my_verySecret_password utp3_tablespace
```

*Note:*

When installing utPLSQL into database with existing unit test packages, utPLSQL will not be able to already-existing unit test packages.
When utPSLQL was installed with DDL trigger, you have to do one of:
- Recompile existing Unit Test packages to make utPLSQL aware of their existence
- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database

Steps above are required to assure annotation cache is populated properly from existing objects.
Rebuilding annotation cache might be faster than code recompilation.
**Note:**
>When installing utPLSQL into database with existing unit test packages, utPLSQL will not be able to already-existing unit test packages. When utPSLQL was installed with DDL trigger, you have to do one of:
>- Recompile existing Unit Test packages to make utPLSQL aware of their existence
>- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database
>
> Steps above are required to assure annotation cache is populated properly from existing objects. Rebuilding annotation cache might be faster than code recompilation.

# Recommended Schema
It is highly recommended to install utPLSQL in it's own schema. You are free to choose any name for this schema.
Expand Down Expand Up @@ -199,7 +209,8 @@ cd source
sqlplus admin/admins_password@database @install_ddl_trigger.sql ut3
```

*Note:* Trigger can be installed ant any point in time.
**Note:**
>Trigger can be installed ant any point in time.


## Allowing other users to access the utPLSQL framework
Expand Down
2 changes: 1 addition & 1 deletion source/check_sys_grants.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEFINE expected_grants = "&1"
define expected_grants = "&1"
declare
c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray( &expected_grants );

Expand Down
27 changes: 17 additions & 10 deletions source/core/annotations/ut_trigger_annotation_parsing.trg
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
create or replace trigger ut_trigger_annotation_parsing
after create or alter or drop
on database
declare
l_restricted_users ora_name_list_t;
begin
if (ora_dict_obj_owner = UPPER('&&UT3_OWNER')
and ora_dict_obj_name = 'UT3_TRIGGER_ALIVE'
and ora_dict_obj_type = 'SYNONYM')
then
execute immediate 'begin ut_trigger_check.is_alive(); end;';
elsif ( ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE')
and ora_dict_obj_owner
not in (
'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL')
and not (ora_dict_obj_type = 'TYPE' and ora_dict_obj_name like 'SYS\_PLSQL\_%' escape '\')
)
then
execute immediate 'begin ut_annotation_manager.trigger_obj_annotation_rebuild; end;';
elsif ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then
$if dbms_db_version.version < 12 $then
l_restricted_users := ora_name_list_t(
'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL');
$else
select /*+ result_cache */ username bulk collect into l_restricted_users
from all_users where oracle_maintained = 'Y';
$end
if not (ora_dict_obj_type = 'TYPE' and ora_dict_obj_name like 'SYS\_PLSQL\_%' escape '\')
and not ora_dict_obj_owner member of l_restricted_users
then
execute immediate 'begin ut_annotation_manager.trigger_obj_annotation_rebuild; end;';
end if;
end if;
exception
when others then null;
Expand Down
1 change: 1 addition & 0 deletions source/core/annotations/ut_trigger_check.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ create or replace package body ut_trigger_check is
limitations under the License.
*/

gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';
g_is_trigger_live boolean := false;

function is_alive return boolean is
Expand Down
6 changes: 2 additions & 4 deletions source/core/annotations/ut_trigger_check.pks
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ create or replace package ut_trigger_check authid definer is
limitations under the License.
*/

gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';

/**
* checks if the trigger &&UT3_OWNER._PARSE is enabled and operational.
*/
function is_alive return boolean;

/**
* If called from a DDL trigger when creating object gc_check_object_name, sets alive flag to true
* Otherwise sets alive flag to false.
* If called from a DDL trigger sets alive flag to true.
* If called outside of DDL trigger, sets alive flag to false.
*/
procedure is_alive;

Expand Down
1 change: 0 additions & 1 deletion source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ create or replace package body ut_suite_manager is
function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows is
l_rows sys_refcursor;
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
l_cursor_text varchar2(32767);
l_result ut_varchar2_rows;
l_object_owner varchar2(250);
Expand Down
19 changes: 1 addition & 18 deletions source/install_headless.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
set echo off
set verify off
column 1 new_value 1 noprint
column 2 new_value 2 noprint
column 3 new_value 3 noprint
select null as "1", null as "2" , null as "3" from dual where 1=0;
column sep new_value sep noprint
select '--------------------------------------------------------------' as sep from dual;

spool params.sql.tmp

column ut3_owner new_value ut3_owner noprint
column ut3_password new_value ut3_password noprint
column ut3_tablespace new_value ut3_tablespace noprint

select coalesce('&&1','UT3') ut3_owner,
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
coalesce('&&3','users') ut3_tablespace from dual;

@@set_install_params.sql

@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
@@install.sql &&ut3_owner
Expand Down
19 changes: 1 addition & 18 deletions source/install_headless_with_trigger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
set echo off
set verify off
column 1 new_value 1 noprint
column 2 new_value 2 noprint
column 3 new_value 3 noprint
select null as "1", null as "2" , null as "3" from dual where 1=0;
column sep new_value sep noprint
select '--------------------------------------------------------------' as sep from dual;

spool params.sql.tmp

column ut3_owner new_value ut3_owner noprint
column ut3_password new_value ut3_password noprint
column ut3_tablespace new_value ut3_tablespace noprint

select coalesce('&&1','UT3') ut3_owner,
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
coalesce('&&3','users') ut3_tablespace from dual;

@@set_install_params.sql

@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
@@install.sql &&ut3_owner
Expand Down
34 changes: 34 additions & 0 deletions source/set_install_params.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
utPLSQL - Version 3
Copyright 2016 - 2018 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

set echo off
set verify off
column 1 new_value 1 noprint;
column 2 new_value 2 noprint;
column 3 new_value 3 noprint;
select null as "1", null as "2" , null as "3" from dual where 1=0;
column sep new_value sep noprint
select '--------------------------------------------------------------' as sep from dual;

column ut3_owner new_value ut3_owner noprint
column ut3_password new_value ut3_password noprint
column ut3_tablespace new_value ut3_tablespace noprint

select coalesce('&&1','UT3') ut3_owner,
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
coalesce('&&3','users') ut3_tablespace
from dual;