Skip to content

Commit

Permalink
Protect internal tables for refcursor comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasylow committed Jun 14, 2019
1 parent 467078f commit 114c1c3
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 99 deletions.
2 changes: 1 addition & 1 deletion development/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#goto git root directory
git rev-parse && cd "$(git rev-parse --show-cdup)"

. development/env.sh
#. development/env.sh

"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL
set echo on
Expand Down
2 changes: 1 addition & 1 deletion development/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#goto git root directory
git rev-parse && cd "$(git rev-parse --show-cdup)"

. development/env.sh
#. development/env.sh

header="******************************************************************************************"
if ! development/cleanup.sh; then
Expand Down
2 changes: 1 addition & 1 deletion source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ create or replace package body ut_runner is

procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is
begin
ut_utils.cleanup_temp_tables;
utplsqlowner_dal.clean_expectations;
ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run);
ut_metadata.reset_source_definition_cache;
ut_utils.read_cache_to_dbms_output();
Expand Down
6 changes: 0 additions & 6 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,6 @@ create or replace package body ut_utils is
return l_xpath;
end;

procedure cleanup_temp_tables is
begin
execute immediate 'delete from ut_compound_data_tmp';
execute immediate 'delete from ut_compound_data_diff_tmp';
end;

function to_version(a_version_no varchar2) return t_version is
l_result t_version;
c_version_part_regex constant varchar2(20) := '[0-9]+';
Expand Down
1 change: 0 additions & 1 deletion source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ create or replace package ut_utils authid definer is

function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2;

procedure cleanup_temp_tables;

/**
* Converts version string into version record
Expand Down
2 changes: 0 additions & 2 deletions source/create_synonyms_and_grants_for_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ grant execute on &&ut3_owner..ut_file_mapping to public;
grant execute on &&ut3_owner..ut_file_mapper to public;
grant execute on &&ut3_owner..ut_key_value_pairs to public;
grant execute on &&ut3_owner..ut_key_value_pair to public;
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to public;
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to public;
grant execute on &&ut3_owner..ut_sonar_test_reporter to public;
grant execute on &&ut3_owner..ut_annotations to public;
grant execute on &&ut3_owner..ut_annotation to public;
Expand Down
2 changes: 0 additions & 2 deletions source/create_user_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user;
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user;
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
grant execute on &&ut3_owner..ut_annotations to &ut3_user;
grant execute on &&ut3_owner..ut_annotation to &ut3_user;
Expand Down
1 change: 0 additions & 1 deletion source/create_user_synonyms.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ create or replace synonym &ut3_user..ut_file_mapping for &&ut3_owner..ut_file_ma
create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_mapper;
create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs;
create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair;
create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data;
create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter;
create or replace synonym &ut3_user..ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter;
create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks;
Expand Down
6 changes: 4 additions & 2 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ create or replace package body ut_compound_data_helper is
a_join_by_list ut_varchar2_list,
a_unordered boolean,
a_inclusion_type boolean,
a_is_negated boolean
a_is_negated boolean,
a_max_count integer
) return clob is
l_compare_sql clob;
l_xmltable_stmt clob;
Expand All @@ -335,7 +336,7 @@ create or replace package body ut_compound_data_helper is
l_not_equal_stmt clob;
l_where_stmt clob;
l_ut_owner varchar2(250) := ut_utils.ut_owner;

function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is
begin
return
Expand All @@ -356,6 +357,7 @@ create or replace package body ut_compound_data_helper is
end;

begin

dbms_lob.createtemporary(l_compare_sql, true);
--Initiate a SQL template with placeholders
ut_utils.append_to_clob(l_compare_sql, g_compare_sql_template);
Expand Down
3 changes: 2 additions & 1 deletion source/expectations/data_values/ut_compound_data_helper.pks
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ create or replace package ut_compound_data_helper authid definer is
a_join_by_list ut_varchar2_list,
a_unordered boolean,
a_inclusion_type boolean,
a_is_negated boolean
a_is_negated boolean,
a_max_count integer
) return clob;

procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw);
Expand Down
11 changes: 1 addition & 10 deletions source/expectations/data_values/ut_compound_data_value.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,8 @@ create or replace type body ut_compound_data_value as
if not self.is_null() then
dbms_lob.createtemporary(l_result, true);
ut_utils.append_to_clob(l_result,'Data:'||chr(10));
--return first c_max_rows rows
execute immediate '
select xmlserialize( content ucd.item_data no indent)
from '|| ut_utils.ut_owner ||q'[.ut_compound_data_tmp tmp
,xmltable ( '/ROWSET' passing tmp.item_data
columns item_data xmltype PATH '*'
) ucd
where tmp.data_id = :data_id
and rownum <= :max_rows]'
bulk collect into l_results using self.data_id, ut_utils.gc_diff_max_rows;

utplsqlowner_dal.get_ut_compound_data_xml(self.data_id, ut_utils.gc_diff_max_rows,l_results);
ut_utils.append_to_clob(l_result,l_results);

l_result_string := ut_utils.to_string(l_result,null);
Expand Down
8 changes: 3 additions & 5 deletions source/expectations/data_values/ut_data_value_refcursor.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ create or replace type body ut_data_value_refcursor as
null;
$end
l_elements_count := l_elements_count + dbms_xmlgen.getNumRowsProcessed(l_ctx);
execute immediate
'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' ||
'values (:self_guid, :self_row_count, :l_xml)'
using in self.data_id, l_set_id, l_xml;
utplsqlowner_dal.ins_ut_compound_data_tmp(self.data_id, l_set_id, l_xml);
l_set_id := l_set_id + c_bulk_rows;
end loop;

Expand Down Expand Up @@ -375,7 +372,8 @@ create or replace type body ut_data_value_refcursor as
a_match_options.join_by.items,
a_match_options.unordered(),
a_inclusion_compare,
a_is_negated
a_is_negated,
greatest(self.elements_count,l_other.elements_count)
);
l_result := l_result + compare_data( l_self, l_other, l_diff_cursor_text );
end if;
Expand Down
Loading

0 comments on commit 114c1c3

Please sign in to comment.