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

Skip to content

Commit a753e66

Browse files
committed
Fixing ORA-600
1 parent 273962b commit a753e66

1 file changed

Lines changed: 80 additions & 43 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,12 @@ create or replace package body ut_suite_cache_manager is
8888
q'[with
8989
suite_items as (
9090
select /*+ cardinality(c 500) */ value(c) as obj
91-
from ut_suite_cache c,
92-
table(:l_schema_paths) sp
93-
where c.object_owner = upper(sp.schema_name)
94-
and sp.suite_path is not null
95-
and (
96-
sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
97-
or
98-
(
99-
c.path||'.' like sp.suite_path||'.%' /*all children and self*/
100-
and c.object_name like nvl(upper(sp.object_name),c.object_name)
101-
and c.name like nvl(upper(sp.procedure_name),c.name)
102-
)
103-
)
104-
union all
105-
select /*+ cardinality(c 500) */ value(c) as obj
106-
from ut_suite_cache c,
107-
table(:l_schema_paths) sp
108-
where c.object_owner = upper(sp.schema_name)
109-
and sp.suite_path is null
110-
and c.object_name like nvl(upper(replace(sp.object_name,'*','%')),c.object_name)
111-
and c.name like nvl(upper(replace(sp.procedure_name,'*','%')),c.name)
112-
),
113-
{:tags:}
91+
from table(:suite_items) c),
11492
suitepaths as (
11593
select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath,
11694
c.obj.path as path,
11795
c.obj.object_owner as object_owner
118-
from {:suite_item_name:} c
96+
from suite_items c
11997
where c.obj.self_type = 'UT_SUITE'
12098
),
12199
gen as (
@@ -152,7 +130,7 @@ create or replace package body ut_suite_cache_manager is
152130
from logical_suite_data s
153131
),
154132
items as (
155-
select obj from {:suite_item_name:}
133+
select obj from suite_items
156134
union all
157135
select obj from logical_suites
158136
)
@@ -404,44 +382,103 @@ create or replace package body ut_suite_cache_manager is
404382
return expand_paths(group_paths_by_schema(a_paths));
405383
end;
406384

385+
function get_suite_items (
386+
a_schema_paths ut_path_items
387+
) return ut_suite_cache_rows is
388+
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
389+
begin
390+
select /*+ cardinality(c 500) */ value(c) as obj
391+
bulk collect into l_suite_items
392+
from ut_suite_cache c,
393+
table(a_schema_paths) sp
394+
where c.object_owner = upper(sp.schema_name)
395+
and (
396+
(sp.suite_path is not null and
397+
sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
398+
or
399+
( c.path||'.' like sp.suite_path||'.%' /*all children and self*/
400+
and c.object_name like nvl(upper(sp.object_name),c.object_name)
401+
and c.name like nvl(upper(sp.procedure_name),c.name) ) )
402+
or
403+
( sp.suite_path is null
404+
and c.object_name like nvl(upper(replace(sp.object_name,'*','%')),c.object_name)
405+
and c.name like nvl(upper(replace(sp.procedure_name,'*','%')),c.name)
406+
));
407+
return l_suite_items;
408+
end;
409+
410+
function get_tags_suites (
411+
a_suite_items ut_suite_cache_rows,
412+
a_tags ut_varchar2_rows
413+
) return ut_suite_cache_rows is
414+
l_suite_tags ut_suite_cache_rows := ut_suite_cache_rows();
415+
l_include_tags ut_varchar2_rows;
416+
l_exclude_tags ut_varchar2_rows;
417+
begin
418+
419+
select /*+ no_parallel */ column_value
420+
bulk collect into l_include_tags
421+
from table(a_tags)
422+
where column_value not like '-%';
423+
424+
select /*+ no_parallel */ ltrim(column_value,'-')
425+
bulk collect into l_exclude_tags
426+
from table(a_tags)
427+
where column_value like '-%';
428+
429+
with included_tags as (
430+
select c.path as path
431+
from table(a_suite_items) c
432+
where c.tags multiset intersect l_include_tags is not empty or l_include_tags is empty
433+
),
434+
excluded_tags as (
435+
select c.path as path
436+
from table(a_suite_items) c
437+
where c.tags multiset intersect l_exclude_tags is not empty
438+
)
439+
select value(c) as obj
440+
bulk collect into l_suite_tags
441+
from table(a_suite_items) c
442+
where exists (
443+
select 1 from included_tags t
444+
where t.path||'.' like c.path || '.%' /*all parents and self*/
445+
or c.path||'.' like t.path || '.%' /*all children and self*/
446+
)
447+
and not exists (
448+
select 1 from excluded_tags t
449+
where c.path||'.' like t.path || '.%' /*all children and self*/
450+
);
451+
return l_suite_tags;
452+
end;
453+
407454
function get_cached_suite_rows(
408455
a_schema_paths ut_path_items,
409456
a_random_seed positive := null,
410457
a_tags ut_varchar2_rows := null
411458
) return ut_suite_cache_rows is
412459
l_results ut_suite_cache_rows := ut_suite_cache_rows();
460+
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
413461
l_schema_paths ut_path_items;
414462
l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
415-
l_include_tags ut_varchar2_rows;
416-
l_exclude_tags ut_varchar2_rows;
463+
417464
l_suite_item_name varchar2(20);
418465
l_paths ut_varchar2_rows;
419466
l_schema varchar2(4000);
420467
l_sql varchar2(32767);
421468
begin
422-
select /*+ no_parallel */ column_value
423-
bulk collect into l_include_tags
424-
from table(l_tags)
425-
where column_value not like '-%';
426-
427-
select /*+ no_parallel */ ltrim(column_value,'-')
428-
bulk collect into l_exclude_tags
429-
from table(l_tags)
430-
where column_value like '-%';
431469

432470
l_schema_paths := a_schema_paths;
433-
--We still need to turn this into qualified SQL name....maybe as part of results ?
434-
l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end;
435-
436471
l_sql := gc_get_bulk_cache_suite_sql;
437-
l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name);
438-
l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count));
439472
l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed));
473+
l_suite_items := get_suite_items(a_schema_paths);
474+
if l_tags.count > 0 then
475+
l_suite_items := get_tags_suites(l_suite_items,l_tags);
476+
end if;
440477
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
441-
478+
442479
execute immediate l_sql
443480
bulk collect into l_results
444-
using l_schema_paths, l_schema_paths, l_include_tags, l_include_tags, l_exclude_tags, a_random_seed;
481+
using l_suite_items, a_random_seed;
445482
return l_results;
446483
end;
447484

0 commit comments

Comments
 (0)