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

Skip to content

Commit df98ebc

Browse files
committed
Improved cursor comparison - only showing different lines
1 parent e43b156 commit df98ebc

7 files changed

Lines changed: 18 additions & 6 deletions

File tree

source/core/ut_utils.pkb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ create or replace package body ut_utils is
381381
pragma autonomous_transaction;
382382
begin
383383
execute immediate 'delete from ut_cursor_data';
384+
execute immediate 'delete from ut_cursor_data_diff';
384385
commit;
385386
end;
386387

source/create_synonyms_and_grants_for_public.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ grant execute on &&ut3_owner..ut_file_mapper to public;
6666
grant execute on &&ut3_owner..ut_key_value_pairs to public;
6767
grant execute on &&ut3_owner..ut_key_value_pair to public;
6868
grant select, insert, delete on &&ut3_owner..ut_cursor_data to public;
69+
grant select, insert, delete on &&ut3_owner..ut_cursor_data_diff to public;
6970
grant execute on &&ut3_owner..ut_sonar_test_reporter to public;
7071
grant execute on &&ut3_owner..ut_annotations to public;
7172
grant execute on &&ut3_owner..ut_annotation to public;
@@ -117,4 +118,5 @@ create public synonym ut_file_mapper for &&ut3_owner..ut_file_mapper;
117118
create public synonym ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs;
118119
create public synonym ut_key_value_pair for &&ut3_owner..ut_key_value_pair;
119120
create public synonym ut_cursor_data for &&ut3_owner..ut_cursor_data;
121+
create public synonym ut_cursor_data_diff for &&ut3_owner..ut_cursor_data_diff;
120122
create public synonym ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter;

source/create_synonyms_and_grants_for_user.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
8686
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
8787
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
8888
grant select, insert, delete on &&ut3_owner..ut_cursor_data to &ut3_user;
89+
grant select, insert, delete on &&ut3_owner..ut_cursor_data_diff to &ut3_user;
8990
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
9091
grant execute on &&ut3_owner..ut_annotations to &ut3_user;
9192
grant execute on &&ut3_owner..ut_annotation to &ut3_user;
@@ -136,4 +137,5 @@ create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_map
136137
create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs;
137138
create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair;
138139
create or replace synonym &ut3_user..ut_cursor_data for &&ut3_owner..ut_cursor_data;
140+
create or replace synonym &ut3_user..ut_cursor_data_diff for &&ut3_owner..ut_cursor_data_diff;
139141
create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
create global temporary table ut_cursor_data_diff(
2+
row_no integer
3+
constraint ut_cursor_data_diff_pk primary key(row_no)
4+
) on commit preserve rows;

source/expectations/data_values/ut_data_value_refcursor.tpb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ create or replace type body ut_data_value_refcursor as
106106
l_result_string varchar2(32767);
107107
begin
108108
dbms_lob.createtemporary(l_result,true);
109-
--return first 100 rows
109+
--return rows which were previously marked as different
110110
select xmlserialize( content ucd.row_data no indent)
111111
bulk collect into l_results
112112
from ut_cursor_data ucd
113113
where ucd.cursor_data_guid = self.data_value
114-
and ucd.row_no <= c_max_rows;
114+
and ucd.row_no in (select row_no from ut_cursor_data_diff ucdc);
115115

116116
for i in 1 .. l_results.count loop
117117
dbms_lob.append(l_result,l_results(i));
@@ -138,17 +138,17 @@ create or replace type body ut_data_value_refcursor as
138138
l_xpath := coalesce(self.exclude_xpath, l_other.exclude_xpath);
139139
if a_other is of (ut_data_value_refcursor) then
140140
l_other := treat(a_other as ut_data_value_refcursor);
141-
select count(1)
142-
into l_result
141+
insert into ut_cursor_data_diff ( row_no )
142+
select nvl(exp.row_no, act.row_no)
143143
from (select case when l_xpath is not null then deletexml( ucd.row_data, l_xpath ) else ucd.row_data end as row_data,
144144
ucd.row_no
145145
from ut_cursor_data ucd where ucd.cursor_data_guid = self.data_value) exp
146146
full outer join (select case when l_xpath is not null then deletexml( ucd.row_data, l_xpath ) else ucd.row_data end as row_data,
147147
ucd.row_no
148148
from ut_cursor_data ucd where ucd.cursor_data_guid = l_other.data_value) act
149149
on (exp.row_no = act.row_no)
150-
where nvl(dbms_lob.compare(xmlserialize( content exp.row_data no indent), xmlserialize( content act.row_data no indent)),1) != 0
151-
and rownum <= 1;
150+
where nvl(dbms_lob.compare(xmlserialize( content exp.row_data no indent), xmlserialize( content act.row_data no indent)),1) != 0;
151+
select count(1) into l_result from ut_cursor_data_comp where rownum <= 1;
152152
else
153153
raise value_error;
154154
end if;

source/install.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ prompt Installing PLSQL profiler objects into &&ut3_owner schema
135135

136136
--expectations and matchers
137137
@@install_component.sql 'expectations/data_values/ut_cursor_data.sql'
138+
@@install_component.sql 'expectations/data_values/ut_cursor_data_diff.sql'
138139
@@install_component.sql 'expectations/data_values/ut_data_value.tps'
139140
@@install_component.sql 'expectations/data_values/ut_data_value_anydata.tps'
140141
@@install_component.sql 'expectations/data_values/ut_data_value_collection.tps'

source/uninstall.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ drop type ut_data_value force;
148148

149149
drop table ut_cursor_data;
150150

151+
drop table ut_cursor_data_diff;
152+
151153
drop package ut_annotation_manager;
152154

153155
drop package ut_annotation_parser;

0 commit comments

Comments
 (0)