Skip to content

Commit 0d8d34d

Browse files
committed
Cleanup Phase1.
1 parent a753e66 commit 0d8d34d

2 files changed

Lines changed: 41 additions & 274 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 28 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -20,70 +20,6 @@ create or replace package body ut_suite_cache_manager is
2020
* Private code
2121
*/
2222

23-
gc_get_cache_suite_sql constant varchar2(32767) :=
24-
q'[with
25-
suite_items as (
26-
select /*+ cardinality(c 500) */ value(c) as obj
27-
from ut_suite_cache c
28-
where 1 = 1
29-
and c.object_owner = :l_object_owner
30-
and ( {:path:}
31-
and {:object_name:}
32-
and {:procedure_name:}
33-
)
34-
)
35-
),
36-
{:tags:}
37-
suitepaths as (
38-
select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath,
39-
c.obj.path as path,
40-
c.obj.object_owner as object_owner
41-
from {:suite_item_name:} c
42-
where c.obj.self_type = 'UT_SUITE'
43-
),
44-
gen as (
45-
select rownum as pos
46-
from xmltable('1 to 20')
47-
),
48-
suitepath_part AS (
49-
select distinct
50-
substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path,
51-
object_owner
52-
from suitepaths b
53-
join gen g
54-
on g.pos <= regexp_count(b.suitepath, '\w+')
55-
),
56-
logical_suite_data as (
57-
select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner,
58-
upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name,
59-
cast(null as ut_executables) as x,
60-
cast(null as ut_varchar2_rows) as y,
61-
cast(null as ut_executable_test) as z
62-
from suitepath_part p
63-
where p.path
64-
not in (select s.path from suitepaths s)
65-
),
66-
logical_suites as (
67-
select ut_suite_cache_row(
68-
null,
69-
s.self_type, s.path, s.object_owner, s.object_name,
70-
s.object_name, null, null, null, null, 0,null,
71-
ut_varchar2_rows(),
72-
s.x, s.x, s.x, s.x, s.x, s.x,
73-
s.y, null, s.z
74-
) as obj
75-
from logical_suite_data s
76-
),
77-
items as (
78-
select obj from {:suite_item_name:}
79-
union all
80-
select obj from logical_suites
81-
)
82-
select /*+ no_parallel */ c.obj
83-
from items c
84-
order by c.obj.object_owner,{:random_seed:}]';
85-
86-
8723
gc_get_bulk_cache_suite_sql constant varchar2(32767) :=
8824
q'[with
8925
suite_items as (
@@ -157,61 +93,6 @@ create or replace package body ut_suite_cache_manager is
15793
return l_result;
15894
end;
15995

160-
161-
function get_path_sql(a_path in varchar2) return varchar2 is
162-
begin
163-
return case when a_path is not null then q'[
164-
:l_path||'.' like c.path || '.%' /*all parents and self*/
165-
or ( c.path||'.' like :l_path || '.%' /*all children and self*/
166-
]'
167-
else ' :l_path is null and ( :l_path is null ' end;
168-
end;
169-
170-
function get_object_name_sql(a_object_name in varchar2) return varchar2 is
171-
begin
172-
return case when a_object_name is not null
173-
then ' c.object_name = :a_object_name '
174-
else ' :a_object_name is null' end;
175-
end;
176-
177-
function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is
178-
begin
179-
return case when a_procedure_name is not null
180-
then ' c.name = :a_procedure_name'
181-
else ' :a_procedure_name is null' end;
182-
end;
183-
184-
function get_tags_sql(a_tags_count in integer) return varchar2 is
185-
begin
186-
return case when a_tags_count > 0 then
187-
q'[included_tags as (
188-
select c.obj.path as path
189-
from suite_items c
190-
where c.obj.tags multiset intersect :a_include_tag_list is not empty or :a_include_tag_list is empty
191-
),
192-
excluded_tags as (
193-
select c.obj.path as path
194-
from suite_items c
195-
where c.obj.tags multiset intersect :a_exclude_tag_list is not empty
196-
),
197-
suite_items_tags as (
198-
select c.*
199-
from suite_items c
200-
where exists (
201-
select 1 from included_tags t
202-
where t.path||'.' like c.obj.path || '.%' /*all parents and self*/
203-
or c.obj.path||'.' like t.path || '.%' /*all children and self*/
204-
)
205-
and not exists (
206-
select 1 from excluded_tags t
207-
where c.obj.path||'.' like t.path || '.%' /*all children and self*/
208-
)
209-
),]'
210-
else
211-
q'[dummy as (select 'x' from dual where :a_include_tag_list is null and :a_include_tag_list is null and :a_exclude_tag_list is null),]'
212-
end;
213-
end;
214-
21596
function get_random_seed_sql(a_random_seed positive) return varchar2 is
21697
begin
21798
return case
@@ -269,70 +150,6 @@ create or replace package body ut_suite_cache_manager is
269150
return l_results;
270151
end;
271152

