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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
36a061c
Removed parsing of annotation text (params) from ut_annotations as an…
jgebal Oct 6, 2017
a29cabe
Removed duplicate `old_tests` for ut_annotations - the functionality …
jgebal Oct 6, 2017
58c6293
Renamed `ut_annotations` to `ut_annotation_parser` and moved to annot…
jgebal Oct 7, 2017
375a7ff
Removed ``ut_annotations` from uninstall script.
jgebal Oct 7, 2017
13703fa
Fixed failing old tests after refactoring.
jgebal Oct 7, 2017
ac23f15
Refactored ut_annotation_parser API to use `ut_annotations` collectio…
jgebal Oct 7, 2017
df2c763
Added cache mechanism to `ut_annotation_parser`.
jgebal Oct 8, 2017
6088c81
Added ability to get annotations for single object.
jgebal Oct 9, 2017
4ec9eb5
Reworking annotation cache - not to use cast(Collect()) on dba_source.
jgebal Oct 13, 2017
dbf2538
Fixed failing test and test for Wrapped package.
jgebal Oct 14, 2017
ca31e98
Added missing annotation manager.
jgebal Oct 14, 2017
289f006
Removed dbms_output from code.
jgebal Oct 14, 2017
8e26ed0
Merge remote-tracking branch 'upstream/develop' into feature/annotati…
jgebal Oct 14, 2017
239abde
Add grant ut_annotation_manager to public
pesse Oct 16, 2017
6acd2ad
Add grant ut_annotation_manager to ut3_user
pesse Oct 16, 2017
e114aae
Merge branch 'develop' into feature/annotations_restructuring
jgebal Oct 17, 2017
b83e142
Fixed hardcoded schema-name
jgebal Oct 18, 2017
6dcaae9
Merge remote-tracking branch 'upstream/develop' into feature/annotati…
jgebal Oct 18, 2017
aafca84
Refactored annotation cache.
jgebal Oct 22, 2017
cd394c7
Fixed test execution on 12.1.
jgebal Oct 23, 2017
73c15a2
Merge remote-tracking branch 'upstream/develop' into feature/annotati…
jgebal Oct 23, 2017
5967a3a
Fixed test execution on 12.1.
jgebal Oct 23, 2017
1438753
Merge branch 'develop' into feature/annotations_restructuring
jgebal Oct 24, 2017
4f5d870
Merge conflicts cleanup
jgebal Oct 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reworking annotation cache - not to use cast(Collect()) on dba_source.
Added filtering of dba_source by test containing annotations.
Added cardinality hint with scaling.
Removed public procedure `config_package` - used only for one unit test.
Fixed naming of procedures.
Performance improvements on collections.
  • Loading branch information
jgebal committed Oct 14, 2017
commit 4ec9eb594af2eaec961e90a9ab0b6773b251ef0b
5 changes: 3 additions & 2 deletions development/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ drop user ${UT3_USER} cascade;
begin
for i in (
select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym from dba_synonyms a
where not exists (select null from dba_objects b where a.table_name=b.object_name and a.table_owner=b.owner )
and a.table_owner <> 'SYS'
where not exists (select 1 from dba_objects b where (a.table_name=b.object_name and a.table_owner=b.owner or b.owner='SYS' and a.table_owner=b.object_name) )
and a.table_owner not in ('SYS','SYSTEM')
) loop
dbms_output.put_line(i.drop_orphaned_synonym);
execute immediate i.drop_orphaned_synonym;
end loop;
end;
Expand Down
12 changes: 0 additions & 12 deletions examples/demo_of_expectations/demo_equal_matcher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ create or replace package demo_equal_matcher as
-- %displayname(Gives success when comparing null actual to a null expected)
procedure object_compare_null_both_ok;

-- %test
-- %displayname(Gives failure when comparing null actual to a null expected, setting null equal to false)
procedure object_compare_null_both_fail;

-- %test
-- %displayname(Gives failure when comparing identical objects containing different data)
procedure object_compare_different_data;
Expand Down Expand Up @@ -94,14 +90,6 @@ create or replace package body demo_equal_matcher as
ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected));
end;

procedure object_compare_null_both_fail is
l_expected demo_department;
l_actual demo_department;
begin
ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected),false);
end;


procedure object_compare_different_data is
l_expected demo_department;
l_actual demo_department;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set echo off
@@tst_pkg_huge.pks

declare
l_suite ut_logical_suite;
l_suites ut_suite_items;
begin
l_suite := ut_suite_manager.config_package(a_owner_name => USER,a_object_name => 'TST_PKG_HUGE');
l_suites := ut_suite_manager.configure_execution_by_path(USER||'.TST_PKG_HUGE');
end;
/

Expand Down
2 changes: 2 additions & 0 deletions old_tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ begin
'source/core/types',
'source/core/annotations/ut_annotation_parser.pkb',
'source/core/annotations/ut_annotation_parser.pks',
'source/core/annotations/ut_annotation_cache_manager.pkb',
'source/core/annotations/ut_annotation_cache_manager.pks',
'source/core/ut_expectation_processor.pkb',
'source/core/ut_expectation_processor.pks',
'source/core/ut_file_mapper.pkb',
Expand Down
16 changes: 16 additions & 0 deletions source/core/annotations/ut_annotated_object.tps
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
create type ut_annotated_object as object(
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
object_owner varchar2(250),
object_name varchar2(250),
object_type varchar2(50),
Expand Down
19 changes: 18 additions & 1 deletion source/core/annotations/ut_annotated_objects.tps
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
create type ut_annotated_objects as table of ut_annotated_object
create type ut_annotated_objects as
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
table of ut_annotated_object
/

16 changes: 16 additions & 0 deletions source/core/annotations/ut_annotation.tps
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
create type ut_annotation as object(
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
position number(5,0),
name varchar2(1000),
text varchar2(4000),
Expand Down
15 changes: 13 additions & 2 deletions source/core/annotations/ut_annotation_cache.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
create table ut_annotation_cache (
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
cache_id number(20,0) not null,
annotation_position number(5,0) not null,
annotation_name varchar2(1000) not null,
annotation_text varchar2(4000),
subobject_name varchar2(250),
-- subobject_name_not_null varchar2(250) generated always as (nvl(subobject_name,'null')) not null,
constraint ut_annotation_cache_pk primary key(cache_id, annotation_position),
-- constraint ut_annotation_cache_pk primary key(cache_id, annotation_position, subobject_name_not_null),
constraint ut_annotation_cache_fk foreign key(cache_id) references ut_annotation_cache_info(cache_id) on delete cascade
);

Expand Down
17 changes: 14 additions & 3 deletions source/core/annotations/ut_annotation_cache_info.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
create table ut_annotation_cache_info (
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
cache_id number(20,0) not null,
object_owner varchar2(250) not null,
object_name varchar2(250) not null,
object_type varchar2(250) not null,
parse_time date not null,
is_annotated varchar2(1) not null,
constraint ut_annotation_cache_info_pk primary key(cache_id),
constraint ut_annotation_cache_info_uk unique (object_owner, object_name, object_type),
constraint ut_annotation_cache_info_ck1 check (is_annotated in ('Y','N'))
constraint ut_annotation_cache_info_uk unique (object_owner, object_name, object_type)
) organization index;

93 changes: 74 additions & 19 deletions source/core/annotations/ut_annotation_cache_manager.pkb
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
create or replace package body ut_annotation_cache_manager as
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

procedure update_cache(a_object ut_annotated_object, a_cache_id integer) is
l_is_annotated varchar2(1);
v_cache_id integer := a_cache_id;
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

procedure update_cache(a_object ut_annotated_object) is
v_cache_id integer;
l_current_schema varchar2(250) := ut_utils.ut_owner;
pragma autonomous_transaction;
begin
if a_object.annotations is not null and a_object.annotations.count > 0 then
l_is_annotated := 'Y';
else
l_is_annotated := 'N';
end if;

if v_cache_id is not null then
update ut_annotation_cache_info i
set i.parse_time = sysdate,
i.is_annotated = l_is_annotated
where i.cache_id = v_cache_id;
else
update ut_annotation_cache_info i
set i.parse_time = sysdate
where (i.object_owner, i.object_name, i.object_type)
in ((a_object.object_owner, a_object.object_name, a_object.object_type))
returning cache_id into v_cache_id;
if sql%rowcount = 0 then
insert into ut_annotation_cache_info
(cache_id, object_owner, object_name, object_type, parse_time, is_annotated)
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, sysdate, l_is_annotated)
(cache_id, object_owner, object_name, object_type, parse_time)
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, sysdate)
returning cache_id into v_cache_id;
end if;

delete from ut_annotation_cache c
where cache_id = v_cache_id;

if l_is_annotated = 'Y' then
if a_object.annotations is not null and a_object.annotations.count > 0 then
-- begin
insert into ut_annotation_cache
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
Expand All @@ -43,5 +52,51 @@ create or replace package body ut_annotation_cache_manager as
commit;
end;

end;

procedure cleanup_cache(a_objects ut_annotation_cached_objects) is
pragma autonomous_transaction;
begin

delete from ut_annotation_cache c
where c.cache_id
in (select i.cache_id
from ut_annotation_cache_info i
join table (a_objects) o
using (object_name, object_type, object_owner)
);

merge into ut_annotation_cache_info i
using (select o.object_name, o.object_type, o.object_owner
from table(a_objects) o ) o
on (o.object_name = i.object_name
and o.object_type = i.object_type
and o.object_owner = i.object_owner)
when matched then update set parse_time = sysdate
when not matched then insert
(cache_id, object_owner, object_name, object_type, parse_time)
values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, sysdate);

commit;
end;

function get_annotations_for_objects(a_cached_objects ut_annotation_cached_objects) return sys_refcursor is
l_results sys_refcursor;
begin
open l_results for
select ut_annotated_object(
o.object_owner, o.object_name, o.object_type,
cast(
collect(
ut_annotation(
c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name
) order by c.annotation_position
) as ut_annotations
)
)
from table(a_cached_objects) o
join ut_annotation_cache c on o.cache_id = c.cache_id
group by o.object_owner, o.object_name, o.object_type;
return l_results;
end;
end ut_annotation_cache_manager;
/
22 changes: 21 additions & 1 deletion source/core/annotations/ut_annotation_cache_manager.pks
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
create or replace package ut_annotation_cache_manager authid definer as
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

procedure update_cache(a_object ut_annotated_object, a_cache_id integer);
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

procedure update_cache(a_object ut_annotated_object);

function get_annotations_for_objects(a_cached_objects ut_annotation_cached_objects) return sys_refcursor;

procedure cleanup_cache(a_objects ut_annotation_cached_objects);

end;
/
18 changes: 16 additions & 2 deletions source/core/annotations/ut_annotation_cache_seq.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
create sequence ut_annotation_cache_seq cache 20
/
create sequence ut_annotation_cache_seq
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
cache 20;

24 changes: 24 additions & 0 deletions source/core/annotations/ut_annotation_cached_object.tps
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
create type ut_annotation_cached_object as object(
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
object_owner varchar2(250),
object_name varchar2(250),
object_type varchar2(250),
needs_refresh varchar2(1),
cache_id number(20,0)
)
/
19 changes: 19 additions & 0 deletions source/core/annotations/ut_annotation_cached_objects.tps
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create type ut_annotation_cached_objects as
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
table of ut_annotation_cached_object
/
Loading