8000 Merge pull request #1160 from utPLSQL/feature/fix_cache_when_parallel… · utPLSQL/utPLSQL@938a06f · GitHub
[go: up one dir, main page]

Skip to content

Commit 938a06f

Browse files
authored
Merge pull request #1160 from utPLSQL/feature/fix_cache_when_parallel_enabled
Feature/fix cache when parallel enabled
2 parents c930ba6 + f35694e commit 938a06f

26 files changed

+137
-135
lines changed

source/api/ut.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ create or replace package body ut is
674674
procedure set_nls is
675675
begin
676676
if g_nls_date_format is null then
677-
select nsp.value
677+
select /*+ no_parallel */ nsp.value
678678
into g_nls_date_format
679679
from nls_session_parameters nsp
680680
where parameter = 'NLS_DATE_FORMAT';

source/check_object_grants.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ begin
2424
l_target_table := get_view('dba_tab_privs');
2525
l_owner_column := case when l_target_table like 'dba%' then 'owner' else 'table_schema' end;
2626
execute immediate q'[
27-
select listagg(' - '||object_name,CHR(10)) within group(order by object_name)
27+
select /*+ no_parallel */ listagg(' - '||object_name,CHR(10)) within group(order by object_name)
2828
from (
2929
select column_value as object_name
3030
from table(:l_expected_grants)

source/core/annotations/ut_annotation_cache_manager.pkb

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,41 @@ create or replace package body ut_annotation_cache_manager as
2121
l_timestamp timestamp := systimestamp;
2222
pragma autonomous_transaction;
2323
begin
24-
update ut_annotation_cache_schema s
24+
update /*+ no_parallel */ ut_annotation_cache_schema s
2525
set s.max_parse_time = l_timestamp
2626
where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner;
2727

2828
if sql%rowcount = 0 then
29-
insert into ut_annotation_cache_schema s
29+
insert /*+ no_parallel */ into ut_annotation_cache_schema s
3030
(object_owner, object_type, max_parse_time)
3131
values (a_object.object_owner, a_object.object_type, l_timestamp);
3232
end if;
3333

3434
-- if not in trigger, or object has annotations
3535
if ora_sysevent is null or a_object.annotations is not null and a_object.annotations.count > 0 then
3636

37-
update ut_annotation_cache_info i
37+
update /*+ no_parallel */ ut_annotation_cache_info i
3838
set i.parse_time = l_timestamp
3939
where (i.object_owner, i.object_name, i.object_type)
4040
in ((a_object.object_owner, a_object.object_name, a_object.object_type))
4141
returning cache_id into l_cache_id;
4242

4343
if sql%rowcount = 0 then
4444

45-
insert into ut_annotation_cache_info
45+
insert /*+ no_parallel */ into ut_annotation_cache_info
4646
(cache_id, object_owner, object_name, object_type, parse_time)
4747
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp)
4848
returning cache_id into l_cache_id;
4949
end if;
5050

5151
end if;
5252

53-
delete from ut_annotation_cache c where cache_id = l_cache_id;
53+
delete /*+ no_parallel */ from ut_annotation_cache c where cache_id = l_cache_id;
5454

5555
if a_object.annotations is not null and a_object.annotations.count > 0 then
56-
insert into ut_annotation_cache
56+
insert /*+ no_parallel */ into ut_annotation_cache
5757
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
58-
select l_cache_id, a.position, a.name, a.text, a.subobject_name
58+
select /*+ no_parallel */ l_cache_id, a.position, a.name, a.text, a.subobject_name
5959
from table(a_object.annotations) a;
6060
end if;
6161
commit;
@@ -67,9 +67,9 @@ create or replace package body ut_annotation_cache_manager as
6767
pragma autonomous_transaction;
6868
begin
6969

