Skip to content

Commit 204a4cd

Browse files
committed
Modified ut_suite_item.path to varchar2(1000)
Moved exception handling. Removed alter on `ut_suite_cache` table. Unified `ut_utils.to_string` for clob/blob and varchar2 types.
1 parent 903da20 commit 204a4cd

6 files changed

Lines changed: 73 additions & 52 deletions

File tree

source/core/types/ut_suite_item.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ create or replace type ut_suite_item force under ut_event_item (
3636
/**
3737
* Full path of the invocation of the item (including the items name itself)
3838
*/
39-
path varchar2(4000 byte),
39+
path varchar2(1000 byte),
4040
/**
4141
* The type of the rollback behavior
4242
*/

source/core/ut_suite_cache.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ create table ut_suite_cache (
7373
where rownum < 0
7474
/
7575

76-
alter table ut_suite_cache modify (path varchar2( 1000 ))
77-
/
7876
alter table ut_suite_cache modify (object_owner not null, path not null, self_type not null, object_name not null, name not null, parse_time not null)
7977
/
8078
alter table ut_suite_cache add constraint ut_suite_cache_pk primary key (id)
@@ -88,8 +86,6 @@ alter table ut_suite_cache add constraint ut_suite_cache_schema_fk foreign key (
8886
references ut_suite_cache_package(object_owner, object_name) on delete cascade
8987
/
9088

91-
92-
9389
drop type ut_tests
9490
/
9591

source/core/ut_suite_manager.pkb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -480,39 +480,37 @@ create or replace package body ut_suite_manager is
480480
l_suite_items ut_suite_items;
481481

482482
l_bad_suitepath_obj ut_varchar2_list := ut_varchar2_list();
483-
ex_value_too_large exception;
484-
pragma exception_init (ex_value_too_large,-12899);
483+
ex_string_too_small exception;
484+
pragma exception_init (ex_string_too_small,-06502);
485485
begin
486486
loop
487487
fetch a_annotated_objects bulk collect into l_annotated_objects limit 10;
488488

489489
for i in 1 .. l_annotated_objects.count loop
490-
ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items );
491490
begin
492-
ut_suite_cache_manager.save_object_cache(
493-
a_owner_name,
494-
l_annotated_objects( i ).object_name,
495-
l_annotated_objects( i ).parse_time,
496-
l_suite_items
497-
);
491+
ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items );
498492
exception
499-
when ex_value_too_large then
493+
when ex_string_too_small then
500494
ut_utils.append_to_list(l_bad_suitepath_obj,a_owner_name||'.'||l_annotated_objects( i ).object_name);
501495
end;
496+
ut_suite_cache_manager.save_object_cache(
497+
a_owner_name,
498+
l_annotated_objects( i ).object_name,
499+
l_annotated_objects( i ).parse_time,
500+
l_suite_items
501+
);
502502
end loop;
503503
exit when a_annotated_objects%notfound;
504504
end loop;
505505
close a_annotated_objects;
506506

507507
--Check for any invalid suitepath objects
508508
if l_bad_suitepath_obj.count > 0 then
509-
raise ut_utils.ex_value_too_large;
509+
raise_application_error(
510+
ut_utils.gc_value_too_large,
511+
ut_utils.to_string(gc_suitpath_error_message||ut_utils.table_to_clob(l_bad_suitepath_obj,','))
512+
);
510513
end if;
511-
512-
exception
513-
when ut_utils.ex_value_too_large then
514-
raise_application_error(ut_utils.gc_value_too_large,
515-
ut_utils.to_string(gc_suitpath_error_message||ut_utils.table_to_clob(l_bad_suitepath_obj,',')));
516514
end;
517515

518516
procedure refresh_cache(

source/core/ut_utils.pkb

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,50 +77,66 @@ create or replace package body ut_utils is
7777
$end
7878
end;
7979

80-
function to_string(a_value varchar2, a_qoute_char varchar2 := '''', a_max_output_len in number := gc_max_output_string_length) return varchar2 is
81-
l_len integer := coalesce(length(a_value),0);
80+
function to_string(
81+
a_value varchar2,
82+
a_quote_char varchar2 := '''',
83+
a_max_output_len in number := gc_max_output_string_length
84+
) return varchar2 is
8285
l_result varchar2(32767);
83-
l_max_input_string_length integer := a_max_output_len - 2;--we need to remove 2 chars for quotes around string
84-
l_overflow_substr_len integer := l_max_input_string_length - length(gc_more_data_string);
86+
c_length constant integer := coalesce( length( a_value ), 0 );
87+
c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
88+
c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
8589
begin
86-
if l_len = 0 then
90+
if c_length = 0 then
8791
l_result := gc_null_string;
88-
elsif l_len <= l_max_input_string_length then
89-
l_result := surround_with(a_value, a_qoute_char);
92+
elsif c_length <= c_max_input_string_length then
93+
l_result := surround_with(a_value, a_quote_char);
9094
else
91-
l_result := surround_with(substr(a_value,1,l_overflow_substr_len),a_qoute_char) || gc_more_data_string;
95+
l_result := surround_with(substr(a_value, 1, c_overflow_substr_len ), a_quote_char) || gc_more_data_string;
9296
end if ;
9397
return l_result;
9498
end;
9599

96-
function to_string(a_value clob, a_qoute_char varchar2 := '''') return varchar2 is
97-
l_len integer := coalesce(dbms_lob.getlength(a_value), 0);
98-
l_result varchar2(32767);
100+
function to_string(
101+
a_value clob,
102+
a_quote_char varchar2 := '''',
103+
a_max_output_len in number := gc_max_output_string_length
104+
) return varchar2 is
105+
l_result varchar2(32767);
106+
c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0);
107+
c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
108+
c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
99109
begin
100110
if a_value is null then
101111
l_result := gc_null_string;
102-
elsif l_len = 0 then
112+
elsif c_length = 0 then
103113
l_result := gc_empty_string;
104-
elsif l_len <= gc_max_input_string_length then
105-
l_result := surround_with(a_value,a_qoute_char);
114+
elsif c_length <= c_max_input_string_length then
115+
l_result := surround_with(a_value,a_quote_char);
106116
else
107-
l_result := surround_with(dbms_lob.substr(a_value, gc_overflow_substr_len),a_qoute_char) || gc_more_data_string;
117+
l_result := surround_with(dbms_lob.substr(a_value, c_overflow_substr_len), a_quote_char) || gc_more_data_string;
108118
end if;
109119
return l_result;
110120
end;
111121

112-
function to_string(a_value blob, a_qoute_char varchar2 := '''') return varchar2 is
113-
l_len integer := coalesce(dbms_lob.getlength(a_value), 0);
114-
l_result varchar2(32767);
122+
function to_string(
123+
a_value blob,
124+
a_quote_char varchar2 := '''',
125+
a_max_output_len in number := gc_max_output_string_length
126+
) return varchar2 is
127+
l_result varchar2(32767);
128+
c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0);
129+
c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
130+
c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
115131
begin
116132
if a_value is null then
117133
l_result := gc_null_string;
118-
elsif l_len = 0 then
134+
elsif c_length = 0 then
119135
l_result := gc_empty_string;
120-
elsif l_len <= gc_max_input_string_length then
121-
l_result := surround_with(rawtohex(a_value),a_qoute_char);
136+
elsif c_length <= c_max_input_string_length then
137+
l_result := surround_with(rawtohex(a_value),a_quote_char);
122138
else
123-
l_result := to_string( rawtohex(dbms_lob.substr(a_value, gc_overflow_substr_len)) );
139+
l_result := to_string( rawtohex(dbms_lob.substr(a_value, c_overflow_substr_len)) );
124140
end if ;
125141
return l_result;
126142
end;

