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

Skip to content

Commit 8f6d6c2

Browse files
committed
Addressed review comments.
Refactored install scripts to avoid duplication. Added check for `oracle_maintained` schema when firing DDL trigger.
1 parent 94a1c23 commit 8f6d6c2

10 files changed

Lines changed: 83 additions & 67 deletions

docs/userguide/advanced_data_comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ Unable to join sets:
430430
Please make sure that your join clause is not refferring to collection element
431431
```
432432

433-
***Note***
433+
**Note**
434434
>`join_by` option is slower to process as it needs to perform a cursor join.
435435
436436
## Defining item lists in option

docs/userguide/install.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,23 @@ The headless scripts accept three optional parameters that define:
8989

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

92-
*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.
93-
94-
*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.
95-
92+
**Note:**
93+
> 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.
94+
95+
**Note:**
96+
> 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.
97+
98+
**Note:**
99+
> When installing with DDL trigger, utPLSQL will not be registering unit tests for any of oracle-maintained schemas.
100+
For Oracle 11g following users are excluded:
101+
> 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
102+
>
103+
> For Oracle 12c and above the users returned by below query are excluded by utPLSQL:
104+
>
105+
>```sql
106+
> select username from all_users where oracle_maintained='Y';
107+
>```
108+
96109
## Installation without DDL trigger
97110
98111
To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql` as SYSDBA.
@@ -125,15 +138,12 @@ cd source
125138
sqlplus sys/sys_pass@db as sysdba @install_headless_with_trigger.sql utp3 my_verySecret_password utp3_tablespace
126139
```
127140

128-
*Note:*
129-
130-
When installing utPLSQL into database with existing unit test packages, utPLSQL will not be able to already-existing unit test packages.
131-
When utPSLQL was installed with DDL trigger, you have to do one of:
132-
- Recompile existing Unit Test packages to make utPLSQL aware of their existence
133-
- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database
134-
135-
Steps above are required to assure annotation cache is populated properly from existing objects.
136-
Rebuilding annotation cache might be faster than code recompilation.
141+
**Note:**
142+
>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:
143+
>- Recompile existing Unit Test packages to make utPLSQL aware of their existence
144+
>- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database
145+
>
146+
> Steps above are required to assure annotation cache is populated properly from existing objects. Rebuilding annotation cache might be faster than code recompilation.
137147
138148
# Recommended Schema
139149
It is highly recommended to install utPLSQL in it's own schema. You are free to choose any name for this schema.
@@ -199,7 +209,8 @@ cd source
199209
sqlplus admin/admins_password@database @install_ddl_trigger.sql ut3
200210
```
201211

202-
*Note:* Trigger can be installed ant any point in time.
212+
**Note:**
213+
>Trigger can be installed ant any point in time.
203214
204215

205216
## Allowing other users to access the utPLSQL framework

source/check_sys_grants.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DEFINE expected_grants = "&1"
1+
define expected_grants = "&1"
22
declare
33
c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray( &expected_grants );
44

