Skip to content

Commit

Permalink
- removed grants to ut_suite_cache
Browse files Browse the repository at this point in the history
- changed `dbmspcc_...` tables to be global temporary
- added cleanup of session level global temp tables after run
  • Loading branch information
jgebal committed Jun 28, 2019
1 parent 41c007c commit 6f0a939
Show file tree
Hide file tree
Showing 19 changed files with 528 additions and 576 deletions.
4 changes: 2 additions & 2 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ create or replace package body ut_runner is

procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is
begin
ut_utils.cleanup_temp_tables;
ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run);
ut_metadata.reset_source_definition_cache;
ut_utils.read_cache_to_dbms_output();
ut_coverage_helper.cleanup_tmp_table();
ut_compound_data_helper.cleanup_diff();
if not a_force_manual_rollback then
rollback;
ut_utils.cleanup_session_temp_tables;
end if;
end;

Expand Down Expand Up @@ -196,7 +196,7 @@ create or replace package body ut_runner is
function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is
l_cursor sys_refcursor;
l_results ut_suite_items_info;
c_bulk_limit constant integer := 10;
c_bulk_limit constant integer := 100;
begin
l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name );
loop
Expand Down
2 changes: 1 addition & 1 deletion source/api/ut_suite_item_info.tps
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ create or replace type ut_suite_item_info as object (
object_owner varchar2( 250 ), -- the owner of test suite packages
object_name varchar2( 250 ), -- the name of test suite package
item_name varchar2( 250 ), -- the name of suite/test
item_description varchar2( 250 ), -- the description of suite/suite item
item_description varchar2( 4000 ), -- the description of suite/suite item
item_type varchar2( 250 ), -- the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST)
item_line_no integer, -- line_number where annotation identifying the item exists
path varchar2( 4000 ),-- suitepath of the item
Expand Down
6 changes: 2 additions & 4 deletions source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ create or replace package body ut_annotation_manager as
limitations under the License.
*/

gc_max_objects_limit integer := 1000000;
------------------------------
--private definitions

Expand Down Expand Up @@ -46,7 +45,7 @@ create or replace package body ut_annotation_manager as
and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
)]';
open l_rows for l_cursor_text using l_data;
fetch l_rows bulk collect into l_result limit gc_max_objects_limit;
fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit;
close l_rows;
return l_result;
end;
Expand Down Expand Up @@ -96,7 +95,7 @@ create or replace package body ut_annotation_manager as
else 'o.last_ddl_time >= cast(:a_parse_date as date)'
end;
open l_rows for l_cursor_text using l_data, a_parse_date;
fetch l_rows bulk collect into l_result limit gc_max_objects_limit;
fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit;
close l_rows;
end if;
ut_event_manager.trigger_event('get_annotation_objs_info - end (count='||l_result.count||')');
Expand Down Expand Up @@ -172,7 +171,6 @@ create or replace package body ut_annotation_manager as
l_object_lines.delete;
end if;
close a_sources_cursor;
commit;
end;


