Skip to content

Commit 5f07682

Browse files
committed
Fixed output_buffer purging error.
Resolves #934
1 parent 75d2053 commit 5f07682

15 files changed

+165
-344
lines changed

source/core/coverage/ut_coverage_helper.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ create or replace package body ut_coverage_helper is
4444
pragma autonomous_transaction;
4545
begin
4646
null;
47-
execute immediate 'truncate table ut_coverage_sources_tmp$';
47+
execute immediate 'truncate table ut_coverage_sources_tmp';
4848
commit;
4949
end;
5050

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create global temporary table ut_coverage_sources_tmp$(
1+
create global temporary table ut_coverage_sources_tmp(
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2018 utPLSQL Project
@@ -21,46 +21,5 @@ create global temporary table ut_coverage_sources_tmp$(
2121
constraint ut_coverage_sources_tmp_pk primary key (owner,name,line)
2222
) on commit preserve rows;
2323

24-
create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line);
25-
26-
declare
27-
ex_nonedition_user exception;
28-
ex_view_doesnt_exist exception;
29-
pragma exception_init(ex_nonedition_user,-42314);
30-
pragma exception_init(ex_view_doesnt_exist,-942);
31-
v_view_source varchar2(32767);
32-
begin
33-
begin
34-
execute immediate 'drop view ut_coverage_sources_tmp';
35-
exception
36-
when ex_view_doesnt_exist then
37-
null;
38-
end;
39-
v_view_source := ' ut_coverage_sources_tmp as
40-
/*
41-
utPLSQL - Version 3
42-
Copyright 2016 - 2018 utPLSQL Project
43-
Licensed under the Apache License, Version 2.0 (the "License"):
44-
you may not use this file except in compliance with the License.
45-
You may obtain a copy of the License at
46-
http://www.apache.org/licenses/LICENSE-2.0
47-
Unless required by applicable law or agreed to in writing, software
48-
distributed under the License is distributed on an "AS IS" BASIS,
49-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50-
See the License for the specific language governing permissions and
51-
limitations under the License.
52-
*/
53-
select full_name
54-
,owner
55-
,name
56-
,line
57-
,to_be_skipped
58-
,text
59-
from ut_coverage_sources_tmp$';
60-
61-
execute immediate 'create or replace editioning view '||v_view_source;
62-
exception
63-
when ex_nonedition_user then
64-
execute immediate 'create or replace view '||v_view_source;
65-
end;
66-
/
24+
--is this needed?
25+
--create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
create or replace type body ut_output_buffer_base is
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is
20+
pragma autonomous_transaction;
21+
l_exists int;
22+
begin
23+
cleanup_buffer();
24+
self.self_type := coalesce(a_self_type,self.self_type);
25+
self.output_id := coalesce(a_output_id, self.output_id, sys_guid());
26+
self.start_date := coalesce(self.start_date, sysdate);
27+
self.last_message_id := 0;
28+
select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id;
29+
if ( l_exists > 0 ) then
30+
update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id;
31+
else
32+
insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date);
33+
end if;
34+
commit;
35+
self.is_closed := 0;
36+
end;
37+
38+
member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is
39+
l_lines sys_refcursor;
40+
begin
41+
open l_lines for
42+
select text, item_type
43+
from table(self.get_lines(a_initial_timeout, a_timeout_sec));
44+
return l_lines;
45+
end;
46+
47+
member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is
48+
l_data sys_refcursor;
49+
l_clob clob;
50+
l_item_type varchar2(32767);
51+
l_lines ut_varchar2_list;
52+
begin
53+
l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec);
54+
loop
55+
fetch l_data into l_clob, l_item_type;
56+
exit when l_data%notfound;
57+
l_lines := ut_utils.clob_to_table(l_clob);
58+
for i in 1 .. l_lines.count loop
59+
dbms_output.put_line(l_lines(i));
60+
end loop;
61+
end loop;
62+
close l_data;
63+
end;
64+
65+
member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is
66+
gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours
67+
l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24);
68+
l_max_retention_date date := sysdate - l_retention_days;
69+
pragma autonomous_transaction;
70+
begin
71+
delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date;
72+
commit;
73+
end;
74+
75+
end;
76+
/

