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

Skip to content

Commit 4737fde

Browse files
committed
Added select with row limit to assure we dont overload memory when reading data on after-run.
1 parent abe6848 commit 4737fde

3 files changed

Lines changed: 45 additions & 12 deletions

File tree

source/core/output_buffers/ut_output_buffer_tmp.sql

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
create table ut_output_buffer_tmp$(
1+
declare
2+
v_table_sql varchar2(32767);
3+
e_non_assm exception;
4+
pragma exception_init(e_non_assm, -43853);
5+
begin
6+
v_table_sql := 'create table ut_output_buffer_tmp$(
27
/*
38
utPLSQL - Version 3
49
Copyright 2016 - 2018 utPLSQL Project
@@ -25,9 +30,18 @@ create table ut_output_buffer_tmp$(
2530
constraint ut_output_buffer_tmp_pk primary key(output_id, message_id),
2631
constraint ut_output_buffer_tmp_ck check(is_finished = 0 and text is not null or is_finished = 1 and text is null),
2732
constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id)
28-
) organization index overflow nologging initrans 100
29-
lob(text) store as securefile ut_output_text(retention none)
30-
;
33+
) organization index overflow nologging initrans 100 ';
34+
begin
35+
execute immediate
36+
v_table_sql || 'lob(text) store as securefile ut_output_text(retention none)';
37+
exception
38+
when e_non_assm then
39+
execute immediate
40+
v_table_sql || 'lob(text) store as basicfile ut_output_text(pctversion 0)';
41+
42+
end;
43+
end;
44+
/
3145

3246
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
3347
declare

source/core/output_buffers/ut_output_table_buffer.tpb

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ create or replace type body ut_output_table_buffer is
8989
lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long
9090
lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec
9191
l_sleep_time number(2,1) := lc_short_sleep_time;
92+
lc_bulk_limit constant integer := 100;
9293

9394
procedure remove_read_data(a_message_ids ut_integer_list) is
9495
pragma autonomous_transaction;
@@ -99,13 +100,26 @@ create or replace type body ut_output_table_buffer is
99100
commit;
100101
end;
101102

102-
begin
103-
loop
104-
select a.message_id, ut_output_data_row(a.text, a.item_type)
103+
procedure remove_buffer_info is
104+
pragma autonomous_transaction;
105+
begin
106+
delete from ut_output_buffer_info_tmp a
107+
where a.output_id = self.output_id;
108+
commit;
109+
end;
110+
111+
begin
112+
while not l_finished loop
113+
with ordered_buffer as (
114+
select a.message_id, ut_output_data_row(a.text, a.item_type)
115+
from ut_output_buffer_tmp a
116+
where a.output_id = self.output_id
117+
order by a.message_id
118+
)
119+
select b.*
105120
bulk collect into l_message_ids, l_buffer_data
106-
from ut_output_buffer_tmp a
107-
where a.output_id = self.output_id
108-
order by a.message_id;
121+
from ordered_buffer b
122+
where rownum <= lc_bulk_limit;
109123

110124
--nothing fetched from output, wait and try again
111125
if l_buffer_data.count = 0 then
@@ -130,7 +144,12 @@ create or replace type body ut_output_table_buffer is
130144
end loop;
131145
end if;
132146
remove_read_data(l_message_ids);
133-
exit when l_already_waited_for >= l_wait_for or l_finished;
147+
if l_finished then
148+
remove_buffer_info();
149+
end if;
150+
if l_already_waited_for >= l_wait_for then
151+
l_finished := true;
152+
end if;
134153
end loop;
135154
return;
136155
end;

test/install_and_run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ cd ..
1313
time utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_STR} \
1414
-source_path=source -owner=ut3 \
1515
-test_path=test -c \
16-
-f=ut_documentation_reporter -o=test_results.log -s \
1716
-f=ut_coverage_sonar_reporter -o=coverage.xml \
1817
-f=ut_coverage_html_reporter -o=coverage.html \
1918
-f=ut_coveralls_reporter -o=coverage.json \
2019
-f=ut_sonar_test_reporter -o=test_results.xml \
2120
-f=ut_junit_reporter -o=junit_test_results.xml \
2221
-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \
22+
-f=ut_documentation_reporter -o=test_results.log -s \
2323
-scc

0 commit comments

Comments
 (0)