@@ -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
0 commit comments