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

Skip to content

Commit e41d6f9

Browse files
committed
Interim commit with lots of dirty code - got to a place where I get the infamous ORA-00600
`ORA-00600: internal error code, arguments: [pfrobj.c: invalid RTTI for Object], [], [], [], [], [], [], [], [], [], [], []``
1 parent 899ddcf commit e41d6f9

32 files changed

Lines changed: 1270 additions & 287 deletions

source/core/annotations/ut_annotated_object.tps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ create type ut_annotated_object as object(
1818
object_owner varchar2(250),
1919
object_name varchar2(250),
2020
object_type varchar2(50),
21+
parse_time date,
2122
annotations ut_annotations
2223
)
2324
/

source/core/annotations/ut_annotation_cache_manager.pkb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@ create or replace package body ut_annotation_cache_manager as
3737
where cache_id = l_cache_id;
3838

3939
if a_object.annotations is not null and a_object.annotations.count > 0 then
40-
-- begin
4140
insert into ut_annotation_cache
4241
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
4342
select l_cache_id, a.position, a.name, a.text, a.subobject_name
4443
from table(a_object.annotations) a;
45-
--TODO - duplicate annotations found?? - should not happen, getting standalone annotations need to happen after procedure annotations were parsed
46-
-- exception
47-
-- when others then
48-
-- dbms_output.put_line(xmltype(anydata.convertCollection(a_object.annotations)).getclobval);
49-
-- raise;
50-
-- end;
5144
end if;
5245
commit;
5346
end;
@@ -81,12 +74,12 @@ create or replace package body ut_annotation_cache_manager as
8174
commit;
8275
end;
8376

84-
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info) return sys_refcursor is
77+
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor is
8578
l_results sys_refcursor;
8679
begin
87-
open l_results for
80+
open l_results for q'[
8881
select ut_annotated_object(
89-
o.object_owner, o.object_name, o.object_type,
82+
i.object_owner, i.object_name, i.object_type, i.parse_time,
9083
cast(
9184
collect(
9285
ut_annotation(
@@ -95,11 +88,13 @@ create or replace package body ut_annotation_cache_manager as
9588
) as ut_annotations
9689
)
9790
)
98-
from table(a_cached_objects) o
91+
from table(:a_cached_objects) o
9992
join ut_annotation_cache_info i
10093
on o.object_owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type
10194
join ut_annotation_cache c on i.cache_id = c.cache_id
102-
group by o.object_owner, o.object_name, o.object_type;
95+
where ]'|| case when a_parse_date is null then ':a_parse_date is null' else 'i.parse_time > :a_parse_date' end ||q'[
96+
group by i.object_owner, i.object_name, i.object_type, i.parse_time]'
97+
using a_cached_objects, a_parse_date;
10398
return l_results;
10499
end;
105100

source/core/annotations/ut_annotation_cache_manager.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ create or replace package ut_annotation_cache_manager authid definer as
3232
*
3333
* @param a_cached_objects a `ut_annotation_objs_cache_info` list with information about objects to get from cache
3434
*/
35-
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info) return sys_refcursor;
35+
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor;
3636

3737
/**
3838
* Removes cached information about annotations for objects on the list and updates parse_time in cache info table.

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ create or replace package body ut_annotation_manager as
1919
------------------------------
2020
--private definitions
2121

22-
function get_annotation_objs_info_cur(a_object_owner varchar2, a_object_type varchar2) return sys_refcursor is
23-
l_result sys_refcursor;
22+
function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotation_objs_cache_info is
23+
l_rows sys_refcursor;
2424
l_ut_owner varchar2(250) := ut_utils.ut_owner;
2525
l_objects_view varchar2(200) := ut_metadata.get_dba_view('dba_objects');
26-
l_cursor_text long;
26+
l_cursor_text varchar2(32767);
27+
l_result ut_annotation_objs_cache_info;
2728
begin
2829
l_cursor_text :=
2930
q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
@@ -34,10 +35,20 @@ create or replace package body ut_annotation_manager as
3435
)
3536
from ]'||l_objects_view||q'[ o
3637
left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i
37-
on o.owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type
38+
on o.owner = i.object_owner
39+
and o.object_name = i.object_name
40+
and o.object_type = i.object_type
3841
where o.owner = :a_object_owner
39-
and o.object_type = :a_object_type]';
40-
open l_result for l_cursor_text using a_object_owner, a_object_type;
42+
and o.object_type = :a_object_type
43+
and ]'
44+
|| case
45+
when a_parse_date is null
46+
then ':a_parse_date is null'
47+
else 'o.last_ddl_time > :a_parse_date'
48+
end;
49+
open l_rows for l_cursor_text using a_object_owner, a_object_type, a_parse_date;
50+
fetch l_rows bulk collect into l_result limit 1000000;
51+
close l_rows;
4152
return l_result;
4253
end;
4354

@@ -103,6 +114,7 @@ create or replace package body ut_annotation_manager as
103114
l_names dbms_preprocessor.source_lines_t;
104115
l_name varchar2(250);
105116
l_object_lines dbms_preprocessor.source_lines_t;
117+
l_parse_time date := sysdate;
106118
pragma autonomous_transaction;
107119
begin
108120
ut_annotation_cache_manager.cleanup_cache(a_schema_objects);
@@ -112,7 +124,7 @@ create or replace package body ut_annotation_manager as
112124
if l_names(i) != l_name then
113125
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines);
114126
ut_annotation_cache_manager.update_cache(
115-
ut_annotated_object(a_object_owner, l_name, a_object_type, l_annotations)
127+
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
116128
);
117129
l_object_lines.delete;
118130
end if;
@@ -126,7 +138,7 @@ create or replace package body ut_annotation_manager as
126138
if a_sources_cursor%rowcount > 0 then
127139
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines);
128140
ut_annotation_cache_manager.update_cache(
129-
ut_annotated_object(a_object_owner, l_name, a_object_type, l_annotations)
141+
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
130142
);
131143
l_object_lines.delete;
132144
end if;
@@ -140,7 +152,8 @@ create or replace package body ut_annotation_manager as
140152
l_objects_to_parse ut_annotation_objs_cache_info := ut_annotation_objs_cache_info();
141153
begin
142154
--get list of objects in cache
143-
select count( 1)into l_objects_in_cache_count from table(a_info_rows) x where x.needs_refresh = 'N';
155+
select count(1) into l_objects_in_cache_count
156+
from table(a_info_rows) x where x.needs_refresh = 'N';
144157

145158
--if cache is empty and there are objects to parse
146159
if l_objects_in_cache_count = 0 and a_info_rows.count > 0 then
@@ -173,30 +186,26 @@ create or replace package body ut_annotation_manager as
173186
--public definitions
174187
------------------------------------------------------------
175188
procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is
176-
l_info_cursor sys_refcursor;
177-
l_info_rows ut_annotation_objs_cache_info;
178189
begin
179-
l_info_cursor := get_annotation_objs_info_cur(a_object_owner, a_object_type);
180-
fetch l_info_cursor bulk collect into l_info_rows;
181-
close l_info_cursor;
182-
rebuild_annotation_cache(a_object_owner, a_object_type, l_info_rows);
190+
rebuild_annotation_cache(
191+
a_object_owner,
192+
a_object_type,
193+
get_annotation_objs_info(a_object_owner, a_object_type, null)
194+
);
183195
end;
184196

185-
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotated_objects pipelined is
186-
l_info_cursor sys_refcursor;
197+
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined is
187198
l_info_rows ut_annotation_objs_cache_info;
188199
l_cursor sys_refcursor;
189200
l_results ut_annotated_objects;
190201
c_object_fetch_limit constant integer := 10;
191202
begin
192-
193-
l_info_cursor := get_annotation_objs_info_cur(a_object_owner, a_object_type);
194-
fetch l_info_cursor bulk collect into l_info_rows;
195-
close l_info_cursor;
203+
204+
l_info_rows := get_annotation_objs_info(a_object_owner, a_object_type, a_parse_date);
196205
rebuild_annotation_cache(a_object_owner, a_object_type, l_info_rows);
197206

198207
--pipe annotations from cache
199-
l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_info_rows);
208+
l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_info_rows, a_parse_date);
200209
loop
201210
fetch l_cursor bulk collect into l_results limit c_object_fetch_limit;
202211
for i in 1 .. l_results.count loop
@@ -205,7 +214,6 @@ create or replace package body ut_annotation_manager as
205214
exit when l_cursor%notfound;
206215
end loop;
207216
close l_cursor;
208-
209217
end;
210218

211219
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is

source/core/annotations/ut_annotation_manager.pks

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ create or replace package ut_annotation_manager authid current_user as
2727
*
2828
* @param a_object_owner owner of objects to get annotations for
2929
* @param a_object_type type of objects to get annotations for
30+
* @param a_parse_date date when object was last parsed
3031
* @return array containing annotated objects along with annotations for each object (nested)
3132
*/
32-
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotated_objects pipelined;
33+
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined;
3334

3435
/**
3536
* Rebuilds annotation cache for a specified schema and object type.

source/core/types/ut_logical_suite.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ create or replace type body ut_logical_suite as
2121
) return self as result is
2222
begin
2323
self.self_type := $$plsql_unit;
24-
self.init(a_object_owner, a_object_name, a_name);
24+
self.init(a_object_owner, a_object_name, a_name, 0);
2525
self.path := a_path;
2626
self.disabled_flag := ut_utils.boolean_to_int(false);
2727
self.items := ut_suite_items();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create or replace type ut_logical_suites as
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+
table of ut_logical_suite
19+
/

source/core/types/ut_suite.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ create or replace type body ut_suite as
1717
*/
1818

1919
constructor function ut_suite (
20-
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2
20+
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer
2121
) return self as result is
2222
begin
2323
self.self_type := $$plsql_unit;
24-
self.init(a_object_owner, a_object_name, a_object_name);
24+
self.init(a_object_owner, a_object_name, a_object_name, a_line_no);
2525
self.items := ut_suite_items();
2626
before_all_list := ut_executables();
2727
after_all_list := ut_executables();

source/core/types/ut_suite.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ create or replace type ut_suite under ut_logical_suite (
2727
*/
2828
after_all_list ut_executables,
2929
constructor function ut_suite (
30-
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2
30+
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer
3131
) return self as result,
3232
overriding member function do_execute(self in out nocopy ut_suite) return boolean,
3333
overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list,

source/core/types/ut_suite_context.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ create or replace type body ut_suite_context as
1717
*/
1818

1919
constructor function ut_suite_context (
20-
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null
20+
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer
2121
) return self as result is
2222
begin
2323
self.self_type := $$plsql_unit;
24-
self.init(a_object_owner, a_object_name, a_context_name);
24+
self.init(a_object_owner, a_object_name, a_context_name, a_line_no);
2525
self.items := ut_suite_items();
2626
before_all_list := ut_executables();
2727
after_all_list := ut_executables();

0 commit comments

Comments
 (0)