272-
273-
274-
/*
275-
* Public code
276-
*/
277-
function get_cached_suite_rows(
278-
a_object_owner varchar2,
279-
a_path varchar2 := null,
280-
a_object_name varchar2 := null,
281-
a_procedure_name varchar2 := null,
282-
a_random_seed positive := null,
283-
a_tags ut_varchar2_rows := null
284-
) return ut_suite_cache_rows is
285-
l_path varchar2(4000);
286-
l_results ut_suite_cache_rows := ut_suite_cache_rows();
287-
l_sql varchar2(32767);
288-
l_suite_item_name varchar2(20);
289-
l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
290-
l_include_tags ut_varchar2_rows;
291-
l_exclude_tags ut_varchar2_rows;
292-
l_object_owner varchar2(250) := ut_utils.qualified_sql_name(a_object_owner);
293-
l_object_name varchar2(250) := ut_utils.qualified_sql_name(a_object_name);
294-
l_procedure_name varchar2(250) := ut_utils.qualified_sql_name(a_procedure_name);
295-
begin
296-
297-
select /*+ no_parallel */ column_value
298-
bulk collect into l_include_tags
299-
from table(l_tags)
300-
where column_value not like '-%';
301-
302-
select /*+ no_parallel */ ltrim(column_value,'-')
303-
bulk collect into l_exclude_tags
304-
from table(l_tags)
305-
where column_value like '-%';
306-
307-
if a_path is null and a_object_name is not null then
308-
select /*+ no_parallel */ min(c.path)
309-
into l_path
310-
from ut_suite_cache c
311-
where c.object_owner = upper(l_object_owner)
312-
and c.object_name = upper(l_object_name)
313-
and c.name = nvl(upper(l_procedure_name), c.name);
314-
else
315-
l_path := lower(ut_utils.qualified_sql_name(a_path));
316-
end if;
317-
l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end;
318-
319-
l_sql := gc_get_cache_suite_sql;
320-
l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name);
321-
l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner));
322-
l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path));
323-
l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name));
324-
l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name));
325-
l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count));
326-
l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed));
327-
328-
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
329-
330-
execute immediate l_sql
331-
bulk collect into l_results
332-
using upper(l_object_owner), l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_include_tags, l_include_tags, l_exclude_tags, a_random_seed;
333-
return l_results;
334-
end;
335-
336153
function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
337154
l_schema_paths ut_path_items:= ut_path_items();
338155
begin
@@ -371,17 +188,9 @@ create or replace package body ut_suite_cache_manager is
371188
row_number() over ( partition by schema_name,object_name,procedure_name,suite_path order by 1) r_num
372189
from paths_to_expand)
373190
where r_num = 1 ;
374-
375-
376-
377191
return l_schema_paths;
378192
end;
379-
380-
function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is
381-
begin
382-
return expand_paths(group_paths_by_schema(a_paths));
383-
end;
384-
193+
385194
function get_suite_items (
386195
a_schema_paths ut_path_items
387196
) return ut_suite_cache_rows is
@@ -451,6 +260,33 @@ create or replace package body ut_suite_cache_manager is
451260
return l_suite_tags;
452261
end;
453262