Expand Down
144 changes: 24 additions & 120 deletions source/core/coverage/dbms_plssqlcode.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,21 @@ begin
select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
if l_tab_exist = 0 then
execute immediate q'[
create table dbmspcc_blocks (
create global temporary table dbmspcc_blocks (
run_id number(38, 0),
object_id number(38, 0),
block number(38, 0),
line number(38, 0),
col number(38, 0),
covered number(1, 0),
not_feasible number(1, 0)
)]';
execute immediate q'[
create unique index dbmspcc_blocks_pk on
dbmspcc_blocks (
run_id,
object_id,
block
)]';
execute immediate q'[
alter table dbmspcc_blocks modify (
line
constraint dbmspcc_blocks_line_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_blocks modify (
col
constraint dbmspcc_blocks_col_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_blocks modify (
covered
constraint dbmspcc_blocks_covered_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_blocks modify (
not_feasible
constraint dbmspcc_blocks_not_feasible_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_covered_ck check ( covered in (
0,
1
) ) enable]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in (
0,
1
) ) enable]';
execute immediate q'[
alter table dbmspcc_blocks
add constraint dbmspcc_blocks_pk primary key ( run_id,
object_id,
block )
using index enable]';
line number(38, 0) constraint dbmspcc_blocks_line_nn not null enable,
col number(38, 0) constraint dbmspcc_blocks_col_nn not null enable,
covered number(1, 0) constraint dbmspcc_blocks_covered_nn not null enable,
not_feasible number(1, 0) constraint dbmspcc_blocks_not_feasible_nn not null enable,
constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable,
constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable,
constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable,
constraint dbmspcc_blocks_covered_ck check ( covered in ( 0, 1 ) ) enable,
constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( 0, 1 ) ) enable,
constraint dbmspcc_blocks_pk primary key ( run_id, object_id, block ) using index
) on commit preserve rows]';
end if;
end;
/
Expand All @@ -82,31 +34,13 @@ begin
select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
if l_tab_exist = 0 then
execute immediate q'[
create table dbmspcc_runs (
create global temporary table dbmspcc_runs (
run_id number(38, 0),
run_comment varchar2(4000 byte),
run_owner varchar2(128 byte),
run_timestamp date
)]';
execute immediate q'[
create unique index dbmspcc_runs_pk on
dbmspcc_runs (
run_id
)]';
execute immediate q'[
alter table dbmspcc_runs modify (
run_owner
constraint dbmspcc_runs_run_owner_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_runs modify (
run_timestamp
constraint dbmspcc_runs_run_timestamp_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_runs
add constraint dbmspcc_runs_pk primary key ( run_id )
using index enable]';
run_owner varchar2(128 byte) constraint dbmspcc_runs_run_owner_nn not null enable,
run_timestamp date constraint dbmspcc_runs_run_timestamp_nn not null enable,
constraint dbmspcc_runs_pk primary key ( run_id ) using index enable
) on commit preserve rows]';
end if;
end;
/
Expand All @@ -119,45 +53,15 @@ begin
select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
if l_tab_exist = 0 then
execute immediate q'[
create table dbmspcc_units (
create global temporary table dbmspcc_units (
run_id number(38, 0),
object_id number(38, 0),
owner varchar2(128 byte),
name varchar2(128 byte),
type varchar2(12 byte),
last_ddl_time date
)]';
execute immediate q'[
create unique index dbmspcc_units_pk on
dbmspcc_units (
run_id,
object_id
)]';
execute immediate q'[
alter table dbmspcc_units modify (
owner
constraint dbmspcc_units_owner_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_units modify (
name
constraint dbmspcc_units_name_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_units modify (
type
constraint dbmspcc_units_type_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_units modify (
last_ddl_time
constraint dbmspcc_units_last_ddl_time_nn not null enable
)]';
execute immediate q'[
alter table dbmspcc_units
add constraint dbmspcc_units_pk primary key ( run_id,
object_id )
using index enable]';
owner varchar2(128 byte) constraint dbmspcc_units_owner_nn not null enable,
name varchar2(128 byte) constraint dbmspcc_units_name_nn not null enable,
type varchar2(12 byte) constraint dbmspcc_units_type_nn not null enable,
last_ddl_time date constraint dbmspcc_units_last_ddl_time_nn not null enable,
constraint dbmspcc_units_pk primary key ( run_id, object_id ) using index enable
) on commit preserve rows]';
end if;
end;
/
4 changes: 0 additions & 4 deletions source/core/coverage/ut_coverage.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ create or replace package body ut_coverage is
l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp);
begin
if not is_develop_mode() and not g_is_started then
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
ut_coverage_helper_block.coverage_start( l_run_comment, g_coverage_id(gc_block_coverage) );
$end
ut_coverage_helper_profiler.coverage_start( l_run_comment, g_coverage_id(gc_proftab_coverage) );
coverage_pause();
g_is_started := true;
Expand Down Expand Up @@ -200,9 +198,7 @@ create or replace package body ut_coverage is
begin
if not is_develop_mode() then
g_is_started := false;
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
ut_coverage_helper_block.coverage_stop();
$end
ut_coverage_helper_profiler.coverage_stop();
g_is_started := false;
end if;
Expand Down
1 change: 0 additions & 1 deletion source/core/coverage/ut_coverage_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ create or replace package body ut_coverage_helper is
pragma autonomous_transaction;
begin
execute immediate 'truncate table ut_coverage_sources_tmp';
commit;
end;

function is_tmp_table_populated return boolean is
Expand Down
22 changes: 9 additions & 13 deletions source/core/coverage/ut_coverage_helper_block.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ create or replace package body ut_coverage_helper_block is
end;

function block_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_block_rows is
l_raw_coverage sys_refcursor;
l_coverage_rows t_block_rows;
l_ut3_owner varchar2(128) := ut_utils.ut_owner();
begin

open l_raw_coverage for 'select ccb.line
,count(ccb.block) totalblocks
,sum(ccb.covered)
select ccb.line as line,
count(ccb.block) as blocks,
sum(ccb.covered) as covered_blocks
bulk collect into l_coverage_rows
from dbmspcc_units ccu
left outer join dbmspcc_blocks ccb
on ccu.run_id = ccb.run_id
and ccu.object_id = ccb.object_id
where ccu.run_id = :a_coverage_id
and ccu.owner = :a_object_owner
and ccu.name = :a_object_name
where ccu.run_id = a_coverage_id
and ccu.owner = a_object_owner
and ccu.name = a_object_name
group by ccb.line
order by 1' using a_coverage_id,a_object_owner,a_object_name;
order by 1;

fetch l_raw_coverage bulk collect into l_coverage_rows;
close l_raw_coverage;

return l_coverage_rows;
return l_coverage_rows;
end;

function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is
Expand Down
40 changes: 40 additions & 0 deletions source/core/types/ut_suite_cache_row.tps
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
create type ut_suite_cache_row as object (
/*
utPLSQL - Version 3
Copyright 2016 - 2019 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.
*/
id number(22,0),
self_type varchar2(250 byte),
path varchar2(1000 byte),
object_owner varchar2(250 byte),
object_name varchar2(250 byte),
name varchar2(250 byte),
line_no number,
parse_time timestamp (6),
description varchar2(4000 byte),
rollback_type number,
disabled_flag number,
warnings ut_varchar2_rows,
before_all_list ut_executables,
after_all_list ut_executables,
before_each_list ut_executables,
before_test_list ut_executables,
after_each_list ut_executables,
after_test_list ut_executables,
expected_error_codes ut_integer_list,
tags ut_varchar2_rows,
item ut_executable_test
)
/
19 changes: 19 additions & 0 deletions source/core/types/ut_suite_cache_rows.tps
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create type ut_suite_cache_rows as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 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_suite_cache_row
/

0 comments on commit 6f0a939

Please sign in to comment.