70-
delete from ut_annotation_cache c
70+
delete /*+ no_parallel */ from ut_annotation_cache c
7171
where c.cache_id
72-
in (select i.cache_id
72+
in (select /*+ no_parallel */ i.cache_id
7373
from ut_annotation_cache_info i
7474
join table (a_objects) o
7575
on o.object_name = i.object_name
@@ -78,25 +78,26 @@ create or replace package body ut_annotation_cache_manager as
7878
and o.needs_refresh = 'Y'
7979
);
8080

81-
update ut_annotation_cache_schema s
81+
update /*+ no_parallel */ ut_annotation_cache_schema s
8282
set s.max_parse_time = l_timestamp
8383
where (s.object_owner, s.object_type)
8484
in (
85-
select o.object_owner, o.object_type
85+
select /*+ no_parallel */ o.object_owner, o.object_type
8686
from table(a_objects) o
8787
where o.needs_refresh = 'Y'
8888
);
8989

9090
if sql%rowcount = 0 then
91-
insert into ut_annotation_cache_schema s
91+
insert /*+ no_parallel */ into ut_annotation_cache_schema s
9292
(object_owner, object_type, max_parse_time)
93-
select distinct o.object_owner, o.object_type, l_timestamp
93+
select /*+ no_parallel */ distinct o.object_owner, o.object_type, l_timestamp
9494
from table(a_objects) o
9595
where o.needs_refresh = 'Y';
9696
end if;
9797

98-
merge into ut_annotation_cache_info i
99-
using (select o.object_name, o.object_type, o.object_owner
98+
merge /*+ no_parallel */
99+
into ut_annotation_cache_info i
100+
using (select /*+ no_parallel */ o.object_name, o.object_type, o.object_owner
100101
from table(a_objects) o
101102
where o.needs_refresh = 'Y'
102103
) o
@@ -116,7 +117,7 @@ create or replace package body ut_annotation_cache_manager as
116117
function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info is
117118
l_result ut_annotation_objs_cache_info;
118119
begin
119-
select ut_annotation_obj_cache_info(
120+
select /*+ no_parallel */ ut_annotation_obj_cache_info(
120121
object_owner => i.object_owner,
121122
object_name => i.object_name,
122123
object_type => i.object_type,
@@ -135,7 +136,7 @@ create or replace package body ut_annotation_cache_manager as
135136
l_result t_cache_schema_info;
136137
begin
137138
begin
138-
select *
139+
select /*+ no_parallel */ *
139140
into l_result
140141
from ut_annotation_cache_schema s
141142
where s.object_type = a_object_type and s.object_owner = a_object_owner;
@@ -149,7 +150,7 @@ create or replace package body ut_annotation_cache_manager as
149150
procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is
150151
pragma autonomous_transaction;
151152
begin
152-
update ut_annotation_cache_schema s
153+
update /*+ no_parallel */ ut_annotation_cache_schema s
153154
set s.full_refresh_time = s.max_parse_time
154155
where s.object_owner = a_object_owner
155156
and s.object_type = a_object_type;
@@ -160,9 +161,9 @@ create or replace package body ut_annotation_cache_manager as
160161
pragma autonomous_transaction;
161162
begin
162163

163-
delete from ut_annotation_cache_info i
164+
delete /*+ no_parallel */ from ut_annotation_cache_info i
164165
where exists (
165-
select 1 from table (a_objects) o
166+
select /*+ no_parallel */ 1 from table (a_objects) o
166167
where o.object_name = i.object_name
167168
and o.object_type = i.object_type
168169
and o.object_owner = i.object_owner
@@ -175,7 +176,7 @@ create or replace package body ut_annotation_cache_manager as
175176
l_results sys_refcursor;
176177
begin
177178
open l_results for
178-
select ut_annotated_object(
179+
select /*+ no_parallel */ ut_annotated_object(
179180
i.object_owner, i.object_name, i.object_type, i.parse_time,
180181
cast(
181182
collect(
@@ -204,15 +205,15 @@ create or replace package body ut_annotation_cache_manager as
204205
else
205206
l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end;
206207
l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end;
207-
l_cache_filter := ' c.cache_id in (select i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )';
208+
l_cache_filter := ' c.cache_id in (select /*+ no_parallel */ i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )';
208209
end if;
209-
execute immediate 'delete from ut_annotation_cache c where ' || l_cache_filter
210+
execute immediate 'delete /*+ no_parallel */ from ut_annotation_cache c where ' || l_cache_filter
210211
using a_object_owner, a_object_type;
211212

212-
execute immediate ' delete from ut_annotation_cache_info i where ' || l_filter
213+
execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_info i where ' || l_filter
213214
using a_object_owner, a_object_type;
214215

215-
execute immediate ' delete from ut_annotation_cache_schema s where ' || l_filter
216+
execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_schema s where ' || l_filter
216217
using a_object_owner, a_object_type;
217218

218219
commit;

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ create or replace package body ut_annotation_manager as
3434
l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type );
3535

3636
if l_cached_objects is not empty then
37-
execute immediate 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
37+
execute immediate 'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
3838
value(i)
3939
from table( :l_data ) i
4040
where
@@ -71,7 +71,7 @@ create or replace package body ut_annotation_manager as
7171
--limit the list to objects that exist and are visible to the invoking user
7272
--enrich the list by info about cache validity
7373
execute immediate
74-
'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
74+
'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
7575
'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
7676
object_owner => o.owner,
7777
object_name => o.object_name,
@@ -108,7 +108,7 @@ create or replace package body ut_annotation_manager as
108108
begin
109109
l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh));
110110
open l_result for
111-
q'[select x.name, x.text
111+
q'[select /*+ no_parallel */ x.name, x.text
112112
from (select /*+ cardinality( r ]'||l_card||q'[ )*/
113113
s.name, s.text, s.line,
114114
max(case when s.text like '%--%\%%' escape '\'
@@ -252,7 +252,7 @@ create or replace package body ut_annotation_manager as
252252
l_sql_lines := ut_utils.convert_collection( ut_utils.clob_to_table(l_sql_clob) );
253253
end if;
254254
open l_result for
255-
select a_object_name as name, column_value||chr(10) as text from table(l_sql_lines);
255+
select /*+ no_parallel */ a_object_name as name, column_value||chr(10) as text from table(l_sql_lines);
256256
return l_result;
257257
end;
258258

@@ -261,7 +261,7 @@ create or replace package body ut_annotation_manager as
261261
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
262262
begin
263263
open l_result for
264-
q'[select :a_object_name, s.text
264+
q'[select /*+ no_parallel */ :a_object_name, s.text
265265
from ]'||l_sources_view||q'[ s
266266
where s.type = :a_object_type
267267
and s.owner = :a_object_owner
@@ -279,7 +279,7 @@ create or replace package body ut_annotation_manager as
279279
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
280280
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL');
281281
$else
282-
select username bulk collect into l_restricted_users
282+
select /*+ no_parallel */ username bulk collect into l_restricted_users
283283
from all_users where oracle_maintained = 'Y';
284284
$end
285285
if ora_dict_obj_owner member of l_restricted_users then

source/core/annotations/ut_annotation_parser.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ create or replace package body ut_annotation_parser as
210210

211211
dbms_lob.freetemporary(l_source);
212212

213-
select value(x) bulk collect into l_result from table(l_annotations) x order by x.position;
213+
select /*+ no_parallel */ value(x) bulk collect into l_result from table(l_annotations) x order by x.position;
214214

215215
return l_result;
216216
end parse_object_annotations;

source/core/coverage/ut_coverage.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ create or replace package body ut_coverage is
7777
end as to_be_skipped
7878
from sources s
7979
)
80-
select full_name, owner, name, type, line, to_be_skipped, text
80+
select /*+ no_parallel */ full_name, owner, name, type, line, to_be_skipped, text
8181
from coverage_sources s
8282
-- Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
8383
where (s.owner, s.name) not in ( select /*+ cardinality(el {skipped_objects_cardinality})*/el.owner, el.name from table(:l_skipped_objects) el )

source/core/coverage/ut_coverage_helper.pkb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ create or replace package body ut_coverage_helper is
3535
procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows) is
3636
begin
3737
forall i in 1 .. a_data.count
38-
insert into ut_coverage_sources_tmp
38+
insert /*+ no_parallel */ into ut_coverage_sources_tmp
3939
(full_name,owner,name,type,line,text,to_be_skipped)
4040
values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).type,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped);
4141
end;
@@ -49,7 +49,7 @@ create or replace package body ut_coverage_helper is
4949
function is_tmp_table_populated return boolean is
5050
l_result integer;
5151
begin
52-
select 1 into l_result from ut_coverage_sources_tmp where rownum = 1;
52+
select /*+ no_parallel */ 1 into l_result from ut_coverage_sources_tmp where rownum = 1;
5353
return (l_result = 1);
5454
exception
5555
when no_data_found then
@@ -60,7 +60,7 @@ create or replace package body ut_coverage_helper is
6060
l_result t_tmp_table_objects_crsr;
6161
begin
6262
open l_result for
63-
select o.owner, o.name, o.type, o.full_name, max(o.line) as lines_count,
63+
select /*+ no_parallel */ o.owner, o.name, o.type, o.full_name, max(o.line) as lines_count,
6464
cast(
6565
collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list
6666
) as to_be_skipped_list
@@ -73,7 +73,7 @@ create or replace package body ut_coverage_helper is
7373
function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list is
7474
l_result ut_varchar2_list;
7575
begin
76-
select rtrim(s.text,chr(10)) as text
76+
select /*+ no_parallel */ rtrim(s.text,chr(10)) as text
7777
bulk collect into l_result
7878
from ut_coverage_sources_tmp s
7979
where s.owner = a_owner
@@ -86,7 +86,7 @@ create or replace package body ut_coverage_helper is
8686
procedure set_coverage_run_ids( a_coverage_run_id raw, a_line_coverage_id integer, a_block_coverage_id integer ) is
8787
pragma autonomous_transaction;
8888
begin
89-
insert into ut_coverage_runs
89+
insert /*+ no_parallel */ into ut_coverage_runs
9090
( coverage_run_id, line_coverage_id, block_coverage_id )
9191
values
9292
( a_coverage_run_id, a_line_coverage_id, a_block_coverage_id );

source/core/coverage/ut_coverage_helper_block.pkb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ create or replace package body ut_coverage_helper_block is
4646
l_ut_owner varchar2(250) := ut_utils.ut_owner;
4747
begin
4848
execute immediate q'[
49-
select line as line,
49+
select /*+ no_parallel */
50+
line as line,
5051
count(block) as blocks,
5152
sum(covered) as covered_blocks
5253
from (select line,

source/core/coverage/ut_coverage_helper_profiler.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ create or replace package body ut_coverage_helper_profiler is
5858
function proftab_results(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return t_proftab_rows is
5959
l_coverage_rows t_proftab_rows;
6060
begin
61-
select
61+
select /*+ no_parallel */
6262
d.line#,
6363
case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur
6464
bulk collect into l_coverage_rows

source/core/coverage/ut_coverage_reporter_base.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ create or replace type body ut_coverage_reporter_base is
9393
(l_reporter as ut_output_reporter_base).before_calling_run(null);
9494
l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) );
9595
l_reporter.on_finalize(null);
96-
for i in (select x.text from table(l_reporter.get_lines(1, 1)) x ) loop
96+
for i in (select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x ) loop
9797
pipe row (i.text);
9898
end loop;
9999
return;
@@ -107,7 +107,7 @@ create or replace type body ut_coverage_reporter_base is
107107
(l_reporter as ut_output_reporter_base).before_calling_run(null);
108108
l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) );
109109
l_reporter.on_finalize(null);
110-
open l_result for select x.text from table(l_reporter.get_lines(1, 1)) x;
110+
open l_result for select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x;
111111
return l_result;
112112
end;
113113

source/core/output_buffers/ut_output_buffer_base.tpb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ create or replace type body ut_output_buffer_base is
2525
self.output_id := coalesce(a_output_id, self.output_id, sys_guid());
2626
self.start_date := coalesce(self.start_date, sysdate);
2727
self.last_message_id := 0;
28-
select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id;
28+
select /*+ no_parallel */ count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id;
2929
if ( l_exists > 0 ) then
30-
update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id;
30+
update /*+ no_parallel */ ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id;
3131
else
32-
insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date);
32+
insert /*+ no_parallel */ into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date);
3333
end if;
3434
commit;
3535
self.is_closed := 0;
@@ -39,7 +39,7 @@ create or replace type body ut_output_buffer_base is
3939
l_lines sys_refcursor;
4040
begin
4141
open l_lines for
42-
select text, item_type
42+
select /*+ no_parallel */ text, item_type
4343
from table(self.get_lines(a_initial_timeout, a_timeout_sec));
4444
return l_lines;
4545
end;

0 commit comments

Comments
 (0)
0