From 7d89f1cfad3be799058e5d3827dff00ddbc0a2df Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 08:39:28 +0300 Subject: [PATCH 1/8] addressed #382 addressed #383 --- .travis/install.sh | 6 ++- source/core/coverage/proftab.sql | 65 ++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/.travis/install.sh b/.travis/install.sh index 909361a5a..ddcd9e3c4 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -8,7 +8,11 @@ pwd set feedback off set verify off -@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE +--@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE +@../source/install_headless.sql + +--change the deafult password +alter user $UT3_OWNER identified by $UT3_OWNER_PASSWORD; --needed for Mystats script to work grant select any dictionary to $UT3_OWNER; --Needed for testing a coverage outside ut3_owner. diff --git a/source/core/coverage/proftab.sql b/source/core/coverage/proftab.sql index d8d2d915b..23e098fd0 100644 --- a/source/core/coverage/proftab.sql +++ b/source/core/coverage/proftab.sql @@ -1,4 +1,9 @@ -create table plsql_profiler_runs +declare + l_tab_exist number; +begin + select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_RUNS'; + if l_tab_exist = 0 then + execute immediate q'[create table plsql_profiler_runs ( runid number primary key, -- unique run identifier, -- from plsql_profiler_runnumber @@ -11,12 +16,20 @@ create table plsql_profiler_runs run_system_info varchar2(2047), -- currently unused run_comment1 varchar2(2047), -- additional comment spare1 varchar2(256) -- unused -); +)]'; + execute immediate q'[comment on table plsql_profiler_runs is + 'Run-specific information for the PL/SQL profiler']'; + dbms_output.put_line('PLSQL_PROFILER_RUNS table created'); + end if; +end; +/ -comment on table plsql_profiler_runs is - 'Run-specific information for the PL/SQL profiler'; - -create table plsql_profiler_units +declare + l_tab_exist number; +begin + select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_UNITS'; + if l_tab_exist = 0 then + execute immediate q'[create table plsql_profiler_units ( runid number references plsql_profiler_runs, unit_number number, -- internally generated library unit # @@ -31,12 +44,20 @@ create table plsql_profiler_units spare2 number, -- unused -- primary key (runid, unit_number) -); - -comment on table plsql_profiler_units is - 'Information about each library unit in a run'; +)]'; + execute immediate q'[comment on table plsql_profiler_units is + 'Information about each library unit in a run']'; + dbms_output.put_line('PLSQL_PROFILER_UNITS table created'); + end if; +end; +/ -create table plsql_profiler_data +declare + l_tab_exist number; +begin + select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_DATA'; + if l_tab_exist = 0 then + execute immediate q'[create table plsql_profiler_data ( runid number, -- unique (generated) run identifier unit_number number, -- internally generated library unit # @@ -52,10 +73,22 @@ create table plsql_profiler_data -- primary key (runid, unit_number, line#), foreign key (runid, unit_number) references plsql_profiler_units -); - -comment on table plsql_profiler_data is - 'Accumulated data from all profiler runs'; +)]'; + execute immediate q'[comment on table plsql_profiler_data is + 'Accumulated data from all profiler runs']'; + dbms_output.put_line('PLSQL_PROFILER_DATA table created'); + end if; +end; +/ -create sequence plsql_profiler_runnumber start with 1 nocache; +declare + l_seq_exist number; +begin + select count(*) into l_seq_exist from user_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER'; + if l_seq_exist = 0 then + execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]'; + dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created'); + end if; +end; +/ From 7d6b4b8a2abb99f0e63788c40948866494bbfe79 Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 08:46:28 +0300 Subject: [PATCH 2/8] improved install.sql script --- source/install.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/install.sql b/source/install.sql index 0ccf2a078..ca53f1484 100644 --- a/source/install.sql +++ b/source/install.sql @@ -87,12 +87,12 @@ alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6 @@install_component.sql 'core/ut_expectation_processor.pkb' prompt Installing PLSQL profiler objects into &&ut3_owner schema -prompt You will see "ORA-00955" errors if they already exist -prompt &&line_separator -whenever sqlerror continue -set feedback on +--prompt You will see "ORA-00955" errors if they already exist +--prompt &&line_separator +--whenever sqlerror continue +--set feedback on @@core/coverage/proftab.sql -whenever sqlerror exit failure rollback +--whenever sqlerror exit failure rollback @@install_component.sql 'core/ut_file_mapper.pks' @@install_component.sql 'core/ut_file_mapper.pkb' From 4dbf6e80a6caf066a21655d5c9deb6f17f0f2eef Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 08:48:08 +0300 Subject: [PATCH 3/8] removed exit from install_headless.sql --- source/install_headless.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/install_headless.sql b/source/install_headless.sql index 69513fcd3..36fe8f6a3 100644 --- a/source/install_headless.sql +++ b/source/install_headless.sql @@ -21,5 +21,3 @@ define ut3_tablespace = users @@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace @@install.sql &&ut3_owner @@create_synonyms_and_grants_for_public.sql &&ut3_owner - -exit From 3bd33d1ceeb4ecb58e87dee5e50938f19b2c45f5 Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 09:21:05 +0300 Subject: [PATCH 4/8] fix --- .travis/install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis/install.sh b/.travis/install.sh index ddcd9e3c4..4a319d5bc 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -11,6 +11,7 @@ set verify off --@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE @../source/install_headless.sql +set feedback on --change the deafult password alter user $UT3_OWNER identified by $UT3_OWNER_PASSWORD; --needed for Mystats script to work @@ -18,6 +19,7 @@ grant select any dictionary to $UT3_OWNER; --Needed for testing a coverage outside ut3_owner. grant create any procedure, execute any procedure to $UT3_OWNER; +set feedback off @../source/create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE cd .. @@ -27,10 +29,10 @@ cd .. --@ut_debug_enable.sql --cd .. -cd source -@install.sql $UT3_OWNER -@create_synonyms_and_grants_for_user.sql $UT3_OWNER $UT3_USER -cd .. +--cd source +--@install.sql $UT3_OWNER +--@create_synonyms_and_grants_for_user.sql $UT3_OWNER $UT3_USER +--cd .. cd development conn $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR From f4fd702b3dd325a3bb3dbc1438bedb39b16a2273 Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 10:29:02 +0300 Subject: [PATCH 5/8] took into account that --- source/core/coverage/proftab.sql | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/core/coverage/proftab.sql b/source/core/coverage/proftab.sql index 23e098fd0..05af00fe8 100644 --- a/source/core/coverage/proftab.sql +++ b/source/core/coverage/proftab.sql @@ -1,7 +1,10 @@ declare l_tab_exist number; begin - select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_RUNS'; + select count(*) into l_tab_exist from + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_RUNS' and owner in (user,'PUBLIC') + union all + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNS'); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_runs ( @@ -27,7 +30,10 @@ end; declare l_tab_exist number; begin - select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_UNITS'; + select count(*) into l_tab_exist from + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner in (user,'PUBLIC') + union all + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS'); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_units ( @@ -55,7 +61,10 @@ end; declare l_tab_exist number; begin - select count(*) into l_tab_exist from user_tables where table_name = 'PLSQL_PROFILER_DATA'; + select count(*) into l_tab_exist from + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner in (user,'PUBLIC'); + union all + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_DATA'); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_data ( @@ -84,7 +93,10 @@ end; declare l_seq_exist number; begin - select count(*) into l_seq_exist from user_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER'; + select count(*) into l_seq_exist from + (select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner in (user,'PUBLIC'); + union all + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER'); if l_seq_exist = 0 then execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]'; dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created'); From d0dbccb89d941acb4d3f11b21a269a0418498886 Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 10:30:34 +0300 Subject: [PATCH 6/8] removed commented code --- source/install.sql | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/install.sql b/source/install.sql index ca53f1484..c4907d8f4 100644 --- a/source/install.sql +++ b/source/install.sql @@ -87,12 +87,7 @@ alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6 @@install_component.sql 'core/ut_expectation_processor.pkb' prompt Installing PLSQL profiler objects into &&ut3_owner schema ---prompt You will see "ORA-00955" errors if they already exist ---prompt &&line_separator ---whenever sqlerror continue ---set feedback on @@core/coverage/proftab.sql ---whenever sqlerror exit failure rollback @@install_component.sql 'core/ut_file_mapper.pks' @@install_component.sql 'core/ut_file_mapper.pkb' From a8a00936a0974b9b461f35ffbfe33353672ecbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Mon, 3 Jul 2017 17:26:21 +0100 Subject: [PATCH 7/8] Update proftab.sql Fixed syntax errors. Fixed bug when deploying to different user schema --- source/core/coverage/proftab.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/core/coverage/proftab.sql b/source/core/coverage/proftab.sql index 05af00fe8..0cf59bc69 100644 --- a/source/core/coverage/proftab.sql +++ b/source/core/coverage/proftab.sql @@ -2,9 +2,9 @@ declare l_tab_exist number; begin select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_RUNS' and owner in (user,'PUBLIC') + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNS'); + select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_runs ( @@ -31,9 +31,9 @@ declare l_tab_exist number; begin select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner in (user,'PUBLIC') + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS'); + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_units ( @@ -62,9 +62,9 @@ declare l_tab_exist number; begin select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner in (user,'PUBLIC'); + (select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_DATA'); + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_data ( @@ -94,9 +94,9 @@ declare l_seq_exist number; begin select count(*) into l_seq_exist from - (select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner in (user,'PUBLIC'); + (select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER'); + select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_seq_exist = 0 then execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]'; dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created'); From 766af11c7f474a2b085cb9ce18bfb45bc02ed704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Mon, 3 Jul 2017 17:36:17 +0100 Subject: [PATCH 8/8] Update proftab.sql --- source/core/coverage/proftab.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/core/coverage/proftab.sql b/source/core/coverage/proftab.sql index 0cf59bc69..ad0caa458 100644 --- a/source/core/coverage/proftab.sql +++ b/source/core/coverage/proftab.sql @@ -33,7 +33,7 @@ begin select count(*) into l_tab_exist from (select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); + select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_units ( @@ -64,7 +64,7 @@ begin select count(*) into l_tab_exist from (select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA')); + select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[create table plsql_profiler_data ( @@ -96,7 +96,7 @@ begin select count(*) into l_seq_exist from (select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA') union all - select synonym_name from user_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER' and owner = sys_context('USERENV','CURRENT_SCHEMA')); + select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_seq_exist = 0 then execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]'; dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created');