diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb index cfa3e413c..5f9744265 100644 --- a/source/core/coverage/ut_coverage_helper.pkb +++ b/source/core/coverage/ut_coverage_helper.pkb @@ -44,7 +44,7 @@ create or replace package body ut_coverage_helper is pragma autonomous_transaction; begin null; - execute immediate 'truncate table ut_coverage_sources_tmp$'; + execute immediate 'truncate table ut_coverage_sources_tmp'; commit; end; diff --git a/source/core/coverage/ut_coverage_sources_tmp.sql b/source/core/coverage/ut_coverage_sources_tmp.sql index bcc661a22..29b53d147 100644 --- a/source/core/coverage/ut_coverage_sources_tmp.sql +++ b/source/core/coverage/ut_coverage_sources_tmp.sql @@ -1,4 +1,4 @@ -create global temporary table ut_coverage_sources_tmp$( +create global temporary table ut_coverage_sources_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2018 utPLSQL Project @@ -21,46 +21,5 @@ create global temporary table ut_coverage_sources_tmp$( constraint ut_coverage_sources_tmp_pk primary key (owner,name,line) ) on commit preserve rows; -create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line); - -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_coverage_sources_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_coverage_sources_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select full_name - ,owner - ,name - ,line - ,to_be_skipped - ,text - from ut_coverage_sources_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ +--is this needed? +--create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line); diff --git a/source/core/output_buffers/ut_output_buffer_base.tpb b/source/core/output_buffers/ut_output_buffer_base.tpb new file mode 100644 index 000000000..12eb08791 --- /dev/null +++ b/source/core/output_buffers/ut_output_buffer_base.tpb @@ -0,0 +1,76 @@ +create or replace type body ut_output_buffer_base is + /* + utPLSQL - Version 3 + Copyright 2016 - 2018 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is + pragma autonomous_transaction; + l_exists int; + begin + cleanup_buffer(); + self.self_type := coalesce(a_self_type,self.self_type); + self.output_id := coalesce(a_output_id, self.output_id, sys_guid()); + self.start_date := coalesce(self.start_date, sysdate); + self.last_message_id := 0; + select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; + if ( l_exists > 0 ) then + update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; + else + insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); + end if; + commit; + self.is_closed := 0; + end; + + member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is + l_lines sys_refcursor; + begin + open l_lines for + select text, item_type + from table(self.get_lines(a_initial_timeout, a_timeout_sec)); + return l_lines; + end; + + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is + l_data sys_refcursor; + l_clob clob; + l_item_type varchar2(32767); + l_lines ut_varchar2_list; + begin + l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); + loop + fetch l_data into l_clob, l_item_type; + exit when l_data%notfound; + l_lines := ut_utils.clob_to_table(l_clob); + for i in 1 .. l_lines.count loop + dbms_output.put_line(l_lines(i)); + end loop; + end loop; + close l_data; + end; + + member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is + gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours + l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); + l_max_retention_date date := sysdate - l_retention_days; + pragma autonomous_transaction; + begin + delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date; + commit; + end; + +end; +/ \ No newline at end of file diff --git a/source/core/output_buffers/ut_output_buffer_base.tps b/source/core/output_buffers/ut_output_buffer_base.tps index 59226a7fb..cffdc63bc 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tps +++ b/source/core/output_buffers/ut_output_buffer_base.tps @@ -1,4 +1,4 @@ -create or replace type ut_output_buffer_base authid definer as object( +create or replace type ut_output_buffer_base force authid definer as object( /* utPLSQL - Version 3 Copyright 2016 - 2018 utPLSQL Project @@ -17,13 +17,18 @@ create or replace type ut_output_buffer_base authid definer as object( */ output_id raw(32), - member procedure init(self in out nocopy ut_output_buffer_base), + is_closed number(1,0), + start_date date, + last_message_id number(38,0), + self_type varchar2(250 byte), + member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null), + member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null), + member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null), not instantiable member procedure close(self in out nocopy ut_output_buffer_base), not instantiable member procedure send_line(self in out nocopy ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null), 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), not instantiable member procedure send_clob(self in out nocopy ut_output_buffer_base, a_text clob, a_item_type varchar2 := null), - not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - not instantiable member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - not instantiable member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) + not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined ) not final not instantiable / diff --git a/source/core/output_buffers/ut_output_buffer_info_tmp.sql b/source/core/output_buffers/ut_output_buffer_info_tmp.sql index 5880022f5..c6e8995fb 100644 --- a/source/core/output_buffers/ut_output_buffer_info_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_info_tmp.sql @@ -1,4 +1,4 @@ -create table ut_output_buffer_info_tmp$( +create table ut_output_buffer_info_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2018 utPLSQL Project @@ -23,41 +23,3 @@ create table ut_output_buffer_info_tmp$( ) organization index nologging initrans 10 ; --- This is needed to be EBR ready as editioning view can only be created by edition enabled user -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_output_buffer_info_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_output_buffer_info_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select output_id - ,start_date - from ut_output_buffer_info_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ diff --git a/source/core/output_buffers/ut_output_buffer_tmp.sql b/source/core/output_buffers/ut_output_buffer_tmp.sql index e78a71c15..7ae024555 100644 --- a/source/core/output_buffers/ut_output_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_tmp.sql @@ -1,9 +1,4 @@ -declare - v_table_sql varchar2(32767); - e_non_assm exception; - pragma exception_init(e_non_assm, -43853); -begin - v_table_sql := 'create table ut_output_buffer_tmp$( +create table ut_output_buffer_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2018 utPLSQL Project @@ -31,52 +26,7 @@ begin constraint ut_output_buffer_tmp_ck check( is_finished = 0 and (text is not null or item_type is not null ) or is_finished = 1 and text is null and item_type is null ), - constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id) + constraint ut_output_buffer_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) organization index nologging initrans 100 - overflow nologging initrans 100 -'; - execute immediate v_table_sql; -end; -/ + overflow nologging initrans 100; --- This is needed to be EBR ready as editioning view can only be created by edition enabled user -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_output_buffer_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_output_buffer_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select output_id - ,message_id - ,text - ,item_type - ,is_finished - from ut_output_buffer_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ diff --git a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql index 57be1c6f4..0f56a837e 100644 --- a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql @@ -3,7 +3,7 @@ declare e_non_assm exception; pragma exception_init(e_non_assm, -43853); begin - v_table_sql := 'create table ut_output_clob_buffer_tmp$( + v_table_sql := 'create table ut_output_clob_buffer_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2018 utPLSQL Project @@ -31,7 +31,7 @@ begin constraint ut_output_clob_buffer_tmp_ck check( is_finished = 0 and (text is not null or item_type is not null ) or is_finished = 1 and text is null and item_type is null ), - constraint ut_output_clob_buffer_tmp_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id) + constraint ut_output_clob_buffer_tmp_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) nologging initrans 100 '; begin @@ -45,45 +45,3 @@ begin end; end; / - --- This is needed to be EBR ready as editioning view can only be created by edition enabled user -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_output_clob_buffer_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_output_clob_buffer_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select output_id - ,message_id - ,text - ,item_type - ,is_finished - from ut_output_clob_buffer_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tpb b/source/core/output_buffers/ut_output_clob_table_buffer.tpb index 56873a418..a8d979946 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tpb @@ -18,27 +18,10 @@ create or replace type body ut_output_clob_table_buffer is constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result is begin - self.output_id := coalesce(a_output_id, sys_guid()); - self.start_date := sysdate; - self.last_message_id := 0; - self.init(); - self.cleanup_buffer(); + self.init(a_output_id, $$plsql_unit); return; end; - overriding member procedure init(self in out nocopy ut_output_clob_table_buffer) is - pragma autonomous_transaction; - l_exists int; - begin - select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; - if ( l_exists > 0 ) then - update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; - else - insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); - end if; - commit; - end; - overriding member procedure close(self in out nocopy ut_output_clob_table_buffer) is pragma autonomous_transaction; begin @@ -46,6 +29,7 @@ create or replace type body ut_output_clob_table_buffer is insert into ut_output_clob_buffer_tmp(output_id, message_id, is_finished) values (self.output_id, self.last_message_id, 1); commit; + self.is_closed := 1; end; overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null) is @@ -169,46 +153,5 @@ create or replace type body ut_output_clob_table_buffer is return; end; - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is - l_lines sys_refcursor; - begin - open l_lines for - select text, item_type - from table(self.get_lines(a_initial_timeout, a_timeout_sec)); - return l_lines; - end; - - overriding member procedure lines_to_dbms_output(self in ut_output_clob_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null) is - l_data sys_refcursor; - l_clob clob; - l_item_type varchar2(32767); - l_lines ut_varchar2_list; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data into l_clob, l_item_type; - exit when l_data%notfound; - l_lines := ut_utils.clob_to_table(l_clob); - for i in 1 .. l_lines.count loop - dbms_output.put_line(l_lines(i)); - end loop; - end loop; - close l_data; - end; - - member procedure cleanup_buffer(self in ut_output_clob_table_buffer, a_retention_time_sec natural := null) is - gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours - l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); - l_max_retention_date date := sysdate - l_retention_days; - pragma autonomous_transaction; - begin - delete from ut_output_clob_buffer_tmp t - where t.output_id - in (select i.output_id from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date); - - delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date; - commit; - end; - end; / diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tps b/source/core/output_buffers/ut_output_clob_table_buffer.tps index 83e342106..ac9a502cd 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tps +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tps @@ -16,17 +16,11 @@ create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( limitations under the License. */ - start_date date, - last_message_id number(38,0), constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result, - overriding member procedure init(self in out nocopy ut_output_clob_table_buffer), overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null), overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null), overriding member procedure close(self in out nocopy ut_output_clob_table_buffer), - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - overriding member procedure lines_to_dbms_output(self in ut_output_clob_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null), - member procedure cleanup_buffer(self in ut_output_clob_table_buffer, a_retention_time_sec natural := null) + overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined ) not final / diff --git a/source/core/output_buffers/ut_output_table_buffer.tpb b/source/core/output_buffers/ut_output_table_buffer.tpb index afcbcbc95..44e91cc38 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_table_buffer.tpb @@ -18,27 +18,10 @@ create or replace type body ut_output_table_buffer is constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result is begin - self.output_id := coalesce(a_output_id, sys_guid()); - self.start_date := sysdate; - self.last_message_id := 0; - self.init(); - self.cleanup_buffer(); + self.init(a_output_id, $$plsql_unit); return; end; - overriding member procedure init(self in out nocopy ut_output_table_buffer) is - pragma autonomous_transaction; - l_exists int; - begin - select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; - if ( l_exists > 0 ) then - update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; - else - insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); - end if; - commit; - end; - overriding member procedure close(self in out nocopy ut_output_table_buffer) is pragma autonomous_transaction; begin @@ -46,6 +29,7 @@ create or replace type body ut_output_table_buffer is insert into ut_output_buffer_tmp(output_id, message_id, is_finished) values (self.output_id, self.last_message_id, 1); commit; + self.is_closed := 1; end; overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is @@ -187,46 +171,5 @@ create or replace type body ut_output_table_buffer is return; end; - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is - l_lines sys_refcursor; - begin - open l_lines for - select text, item_type - from table(self.get_lines(a_initial_timeout, a_timeout_sec)); - return l_lines; - end; - - overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null) is - l_data sys_refcursor; - l_clob clob; - l_item_type varchar2(32767); - l_lines ut_varchar2_list; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data into l_clob, l_item_type; - exit when l_data%notfound; - l_lines := ut_utils.clob_to_table(l_clob); - for i in 1 .. l_lines.count loop - dbms_output.put_line(l_lines(i)); - end loop; - end loop; - close l_data; - end; - - member procedure cleanup_buffer(self in ut_output_table_buffer, a_retention_time_sec natural := null) is - gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours - l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); - l_max_retention_date date := sysdate - l_retention_days; - pragma autonomous_transaction; - begin - delete from ut_output_buffer_tmp t - where t.output_id - in (select i.output_id from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date); - - delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date; - commit; - end; - end; / diff --git a/source/core/output_buffers/ut_output_table_buffer.tps b/source/core/output_buffers/ut_output_table_buffer.tps index 9cf64927c..77a057b78 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tps +++ b/source/core/output_buffers/ut_output_table_buffer.tps @@ -16,17 +16,11 @@ create or replace type ut_output_table_buffer under ut_output_buffer_base ( limitations under the License. */ - start_date date, - last_message_id number(38,0), constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result, - overriding member procedure init(self in out nocopy ut_output_table_buffer), overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null), overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null), overriding member procedure close(self in out nocopy ut_output_table_buffer), - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null), - member procedure cleanup_buffer(self in ut_output_table_buffer, a_retention_time_sec natural := null) + overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined ) not final / diff --git a/source/install.sql b/source/install.sql index 145357052..e6ccf7d28 100644 --- a/source/install.sql +++ b/source/install.sql @@ -92,14 +92,15 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'expectations/data_values/ut_key_anyvalues.tps' ---output buffer base api -@@install_component.sql 'core/output_buffers/ut_output_data_row.tps' -@@install_component.sql 'core/output_buffers/ut_output_data_rows.tps' -@@install_component.sql 'core/output_buffers/ut_output_buffer_base.tps' --output buffer table @@install_component.sql 'core/output_buffers/ut_output_buffer_info_tmp.sql' @@install_component.sql 'core/output_buffers/ut_output_buffer_tmp.sql' @@install_component.sql 'core/output_buffers/ut_output_clob_buffer_tmp.sql' +--output buffer base api +@@install_component.sql 'core/output_buffers/ut_output_data_row.tps' +@@install_component.sql 'core/output_buffers/ut_output_data_rows.tps' +@@install_component.sql 'core/output_buffers/ut_output_buffer_base.tps' +@@install_component.sql 'core/output_buffers/ut_output_buffer_base.tpb' --output buffer table api @@install_component.sql 'core/output_buffers/ut_output_table_buffer.tps' @@install_component.sql 'core/output_buffers/ut_output_table_buffer.tpb' diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index b109efd89..f34b964de 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -52,9 +52,7 @@ drop package ut_coverage; drop package ut_coverage_helper; -drop view ut_coverage_sources_tmp; - -drop table ut_coverage_sources_tmp$; +drop table ut_coverage_sources_tmp purge; drop package ut_teamcity_reporter_helper; @@ -70,17 +68,17 @@ drop package ut_suite_builder; drop package ut_suite_cache_manager; -drop table ut_suite_cache; +drop table ut_suite_cache purge; drop sequence ut_suite_cache_seq; -drop table ut_suite_cache_package; +drop table ut_suite_cache_package purge; -drop table ut_suite_cache_schema; +drop table ut_suite_cache_schema purge; drop package ut; -drop table ut_dbms_output_cache; +drop table ut_dbms_output_cache purge; drop type ut_expectation_compound force; @@ -160,9 +158,9 @@ drop type ut_cursor_column_tab force; drop type ut_cursor_column force; -drop table ut_compound_data_tmp; +drop table ut_compound_data_tmp purge; -drop table ut_compound_data_diff_tmp; +drop table ut_compound_data_diff_tmp purge; drop trigger ut_trigger_annotation_parsing; @@ -172,11 +170,11 @@ drop package ut_annotation_parser; drop package ut_annotation_cache_manager; -drop table ut_annotation_cache cascade constraints; +drop table ut_annotation_cache cascade constraints purge; -drop table ut_annotation_cache_info cascade constraints; +drop table ut_annotation_cache_info cascade constraints purge; -drop table ut_annotation_cache_schema cascade constraints; +drop table ut_annotation_cache_schema cascade constraints purge; drop sequence ut_annotation_cache_seq; @@ -260,17 +258,11 @@ drop type ut_output_clob_table_buffer force; drop type ut_output_buffer_base force; -drop view ut_output_buffer_tmp; - -drop table ut_output_buffer_tmp$ purge; - -drop view ut_output_clob_buffer_tmp; - -drop table ut_output_clob_buffer_tmp$ purge; +drop table ut_output_buffer_tmp purge; -drop view ut_output_buffer_info_tmp; +drop table ut_output_clob_buffer_tmp purge; -drop table ut_output_buffer_info_tmp$; +drop table ut_output_buffer_info_tmp purge; drop type ut_output_data_rows force; diff --git a/test/ut3_tester/core/test_output_buffer.pkb b/test/ut3_tester/core/test_output_buffer.pkb index 40af7e0b0..7aab6f389 100644 --- a/test/ut3_tester/core/test_output_buffer.pkb +++ b/test/ut3_tester/core/test_output_buffer.pkb @@ -109,6 +109,42 @@ create or replace package body test_output_buffer is ut.expect(l_remaining).to_equal(0); end; - + + procedure test_purge(a_buffer ut3.ut_output_buffer_base ) is + l_stale_buffer ut3.ut_output_buffer_base := a_buffer; + l_fresh_buffer ut3.ut_output_buffer_base; + l_buffer ut3.ut_output_buffer_base; + begin + --Arrange + l_stale_buffer.start_date := sysdate - 2; + --initialize with new start date + l_stale_buffer.init(); + l_stale_buffer.send_line('some text'); + l_stale_buffer.close(); + + l_fresh_buffer := ut3.ut_output_table_buffer(); + l_fresh_buffer.send_line('some text'); + l_fresh_buffer.close(); + + --Act - purge is performed on new buffer create + l_buffer := ut3.ut_output_table_buffer(); + + --Assert + -- Data in "fresh" buffer remains + ut.expect( l_fresh_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_have_count(1); + -- Data in "slate" buffer is purged and so the call to get_lines_cursor throws ORA-20218 + ut.expect( l_stale_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_be_empty(); + end; + + procedure test_purge_text_buffer is + begin + test_purge(ut3.ut_output_table_buffer()); + end; + + procedure test_purge_clob_buffer is + begin + test_purge(ut3.ut_output_clob_table_buffer()); + end; + end test_output_buffer; / diff --git a/test/ut3_tester/core/test_output_buffer.pks b/test/ut3_tester/core/test_output_buffer.pks index 8f4d5873d..24c2c01eb 100644 --- a/test/ut3_tester/core/test_output_buffer.pks +++ b/test/ut3_tester/core/test_output_buffer.pks @@ -18,5 +18,13 @@ create or replace package test_output_buffer is --%test(Waits For The Data To Appear For Specified Time) procedure test_waiting_for_data; + --%test(Purges text buffer data older than one day and leaves the rest) + --%throws(-20218) + procedure test_purge_text_buffer; + + --%test(Purges clob buffer data older than one day and leaves the rest) + --%throws(-20218) + procedure test_purge_clob_buffer; + end test_output_buffer; /