263+
/*
264+
* Public code
265+
*/
266+
267+
function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is
268+
begin
269+
return expand_paths(group_paths_by_schema(a_paths));
270+
end;
271+
272+
function get_cached_suite_rows(
273+
a_object_owner varchar2,
274+
a_path varchar2 := null,
275+
a_object_name varchar2 := null,
276+
a_procedure_name varchar2 := null,
277+
a_random_seed positive := null,
278+
a_tags ut_varchar2_rows := null
279+
) return ut_suite_cache_rows is
280+
l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
281+
l_object_owner varchar2(250) := ut_utils.qualified_sql_name(a_object_owner);
282+
l_object_name varchar2(250) := ut_utils.qualified_sql_name(a_object_name);
283+
l_procedure_name varchar2(250) := ut_utils.qualified_sql_name(a_procedure_name);
284+
l_schema_paths ut_path_items;
285+
begin
286+
l_schema_paths := ut_path_items(ut_path_item(a_object_owner,a_object_name,a_procedure_name,a_path));
287+
return get_cached_suite_rows(l_schema_paths,a_random_seed,l_tags);
288+
end;
289+
454290
function get_cached_suite_rows(
455291
a_schema_paths ut_path_items,
456292
a_random_seed positive := null,

source/core/ut_suite_manager.pkb

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -299,51 +299,14 @@ create or replace package body ut_suite_manager is
299299
close a_suite_data_cursor;
300300
end reconstruct_from_cache;
301301

302-
303-
function get_cached_suite_data(
304-
a_object_owner varchar2,
305-
a_path varchar2 := null,
306-
a_object_name varchar2 := null,
307-
a_procedure_name varchar2 := null,
308-
a_skip_all_objects boolean := false,
309-
a_random_seed positive,
310-
a_tags ut_varchar2_rows := null
311-
) return t_cached_suites_cursor is
312-
l_unfiltered_rows ut_suite_cache_rows;
313-
l_result t_cached_suites_cursor;
314-
begin
315-
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows(
316-
a_object_owner,
317-
a_path,
318-
a_object_name,
319-
a_procedure_name,
320-
a_random_seed,
321-
a_tags
322-
);
323-
if a_skip_all_objects then
324-
open l_result for
325-
select /*+ no_parallel */ c.* from table(l_unfiltered_rows) c;
326-
else
327-
open l_result for
328-
select /*+ no_parallel */ c.* from table(l_unfiltered_rows) c
329-
where exists
330-
( select 1
331-
from all_objects a
332-
where a.object_name = c.object_name
333-
and a.owner = c.object_owner
334-
and a.object_type = 'PACKAGE'
335-
)
336-
or c.self_type = 'UT_LOGICAL_SUITE';
337-
end if;
338-
339-
return l_result;
340-
end;
341-
342-
function get_filtered_cursor(a_unfiltered_rows in ut_suite_cache_rows)
302+
function get_filtered_cursor(
303+
a_unfiltered_rows in ut_suite_cache_rows,
304+
a_skip_all_objects boolean := false
305+
)
343306
return ut_suite_cache_rows is
344307
l_result ut_suite_cache_rows := ut_suite_cache_rows();
345308
begin
346-
if ut_metadata.user_has_execute_any_proc() then
309+
if ut_metadata.user_has_execute_any_proc() or a_skip_all_objects then
347310
l_result := a_unfiltered_rows;
348311
else
349312
for i in (
@@ -397,7 +360,8 @@ create or replace package body ut_suite_manager is
397360
function get_cached_suite_data(
398361
a_schema_paths ut_path_items,
399362
a_random_seed positive,
400-
a_tags ut_varchar2_rows := null
363+
a_tags ut_varchar2_rows := null,
364+
a_skip_all_objects boolean := false
401365
) return t_cached_suites_cursor is
402366
l_unfiltered_rows ut_suite_cache_rows;
403367
l_filtered_rows ut_suite_cache_rows;
@@ -409,7 +373,7 @@ create or replace package body ut_suite_manager is
409373
a_tags
410374
);
411375

412-
l_filtered_rows := get_filtered_cursor(l_unfiltered_rows);
376+
l_filtered_rows := get_filtered_cursor(l_unfiltered_rows,a_skip_all_objects);
413377
reconcile_paths_and_suites(a_schema_paths,l_filtered_rows);
414378

415379
open l_result for
@@ -519,19 +483,17 @@ create or replace package body ut_suite_manager is
519483
a_skip_all_objects boolean := false
520484
) return ut_suite_items is
521485
l_suites ut_suite_items := ut_suite_items();
486+
l_schema_paths ut_path_items;
522487
begin
523488
build_and_cache_suites(a_owner_name, a_annotated_objects);
524-
489+
l_schema_paths := ut_path_items(ut_path_item(a_owner_name,a_object_name,a_procedure_name,a_path));
525490
reconstruct_from_cache(
526491
l_suites,
527492
get_cached_suite_data(
528-
a_owner_name,
529-
a_path,
530-
a_object_name,
531-
a_procedure_name,
532-
a_skip_all_objects,
493+
l_schema_paths,
533494
null,
534-
null
495+
null,
496+
a_skip_all_objects
535497
)
536498
);
537499
return l_suites;
@@ -596,37 +558,6 @@ create or replace package body ut_suite_manager is
596558
a_tags
597559
);
598560

599-
/*
600-
l_schema := l_schema_paths.first;
601-
while l_schema is not null loop
602-
l_path_items := l_schema_paths(l_schema);
603-
for i in 1 .. l_path_items.count loop
604-
l_path_item := l_path_items(i);
605-
add_suites_for_path(
606-
upper(l_schema),
607-
l_path_item.suite_path,
608-
l_path_item.object_name,
609-
l_path_item.procedure_name,
610-
a_suites,
611-
a_random_seed,
612-
a_tags
613-
);
614-
if a_suites.count = l_suites_count then
615-
if l_path_item.suite_path is not null then
616-
raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||l_schema||':'||l_path_item.suite_path|| '.');
617-
elsif l_path_item.procedure_name is not null then
618-
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||l_schema||'.'||l_path_item.object_name|| '.'||l_path_item.procedure_name||' does not exist');
619-
elsif l_path_item.object_name is not null then
620-
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_path_item.object_name|| ' does not exist');
621-
end if;
622-
end if;
623-
l_index := a_suites.first;
624-
l_suites_count := a_suites.count;
625-
end loop;
626-
l_schema := l_schema_paths.next(l_schema);
627-
end loop;*/
628-
629-
630561
--propagate rollback type to suite items after organizing suites into hierarchy
631562
for i in 1 .. a_suites.count loop
632563
a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() );

0 commit comments

Comments
 (0)