source/core/ut_utils.pks

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ create or replace package ut_utils authid definer is
111111

112112
gc_max_storage_varchar2_len constant integer := 4000;
113113
gc_max_output_string_length constant integer := 4000;
114-
gc_max_input_string_length constant integer := gc_max_output_string_length - 2; --we need to remove 2 chars for quotes around string
115114
gc_more_data_string constant varchar2(5) := '[...]';
116-
gc_overflow_substr_len constant integer := gc_max_input_string_length - length(gc_more_data_string);
115+
gc_more_data_string_len constant integer := length( gc_more_data_string );
117116
gc_number_format constant varchar2(100) := 'TM9';
118117
gc_date_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ss';
119118
gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff';
@@ -155,11 +154,23 @@ create or replace package ut_utils authid definer is
155154

156155
procedure debug_log(a_message clob);
157156

158-
function to_string(a_value varchar2, a_qoute_char varchar2 := '''', a_max_output_len in number := gc_max_output_string_length) return varchar2;
159-
160-
function to_string(a_value clob, a_qoute_char varchar2 := '''') return varchar2;
161-
162-
function to_string(a_value blob, a_qoute_char varchar2 := '''') return varchar2;
157+
function to_string(
158+
a_value varchar2,
159+
a_quote_char varchar2 := '''',
160+
a_max_output_len in number := gc_max_output_string_length
161+
) return varchar2;
162+
163+
function to_string(
164+
a_value clob,
165+
a_quote_char varchar2 := '''',
166+
a_max_output_len in number := gc_max_output_string_length
167+
) return varchar2;
168+
169+
function to_string(
170+
a_value blob,
171+
a_quote_char varchar2 := '''',
172+
a_max_output_len in number := gc_max_output_string_length
173+
) return varchar2;
163174

164175
function to_string(a_value boolean) return varchar2;
165176

test/core/test_suite_manager.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,12 +1484,12 @@ end;]';
14841484
l_actual ut3.ut_object_names;
14851485
l_expected_message varchar2(500);
14861486
begin
1487-
l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3.DUMMY_LONG_TEST_PACKAGE,UT3.DUMMY_LONG_TEST_PACKAGE1']';
1487+
l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3.DUMMY_LONG_TEST_PACKAGE,UT3.DUMMY_LONG_TEST_PACKAGE1'%]';
14881488
l_actual := ut3.ut_suite_manager.get_schema_ut_packages(ut3.ut_varchar2_rows('UT3'));
14891489
ut.fail('Expected exception for suitpaths over 1k for two packages');
14901490
exception
14911491
when others then
1492-
ut.expect(SQLERRM).to_equal(l_expected_message);
1492+
ut.expect(dbms_utility.format_error_stack()).to_be_like(l_expected_message);
14931493
ut.expect(SQLCODE).to_equal(ut3.ut_utils.gc_value_too_large);
14941494
end;
14951495

0 commit comments

Comments
 (0)