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

Skip to content

Commit f1ee7ad

Browse files
committed
Fixed performance issues for 12.1 and 12.2 with source parsing using dbms_preprocessor
1 parent 0213cdc commit f1ee7ad

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

source/core/ut_metadata.pkb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,20 @@ create or replace package body ut_metadata as
116116
end;
117117

118118
function get_package_spec_source(a_owner varchar2, a_object_name varchar2) return clob is
119-
l_lines sys.dbms_preprocessor.source_lines_t;
120-
l_source clob;
119+
l_lines sys.dbms_preprocessor.source_lines_t;
120+
l_cursor sys_refcursor;
121+
l_source clob;
122+
l_view_name varchar2(128) := get_dba_view('dba_source');
121123
begin
122-
begin
123-
l_lines := sys.dbms_preprocessor.get_post_processed_source(object_type => 'PACKAGE',
124-
schema_name => a_owner,
125-
object_name => a_object_name);
126-
127-
for i in 1..l_lines.count loop
128-
ut_utils.append_to_clob(l_source, l_lines(i));
129-
end loop;
130-
131-
end;
124+
open l_cursor for 'select text from '||l_view_name||q'[ s
125+
where s.owner = :a_owner and s.name = :a_object_name and s.type = 'PACKAGE'
126+
order by s.line]' using upper(a_owner), upper(a_object_name);
127+
fetch l_cursor bulk collect into l_lines;
128+
-- we fetch the source explicitly as dbms_preprocessor is very sow on 12.1 and 12.2 when grabbing the sources.
129+
l_lines := sys.dbms_preprocessor.get_post_processed_source(l_lines);
130+
for i in 1..l_lines.count loop
131+
ut_utils.append_to_clob(l_source, l_lines(i));
132+
end loop;
132133
return l_source;
133134
end;
134135

0 commit comments

Comments
 (0)