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

Skip to content

Commit 61066a9

Browse files
authored
Merge pull request #660 from pocelka/bugfix/non_sysdba_install
Bugfix/non sysdba install
2 parents 37ed91f + 6a79ade commit 61066a9

5 files changed

Lines changed: 237 additions & 95 deletions

File tree

docs/userguide/install.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ Example invocation:
135135
cd source
136136
sqlplus admin/admins_password@database @create_synonyms_and_grants_for_public.sql ut3
137137
```
138-
To grant utPLSQL to an individual user, execute script `source/create_synonyms_and_grants_for_user.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for.
138+
To grant utPLSQL to an individual user, execute scripts `source/create_user_grants.sql` and `source/create_user_synonyms.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for.
139139

140140
Example invocation:
141141
```bash
142142
cd source
143-
sqlplus admin/admins_password@database @create_synonyms_and_grants_for_user.sql ut3 hr
143+
sqlplus ut3_user/ut3_password@database @create_user_grants.sql ut3 hr
144+
sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr
144145
```
145146

146147
The following tools that support the SQL*Plus commands can be used to run the installation script:
Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1-
create global temporary table ut_dbms_output_cache(
2-
/*
3-
utPLSQL - Version 3
4-
Copyright 2016 - 2017 utPLSQL Project
5-
Licensed under the Apache License, Version 2.0 (the "License"):
6-
you may not use this file except in compliance with the License.
7-
You may obtain a copy of the License at
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
Unless required by applicable law or agreed to in writing, software
10-
distributed under the License is distributed on an "AS IS" BASIS,
11-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
See the License for the specific language governing permissions and
13-
limitations under the License.
14-
*/
15-
/*
16-
* This table is not a global temporary table as it needs to allow cross-session data exchange
17-
* It is used however as a temporary table with multiple writers.
18-
* This is why it has very high initrans and has nologging
19-
*/
20-
seq_no number(20,0) not null,
21-
text varchar2(4000),
22-
constraint ut_dbms_output_cache_pk primary key(seq_no)
23-
) on commit preserve rows;
1+
/*
2+
utPLSQL - Version 3
3+
Copyright 2016 - 2017 utPLSQL Project
4+
Licensed under the Apache License, Version 2.0 (the "License"):
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
/*
15+
* This table is not a global temporary table as it needs to allow cross-session data exchange
16+
* It is used however as a temporary table with multiple writers.
17+
* This is why it has very high initrans and has nologging
18+
*/
19+
declare
20+
l_tab_exist number;
21+
begin
22+
select count(*) into l_tab_exist from
23+
(select table_name from all_tables where table_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA')
24+
union all
25+
select synonym_name from all_synonyms where synonym_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
26+
if l_tab_exist = 0 then
27+
28+
execute immediate q'[create global temporary table ut_dbms_output_cache
29+
(
30+
seq_no number(20,0) not null,
31+
text varchar2(4000),
32+
constraint ut_dbms_output_cache_pk primary key(seq_no)
33+
) on commit preserve rows
34+
]';
35+
36+
end if;
37+
end;
38+
/

source/create_user_grants.sql

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
utPLSQL - Version 3
3+
Copyright 2016 - 2017 utPLSQL Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"):
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework
18+
*/
19+
20+
@@define_ut3_owner_param.sql
21+
22+
column 2 new_value 2 noprint
23+
select null as "2" from dual where 1=0;
24+
spool params.sql.tmp
25+
select
26+
case
27+
when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema to which should be granted the utPLSQL v3 ']'
28+
else 'define ut3_user=&&2'
29+
end
30+
from dual;
31+
spool off
32+
set termout on
33+
@params.sql.tmp
34+
set termout off
35+
/* cleanup temporary sql files */
36+
--try running on windows
37+
$ del params.sql.tmp
38+
--try running on linux/unix
39+
! rm params.sql.tmp
40+
set termout on
41+
42+
set echo off
43+
set feedback on
44+
set heading off
45+
set verify off
46+
47+
prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user
48+
49+
whenever sqlerror exit failure rollback
50+
whenever oserror exit failure rollback
51+
52+
alter session set current_schema = &&ut3_owner;
53+
54+
grant execute on &&ut3_owner..ut_be_between to &ut3_user;
55+
grant execute on &&ut3_owner..ut_be_empty to &ut3_user;
56+
grant execute on &&ut3_owner..ut_be_false to &ut3_user;
57+
grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user;
58+
grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user;
59+
grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user;
60+
grant execute on &&ut3_owner..ut_be_less_than to &ut3_user;
61+
grant execute on &&ut3_owner..ut_be_like to &ut3_user;
62+
grant execute on &&ut3_owner..ut_be_not_null to &ut3_user;
63+
grant execute on &&ut3_owner..ut_be_null to &ut3_user;
64+
grant execute on &&ut3_owner..ut_be_true to &ut3_user;
65+
grant execute on &&ut3_owner..ut_equal to &ut3_user;
66+
grant execute on &&ut3_owner..ut_have_count to &ut3_user;
67+
grant execute on &&ut3_owner..ut_match to &ut3_user;
68+
grant execute on &&ut3_owner..ut to &ut3_user;
69+
grant execute on &&ut3_owner..ut_runner to &ut3_user;
70+
grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user;
71+
grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user;
72+
grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user;
73+
grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user;
74+
grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user;
75+
grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user;
76+
grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user;
77+
grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user;
78+
grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user;
79+
grant execute on &&ut3_owner..ut_reporters to &ut3_user;
80+
grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user;
81+
grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user;
82+
grant execute on &&ut3_owner..ut_integer_list to &ut3_user;
83+
grant execute on &&ut3_owner..ut_reporter_base to &ut3_user;
84+
grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user;
85+
grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user;
86+
grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user;
87+
grant execute on &&ut3_owner..ut_coverage to &ut3_user;
88+
grant execute on &&ut3_owner..ut_coverage_options to &ut3_user;
89+
grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user;
90+
grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user;
91+
grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user;
92+
grant execute on &&ut3_owner..ut_file_mappings to &ut3_user;
93+
grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
94+
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
95+
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
96+
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
97+
grant select, insert, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user;
98+
grant select, insert, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user;
99+
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
100+
grant execute on &&ut3_owner..ut_annotations to &ut3_user;
101+
grant execute on &&ut3_owner..ut_annotation to &ut3_user;
102+
grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user;
103+
grant execute on &&ut3_owner..ut_annotated_object to &ut3_user;
104+
grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user;
105+
grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user;
106+
grant select on &&ut3_owner..ut_annotation_cache to &ut3_user;
107+
grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user;
108+
grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user;
109+
grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user;
110+
grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user;
111+
begin
112+
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
113+
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user';
114+
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user';
115+
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user';
116+
$else
117+
null;
118+
$end
119+
end;
120+
/

source/create_synonyms_and_grants_for_user.sql renamed to source/create_user_synonyms.sql

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -51,75 +51,6 @@ whenever oserror exit failure rollback
5151

5252
alter session set current_schema = &&ut3_owner;
5353

54-
grant execute on &&ut3_owner..ut_be_between to &ut3_user;
55-
grant execute on &&ut3_owner..ut_be_empty to &ut3_user;
56-
grant execute on &&ut3_owner..ut_be_false to &ut3_user;
57-
grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user;
58-
grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user;
59-
grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user;
60-
grant execute on &&ut3_owner..ut_be_less_than to &ut3_user;
61-
grant execute on &&ut3_owner..ut_be_like to &ut3_user;
62-
grant execute on &&ut3_owner..ut_be_not_null to &ut3_user;
63-
grant execute on &&ut3_owner..ut_be_null to &ut3_user;
64-
grant execute on &&ut3_owner..ut_be_true to &ut3_user;
65-
grant execute on &&ut3_owner..ut_equal to &ut3_user;
66-
grant execute on &&ut3_owner..ut_have_count to &ut3_user;
67-
grant execute on &&ut3_owner..ut_match to &ut3_user;
68-
grant execute on &&ut3_owner..ut to &ut3_user;
69-
grant execute on &&ut3_owner..ut_runner to &ut3_user;
70-
grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user;
71-
grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user;
72-
grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user;
73-
grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user;
74-
grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user;
75-
grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user;
76-
grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user;
77-
grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user;
78-
grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user;
79-
grant execute on &&ut3_owner..ut_reporters to &ut3_user;
80-
grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user;
81-
grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user;
82-
grant execute on &&ut3_owner..ut_integer_list to &ut3_user;
83-
grant execute on &&ut3_owner..ut_reporter_base to &ut3_user;
84-
grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user;
85-
grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user;
86-
grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user;
87-
grant execute on &&ut3_owner..ut_coverage to &ut3_user;
88-
grant execute on &&ut3_owner..ut_coverage_options to &ut3_user;
89-
grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user;
90-
grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user;
91-
grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user;
92-
grant execute on &&ut3_owner..ut_file_mappings to &ut3_user;
93-
grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
94-
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
95-
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
96-
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
97-
grant select, insert, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user;
98-
grant select, insert, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user;
99-
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
100-
grant execute on &&ut3_owner..ut_annotations to &ut3_user;
101-
grant execute on &&ut3_owner..ut_annotation to &ut3_user;
102-
grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user;
103-
grant execute on &&ut3_owner..ut_annotated_object to &ut3_user;
104-
grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user;
105-
grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user;
106-
grant select on &&ut3_owner..ut_annotation_cache to &ut3_user;
107-
grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user;
108-
grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user;
109-
grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user;
110-
grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user;
111-
begin
112-
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
113-
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user';
114-
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user';
115-
execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user';
116-
$else
117-
null;
118-
$end
119-
end;
120-
/
121-
122-
12354
prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3_user
12455

12556
create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between;

source/uninstall.sql

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ drop type ut_output_buffer_base force;
242242

243243
drop view ut_output_buffer_tmp;
244244

245-
drop table ut_output_buffer_tmp$;
245+
drop table ut_output_buffer_tmp$ purge;
246246

247247
drop view ut_output_buffer_info_tmp;
248248

@@ -274,6 +274,16 @@ drop type ut_varchar2_list force;
274274

275275
drop type ut_varchar2_rows force;
276276

277+
drop package ut_coverage_profiler;
278+
279+
drop package ut_compound_data_helper;
280+
281+
drop package ut_coverage_helper_profiler;
282+
283+
drop type ut_have_count;
284+
285+
drop type ut_compound_data_value;
286+
277287
set echo off
278288
set feedback off
279289
declare
@@ -304,6 +314,71 @@ begin
304314
dbms_output.put_line(i||' synonyms dropped');
305315
end;
306316
/
317+
318+
declare
319+
i integer := 0;
320+
begin
321+
dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner'));
322+
for syn in (
323+
select
324+
case when owner = 'PUBLIC' then 'public synonym '
325+
else 'synonym ' || owner || '.'
326+
end || synonym_name as syn_name,
327+
table_owner || '.' || table_name as for_object
328+
from all_synonyms s
329+
where 1 = 1
330+
and table_owner = upper('&&ut3_owner')
331+
and synonym_name in ('DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS')
332+
)
333+
loop
334+
335+
begin
336+
337+
execute immediate 'drop '||syn.syn_name;
338+
sys.dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object);
339+
340+
i := i + 1;
341+
exception
342+
when others then
343+
sys.dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object);
344+
end;
345+
end loop;
346+
sys.dbms_output.put_line('&&line_separator');
347+
sys.dbms_output.put_line(i||' synonyms dropped');
348+
end;
349+
/
350+
351+
declare
352+
i integer := 0;
353+
begin
354+
sys.dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner'));
355+
356+
for pkg in (select object_name, owner
357+
from all_objects
358+
where 1 = 1
359+
and owner = upper('&&ut3_owner')
360+
and object_type = 'PACKAGE'
361+
and object_name in ('UT_COVERAGE_HELPER_BLOCK','UT_COVERAGE_BLOCK'))
362+
loop
363+
364+
begin
365+
execute immediate 'drop package ' || pkg.owner || '.' || pkg.object_name;
366+
367+
sys.dbms_output.put_line('Dropped '|| pkg.object_name);
368+
i := i + 1;
369+
370+
exception
371+
when others then
372+
dbms_output.put_line('FAILED to drop ' || pkg.object_name);
373+
end;
374+
375+
end loop;
376+
377+
sys.dbms_output.put_line('&&line_separator');
378+
sys.dbms_output.put_line(i || ' packages dropped');
379+
end;
380+
/
381+
307382
begin
308383
dbms_output.put_line('&&line_separator');
309384
dbms_output.put_line('Uninstall complete');

0 commit comments

Comments
 (0)