source/core/output_buffers/ut_output_buffer_base.tps

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace type ut_output_buffer_base authid definer as object(
1+
create or replace type ut_output_buffer_base force authid definer as object(
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2018 utPLSQL Project
@@ -17,13 +17,18 @@ create or replace type ut_output_buffer_base authid definer as object(
1717
*/
1818

1919
output_id raw(32),
20-
member procedure init(self in out nocopy ut_output_buffer_base),
20+
is_closed number(1,0),
21+
start_date date,
22+
last_message_id number(38,0),
23+
self_type varchar2(250 byte),
24+
member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null),
25+
member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor,
26+
member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null),
27+
member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null),
2128
not instantiable member procedure close(self in out nocopy ut_output_buffer_base),
2229
not instantiable member procedure send_line(self in out nocopy ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null),
2330
not instantiable member procedure send_lines(self in out nocopy ut_output_buffer_base, a_text_list ut_varchar2_rows, a_item_type varchar2 := null),
2431
not instantiable member procedure send_clob(self in out nocopy ut_output_buffer_base, a_text clob, a_item_type varchar2 := null),
25-
not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined,
26-
not instantiable member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor,
27-
not instantiable member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null)
32+
not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined
2833
) not final not instantiable
2934
/
Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table ut_output_buffer_info_tmp$(
1+
create table ut_output_buffer_info_tmp(
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2018 utPLSQL Project
@@ -23,41 +23,3 @@ create table ut_output_buffer_info_tmp$(
2323
) organization index nologging initrans 10
2424
;
2525

26-
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
27-
declare
28-
ex_nonedition_user exception;
29-
ex_view_doesnt_exist exception;
30-
pragma exception_init(ex_nonedition_user,-42314);
31-
pragma exception_init(ex_view_doesnt_exist,-942);
32-
v_view_source varchar2(32767);
33-
begin
34-
begin
35-
execute immediate 'drop view ut_output_buffer_info_tmp';
36-
exception
37-
when ex_view_doesnt_exist then
38-
null;
39-
end;
40-
v_view_source := ' ut_output_buffer_info_tmp as
41-
/*
42-
utPLSQL - Version 3
43-
Copyright 2016 - 2018 utPLSQL Project
44-
Licensed under the Apache License, Version 2.0 (the "License"):
45-
you may not use this file except in compliance with the License.
46-
You may obtain a copy of the License at
47-
http://www.apache.org/licenses/LICENSE-2.0
48-
Unless required by applicable law or agreed to in writing, software
49-
distributed under the License is distributed on an "AS IS" BASIS,
50-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51-
See the License for the specific language governing permissions and
52-
limitations under the License.
53-
*/
54-
select output_id
55-
,start_date
56-
from ut_output_buffer_info_tmp$';
57-
58-
execute immediate 'create or replace editioning view '||v_view_source;
59-
exception
60-
when ex_nonedition_user then
61-
execute immediate 'create or replace view '||v_view_source;
62-
end;
63-
/
Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
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$(
1+
create table ut_output_buffer_tmp(
72
/*
83
utPLSQL - Version 3
94
Copyright 2016 - 2018 utPLSQL Project
@@ -31,52 +26,7 @@ begin
3126
constraint ut_output_buffer_tmp_ck check(
3227
is_finished = 0 and (text is not null or item_type is not null )
3328
or is_finished = 1 and text is null and item_type is null ),
34-
constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id)
29+
constraint ut_output_buffer_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade
3530
) organization index nologging initrans 100
36-
overflow nologging initrans 100
37-
';
38-
execute immediate v_table_sql;
39-
end;
40-
/
31+
overflow nologging initrans 100;
4132

42-
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
43-
declare
44-
ex_nonedition_user exception;
45-
ex_view_doesnt_exist exception;
46-
pragma exception_init(ex_nonedition_user,-42314);
47-
pragma exception_init(ex_view_doesnt_exist,-942);
48-
v_view_source varchar2(32767);
49-
begin
50-
begin
51-
execute immediate 'drop view ut_output_buffer_tmp';
52-
exception
53-
when ex_view_doesnt_exist then
54-
null;
55-
end;
56-
v_view_source := ' ut_output_buffer_tmp as
57-
/*
58-
utPLSQL - Version 3
59-
Copyright 2016 - 2018 utPLSQL Project
60-
Licensed under the Apache License, Version 2.0 (the "License"):
61-
you may not use this file except in compliance with the License.
62-
You may obtain a copy of the License at
63-
http://www.apache.org/licenses/LICENSE-2.0
64-
Unless required by applicable law or agreed to in writing, software
65-
distributed under the License is distributed on an "AS IS" BASIS,
66-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67-
See the License for the specific language governing permissions and
68-
limitations under the License.
69-
*/
70-
select output_id
71-
,message_id
72-
,text
73-
,item_type
74-
,is_finished
75-
from ut_output_buffer_tmp$';
76-
77-
execute immediate 'create or replace editioning view '||v_view_source;
78-
exception
79-
when ex_nonedition_user then
80-
execute immediate 'create or replace view '||v_view_source;
81-
end;
82-
/

source/core/output_buffers/ut_output_clob_buffer_tmp.sql

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ declare
33
e_non_assm exception;
44
pragma exception_init(e_non_assm, -43853);
55
begin
6-
v_table_sql := 'create table ut_output_clob_buffer_tmp$(
6+
v_table_sql := 'create table ut_output_clob_buffer_tmp(
77
/*
88
utPLSQL - Version 3
99
Copyright 2016 - 2018 utPLSQL Project
@@ -31,7 +31,7 @@ begin
3131
constraint ut_output_clob_buffer_tmp_ck check(
3232
is_finished = 0 and (text is not null or item_type is not null )
3333
or is_finished = 1 and text is null and item_type is null ),
34-
constraint ut_output_clob_buffer_tmp_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id)
34+
constraint ut_output_clob_buffer_tmp_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade
3535
) nologging initrans 100
3636
';
3737
begin
@@ -45,45 +45,3 @@ begin
4545
end;
4646
end;
4747
/
48-
49-
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
50-
declare
51-
ex_nonedition_user exception;
52-
ex_view_doesnt_exist exception;
53-
pragma exception_init(ex_nonedition_user,-42314);
54-
pragma exception_init(ex_view_doesnt_exist,-942);
55-
v_view_source varchar2(32767);
56-
begin
57-
begin
58-
execute immediate 'drop view ut_output_clob_buffer_tmp';
59-
exception
60-
when ex_view_doesnt_exist then
61-
null;
62-
end;
63-
v_view_source := ' ut_output_clob_buffer_tmp as
64-
/*
65-
utPLSQL - Version 3
66-
Copyright 2016 - 2018 utPLSQL Project
67-
Licensed under the Apache License, Version 2.0 (the "License"):
68-
you may not use this file except in compliance with the License.
69-
You may obtain a copy of the License at
70-
http://www.apache.org/licenses/LICENSE-2.0
71-
Unless required by applicable law or agreed to in writing, software
72-
distributed under the License is distributed on an "AS IS" BASIS,
73-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74-
See the License for the specific language governing permissions and
75-
limitations under the License.
76-
*/
77-
select output_id
78-
,message_id
79-
,text
80-
,item_type
81-
,is_finished
82-
from ut_output_clob_buffer_tmp$';
83-
84-
execute immediate 'create or replace editioning view '||v_view_source;
85-
exception
86-
when ex_nonedition_user then
87-
execute immediate 'create or replace view '||v_view_source;
88-
end;
89-
/

0 commit comments

Comments
 (0)