source/core/annotations/ut_trigger_annotation_parsing.trg

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
create or replace trigger ut_trigger_annotation_parsing
22
after create or alter or drop
33
on database
4+
declare
5+
l_restricted_users ora_name_list_t;
46
begin
57
if (ora_dict_obj_owner = UPPER('&&UT3_OWNER')
68
and ora_dict_obj_name = 'UT3_TRIGGER_ALIVE'
79
and ora_dict_obj_type = 'SYNONYM')
810
then
911
execute immediate 'begin ut_trigger_check.is_alive(); end;';
10-
elsif ( ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE')
11-
and ora_dict_obj_owner
12-
not in (
13-
'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
14-
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
15-
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL')
16-
and not (ora_dict_obj_type = 'TYPE' and ora_dict_obj_name like 'SYS\_PLSQL\_%' escape '\')
17-
)
18-
then
19-
execute immediate 'begin ut_annotation_manager.trigger_obj_annotation_rebuild; end;';
12+
elsif ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then
13+
$if dbms_db_version.version < 12 $then
14+
l_restricted_users := ora_name_list_t(
15+
'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
16+
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
17+
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL');
18+
$else
19+
select /*+ result_cache */ username bulk collect into l_restricted_users
20+
from all_users where oracle_maintained = 'Y';
21+
$end
22+
if not (ora_dict_obj_type = 'TYPE' and ora_dict_obj_name like 'SYS\_PLSQL\_%' escape '\')
23+
and not ora_dict_obj_owner member of l_restricted_users
24+
then
25+
execute immediate 'begin ut_annotation_manager.trigger_obj_annotation_rebuild; end;';
26+
end if;
2027
end if;
2128
exception
2229
when others then null;

source/core/annotations/ut_trigger_check.pkb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ create or replace package body ut_trigger_check is
1616
limitations under the License.
1717
*/
1818

19+
gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';
1920
g_is_trigger_live boolean := false;
2021

2122
function is_alive return boolean is

source/core/annotations/ut_trigger_check.pks

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ create or replace package ut_trigger_check authid definer is
1616
limitations under the License.
1717
*/
1818

19-
gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';
20-
2119
/**
2220
* checks if the trigger &&UT3_OWNER._PARSE is enabled and operational.
2321
*/
2422
function is_alive return boolean;
2523

2624
/**
27-
* If called from a DDL trigger when creating object gc_check_object_name, sets alive flag to true
28-
* Otherwise sets alive flag to false.
25+
* If called from a DDL trigger sets alive flag to true.
26+
* If called outside of DDL trigger, sets alive flag to false.
2927
*/
3028
procedure is_alive;
3129

source/core/ut_suite_manager.pkb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ create or replace package body ut_suite_manager is
332332
function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows is
333333
l_rows sys_refcursor;
334334
l_ut_owner varchar2(250) := ut_utils.ut_owner;
335-
l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
336335
l_cursor_text varchar2(32767);
337336
l_result ut_varchar2_rows;
338337
l_object_owner varchar2(250);

source/install_headless.sql

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,8 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
17-
set echo off
18-
set verify off
19-
column 1 new_value 1 noprint
20-
column 2 new_value 2 noprint
21-
column 3 new_value 3 noprint
22-
select null as "1", null as "2" , null as "3" from dual where 1=0;
23-
column sep new_value sep noprint
24-
select '--------------------------------------------------------------' as sep from dual;
25-
26-
spool params.sql.tmp
27-
28-
column ut3_owner new_value ut3_owner noprint
29-
column ut3_password new_value ut3_password noprint
30-
column ut3_tablespace new_value ut3_tablespace noprint
31-
32-
select coalesce('&&1','UT3') ut3_owner,
33-
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
34-
coalesce('&&3','users') ut3_tablespace from dual;
3517

18+
@@set_install_params.sql
3619

3720
@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
3821
@@install.sql &&ut3_owner

source/install_headless_with_trigger.sql

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,8 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
17-
set echo off
18-
set verify off
19-
column 1 new_value 1 noprint
20-
column 2 new_value 2 noprint
21-
column 3 new_value 3 noprint
22-
select null as "1", null as "2" , null as "3" from dual where 1=0;
23-
column sep new_value sep noprint
24-
select '--------------------------------------------------------------' as sep from dual;
25-
26-
spool params.sql.tmp
27-
28-
column ut3_owner new_value ut3_owner noprint
29-
column ut3_password new_value ut3_password noprint
30-
column ut3_tablespace new_value ut3_tablespace noprint
31-
32-
select coalesce('&&1','UT3') ut3_owner,
33-
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
34-
coalesce('&&3','users') ut3_tablespace from dual;
3517

18+
@@set_install_params.sql
3619

3720
@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
3821
@@install.sql &&ut3_owner

source/set_install_params.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
utPLSQL - Version 3
3+
Copyright 2016 - 2018 utPLSQL Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"):
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
set echo off
19+
set verify off
20+
column 1 new_value 1 noprint;
21+
column 2 new_value 2 noprint;
22+
column 3 new_value 3 noprint;
23+
select null as "1", null as "2" , null as "3" from dual where 1=0;
24+
column sep new_value sep noprint
25+
select '--------------------------------------------------------------' as sep from dual;
26+
27+
column ut3_owner new_value ut3_owner noprint
28+
column ut3_password new_value ut3_password noprint
29+
column ut3_tablespace new_value ut3_tablespace noprint
30+
31+
select coalesce('&&1','UT3') ut3_owner,
32+
coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password,
33+
coalesce('&&3','users') ut3_tablespace
34+
from dual;

0 commit comments

Comments
 (0)