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

Skip to content

Commit 2db8d63

Browse files
committed
Addressing issue with reconstruct_cache knocking off other levels.
Solution was to introduce a sort order that work from bottom to top.
1 parent d5ee6ca commit 2db8d63

1 file changed

Lines changed: 44 additions & 10 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,10 @@ create or replace package body ut_suite_cache_manager is
6464
s.y, null, s.z
6565
) as obj
6666
from logical_suite_data s
67-
),
68-
items as (
69-
select obj from suite_items
70-
union all
71-
select obj from logical_suites
7267
)
73-
select /*+ no_parallel */ c.obj
74-
from items c
75-
order by c.obj.object_owner,{:random_seed:}]';
68+
select /*+ no_parallel */obj from suite_items
69+
union all
70+
select /*+ no_parallel */ obj from logical_suites]';
7671

7772
function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is
7873
l_result ut_varchar2_rows;
@@ -293,6 +288,43 @@ create or replace package body ut_suite_cache_manager is
293288
return l_suite_tags;
294289
end;
295290

291+
/*
292+
We will sort a suites in hierarchical structure.
293+
Sorting from bottom to top so when we consolidate
294+
we will go in proper order.
295+
For random seed we will add an extra sort that can be null
296+
*/
297+
procedure sort_and_randomize_tests(
298+
a_suite_rows in out ut_suite_cache_rows,
299+
a_random_seed positive := null)
300+
is
301+
l_suite_rows ut_suite_cache_rows;
302+
begin
303+
with
304+
extract_parent_child as (
305+
select s.path, substr(s.path,1,instr(s.path,'.',-1,1)-1) as parent_path,s.object_owner,s.line_no,a_random_seed random_seed
306+
from table(a_suite_rows) s),
307+
t1(path,parent_path,object_owner,line_no,random_seed) as (
308+
--Anchor memeber
309+
select s.path, parent_path,s.object_owner,s.line_no,random_seed
310+
from extract_parent_child s
311+
where parent_path is null
312+
union all
313+
--Recursive member
314+
select t2.path, t2.parent_path,t2.object_owner,t2.line_no,t2.random_seed
315+
from t1,extract_parent_child t2
316+
where t2.parent_path = t1.path
317+
and t1.object_owner = t2.object_owner)
318+
search depth first by line_no desc,random_seed set order1
319+
select value(i) as obj
320+
bulk collect into l_suite_rows
321+
from t1 c
322+
join table(a_suite_rows) i on i.object_owner = c.object_owner and i.path = c.path
323+
order by order1 desc;
324+
325+
a_suite_rows := l_suite_rows;
326+
end;
327+
296328
/*
297329
* Public code
298330
*/
@@ -308,6 +340,7 @@ create or replace package body ut_suite_cache_manager is
308340
a_tags ut_varchar2_rows := null
309341
) return ut_suite_cache_rows is
310342
l_results ut_suite_cache_rows := ut_suite_cache_rows();
343+
l_results2 ut_suite_cache_rows := ut_suite_cache_rows();
311344
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
312345
l_schema_paths ut_path_items;
313346
l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
@@ -316,7 +349,6 @@ create or replace package body ut_suite_cache_manager is
316349

317350
l_schema_paths := a_schema_paths;
318351
l_sql := gc_get_bulk_cache_suite_sql;
319-
l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed));
320352
l_suite_items := get_suite_items(a_schema_paths);
321353
if l_tags.count > 0 then
322354
l_suite_items := get_tags_suites(l_suite_items,l_tags);
@@ -325,7 +357,9 @@ create or replace package body ut_suite_cache_manager is
325357

326358
execute immediate l_sql
327359
bulk collect into l_results
328-
using l_suite_items, a_random_seed;
360+
using l_suite_items;
361+
362+
sort_and_randomize_tests(l_results,a_random_seed);
329363
return l_results;
330364
end;
331365

0 commit comments

Comments
 (0)