@@ -15,85 +15,7 @@ create or replace package body ut_coverage_proftab is
1515 See the License for the specific language governing permissions and
1616 limitations under the License.
1717 */
18-
19- -- The source query has two important transformations done in it.
20- -- the flag: to_be_skipped ='Y' is set for a line of code that is badly reported by DBMS_PROFILER as executed 0 times.
21- -- This includes lines that are:
22- -- - PACKAGE, PROCEDURE, FUNCTION definition line,
23- -- - BEGIN, END of a block
24- -- Another transformation is adjustment of line number for TRIGGER body.
25- -- DBMS_PROFILER is reporting line numbers for triggers not as defined in DBA_SOURCE, its usign line numbers as defined in DBA_TRIGGERS
26- -- the DBA_TRIGGERS does not contain the trigger specification lines, only lines that define the trigger body.
27- -- the query adjusts the line numbers for triggers by finding first occurrence of begin|declare|compound in the trigger body line.
28- -- The subquery is optimized by:
29- -- - COALESCE function -> it will execute only for TRIGGERS
30- -- - scalar subquery cache -> it will only execute once for one trigger source code.
31- function get_cov_sources_sql(a_coverage_options ut_coverage_options) return varchar2 is
32- l_result varchar2(32767);
33- l_full_name varchar2(100);
34- l_view_name varchar2(200) := ut_metadata.get_dba_view('dba_source');
35- begin
36- if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
37- l_full_name := 'f.file_name';
38- else
39- l_full_name := 'lower(s.owner||''.''||s.name)';
40- end if;
41- l_result := '
42- select full_name, owner, name, line, to_be_skipped, text
43- from (
44- select '||l_full_name||q'[ as full_name,
45- s.owner,
46- s.name,
47- s.line -
48- coalesce(
49- case when type!='TRIGGER' then 0 end,
50- (select min(t.line) - 1
51- from ]'||l_view_name||q'[ t
52- where t.owner = s.owner and t.type = s.type and t.name = s.name
53- and regexp_like( t.text, '[A-Za-z0-9$#_]*(begin|declare|compound).*','i'))
54- ) as line,
55- s.text,
56- case
57- when
58- -- to avoid execution of regexp_like on every line
59- -- first do a rough check for existence of search pattern keyword
60- (lower(s.text) like '%procedure%'
61- or lower(s.text) like '%function%'
62- or lower(s.text) like '%begin%'
63- or lower(s.text) like '%end%'
64- or lower(s.text) like '%package%'
65- ) and
66- regexp_like(
67- s.text,
68- '^([\t ]*(((not)?\s*(overriding|final|instantiable)[\t ]*)*(static|constructor|member)?[\t ]*(procedure|function)|package([\t ]+body)|begin|end([\t ]+\S+)*[ \t]*;))', 'i'
69- )
70- then 'Y'
71- end as to_be_skipped
72- from ]'||l_view_name||q'[ s]';
73-
74- if a_coverage_options.file_mappings is not empty then
75- l_result := l_result || '
76- join table(:file_mappings) f
77- on s.name = f.object_name
78- and s.type = f.object_type
79- and s.owner = f.object_owner
80- where 1 = 1';
81- elsif a_coverage_options.include_objects is not empty then
82- l_result := l_result || '
83- where (s.owner, s.name) in (select il.owner, il.name from table(:include_objects) il)';
84- else
85- l_result := l_result || '
86- where s.owner in (select upper(t.column_value) from table(:l_schema_names) t)';
87- end if;
88- l_result := l_result || q'[
89- and s.type not in ('PACKAGE', 'TYPE', 'JAVA SOURCE')
90- --Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
91- and (s.owner, s.name) not in (select el.owner, el.name from table(:l_skipped_objects) el)
92- )
93- where line > 0]';
94- return l_result;
95- end;
96-
18+
9719 /**
9820 * Public functions
9921 */
@@ -107,7 +29,7 @@ create or replace package body ut_coverage_proftab is
10729 begin
10830
10931 --prepare global temp table with sources
110- ut_coverage.populate_tmp_table(a_coverage_options,get_cov_sources_sql(a_coverage_options));
32+ ut_coverage.populate_tmp_table(a_coverage_options,ut_coverage. get_cov_sources_sql(a_coverage_options,'Y' ));
11133
11234 l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor();
11335 loop
0 commit comments