@@ -24,29 +24,28 @@ create or replace package body ut_annotation_manager as
2424 l_ut_owner varchar2(250) := ut_utils.ut_owner;
2525 l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
2626 l_cursor_text varchar2(32767);
27+ l_data ut_annotation_objs_cache_info;
2728 l_result ut_annotation_objs_cache_info;
29+ l_card natural;
2830 begin
31+ l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type);
32+ l_card := ut_utils.scale_cardinality(cardinality(l_data));
33+
2934 l_cursor_text :=
30- q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
31- object_owner => i.object_owner,
32- object_name => i.object_name,
33- object_type => i.object_type,
34- needs_refresh => null
35- )
36- from ]'||l_ut_owner||q'[.ut_annotation_cache_info i
35+ 'select /*+ cardinality(i '||l_card||') */
36+ value(i)
37+ from table( cast( :l_data as '||l_ut_owner||'.ut_annotation_objs_cache_info ) ) i
3738 where
3839 not exists (
39- select 1 from ] '||l_objects_view||q'[ o
40+ select 1 from '||l_objects_view||q'[ o
4041 where o.owner = i.object_owner
4142 and o.object_name = i.object_name
4243 and o.object_type = i.object_type
43- and o.owner = :a_object_owner
44- and o.object_type = :a_object_type
45- )
46- and i.object_owner = :a_object_owner
47- and i.object_type = :a_object_type]';
48- open l_rows for l_cursor_text using a_object_owner, a_object_type, a_object_owner, a_object_type;
49- fetch l_rows bulk collect into l_result limit 1000000;
44+ and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
45+ and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
46+ )]';
47+ open l_rows for l_cursor_text using l_data;
48+ fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit;
5049 close l_rows;
5150 return l_result;
5251 end;
@@ -61,83 +60,48 @@ create or replace package body ut_annotation_manager as
6160 l_ut_owner varchar2(250) := ut_utils.ut_owner;
6261 l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
6362 l_cursor_text varchar2(32767);
63+ l_data ut_annotation_objs_cache_info;
6464 l_result ut_annotation_objs_cache_info;
65- l_object_owner varchar2(250);
66- l_object_type varchar2(250);
6765 begin
6866 ut_event_manager.trigger_event(
6967 'get_annotation_objs_info - start ( a_full_scan = ' || ut_utils.to_string(a_full_scan) || ' )'
7068 );
69+
70+ l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type);
71+
7172 if not a_full_scan then
72- l_cursor_text :=
73- q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
74- object_owner => i.object_owner,
75- object_name => i.object_name,
76- object_type => i.object_type,
77- needs_refresh => 'N'
78- )
79- from ]'||l_ut_owner||q'[.ut_annotation_cache_info i
80- where i.object_owner = :a_object_owner
81- and i.object_type = :a_object_type]';
82- open l_rows for l_cursor_text using a_object_owner, a_object_type;
73+ l_result := l_data;
8374 else
84- if a_object_owner is not null then
85- l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner);
86- end if;
87- if a_object_type is not null then
88- l_object_type := sys.dbms_assert.qualified_sql_name(a_object_type);
89- end if;
9075 l_cursor_text :=
91- q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
92- object_owner => o.owner,
93- object_name => o.object_name,
94- object_type => o.object_type,
95- needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end
96- )
97- from ]'||l_objects_view||q'[ o
98- left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i
76+ 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_data))||') */
77+ '||l_ut_owner||q'[.ut_annotation_obj_cache_info(
78+ object_owner => o.owner,
79+ object_name => o.object_name,
80+ object_type => o.object_type,
81+ needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end,
82+ parse_time => i.parse_time
83+ )
84+ from ]'||l_objects_view||' o
85+ left join table( cast(:l_data as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) i
9986 on o.owner = i.object_owner
10087 and o.object_name = i.object_name
10188 and o.object_type = i.object_type
102- where o.owner = ']'||l_object_owner ||q'['
103- and o.object_type = ']'||l_object_type ||q'['
89+ where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner) ||q'['
90+ and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type) ||q'['
10491 and ]'
10592 || case
10693 when a_parse_date is null
10794 then ':a_parse_date is null'
10895 else 'o.last_ddl_time >= cast(:a_parse_date as date)'
10996 end;
110- open l_rows for l_cursor_text using a_parse_date;
97+ open l_rows for l_cursor_text using l_data, a_parse_date;
98+ fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit;
99+ close l_rows;
111100 end if;
112- fetch l_rows bulk collect into l_result limit 10000000;
113- close l_rows;
114101 ut_event_manager.trigger_event('get_annotation_objs_info - end (count='||l_result.count||')');
115102 return l_result;
116103 end;
117104
118- function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2) return sys_refcursor is
119- l_result sys_refcursor;
120- l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
121- begin
122- open l_result for
123- q'[select s.name, s.text
124- from (select s.name, s.text, s.line,
125- max(case when s.text like '%--%\%%' escape '\'
126- and regexp_like(s.text,'--\s*%')
127- then 'Y' else 'N' end
128- )
129- over(partition by s.name) is_annotated
130- from ]'||l_sources_view||q'[ s
131- where s.type = :a_object_type
132- and s.owner = :a_object_owner
133- ) s
134- where s.is_annotated = 'Y'
135- order by s.name, s.line]'
136- using a_object_type, a_object_owner, a_object_type, a_object_owner;
137-
138- return l_result;
139- end;
140-
141105 function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is
142106 l_result sys_refcursor;
143107 l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
@@ -158,12 +122,12 @@ create or replace package body ut_annotation_manager as
158122 on s.name = r.object_name
159123 and s.owner = r.object_owner
160124 and s.type = r.object_type
161- where s.type = :a_object_type
162- and s.owner = :a_object_owner
125+ where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
126+ and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
163127 ) s
164128 where s.is_annotated = 'Y'
165129 order by s.name, s.line]'
166- using a_objects_to_refresh, a_object_type, a_object_owner ;
130+ using a_objects_to_refresh;
167131
168132 return l_result;
169133 end;
@@ -207,7 +171,6 @@ create or replace package body ut_annotation_manager as
207171 l_object_lines.delete;
208172 end if;
209173 close a_sources_cursor;
210- commit;
211174 end;
212175
213176
@@ -257,7 +220,6 @@ create or replace package body ut_annotation_manager as
257220 procedure trigger_obj_annotation_rebuild is
258221 l_sql_text ora_name_list_t;
259222 l_parts binary_integer;
260- l_object_to_parse ut_annotation_obj_cache_info;
261223 l_restricted_users ora_name_list_t;
262224
263225 function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is
@@ -312,8 +274,6 @@ create or replace package body ut_annotation_manager as
312274 return;
313275 end if;
314276
315- l_object_to_parse := ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y');
316-
317277 if ora_sysevent = 'CREATE' then
318278 l_parts := ORA_SQL_TXT(l_sql_text);
319279 build_annot_cache_for_sources(
@@ -324,9 +284,13 @@ create or replace package body ut_annotation_manager as
324284 build_annot_cache_for_sources(
325285 ora_dict_obj_owner, ora_dict_obj_type,
326286 get_source_for_object(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type)
327- );
287+ );
328288 elsif ora_sysevent = 'DROP' then
329- ut_annotation_cache_manager.remove_from_cache(ut_annotation_objs_cache_info(l_object_to_parse));
289+ ut_annotation_cache_manager.remove_from_cache(
290+ ut_annotation_objs_cache_info(
291+ ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y', null)
292+ )
293+ );
330294 end if;
331295 end if;
332296 end;
0 commit comments