1 PACKAGE BODY dbms_preup AS
2
3 c_output_terminal CONSTANT NUMBER := 0;
4 c_output_file CONSTANT NUMBER := 1;
5
6 --
7 -- Values for 'level' field
8 --
9 c_check_level_success CONSTANT NUMBER := 1;
10 c_check_level_info CONSTANT NUMBER := 3;
11 c_check_level_warning CONSTANT NUMBER := 2;
12 c_check_level_error CONSTANT NUMBER := 4;
13 c_check_level_recommend CONSTANT NUMBER := 5;
14
15 c_check_level_warning_txt CONSTANT VARCHAR2(7) := 'WARNING';
16 c_check_level_error_txt CONSTANT VARCHAR2(5) := 'ERROR';
17 c_check_level_info_txt CONSTANT VARCHAR2(4) := 'INFO';
18 c_check_level_success_txt CONSTANT VARCHAR2(7) := 'SUCCESS';
19 c_check_level_recommend_txt CONSTANT VARCHAR2(16) := 'RECOMMENDATION';
20
21
22 c_dbua_detail_type_sql CONSTANT VARCHAR2(3) := 'SQL';
23 c_dbua_detail_type_text CONSTANT VARCHAR2(4) := 'TEXT';
24
25 c_dbua_fixup_type_auto CONSTANT VARCHAR2(4) := 'AUTO';
26 c_dbua_fixup_type_manual CONSTANT VARCHAR2(6) := 'MANUAL';
27 c_dbua_fixup_stage_pre CONSTANT VARCHAR2(11):= 'PRE_UPGRADE';
28 c_dbua_fixup_stage_post CONSTANT VARCHAR2(12):= 'POST_UPGRADE';
29 c_dbua_fixup_stage_validation CONSTANT VARCHAR2(11):= 'VALIDATION';
30
31 --
32 -- Can't used this for declaring strings but can for length
33 -- checks
34 --
35 c_str_max CONSTANT NUMBER := 4000;
36
37 --
38 -- Record types
39 --
40
41 TYPE cursor_t IS REF CURSOR;
42
43 TYPE minvalue_record_t IS RECORD (
44 name VARCHAR2(80),
45 minvalue NUMBER,
46 oldvalue NUMBER,
47 newvalue NUMBER,
48 display BOOLEAN,
49 diff NUMBER -- the positive diff of 'oldvalue - minvalue' if
50 -- sga_target or memory_target is used
51 );
52
53 TYPE minvalue_table_t IS TABLE of minvalue_record_t
54 INDEX BY BINARY_INTEGER;
55
56 minvp_db32 minvalue_table_t;
57 minvp_db64 minvalue_table_t;
58 max_minvp BINARY_INTEGER; -- non-zero index to the last entry in the table
59 -- index to the table starts with 1
60
61 --
62 -- These are all indexes into the minvp arrays for the given pools
63 -- Indexes are not hardcoded
64 --
65 sp_idx BINARY_INTEGER; -- Shared_Pool_size
66 jv_idx BINARY_INTEGER; -- JaVa_pool_size
67 st_idx BINARY_INTEGER; -- Sga_Target
68 cs_idx BINARY_INTEGER; -- db_Cache_Size
69 pt_idx BINARY_INTEGER; -- Pga_aggregate_Target
70 mt_idx BINARY_INTEGER; -- Memory_Target
71 lp_idx BINARY_INTEGER; -- Large_Pool_size
72 sr_idx BINARY_INTEGER; -- StReams_pool_size
73 pl_idx BINARY_INTEGER; -- Pga_aggregate_Limit
74
75 TYPE comp_record_t IS RECORD (
76 cid VARCHAR2(30), -- component id
77 cname VARCHAR2(45), -- component name
78 version VARCHAR2(30), -- version
79 status VARCHAR2(15), -- component status
80 schema VARCHAR2(30), -- owner of component
81 def_ts VARCHAR2(30), -- name of default tablespace
82 script VARCHAR2(128), -- upgrade script name
83 processed BOOLEAN, -- TRUE IF in the registry AND is not
84 -- status REMOVING/REMOVED, OR
85 -- TRUE IF will be in the registry because
86 -- because cmp_info().install is TRUE
87 install BOOLEAN, -- TRUE if component to be installed in upgrade
88 sys_kbytes NUMBER, -- upgrade size needed in system tablespace
89 sysaux_kbytes NUMBER, -- upgrade size needed in sysaux tablespace
90 def_ts_kbytes NUMBER, -- upgrade size needed in 'other' tablespace
91 ins_sys_kbytes NUMBER, -- install size needed in system tablespace
92 ins_def_kbytes NUMBER, -- install size needed in 'other' tablespace
93 archivelog_kbytes NUMBER, -- minimum archive log space per component
94 flashbacklog_kbytes NUMBER -- minimum flashback log size per component
95 );
96 TYPE comp_table_t IS TABLE of comp_record_t INDEX BY BINARY_INTEGER;
97 cmp_info comp_table_t; -- Table of component information
98
99
100 -- index values for components (order as in upgrade script)
101 catalog CONSTANT BINARY_INTEGER:=1;
102 catproc CONSTANT BINARY_INTEGER:=2;
103 javavm CONSTANT BINARY_INTEGER:=3;
104 xml CONSTANT BINARY_INTEGER:=4;
105 rac CONSTANT BINARY_INTEGER:=5;
106 owm CONSTANT BINARY_INTEGER:=6;
107 mgw CONSTANT BINARY_INTEGER:=7;
108 aps CONSTANT BINARY_INTEGER:=8;
109 ols CONSTANT BINARY_INTEGER:=9;
110 dv CONSTANT BINARY_INTEGER:=10;
111 em CONSTANT BINARY_INTEGER:=11;
112 context CONSTANT BINARY_INTEGER:=12;
113 xdb CONSTANT BINARY_INTEGER:=13;
114 catjava CONSTANT BINARY_INTEGER:=14;
115 ordim CONSTANT BINARY_INTEGER:=15;
116 sdo CONSTANT BINARY_INTEGER:=16;
117 odm CONSTANT BINARY_INTEGER:=17;
118 wk CONSTANT BINARY_INTEGER:=18;
119 exf CONSTANT BINARY_INTEGER:=19;
120 rul CONSTANT BINARY_INTEGER:=20;
121 apex CONSTANT BINARY_INTEGER:=21;
122 xoq CONSTANT BINARY_INTEGER:=22;
123 misc CONSTANT BINARY_INTEGER:=23;
124
125 max_comps CONSTANT BINARY_INTEGER := 23;-- include components + 'misc'
126 -- for space calculations
127 max_components CONSTANT BINARY_INTEGER := 22;
128
129 -- these size constants need to be in NUMBER and end with .0 to avoid
130 -- "ORA-01426: numeric overflow" when storing numbers like 2048*c_mb
131 c_kb CONSTANT NUMBER := 1024.0; -- 1 KB
132 c_mb CONSTANT NUMBER := 1048576.0; -- 1 MB
133 c_gb CONSTANT NUMBER := 1073741824.0; -- 1 GB
134
135 -- minimum size constants for tablespace sizing, in units of Kbytes and Mbytes
136 -- c_sysaux_minsz_kb : (500*1024)Kb = 500Mb -- minimum size for sysaux
137 -- c_undo_minsz_kb : (400*1024)Kb = 400Mb -- minimum size for undo
138 -- c_incby_minsz_mb : 50Mb -- minimum size to increase by
139 c_sysaux_minsz_kb CONSTANT BINARY_INTEGER := 500 * c_kb; -- (500*1024)kb =500M
140 c_undo_minsz_kb CONSTANT BINARY_INTEGER := 400 * c_kb; -- (400*1024)kb =400M
141 c_incby_minsz_mb CONSTANT BINARY_INTEGER := 50; -- 50Mb
142
143 TYPE obsolete_record_t IS RECORD (
144 name VARCHAR2(80),
145 version VARCHAR2(20), -- version where is was obsolete/deprecated
146 deprecated BOOLEAN, -- Has become Depreciated
147 db_match BOOLEAN
148 );
149
150 TYPE obsolete_table_t IS TABLE of obsolete_record_t
151 INDEX BY BINARY_INTEGER;
152
153 op obsolete_table_t;
154 max_op BINARY_INTEGER;
155
156 TYPE renamed_record_t IS RECORD (
157 oldname VARCHAR2(80),
158 newname VARCHAR2(80),
159 db_match BOOLEAN
160 );
161
162 TYPE renamed_table_t IS TABLE of renamed_record_t
163 INDEX BY BINARY_INTEGER;
164
165 rp renamed_table_t;
166 max_rp BINARY_INTEGER;
167
168 TYPE special_record_t IS RECORD (
169 oldname VARCHAR2(80),
170 oldvalue VARCHAR2(80),
171 newname VARCHAR2(80),
172 newvalue VARCHAR2(80),
173 dbua_OutInUpdate BOOLEAN,
174 db_match BOOLEAN
175 );
176
177 TYPE special_table_t IS TABLE of special_record_t
178 INDEX BY BINARY_INTEGER;
179
180 sp special_table_t;
181 max_sp BINARY_INTEGER;
182
183 TYPE required_record_t IS RECORD (
184 name VARCHAR2(80),
185 newnumbervalue NUMBER,
186 newstringvalue VARCHAR2(4000),
187 type NUMBER,
188 db_match BOOLEAN
189 );
190
191 TYPE required_table_t IS TABLE of required_record_t
192 INDEX BY BINARY_INTEGER;
193
194 reqp required_table_t;
195 max_reqp BINARY_INTEGER;
196
197 TYPE tablespace_record_t IS RECORD (
198 name VARCHAR2(128), -- tablespace name
199 inuse NUMBER, -- kbytes inuse in tablespace
200 alloc NUMBER, -- kbytes allocated to tbs
201 auto NUMBER, -- autoextend kbytes available
202 avail NUMBER, -- total kbytes available
203 delta NUMBER, -- kbytes required for upgrade
204 inc_by NUMBER, -- kbytes to increase tablespace by
205 min NUMBER, -- minimum required kbytes to perform upgrade
206 addl NUMBER, -- additional space allocated during upgrade
207 fname VARCHAR2(513), -- filename in tablespace
208 fauto BOOLEAN, -- TRUE if there is a file to increase autoextend
209 temporary BOOLEAN, -- TRUE if Temporary tablespace
210 localmanaged BOOLEAN -- TRUE if locally managed temporary tablespace
211 -- FALSE if dictionary managed temp tablespace
212 );
213
214 TYPE tablespace_table_t IS TABLE OF tablespace_record_t
215 INDEX BY BINARY_INTEGER;
216
217 ts_info tablespace_table_t; -- Tablespace information
218 max_ts BINARY_INTEGER; -- Total number of relevant tablespaces
219
220
221 TYPE rollback_record_t IS RECORD (
222 tbs_name VARCHAR2(30), -- tablespace name
223 seg_name VARCHAR2(30), -- segment name
224 status VARCHAR(30), -- online or offline
225 inuse NUMBER, -- kbytes in use
226 next NUMBER, -- kbytes in NEXT
227 max_ext NUMBER, -- max extents
228 auto NUMBER -- autoextend available for tablespace
229 );
230
231 TYPE rollback_table_t IS TABLE of rollback_record_t
232 INDEX BY BINARY_INTEGER;
233
234 rs_info rollback_table_t; -- Rollback segment information
235 max_rs BINARY_INTEGER; -- Total number of public rollback segs
236
237 TYPE fb_record_t IS RECORD (
238 active BOOLEAN, -- ON or OFF
239 file_dest VARCHAR2(1000), -- db_recovery_file_dest
240 dsize NUMBER, -- db_recovery_file_dest_size
241 name VARCHAR2(513), -- name
242 limit NUMBER, -- space limit
243 used NUMBER, -- Used
244 reclaimable NUMBER,
245 files NUMBER -- number of files
246 );
247 flashback_info fb_record_t;
248
249 --
250 -- Have we initialized the package?
251 --
252 p_package_inited BOOLEAN := FALSE;
253
254 --
255 -- Specifics about the DB being checked
256 --
257
258 db_name VARCHAR2(256);
259 con_name VARCHAR2(256); -- container or db name
260 con_id NUMBER; -- container or db id
261 db_compat VARCHAR2(30);
262 db_version VARCHAR2(30); -- Complete version
263 db_major_vers VARCHAR2(12); -- Major vers xx.n.n
264 db_patch_vers VARCHAR2(12); -- include patch
265 db_n_version BINARY_INTEGER; -- Numeric version of db_version
266 db_compat_majorver NUMBER;
267
268 db_is_XE BOOLEAN := FALSE;
269 db_VLM_enabled BOOLEAN := FALSE;
270
271 db_64bit BOOLEAN := FALSE;
272 db_platform VARCHAR2(128);
273 db_platform_id NUMBER;
274 db_block_size NUMBER;
275 db_undo VARCHAR(128);
276 db_undo_tbs VARCHAR(128);
277 db_flashback_on BOOLEAN := FALSE;
278 db_log_mode VARCHAR2(30);
279 db_inplace_upgrade BOOLEAN := FALSE;
280 db_invalid_state BOOLEAN := FALSE; -- If the DB is not in OPEN state
281 db_tz_version NUMBER := 0;
282
283 db_cpus NUMBER; -- # of cpus
284 db_cpu_threads NUMBER; -- Threads per CPU
285
286 db_npdbs NUMBER; -- # of pdbs as seen in v$pdbs
287
288 --
289 -- A few stand-along values that we report
290 --
291 pMinFlashbackLogGen NUMBER;
292 pminArchiveLogGen NUMBER;
293
294 --
295 -- Setup in init_package depending on platform
296 --
297 crlf VARCHAR(2);
298 --
299 -- Header, centered, with "*" in it, setup in
300 -- init routine.
301 --
302 pStarHeader VARCHAR2(80);
303 pActionRequired VARCHAR2(40) := '^^^ MANUAL ACTION REQUIRED ^^^';
304 pActionSuggested VARCHAR2(40) := '^^^ MANUAL ACTION SUGGESTED ^^^';
305 --
306 -- If we want a check routine to ONLY do a check and
307 -- not generate any script /log output
308 --
309 pCheckOnly BOOLEAN;
310 --
311 -- Make this a package variable so some of the
312 -- resources are disabled should the package be
313 -- run on an unsupported release
314 --
315 pUnsupportedUpgrade BOOLEAN;
316
317 --
318 -- If we are debugging the FAILURE sitiuations
319 --
320 pDBGFailCheck BOOLEAN; -- For specific defined _check procedures
321 pDBGFailAll BOOLEAN; -- For checks that are not 'formal checks'
322 pDBGAllResources BOOLEAN; -- Dump out all the resources as failures
323 pDBGSizeResources BOOLEAN; -- For Tablespace resource info
324
325 pOutputType NUMBER := c_output_text;
326 pOutputDest NUMBER := c_output_terminal;
327
328 --
329 -- file names and file pointers -
330 -- Used when outputting to preupgrade log file
331 --
332 pOutputUFT UTL_FILE.FILE_TYPE;
333 pOutputFName VARCHAR2(512) := NULL;
334 pOutputLocation VARCHAR2(512) := NULL; -- text/xml directory object name
335 -- PREUPGRADE_DIR or PREUPG_OUTPUT_DIR
336 pOutputVerified BOOLEAN;
337
338 -- paths in directory objects
339 pTextLogDir VARCHAR2(512) := NULL; -- path to PREUPGRADE_DIR dir obj
340 pPdbLogDir VARCHAR2(512) := NULL; -- path to PDB_PREUPGRADE_DIR dir obj
341
342 --
343 -- file names and file pointers -
344 -- Used for outputting to preupgrade and postupgrade fixup sql scripts
345 --
346 pPreScriptUFT UTL_FILE.FILE_TYPE;
347 pPostScriptUFT UTL_FILE.FILE_TYPE;
348 pPreScriptFname VARCHAR2(512) := c_pre_script_fn;
349 pPostScriptFname VARCHAR2(512) := c_post_script_fn;
350
351 -- TRUE if 'will be' or 'is' outputting/generating fixup scripts; else FALSE
352 pOutputFixupScripts BOOLEAN := FALSE;
353
354 pCreatedDirObj BOOLEAN := TRUE; -- Assume we will be creating/cleaning up
355
356 pCreatedPdbDirObj BOOLEAN := FALSE; -- is pdb dir obj created? TRUE/FALSE
357
358 --
359 -- Keep track of the destination paths and file names
360 -- preupgrade tool wrote into for
361 -- display messages like 'Results of the checks are located at:'.
362 -- Note: the names here are just filenames; paths are not included.
363 -- Note: the default names here are the final destination filenames
364 -- Note: this is only for non-DBUA/TEXT cases
365 --
366 finalDestLogFn VARCHAR2(99) := c_output_fn; -- preupgrade.log
367 finalDestPreScriptFn VARCHAR2(99) := c_pre_script_fn; -- preupgrade_fixups.sql
368 finalDestPostScriptFn VARCHAR2(99) := c_post_script_fn;-- postupgrade_fixups.sql
369
370 --
371 -- If db is a non-cdb or root, then preupgrade tool writes directly to the
372 -- "main" destination files - preupgrade.log, preupgrade_fixups.sql, and
373 -- postupgrade_fixups.sql.
374 --
375 -- But if db is a pdb, then preuprgrade tool first writes to a pdb file -
376 -- preupgrade.<con_name>.log, preupgrade_fixups.<con_name>.sql, and
377 -- postupgrade_fixups<con_name>.log. Then if pdb can create a write
378 -- lock file exclusively, then pdb will concatenate its files to the "main"
379 -- destination files. Then after concatenate is done, the pdb files are
380 -- saved in a pdbfiles subdirectory under PREUPGRADE_DIR.
381 --
382 -- Note: DBUA will need to continue to run with "-n 1" via catcon.
383 -- I.e., The concatenate feature is not implemented in DBUA, not now anyway.
384 --
385 -- Note: This concatentate feature is a must if preupgrade tool were to run
386 -- in multiple pdbs simultaneously.
387 --
388 pConcatToMainFile BOOLEAN := FALSE;
389
390 pGotWriteLock BOOLEAN := FALSE; -- exclusive write lock file created
391
392 --
393 -- use this variable to surround tracing stmts to be left permanently in
394 -- this file
395 -- note: lets append 'XXX ' to begin of tracing stmts so that they stand out
396 --
397 tracing_on_xxx BOOLEAN := FALSE;
398
399 --
400 -- Declares of local functions/procedures
401 --
402 --
403 -- Init all the checks and package variables,
404 -- If not called before a 'check' routine, will be
405 -- called automaticlly.
406 --
407 PROCEDURE init_package;
408 PROCEDURE init_preupchecks;
409 PROCEDURE init_preuprecommend;
410 PROCEDURE init_initparams;
411 PROCEDURE init_params;
412 PROCEDURE init_components;
413 PROCEDURE init_resources;
414
415 PROCEDURE define_check (
416 idx IN OUT NUMBER,
417 name VARCHAR2,
418 check_level NUMBER,
419 descript VARCHAR2);
420
421 FUNCTION getHelp (
422 name IN VARCHAR2,
423 helpType IN NUMBER) RETURN VARCHAR2;
424
425 --
426 -- Used to generate a valid dbua tag for a pre-up check
427 --
428 FUNCTION genDBUAXMLCheck (name VARCHAR2,
429 eseverity NUMBER,
430 etext VARCHAR2,
431 ecause VARCHAR2,
432 action VARCHAR2,
433 detailtype VARCHAR2,
434 detailinfo VARCHAR2,
435 fixuptype VARCHAR2,
436 fixupstage VARCHAR2 ) RETURN VARCHAR2;
437
438 PROCEDURE verifyDefaultDirObj;
439
440 PROCEDURE store_comp (i BINARY_INTEGER,
441 schema VARCHAR2,
442 version VARCHAR2,
443 status NUMBER);
444 PROCEDURE store_minval_dbbit (dbbit NUMBER,
445 i IN OUT BINARY_INTEGER,
446 name VARCHAR2,
447 minv NUMBER);
448 PROCEDURE store_minvalue (i BINARY_INTEGER,
449 name VARCHAR2,
450 minv NUMBER,
451 minvp IN OUT MINVALUE_TABLE_T);
452 PROCEDURE store_oldval (minvp IN OUT MINVALUE_TABLE_T);
453 PROCEDURE store_renamed (i IN OUT BINARY_INTEGER,
454 old VARCHAR2,
455 new VARCHAR2);
456 PROCEDURE store_removed (i IN OUT BINARY_INTEGER,
457 name VARCHAR2,
458 version VARCHAR2,
459 deprecated BOOLEAN);
460 PROCEDURE store_special (i IN OUT BINARY_INTEGER,
461 old VARCHAR2,
462 oldv VARCHAR2,
463 new VARCHAR2,
464 newv VARCHAR2);
465 PROCEDURE store_required (i IN OUT BINARY_INTEGER,
466 name VARCHAR2,
467 newvn NUMBER,
468 newvs VARCHAR2,
469 dtype NUMBER);
470 FUNCTION pvalue_to_number (value_string VARCHAR2) RETURN NUMBER;
471 FUNCTION is_comp_tablespace (tsname VARCHAR2) RETURN BOOLEAN;
472 FUNCTION ts_is_SYS_temporary (tsname VARCHAR2) RETURN BOOLEAN;
473 FUNCTION ts_has_queues (tsname VARCHAR2) RETURN BOOLEAN;
474 PROCEDURE find_newval (minvp IN OUT MINVALUE_TABLE_T,
475 dbbit NUMBER);
476 PROCEDURE find_sga_mem_values (minvp IN OUT MINVALUE_TABLE_T,
477 dbbit NUMBER);
478 PROCEDURE init_mem_sizes (minvp IN OUT MINVALUE_TABLE_T,
479 dbbit IN NUMBER,
480 max_minvp IN OUT BINARY_INTEGER);
481
482 FUNCTION CenterLine (line IN VARCHAR2) RETURN VARCHAR2;
483 FUNCTION htmlentities (intxt varchar2) RETURN VARCHAR2;
484 PROCEDURE output_manual_initparams (minvp IN MINVALUE_TABLE_T,
485 bis64bit IN BOOLEAN);
486 PROCEDURE output_xml_initparams (minvp IN MINVALUE_TABLE_T);
487
488 PROCEDURE get_write_lock; -- is write lock file created? T/F
489
490
491 -- ****************************************************************
492 -- Start of Code
493 -- ****************************************************************
494
495 --
496 -- Used to execute a sql statement (for a fixup)
497 -- Errors are returned in sqlerrtxt and sqlerrcode
498 --
499 FUNCTION execute_sql_statement (
500 statement VARCHAR2,
501 sqlerrtxt IN OUT VARCHAR2,
502 sqlerrcode IN OUT NUMBER) RETURN NUMBER
503 IS
504 ret_val NUMBER := c_fixup_status_success;
505
506 BEGIN
507 BEGIN
508 EXECUTE IMMEDIATE statement;
509 EXCEPTION WHEN OTHERS THEN
510 sqlerrtxt := SQLERRM;
511 sqlerrcode := SQLCODE;
512 ret_val := c_fixup_status_failure;
513 END;
514 RETURN (ret_val);
515 END execute_sql_statement;
516
517 FUNCTION get_version RETURN VARCHAR2
518 IS
519 BEGIN
520 return(dbms_preup.c_version);
521 END get_version;
522
523 FUNCTION run_all_checks RETURN NUMBER
524 IS
525 checks_run NUMBER := 0;
526 BEGIN
527 init_package;
528
529 FOR i IN 1..pCheckCount LOOP
530 IF check_table(i).type = c_type_check OR
531 check_table(i).type = c_type_check_interactive_only THEN
532 --
533 -- Only non-recommended checks
534 --
535 check_table(i) := run_check (check_table(i).name);
536 checks_run := checks_run + 1;
537
538 IF (check_table(i).passed = FALSE) THEN
539 IF (check_table(i).level = c_check_level_error) THEN
540 pCheckErrorCount := pCheckErrorCount + 1;
541 ELSIF (check_table(i).level = c_check_level_warning) THEN
542 pCheckWarningCount := pCheckWarningCount + 1;
543 ELSIF (check_table(i).level = c_check_level_info) THEN
544 pCheckInfoCount := pCheckInfoCount + 1;
545 -- There can be 'success' status, no count of those is needed.
546 END IF;
547 END IF;
548 END IF;
549 END LOOP;
550 return (checks_run);
551 END run_all_checks;
552
553 PROCEDURE run_all_recommend (whatType NUMBER)
554 IS
555 BEGIN
556 init_package;
557
558 FOR i IN 1..pCheckCount LOOP
559 IF check_table(i).type = whatType THEN
560 -- Only run the recommend checks
561 check_table(i) := run_recommend (check_table(i).name);
562 END IF;
563 END LOOP;
564 END run_all_recommend;
565
566 FUNCTION run_recommend (check_name VARCHAR2) RETURN check_record_t
567 IS
568 execute_failed BOOLEAN := FALSE;
569 idx NUMBER;
570 retval NUMBER;
571 check_stmt VARCHAR2(100);
572 r_text VARCHAR2(4000);
573
574 BEGIN
575 init_package;
576
577 IF check_names.EXISTS(check_name) = FALSE
578 THEN
579 EXECUTE IMMEDIATE 'BEGIN
580 RAISE_APPLICATION_ERROR (-20000,
581 ''Pre-Upgrade Package Requested Check does not exist''); END;';
582 return (NULL);
583 END IF;
584 idx := check_names(check_name).idx;
585
586 IF check_table(idx).always_fail THEN
587 --
588 -- We want to fail this check, set the global
589 -- so the package checks know to fail
590 --
591 pDBGFailCheck := TRUE;
592 END IF;
593
594 --
595 -- This executes the check procedure
596 -- An example would be
597 --
598 -- BEGIN dictionary_stats_recommend; END;
599 --
600
601 check_stmt := 'BEGIN dbms_preup.'
602 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
603 || '_recommend; END;';
604
605 BEGIN
606 EXECUTE IMMEDIATE check_stmt;
607 EXCEPTION WHEN OTHERS THEN
608 execute_failed := TRUE;
609 END;
610
611 --
612 -- Save away the results of the check
613 --
614 check_table(idx).executed := TRUE;
615
616 if execute_failed = TRUE
617 THEN
618 check_table(idx).execute_failed := TRUE;
619 ELSE
620 check_table(idx).passed := TRUE;
621 END IF;
622 --
623 -- Always turn this off
624 --
625 pDBGFailCheck := FALSE;
626 return (check_table(idx));
627 END run_recommend;
628
629 ------------------------------- boolval -------------------------------------
630 FUNCTION boolval (p boolean,
631 trueval VARCHAR2,
632 falseval VARCHAR2) return varchar2
633 IS
634 --
635 -- Return truval if the bool is TRUE otherwise return falseval
636 -- Usage: boolval(somebool, 'Yes', 'No')
637 -- boolval(somebool, 'On', 'Off')
638 -- boolval(somebool, 'True', 'False')
639 BEGIN
640 if p = TRUE THEN
641 return trueval;
642 ELSE
643 return falseval;
644 END IF;
645 END boolval;
646
647 PROCEDURE dump_check_rec (p_check_rec check_record_t)
648 IS
649 BEGIN
650 DisplayLine ('-------- CHECK RECORD ------');
651 DisplayLine ('Name: ' || p_check_rec.name);
652 DisplayLine ('Description: ' || p_check_rec.descript);
653 DisplayLine ('Name Prefix: ' || p_check_rec.f_name_prefix);
654 IF (p_check_rec.type = c_type_check) THEN
655 DisplayLine ('Type: ' || 'Normal');
656 ELSIF (p_check_rec.type = c_type_check_interactive_only) THEN
657 DisplayLine ('Type: ' || 'Manual Only');
658 ELSIF (p_check_rec.type = c_type_recommend_pre) THEN
659 DisplayLine ('Type: ' || 'Pre Upgrade Recommend');
660 ELSIF (p_check_rec.type = c_type_recommend_post) THEN
661 DisplayLine ('Type: ' || 'Post Upgrade Recommend');
662 ELSE
663 DisplayLine ('Type: ' || 'UNKNOWN: ' || p_check_rec.type);
664 END IF;
665 DisplayLine ('Passed: ' || boolval(p_check_rec.passed, 'Yes', 'No'));
666 DisplayLine ('Skipped: ' || boolval(p_check_rec.skipped, 'Yes', 'No'));
667 DisplayLine ('Fix Type: ' || p_check_rec.fix_type);
668 DisplayLine ('Executed: ' || boolval(p_check_rec.executed, 'Yes', 'No'));
669
670 if p_check_rec.fixup_executed AND p_check_rec.fixup_failed THEN
671 DisplayLine ('Execute Fail: -- Fixup Attempted --');
672 ELSE
673 DisplayLine ('Execute Fail: ' || boolval(p_check_rec.execute_failed, 'Yes', 'No'));
674 END IF;
675 DisplayLine ('Versions: ' || p_check_rec.valid_versions);
676 DisplayLine ('Fixup Executed:' || boolval(p_check_rec.fixup_executed, 'Yes', 'No'));
677 DisplayLine ('Fixup Fail: ' || boolval(p_check_rec.execute_failed, 'Yes', 'No'));
678 DisplayLine ('Text: ' || p_check_rec.result_text);
679 DisplayLine ('SQLCODE: ' || TO_CHAR(p_check_rec.sqlcode));
680 DisplayLine ('----------------------------');
681
682 END dump_check_rec;
683
684 FUNCTION getHelp (
685 name IN VARCHAR2,
686 helpType IN NUMBER) RETURN VARCHAR2
687 IS
688 --
689 -- Use this to get back the help text (English only)
690 -- for a specific check. The helpType is either
691 -- c_help_overview for an overview of what the check does or
692 -- c_help_fixup which describes what the fixup would do
693 --
694 idx NUMBER;
695 rhelp VARCHAR2(2000);
696 estatement VARCHAR2(200);
697 BEGIN
698 IF check_names.EXISTS(name) = FALSE THEN
699 return 'WARNING - CHECK ' || name || ' does not exist';
700 END IF;
701 idx := check_names(name).idx;
702 estatement := 'BEGIN :r1 := dbms_preup.'
703 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
704 || '_gethelp (:helpType); END;';
705 EXECUTE IMMEDIATE estatement
706 USING OUT rhelp, IN helpType;
707 return rhelp;
708 END getHelp;
709
710 PROCEDURE define_check (
711 idx IN OUT NUMBER,
712 name VARCHAR2,
713 check_level NUMBER,
714 descript VARCHAR2)
715 IS
716 BEGIN
717 --
718 -- Setup the check_name array
719 --
720 check_names(name).idx := idx;
721
722 check_table(idx).name := name;
723 check_table(idx).descript := descript;
724 -- Default values
725 check_table(idx).type := c_type_check;
726 check_table(idx).f_name_prefix := name;
727 check_table(idx).valid_versions := 'ALL';
728 check_table(idx).level := check_level;
729 -- Assume all fixable on source side, auto
730 check_table(idx).fix_type := c_fix_source_auto;
731 check_table(idx).passed := FALSE;
732 check_table(idx).skipped := FALSE;
733 check_table(idx).executed := FALSE;
734 check_table(idx).execute_failed := FALSE;
735 check_table(idx).fixup_executed := FALSE;
736 check_table(idx).fixup_failed := FALSE;
737 check_table(idx).always_fail := FALSE;
738 idx := idx + 1;
739 END define_check;
740
741
742 -- *******************************************************************
743 -- Init package variables used throughout the package
744 -- *******************************************************************
745 PROCEDURE init_package
746 IS
747 tmp_bool BOOLEAN;
748 c_value VARCHAR2(80);
749 t_db_prev_vers VARCHAR2(30);
750 t_db_dict_vers VARCHAR2(30);
751 tmp_varchar1 VARCHAR2(512);
752 tmp_varchar4 VARCHAR2(4000); -- Max from any query we do
753 p_count INTEGER;
754
755 BEGIN
756 IF p_package_inited THEN
757 RETURN;
758 END IF;
759
760 pCheckOnly := FALSE;
761 pDBGFailCheck := FALSE;
762 pDBGFailAll := FALSE;
763
764 pDBGSizeResources := FALSE;
765 pCheckErrorCount := 0;
766 pCheckWarningCount := 0;
767 pCheckInfoCount := 0;
768 --
769 -- Used all over the place for output
770 --
771 pStarHeader := CenterLine ('*****************************************');
772
773 -- Check for SYSDBA
774 SELECT USER INTO tmp_varchar1 FROM SYS.DUAL;
775 IF tmp_varchar1 != 'SYS' THEN
776 EXECUTE IMMEDIATE 'BEGIN
777 RAISE_APPLICATION_ERROR (-20000,
778 ''These functions must be run AS SYSDBA''); END;';
779 END IF;
780
781 EXECUTE IMMEDIATE 'SELECT name FROM v$database' INTO db_name;
782 EXECUTE IMMEDIATE 'SELECT dbms_preup.get_con_name FROM sys.dual' INTO con_name;
783 EXECUTE IMMEDIATE 'SELECT dbms_preup.get_con_id FROM sys.dual' INTO con_id;
784 EXECUTE IMMEDIATE 'SELECT version FROM v$instance' INTO db_version;
785
786 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''compatible'''
787 INTO db_compat;
788
789 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''db_block_size'''
790 INTO db_block_size;
791 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''undo_management'''
792 INTO db_undo;
793 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''undo_tablespace'''
794 INTO db_undo_tbs;
795 --
796 -- Flashback on can have several 'on' states, but only one 'off' so check
797 -- for NO.
798 -- Put inside begin/end to catch execution on pre 10.x DB's where undo_tablespace
799 -- is not defined yet.
800 --
801 p_count := 0;
802 BEGIN
803 EXECUTE IMMEDIATE 'SELECT count(*) FROM v$database WHERE flashback_on = ''NO'''
804 INTO p_count;
805 EXCEPTION WHEN OTHERS THEN NULL;
806 END;
807
808 IF p_count <= 0 THEN
809 db_flashback_on := TRUE;
810 END IF;
811
812 EXECUTE IMMEDIATE 'SELECT LOG_MODE from v$database'
813 INTO db_log_mode;
814
815 IF db_undo != 'AUTO' OR db_undo_tbs IS NULL THEN
816 db_undo_tbs := 'NO UNDO TBS'; -- undo tbs is not in use
817 END IF;
818
819 EXECUTE IMMEDIATE 'SELECT platform_id, platform_name
820 FROM v$database'
821 INTO db_platform_id, db_platform;
822 IF db_platform_id NOT IN (1,7,10,15,16,17) THEN
823 db_64bit := TRUE;
824 END IF;
825
826 db_major_vers := SUBSTR (db_version, 1,6); -- First three digits
827 db_patch_vers := SUBSTR (db_version, 1,8); -- Include 4th digit
828
829 db_compat_majorver := TO_NUMBER(SUBSTR(db_compat,1,2));
830
831 db_n_version := 0; -- initialize to 0 so that comparisons will be valid
832 -- if preupgrade tool is run on - for example - 12.2
833 IF db_major_vers = '10.2.0' THEN
834 db_n_version := 102;
835 ELSIF db_major_vers = '11.1.0' THEN
836 db_n_version := 111;
837 ELSIF db_major_vers = '11.2.0' THEN
838 db_n_version := 112;
839 ELSIF db_major_vers = '12.1.0' THEN
840 db_n_version := 121;
841 END IF;
842
843
844 IF ( (instr (c_supported_versions, db_patch_vers) = 0) OR
845 (db_major_vers = SUBSTR (c_version, 1,6))) THEN
846 --
847 -- Didn't find this DB's version in the supported list
848 -- However, if the major version matches the c_version
849 -- for this script, this may be a re-run etc so let the tool run.
850 -- Note using substr, instead of hard-coding '121' avoids
851 -- errors while versions are updated.
852 --
853 pUnsupportedUpgrade := TRUE;
854 ELSE
855 pUnsupportedUpgrade := FALSE;
856 END IF;
857
858 EXECUTE IMMEDIATE 'SELECT value FROM sys.v$parameter WHERE name = ''cpu_count'''
859 INTO tmp_varchar1;
860 db_cpus := to_number (tmp_varchar1);
861
862 EXECUTE IMMEDIATE
863 'SELECT value FROM v$parameter WHERE name = ''parallel_threads_per_cpu'''
864 INTO tmp_varchar1;
865 db_cpu_threads := pvalue_to_number(tmp_varchar1);
866
867 BEGIN
868 EXECUTE IMMEDIATE
869 'SELECT edition FROM sys.registry$ WHERE cid=''CATPROC'''
870 INTO tmp_varchar1;
871 IF tmp_varchar1 = 'XE' THEN
872 db_is_XE := TRUE;
873 END IF; -- XE edition
874 EXCEPTION
875 WHEN OTHERS THEN NULL; -- no edition column
876 END;
877
878 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''use_indirect_data_buffers'''
879 INTO tmp_varchar1;
880 IF tmp_varchar1 = 'TRUE'
881 THEN
882 db_VLM_enabled := TRUE;
883 END IF;
884
885 --
886 -- Make sure we are in OPEN state
887
888 EXECUTE IMMEDIATE 'SELECT status FROM V$INSTANCE'
889 INTO tmp_varchar1;
890 IF tmp_varchar1 NOT IN ('OPEN', 'OPEN MIGRATE') THEN
891 db_invalid_state := TRUE;
892 END IF;
893
894 --
895 -- Time zone data
896 --
897 EXECUTE IMMEDIATE 'SELECT version from v$timezone_file'
898 INTO db_tz_version;
899
900 --
901 -- Call procedure to fixup timezone info (if needed)
902 --
903
904 tz_fixup (FALSE);
905
906 IF db_patch_vers = c_version THEN
907 --
908 -- This block will reset db_major_vers to the value
909 -- in prv_version from registry$ - this allows the
910 -- comparision checks to behave correctly.
911 --
912 BEGIN
913 EXECUTE IMMEDIATE 'SELECT version, prv_version FROM sys.registry$
914 WHERE cid = ''CATPROC'''
915 INTO t_db_dict_vers, t_db_prev_vers;
916
917 IF t_db_dict_vers = db_version THEN
918 IF t_db_prev_vers != '' THEN
919 --
920 -- If prev vers is '', the DB
921 -- was never upgraded, so not really a re-run
922 --
923 db_major_vers := substr(t_db_prev_vers,1,6); -- use prev catproc version
924 END IF;
925 ELSE
926 db_inplace_upgrade := TRUE;
927 db_major_vers := substr(t_db_dict_vers,1,6); -- use CATPROC version
928 db_version := t_db_dict_vers;
929 END IF;
930
931 EXCEPTION
932 WHEN NO_DATA_FOUND THEN NULL; -- registry$ exists, but no CATPROC entry
933 END;
934 END IF;
935
936 --
937 -- Set the newline depending on platform
938 --
939 IF INSTR(db_platform, 'WINDOWS') != 0 THEN
940 crlf := CHR(13) || CHR(10); -- Windows gets the \r and \n
941 ELSE
942 crlf := CHR (10); -- Just \n for the rest of the world
943 END IF;
944
945 init_initparams;
946 init_components;
947
948 init_params; -- Named params, not init params
949
950 -- Process required data
951
952 FOR i IN 1..max_reqp LOOP
953 BEGIN
954 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name =
955 :1 AND isdefault = ''TRUE'''
956 INTO c_value
957 USING reqp(i).name;
958 IF reqp(i).name = 'undo_management' THEN
959 --
960 -- Starting in 11.1, undo_management default is changed
961 -- from MANUAL to AUTO.
962 --
963 IF db_n_version = 102 THEN
964 reqp(i).db_match := TRUE;
965 END IF;
966 END IF;
967 EXCEPTION WHEN NO_DATA_FOUND THEN
968 reqp(i).db_match := FALSE;
969 END;
970 END LOOP;
971
972 -- Find values for memory initialization parameters with minimum values
973 -- Convert to numeric values
974 store_oldval(minvp_db32);
975 store_oldval(minvp_db64);
976
977 -- determine new values for memory init parameters with minimum values
978 find_newval(minvp_db32, 32);
979 find_newval(minvp_db64, 64);
980
981 init_resources;
982
983 init_preupchecks;
984
985 init_preuprecommend;
986
987 p_package_inited := TRUE;
988
989 END init_package;
990
991 PROCEDURE init_preupchecks
992 IS
993 i NUMBER := 1;
994
995 BEGIN
996 -- ********************************************************
997 -- Define the pre-up checks
998 -- The order in which they are defined is the order in
999 -- which they will be executed.
1000 -- ********************************************************
1001
1002 define_check (i, 'UNSUPPORTED_VERSION', c_check_level_error,
1003 'Make sure we support a direct upgrade from this version');
1004 check_table(check_names('UNSUPPORTED_VERSION').idx).fix_type := c_fix_source_manual;
1005 -- DBUA does their own.
1006 check_table(check_names('UNSUPPORTED_VERSION').idx).type := c_type_check_interactive_only;
1007
1008 define_check (i, 'DEFAULT_PROCESS_COUNT', c_check_level_warning,
1009 'Verify min process count is not too low');
1010 check_table(i-1).fix_type := c_fix_source_manual;
1011 -- DBUA does their own.
1012 check_table(i-1).type := c_type_check_interactive_only;
1013
1014 define_check (i, 'COMPATIBLE_PARAMETER', c_check_level_error,
1015 'Verify compatible parameter value is valid');
1016 check_table(i-1).fix_type := c_fix_source_manual;
1017 check_table(i-1).type := c_type_check_interactive_only;
1018
1019 define_check (i, 'OLS_SYS_MOVE', c_check_level_error,
1020 'Check if SYSTEM.AUD$ needs to move to SYS.AUD$ before upgrade');
1021 check_table(i-1).fix_type := c_fix_source_manual;
1022
1023 define_check (i, 'OCM_USER_PRESENT', c_check_level_warning,
1024 'Check for OCM schema');
1025 define_check (i, 'APPQOSSYS_USER_PRESENT', c_check_level_warning,
1026 'Check for APPQOSSYS schema');
1027
1028 define_check (i, 'AUDSYS_USER_PRESENT', c_check_level_error,
1029 'Verify if a user or role with the name AUDSYS exists');
1030 check_table(i-1).valid_versions := '102,111,112';
1031 check_table(i-1).fix_type := c_fix_source_manual;
1032
1033 define_check (i, 'AUDIT_ADMIN_ROLE_PRESENT', c_check_level_error,
1034 'Verify if a user or role with the name AUDIT_ADMIN exists');
1035 check_table(i-1).f_name_prefix := 'AAR_PRESENT';
1036 check_table(i-1).valid_versions := '102,111,112';
1037 check_table(i-1).fix_type := c_fix_source_manual;
1038
1039 define_check (i, 'AUDIT_VIEWER', c_check_level_error,
1040 'Verify if a user or role with the name AUDIT_VIEWER exists');
1041 check_table(i-1).valid_versions := '102,111,112';
1042 check_table(i-1).fix_type := c_fix_source_manual;
1043
1044 define_check (i, 'SYSBACKUP_USER_PRESENT', c_check_level_error,
1045 'Verify if a user or role with the name SYSBACKUP exists');
1046 check_table(i-1).valid_versions := '102,111,112';
1047 check_table(i-1).fix_type := c_fix_source_manual;
1048
1049 define_check (i, 'SYSDG_USER_PRESENT', c_check_level_error,
1050 'Verify if a user or role with the name SYSDG exists');
1051 check_table(i-1).valid_versions := '102,111,112';
1052 check_table(i-1).fix_type := c_fix_source_manual;
1053
1054 define_check (i, 'SYSKM_USER_PRESENT', c_check_level_error,
1055 'Verify if a user or role with the name SYSKM exists');
1056 check_table(i-1).valid_versions := '102,111,112';
1057 check_table(i-1).fix_type := c_fix_source_manual;
1058
1059 define_check (i, 'CAPT_ADM_ROLE_PRESENT', c_check_level_error,
1060 'Verify if a user or role with the name CAPTURE_ADMIN exists');
1061 check_table(i-1).valid_versions := '102,111,112';
1062 check_table(i-1).fix_type := c_fix_source_manual;
1063
1064 define_check (i, 'GSMCATUSER_PRESENT', c_check_level_error,
1065 'Verify if a user or role with the name GSMCATUSER exists');
1066 check_table(i-1).valid_versions := '102,111,112';
1067 check_table(i-1).fix_type := c_fix_source_manual;
1068
1069 define_check (i, 'GSMUSER_USER_PRESENT', c_check_level_error,
1070 'Verify if a user or role with the name GSMUSER exists');
1071 check_table(i-1).valid_versions := '102,111,112';
1072 check_table(i-1).fix_type := c_fix_source_manual;
1073
1074 define_check (i, 'GSMADM_INT_PRESENT', c_check_level_error,
1075 'Verify if a user or role with the name GSMADMIN_INTERNAL exists');
1076 check_table(i-1).valid_versions := '102,111,112';
1077 check_table(i-1).fix_type := c_fix_source_manual;
1078
1079 define_check (i, 'GSMUSER_ROLE_PRESENT', c_check_level_error,
1080 'Verify if a user or role with the name GSMUSER exists');
1081 check_table(i-1).valid_versions := '102,111,112';
1082 check_table(i-1).fix_type := c_fix_source_manual;
1083
1084 define_check (i, 'GSM_PAD_ROLE_PRESENT', c_check_level_error,
1085 'Verify if a user or role with the name GSM_POOLADMIN exists');
1086 check_table(i-1).valid_versions := '102,111,112';
1087 check_table(i-1).fix_type := c_fix_source_manual;
1088
1089 define_check (i, 'GSMADMIN_ROLE_PRESENT', c_check_level_error,
1090 'Verify if a user or role with the name GSMADMIN exists');
1091 check_table(i-1).valid_versions := '102,111,112';
1092 check_table(i-1).fix_type := c_fix_source_manual;
1093
1094 define_check (i, 'GDS_CT_ROLE_PRESENT', c_check_level_error,
1095 'Verify if a user or role with the name GDS_CATALOG_SELECT exists');
1096 check_table(i-1).valid_versions := '102,111,112';
1097 check_table(i-1).fix_type := c_fix_source_manual;
1098
1099 define_check (i, 'AWR_DBIDS_PRESENT', c_check_level_warning,
1100 'Verify if AWR contains inactive DBIDs');
1101 check_table(i-1).fix_type := c_fix_target_manual_post;
1102
1103 define_check (i, 'DV_ENABLED', c_check_level_warning,
1104 'Check if Database Vault is enabled');
1105 check_table(i-1).fix_type := c_fix_source_manual;
1106
1107 define_check (i, 'EM_PRESENT', c_check_level_warning,
1108 'Check if Enterprise Manager is present');
1109
1110 define_check (i, 'FILES_NEED_RECOVERY', c_check_level_error,
1111 'Check for any pending file recoveries');
1112 check_table(i-1).fix_type := c_fix_source_manual;
1113
1114 define_check (i, 'FILES_BACKUP_MODE', c_check_level_error,
1115 'Check for files in backup mode');
1116 check_table(i-1).fix_type := c_fix_source_manual;
1117
1118 define_check (i, '2PC_TXN_EXIST', c_check_level_error,
1119 'Check for unresolved distributed transactions');
1120 check_table(i-1).fix_type := c_fix_source_manual;
1121 check_table(i-1).f_name_prefix := 'pending_2pc_txn';
1122
1123 define_check (i, 'SYNC_STANDBY_DB', c_check_level_warning,
1124 'Check for unsynced database');
1125 check_table(i-1).fix_type := c_fix_source_manual;
1126
1127 define_check (i, 'ULTRASEARCH_DATA', c_check_level_warning,
1128 'Check for any UltraSearch data');
1129 check_table(i-1).fix_type := c_fix_source_manual;
1130
1131 define_check (i, 'REMOTE_REDO', c_check_level_error,
1132 'Check for invalid values for log_archive_dest_1');
1133 check_table(i-1).fix_type := c_fix_source_manual;
1134 check_table(i-1).valid_versions := '102, 111';
1135
1136 define_check (i, 'SYS_DEFAULT_TABLESPACE', c_check_level_warning,
1137 'Check that SYS/SYSTEM default tablespace is SYSTEM');
1138 check_table(i-1).f_name_prefix := 'SYS_DEF_TABLESPACE';
1139
1140 define_check (i, 'INVALID_LOG_ARCHIVE_FORMAT', c_check_level_error,
1141 'Check log_archive_format settings');
1142 check_table(i-1).fix_type := c_fix_source_manual;
1143 check_table(i-1).f_name_prefix := 'INVALID_LAF';
1144
1145 define_check (i, 'INVALID_USR_TABLEDATA', c_check_level_error,
1146 'Check for invalid (not converted) user table data');
1147 check_table(check_names('INVALID_USR_TABLEDATA').idx).fix_type :=
1148 c_fix_source_manual;
1149
1150 define_check (i, 'INVALID_SYS_TABLEDATA', c_check_level_error,
1151 'Check for invalid (not converted) table data');
1152 check_table(check_names('INVALID_SYS_TABLEDATA').idx).fix_type :=
1153 c_fix_source_manual;
1154
1155 define_check (i, 'ENABLED_INDEXES_TBL', c_check_level_warning,
1156 'Check for existance of sys.enabled$indexes table');
1157 define_check (i, 'ORDIMAGEINDEX', c_check_level_warning,
1158 'Check for use of Oracle Multimedia image domain index');
1159 check_table(i-1).fix_type := c_fix_source_manual;
1160
1161 define_check (i, 'DBMS_LDAP_DEPENDENCIES_EXIST', c_check_level_warning,
1162 'Check for dependency on DBMS_LDAP package');
1163 check_table(i-1).f_name_prefix := 'DBMS_LDAP_DEP_EXIST';
1164 check_table(i-1).fix_type := c_fix_source_manual;
1165
1166 define_check (i, 'REMOVE_DMSYS', c_check_level_warning,
1167 'Check for existance of DMSYS schema');
1168 check_table(i-1).valid_versions := '102,111,112,121';
1169
1170 define_check (i, 'INVALID_OBJECTS_EXIST', c_check_level_warning,
1171 'Check for invalid objects');
1172 check_table(i-1).f_name_prefix := 'INVALID_OBJ_EXIST';
1173 check_table(i-1).fix_type := c_fix_target_manual_post;
1174
1175 -- check if java mitigation patch is installed and JAVA development is DISABLED
1176 define_check (i, 'JVM_MITIGATION_PATCH', c_check_level_warning,
1177 'Check if JAVA mitigation patch is ENABLED.');
1178 check_table(i-1).fix_type := c_fix_source_manual;
1179
1180 define_check (i, 'AMD_EXISTS', c_check_level_info,
1181 'Check to see if AMD is present in the database');
1182 check_table(i-1).fix_type := c_fix_target_manual_pre;
1183 -- DBUA does their own.
1184 check_table(i-1).type := c_type_check_interactive_only;
1185
1186 define_check (i, 'EXF_RUL_EXISTS', c_check_level_info,
1187 'Check to see if EXF/RUL are present in the database');
1188 check_table(i-1).fix_type := c_fix_target_manual_pre;
1189
1190 define_check (i, 'NEW_TIME_ZONES_EXIST', c_check_level_error,
1191 'Check for use of newer timezone data file');
1192 check_table(i-1).fix_type := c_fix_target_manual_pre;
1193
1194 define_check (i, 'OLD_TIME_ZONES_EXIST', c_check_level_info,
1195 'Check for use of older timezone data file');
1196 check_table(i-1).fix_type := c_fix_target_manual_post;
1197
1198 define_check (i, 'PURGE_RECYCLEBIN', c_check_level_error,
1199 'Check that recycle bin is empty prior to upgrade');
1200
1201 define_check (i, 'NACL_OBJECTS_EXIST', c_check_level_warning,
1202 'Check for Network ACL Objects in use');
1203 check_table(i-1).fix_type := c_fix_source_manual;
1204
1205 define_check (i, 'JOB_QUEUE_PROCESS', c_check_level_warning,
1206 'Check JOB_QUEUE_PROCESSES value');
1207 -- This check may get changed to error in the _check routine
1208 check_table(i-1).fix_type := c_fix_source_manual;
1209
1210 -- Define RAS related pre-up checks
1211 define_check (i, 'PROVISIONER_PRESENT', c_check_level_error,
1212 'Verify if a user or role with the name PROVISIONER exists');
1213 check_table(i-1).valid_versions := '102,111,112';
1214 check_table(i-1).fix_type := c_fix_source_manual;
1215
1216 define_check (i, 'XS_RESOURCE_PRESENT', c_check_level_error,
1217 'Verify if a user or role with the name XS_RESOURCE exists');
1218 check_table(i-1).valid_versions := '102,111,112';
1219 check_table(i-1).fix_type := c_fix_source_manual;
1220
1221 define_check (i, 'XS_SESSION_ADMIN', c_check_level_error,
1222 'Verify if a user or role with the name XS_SESSION_ADMIN exists');
1223 check_table(i-1).valid_versions := '102,111,112';
1224 check_table(i-1).fix_type := c_fix_source_manual;
1225
1226 define_check (i, 'XS_NAMESPACE_ADMIN', c_check_level_error,
1227 'Verify if a user or role with the name XS_NAMESPACE_ADMIN exists');
1228 check_table(i-1).valid_versions := '102,111,112';
1229 check_table(i-1).fix_type := c_fix_source_manual;
1230
1231 define_check (i, 'XS_CACHE_ADMIN', c_check_level_error,
1232 'Verify if a user or role with the name XS_CACHE_ADMIN exists');
1233 check_table(i-1).valid_versions := '102,111,112';
1234 check_table(i-1).fix_type := c_fix_source_manual;
1235
1236 define_check (i, 'NOT_UPG_BY_STD_UPGRD', c_check_level_info,
1237 'Identify existing components that will NOT be upgraded');
1238 check_table(i-1).valid_versions := '102,111,112';
1239 check_table(i-1).fix_type := c_fix_target_manual_post;
1240
1241 define_check (i, 'EMX_BASIC_ROLE_PRESENT', c_check_level_error,
1242 'Verify if a user or role with the name EM_EXPRESS_BASIC exists');
1243 check_table(i-1).valid_versions := '102,111,112';
1244 check_table(i-1).fix_type := c_fix_source_manual;
1245
1246 define_check (i, 'EMX_ALL_ROLE_PRESENT', c_check_level_error,
1247 'Verify if a user or role with the name EM_EXPRESS_ALL exists');
1248 check_table(i-1).valid_versions := '102,111,112';
1249 check_table(i-1).fix_type := c_fix_source_manual;
1250
1251 -- check open_cursors value is at minimal value for APEX upgrades
1252 -- error condition
1253 define_check (i, 'OPEN_CURSORS', c_check_level_error,
1254 'Check that OPEN_CURSORS is set at 150 or higher');
1255 check_table(i-1).fix_type := c_fix_source_manual;
1256
1257 define_check (i, 'XBRL_VERSION', c_check_level_warning,
1258 'Check for existence of XBRLSYS schema');
1259 check_table(i-1).valid_versions := '112,121';
1260
1261 -- let user know that apex upgrade can be done manually prior to db upgrade
1262 define_check (i, 'APEX_UPGRADE_MSG', c_check_level_info,
1263 'Check that APEX will need to be upgraded.');
1264 check_table(i-1).fix_type := c_fix_source_manual;
1265
1266 -- check if user needs to know resource_limit's default is changing
1267 -- from FALSE to TRUE starting in 12102
1268 define_check (i, 'DEFAULT_RESOURCE_LIMIT', c_check_level_warning,
1269 'RESOURCE_LIMIT default has changed to TRUE starting 12.1.0.2');
1270 check_table(i-1).valid_versions := '102,111,112,121';
1271 check_table(i-1).fix_type := c_fix_source_manual;
1272
1273 -- recomend apply PSU if java mitigation patch is installed and JAVA development is DISABLED after upgrade
1274 define_check (i, 'POST_JVM_MITIGAT_PATCH', c_check_level_info,
1275 'Warn customer about JAVA mitigation patch is ENABLED at the end of the upgrade.');
1276 check_table(i-1).fix_type := c_fix_target_manual_post;
1277
1278 pCheckCount := i -1;
1279
1280 END init_preupchecks;
1281
1282
1283 PROCEDURE init_preuprecommend
1284 IS
1285 --
1286 -- Always start with the existing pCheckCount
1287 --
1288 i NUMBER := pCheckCount + 1;
1289
1290 BEGIN
1291
1292 -- ********************************************************
1293 -- Define the pre-up recommendations
1294 -- ********************************************************
1295 define_check (i, 'DICTIONARY_STATS', c_check_level_recommend,
1296 'Gather Dictionary Stats prior to upgrade');
1297 check_table(i-1).type := c_type_recommend_pre;
1298 define_check (i, 'HIDDEN_PARAMS', c_check_level_recommend,
1299 'Check for any hidden params defined');
1300 check_table(i-1).type := c_type_recommend_pre;
1301 define_check (i, 'UNDERSCORE_EVENTS', c_check_level_recommend,
1302 'Check for any underscore events that are defined');
1303 check_table(i-1).type := c_type_recommend_pre;
1304 define_check (i, 'AUDIT_RECORDS', c_check_level_recommend,
1305 'Recommend purging audit records');
1306 check_table(i-1).type := c_type_recommend_pre;
1307 define_check (i, 'FIXED_OBJECTS', c_check_level_recommend,
1308 'Recommend running stats on fixed objects');
1309 check_table(i-1).type := c_type_recommend_post;
1310 pCheckCount := i -1;
1311
1312 END init_preuprecommend;
1313
1314
1315 PROCEDURE init_initparams
1316 IS
1317 t_null CHAR(1);
1318 idx BINARY_INTEGER;
1319 BEGIN
1320
1321 --
1322 -- Initialize memory values for upgrade with minimum values
1323 --
1324 init_mem_sizes(minvp_db32, 32, max_minvp);
1325 init_mem_sizes(minvp_db64, 64, max_minvp);
1326 idx := max_minvp; -- set local variable idx to the last index used in minvp
1327
1328 --
1329 -- For manual mode, there is a complete preup-check for
1330 -- this.
1331 --
1332 store_minval_dbbit(0, idx,'processes', c_max_processes);
1333 max_minvp := idx; -- update last index used in minvp
1334
1335 END init_initparams;
1336
1337 PROCEDURE init_params
1338 IS
1339 i NUMBER;
1340 tmp_num2 NUMBER;
1341 tmp_num3 NUMBER;
1342 t_null CHAR(1);
1343 c_value VARCHAR2(80);
1344 idx BINARY_INTEGER;
1345
1346 BEGIN
1347
1348 /*
1349 To identify new obsolete and deprecated parameters, use the
1350 following queries and diff with the list from the prior release:
1351
1352 select name from v$obsolete_parameter order by name;
1353
1354 select name from v$parameter
1355 where isdeprecated = 'TRUE' order by name;
1356
1357 */
1358
1359 -- Load Obsolete and Deprecated parameters
1360
1361 -- Obsolete initialization parameters in release 8.0 --
1362 idx:=0;
1363 store_removed(idx,'checkpoint_process', '8.0', FALSE);
1364 store_removed(idx,'fast_cache_flush', '8.0', FALSE);
1365 store_removed(idx,'gc_db_locks', '8.0', FALSE);
1366 store_removed(idx,'gc_freelist_groups', '8.0', FALSE);
1367 store_removed(idx,'gc_rollback_segments', '8.0', FALSE);
1368 store_removed(idx,'gc_save_rollback_locks', '8.0', FALSE);
1369 store_removed(idx,'gc_segments', '8.0', FALSE);
1370 store_removed(idx,'gc_tablespaces', '8.0', FALSE);
1371 store_removed(idx,'io_timeout', '8.0', FALSE);
1372 store_removed(idx,'init_sql_files', '8.0', FALSE);
1373 store_removed(idx,'ipq_address', '8.0', FALSE);
1374 store_removed(idx,'ipq_net', '8.0', FALSE);
1375 store_removed(idx,'lm_domains', '8.0', FALSE);
1376 store_removed(idx,'lm_non_fault_tolerant', '8.0', FALSE);
1377 store_removed(idx,'mls_label_format', '8.0', FALSE);
1378 store_removed(idx,'optimizer_parallel_pass', '8.0', FALSE);
1379 store_removed(idx,'parallel_default_max_scans', '8.0', FALSE);
1380 store_removed(idx,'parallel_default_scan_size', '8.0', FALSE);
1381 store_removed(idx,'post_wait_device', '8.0', FALSE);
1382 store_removed(idx,'sequence_cache_hash_buckets', '8.0', FALSE);
1383 store_removed(idx,'unlimited_rollback_segments', '8.0', FALSE);
1384 store_removed(idx,'use_readv', '8.0', FALSE);
1385 store_removed(idx,'use_sigio', '8.0', FALSE);
1386 store_removed(idx,'v733_plans_enabled', '8.0', FALSE);
1387
1388 -- Obsolete in 8.1
1389 store_removed(idx,'allow_partial_sn_results', '8.1', FALSE);
1390 store_removed(idx,'arch_io_slaves', '8.1', FALSE);
1391 store_removed(idx,'b_tree_bitmap_plans', '8.1', FALSE);
1392 store_removed(idx,'backup_disk_io_slaves', '8.1', FALSE);
1393 store_removed(idx,'cache_size_threshold', '8.1', FALSE);
1394 store_removed(idx,'cleanup_rollback_entries', '8.1', FALSE);
1395 store_removed(idx,'close_cached_open_cursors', '8.1', FALSE);
1396 store_removed(idx,'complex_view_merging', '8.1', FALSE);
1397 store_removed(idx,'db_block_checkpoint_batch', '8.1', FALSE);
1398 store_removed(idx,'db_block_lru_extended_statistics', '8.1', FALSE);
1399 store_removed(idx,'db_block_lru_statistics', '8.1', FALSE);
1400 store_removed(idx,'db_file_simultaneous_writes', '8.1', FALSE);
1401 store_removed(idx,'delayed_logging_block_cleanouts', '8.1', FALSE);
1402 store_removed(idx,'discrete_transactions_enabled', '8.1', FALSE);
1403 store_removed(idx,'distributed_recovery_connection_hold_time', '8.1', FALSE);
1404 store_removed(idx,'ent_domain_name', '8.1', FALSE);
1405 store_removed(idx,'fast_full_scan_enabled', '8.1', FALSE);
1406 store_removed(idx,'freeze_DB_for_fast_instance_recovery', '8.1', FALSE);
1407 store_removed(idx,'gc_latches', '8.1', FALSE);
1408 store_removed(idx,'gc_lck_procs', '8.1', FALSE);
1409 store_removed(idx,'job_queue_keep_connections', '8.1', FALSE);
1410 store_removed(idx,'large_pool_min_alloc', '8.1', FALSE);
1411 store_removed(idx,'lgwr_io_slaves', '8.1', FALSE);
1412 store_removed(idx,'lm_locks', '8.1', FALSE);
1413 store_removed(idx,'lm_procs', '8.1', FALSE);
1414 store_removed(idx,'lm_ress', '8.1', FALSE);
1415 store_removed(idx,'lock_sga_areas', '8.1', FALSE);
1416 store_removed(idx,'log_archive_buffer_size', '8.1', FALSE);
1417 store_removed(idx,'log_archive_buffers', '8.1', FALSE);
1418 store_removed(idx,'log_block_checksum', '8.1', FALSE);
1419 store_removed(idx,'log_files', '8.1', FALSE);
1420 store_removed(idx,'log_simultaneous_copies', '8.1', FALSE);
1421 store_removed(idx,'log_small_entry_max_size', '8.1', FALSE);
1422 store_removed(idx,'mts_rate_log_size', '8.1', FALSE);
1423 store_removed(idx,'mts_rate_scale', '8.1', FALSE);
1424 store_removed(idx,'ogms_home', '8.1', FALSE);
1425 store_removed(idx,'ops_admin_group', '8.1', FALSE);
1426 store_removed(idx,'optimizer_search_limit', '8.1', FALSE);
1427 store_removed(idx,'parallel_default_max_instances', '8.1', FALSE);
1428 store_removed(idx,'parallel_min_message_pool', '8.1', FALSE);
1429 store_removed(idx,'parallel_server_idle_time', '8.1', FALSE);
1430 store_removed(idx,'parallel_transaction_resource_timeout', '8.1', FALSE);
1431 store_removed(idx,'push_join_predicate', '8.1', FALSE);
1432 store_removed(idx,'reduce_alarm', '8.1', FALSE);
1433 store_removed(idx,'row_cache_cursors', '8.1', FALSE);
1434 store_removed(idx,'sequence_cache_entries', '8.1', FALSE);
1435 store_removed(idx,'sequence_cache_hash_buckets', '8.1', FALSE);
1436 store_removed(idx,'shared_pool_reserved_min_alloc', '8.1', FALSE);
1437 store_removed(idx,'snapshot_refresh_interval', '8.1', FALSE);
1438 store_removed(idx,'snapshot_refresh_keep_connections', '8.1', FALSE);
1439 store_removed(idx,'snapshot_refresh_processes', '8.1', FALSE);
1440 store_removed(idx,'sort_direct_writes', '8.1', FALSE);
1441 store_removed(idx,'sort_read_fac', '8.1', FALSE);
1442 store_removed(idx,'sort_spacemap_size', '8.1', FALSE);
1443 store_removed(idx,'sort_write_buffer_size', '8.1', FALSE);
1444 store_removed(idx,'sort_write_buffers', '8.1', FALSE);
1445 store_removed(idx,'spin_count', '8.1', FALSE);
1446 store_removed(idx,'temporary_table_locks', '8.1', FALSE);
1447 store_removed(idx,'use_ism', '8.1', FALSE);
1448
1449 -- Obsolete in 9.0.1
1450 store_removed(idx,'always_anti_join', '9.0.1', FALSE);
1451 store_removed(idx,'always_semi_join', '9.0.1', FALSE);
1452 store_removed(idx,'db_block_lru_latches', '9.0.1', FALSE);
1453 store_removed(idx,'db_block_max_dirty_target', '9.0.1', FALSE);
1454 store_removed(idx,'gc_defer_time', '9.0.1', FALSE);
1455 store_removed(idx,'gc_releasable_locks', '9.0.1', FALSE);
1456 store_removed(idx,'gc_rollback_locks', '9.0.1', FALSE);
1457 store_removed(idx,'hash_multiblock_io_count', '9.0.1', FALSE);
1458 store_removed(idx,'instance_nodeset', '9.0.1', FALSE);
1459 store_removed(idx,'job_queue_interval', '9.0.1', FALSE);
1460 store_removed(idx,'ops_interconnects', '9.0.1', FALSE);
1461 store_removed(idx,'optimizer_percent_parallel', '9.0.1', FALSE);
1462 store_removed(idx,'sort_multiblock_read_count', '9.0.1', FALSE);
1463 store_removed(idx,'text_enable', '9.0.1', FALSE);
1464
1465 -- Obsolete in 9.2
1466 store_removed(idx,'distributed_transactions', '9.2', FALSE);
1467 store_removed(idx,'max_transaction_branches', '9.2', FALSE);
1468 store_removed(idx,'parallel_broadcast_enabled', '9.2', FALSE);
1469 store_removed(idx,'standby_preserves_names', '9.2', FALSE);
1470
1471 -- Obsolete in 10.1 (mts_ renames commented out)
1472 store_removed(idx,'dblink_encrypt_login', '10.1', FALSE);
1473 store_removed(idx,'hash_join_enabled', '10.1', FALSE);
1474 store_removed(idx,'log_parallelism', '10.1', FALSE);
1475 store_removed(idx,'max_rollback_segments', '10.1', FALSE);
1476 store_removed(idx,'mts_listener_address', '10.1', FALSE);
1477 store_removed(idx,'mts_multiple_listeners', '10.1', FALSE);
1478 store_removed(idx,'mts_service', '10.1', FALSE);
1479 store_removed(idx,'optimizer_max_permutations', '10.1', FALSE);
1480 store_removed(idx,'oracle_trace_collection_name', '10.1', FALSE);
1481 store_removed(idx,'oracle_trace_collection_path', '10.1', FALSE);
1482 store_removed(idx,'oracle_trace_collection_size', '10.1', FALSE);
1483 store_removed(idx,'oracle_trace_enable', '10.1', FALSE);
1484 store_removed(idx,'oracle_trace_facility_name', '10.1', FALSE);
1485 store_removed(idx,'oracle_trace_facility_path', '10.1', FALSE);
1486 store_removed(idx,'partition_view_enabled', '10.1', FALSE);
1487 store_removed(idx,'plsql_native_c_compiler', '10.1', FALSE);
1488 store_removed(idx,'plsql_native_linker', '10.1', FALSE);
1489 store_removed(idx,'plsql_native_make_file_name', '10.1', FALSE);
1490 store_removed(idx,'plsql_native_make_utility', '10.1', FALSE);
1491 store_removed(idx,'row_locking', '10.1', FALSE);
1492 store_removed(idx,'serializable', '10.1', FALSE);
1493 store_removed(idx,'transaction_auditing', '10.1', FALSE);
1494 store_removed(idx,'undo_suppress_errors', '10.1', FALSE);
1495
1496 -- Deprecated in 10.1, no new value
1497 store_removed(idx,'global_context_pool_size', '10.1', TRUE);
1498 store_removed(idx,'log_archive_start', '10.1', TRUE);
1499 store_removed(idx,'max_enabled_roles', '10.1', TRUE);
1500 store_removed(idx,'parallel_automatic_tuning', '10.1', TRUE);
1501
1502 store_removed(idx,'_average_dirties_half_life', '10.1', TRUE);
1503 store_removed(idx,'_compatible_no_recovery', '10.1', TRUE);
1504 store_removed(idx,'_db_no_mount_lock', '10.1', TRUE);
1505 store_removed(idx,'_lm_direct_sends', '10.1', TRUE);
1506 store_removed(idx,'_lm_multiple_receivers', '10.1', TRUE);
1507 store_removed(idx,'_lm_statistics', '10.1', TRUE);
1508 store_removed(idx,'_oracle_trace_events', '10.1', TRUE);
1509 store_removed(idx,'_oracle_trace_facility_version', '10.1', TRUE);
1510 store_removed(idx,'_seq_process_cache_const', '10.1', TRUE);
1511
1512 -- Obsolete in 10.2
1513 store_removed(idx,'enqueue_resources', '10.2', FALSE);
1514
1515 -- Deprecated, but not renamed in 10.2
1516 store_removed(idx,'logmnr_max_persistent_sessions', '10.2', TRUE);
1517 store_removed(idx,'max_commit_propagation_delay', '10.2', TRUE);
1518 store_removed(idx,'remote_archive_enable', '10.2', TRUE);
1519 store_removed(idx,'serial_reuse', '10.2', TRUE);
1520 store_removed(idx,'sql_trace', '10.2', TRUE);
1521
1522 -- Deprecated, but not renamed in 11.1
1523 store_removed(idx,'commit_write', '11.1', TRUE);
1524 store_removed(idx,'cursor_space_for_time', '11.1', TRUE);
1525 store_removed(idx,'instance_groups', '11.1', TRUE);
1526 store_removed(idx,'log_archive_local_first', '11.1', TRUE);
1527 store_removed(idx,'remote_os_authent', '11.1', TRUE);
1528 store_removed(idx,'sql_version', '11.1', TRUE);
1529 store_removed(idx,'standby_archive_dest', '11.1', TRUE);
1530 store_removed(idx,'plsql_v2_compatibility', '11.1', TRUE);
1531
1532 -- Instead a new parameter diagnostic_dest is
1533 -- replace two (core_dump_dest lives)
1534 store_removed(idx,'background_dump_dest', '11.1', TRUE);
1535 store_removed(idx,'user_dump_dest', '11.1', TRUE);
1536
1537 -- Obsolete in 11.1
1538
1539 store_removed(idx,'_log_archive_buffer_size', '11.1', FALSE);
1540 store_removed(idx,'_fast_start_instance_recover_target', '11.1', FALSE);
1541 store_removed(idx,'_lm_rcv_buffer_size', '11.1', FALSE);
1542 store_removed(idx,'ddl_wait_for_locks', '11.1', FALSE);
1543 store_removed(idx,'remote_archive_enable', '11.1', FALSE);
1544
1545 -- Deprecated in 11.2
1546 store_removed(idx,'active_instance_count', '11.2', TRUE);
1547 store_removed(idx,'cursor_space_for_time', '11.2', TRUE);
1548 store_removed(idx,'fast_start_io_target', '11.2', TRUE);
1549 store_removed(idx,'global_context_pool_size', '11.2', TRUE);
1550 store_removed(idx,'instance_groups', '11.2', TRUE);
1551 store_removed(idx,'lock_name_space', '11.2', TRUE);
1552 store_removed(idx,'log_archive_local_first', '11.2', TRUE);
1553 store_removed(idx,'max_commit_propagation_delay', '11.2', TRUE);
1554 store_removed(idx,'parallel_automatic_tuning', '11.2', TRUE);
1555 store_removed(idx,'parallel_io_cap_enabled', '11.2', TRUE);
1556 store_removed(idx,'resource_manager_cpu_allocation', '11.2', TRUE);
1557 store_removed(idx,'serial_reuse', '11.2', TRUE);
1558
1559 -- Obsolete in 11.2
1560 store_removed(idx,'drs_start', '11.2', FALSE);
1561 store_removed(idx,'gc_files_to_locks', '11.2', FALSE);
1562 store_removed(idx,'plsql_native_library_dir', '11.2', FALSE);
1563 store_removed(idx,'plsql_native_library_subdir_count', '11.2', FALSE);
1564 store_removed(idx,'sql_version', '11.2', FALSE);
1565 store_removed(idx,'cell_partition_large_extents', '11.2', FALSE);
1566
1567 -- Sessions removed for XE upgrade only
1568 IF db_is_XE THEN
1569 store_removed(idx,'sessions', '10.1', FALSE);
1570 END IF;
1571
1572 --
1573 -- Removed for 12.1
1574 --
1575 store_removed(idx,'_lm_validate_resource_type', '12.1', TRUE);
1576 store_removed(idx,'sec_case_sensitive_logon', '12.1', TRUE);
1577 max_op := idx;
1578
1579 -- Load Renamed parameters
1580
1581 -- Initialization Parameters Renamed in Release 8.0 --
1582 idx:=0;
1583 store_renamed(idx,'async_read','disk_asynch_io');
1584 store_renamed(idx,'async_write','disk_asynch_io');
1585 store_renamed(idx,'ccf_io_size','db_file_direct_io_count');
1586 store_renamed(idx,'db_file_standby_name_convert','db_file_name_convert');
1587 store_renamed(idx,'db_writers','dbwr_io_slaves');
1588 store_renamed(idx,'log_file_standby_name_convert',
1589 'log_file_name_convert');
1590 store_renamed(idx,'snapshot_refresh_interval','job_queue_interval');
1591
1592 -- Initialization Parameters Renamed in Release 8.1.4 --
1593 store_renamed(idx,'mview_rewrite_enabled','query_rewrite_enabled');
1594 store_renamed(idx,'rewrite_integrity','query_rewrite_integrity');
1595
1596 -- Initialization Parameters Renamed in Release 8.1.5 --
1597 store_renamed(idx,'nls_union_currency','nls_dual_currency');
1598 store_renamed(idx,'parallel_transaction_recovery',
1599 'fast_start_parallel_rollback');
1600
1601 -- Initialization Parameters Renamed in Release 9.0.1 --
1602 store_renamed(idx,'fast_start_io_target','fast_start_mttr_target');
1603 store_renamed(idx,'mts_circuits','circuits');
1604 store_renamed(idx,'mts_dispatchers','dispatchers');
1605 store_renamed(idx,'mts_max_dispatchers','max_dispatchers');
1606 store_renamed(idx,'mts_max_servers','max_shared_servers');
1607 store_renamed(idx,'mts_servers','shared_servers');
1608 store_renamed(idx,'mts_sessions','shared_server_sessions');
1609 store_renamed(idx,'parallel_server','cluster_database');
1610 store_renamed(idx,'parallel_server_instances',
1611 'cluster_database_instances');
1612
1613 -- Initialization Parameters Renamed in Release 9.2 --
1614 store_renamed(idx,'drs_start','dg_broker_start');
1615
1616 -- Initialization Parameters Renamed in Release 10.1 --
1617 store_renamed(idx,'lock_name_space','db_unique_name');
1618
1619 -- Initialization Parameters Renamed in Release 10.2 --
1620 -- none as of 4/1/05
1621
1622 -- Initialization Parameters Renamed in Release 11.2 --
1623
1624 store_renamed(idx,'buffer_pool_keep', 'db_keep_cache_size');
1625 store_renamed(idx,'buffer_pool_recycle', 'db_recycle_cache_size');
1626 store_renamed(idx,'commit_write', 'commit_logging,commit_wait');
1627
1628 max_rp := idx;
1629
1630 -- Initialize special initialization parameters
1631
1632 idx := 0;
1633 store_special(idx,'rdbms_server_dn',NULL,'ldap_directory_access','SSL');
1634 store_special(idx,'plsql_compiler_flags','INTERPRETED',
1635 'plsql_code_type','INTERPRETED');
1636 store_special(idx,'plsql_compiler_flags','NATIVE',
1637 'plsql_code_type','NATIVE');
1638 store_special(idx,'plsql_debug','TRUE',
1639 'plsql_optimize_level','1');
1640 store_special(idx,'plsql_compiler_flags','DEBUG',
1641 'plsql_optimize_level','1');
1642
1643 -- Only use these special parameters for databases
1644 -- in which Very Large Memory is not enabled
1645
1646 IF db_VLM_enabled = FALSE THEN
1647 store_special(idx,'db_block_buffers',NULL,
1648 'db_cache_size',NULL);
1649 store_special(idx,'buffer_pool_recycle',NULL,
1650 'db_recycle_cache_size',NULL);
1651 store_special(idx,'buffer_pool_keep',NULL,
1652 'db_keep_cache_size',NULL);
1653 END IF;
1654
1655 --
1656 -- for 12.1, AUDIT_TRAIL has depreicated several values
1657 -- that were allowed for AUDIT_TRAIL, they have new
1658 -- mappings.
1659 -- Use store_special - bug 2631483 and set the
1660 -- dbua_outInUpdate flag so output_xml_initparams
1661 -- dumps these out
1662 --
1663 store_special(idx,'audit_trail','FALSE',
1664 'audit_trail','NONE');
1665 sp(idx).dbua_OutInUpdate := TRUE;
1666 store_special(idx,'audit_trail','TRUE',
1667 'audit_trail','DB');
1668 sp(idx).dbua_OutInUpdate := TRUE;
1669 store_special(idx,'audit_trail','DB_EXTENDED',
1670 'audit_trail','DB,EXTENDED');
1671 sp(idx).dbua_OutInUpdate := TRUE;
1672
1673 max_sp := idx;
1674
1675 --
1676 -- Min value for db_block_size
1677 --
1678 idx := 0;
1679 store_required (idx, 'db_block_size', 2048, '', 3);
1680
1681 IF db_n_version = 102 THEN
1682 -- If undo_management is not specified in pre-11g database, then
1683 -- it needs to be specified MANUAL since the default is changing
1684 -- from MANUAL to AUTO starting in 11.1.
1685 store_required(idx, 'undo_management', 0, 'MANUAL', 2);
1686 END IF;
1687 max_reqp := idx;
1688
1689 --
1690 -- Now run through them and figure out what is
1691 -- or isn't in use.
1692 --
1693 FOR i IN 1..max_rp LOOP
1694 BEGIN
1695 EXECUTE IMMEDIATE 'SELECT NULL FROM v$parameter WHERE name =
1696 LOWER(:1) AND isdefault = ''FALSE'''
1697 INTO t_null
1698 USING rp(i).oldname;
1699 rp(i).db_match := TRUE;
1700 EXCEPTION WHEN NO_DATA_FOUND THEN
1701 rp(i).db_match := FALSE;
1702 END;
1703 END LOOP;
1704
1705 FOR i IN 1..max_op LOOP
1706 BEGIN
1707 EXECUTE IMMEDIATE 'SELECT NULL FROM v$parameter WHERE name =
1708 LOWER(:1) AND isdefault = ''FALSE'''
1709 INTO t_null
1710 USING op(i).name;
1711 op(i).db_match := TRUE;
1712 EXCEPTION WHEN NO_DATA_FOUND THEN
1713 op(i).db_match := FALSE;
1714 END;
1715 END LOOP;
1716
1717 --
1718 -- The store_special procedure inits the db_match to
1719 -- field to FALSE, so only when we match do we need to
1720 -- do something.
1721 --
1722 FOR i IN 1..max_sp LOOP
1723 BEGIN
1724 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name =
1725 LOWER(:1) AND isdefault = ''FALSE'''
1726 INTO c_value
1727 USING sp(i).oldname;
1728
1729 IF sp(i).oldvalue IS NULL OR c_value = sp(i).oldvalue THEN
1730
1731 sp(i).db_match := TRUE;
1732
1733 --
1734 -- No old value specified, or oldvalue is what we are
1735 -- looking for
1736 --
1737
1738 -- db_block_buffers
1739 -- Example: db_block_buffers = 7000
1740
1741 IF sp(i).oldname = 'db_block_buffers' THEN
1742 sp(i).newvalue := TO_CHAR(TO_NUMBER(c_value) * db_block_size);
1743
1744 ELSIF sp(i).oldname = 'buffer_pool_recycle' OR
1745 sp(i).oldname = 'buffer_pool_keep' THEN
1746
1747 -- buffer_pool_...
1748 -- Examples: buffer_pool_recycle= lru_latches:1, buffers:200
1749 -- buffer_pool_keep= (buffers:100,lru_latches:1)
1750
1751 IF INSTR(UPPER(c_value),'BUFFERS:') > 0 THEN -- has keyword
1752 IF INSTR(SUBSTR(c_value,INSTR(UPPER(c_value),
1753 'BUFFERS:')+8),',') > 0 THEN
1754 -- has second keyword after BUFFERS
1755 sp(i).newvalue := TO_CHAR(TO_NUMBER(SUBSTR(c_value,
1756 INSTR(UPPER(c_value),'BUFFERS:')+8,
1757 INSTR(c_value,',')-INSTR(UPPER(c_value),'BUFFERS:')-8))
1758 * db_block_size);
1759 ELSE -- no second keyword
1760 sp(i).newvalue := TO_CHAR(TO_NUMBER(SUBSTR(c_value,
1761 INSTR(UPPER(c_value),'BUFFERS:')+8)) * db_block_size);
1762 END IF; -- second keyword
1763 ELSIF INSTR(UPPER(c_value),',') > 0 THEN -- has keyword format #,#
1764 --
1765 -- In the #,# Format the first number before the comma is
1766 -- buffers second number is the lru latches. For the calculation
1767 -- we parse out the the buffer number and multiply
1768 -- by db_block_size.
1769 --
1770 tmp_num2 := INSTR(UPPER(c_value),',');
1771 sp(i).newvalue := TRIM(SUBSTR(c_value, 1, tmp_num2-1));
1772 sp(i).newvalue := TO_CHAR(TO_NUMBER(sp(i).newvalue)
1773 * db_block_size);
1774 ELSE -- no keywords, just number
1775 sp(i).newvalue := TO_CHAR(TO_NUMBER(c_value) * db_block_size);
1776 END IF; -- keywords
1777
1778 END IF; -- params with calculated values
1779
1780 ELSE
1781 --
1782 -- Oldvalue is not null or queried value isn't
1783 -- the oldvalue in the sp data.
1784 --
1785
1786 -- plsql_compiler_flags may contain two values
1787 -- in this case we process the list of values
1788
1789 IF (sp(i).oldname = 'plsql_compiler_flags') AND
1790 (INSTR(c_value,sp(i).oldvalue) > 0) THEN
1791 -- If 'DEBUG' value found in list then make sure
1792 -- it is not finding NON_DEBUG
1793 -- (using premise that DEBUG and NON_DEBUG do not mix)
1794 IF (sp(i).oldvalue='DEBUG' AND
1795 INSTR(c_value,'NON_DEBUG') = 0) OR
1796 (sp(i).oldvalue != 'DEBUG') THEN
1797 sp(i).db_match := TRUE;
1798 END IF;
1799 END IF;
1800 END IF;
1801 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
1802 END;
1803 END LOOP;
1804
1805 END init_params;
1806
1807 PROCEDURE init_components
1808 IS
1809 reg_cursor cursor_t;
1810 c_null CHAR(1);
1811 c_cid VARCHAR2(128);
1812 c_version VARCHAR2(128);
1813 c_schema VARCHAR2(128);
1814 n_schema NUMBER;
1815 n_status NUMBER;
1816
1817 BEGIN
1818 -- Clear all variable component data
1819 FOR i IN 1..max_comps LOOP
1820 cmp_info(i).sys_kbytes:= 2*c_kb;
1821 cmp_info(i).sysaux_kbytes:= 2*c_kb;
1822 cmp_info(i).def_ts_kbytes:= 0;
1823 cmp_info(i).ins_sys_kbytes:= 0;
1824 cmp_info(i).ins_def_kbytes:= 0;
1825 cmp_info(i).def_ts := NULL;
1826 cmp_info(i).processed := FALSE;
1827 cmp_info(i).install := FALSE;
1828 cmp_info(i).archivelog_kbytes := 0;
1829 cmp_info(i).flashbacklog_kbytes := 0;
1830 END LOOP;
1831
1832 -- Load component id and name
1833 cmp_info(catalog).cid := 'CATALOG';
1834 cmp_info(catalog).cname := 'Oracle Catalog Views';
1835 cmp_info(catproc).cid := 'CATPROC';
1836 cmp_info(catproc).cname := 'Oracle Packages and Types';
1837 cmp_info(javavm).cid := 'JAVAVM';
1838 cmp_info(javavm).cname := 'JServer JAVA Virtual Machine';
1839 cmp_info(xml).cid := 'XML';
1840 cmp_info(xml).cname := 'Oracle XDK for Java';
1841 cmp_info(catjava).cid := 'CATJAVA';
1842 cmp_info(catjava).cname := 'Oracle Java Packages';
1843 cmp_info(xdb).cid := 'XDB';
1844 cmp_info(xdb).cname := 'Oracle XML Database';
1845 cmp_info(rac).cid := 'RAC';
1846 cmp_info(rac).cname := 'Real Application Clusters';
1847 cmp_info(owm).cid := 'OWM';
1848 cmp_info(owm).cname := 'Oracle Workspace Manager';
1849 cmp_info(odm).cid := 'ODM';
1850 cmp_info(odm).cname := 'Data Mining';
1851 cmp_info(mgw).cid := 'MGW';
1852 cmp_info(mgw).cname := 'Messaging Gateway';
1853 cmp_info(aps).cid := 'APS';
1854 cmp_info(aps).cname := 'OLAP Analytic Workspace';
1855 cmp_info(xoq).cid := 'XOQ';
1856 cmp_info(xoq).cname := 'Oracle OLAP API';
1857 cmp_info(ordim).cid := 'ORDIM';
1858 cmp_info(ordim).cname := 'Oracle Multimedia';
1859 cmp_info(sdo).cid := 'SDO';
1860 cmp_info(sdo).cname := 'Oracle Spatial';
1861 cmp_info(context).cid := 'CONTEXT';
1862 cmp_info(context).cname := 'Oracle Text';
1863 cmp_info(wk).cid := 'WK';
1864 cmp_info(wk).cname := 'Oracle Ultra Search';
1865 cmp_info(ols).cid := 'OLS';
1866 cmp_info(ols).cname := 'Oracle Label Security';
1867 cmp_info(exf).cid := 'EXF';
1868 cmp_info(exf).cname := 'Expression Filter';
1869 cmp_info(em).cid := 'EM';
1870 cmp_info(em).cname := 'Oracle Enterprise Manager Repository';
1871 cmp_info(rul).cid := 'RUL';
1872 cmp_info(rul).cname := 'Rule Manager';
1873 cmp_info(apex).cid := 'APEX';
1874 cmp_info(apex).cname := 'Oracle Application Express';
1875 cmp_info(dv).cid := 'DV';
1876 cmp_info(dv).cname := 'Oracle Database Vault';
1877 cmp_info(misc).cid := 'STATS';
1878 cmp_info(misc).cname := 'Gather Statistics';
1879
1880 -- Initialize comp script names
1881
1882 IF db_n_version = 112 THEN
1883 --
1884 -- for 11.2, several components moved into
1885 -- catalog/catproc so they no longer have their own scripts
1886 --
1887 cmp_info(catalog).script := '?/rdbms/admin/catalog.sql';
1888 cmp_info(catproc).script := '?/rdbms/admin/catproc.sql';
1889 cmp_info(javavm).script := '?/javavm/install/jvmpatch.sql';
1890 cmp_info(xml).script := '?/xdk/admin/xmlpatch.sql';
1891 cmp_info(xdb).script := '?/rdbms/admin/xdbpatch.sql';
1892 cmp_info(rac).script := '?/rdbms/admin/catclust.sql';
1893 cmp_info(ols).script := '?/rdbms/admin/olspatch.sql';
1894 cmp_info(exf).script := '?/rdbms/admin/exfpatch.sql';
1895 cmp_info(rul).script := '?/rdbms/admin/rulpatch.sql';
1896 cmp_info(owm).script := '?/rdbms/admin/owmpatch.sql';
1897 cmp_info(ordim).script := '?/ord/im/admin/impatch.sql';
1898 cmp_info(sdo).script := '?/md/admin/sdopatch.sql';
1899 cmp_info(context).script := '?/ctx/admin/ctxpatch.sql';
1900 cmp_info(mgw).script := '?/mgw/admin/mgwpatch.sql';
1901 cmp_info(aps).script := '?/olap/admin/apspatch.sql';
1902 cmp_info(xoq).script := '?/olap/admin/xoqpatch.sql';
1903 cmp_info(apex).script := '?/apex/apxpatch.sql';
1904 cmp_info(dv).script := '?/rdbms/admin/dvpatch.sql';
1905 ELSE
1906 cmp_info(catalog).script := '?/rdbms/admin/catalog.sql';
1907 cmp_info(catproc).script := '?/rdbms/admin/catproc.sql';
1908 cmp_info(javavm).script := '?/javavm/install/jvmdbmig.sql';
1909 cmp_info(xml).script := '?/xdk/admin/xmldbmig.sql';
1910 cmp_info(xdb).script := '?/rdbms/admin/xdbdbmig.sql';
1911 cmp_info(rac).script := '?/rdbms/admin/catclust.sql';
1912 cmp_info(ols).script := '?/rdbms/admin/olsdbmig.sql';
1913 cmp_info(exf).script := '?/rdbms/admin/exfdbmig.sql';
1914 cmp_info(rul).script := '?/rdbms/admin/ruldbmig.sql';
1915 cmp_info(owm).script := '?/rdbms/admin/owmdbmig.sql';
1916 cmp_info(odm).script := '?/rdbms/admin/odmdbmig.sql';
1917 cmp_info(ordim).script := '?/ord/im/admin/imdbmig.sql';
1918 cmp_info(sdo).script := '?/md/admin/sdodbmig.sql';
1919 cmp_info(context).script := '?/ctx/admin/ctxdbmig.sql';
1920 cmp_info(wk).script := '?/rdbms/admin/wkremov.sql';
1921 cmp_info(mgw).script := '?/mgw/admin/mgwdbmig.sql';
1922 cmp_info(aps).script := '?/olap/admin/apsdbmig.sql';
1923 cmp_info(xoq).script := '?/olap/admin/xoqdbmig.sql';
1924 cmp_info(apex).script := '?/apex/apxdbmig.sql';
1925 cmp_info(dv).script := '?/rdbms/admin/dvdbmig.sql';
1926 END IF;
1927
1928 -- *****************************************************************
1929 -- Store Release Dependent Data
1930 -- *****************************************************************
1931
1932 -- kbytes for component installs (into SYSTEM and DEFAULT tablespaces)
1933 -- rae: add 10% for 11g .
1934 -- the '*1.2' below from point (a) to (b) are rae's .
1935 -- Point (a)
1936 cmp_info(javavm).ins_sys_kbytes:= 105972*1.2; -- rae's
1937 cmp_info(xml).ins_sys_kbytes:= 4818*1.2; -- rae's
1938 cmp_info(catjava).ins_sys_kbytes:= 5760*1.2; -- rae's
1939 cmp_info(xdb).ins_sys_kbytes := 10*c_kb * 1.2;
1940 IF db_block_size = 16384 THEN
1941 cmp_info(xdb).ins_def_kbytes:= (88*2)*c_kb * 1.2;
1942 ELSE
1943 cmp_info(xdb).ins_def_kbytes:= 88*c_kb * 1.2;
1944 END IF;
1945 cmp_info(ordim).ins_sys_kbytes := 10*c_kb * 1.2; -- actually saw 1MB
1946 cmp_info(ordim).ins_def_kbytes := 60*c_kb * 1.2;
1947 cmp_info(em).ins_sys_kbytes:= 0; -- was 22528*1.2 (rae's)
1948 cmp_info(em).ins_def_kbytes:= 0; -- was 51200*1.2 (rae's)
1949 -- Point (b)
1950
1951 -- If there's XMLIndex on the XDB Repository during APEX upgrade
1952 -- from 11107 to 121 (apex v3 to v4), then 316M increase in xdb is seen.
1953 -- 316M = 85M (increase in lob segments + tables owned by xdb) +
1954 -- 231M (increase in xmlindexes on xdb repository)
1955 -- (I.e., if no xmlindexes, then 85M of increase in XDB during APEX v3->v4
1956 -- upgrade.)
1957
1958 IF db_n_version = 102 THEN
1959 -- mult by 1.1 for experimental noise
1960 cmp_info(catalog).sys_kbytes:= 67*c_kb * 1.1;
1961 cmp_info(catproc).sys_kbytes:= (99+100)*c_kb * 1.1; -- catproc+catupend
1962 cmp_info(javavm).sys_kbytes:= 101*c_kb * 1.1;
1963 cmp_info(xdb).sys_kbytes:= 12*c_kb * 1.1;
1964 cmp_info(ordim).sys_kbytes:= 10*c_kb * 1.1;
1965 cmp_info(sdo).sys_kbytes:= 12*c_kb * 1.1;
1966 cmp_info(apex).sys_kbytes:= 81*c_kb * 1.1;
1967
1968 cmp_info(catalog).sysaux_kbytes:= 14*c_kb * 1.1;
1969 cmp_info(catproc).sysaux_kbytes:= 31*c_kb * 1.1;
1970 cmp_info(aps).sysaux_kbytes:= 36*c_kb * 1.1;
1971
1972 cmp_info(context).def_ts_kbytes:= 2*c_kb; -- CTXSYS , default
1973 cmp_info(exf).def_ts_kbytes:= 2*c_kb; -- EXFSYS , default
1974 cmp_info(apex).def_ts_kbytes:= 320*c_kb * 1.1; -- FLOWS_
1975 cmp_info(ordim).def_ts_kbytes:= 15*c_kb * 1.1; -- ORDSYS
1976 cmp_info(sdo).def_ts_kbytes:= 38*c_kb * 1.1; -- MDSYS
1977 cmp_info(em).def_ts_kbytes:= 0; -- SYSMAN
1978 cmp_info(catproc).def_ts_kbytes:= 31*c_kb * 1.1;
1979 cmp_info(owm).def_ts_kbytes:= 2*c_kb; -- WMSYS
1980 cmp_info(xdb).def_ts_kbytes:= 85*c_kb; -- XDB
1981 cmp_info(ols).def_ts_kbytes:= 2*c_kb; -- LBACSYS , default
1982 cmp_info(dv).def_ts_kbytes:= 2*c_kb; -- DVSYS , default
1983 cmp_info(aps).def_ts_kbytes := 37*c_kb * 1.1;
1984 cmp_info(wk).def_ts_kbytes:= 0; -- WK removed => 0 increase
1985
1986 ELSIF db_n_version = 111 THEN
1987
1988 -- mult by 1.1 or 1.2 for experimental noise
1989 cmp_info(catalog).sys_kbytes:= 64*c_kb * 1.1;
1990 cmp_info(catproc).sys_kbytes:= (59+123)*c_kb * 1.1; -- catproc+catupend
1991 cmp_info(javavm).sys_kbytes:= 49*c_kb * 1.1;
1992 cmp_info(context).sys_kbytes:= 7*c_kb * 1.1;
1993 cmp_info(xdb).sys_kbytes:= 2*c_kb * 1.1;
1994 cmp_info(ordim).sys_kbytes:= 50*c_kb * 1.1;
1995 cmp_info(sdo).sys_kbytes:= 11*c_kb * 1.1;
1996 cmp_info(apex).sys_kbytes:= 50*c_kb * 1.1;
1997 cmp_info(em).sys_kbytes:= 0;
1998
1999 cmp_info(catalog).sysaux_kbytes:= 12*c_kb * 1.1;
2000 cmp_info(catproc).sysaux_kbytes:= 21*c_kb * 1.1;
2001 cmp_info(aps).sysaux_kbytes:= 13*c_kb * 1.1;
2002
2003 cmp_info(context).def_ts_kbytes:= 2*c_kb; -- CTXSYS , default
2004 cmp_info(exf).def_ts_kbytes:= 2*c_kb; -- EXFSYS , default
2005 cmp_info(apex).def_ts_kbytes := 320*c_kb * 1.1; -- FLOWS_
2006 cmp_info(sdo).def_ts_kbytes:= 23*c_kb * 1.1; -- MDSYS
2007 cmp_info(ordim).def_ts_kbytes:= 15*c_kb * 1.1; -- ORDSYS
2008 cmp_info(em).def_ts_kbytes:= 0; -- SYSMAN, removed, 0 increase
2009 cmp_info(catproc).def_ts_kbytes:= 21*c_kb * 1.1;
2010 cmp_info(owm).def_ts_kbytes:= 2*c_kb; -- WMSYS, default
2011 cmp_info(xdb).def_ts_kbytes:= 85*c_kb; -- XDB
2012 cmp_info(ols).def_ts_kbytes:= 2*c_kb; -- LBACSYS , default
2013 cmp_info(dv).def_ts_kbytes:= 2*c_kb; -- DVSYS , default
2014 cmp_info(wk).def_ts_kbytes:= 0; -- WK removed => 0 increase
2015
2016 ELSIF db_n_version = 112 THEN
2017
2018 -- mult by 1.1 or 1.2 for experimental noise
2019 cmp_info(catalog).sys_kbytes:= 58*c_kb * 1.1;
2020 cmp_info(catproc).sys_kbytes:= (31+123)*c_kb * 1.1; -- catproc+catupend
2021 cmp_info(javavm).sys_kbytes:= 10*c_kb * 1.1;
2022 cmp_info(context).sys_kbytes:= 4*c_kb * 1.1;
2023 cmp_info(xdb).sys_kbytes:= 2*c_kb * 1.1;
2024 cmp_info(sdo).sys_kbytes:= 2*c_kb * 1.1;
2025 cmp_info(apex).sys_kbytes:= 50*c_kb * 1.1;
2026
2027 cmp_info(catalog).sysaux_kbytes:= 2*c_kb; -- default
2028 cmp_info(catproc).sysaux_kbytes:= 27*c_kb * 1.1;
2029
2030 -- apex: 269 is the amount of space needed (as seen from experiments) +
2031 -- 50 is the padding because if apex is in its own tablespace
2032 -- then having a padding would be good
2033 cmp_info(apex).def_ts_kbytes := 320*c_kb * 1.1; -- FLOWS_
2034
2035 cmp_info(sdo).def_ts_kbytes:= 10*c_kb * 1.1; -- MDSYS
2036 cmp_info(ordim).def_ts_kbytes:= 2*c_kb; -- ORDSYS , default
2037 cmp_info(em).def_ts_kbytes:= 0; -- SYSMAN , 0 increase
2038 cmp_info(owm).def_ts_kbytes:= 2*c_kb; -- WMSYS , default
2039 cmp_info(xdb).def_ts_kbytes:= 85*c_kb; -- XDB , default
2040 cmp_info(aps).def_ts_kbytes := 2*c_kb; -- default
2041 cmp_info(ols).def_ts_kbytes:= 2*c_kb; -- LBACSYS , default
2042 cmp_info(dv).def_ts_kbytes:= 2*c_kb; -- DVSYS , default
2043 cmp_info(wk).def_ts_kbytes:= 0; -- WK removed => 0 increase
2044
2045 ELSIF db_n_version = 121 THEN
2046 -- initial estimates of growth in patch release
2047 -- let's use 112 values for now (copy and paste of 112 values from above)
2048 -- CML: need to update for 121 patch upgrades
2049
2050 -- mult by 1.1 or 1.2 for experimental noise
2051 cmp_info(catalog).sys_kbytes:= 58*c_kb * 1.1;
2052 cmp_info(catproc).sys_kbytes:= (31+123)*c_kb * 1.1; -- catproc+catupend
2053 cmp_info(javavm).sys_kbytes:= 10*c_kb * 1.1;
2054 cmp_info(context).sys_kbytes:= 4*c_kb * 1.1;
2055 cmp_info(xdb).sys_kbytes:= 2*c_kb * 1.1;
2056 cmp_info(sdo).sys_kbytes:= 2*c_kb * 1.1;
2057 cmp_info(apex).sys_kbytes:= 50*c_kb * 1.1;
2058
2059 cmp_info(catalog).sysaux_kbytes:= 2*c_kb; -- default
2060 cmp_info(catproc).sysaux_kbytes:= 27*c_kb * 1.2;
2061
2062 cmp_info(apex).def_ts_kbytes := 320*c_kb * 1.1; -- FLOWS_
2063 cmp_info(sdo).def_ts_kbytes:= 10*c_kb * 1.1; -- MDSYS
2064 cmp_info(ordim).def_ts_kbytes:= 2*c_kb; -- ORDSYS , default
2065 cmp_info(em).def_ts_kbytes:= 0; -- SYSMAN , 0 increase
2066 cmp_info(owm).def_ts_kbytes:= 2*c_kb; -- WMSYS , default
2067 cmp_info(xdb).def_ts_kbytes:= 85*c_kb; -- XDB , default
2068 cmp_info(aps).def_ts_kbytes := 2*c_kb; -- default
2069 cmp_info(ols).def_ts_kbytes:= 2*c_kb; -- LBACSYS , default
2070 cmp_info(dv).def_ts_kbytes:= 2*c_kb; -- DVSYS , default
2071 cmp_info(wk).def_ts_kbytes:= 0; -- WK removed => 0 increase
2072
2073 END IF;
2074
2075 -- Flashback and archivelog for each database component
2076
2077 -- note: The unit of measurement in archivelog_kbytes and flashbacklog_kbytes
2078 -- below are in Kb.
2079 -- For example:
2080 -- cmp_info(catalog).archivelog_kbytes := 580*c_kb; <= is 593920 Kb
2081 -- cmp_info(catalog).flashbacklog_kbytes := 285*c_kb; <= is 291840 Kb
2082
2083 -- cml: Although AMD is not in 12c, let's save these 2 entries in case
2084 -- the amd info below is needed for future backports to older releases.
2085 -- cmp_info(amd).archivelog_kbytes := 43*c_kb;
2086 -- cmp_info(amd).flashbacklog_kbytes := 55*c_kb;
2087
2088
2089 cmp_info(catalog).archivelog_kbytes := 580*c_kb;
2090 cmp_info(catalog).flashbacklog_kbytes := 285*c_kb;
2091
2092 -- catproc = catproc + utlmmig + utlrp
2093 cmp_info(catproc).archivelog_kbytes := (705+410+312)*c_kb;
2094 cmp_info(catproc).flashbacklog_kbytes := (155+0+210)*c_kb;
2095
2096 cmp_info(javavm).archivelog_kbytes := 455*c_kb;
2097 cmp_info(javavm).flashbacklog_kbytes := 160*c_kb;
2098
2099 cmp_info(xml).archivelog_kbytes := 96*c_kb;
2100 cmp_info(xml).flashbacklog_kbytes := 55*c_kb;
2101
2102 cmp_info(aps).archivelog_kbytes := 96*c_kb;
2103
2104 cmp_info(dv).archivelog_kbytes := 47*c_kb;
2105
2106 cmp_info(context).archivelog_kbytes := 92*c_kb;
2107
2108 cmp_info(xdb).archivelog_kbytes := 174*c_kb;
2109 cmp_info(xdb).flashbacklog_kbytes := 55*c_kb;
2110
2111 cmp_info(catjava).archivelog_kbytes := 50*c_kb;
2112
2113 cmp_info(owm).archivelog_kbytes := 49*c_kb;
2114 cmp_info(owm).flashbacklog_kbytes := 60*c_kb;
2115
2116 cmp_info(ordim).archivelog_kbytes := 354*c_kb;
2117
2118 cmp_info(sdo).archivelog_kbytes := 487*c_kb;
2119 cmp_info(sdo).flashbacklog_kbytes := 115*c_kb;
2120
2121 cmp_info(apex).archivelog_kbytes := 822*c_kb;
2122
2123 cmp_info(xoq).archivelog_kbytes := 49*c_kb;
2124
2125 cmp_info(em).archivelog_kbytes := 415*c_kb;
2126 cmp_info(em).flashbacklog_kbytes := 447*c_kb;
2127
2128 -- For tablespace sizing
2129 -- CML: TS: estimate for utlrp later? utlrp space goes into system and
2130 -- system right now is not sized for utlrp.
2131 cmp_info(misc).sys_kbytes:= 100*c_kb; -- misc: round up to 100M fudge
2132 cmp_info(misc).sysaux_kbytes:= 50*c_kb; -- misc: round up to 50M fudge
2133
2134 --
2135 -- Grab the Component ID (varchar2) from
2136 -- registry, and then see if the
2137 -- schema exists in USER$ below which means its
2138 -- in use in this database.
2139 --
2140 OPEN reg_cursor FOR
2141 'SELECT cid, status, version, schema#
2142 FROM sys.registry$ WHERE namespace =''SERVER''';
2143
2144 LOOP
2145
2146 FETCH reg_cursor INTO c_cid, n_status, c_version, n_schema;
2147 EXIT WHEN reg_cursor%NOTFOUND;
2148
2149 -- If the status is not REMOVED or REMOVING
2150 IF n_status NOT IN (99,8)
2151 THEN
2152 EXECUTE IMMEDIATE 'SELECT name FROM sys.user$ WHERE user#=:1'
2153 INTO c_schema
2154 USING n_schema;
2155
2156 FOR i IN 1..max_components LOOP
2157 IF c_cid = cmp_info(i).cid
2158 THEN
2159 store_comp(i, c_schema, c_version, n_status);
2160 EXIT; -- from component search loop
2161 END IF;
2162 END LOOP; -- ignore if not in component list
2163 END IF;
2164 END LOOP;
2165 CLOSE reg_cursor;
2166
2167
2168 -- Ultra Search not in 10.1.0.2 registry so check schema
2169 IF NOT cmp_info(wk).processed THEN
2170 BEGIN
2171 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.user$ WHERE name = ''WKSYS'''
2172 INTO c_null;
2173 store_comp(wk, 'WKSYS', db_version, NULL);
2174 EXCEPTION
2175 WHEN NO_DATA_FOUND THEN NULL;
2176 END;
2177 END IF;
2178
2179 -- Check for HTML DB in 9.2.0 and 10.1 databases
2180 -- 121: Is this needed
2181 BEGIN
2182 EXECUTE IMMEDIATE 'SELECT FLOWS_010500.wwv_flows_release from sys.dual'
2183 INTO c_version;
2184 store_comp(apex,'FLOWS_010500',c_version, NULL);
2185 EXCEPTION
2186 WHEN OTHERS THEN NULL;
2187 END;
2188
2189 -- 121: Is this needed
2190 BEGIN
2191 EXECUTE IMMEDIATE 'SELECT FLOWS_010600.wwv_flows_release from sys.dual'
2192 INTO c_version;
2193 store_comp(apex,'FLOWS_010600',c_version, NULL);
2194 EXCEPTION
2195 WHEN OTHERS THEN NULL;
2196 END;
2197
2198 -- Check for APEX in 10.2 databases
2199 BEGIN
2200 EXECUTE IMMEDIATE 'SELECT FLOWS_020000.wwv_flows_release from sys.dual'
2201 INTO c_version;
2202 store_comp(apex,'FLOWS_020000',c_version, NULL);
2203 EXCEPTION
2204 WHEN OTHERS THEN NULL;
2205 END;
2206
2207 BEGIN
2208 EXECUTE IMMEDIATE 'SELECT FLOWS_020100.wwv_flows_release from sys.dual'
2209 INTO c_version;
2210 store_comp(apex,'FLOWS_020100',c_version, NULL);
2211 EXCEPTION
2212 WHEN OTHERS THEN NULL;
2213 END;
2214
2215 -- Database Vault not in registry so check for dvsys schema
2216 IF NOT cmp_info(dv).processed THEN
2217 BEGIN
2218 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.user$ WHERE name = ''DVSYS'''
2219 INTO c_null;
2220 store_comp(dv, 'DVSYS', '10.2.0', NULL);
2221 EXCEPTION
2222 WHEN NO_DATA_FOUND THEN NULL;
2223 END;
2224 END IF;
2225
2226 -- CML: TS: estimate for utlrp later?
2227 -- Consider MISC (miscellaneous) in registry because
2228 -- cmp_info(misc).processed has to be equal to TRUE before the tablespace
2229 -- sizing algorithm will consider the space needed for MISC.
2230 -- this call will set 'cmp_info(misc).processed := TRUE;'
2231 store_comp(misc, 'SYS', NULL, NULL);
2232
2233
2234 IF db_n_version != 112 THEN -- install required components on major release only
2235 -- if SDO, ORDIM, WK, EXF, or ODM components are present, need JAVAVM
2236 IF NOT cmp_info(javavm).processed THEN
2237 IF cmp_info(ordim).processed OR cmp_info(wk).processed OR
2238 cmp_info(exf).processed OR cmp_info(sdo).processed
2239 THEN
2240 store_comp(javavm, 'SYS', NULL, NULL);
2241 cmp_info(javavm).install := TRUE;
2242 store_comp(catjava, 'SYS', NULL, NULL);
2243 cmp_info(catjava).install := TRUE;
2244 END IF;
2245 END IF;
2246
2247 -- If there is a JAVAVM component
2248 -- THEN include the CATJAVA component.
2249 IF cmp_info(javavm).processed AND NOT cmp_info(catjava).processed
2250 THEN
2251 store_comp(catjava, 'SYS', NULL, NULL);
2252 cmp_info(catjava).install := TRUE;
2253 END IF;
2254
2255 -- If interMedia or Spatial component, but no XML, Then
2256 -- install XML
2257 IF NOT cmp_info(xml).processed AND
2258 (cmp_info(ordim).processed OR cmp_info(sdo).processed)
2259 THEN
2260 store_comp(xml, 'SYS', NULL, NULL);
2261 cmp_info(xml).install := TRUE;
2262 END IF;
2263
2264 -- If no XDB, Then install XDB
2265 IF NOT cmp_info(xdb).processed THEN
2266 store_comp(xdb, 'XDB', NULL, NULL);
2267 cmp_info(xdb).install := TRUE;
2268 cmp_info(xdb).def_ts := 'SYSAUX';
2269 END IF;
2270
2271 -- If Spatial component, but no ORDIM, Then
2272 -- install ORDIM
2273 IF NOT cmp_info(ordim).processed AND
2274 (cmp_info(sdo).processed)
2275 THEN
2276 store_comp(ordim, 'ORDSYS', NULL, NULL);
2277 cmp_info(ordim).install := TRUE;
2278 cmp_info(ordim).def_ts := 'SYSAUX';
2279 END IF;
2280 END IF; -- not for patch release
2281
2282 END init_components;
2283
2284 PROCEDURE init_resources
2285 IS
2286 idx BINARY_INTEGER;
2287 tmp_cursor cursor_t;
2288 tmp_num1 NUMBER;
2289 tmp_num2 NUMBER;
2290 delta_queues INTEGER;
2291 delta_kbytes NUMBER;
2292 p_tsname VARCHAR2(128);
2293 tmp_varchar1 VARCHAR2(128);
2294 tmp_varchar2 VARCHAR2(128);
2295 tmp_filename SYS.DBA_TEMP_FILES.FILE_NAME%TYPE;
2296 p_status VARCHAR2(30);
2297 sum_bytes NUMBER;
2298 p_count INTEGER;
2299 default_tablespaces VARCHAR2(4000);
2300
2301 BEGIN
2302 --
2303 -- Misc stand-along values we report about
2304 --
2305 pMinFlashbackLogGen := 0;
2306 pminArchiveLogGen := 0;
2307
2308 idx := 0;
2309
2310 -- we know we need SYSTEM and SYSAUX in the list of tablespaces anyway, add 'em now.
2311 default_tablespaces := '''SYSTEM'', ''SYSAUX''';
2312
2313 FOR i in 1..max_comps LOOP
2314 IF (cmp_info(i).def_ts is not null) THEN
2315 -- there is not a worry about overflowing default_tablespaces or sql injection. The values we pull from .def_ts
2316 -- are all hardcoded in this program, and as a result, we could just hardcode default_tablespaces too, but to
2317 -- make room for smooth changes in the future, this loop guarantees we pick up new def_ts's. The current list
2318 -- as of 12.1.0.2 is only 'SYSTEM', 'SYSAUX'.
2319
2320 -- push a new tablespace onto the list only if it doesn't exist on the list already
2321 IF (instr(default_tablespaces,'''' || cmp_info(i).def_ts || '''') = 0) THEN
2322 default_tablespaces := default_tablespaces || ',''' || cmp_info(i).def_ts || '''';
2323 END IF;
2324 END IF;
2325 END LOOP;
2326
2327 OPEN tmp_cursor FOR
2328 'SELECT tablespace_name, contents, extent_management FROM SYS.dba_tablespaces ' ||
2329 'WHERE tablespace_name in (:1,' || default_tablespaces || ') or ' ||
2330 'tablespace_name in (SELECT distinct T.tablespace_name ' ||
2331 'FROM sys.dba_queues Q, ' ||
2332 'sys.dba_tables T ' ||
2333 'WHERE Q.queue_table=T.table_name AND Q.owner = T.owner) or ' ||
2334 'tablespace_name in (SELECT temporary_tablespace ' ||
2335 'FROM sys.dba_users ' ||
2336 'WHERE username = ''SYS'') '
2337 USING db_undo_tbs;
2338 LOOP
2339 FETCH tmp_cursor INTO p_tsname, tmp_varchar1, tmp_varchar2;
2340 EXIT WHEN tmp_cursor%NOTFOUND;
2341 --
2342 -- Comment out the following IF statement.
2343 -- Previously, the containing LOOP used to simply select ALL tablespaces into cursor tmp_cursor
2344 -- and use the following IF to process only the tablespaces that meet the IF's condition.
2345 -- The problem was that the condition in the IF involved multiple SELECT statements
2346 -- that were embedded in the called routines (ts_has_queues, ts_is_SYS_temporary) and since those
2347 -- SELECTS were in a LOOP, performance would suffer too much if there were a lot of tablespaces
2348 -- (Too many LOOP iterations when the cost of each iteration was non-trivial.)
2349 -- The new code essentially moves the condition of the IF statement into the original TMP_CURSOR select.
2350 -- Now, even if the performance of the tmp_cursor SELECT is a little slow, it will only be executed once,
2351 -- and the expensive ts_has_queues and ts_is_SYS_temporary calls aren't in the body of the LOOP.
2352 --
2353 -- IF p_tsname IN ('SYSTEM', 'SYSAUX', db_undo_tbs) OR
2354 -- is_comp_tablespace(p_tsname) OR
2355 -- ts_has_queues (p_tsname) OR
2356 -- ts_is_SYS_temporary (p_tsname) THEN
2357
2358 idx := idx + 1;
2359 ts_info(idx).name := p_tsname;
2360 IF tmp_varchar1 = 'TEMPORARY' THEN
2361 ts_info(idx).temporary := TRUE;
2362 ELSE
2363 ts_info(idx).temporary := FALSE;
2364 END IF;
2365
2366 IF tmp_varchar2 = 'LOCAL' THEN
2367 ts_info(idx).localmanaged := TRUE;
2368 ELSE
2369 ts_info(idx).localmanaged := FALSE;
2370 END IF;
2371
2372 -- Get number of kbytes used
2373 EXECUTE IMMEDIATE
2374 'SELECT SUM(bytes) FROM sys.dba_segments seg WHERE seg.tablespace_name = :1'
2375 INTO sum_bytes
2376 USING p_tsname;
2377 IF sum_bytes IS NULL THEN
2378 ts_info(idx).inuse := 0;
2379 ELSIF sum_bytes <= c_kb THEN
2380 ts_info(idx).inuse := 1;
2381 ELSE
2382 ts_info(idx).inuse := ROUND(sum_bytes/c_kb);
2383 END IF;
2384 -- TS: calculate space used per tablespace (ts_info(idx).name)
2385
2386 -- Get number of kbytes allocated
2387 IF ts_info(idx).temporary AND
2388 ts_info(idx).localmanaged THEN
2389 EXECUTE IMMEDIATE
2390 'SELECT SUM(bytes) FROM sys.dba_temp_files files WHERE ' ||
2391 'files.tablespace_name = :1'
2392 INTO sum_bytes
2393 USING p_tsname;
2394 ELSE
2395 EXECUTE IMMEDIATE
2396 'SELECT SUM(bytes) FROM sys.dba_data_files files WHERE ' ||
2397 'files.tablespace_name = :1'
2398 INTO sum_bytes
2399 USING p_tsname;
2400 END IF;
2401
2402 IF sum_bytes IS NULL THEN
2403 ts_info(idx).alloc:=0;
2404 ELSIF sum_bytes <= c_kb THEN
2405 ts_info(idx).alloc:=1;
2406 ELSE
2407 ts_info(idx).alloc:=ROUND(sum_bytes/c_kb);
2408 END IF;
2409
2410 -- Get number of kbytes of unused autoextend
2411 IF ts_info(idx).temporary AND
2412 ts_info(idx).localmanaged THEN
2413 EXECUTE IMMEDIATE
2414 'SELECT SUM(decode(maxbytes, 0, 0, maxbytes-bytes)) ' ||
2415 'FROM sys.dba_temp_files WHERE tablespace_name=:1'
2416 INTO sum_bytes
2417 USING p_tsname;
2418 ELSE
2419 EXECUTE IMMEDIATE
2420 'SELECT SUM(decode(maxbytes, 0, 0, maxbytes-bytes)) ' ||
2421 'FROM sys.dba_data_files WHERE tablespace_name=:1'
2422 INTO sum_bytes
2423 USING p_tsname;
2424 END IF;
2425
2426 IF sum_bytes IS NULL THEN
2427 ts_info(idx).auto:=0;
2428 ELSIF sum_bytes <= c_kb THEN
2429 ts_info(idx).auto:=1;
2430 ELSE
2431 ts_info(idx).auto:=ROUND(sum_bytes/c_kb);
2432 END IF;
2433
2434 -- total available is allocated plus auto extend
2435 ts_info(idx).avail := ts_info(idx).alloc + ts_info(idx).auto;
2436 -- END IF;
2437 END LOOP;
2438 CLOSE tmp_cursor;
2439
2440 max_ts := idx; -- max tablespaces of interest
2441
2442 -- *****************************************************************
2443 -- Collect Public Rollback Information
2444 -- *****************************************************************
2445
2446 idx := 0;
2447 IF db_undo != 'AUTO' THEN -- using rollback segments
2448
2449 OPEN tmp_cursor FOR
2450 'SELECT segment_name, next_extent, max_extents, status FROM SYS.dba_rollback_segs
2451 WHERE owner=''PUBLIC'' OR (owner=''SYS'' AND segment_name != ''SYSTEM'')';
2452 LOOP
2453 FETCH tmp_cursor INTO tmp_varchar1, tmp_num1, tmp_num2, p_status;
2454 EXIT WHEN tmp_cursor%NOTFOUND;
2455 BEGIN
2456 --- get sum of bytes and tablespace name
2457 EXECUTE IMMEDIATE
2458 'SELECT tablespace_name, sum(bytes) FROM sys.dba_segments
2459 WHERE segment_name = :1 AND ROWNUM = 1 GROUP BY tablespace_name'
2460 INTO p_tsname, sum_bytes
2461 USING tmp_varchar1;
2462 IF sum_bytes < c_kb THEN
2463 sum_bytes := 1;
2464 ELSE
2465 sum_bytes := sum_bytes/c_kb;
2466 END IF;
2467 EXCEPTION WHEN NO_DATA_FOUND THEN
2468 sum_bytes := NULL;
2469 END;
2470
2471 IF sum_bytes IS NOT NULL THEN
2472 idx:=idx + 1;
2473 rs_info(idx).tbs_name := p_tsname;
2474 rs_info(idx).seg_name := tmp_varchar1;
2475 rs_info(idx).status := p_status;
2476 rs_info(idx).next := tmp_num1/c_kb;
2477 rs_info(idx).max_ext := tmp_num2;
2478 rs_info(idx).inuse := sum_bytes;
2479 EXECUTE IMMEDIATE
2480 'SELECT ROUND(SUM(DECODE(maxbytes, 0, 0,maxbytes-bytes)/:1))
2481 FROM sys.dba_data_files WHERE tablespace_name=:2'
2482 INTO rs_info(idx).auto
2483 USING c_kb, p_tsname;
2484
2485 EXECUTE IMMEDIATE
2486 'SELECT ROUND(SUM(DECODE(maxbytes, 0, 0,maxbytes-bytes)/:1))
2487 FROM sys.dba_data_files WHERE tablespace_name=:2'
2488 INTO tmp_num1
2489 USING c_kb, p_tsname;
2490 END IF;
2491 END LOOP;
2492 CLOSE tmp_cursor;
2493 END IF; -- using undo tablespace, not rollback
2494
2495 max_rs := idx;
2496
2497 -- *****************************************************************
2498 -- Determine free space needed if
2499 -- Archiving was on;
2500 -- Flashback Database was on
2501 -- We only report the values if they are actually on.
2502 -- *****************************************************************
2503
2504 -- calculate the minimum amount of archive and flashback logs used
2505 -- for an upgrade for each component.
2506 --
2507 -- This is only an issue when db_log_mode = 'ARCHIVELOG'
2508 --
2509 FOR i in 1..max_comps LOOP
2510 IF cmp_info(i).processed THEN
2511 pMinArchiveLogGen := pMinArchiveLogGen
2512 + cmp_info(i).archivelog_kbytes;
2513 pMinFlashbackLogGen := pMinFlashbackLogGen
2514 + cmp_info(i).flashbacklog_kbytes;
2515 END IF;
2516 END LOOP;
2517
2518 -- The numbers used were seen from experiments. Add 10% for experimental
2519 -- noise.
2520 pMinArchiveLogGen := pMinArchiveLogGen * 1.1;
2521 pMinFlashbackLogGen := pMinFlashbackLogGen * 1.1;
2522
2523 -- Total recovery area needed is:
2524 -- pMinArchiveLogGen + pMinFlashbacklogGen;
2525
2526 -- *****************************************************************
2527 -- Collect Flashback Information
2528 -- *****************************************************************
2529
2530 flashback_info.active := FALSE;
2531 flashback_info.name := '';
2532 flashback_info.limit := 0;
2533 flashback_info.used := 0;
2534 flashback_info.reclaimable := 0;
2535 flashback_info.files := 0;
2536 flashback_info.file_dest := '';
2537 flashback_info.dsize := 0;
2538
2539 IF db_flashback_on THEN
2540 --
2541 -- Get the rest of the flashback settings
2542 --
2543 flashback_info.active := TRUE;
2544
2545 BEGIN
2546 EXECUTE IMMEDIATE 'SELECT rfd.name, rfd.space_limit, rfd.space_used,
2547 rfd.space_reclaimable, rfd.number_of_files,
2548 vp1.value, vp2.value
2549 FROM v$recovery_file_dest rfd, v$parameter vp1, v$parameter vp2
2550 WHERE UPPER(vp1.name) = ''DB_RECOVERY_FILE_DEST'' AND
2551 UPPER(vp2.name) = ''DB_RECOVERY_FILE_DEST_SIZE'''
2552 INTO flashback_info.name, flashback_info.limit, flashback_info.used,
2553 flashback_info.reclaimable, flashback_info.files,
2554 flashback_info.file_dest, flashback_info.dsize;
2555 EXCEPTION
2556 WHEN NO_DATA_FOUND THEN flashback_info.active := FALSE;
2557 END;
2558 END IF;
2559
2560 -- *****************************************************************
2561 -- Calculate Tablespace Requirements
2562 -- *****************************************************************
2563
2564 -- Look at all relevant tablespaces
2565 -- TS: loop per tablespace (ts_info(t).name)
2566 FOR t IN 1..max_ts LOOP
2567 delta_kbytes:=0; -- initialize calculated tablespace delta
2568
2569 IF ts_info(t).name = 'SYSTEM' THEN -- sum the component SYS kbytes
2570 FOR i IN 1..max_comps LOOP
2571
2572 IF pDBGSizeResources THEN
2573 IF cmp_info(i).processed THEN
2574 DisplayDiagLine (cmp_info(i).cid || ' Processed. ' || ' Default Tblspace ' || cmp_info(i).def_ts || '.');
2575 ELSE
2576 DisplayDiagLine (cmp_info(i).cid || ' NOT Processed.');
2577 END IF;
2578 END IF;
2579
2580 IF cmp_info(i).processed THEN
2581 IF cmp_info(i).install THEN -- if component will be installed
2582 delta_kbytes := delta_kbytes + cmp_info(i).ins_sys_kbytes;
2583 IF pDBGSizeResources THEN
2584 DisplayDiagLine ('SYSTEM ' ||
2585 LPAD(cmp_info(i).cid, 10) || ' ToBeInstalled ' ||
2586 LPAD(cmp_info(i).ins_sys_kbytes/c_kb,10) || 'Mb');
2587 END IF;
2588 ELSE -- if component is already in the registry
2589 delta_kbytes := delta_kbytes + cmp_info(i).sys_kbytes;
2590 IF pDBGSizeResources THEN
2591 DisplayDiagLine ('SYSTEM ' ||
2592 LPAD(cmp_info(i).cid, 10) || ' IsInRegistry ' ||
2593 LPAD(cmp_info(i).sys_kbytes/c_kb,10) || 'Mb');
2594 END IF;
2595 END IF;
2596 END IF; -- nothing to add if component is or will not be in
2597 -- the registry
2598 END LOOP;
2599 END IF; -- end of special SYSTEM tablespace processing
2600 -- TS: delta after looping through components in SYSTEM
2601
2602 IF ts_info(t).name = 'SYSAUX' THEN -- sum the component SYSAUX kbytes
2603 FOR i IN 1..max_comps LOOP
2604 IF cmp_info(i).processed AND
2605 (cmp_info(i).def_ts = 'SYSAUX' OR
2606 cmp_info(i).def_ts = 'SYSTEM') THEN
2607 IF cmp_info(i).sysaux_kbytes >= cmp_info(i).def_ts_kbytes THEN
2608 delta_kbytes := delta_kbytes + cmp_info(i).sysaux_kbytes;
2609 ELSE
2610 delta_kbytes := delta_kbytes + cmp_info(i).def_ts_kbytes;
2611 END IF;
2612 IF pDBGSizeResources THEN
2613 DisplayDiagLine('SYSAUX ' ||
2614 LPAD(cmp_info(i).cid, 10) || ' ' ||
2615 LPAD(cmp_info(i).sysaux_kbytes/c_kb,10) || 'Mb');
2616 END IF;
2617 -- bug 13060071 : apex , xdb
2618 -- if xdb and apex are both in db, then add 316M-85M (or 231M
2619 -- more) to sysaux if xdb resides here
2620 IF (cmp_info(i).cid = 'XDB'
2621 AND cmp_info(apex).processed = TRUE) THEN
2622 delta_kbytes := delta_kbytes + (231*c_kb);
2623 IF pDBGSizeResources THEN
2624 DisplayDiagLine('SYSAUX ' ||
2625 LPAD(cmp_info(i).cid, 10) || ' ' || '(due to APEX) ' ||
2626 LPAD(231, 10) || 'Mb');
2627 END IF;
2628 END IF;
2629 END IF;
2630 END LOOP;
2631 END IF; -- end of special SYSAUX tablespace processing
2632 -- TS: sum delta for components in SYSAUX
2633
2634 -- For tablespaces that are not SYSTEM:
2635 -- For tablespaces that are not SYSAUX:
2636 -- For tablespaces that are not UNDO:
2637 -- Now add in component default tablespace deltas
2638 -- def_tablespace_name is NULL for unprocessed comps
2639
2640 IF (ts_info(t).name != 'SYSTEM' AND
2641 ts_info(t).name != 'SYSAUX' AND
2642 ts_info(t).name != db_undo_tbs) THEN
2643 FOR i IN 1..max_comps LOOP
2644 IF (ts_info(t).name = cmp_info(i).def_ts AND
2645 cmp_info(i).processed) THEN
2646 IF cmp_info(i).install THEN -- use install amount
2647 delta_kbytes := delta_kbytes + cmp_info(i).ins_def_kbytes;
2648 IF pDBGSizeResources THEN
2649 DisplayDiagLine( RPAD(ts_info(t).name, 10) ||
2650 LPAD(cmp_info(i).cid, 10) || ' ' ||
2651 LPAD(cmp_info(i).ins_def_kbytes,10));
2652 END IF;
2653
2654 ELSE -- use default tablespace amount
2655 -- bug 9664514
2656 -- if apex version in the source db is older than the version
2657 -- in target db, then apex upgrade include apex install;
2658 -- estimate 180M for typical apex install.
2659 -- note: this section is for space calculations for
2660 -- tablespaces that are non-system and non-sysaux
2661 delta_kbytes := delta_kbytes + cmp_info(i).def_ts_kbytes;
2662
2663 IF pDBGSizeResources THEN
2664 DisplayDiagLine(RPAD(ts_info(t).name, 10) ||
2665 LPAD(cmp_info(i).cid, 10) || ' ' ||
2666 LPAD(cmp_info(i).def_ts_kbytes/c_kb, 10) || 'Mb');
2667 --update_puiu_data('SCHEMA',
2668 -- ts_info(t).name || '-' || cmp_info(i).schema,
2669 -- cmp_info(i).def_ts_kbytes);
2670 END IF;
2671 END IF;
2672
2673 -- bug 13060071 : apex , xdb
2674 -- if xdb and apex are both in db, then add 316M-85M (or 231M
2675 -- more) to xdb default tablespace
2676 IF (cmp_info(i).cid = 'XDB' AND
2677 cmp_info(apex).processed = TRUE) THEN
2678 delta_kbytes := delta_kbytes + (231*c_kb);
2679 IF pDBGSizeResources THEN
2680 DisplayDiagLine(RPAD(ts_info(t).name, 10) || ' ' ||
2681 LPAD(cmp_info(i).cid, 10) || ' ' ||
2682 '(due to APEX) ' || LPAD(231, 10) || 'Mb');
2683 END IF;
2684 END IF;
2685 END IF;
2686 END LOOP; -- end of default tablespace calculations
2687 END IF; -- end of if tblspace is not undo and not sysaux and not system
2688 -- then add in component default tablespace deltas
2689
2690 -- TS: sum delta for install in default tablespaces other than
2691 -- SYSAUX
2692
2693 -- For tablespaces that are not undo:
2694 -- Now look for queues in user schemas
2695 IF ts_info(t).name != db_undo_tbs THEN
2696 EXECUTE IMMEDIATE 'SELECT count(*) FROM sys.dba_tables tb, sys.dba_queues q
2697 WHERE q.queue_table = tb.table_name AND
2698 tb.tablespace_name = '' || ts_info(t).name || '' AND tb.owner NOT IN
2699 (''SYS'',''SYSTEM'',''MDSYS'',''ORDSYS'',''OLAPSYS'',''XDB'',
2700 ''LBACSYS'',''CTXSYS'',''ODM'',''DMSYS'', ''WKSYS'',''WMSYS'',
2701 ''SYSMAN'',''EXFSYS'') '
2702 INTO delta_queues;
2703
2704 IF delta_queues > 0 THEN
2705 delta_kbytes := delta_kbytes + delta_queues*48;
2706 IF pDBGSizeResources THEN
2707 DisplayDiagLine(RPAD(ts_info(t).name, 10) ||
2708 ' QUEUE count = ' || delta_queues);
2709 END IF;
2710 END IF;
2711 END IF; -- end of if tablespace is not undo
2712 -- then look for queues in user schemas
2713
2714 -- See if this is the temporary tablespace for SYS
2715 IF ts_is_SYS_temporary(ts_info(t).name) THEN
2716 delta_kbytes := delta_kbytes + 50*c_kb; -- Add 50M for TEMP
2717 END IF;
2718
2719 -- See if this is the UNDO tablespace - be sure at least
2720 -- 400M (or c_undo_minsz_kb) is available
2721 IF ts_info(t).name = db_undo_tbs THEN
2722 ts_info(t).min := c_undo_minsz_kb;
2723 IF ts_info(t).alloc < ts_info(t).min THEN
2724 delta_kbytes := ts_info(t).min - ts_info(t).inuse;
2725 ELSE
2726 delta_kbytes := 0;
2727 END IF;
2728 END IF; -- end of if this is the undo tablespace
2729
2730 -- If DBUA output, then add in EM install if not in database
2731 IF pOutputType = c_output_xml THEN
2732 IF NOT cmp_info(em).processed THEN
2733 IF ts_info(t).name = 'SYSTEM' THEN
2734 delta_kbytes := delta_kbytes + cmp_info(em).ins_sys_kbytes;
2735 ELSIF ts_info(t).name = 'SYSAUX' THEN
2736 delta_kbytes := delta_kbytes + cmp_info(em).ins_def_kbytes;
2737 END IF;
2738 END IF;
2739 END IF;
2740
2741 -- Put a 20% safety factor on DELTA and round it off
2742 delta_kbytes := ROUND(delta_kbytes*1.20);
2743
2744 -- Finally, save DELTA value
2745 ts_info(t).delta := delta_kbytes;
2746
2747 -- Calculate here the recommendation for minimum tablespace size - it is
2748 -- the "delta" plus existing in use amount IF tablespace is not undo.
2749 -- Else if tablespace is undo, then minimum was already set above
2750 -- to 400M (or c_undo_minsz_kb); therefore no need to calculate here.
2751
2752 -- calculate ts_info(t).min
2753 IF ts_info(t).name != db_undo_tbs THEN
2754 -- calculate minimum tablespace size IF tablespace is NOT undo
2755 ts_info(t).min := ts_info(t).inuse + ts_info(t).delta;
2756
2757 -- See if this is the SYSAUX tablespace - be sure at least 500M allocated
2758 IF ts_info(t).name = 'SYSAUX' THEN
2759 IF ts_info(t).min < c_sysaux_minsz_kb THEN
2760 ts_info(t).min := c_sysaux_minsz_kb;
2761 END IF;
2762 END IF; -- end of checking that the minimum required space for SYSAUX
2763 -- is at least 500Mb (or c_sysaux_minsz_kb)
2764
2765 END IF; -- end of calculate ts_info(t).min
2766
2767 -- convert to MB and round up(min required)/down (alloc,avail,inuse)
2768 ts_info(t).min := CEIL(ts_info(t).min/c_kb);
2769 ts_info(t).alloc := ROUND((ts_info(t).alloc-512)/c_kb);
2770 ts_info(t).avail := ROUND((ts_info(t).avail-512)/c_kb);
2771 ts_info(t).inuse := ROUND((ts_info(t).inuse)/c_kb);
2772
2773 -- Determine amount of additional space needed
2774 -- independent of autoextend on/off
2775 --
2776
2777 IF ts_info(t).min > ts_info(t).alloc THEN
2778 ts_info(t).addl := ts_info(t).min - ts_info(t).alloc;
2779 ELSE
2780 ts_info(t).addl := 0;
2781 END IF;
2782
2783 -- Do we have enough space in the existing tablespace?
2784 IF ts_info(t).min <= ts_info(t).avail THEN
2785 ts_info(t).inc_by := 0;
2786 ELSE
2787 -- need to add space
2788 ts_info(t).inc_by := ts_info(t).min - ts_info(t).avail;
2789
2790 -- sorta silly to ask user to increase tablespace by, for example, 3M.
2791 -- so how about : if there are any increases of less than 50M, we'll
2792 -- just round up the increase to 50M (or c_incby_minsz_mb).
2793 IF ts_info(t).inc_by < c_incby_minsz_mb THEN
2794 -- round up 'min' size such that the inc_by size would equal to 50M
2795 ts_info(t).min := ts_info(t).min +
2796 (c_incby_minsz_mb - ts_info(t).inc_by);
2797 -- round up the 'inc_by' size to 50M
2798 ts_info(t).inc_by := c_incby_minsz_mb;
2799 END IF; -- if inc_by is < 50M
2800 END IF;
2801
2802 -- Find at least one file in the tablespace with autoextend on.
2803 -- If found, then that tablespace has autoextend on; else not on.
2804 -- DBUA will use this information to add to autoextend
2805 -- or to check for total space on disk
2806 --
2807 IF ts_info(t).addl > 0 OR ts_info(t).inc_by > 0 THEN
2808 ts_info(t).fauto := FALSE;
2809 IF ts_info(t).temporary AND ts_info(t).localmanaged THEN
2810 OPEN tmp_cursor FOR
2811 'SELECT file_name, autoextensible from sys.dba_temp_files ' ||
2812 'where tablespace_name = :1' using ts_info(t).name;
2813 ELSE
2814 OPEN tmp_cursor FOR
2815 'SELECT file_name, autoextensible from sys.dba_data_files ' ||
2816 'where tablespace_name = :1' using ts_info(t).name;
2817 END IF;
2818 LOOP
2819 FETCH tmp_cursor INTO tmp_filename, tmp_varchar2;
2820 EXIT WHEN tmp_cursor%NOTFOUND;
2821 IF tmp_varchar2 = 'YES' THEN
2822 ts_info(t).fname := tmp_filename;
2823 ts_info(t).fauto := TRUE;
2824 EXIT;
2825 END IF;
2826 END LOOP;
2827 CLOSE tmp_cursor;
2828 END IF;
2829 END LOOP; -- end of tablespace loop
2830 END init_resources;
2831
2832 procedure time_zone_check
2833 IS
2834 --
2835 -- This is decared as a public function for the package.
2836 --
2837 -- Allow dbms_preup.timezone_check to be called which
2838 -- tells the real procedure to call the init routine.
2839 --
2840 BEGIN
2841 tz_fixup(TRUE);
2842 END time_zone_check;
2843
2844 procedure tz_fixup (call_init BOOLEAN)
2845 IS
2846 --
2847 -- This is the timzeone procedure that does the work
2848 --
2849 tmp_bool BOOLEAN;
2850 BEGIN
2851 -- If called with call_init = TRUE, call the init
2852 -- package, otherwise don't. We need this because
2853 -- the init package will call this procedure
2854 -- and we'll end up in a loop.
2855 --
2856 IF call_init THEN
2857 init_package;
2858 ELSE
2859 -- Need db_tz_version below - fetch it the same way the init routine
2860 -- does.
2861 EXECUTE IMMEDIATE 'SELECT version from v$timezone_file'
2862 INTO db_tz_version;
2863 END IF;
2864 --
2865 -- Update registry$database with tz version (create it if necessary)
2866 --
2867 tmp_bool := FALSE;
2868 IF is_db_readonly = FALSE and NOT db_invalid_state THEN
2869 BEGIN
2870 EXECUTE IMMEDIATE
2871 'UPDATE registry$database set tz_version = :1'
2872 USING db_tz_version;
2873 COMMIT;
2874 EXCEPTION WHEN OTHERS THEN
2875 IF sqlcode = -904 THEN -- registry$database exists but no tz_version
2876 tmp_bool := TRUE;
2877 END IF;
2878 END;
2879
2880 IF tmp_bool = TRUE
2881 THEN
2882 --
2883 -- registry$database does not have tz_version,
2884 -- add it here.
2885 --
2886 EXECUTE IMMEDIATE
2887 'ALTER TABLE registry$database ADD (tz_version NUMBER)';
2888 EXECUTE IMMEDIATE
2889 'UPDATE registry$database set tz_version = :1'
2890 USING db_tz_version;
2891 COMMIT;
2892 END IF;
2893
2894 -- populate sys.props$ with Day Light Saving Time (DST) props
2895 -- Only needed for releases before 11.2
2896 IF db_n_version IN (102, 111) THEN
2897 -- only if the database time zone file versions match.
2898 BEGIN
2899 -- remove all DST entries that we will then populate
2900 EXECUTE IMMEDIATE '
2901 DELETE sys.props$ WHERE name IN (''DST_UPGRADE_STATE'',
2902 ''DST_PRIMARY_TT_VERSION'',
2903 ''DST_SECONDARY_TT_VERSION'')';
2904 EXECUTE IMMEDIATE 'INSERT INTO sys.props$ (name, value$, comment$)
2905 VALUES (''DST_UPGRADE_STATE'', ''NONE'',
2906 ''State of Day Light Saving Time Upgrade'')';
2907 EXECUTE IMMEDIATE 'INSERT INTO sys.props$ (name, value$, comment$)
2908 VALUES (''DST_PRIMARY_TT_VERSION'', TO_CHAR( :1, ''FM999''),
2909 ''Version of primary timezone data file'')'
2910 USING db_tz_version;
2911 EXECUTE IMMEDIATE 'INSERT INTO sys.props$ (name, value$, comment$)
2912 VALUES (''DST_SECONDARY_TT_VERSION'', ''0'',
2913 ''Version of secondary timezone data file'')';
2914 COMMIT;
2915 END;
2916 END IF;
2917 END IF; -- DB read only and db_invalid state
2918 END tz_fixup;
2919
2920 --
2921 -- Put a line out to the output file (or screen)
2922 --
2923 PROCEDURE DisplayLine (line VARCHAR2)
2924 IS
2925 BEGIN
2926 --
2927 -- If the package isn't inited yet (output from init routines)
2928 -- use dbms_output (output files would not be opened)
2929 --
2930 IF p_package_inited = FALSE OR pOutputDest = c_output_terminal THEN
2931 dbms_output.put_line (line);
2932 ELSE
2933 UTL_FILE.PUT_LINE (pOutputUFT,line);
2934 END IF;
2935 END DisplayLine;
2936
2937 --
2938 -- Put a line of text directly to a file
2939 --
2940 PROCEDURE DisplayLine (uft UTL_FILE.FILE_TYPE, line IN VARCHAR2)
2941 IS
2942 BEGIN
2943 BEGIN
2944 UTL_FILE.PUT_LINE (uft,line);
2945 EXCEPTION
2946 WHEN OTHERS THEN NULL; -- utl_file.invalid_filehandle
2947 END;
2948 END DisplayLine;
2949
2950 PROCEDURE DisplayDiagLine (line IN VARCHAR2)
2951 IS
2952 BEGIN
2953 IF pOutputType = c_output_xml THEN
2954 DisplayLine ('<!-- DBG: ' || line || ' -->');
2955 ELSE
2956 DisplayLine ('DBG: ' || line);
2957 END IF;
2958 END DisplayDiagLine;
2959
2960 --
2961 -- Put a line out using put_line (no matter what)
2962 --
2963 PROCEDURE DisplayLinePL (line VARCHAR2)
2964 IS
2965 BEGIN
2966 dbms_output.put_line (line);
2967 END DisplayLinePL;
2968
2969 FUNCTION CenterLine (line IN VARCHAR2) RETURN VARCHAR2
2970 IS
2971 BEGIN
2972 RETURN (LPAD(line,35+(length(line)/2)+1));
2973 END CenterLine;
2974
2975 --
2976 -- Put a line of text to output AND to passed file but
2977 -- its wrapped around dbms_output.put_line (so text only)
2978 -- intended to be dumped out while the pre/post fixup scripts
2979 -- are being run.
2980 -- If the line parameter contains single quote characters, they will be doubled
2981 -- here as needed for the script output.
2982 --
2983 PROCEDURE DisplayLineBoth (uft UTL_FILE.FILE_TYPE, line IN VARCHAR2)
2984 IS
2985 BEGIN
2986 DisplayLine(line);
2987 IF pOutputFixupScripts THEN
2988 DisplayLine (uft, 'dbms_output.put_line (''' || replace(line, q'!'!', q'!''!') || ''');');
2989 END IF;
2990 END DisplayLineBoth;
2991
2992
2993 PROCEDURE DisplayBanner
2994 IS
2995 BEGIN
2996 DisplayLine('**********************************************************************');
2997 END DisplayBanner;
2998
2999 --
3000 -- Overloaded version go to script file if we are creating one.
3001 --
3002 PROCEDURE DisplayBanner (uft UTL_FILE.FILE_TYPE)
3003 IS
3004 BEGIN
3005 DisplayLine('**********************************************************************');
3006 IF pOutputFixupScripts THEN
3007 DisplayLine (uft, 'dbms_output.put_line ('''
3008 || '**********************************************************************'
3009 || ''');');
3010 END IF;
3011 END DisplayBanner;
3012
3013 --
3014 -- Put the passed line out, centering it in a field of 70 char (the length of the banner)
3015 --
3016 PROCEDURE DisplayCenter (line IN VARCHAR2)
3017 IS
3018 BEGIN
3019 DisplayLine(LPAD(line,35+(length(line)/2)+1));
3020 END DisplayCenter;
3021
3022 --
3023 -- Overloaded, including dumping to script file (only TEXT to be
3024 -- displayed when the script file is executed)
3025 --
3026 PROCEDURE DisplayCenter (uft UTL_FILE.FILE_TYPE, line IN VARCHAR2)
3027 IS
3028 BEGIN
3029 DisplayLine(LPAD(line,35+(length(line)/2)+1));
3030 IF pOutputFixupScripts THEN
3031 DisplayLine (uft, 'dbms_output.put_line ('''
3032 || LPAD(line,35+(length(line)/2)+1)
3033 || ''');');
3034 END IF;
3035 END DisplayCenter;
3036
3037 --
3038 -- Same as above, only use dbms_output.put_line only
3039 -- Intended to be used by fixup routine to better control
3040 -- format.
3041 --
3042 PROCEDURE DisplayCenterPL (line IN VARCHAR2)
3043 IS
3044 BEGIN
3045 dbms_output.put_line(LPAD(line,35+(length(line)/2)+1));
3046 END DisplayCenterPL;
3047
3048 PROCEDURE DisplayInformation (text varchar2)
3049 IS
3050 BEGIN
3051 DisplayLine ('INFORMATION: --> ' || text);
3052 END DisplayInformation;
3053
3054 PROCEDURE DisplayWarning (text varchar2)
3055 IS
3056 BEGIN
3057 DisplayLine ('WARNING: --> ' || text);
3058 END DisplayWarning;
3059
3060 PROCEDURE DisplayError (text varchar2)
3061 IS
3062 BEGIN
3063 pCheckErrorCount := pCheckErrorCount + 1;
3064 DisplayLine ('ERROR: --> ' || text);
3065 END DisplayError;
3066
3067 -- Put a blank line in a file (e.g., preupgrade fixup script)
3068 PROCEDURE DisplayBlankLine (uft UTL_FILE.FILE_TYPE)
3069 IS
3070 BEGIN
3071 DisplayLine (uft, ' ');
3072 END DisplayBlankLine;
3073
3074 --
3075 -- Define what the output from this is going to be
3076 -- Text/XML are the only valid options.
3077 -- Defaulting to text
3078 -- If XML, call the procedure to output the header
3079 -- .
3080 PROCEDURE set_output_type (p_type VARCHAR2)
3081 IS
3082 BEGIN
3083 IF p_type = 'XML' THEN
3084 pOutputType := c_output_xml;
3085 ELSE
3086 -- Default to text
3087 pOutputType := c_output_text;
3088 END IF;
3089 END set_output_type;
3090
3091 PROCEDURE set_output_file (p_on_off BOOLEAN)
3092 IS
3093 BEGIN
3094 IF p_on_off THEN
3095 IF pOutputDest = c_output_file THEN
3096 -- Already done.
3097 RETURN;
3098 END IF;
3099 set_output_file (c_output_fn);
3100 ELSE
3101 close_file;
3102 END IF; -- on/off
3103 END set_output_file;
3104
3105 --
3106 -- Overloaded version of set_output_file to include
3107 -- location.
3108 -- Note that p_location is assumed to be verified
3109 -- by the caller.
3110 --
3111 PROCEDURE set_output_file (p_location VARCHAR2, p_fn VARCHAR2)
3112 IS
3113 BEGIN
3114 -- Set local dirobject name then call set output
3115 pOutputLocation := p_location;
3116 pOutputVerified := TRUE;
3117 set_output_file(p_fn);
3118 END set_output_file;
3119
3120 PROCEDURE set_output_file (p_fn VARCHAR2)
3121 IS
3122 openFailure BOOLEAN;
3123
3124 invalidFileOperation EXCEPTION;
3125 PRAGMA exception_init(invalidFileOperation, -29283);
3126 BEGIN
3127
3128 IF (pOutputLocation IS NULL ) THEN
3129 verifyDefaultDirObj;
3130 END IF;
3131
3132 -- if file type is TEXT, then file name is hardcoded as 'preupgrade.log'.
3133 -- if file type is XML, then file name had verbally been agreed on
3134 -- as 'upgrade.xml'.
3135 pOutputFName := p_fn;
3136
3137 -- If file type is TEXT, then final destination output files (if
3138 -- not TERMINAL) are 'preupgrade.log', 'preupgrade_fixups.sql', and
3139 -- 'postupgrade_fixups.sql'.
3140 -- If file type is XML, then possible final destination output file is
3141 -- 'upgrade.xml'.
3142 --
3143 IF (pOutputType = c_output_text) THEN
3144 finalDestLogFn := pOutputFName; -- 'preupgrade.log'
3145 finalDestPreScriptFn := pPreScriptFname; -- 'preupgrade_fixups.sql'
3146 finalDestPostScriptFn := pPostScriptFname; -- 'postupgrade_fixups.sql'
3147 ELSIF (pOutputType = c_output_xml) THEN
3148 finalDestLogFn := pOutputFName; -- 'upgrade.xml'
3149 finalDestPreScriptFn := ''; -- NULL
3150 finalDestPostScriptFn := ''; -- NULL
3151 END IF;
3152
3153 --
3154 -- determine pConcatToMainFile value:
3155 -- a) non-cdb and root will write directly to main destination file => FALSE
3156 -- b) if pdb and TEXT (not dbua) -> concat to main destination files => TRUE
3157 -- c) if pdb and XML (dbua) -> write directly to main destination file
3158 -- one by one => FALSE
3159 --
3160 IF (dbms_preup.is_db_noncdb OR dbms_preup.is_con_root) THEN
3161 pConcatToMainFile := FALSE;
3162 ELSE -- if db is a seed or pdb
3163 IF (pOutputType = c_output_text) THEN
3164 -- will append pdb TEXT file to destination file
3165 pConcatToMainFile := TRUE;
3166 ELSIF (pOutputType = c_output_xml) THEN
3167 -- will not append pdb XML file to destination file
3168 pConcatToMainFile := FALSE;
3169 END IF;
3170 END IF;
3171
3172 -- if output type is text and db is a pdb, then determine output file names.
3173 -- preupgrade.<con_name>.log
3174 -- preupgrade_fixups.<con_name>.sql
3175 -- postupgrade_fixups.<con_name>.sql
3176 -- note: above pdb files are first created in PREUPGRADE_DIR.
3177 -- note: after concat is done, then pdb files are moved to PDB_PREUPGRADE_DIR.
3178 --
3179 IF pConcatToMainFile THEN
3180 con_name := sys.dbms_preup.get_con_name;
3181
3182 pOutputFName := c_text_log_base || con_name || c_text_log_suffix;
3183 pPreScriptFname := c_pre_fixup_base || con_name || c_fixup_suffix;
3184 pPostScriptFname := c_post_fixup_base || con_name || c_fixup_suffix;
3185 END IF;
3186
3187 IF tracing_on_xxx THEN
3188 dbms_output.put_line('XXX finalDestLogFn : ' || finalDestLogFn);
3189 dbms_output.put_line('XXX finalDestPreScriptFn : '|| finalDestPreScriptFn);
3190 dbms_output.put_line('XXX finalDestPostScriptFn : '||finalDestPostScriptFn);
3191 dbms_output.put_line('XXX pOutputFName : ' || pOutputFName);
3192 dbms_output.put_line('XXX pPreScriptFname : ' || pPreScriptFname);
3193 dbms_output.put_line('XXX pPostScriptFname : ' || pPostScriptFname);
3194 END IF;
3195
3196 -- initialize: remove pdb text files in pdbfiles subdir
3197 IF pConcatToMainFile THEN
3198 BEGIN
3199 UTL_FILE.FREMOVE(c_pdb_dir_obj, pOutputFName);
3200 EXCEPTION WHEN OTHERS THEN NULL;
3201 END;
3202
3203 BEGIN
3204 UTL_FILE.FREMOVE(c_pdb_dir_obj, pPreScriptFname);
3205 EXCEPTION WHEN OTHERS THEN NULL;
3206 END;
3207
3208 BEGIN
3209 UTL_FILE.FREMOVE(c_pdb_dir_obj, pPostScriptFname);
3210 EXCEPTION WHEN OTHERS THEN NULL;
3211 END;
3212 END IF;
3213
3214 -- remove lock (just in case it exists from a previous run) right at the
3215 -- begin of connect to either a non-cdb or cdb root
3216 IF (dbms_preup.is_db_noncdb OR dbms_preup.is_con_root) THEN
3217 BEGIN
3218 UTL_FILE.FREMOVE(pOutputLocation, c_wrlock_fname);
3219 EXCEPTION
3220 WHEN invalidFileOperation THEN NULL;
3221 WHEN OTHERS THEN NULL;
3222 END;
3223 END IF;
3224
3225 openFailure := FALSE;
3226 IF pOutputVerified THEN
3227 BEGIN
3228
3229 -- if log file is TEXT, then:
3230 -- if non-cdb OR if cdb$root, create preupgrade.log using 'W' mode
3231 -- if cdb and container is non-root, create file using 'A' mode
3232
3233 -- if log file is XML, then:
3234 -- always create upgrade.xml using 'A' mode as DBUA will be writing
3235 -- lines to it prior to calling preupgrade tool
3236
3237 IF (pOutputType = c_output_text) THEN
3238 -- preupgrade.log is opened in write mode
3239 -- preupgrade.<con_name>.log is also opened in write mode
3240 pOutputUFT :=
3241 UTL_FILE.FOPEN(pOutputLocation, pOutputFName, 'W', c_fopen_max_lsz);
3242 IF tracing_on_xxx = TRUE THEN
3243 dbms_output.put_line('XXX preupgrade log opened');
3244 dbms_output.put_line('XXX out dir obj ' || pOutputLocation);
3245 dbms_output.put_line('XXX pOutputFName ' || pOutputFName);
3246 END IF;
3247 ELSIF (pOutputType = c_output_xml) THEN
3248 -- upgrade.xml is always opened in append mode
3249 --
3250 -- note: if we were to support concat-ting pdb files to a the
3251 -- MAIN upgrade.xml for DBUA, then should pConcatToMainFile
3252 -- is equal to TRUE, the file open mode would be 'W', not 'A'.
3253 --
3254 pOutputUFT :=
3255 UTL_FILE.FOPEN(pOutputLocation, pOutputFName, 'A', c_fopen_max_lsz);
3256 END IF;
3257
3258 EXCEPTION
3259 WHEN OTHERS THEN
3260 openFailure := TRUE;
3261 END;
3262 IF openFailure THEN
3263 DisplayLine ('WARNING: Failed to open ' || pOutputFName || ' in the directory ' || pOutputLocation || ' for write access');
3264 DisplayLine(' script will generate terminal output only');
3265 pOutputVerified := FALSE;
3266 pOutputLocation := NULL;
3267 pOutputDest := c_output_terminal;
3268 -- if we are writing to terminal (for example, because the db is read
3269 -- only and directory object cannot be created, then we are not going
3270 -- to concat to main file)
3271 IF pConcatToMainFile = TRUE THEN
3272 pConcatToMainFile := FALSE; -- reset to FALSE since writing to terminal
3273 END IF;
3274 ELSE
3275 pOutputDest := c_output_file;
3276 END IF;
3277 ELSE
3278 --
3279 -- Failed to verify the outputdir, default to
3280 -- terminal (verify routine will issue error)
3281 --
3282 pOutputDest := c_output_terminal;
3283
3284 -- if we are writing to terminal, then we are not going to concat to
3285 -- main file
3286 IF pConcatToMainFile = TRUE THEN
3287 pConcatToMainFile := FALSE; -- reset to FALSE since writing to terminal
3288 END IF;
3289 END IF;
3290 END set_output_file;
3291
3292 -- display where the preupgrade results are located
3293 PROCEDURE output_results_location
3294 IS
3295 path VARCHAR2(500);
3296 BEGIN
3297 path := get_output_path;
3298 DisplayLinePL(CenterLine('************************************************************'));
3299 DisplayLinePL('');
3300 DisplayLinePL(CenterLine('====>> PRE-UPGRADE RESULTS for ' || con_name || ' <<===='));
3301 DisplayLinePL('');
3302 DisplayLinePL('ACTIONS REQUIRED:');
3303 DisplayLinePL('');
3304 DisplayLinePL('1. Review results of the pre-upgrade checks:');
3305 DisplayLinePL(' ' || path || finalDestLogFn);
3306 DisplayLinePL('');
3307 DisplayLinePL('2. Execute in the SOURCE environment BEFORE upgrade:');
3308 DisplayLinePL(' ' || path || finalDestPreScriptFn);
3309 DisplayLinePL('');
3310 DisplayLinePL('3. Execute in the NEW environment AFTER upgrade:');
3311 DisplayLinePL(' ' || path || finalDestPostScriptFn);
3312 DisplayLinePL('');
3313 DisplayLinePL(CenterLine('************************************************************'));
3314
3315 END output_results_location;
3316
3317 PROCEDURE close_file
3318 IS
3319 BEGIN
3320
3321 IF tracing_on_xxx THEN
3322 dbms_output.put_line('XXX in close_file');
3323 END IF;
3324
3325 IF pOutputDest = c_output_file THEN
3326 IF (UTL_FILE.IS_OPEN(pOutputUFT)) THEN
3327 UTL_FILE.FCLOSE(pOutputUFT);
3328 IF tracing_on_xxx THEN
3329 dbms_output.put_line('XXX close log file');
3330 END IF;
3331 END IF;
3332 pOutputDest := c_output_terminal;
3333
3334 IF (UTL_FILE.IS_OPEN(pPreScriptUFT)) THEN
3335 UTL_FILE.FCLOSE(pPreScriptUFT);
3336 IF tracing_on_xxx THEN
3337 dbms_output.put_line('XXX close preupgrade_fixups.sql');
3338 END IF;
3339 END IF;
3340
3341 IF (UTL_FILE.IS_OPEN(pPostScriptUFT)) THEN
3342 UTL_FILE.FCLOSE(pPostScriptUFT);
3343 IF tracing_on_xxx THEN
3344 dbms_output.put_line('XXX close postupgrade_fixups.sql');
3345 END IF;
3346 END IF;
3347
3348 IF tracing_on_xxx THEN
3349 dbms_output.put_line('XXX in close_file');
3350 dbms_output.put_line('XXX pTextLogDir is ' || pTextLogDir);
3351 dbms_output.put_line('XXX pOutputFName is ' || pOutputFName);
3352 dbms_output.put_line('XXX pOutputLocation is ' || pOutputLocation);
3353 END IF;
3354
3355 IF pOutputFixupScripts = FALSE AND pCreatedDirObj THEN
3356 --
3357 -- Cleanup the directory if we created it, however the
3358 -- DBUA process deals with this so just ignore any
3359 -- drop error.
3360 --
3361 BEGIN
3362 EXECUTE IMMEDIATE 'DROP DIRECTORY :1' USING pOutputLocation;
3363 EXCEPTION WHEN OTHERS THEN NULL;
3364 END;
3365 END IF;
3366 -- We no longer have a pOutputFName and reset pOutputLocation
3367 pOutputFName := NULL;
3368 pOutputLocation := NULL;
3369 END IF;
3370 END close_file;
3371
3372 --
3373 -- For manual mode, we need to output the path were the logs/scripts
3374 -- If we are not outputting files, return ''
3375 --
3376 FUNCTION get_output_path RETURN VARCHAR2
3377 IS
3378 path VARCHAR2(4000);
3379 BEGIN
3380 IF pOutputFixupScripts = FALSE THEN
3381 RETURN '*** Scripts/Logs are not being Generated ***';
3382 END IF;
3383
3384 BEGIN
3385 EXECUTE IMMEDIATE 'SELECT directory_path from SYS.DBA_DIRECTORIES where directory_name=:1'
3386 INTO path
3387 USING c_dir_obj;
3388 EXCEPTION WHEN NO_DATA_FOUND THEN
3389 -- Bug 18463200: workaround is to return the path that was used to
3390 -- create/replace the directory object if db is a pdb
3391 IF (dbms_preup.is_db_noncdb = TRUE OR -- is a non-cdb
3392 dbms_preup.is_con_root = TRUE) THEN -- OR cdb$root
3393 path := '*** PATH NOT DEFINED ***';
3394 ELSE -- this must be a pdb$seed or just a pdb
3395 IF pTextLogDir is NULL THEN -- path is really not defined
3396 path := '*** PATH NOT DEFINED ***';
3397 ELSE
3398 -- pTextLogDir (due to enquote_literal) has single quotes around
3399 -- the string so remove them.
3400 path := ltrim(pTextLogDir, '''');
3401 path := rtrim(path, '''');
3402 END IF;
3403 END IF;
3404 END;
3405 RETURN path;
3406 END get_output_path;
3407
3408 --
3409 -- note: this procedure is only called for when file type is text
3410 --
3411 PROCEDURE set_fixup_scripts (p_on_off BOOLEAN)
3412 IS
3413 openFailure BOOLEAN;
3414 timeinfo VARCHAR2(60);
3415 genline VARCHAR2(200);
3416 BEGIN
3417 IF p_on_off THEN -- IF p_on_off is ON or TRUE
3418 IF pOutputFixupScripts THEN
3419 -- Already done.
3420 RETURN;
3421 END IF;
3422
3423 IF tracing_on_xxx THEN
3424 dbms_output.put_line('XXX set_fixup_scripts: ON');
3425 END IF;
3426
3427 --
3428 -- Make sure a directory object exists
3429 --
3430 verifyDefaultDirObj;
3431
3432 IF pOutputVerified = FALSE THEN
3433 --
3434 -- We couldn't verify the directory object
3435 --
3436 pOutputFixupScripts := FALSE;
3437 RETURN;
3438 END IF;
3439
3440 --
3441 -- Open both files and put some info out.
3442 -- Also dump out a begin/end output line - if there
3443 -- is no errors, these lines will stop the script from
3444 -- generating an error because the begin/end block would be
3445 -- empty.
3446 --
3447 openFailure := FALSE;
3448 BEGIN
3449 -- ALWAYS open PREupgrade fixup file in Write mode (not Append mode).
3450 -- Reasons:
3451 -- a) non-cdb: overwrite 'preupgrade_fixups.sql' if already exists
3452 -- b) cdb: Since ROOT writes to 'preupgrade_fixups.sql' and PDBs write
3453 -- to 'preupgrade_fixups.<con_name>.sql', each file will be
3454 -- overwritten if already exists
3455 pPreScriptUFT := UTL_FILE.FOPEN(pOutputLocation, pPreScriptFname,
3456 'W', c_fopen_max_lsz);
3457
3458 IF tracing_on_xxx THEN
3459 dbms_output.put_line('XXX opened file ' || pPreScriptFname);
3460 END IF;
3461
3462 EXCEPTION
3463 WHEN OTHERS THEN
3464 openFailure := TRUE;
3465 END;
3466
3467 IF openFailure THEN
3468 DisplayLine ('WARNING: Failed to open ' || pPreScriptFname || ' for write access');
3469 ELSE
3470 -- ALWAYS open POSTupgrade fixup file in Write mode (not Append mode).
3471 -- Reasons:
3472 -- a) non-cdb: overwrite 'postupgrade_fixups.sql' if already exists
3473 -- b) cdb: Since ROOT writes to 'postupgrade_fixups.sql' and PDBs write
3474 -- to 'postupgrade_fixups.<con_name>.sql', each file will be
3475 -- overwritten if already exists
3476 BEGIN
3477 pPostScriptUFT :=
3478 UTL_FILE.FOPEN(pOutputLocation, pPostScriptFname, 'W',
3479 c_fopen_max_lsz);
3480
3481 IF tracing_on_xxx THEN
3482 dbms_output.put_line('XXX opened file ' || pPostScriptFname);
3483 END IF;
3484
3485 EXCEPTION
3486 WHEN OTHERS THEN
3487 openFailure := TRUE;
3488 END;
3489 IF openFailure THEN
3490 DisplayLine ('WARNING: Failed to open ' || pPostScriptFname || ' for write access');
3491 END IF;
3492 END IF;
3493
3494 IF openFailure THEN
3495 DisplayLine(' script will not generate fixup scripts.');
3496 pOutputVerified := FALSE;
3497 pOutputLocation := NULL;
3498 pOutputFixupScripts := FALSE;
3499 RETURN;
3500 END IF;
3501
3502 IF tracing_on_xxx THEN
3503 dbms_output.put_line('XXX preupgrade_fixup script opened');
3504 dbms_output.put_line('XXX pOutputLocation ' || pOutputLocation);
3505 dbms_output.put_line('XXX pPreScriptFname ' || pPreScriptFname);
3506 dbms_output.put_line('XXX postupgrade_fixup script opened');
3507 dbms_output.put_line('XXX pOutputLocation ' || pOutputLocation);
3508 dbms_output.put_line('XXX pPostScriptFname ' || pPostScriptFname);
3509 END IF;
3510
3511 EXECUTE IMMEDIATE 'SELECT TO_CHAR(SYSTIMESTAMP,''YYYY-MM-DD HH24:MI:SS '') FROM SYS.DUAL'
3512 INTO timeinfo;
3513
3514 --
3515 -- The linesize at 750 allows the buffering of some of the help text
3516 -- which can get long. No data will be lost, the line will just be
3517 -- unnaturally wrapped.
3518 --
3519 -- a) If this is a cdb, the prefixup steps for multiple containers go into
3520 -- one prefixup file; and the postfixup steps for multiple containers go
3521 -- into one postfixup file. In order to make this work, the fixup steps
3522 -- for a container will go into a IF stmt that gets executed if the
3523 -- container name for those fixup steps match the name of the current
3524 -- container connected to.
3525 -- b) For consistency between a non-cdb and cdb, we keep the same IF stmt
3526 -- format for the fixup steps for both non-cdbs and cdbs. For
3527 -- non-cdbs, we match database names. For cdbs, we match container names.
3528 --
3529 DisplayLine (pPreScriptUFT, 'REM Pre-Upgrade Script Generated on: ' || timeinfo);
3530 DisplayLine (pPreScriptUFT, 'REM Generated by Version: ' || c_version || ' Build: '
3531 || c_build);
3532 DisplayLine (pPreScriptUFT, 'SET ECHO OFF SERVEROUTPUT ON FORMAT WRAPPED TAB OFF LINESIZE 750;' || crlf);
3533 DisplayBlankLine (pPreScriptUFT);
3534
3535 -- In a fixup script, there is a block with IF stmt for each database or
3536 -- container's fixup steps.
3537 DisplayLine (pPreScriptUFT, 'DECLARE');
3538 DisplayLine (pPreScriptUFT, 'con_name varchar2(40);');
3539 DisplayBlankLine (pPreScriptUFT);
3540 DisplayLine (pPreScriptUFT, 'BEGIN ');
3541 DisplayLine (pPreScriptUFT, 'execute immediate ');
3542 DisplayLine (pPreScriptUFT, ' ''select dbms_preup.get_con_name from sys.dual'' into con_name;');
3543
3544 -- If the session currently connected to is of a database or container that
3545 -- matches the name in the IF stmt, then stay in the block and run the
3546 -- fixup steps.
3547 -- Else, if the names do not match, then continue on to the next block in
3548 -- the fixup script.
3549 EXECUTE IMMEDIATE
3550 'select dbms_preup.get_con_name from sys.dual' INTO con_name;
3551 DisplayBlankLine (pPreScriptUFT);
3552 DisplayLine (pPreScriptUFT, 'IF con_name = ''' || con_name || ''' THEN');
3553 DisplayBlankLine (pPreScriptUFT);
3554
3555 -- In its own begin/end so the output gets out before
3556 -- the real work gets started.
3557 genline := 'Pre-Upgrade Fixup Script Generated on ' || timeinfo || ' Version: ' || c_version
3558 || ' Build: ' || c_build;
3559 DisplayLine (pPreScriptUFT, 'BEGIN');
3560 DisplayLine (pPreScriptUFT, 'dbms_output.put_line (''' || genline || ''');');
3561 DisplayLine (pPreScriptUFT, 'dbms_output.put_line (''Beginning Pre-Upgrade Fixups...'');');
3562 genline := 'Executing in container ' || con_name;
3563 DisplayLine (pPreScriptUFT, 'dbms_output.put_line (''' || genline || ''');');
3564 DisplayLine (pPreScriptUFT, 'END;');
3565 DisplayBlankLine (pPreScriptUFT);
3566 DisplayLine (pPreScriptUFT, 'BEGIN');
3567 DisplayLine (pPreScriptUFT, 'dbms_preup.clear_run_flag(TRUE);');
3568 DisplayLine (pPreScriptUFT, 'END;');
3569 DisplayBlankLine (pPreScriptUFT);
3570 --
3571 -- Now post...
3572 --
3573 DisplayLine (pPostScriptUFT, 'REM Post Upgrade Script Generated on: ' || timeinfo);
3574 DisplayLine (pPostScriptUFT, 'REM Generated by Version: ' || c_version || ' Build: '
3575 || c_build);
3576 DisplayLine (pPostScriptUFT, 'SET ECHO OFF SERVEROUTPUT ON FORMAT WRAPPED TAB OFF LINESIZE 750;' || crlf);
3577
3578 -- In a fixup script, there is a block for each database or
3579 -- container's fixup steps.
3580 DisplayBlankLine (pPostScriptUFT);
3581 DisplayLine (pPostScriptUFT, 'DECLARE');
3582 DisplayLine (pPostScriptUFT, 'con_name varchar2(40);');
3583 DisplayBlankLine (pPostScriptUFT);
3584 DisplayLine (pPostScriptUFT, 'BEGIN ');
3585 DisplayLine (pPostScriptUFT, 'execute immediate ');
3586 DisplayLine (pPostScriptUFT, ' ''select dbms_preup.get_con_name from sys.dual'' into con_name;');
3587
3588 -- If the session currently connected to is of a database or container that
3589 -- matches the name in the IF block, then stay in the loop and run the
3590 -- fixup steps.
3591 -- Else, if the names do not match, then continue on to the next block in
3592 -- the fixup script.
3593 EXECUTE IMMEDIATE
3594 'select dbms_preup.get_con_name from sys.dual' INTO con_name;
3595 DisplayBlankLine (pPostScriptUFT);
3596 DisplayLine (pPostScriptUFT, 'IF con_name = ''' || con_name || ''' THEN');
3597 DisplayBlankLine (pPostScriptUFT);
3598
3599 genline := 'Post Upgrade Fixup Script Generated on ' || timeinfo || ' Version: ' || c_version
3600 || ' Build: ' || c_build;
3601 -- In its own begin/end so the output gets out before
3602 -- the real work gets started.
3603 DisplayLine (pPostScriptUFT, 'BEGIN');
3604 DisplayLine (pPostScriptUFT, 'dbms_output.put_line (''' || genline || ''');');
3605 DisplayLine (pPostScriptUFT, 'dbms_output.put_line (''Beginning Post-Upgrade Fixups...'');');
3606 DisplayLine (pPostScriptUFT, 'END;');
3607 DisplayBlankLine (pPostScriptUFT);
3608 DisplayLine (pPostScriptUFT, 'BEGIN');
3609 DisplayLine (pPostScriptUFT, 'dbms_preup.clear_run_flag(FALSE);');
3610 DisplayLine (pPostScriptUFT, 'END;');
3611 DisplayBlankLine (pPostScriptUFT);
3612 pOutputFixupScripts := TRUE;
3613
3614 ELSE -- ELSE IF p_on_off is OFF or FALSE
3615 IF pOutputFixupScripts THEN
3616 --
3617 -- Dump out a call to the routine to run through all the checks and report
3618 -- a summary of success/failures/user actions
3619 --
3620 DisplayLine (pPreScriptUFT, 'BEGIN dbms_preup.fixup_summary(TRUE); END;');
3621 DisplayBlankLine(pPreScriptUFT);
3622
3623 DisplayLine (pPostScriptUFT, 'BEGIN dbms_preup.fixup_summary(FALSE); END;');
3624 DisplayBlankLine (pPostScriptUFT);
3625
3626
3627 EXECUTE IMMEDIATE 'SELECT TO_CHAR(SYSTIMESTAMP,''YYYY-MM-DD HH24:MI:SS '') FROM SYS.DUAL'
3628 INTO timeinfo;
3629
3630 DisplayLine (pPreScriptUFT, 'BEGIN');
3631 DisplayLine (pPreScriptUFT,
3632 'dbms_output.put_line (''**************** Pre-Upgrade Fixup Script Complete *********************'');');
3633 DisplayLine (pPreScriptUFT, 'END;');
3634 DisplayBlankLine (pPreScriptUFT);
3635 -- end of prefixup steps for if container connected is same as con_name
3636 DisplayLine (pPreScriptUFT,'END IF;');
3637 DisplayBlankLine (pPreScriptUFT);
3638 DisplayLine (pPreScriptUFT,'END;');
3639 DisplayLine (pPreScriptUFT, '/'); -- NEEDED for end of this block
3640 DisplayLine (pPreScriptUFT, 'REM Pre-Upgrade Script Closed At: ' || timeinfo);
3641 DisplayLine (pPreScriptUFT, 'REM __________________________________________________________________________');
3642 DisplayBlankLine (pPreScriptUFT);
3643
3644 DisplayLine (pPostScriptUFT, 'BEGIN');
3645 DisplayLine (pPostScriptUFT,
3646 'dbms_output.put_line (''*************** Post Upgrade Fixup Script Complete ********************'');');
3647 DisplayLine (pPostScriptUFT,'END;');
3648
3649 IF tracing_on_xxx THEN
3650 dbms_output.put_line('XXX end post upgrade fixup file');
3651 END IF;
3652
3653 DisplayBlankLine (pPostScriptUFT);
3654 -- end of prefixup steps for if container connected is same as con_name
3655 DisplayLine (pPostScriptUFT,'END IF;');
3656 DisplayBlankLine (pPostScriptUFT);
3657 DisplayLine (pPostScriptUFT,'END;');
3658 DisplayLine (pPostScriptUFT, '/'); -- NEEDED for after end of this block
3659 DisplayLine (pPostScriptUFT,'-- Post Upgrade Script Closed At: ' || timeinfo);
3660 DisplayLine (pPostScriptUFT, 'REM __________________________________________________________________________');
3661 DisplayBlankLine (pPostScriptUFT);
3662
3663 pOutputFixupScripts := TRUE;
3664 END IF;
3665 IF pOutputDest = c_output_terminal AND pCreatedDirObj THEN
3666 --
3667 -- If we created the directory object, (and we are not outputting
3668 -- to a log file) drop the directory object (usually done in close_file
3669 -- but that will not be called if we are not outputting a log file)
3670 --
3671 BEGIN
3672 EXECUTE IMMEDIATE 'DROP DIRECTORY :1' USING pOutputLocation;
3673 EXCEPTION WHEN OTHERS THEN NULL;
3674 END;
3675
3676 pOutputLocation := NULL;
3677 END IF;
3678
3679 END IF; -- on/off
3680 END set_fixup_scripts;
3681
3682 PROCEDURE verifyDefaultDirObj
3683 --
3684 -- Bulk of this code started with a version in catbundle.sql
3685 -- The code creates a java package to create an actual
3686 -- directory on the server under cfgtoollogs/<dbid>/preupgrade
3687 -- and then also creates a directory object to point there.
3688 -- Note: If the directory object already exists, it will
3689 -- be used and no directory will be created.
3690 --
3691 -- The global value:
3692 -- pOutputVerified
3693 -- is set to TRUE if the directory object could be verified,
3694 -- otherwise FALSE.
3695 --
3696 -- Notes:
3697 -- This routine will dump out a warning should the directory object
3698 -- fail to be verified.
3699 --
3700 IS
3701 dummy VARCHAR2(2500);
3702 tmp_varchar VARCHAR2(200);
3703 platform v$database.platform_name%TYPE;
3704 uniqueName VARCHAR2(100);
3705 logDir VARCHAR2(4000); -- the physical directory
3706 dirObjName VARCHAR2(128); -- the object name
3707 rdbmsLogDir VARCHAR2(500);
3708 homeDir VARCHAR2(500);
3709 baseDir VARCHAR2(500);
3710 useDir VARCHAR2(500);
3711 pdbLogDir VARCHAR2(4000); -- path to pdb preupgrade output files
3712 tmp_dirpath VARCHAR2(4000);
3713 clearJava BOOLEAN;
3714 clearJavaAgain BOOLEAN := FALSE; -- Clear Java in 10.2.0.5.0
3715 status NUMBER;
3716 javastatus NUMBER := 0;
3717 javaOK NUMBER;
3718 javaExitSession VARCHAR2(500) :=
3719 'CREATE PROCEDURE PreupJavaExit(exitStatus NUMBER)
3720 AS LANGUAGE JAVA
3721 NAME ''java.lang.System.exit(int)'';'; -- Call Java System.exit
3722 javaCreate VARCHAR2(500) :=
3723 'CREATE OR REPLACE FUNCTION PreupCreateDir(path VARCHAR2)
3724 RETURN NUMBER AS
3725 LANGUAGE JAVA
3726 NAME ''PreupCreateDir.create (java.lang.String) return java.lang.int'';';
3727 dummyCreate VARCHAR2(500) :=
3728 'CREATE OR REPLACE FUNCTION PreupCreateDir(path VARCHAR2)
3729 RETURN NUMBER AS
3730 BEGIN
3731 RETURN 0;
3732 END PreupCreateDir;';
3733 createString VARCHAR2(500);
3734
3735 nameAlreadyExists EXCEPTION;
3736 PRAGMA exception_init(nameAlreadyExists, -955);
3737
3738 classInUse EXCEPTION;
3739 PRAGMA EXCEPTION_INIT(classInUse, -29553);
3740
3741 --
3742 -- Java Exceptions in 10.2.0.5.0 where dbms_java.endsession
3743 -- does not exit so we execute System.exit instead to end
3744 -- the java session.
3745 --
3746 exitCalledFromJava EXCEPTION;
3747 PRAGMA EXCEPTION_INIT(exitCalledFromJava, -29515);
3748
3749 JavaStateCleared EXCEPTION;
3750 PRAGMA EXCEPTION_INIT(exitCalledFromJava, -29550);
3751 openMode v$database.open_mode%TYPE := '';
3752
3753 BEGIN
3754
3755 --
3756 -- If the database is readonly, then this code will not be able to create
3757 -- a directory... because it works by creating a java program in the DB and calling it.
3758 -- So just return and let downstream code deal with the implications.
3759 IF is_db_readonly = TRUE THEN
3760 pOutputLocation := c_dir_obj;
3761 pOutputVerified := TRUE;
3762 return;
3763 END IF;
3764
3765 --
3766 -- >> BEGIN: CREATE DIRECTORY OBJECT
3767 -- Begin of constructing the path to directory object PREUPGRADE_DIR and
3768 -- creating this directory object.
3769 --
3770 -- We always want to recreate the directory object PREUPGRADE_DIR (whether
3771 -- it already exists or not) as its path (if directory object already
3772 -- exists) can contain a path left over from an older upgrade (i.e., the
3773 -- path can reference an older Oracle home). So to be safe, lets
3774 -- re-derive the path and recreate the directory object.
3775 -- Note: Another reason to recreate the directory object -
3776 --
3777 -- IF db is a cdb, then directory object needs to be re-created in
3778 -- each container, whether it pre-exists or not, as we want all containers'
3779 -- directory objects to point to the same path.
3780 --
3781 --
3782 -- Code below figures out the path to create the
3783 -- target directory. This directory (PREUPGRADE_DIR) is where we are going
3784 -- to put the log/scripts.
3785 --
3786 -- Determine ORACLE_HOME value
3787 EXECUTE IMMEDIATE 'SELECT NLS_UPPER(platform_name) FROM v$database'
3788 INTO platform;
3789
3790 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter where '
3791 || 'name=''db_unique_name'''
3792 INTO uniqueName;
3793
3794 -- Default to $ORACLE_BASE/cfgtoollogs/<db-unique-name>/preupgrade
3795 -- if $ORACLE_BASE is not defined then use
3796 -- $ORACLE_HOME/cfgtoollogs/<db-unique-name>/preupgrade
3797 -- if $ORACLE_HOME is not defined then error
3798
3799 DBMS_SYSTEM.GET_ENV('ORACLE_BASE', baseDir);
3800 DBMS_SYSTEM.GET_ENV('ORACLE_HOME', homeDir);
3801
3802 IF homeDir IS NULL THEN
3803 pOutputLocation := NULL;
3804 pOutputVerified := FALSE;
3805 DisplayLine('Warning: ORACLE_HOME is not defined');
3806 DisplayLine(' Terminal output only');
3807 RETURN;
3808 END IF;
3809
3810 IF baseDir IS NOT NULL THEN
3811 useDir := baseDir;
3812 ELSE
3813 useDir := homeDir;
3814 END IF;
3815
3816 --
3817 -- Setup logDir and rdbmsLogDir, starting with useDir as the
3818 -- default.
3819 --
3820 IF INSTR(platform, 'WINDOWS') != 0 THEN
3821 -- Windows, use '\'
3822 useDir := RTRIM(useDir, '\'); -- Remove any trailing slashes
3823 logDir := dbms_assert.enquote_literal(
3824 useDir
3825 || '\cfgtoollogs\'
3826 || uniqueName
3827 || '\preupgrade\');
3828 rdbmsLogDir := homeDir || '\rdbms\log\';
3829 pdbLogDir := dbms_assert.enquote_literal(
3830 useDir
3831 || '\cfgtoollogs\'
3832 || uniqueName
3833 || '\preupgrade\pdbfiles\');
3834 ELSIF INSTR(platform, 'VMS') != 0 THEN
3835 -- VMS, use [] and .
3836 logDir := dbms_assert.enquote_literal (REPLACE (
3837 useDir
3838 || '[cfgtoollogs.'
3839 || uniqueName
3840 || '.preupgrade]', '][', '.'));
3841 rdbmsLogDir := REPLACE(homeDir || '[rdbms.log]', '][', '.');
3842 pdbLogDir := dbms_assert.enquote_literal (REPLACE (
3843 useDir
3844 || '[cfgtoollogs.'
3845 || uniqueName
3846 || '.preupgrade'
3847 || '.pdbfiles]', '][', '.'));
3848 ELSE
3849 -- Unix and z/OS, '/'
3850 useDir := RTRIM(useDir, '/'); -- Remove any trailing slashes
3851 logDir := dbms_assert.enquote_literal(
3852 useDir
3853 || '/cfgtoollogs/'
3854 || uniqueName
3855 || '/preupgrade/');
3856 rdbmsLogDir := homeDir || '/rdbms/log/';
3857 pdbLogDir := dbms_assert.enquote_literal(
3858 useDir
3859 || '/cfgtoollogs/'
3860 || uniqueName
3861 || '/preupgrade/pdbfiles/');
3862 END IF;
3863 -- >> END: CREATE DIRECTORY OBJECT
3864 --
3865 --
3866
3867 --
3868 -- Load in the Java piece
3869 --
3870 status := 1;
3871 javaOK := 0;
3872
3873 --
3874 -- If anything goes wrong with checking java assume
3875 -- java is invalid. This was preventing us from
3876 -- running the pre-upgrade tool in the target database
3877 -- going from 12.1.0.1.0 to 12.1.0.2.0 when the
3878 -- data dictionary had not been upgraded.
3879 --
3880 BEGIN
3881 javastatus :=
3882 dbms_registry.is_valid('JAVAVM',dbms_registry.release_version);
3883 EXCEPTION WHEN OTHERS THEN javastatus := 0;
3884 END;
3885
3886 IF javastatus = 1 THEN
3887 BEGIN
3888 -- Because of the dbms_assert checks we know we are getting a string with
3889 -- leading and trailing single quotes as the path. We need to remove those
3890 -- single quotes before using the passed path variable.
3891 EXECUTE IMMEDIATE '
3892 CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "PreupCreateDir" AS
3893 import java.lang.*;
3894 import java.util.*;
3895 import java.io.*;
3896
3897 public class PreupCreateDir
3898 {
3899 public static int create (String path)
3900 {
3901 path = path.substring(1,path.length()-1); /* Take off leading/trailing quotes */
3902 File myFile = new File(path);
3903 if (myFile.exists())
3904 {
3905 if (myFile.canWrite())
3906 return 1; /* Directory exists and is writable, OK */
3907 else
3908 return 2; /* Directory exists and is not writable, NOT OK */
3909 }
3910 else
3911 {
3912 if (myFile.mkdirs())
3913 return 1; /* Directory created, OK */
3914 else
3915 return 4; /* Directory could not be created, NOT OK */
3916 }
3917 }
3918 }';
3919 javaOK := 1;
3920 EXCEPTION
3921 WHEN classInUse THEN javaOK := 1; -- already created
3922 WHEN OTHERS THEN javaOK := 0;
3923 END;
3924
3925 IF javaOK = 1 THEN
3926 createString := javaCreate;
3927 --
3928 -- Create the jacket System.exit function. We
3929 -- don't replace or drop this function.
3930 -- I don't ever want to get into a JavaSession Cleared
3931 -- state the very problem I am trying to solve.
3932 --
3933 BEGIN
3934 EXECUTE IMMEDIATE javaExitSession;
3935 EXCEPTION
3936 WHEN nameAlreadyExists THEN NULL;
3937 WHEN classInUse THEN NULL;
3938 WHEN OTHERS THEN NULL;
3939 END;
3940 ELSE
3941 -- Create dummy version if the java create failed
3942 createString := dummyCreate;
3943 END IF;
3944 ELSE
3945 -- JavaVM is not present or in an invalid state
3946 --
3947 -- Create dummy version of PreupCreateDir so subsequent
3948 -- blocks will compile
3949 createString := dummyCreate;
3950 END IF;
3951 EXECUTE IMMEDIATE createString;
3952
3953 IF javaOK = 1 THEN
3954 DECLARE
3955 --
3956 -- This exception is command and is handled by ending
3957 -- the session inside the loop.
3958 --
3959 JavaSessionCleared EXCEPTION;
3960 PRAGMA EXCEPTION_INIT(JavaSessionCleared, -29549);
3961 BEGIN
3962 clearJava := FALSE;
3963 status := 0;
3964 FOR tries IN 1..2 LOOP
3965 BEGIN
3966 EXECUTE IMMEDIATE 'CALL PreupCreateDir(:1) into :2'
3967 USING IN logDir, OUT status;
3968 EXCEPTION
3969 WHEN JavaSessionCleared THEN clearJava := TRUE;
3970 WHEN OTHERS THEN
3971 -- note: what used to be "usingExistingDef = FALSE"
3972 logDir := dbms_assert.enquote_literal(rdbmsLogDir);
3973 END;
3974
3975 IF clearJava THEN
3976 --
3977 -- Clear state and try again
3978 -- Use dynamic SQL since dbms_java may not be installed
3979 -- dbms_java.endsession is not Available in 10.2.0.5.0
3980 -- We will try to endsession using System.exit in Java if
3981 -- dbms_java.endsession is not present.
3982 --
3983 BEGIN
3984 EXECUTE IMMEDIATE 'BEGIN :1 := dbms_java.endsession; END;'
3985 USING OUT dummy;
3986 EXCEPTION WHEN OTHERS THEN clearJavaAgain := TRUE;
3987 END;
3988 --
3989 -- If not successful with dbms_java.endsession or not present
3990 -- then try clearing the session state with System.exit.
3991 --
3992 IF clearJavaAgain THEN
3993 BEGIN
3994 EXECUTE IMMEDIATE 'BEGIN PreupJavaExit(0); END; ';
3995 EXCEPTION
3996 WHEN exitCalledFromJava THEN NULL;
3997 WHEN JavaStateCleared THEN NULL;
3998 WHEN OTHERS THEN NULL;
3999 END;
4000 END IF;
4001
4002 ELSIF status = 1 THEN
4003 -- Success, exit loop
4004 EXIT;
4005 ELSIF status = 2 THEN
4006 --
4007 -- Directory exists, not writeable
4008 --
4009 --
4010 -- We said where to create the dir, and it failed,
4011 -- try the rdbmdLogDir area
4012 -- note: what used to be "usingExistingDef = FALSE"
4013 logDir := dbms_assert.enquote_literal(rdbmsLogDir);
4014 ELSE
4015 --
4016 -- status = 4 = could not create the directory
4017 --
4018 EXIT;
4019 END IF;
4020 END LOOP;
4021 END;
4022 --
4023 -- done with the java, clean it up
4024 --
4025 BEGIN
4026 EXECUTE IMMEDIATE 'DROP JAVA SOURCE "PreupCreateDir"';
4027 EXCEPTION WHEN OTHERS THEN NULL;
4028 END;
4029
4030 --
4031 -- end the session
4032 --
4033 BEGIN
4034 EXECUTE IMMEDIATE 'BEGIN :1 := dbms_java.endsession; END;'
4035 USING OUT dummy;
4036 EXCEPTION WHEN OTHERS THEN NULL;
4037 END;
4038 END IF;
4039
4040 --
4041 -- Even if we failed to verify things, try to create the
4042 -- default directory.
4043 --
4044 -- >> BEGIN: CREATE DIRECTORY OBJECT PREUPGRADE_DIR
4045 --
4046 -- Try to create the directory object for the actual directory
4047 -- the javascript created or verified existed
4048 --
4049 BEGIN
4050 EXECUTE IMMEDIATE
4051 'CREATE OR REPLACE DIRECTORY ' || c_dir_obj || ' AS ' || logDir ;
4052 EXCEPTION
4053 WHEN nameAlreadyExists THEN pCreatedDirObj := FALSE;
4054 WHEN OTHERS THEN status := 0;
4055 END;
4056
4057 IF status = 0 THEN
4058 pOutputLocation := NULL;
4059 pOutputVerified := FALSE;
4060 DisplayLine('WARNING: Unable to create required directory object');
4061 DisplayLine(' Terminal output only');
4062 RETURN;
4063 END IF;
4064 BEGIN
4065 -- 10.n gives an error on granting to sys, just ignore it.
4066 EXECUTE IMMEDIATE
4067 'GRANT READ,WRITE ON DIRECTORY ' || c_dir_obj || ' TO SYS';
4068 EXCEPTION WHEN OTHERS THEN NULL;
4069 END;
4070 -- >> END: CREATE DIRECTORY OBJECT PREUPGRADE_DIR
4071
4072 -- create pdbfiles PDB_PREUPGRADE_DIR if:
4073 -- a) pOutputLocation is not NULL, which means not writing to terminal
4074 -- and
4075 -- b) this db is a non-root container
4076 IF (pOutputLocation is NOT NULL) AND
4077 (dbms_preup.is_db_noncdb = FALSE AND dbms_preup.is_con_root = FALSE) THEN
4078 BEGIN
4079 EXECUTE IMMEDIATE
4080 'CREATE OR REPLACE DIRECTORY ' || c_pdb_dir_obj || ' AS ' || pdbLogDir ;
4081 IF tracing_on_xxx THEN
4082 dbms_output.put_line('XXX created directory object ' || c_pdb_dir_obj);
4083 END IF;
4084
4085 EXECUTE IMMEDIATE
4086 'GRANT READ, WRITE ON DIRECTORY ' || c_pdb_dir_obj || ' TO SYS';
4087 IF tracing_on_xxx THEN
4088 dbms_output.put_line('XXX granted permissions to c_pdb_dir_obj');
4089 END IF;
4090
4091 IF tracing_on_xxx THEN
4092 dbms_output.put_line('XXX pdb dir obj created');
4093 END IF;
4094
4095 pCreatedPdbDirObj := TRUE; -- pdb dir obj created
4096 EXCEPTION
4097 WHEN OTHERS THEN
4098 dbms_output.put_line('');
4099 dbms_output.put_line(
4100 'Error when trying to create and/or grant permissions on ' ||
4101 'directory object PDB_PREUPGRADE_DIR. ' ||
4102 'Please fix the error before rerunning the preupgrade tool.');
4103 dbms_output.put_line('');
4104 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
4105 END;
4106 END IF;
4107
4108 IF status != 1 THEN
4109 --
4110 -- something went wrong with the java (or it was not even executed)
4111 --
4112 pOutputLocation := NULL;
4113 pOutputVerified := FALSE;
4114
4115 IF status = 2 THEN
4116 -- A two means we can't write to the area.
4117 tmp_varchar := 'Unable to write to directory ';
4118 ELSIF status = 4 THEN
4119 -- Only other is a 4 which means we couldn't create the dir
4120 tmp_varchar := 'Unable to create directory ';
4121 ELSE
4122 -- 0 ? Could not verify/create because of JAVA
4123 tmp_varchar := 'Unable to verify or create directory ';
4124 END IF;
4125
4126 --
4127 -- We failed to create the directory that we want
4128 --
4129 DisplayLine('WARNING: ' || tmp_varchar || logDir
4130 || ' for Directory Object: ' || c_dir_obj);
4131
4132 --
4133 -- Finish it off and get out.
4134 --
4135 DisplayLine(' script will generate terminal output only');
4136 RETURN;
4137 END IF;
4138
4139 -- save paths of PREUPGRADE_DIR and PDB_PREUPGRADE_DIR for display messages
4140 -- no need to save the path for the xml dir obj as DBUA controls that
4141 pTextLogDir:= logDir; -- PREUPGRADE_DIR
4142 pPdbLogDir := pdbLogDir; -- PDB_PREUPGRADE_DIR
4143
4144 --
4145 -- Set the package variable (will be used for utl_file)
4146 --
4147 pOutputLocation := c_dir_obj;
4148 pOutputVerified := TRUE;
4149
4150 END verifyDefaultDirObj;
4151
4152 PROCEDURE start_xml_document
4153 IS
4154 BEGIN
4155 -- Let's start an xml document IF one of the following is TRUE:
4156 -- (a) this db is NOT a cdb
4157 -- OR
4158 -- (b) if this db is a cdb and current container is CDB$ROOT
4159 if (dbms_preup.is_db_noncdb OR dbms_preup.is_con_root) then
4160 init_package;
4161
4162 -- This line will be written by DBUA prior to running the preugprade tool:
4163 -- DisplayLine ('<UPGRADE>');
4164
4165 end if;
4166 END start_xml_document;
4167
4168 PROCEDURE end_xml_document
4169 IS
4170 misc NUMBER;
4171 BEGIN
4172
4173 -- DBUA will append the following line to xml document upgrade.xml after
4174 -- preupgrade tool is finished:
4175 -- DisplayLine ('</UPGRADE>');
4176
4177 -- Cannot have an empty procedure, so just do a dummy stmt to keep this
4178 -- procedure here.
4179 misc := 1;
4180
4181 END end_xml_document;
4182
4183 -- ****************************************************************************
4184 -- Run a specific check, but don't generate any fixup script or output
4185 -- Do that by setting the 'pCheckOnly' package level variable then execute
4186 -- the check
4187 -- ****************************************************************************
4188 FUNCTION run_check_simple (check_name VARCHAR2) RETURN check_record_t
4189 IS
4190 t_check_rec check_record_t;
4191 execute_failed BOOLEAN := FALSE;
4192 idx NUMBER;
4193 retval NUMBER;
4194 check_stmt VARCHAR2(100);
4195 r_text VARCHAR2(4000);
4196
4197 BEGIN
4198 init_package;
4199
4200 IF check_names.EXISTS(check_name) = FALSE
4201 THEN
4202 EXECUTE IMMEDIATE 'BEGIN
4203 RAISE_APPLICATION_ERROR (-20000,
4204 ''Pre-Upgrade Package Requested Check does not exist''); END;';
4205 RETURN (NULL);
4206 END IF;
4207 idx := check_names(check_name).idx;
4208
4209 pCheckOnly := TRUE;
4210
4211 IF check_table(idx).always_fail THEN
4212 --
4213 -- We want to fail this check, set the global
4214 -- so the package checks know to fail
4215 --
4216 pDBGFailCheck := TRUE;
4217 END IF;
4218
4219 -- Clear out the info about the check before
4220 -- executing it (only an issue during re-run)
4221 --
4222 check_table(idx).passed := FALSE;
4223 check_table(idx).skipped := FALSE;
4224 check_table(idx).executed := FALSE;
4225 check_table(idx).execute_failed := FALSE;
4226 check_table(idx).fixup_executed := FALSE;
4227 check_table(idx).fixup_failed := FALSE;
4228 check_table(idx).always_fail := FALSE;
4229
4230 check_stmt := 'BEGIN :r1 := dbms_preup.'
4231 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4232 || '_check (:rtxt); END;';
4233
4234 BEGIN
4235 EXECUTE IMMEDIATE check_stmt
4236 USING OUT retval, IN OUT r_text;
4237 EXCEPTION WHEN OTHERS THEN
4238 execute_failed := TRUE;
4239 END;
4240
4241 --
4242 -- Save away the results of the check
4243 --
4244 t_check_rec.executed := TRUE;
4245
4246 IF execute_failed = TRUE
4247 THEN
4248 -- Passed is already FALSE
4249 t_check_rec.execute_failed := TRUE;
4250 ELSE
4251 IF retval = c_status_success THEN
4252 t_check_rec.passed := TRUE;
4253 ELSIF retval = c_status_not_for_this_version THEN
4254 t_check_rec.passed := TRUE;
4255 t_check_rec.skipped := TRUE;
4256 ELSE
4257 -- Passed is already FALSE
4258 t_check_rec.result_text := r_text;
4259 END IF;
4260 END IF;
4261
4262 --
4263 -- Always turn these off
4264 --
4265 pDBGFailCheck := FALSE;
4266 pCheckOnly := FALSE;
4267
4268 return t_check_rec;
4269 END run_check_simple;
4270
4271 -- ****************************************************************************
4272 -- Same as run_check_simple only return true/false
4273 -- ****************************************************************************
4274 FUNCTION condition_exists (check_name VARCHAR2) RETURN BOOLEAN
4275 IS
4276 t_check_rec check_record_t := NULL;
4277 execute_failed BOOLEAN := FALSE;
4278 idx NUMBER;
4279 retval NUMBER;
4280 check_stmt VARCHAR2(100);
4281 r_text VARCHAR2(4000);
4282
4283 BEGIN
4284 init_package;
4285
4286 t_check_rec := dbms_preup.run_check_simple(check_name);
4287
4288 IF t_check_rec.passed THEN
4289 RETURN FALSE;
4290 ELSE
4291 RETURN TRUE;
4292 END IF;
4293 END condition_exists;
4294
4295
4296 FUNCTION run_check (check_name VARCHAR2) RETURN check_record_t
4297 IS
4298 execute_failed BOOLEAN := FALSE;
4299 idx NUMBER;
4300 retval NUMBER;
4301 check_stmt VARCHAR2(100);
4302 r_text VARCHAR2(4000);
4303
4304 BEGIN
4305
4306 init_package;
4307
4308 IF check_names.EXISTS(check_name) = FALSE
4309 THEN
4310 EXECUTE IMMEDIATE 'BEGIN
4311 RAISE_APPLICATION_ERROR (-20000,
4312 ''Pre-Upgrade Package Requested Check does not exist''); END;';
4313 return (NULL);
4314 END IF;
4315 idx := check_names(check_name).idx;
4316
4317 IF check_table(idx).always_fail THEN
4318 --
4319 -- We want to fail this check, set the global
4320 -- so the package checks know to fail
4321 --
4322 pDBGFailCheck := TRUE;
4323 END IF;
4324
4325 -- Clear out the info about the check before
4326 -- executing it (only an issue during re-run)
4327 --
4328 check_table(idx).passed := FALSE;
4329 check_table(idx).skipped := FALSE;
4330 check_table(idx).executed := FALSE;
4331 check_table(idx).execute_failed := FALSE;
4332 check_table(idx).fixup_executed := FALSE;
4333 check_table(idx).fixup_failed := FALSE;
4334 check_table(idx).always_fail := FALSE;
4335
4336 --
4337 -- This executes the check procedure
4338 -- An example would be
4339 --
4340 -- BEGIN :r1 := purge_recyclebin_check(r_text); END;
4341 --
4342
4343 check_stmt := 'BEGIN :r1 := dbms_preup.'
4344 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4345 || '_check (:rtxt); END;';
4346
4347 BEGIN
4348 EXECUTE IMMEDIATE check_stmt
4349 USING OUT retval, IN OUT r_text;
4350 EXCEPTION WHEN OTHERS THEN
4351 execute_failed := TRUE;
4352 END;
4353
4354 --
4355 -- Save away the results of the check
4356 --
4357 check_table(idx).executed := TRUE;
4358
4359 if execute_failed = TRUE
4360 THEN
4361 check_table(idx).execute_failed := TRUE;
4362 check_table(idx).passed := FALSE;
4363 ELSE
4364 IF retval = c_status_success THEN
4365 check_table(idx).passed := TRUE;
4366 ELSIF retval = c_status_not_for_this_version THEN
4367 check_table(idx).passed := TRUE;
4368 check_table(idx).skipped := TRUE;
4369 ELSE
4370 check_table(idx).passed := FALSE;
4371 check_table(idx).result_text := r_text;
4372 END IF;
4373 END IF;
4374 --
4375 -- Always turn this off
4376 --
4377 pDBGFailCheck := FALSE;
4378 return (check_table(idx));
4379 END run_check;
4380
4381 --
4382 -- Run a check, dump out the results, no script created
4383 --
4384 PROCEDURE run_check (check_name VARCHAR2)
4385 IS
4386 t_check_rec check_record_t;
4387 execute_failed BOOLEAN := FALSE;
4388 checkonly BOOLEAN;
4389 idx NUMBER;
4390 retval NUMBER;
4391 check_stmt VARCHAR2(100);
4392 r_text VARCHAR2(4000);
4393
4394 BEGIN
4395
4396 init_package;
4397
4398 IF check_names.EXISTS(check_name) = FALSE
4399 THEN
4400 EXECUTE IMMEDIATE 'BEGIN
4401 RAISE_APPLICATION_ERROR (-20000,
4402 ''Pre-Upgrade Package Requested Check does not exist''); END;';
4403 return;
4404 END IF;
4405
4406 checkonly := pCheckOnly;
4407 pCheckOnly := TRUE;
4408
4409 idx := check_names(check_name).idx;
4410
4411 --
4412 -- Because the info is not recorded in our check_table,
4413 -- the run status fields do not need to be cleared)
4414 --
4415
4416 --
4417 -- This executes the check procedure
4418 -- An example would be
4419 --
4420 -- BEGIN :r1 := purge_recyclebin_check(r_text); END;
4421 --
4422 check_stmt := 'BEGIN :r1 := dbms_preup.'
4423 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4424 || '_check (:rtxt); END;';
4425
4426 BEGIN
4427 EXECUTE IMMEDIATE check_stmt
4428 USING OUT retval, IN OUT r_text;
4429 EXCEPTION WHEN OTHERS THEN
4430 execute_failed := TRUE;
4431 END;
4432
4433 DisplayLinePL('');
4434 DisplayLinePL('**********************************************************************');
4435 DisplayLinePL('Check Tag: ' || check_table(idx).name);
4436 DisplayLinePL('Check Summary: ' || check_table(idx).descript);
4437 DisplayLinePL('Check Help Text: ');
4438 DisplayLinePL(' ' || getHelp(check_table(idx).name,c_help_overview));
4439 DisplayLinePL('Fixup Summary: ');
4440 DisplayLinePL(' ' || getHelp(check_table(idx).name,c_help_fixup));
4441 DisplayLinePL('');
4442
4443
4444 IF execute_failed = TRUE THEN
4445 DisplayLinePL(CenterLine('**** Check Failed to Execute ****'));
4446 ELSE
4447 IF retval = c_status_success THEN
4448 DisplayLinePL('++++ Check Passed');
4449 ELSIF retval = c_status_not_for_this_version THEN
4450 DisplayLinePL('++++ Check Not Valid from your current release.');
4451 ELSE
4452 DisplayLinePL('++++ Check Failed:');
4453 DisplayLinePL(' ' || r_text);
4454 END IF;
4455 END IF;
4456 --
4457 -- Restore setting
4458 --
4459 pCheckOnly := checkonly;
4460 END run_check;
4461
4462 PROCEDURE run_fixup_and_report (check_name VARCHAR2)
4463 IS
4464 --
4465 -- Run a check and dump any errors out to stdout.
4466 -- This procedure is used by the fixup scripts.
4467 -- "set server output on" must be executed before and
4468 -- must be connected as SYS
4469 --
4470 -- NOTE:
4471 -- This function is intended to be run OUTSIDE of the preupgrade
4472 -- checks, therefore, its output is displayed to the terminal or
4473 -- redirected location specified (spool) and not to the preupgrade
4474 -- log file.
4475 --
4476 idx NUMBER;
4477 retval NUMBER;
4478 r_sqlcode NUMBER := 0;
4479 check_stmt VARCHAR2(100);
4480 r_text VARCHAR2(4000);
4481
4482 BEGIN
4483 init_package;
4484
4485 IF check_names.EXISTS(check_name) = FALSE
4486 THEN
4487 RAISE_APPLICATION_ERROR (-20000,
4488 'Pre-Upgrade Package Requested Fixup: ' ||
4489 check_name || ' does not exist');
4490 RETURN;
4491 END IF;
4492 idx := check_names(check_name).idx;
4493
4494 --
4495 -- This executes the fixup procedure,
4496 -- An example would be
4497 --
4498 -- BEGIN :r1 := purge_recyclebin_fixup(r_text, r_sqlcode); END;
4499 --
4500
4501 check_stmt := 'BEGIN :r1 := dbms_preup.'
4502 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4503 || '_fixup (:rtxt, :rsqlcode); END;';
4504
4505 --
4506 -- No exception catching here, let the lower levels catch
4507 -- and return the problems.
4508 --
4509 DisplayLinePL('');
4510 DisplayLinePL('**********************************************************************');
4511 DisplayLinePL('Check Tag: ' || check_table(idx).name);
4512 DisplayLinePL('Check Summary: ' || check_table(idx).descript);
4513 DisplayLinePL('Fix Summary: ' || getHelp(check_table(idx).name,c_help_fixup));
4514 DisplayLinePL('**********************************************************************');
4515
4516 --
4517 -- Clear out the existing values
4518 --
4519 check_table(idx).fixup_executed := FALSE;
4520 check_table(idx).result_text := '';
4521 check_table(idx).sqlcode := 0;
4522
4523 EXECUTE IMMEDIATE check_stmt
4524 USING OUT retval, IN OUT r_text, IN OUT r_sqlcode;
4525
4526 --
4527 -- Save away the results of the fixup
4528 --
4529 check_table(idx).fixup_executed := TRUE;
4530 check_table(idx).result_text := r_text;
4531 check_table(idx).sqlcode := r_sqlcode;
4532 check_table(idx).fixup_status := retval;
4533
4534 IF retval = c_fixup_status_success THEN
4535 check_table(idx).fixup_failed := FALSE;
4536 DisplayLinePL('Fixup Succeeded');
4537 ELSIF retval = c_fixup_status_info THEN
4538 -- The fixup wants to return some text, display it here
4539 check_table(idx).fixup_failed := FALSE;
4540 DisplayLinePL('Fixup Returned Information:');
4541 DisplayLinePL(check_table(idx).result_text);
4542 ELSE
4543 check_table(idx).fixup_failed := TRUE;
4544 DisplayLinePL('Fixup Failed:');
4545 DisplayLinePL (check_table(idx).result_text);
4546 DisplayLinePL ('SQL Code: ' || check_table(idx).sqlcode);
4547 END IF;
4548 DisplayLinePL('**********************************************************************');
4549 DisplayLinePL('');
4550 return;
4551 END run_fixup_and_report;
4552
4553
4554 PROCEDURE run_fixup_info (check_name VARCHAR2)
4555 IS
4556 --
4557 -- Run a check, and instead of returning a record with the info
4558 -- on the run (which is what run_check does), This grabs the return
4559 -- text from the fixup routine and displays it.
4560 -- This is only used for those fixup functions that can not do
4561 -- anything for the existing issue, but we need to display some
4562 -- text.
4563 --
4564 -- NOTE:
4565 -- This function is intended to be run OUTSIDE of the preupgrade
4566 -- checks, therefore, its output is displayed to the terminal or
4567 -- redirected location specified and not to the preupgrade
4568 -- log file.
4569 --
4570 idx NUMBER;
4571 retval NUMBER;
4572 r_sqlcode NUMBER := 0;
4573 check_stmt VARCHAR2(100);
4574 r_text VARCHAR2(4000);
4575
4576 BEGIN
4577 init_package;
4578
4579 IF check_names.EXISTS(check_name) = FALSE
4580 THEN
4581 RAISE_APPLICATION_ERROR (-20000,
4582 'Pre-Upgrade Package Requested Fixup: ' ||
4583 check_name || ' does not exist');
4584 RETURN;
4585 END IF;
4586 idx := check_names(check_name).idx;
4587
4588 --
4589 -- This executes the fixup procedure,
4590 -- An example would be
4591 --
4592 -- BEGIN :r1 := purge_recyclebin_fixup(r_text, r_sqlcode); END;
4593 --
4594
4595 check_stmt := 'BEGIN :r1 := dbms_preup.'
4596 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4597 || '_fixup (:rtxt, :rsqlcode); END;';
4598
4599 --
4600 -- No exception catching here, let the lower levels catch
4601 -- and return the problems.
4602 --
4603
4604 dbms_output.put_line ('------- ---------- Executing Fixup ------------ ----------');
4605 dbms_output.put_line ('------- ' || RPAD (check_table(idx).name, 40) || ' ----------');
4606
4607 EXECUTE IMMEDIATE check_stmt
4608 USING OUT retval, IN OUT r_text, IN OUT r_sqlcode;
4609
4610 --
4611 -- Save away the results of the fixup
4612 --
4613 check_table(idx).fixup_executed := TRUE;
4614 check_table(idx).result_text := r_text;
4615 check_table(idx).sqlcode := r_sqlcode;
4616 --
4617 -- don't care about the return status
4618 --
4619 check_table(idx).fixup_failed := FALSE;
4620 dbms_output.put_line ('------- ------------ Fixup Succeeded ----------- ----------');
4621 dbms_output.put_line ('------- ------- Informational Text Returned ---- ----------');
4622 dbms_output.put_line (check_table(idx).result_text);
4623 dbms_output.put_line ('------- ---------------------------------------- ----------');
4624 END run_fixup_info;
4625
4626
4627 FUNCTION run_fixup (check_name VARCHAR2) RETURN check_record_t
4628 IS
4629 idx NUMBER;
4630 retval NUMBER;
4631 r_sqlcode NUMBER := 0;
4632 check_stmt VARCHAR2(100);
4633 r_text VARCHAR2(4000);
4634
4635 BEGIN
4636 init_package;
4637
4638 IF check_names.EXISTS(check_name) = FALSE
4639 THEN
4640 EXECUTE IMMEDIATE 'BEGIN
4641 RAISE_APPLICATION_ERROR (-20000,
4642 ''Pre-Upgrade Package Requested Fixup: '' ||
4643 check_name || '' does not exist''); END;';
4644 return (NULL);
4645 END IF;
4646 idx := check_names(check_name).idx;
4647
4648 -- This executes the fixup procedure
4649 -- An example would be
4650 --
4651 -- BEGIN :r1 := purge_recyclebin_fixup(r_text, r_sqlcode); END;
4652 --
4653
4654 check_stmt := 'BEGIN :r1 := dbms_preup.'
4655 || dbms_assert.simple_sql_name(check_table(idx).f_name_prefix)
4656 || '_fixup (:rtxt, :rsqlcode); END;';
4657
4658 --
4659 -- No exception catching here, let the lower levels catch
4660 -- and return the problems.
4661 --
4662 EXECUTE IMMEDIATE check_stmt
4663 USING OUT retval, IN OUT r_text, IN OUT r_sqlcode;
4664
4665 --
4666 -- Save away the results of the fixup
4667 --
4668 check_table(idx).fixup_executed := TRUE;
4669 check_table(idx).result_text := r_text;
4670 check_table(idx).sqlcode := r_sqlcode;
4671
4672 IF retval = 1
4673 THEN
4674 check_table(idx).fixup_failed := FALSE;
4675 ELSE
4676 check_table(idx).fixup_failed := TRUE;
4677 END IF;
4678
4679 return (check_table(idx));
4680 END run_fixup;
4681
4682 -- ****************************************************************************
4683 -- Debug Functions/Procedures
4684 -- ****************************************************************************
4685
4686 --
4687 -- Set always_fail for a specific check, causing the check to not
4688 -- actually execute the specific check, but cause it to 'fail'
4689 --
4690 PROCEDURE dbg_check (check_name VARCHAR2)
4691 IS
4692 execute_failed BOOLEAN := FALSE;
4693 idx NUMBER;
4694 retval NUMBER;
4695 check_stmt VARCHAR2(100);
4696
4697 BEGIN
4698 init_package;
4699
4700 IF check_names.EXISTS(check_name) = FALSE
4701 THEN
4702 EXECUTE IMMEDIATE 'BEGIN
4703 RAISE_APPLICATION_ERROR (-20000,
4704 ''Pre-Upgrade Package Requested Check does not exist''); END;';
4705 END IF;
4706 idx := check_names(check_name).idx;
4707 check_table(idx).always_fail := TRUE;
4708 END dbg_check;
4709
4710 --
4711 -- Set All the checks always_fail to TRUE
4712 --
4713 PROCEDURE dbg_all_checks
4714 IS
4715 BEGIN
4716 init_package;
4717
4718 FOR i IN 1..pCheckCount LOOP
4719 check_table(i).always_fail := TRUE;
4720 END LOOP;
4721 pDBGFailAll := TRUE;
4722 END dbg_all_checks;
4723
4724 --
4725 -- Turn on or off the output of space information into
4726 -- the log
4727 --
4728 PROCEDURE dbg_space_resources (onoff BOOLEAN)
4729 IS
4730 BEGIN
4731 init_package;
4732 pDBGSizeResources := onoff;
4733 END dbg_space_resources;
4734
4735 --
4736 -- Turn on or off the output of resource information
4737 -- (as if there is an issue with each resource)
4738 --
4739 PROCEDURE dbg_all_resources (onoff BOOLEAN)
4740 IS
4741 BEGIN
4742 init_package;
4743 pDBGAllResources := onoff;
4744 END dbg_all_resources;
4745
4746 --
4747 -- Output the result text of a check
4748 --
4749 PROCEDURE display_check_text (check_record check_record_t )
4750 IS
4751 BEGIN
4752 DisplayLine (check_record.result_text);
4753 END display_check_text;
4754
4755 -- ****************************************************************************
4756 -- General utility functions
4757 -- ****************************************************************************
4758
4759 --------------------------- pvalue_to_number --------------------------------
4760 -- This function converts a parameter string to a number. The function takes
4761 -- into account that the parameter string may have a 'K' or 'M' multiplier
4762 -- character.
4763 FUNCTION pvalue_to_number (value_string VARCHAR2) RETURN NUMBER
4764 IS
4765 ilen NUMBER;
4766 pvalue_number NUMBER;
4767
4768 BEGIN
4769 -- How long is the input string?
4770 ilen := LENGTH ( value_string );
4771
4772 -- Is there a 'K' or 'M' in last position?
4773 IF SUBSTR(UPPER(value_string), ilen, 1) = 'K' THEN
4774 RETURN (c_kb * TO_NUMBER (SUBSTR (value_string, 1, ilen-1)));
4775
4776 ELSIF SUBSTR(UPPER(value_string), ilen, 1) = 'M' THEN
4777 RETURN (c_mb * TO_NUMBER (SUBSTR (value_string, 1, ilen-1)));
4778 END IF;
4779
4780 -- A multiplier wasn't found. Simply convert this string to a number.
4781 RETURN (TO_NUMBER (value_string));
4782 END pvalue_to_number;
4783
4784 PROCEDURE store_oldval (minvp IN OUT MINVALUE_TABLE_T)
4785 IS
4786 c_value VARCHAR2(80);
4787 i INTEGER;
4788 BEGIN
4789 FOR i IN 1..max_minvp LOOP
4790 BEGIN
4791 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name =
4792 LOWER(:1)'
4793 INTO c_value
4794 USING minvp(i).name;
4795 minvp(i).oldvalue := pvalue_to_number(c_value);
4796 EXCEPTION WHEN NO_DATA_FOUND THEN
4797 minvp(i).oldvalue := NULL;
4798 END;
4799 END LOOP;
4800
4801 -- After getting init ora values:
4802 -- Parameter streams_pool_size is not available in 92. Set old value to 0.
4803 IF (db_n_version = 920) THEN
4804 minvp(sr_idx).oldvalue := 0;
4805 END IF;
4806 END store_oldval;
4807
4808 PROCEDURE store_renamed (i IN OUT BINARY_INTEGER,
4809 old VARCHAR2,
4810 new VARCHAR2)
4811 IS
4812 BEGIN
4813 i:= i+1;
4814 rp(i).oldname:=old;
4815 rp(i).newname:=new;
4816 END store_renamed;
4817
4818 PROCEDURE store_removed (i IN OUT BINARY_INTEGER,
4819 name VARCHAR2,
4820 version VARCHAR2,
4821 deprecated BOOLEAN)
4822 IS
4823 BEGIN
4824 i:=i+1;
4825 op(i).name:=name;
4826 op(i).version:=version;
4827 op(i).deprecated:=deprecated;
4828 END store_removed;
4829
4830 PROCEDURE store_special (i IN OUT BINARY_INTEGER,
4831 old VARCHAR2,
4832 oldv VARCHAR2,
4833 new VARCHAR2,
4834 newv VARCHAR2)
4835 IS
4836 BEGIN
4837 i:= i+1;
4838 sp(i).oldname := old;
4839 sp(i).oldvalue := oldv;
4840 sp(i).newname := new;
4841 sp(i).newvalue := newv;
4842 sp(i).db_match := FALSE;
4843 sp(i).dbua_OutInUpdate := FALSE;
4844 END store_special;
4845
4846 PROCEDURE store_required (i IN OUT BINARY_INTEGER,
4847 name VARCHAR2,
4848 newvn NUMBER,
4849 newvs VARCHAR2,
4850 dtype NUMBER)
4851 --
4852 -- Pass a 0, or '', for the newvn (new value numeric) or
4853 -- that you are not setting.
4854 -- store_required(idx, 'foo', 0, 'bar', 2);
4855 -- would mean a string value of 'bar' is expected
4856 --
4857 IS
4858 BEGIN
4859 i:= i+1;
4860 reqp(i).name:=name;
4861 reqp(i).newnumbervalue:=newvn;
4862 reqp(i).newstringvalue:=newvs;
4863 reqp(i).type:= dtype;
4864 reqp(i).db_match:=FALSE;
4865 END store_required;
4866
4867 PROCEDURE find_newval (minvp IN OUT MINVALUE_TABLE_T,
4868 dbbit NUMBER)
4869 IS
4870 extra NUMBER;
4871 BEGIN
4872
4873
4874 -- For 11.1 and up check if MEMORY_TARGET is set and NON-ZERO
4875 --
4876 -- check sga_target + pga_target (for cases where SGA_TARGET is in use)
4877 --
4878 -- memory_target in use
4879 IF db_n_version not in (102) AND minvp(mt_idx).oldvalue != 0 THEN
4880 find_sga_mem_values(minvp, dbbit);
4881
4882 -- If the newvalue is greater than the old value set the display TRUE
4883 IF minvp(mt_idx).newvalue > minvp(mt_idx).oldvalue THEN
4884 minvp(mt_idx).display := TRUE;
4885 END IF;
4886
4887 -- Loop through other pool sizes to ignore warnings
4888 --
4889 -- If a minimum value is required for MEMORY_TARGET then
4890 -- do not output a minimum value for sga_target, pga_aggregate_target,
4891 -- shared_pool_size, java_pool_size, db_cache_size,
4892 -- large_pool_size, and streams_pool_size as these values
4893 -- are no longer considered once MEMORY_TARGET value is set.
4894 -- i.e., for params listed above, set display to FALSE if memory_target
4895 -- is set.
4896 --
4897 -- do not replace memory_target's newvalue with minvalue
4898 FOR i IN 1..max_minvp LOOP
4899 IF i NOT IN (mt_idx,st_idx,pt_idx,sp_idx,jv_idx,cs_idx,lp_idx,sr_idx) AND
4900 (minvp(i).oldvalue IS NULL OR
4901 minvp(i).oldvalue < minvp(i).minvalue)
4902 THEN
4903 minvp(i).display := TRUE;
4904 minvp(i).newvalue := minvp(i).minvalue;
4905 END IF;
4906 END LOOP;
4907
4908 ELSIF minvp(st_idx).oldvalue != 0 THEN -- SGA_TARGET in use
4909 find_sga_mem_values(minvp, dbbit);
4910
4911 IF minvp(st_idx).newvalue > minvp(st_idx).oldvalue THEN
4912 minvp(st_idx).display := TRUE;
4913 END IF;
4914
4915 -- do not set display to TRUE for these params:
4916 -- memory_target, db_cache_size, java_pool_size,
4917 -- shared_pool_size, large_pool_size, and streams_pool_size
4918 -- do not replace sga_target's newvalue with minvalue
4919 FOR i IN 1..max_minvp LOOP
4920 IF i NOT IN (st_idx,mt_idx,cs_idx,jv_idx,sp_idx,lp_idx,sr_idx) AND
4921 (minvp(i).oldvalue IS NULL OR
4922 minvp(i).oldvalue < minvp(i).minvalue)
4923 THEN
4924 minvp(i).display := TRUE;
4925 minvp(i).newvalue := minvp(i).minvalue;
4926 END IF;
4927 END LOOP;
4928
4929 ELSE -- only pool sizes are used
4930 FOR i IN 1..max_minvp LOOP
4931 -- don't print recommendations for sga_target, memory_target,
4932 -- large_pool_size, and streams_pool_size
4933 IF i NOT IN (st_idx,mt_idx,lp_idx,sr_idx) AND
4934 (minvp(i).oldvalue IS NULL OR
4935 minvp(i).oldvalue < minvp(i).minvalue)
4936 THEN
4937 minvp(i).display := TRUE;
4938 minvp(i).newvalue := minvp(i).minvalue;
4939 END IF;
4940 END LOOP;
4941 END IF; -- end of if memory_target, if sga_target, or if neither is in use
4942
4943 --
4944 -- for those memory size parmeters outside of memory_target/sga_target
4945 -- that won't be recommended, explicitly set DISPLAY to FALSE here (even
4946 -- if some had already been set to FALSE above)
4947 --
4948 -- we do not make recommendations for:
4949 minvp(lp_idx).display := FALSE; -- large pool
4950 minvp(sr_idx).display := FALSE; -- streams pool
4951 minvp(pt_idx).display := FALSE; -- pga aggregate target
4952
4953 -- do not recommend pga aggregate limit on upgrades to 12.1.0.2 - period
4954 -- bug 24696626
4955 minvp(pl_idx).display := FALSE;
4956
4957 END find_newval;
4958
4959 --------------------------- init_mem_sizes -------------------------------
4960 -- This is called from init_initparams
4961 -- We're here because we need to initialize min values for memory sizes
4962 -- for upgrade.
4963
4964 PROCEDURE init_mem_sizes (minvp IN OUT MINVALUE_TABLE_T,
4965 dbbit IN NUMBER,
4966 max_minvp IN OUT BINARY_INTEGER)
4967 IS
4968 extra NUMBER;
4969 mtgval NUMBER;
4970 minvalue NUMBER; -- minimum value to set
4971 pdbs_para NUMBER; -- at most # of pdbs upgrading in parallel at a time
4972 batches NUMBER; -- approximate # of pdb upgrade "cycles"
4973 idx BINARY_INTEGER; -- index to minvp
4974 BEGIN
4975
4976 extra := 0;
4977 idx := 0;
4978
4979 -- create minvp records and initialize the values to 0MB
4980 -- note: although we are not making minium recommendations for large pool
4981 -- and stream pool, we still need their values (if user-set) for
4982 -- sga_target calculation
4983 store_minval_dbbit(dbbit,idx,'db_cache_size', 0);
4984 cs_idx := idx;
4985 store_minval_dbbit(dbbit,idx,'java_pool_size', 0);
4986 jv_idx := idx;
4987 store_minval_dbbit(dbbit,idx,'shared_pool_size', 0);
4988 sp_idx := idx;
4989 store_minval_dbbit(dbbit,idx,'large_pool_size', 0);
4990 lp_idx := idx;
4991 store_minval_dbbit(dbbit,idx,'streams_pool_size', 0);
4992 sr_idx := idx;
4993 store_minval_dbbit(dbbit,idx,'pga_aggregate_target', 0);
4994 pt_idx := idx;
4995 store_minval_dbbit(dbbit,idx,'pga_aggregate_limit', 0);
4996 pl_idx := idx;
4997 store_minval_dbbit(dbbit,idx,'sga_target', 0);
4998 st_idx := idx;
4999 store_minval_dbbit(dbbit,idx,'memory_target', 0);
5000 mt_idx := idx;
5001 max_minvp := idx;
5002
5003 -- point to the right table of mem values
5004 IF dbbit = 32 THEN
5005 minvp := minvp_db32;
5006 ELSE
5007 minvp := minvp_db64;
5008 END IF;
5009
5010 -- 12c doesn't support 32 bit database so there is no need to size
5011 -- for 32 bit database here.
5012 -- but since the data structures to support 32 bit db are already here
5013 -- and dbua in 12.1 is still using this info, we will keep the 32 bit code.
5014 -- but will not display the 32 bit values in manual preupgrade output
5015 -- and will remove the 32 bit code in 12.2.
5016
5017 -- lets just make 32 bit values here the same as 64 bit values
5018
5019 -- db_cache_size
5020 IF db_cpus <= 12 THEN
5021 minvp(cs_idx).minvalue := 48 * c_mb;
5022 ELSE
5023 minvp(cs_idx).minvalue := (4 * db_cpus) * c_mb;
5024 END IF;
5025
5026 -- large pool size
5027 minvp(lp_idx).minvalue := 8 * c_mb;
5028
5029 -- streams_pool_size
5030 minvp(sr_idx).minvalue := 0; -- 0M
5031
5032 IF sys.dbms_preup.is_db_noncdb = TRUE THEN -- this db is a non-cdb
5033 -- java_pool_size
5034 minvp(jv_idx).minvalue := 100 * c_mb;
5035
5036 -- shared_pool_size
5037 -- (RTI 18990952 [lrgcu44bdbua]: 472M shared pool was not enough on
5038 -- AIX.PPC64 upgrading 11.2.0.4 to 12.2. 660M worked.)
5039 extra := (264 * 1.5) * c_mb;
5040 minvp(sp_idx).minvalue := 264 * c_mb + extra;
5041 extra := 0;
5042
5043 -- pga_aggregate_target
5044 minvp(pt_idx).minvalue := 384 * c_mb;
5045
5046 -- pga_aggregate_limit (pl_idx)
5047 -- bug 22960672: recommend pga_aggregate_limit only for cdbs because
5048 -- we have not seen a non-cdb exceeding this parameter yet
5049 -- note: pga_aggregate_limit is a new parameter in 12.1.0.1
5050 minvp(pl_idx).display := FALSE;
5051
5052 ELSE -- IF db is a cdb
5053 db_npdbs := sys.dbms_preup.get_npdbs;
5054
5055 -- find # of pdbs that at most will be upgrading at a time.
5056 -- using the default as defined in catctl.pl.
5057 -- will size for default, which is at most smallest integer of cpu_count/2
5058 -- of pdbs upgrading at a time.
5059 -- for example,
5060 -- if cdb has 33 pdbs and # of cpus is 32, then pdbs_para=32/2=16
5061 IF db_npdbs >= trunc(db_cpus/2) THEN -- if # of pdbs >= (# of cpus/2)
5062 IF db_cpus = 1 THEN
5063 -- on 1 cpu mach, default is at most 1 pdb upgrading in parallel
5064 pdbs_para := 1;
5065 ELSE
5066 pdbs_para := trunc(db_cpus/2);
5067 END IF;
5068 ELSE -- if # of pdbs < (# of cpus/2)
5069 -- if we know there's more cpus/2 on this system than pdbs, then lets
5070 -- just size for a smaller # of pdbs upgrading in parallel (pdbs_para).
5071 -- e.g., cdb has 10 pdbs and # of cpus is 32, then size for pdbs_para=10.
5072 pdbs_para := db_npdbs;
5073 END IF;
5074
5075 -- for example, if upgrading 16 pdbs at a time,
5076 -- then if total # of pdbs is 32, it's 2 pdb cycles
5077 -- then if total # of pdbs is 33, it's 3 pdb cycles
5078 batches := ceil(db_npdbs/pdbs_para); -- estimated # of pdb upgrade cycles
5079
5080 -- java pool needed is 64M per pdb upgrading in a batch
5081 extra := 50 * c_mb;
5082 minvp(jv_idx).minvalue := (64 * pdbs_para) * c_mb + extra;
5083 extra := 0;
5084
5085 minvp(sp_idx).minvalue :=
5086 ( (264 * 3)
5087 + (264 * 2)
5088 + (pdbs_para * 200)
5089 + (db_npdbs * 20)
5090 + (batches * 35)
5091 ) * c_mb;
5092 -- constant in con id 1
5093 -- + constant/reserve in con id 0
5094 -- + reserve 200M of shared pool during pdb upgrade in pdb con id
5095 -- + up to 20m of misc in pdb con id that has been upgraded or opened
5096 -- + extra
5097
5098 -- pga_aggregate_target
5099 minvp(pt_idx).minvalue := 1152 * c_mb;
5100
5101 -- pga_aggregate_limit
5102 minvp(pl_idx).minvalue := 3072 * c_mb;
5103
5104 END IF; -- IF db is a cdb
5105
5106 minvp(st_idx).minvalue :=
5107 minvp(cs_idx).minvalue + minvp(jv_idx).minvalue +
5108 minvp(sp_idx).minvalue + minvp(lp_idx).minvalue +
5109 minvp(sr_idx).minvalue;
5110
5111 minvp(mt_idx).minvalue :=
5112 minvp(cs_idx).minvalue + minvp(jv_idx).minvalue +
5113 minvp(sp_idx).minvalue + minvp(lp_idx).minvalue +
5114 minvp(sr_idx).minvalue + minvp(pt_idx).minvalue;
5115
5116 END init_mem_sizes;
5117
5118 --------------------------- find_sga_mem_values ------------------------------
5119 -- This is called when sga_target or memory_target is used.
5120
5121 PROCEDURE find_sga_mem_values (minvp IN OUT MINVALUE_TABLE_T,
5122 dbbit NUMBER)
5123 IS
5124 extra NUMBER;
5125 mtgval NUMBER;
5126 BEGIN
5127
5128 -- We're here because sga_target/memory_target is used.
5129 -- Need to find new values for sga_target.
5130
5131 -- First, reset min values for pools/memory related to sga_target
5132
5133 -- buffer cache (cs)
5134 IF minvp(cs_idx).oldvalue > minvp(cs_idx).minvalue THEN
5135 minvp(cs_idx).diff := minvp(cs_idx).oldvalue - minvp(cs_idx).minvalue;
5136 END IF;
5137
5138 -- java pool (jv)
5139 IF minvp(jv_idx).oldvalue > minvp(jv_idx).minvalue THEN
5140 minvp(jv_idx).diff := minvp(jv_idx).oldvalue - minvp(jv_idx).minvalue;
5141 END IF;
5142
5143 -- shared pool (sp)
5144 IF minvp(sp_idx).oldvalue > minvp(sp_idx).minvalue THEN
5145 minvp(sp_idx).diff := minvp(sp_idx).oldvalue - minvp(sp_idx).minvalue;
5146 END IF;
5147
5148 -- large pool (lp)
5149 IF minvp(lp_idx).oldvalue > minvp(lp_idx).minvalue THEN
5150 minvp(lp_idx).diff := minvp(lp_idx).oldvalue - minvp(lp_idx).minvalue;
5151 END IF;
5152
5153 -- streams pool (sr)
5154 IF minvp(sr_idx).oldvalue > minvp(sr_idx).minvalue THEN
5155 minvp(sr_idx).diff :=
5156 minvp(sr_idx).oldvalue - minvp(sr_idx).minvalue;
5157 END IF;
5158
5159 -- pga_aggregate_target (pt)
5160 IF minvp(pt_idx).oldvalue > minvp(pt_idx).minvalue THEN
5161 minvp(pt_idx).diff :=
5162 minvp(pt_idx).oldvalue - minvp(pt_idx).minvalue;
5163 END IF;
5164
5165 -- calculate sga_target 'newvalue' (new derived minimum) based on
5166 -- st_idx.minvalue and user-specified pool sizes.
5167 -- need to add extra memory or db may not start in new release due to:
5168 -- ORA-00821: Specified value of sga_target <value> is too small,
5169 minvp(st_idx).newvalue :=
5170 minvp(st_idx).minvalue + minvp(cs_idx).diff
5171 + minvp(jv_idx).diff + minvp(sp_idx).diff
5172 + minvp(lp_idx).diff + minvp(sr_idx).diff
5173 + (128 * c_mb);
5174
5175 -- calculate memory_target 'newvalue' (new derived minimum) based on
5176 -- mt_idx.minvalue and user-specified pool sizes.
5177 -- need to add extra memory or db may not start in new release due to:
5178 -- ORA-00838: Specified value of MEMORY_TARGET is too small...
5179 minvp(mt_idx).newvalue :=
5180 minvp(mt_idx).minvalue + minvp(cs_idx).diff
5181 + minvp(jv_idx).diff + minvp(sp_idx).diff
5182 + minvp(lp_idx).diff + minvp(sr_idx).diff
5183 + minvp(pt_idx).diff + (256 * c_mb);
5184
5185 IF (minvp(st_idx).oldvalue != 0) THEN -- SGA_TARGET in use
5186 -- calculate 'newvalue' (new derived minimum) based on user-set sga_target
5187 -- and user-set pga_aggregate_target.
5188 -- for memory_target if sga_target is also set.
5189 -- add extra memory to ensure db will open in new release.
5190 mtgval := minvp(st_idx).oldvalue + minvp(pt_idx).oldvalue + 128*c_mb;
5191 -- set 'newvalue' to the larger of the two new derived minimums (see above)
5192 IF (mtgval > minvp(mt_idx).newvalue) THEN
5193 minvp(mt_idx).newvalue := mtgval;
5194 END IF;
5195 END IF;
5196
5197 -- Note: Although sga_target and memory_target values are found here, we
5198 -- don't set DISPLAY in minvp in this procedure. This setting is done
5199 -- in find_newval.
5200
5201 END find_sga_mem_values;
5202
5203 --------------------------- store_minvalue --------------------------------
5204 PROCEDURE store_minvalue (i BINARY_INTEGER,
5205 name VARCHAR2,
5206 minv NUMBER,
5207 minvp IN OUT MINVALUE_TABLE_T)
5208 IS
5209 BEGIN
5210 minvp(i).name := name;
5211 minvp(i).minvalue := minv;
5212 minvp(i).display := FALSE;
5213 minvp(i).diff := 0;
5214 END store_minvalue;
5215
5216 --------------------------- store_minval_dbbit -----------------------------
5217 PROCEDURE store_minval_dbbit (dbbit NUMBER,
5218 i IN OUT BINARY_INTEGER,
5219 name VARCHAR2,
5220 minv NUMBER)
5221 IS
5222 BEGIN
5223 i:= i+1;
5224 IF dbbit = 32 THEN -- set values for 32-bit
5225 store_minvalue(i, name, minv, minvp_db32);
5226 ELSIF dbbit = 64 THEN -- set values for 64-bit
5227 store_minvalue(i, name, minv, minvp_db64);
5228 ELSE -- if 0 (or anything but 32 and 64), then set values for both db bits
5229 store_minvalue(i, name, minv, minvp_db32);
5230 store_minvalue(i, name, minv, minvp_db64);
5231 END IF;
5232
5233 END store_minval_dbbit;
5234
5235 --------------------------- store_comp -----------------------------------
5236 PROCEDURE store_comp (i BINARY_INTEGER,
5237 schema VARCHAR2,
5238 version VARCHAR2,
5239 status NUMBER)
5240 IS
5241 BEGIN
5242 cmp_info(i).processed := TRUE;
5243 IF status = 0 THEN
5244 cmp_info(i).status := 'INVALID';
5245 ELSIF status = 1 THEN
5246 cmp_info(i).status := 'VALID';
5247 ELSIF status = 2 THEN
5248 cmp_info(i).status := 'LOADING';
5249 ELSIF status = 3 THEN
5250 cmp_info(i).status := 'LOADED';
5251 ELSIF status = 4 THEN
5252 cmp_info(i).status := 'UPGRADING';
5253 ELSIF status = 5 THEN
5254 cmp_info(i).status := 'UPGRADED';
5255 ELSIF status = 6 THEN
5256 cmp_info(i).status := 'DOWNGRADING';
5257 ELSIF status = 7 THEN
5258 cmp_info(i).status := 'DOWNGRADED';
5259 ELSIF status = 8 THEN
5260 cmp_info(i).status := 'REMOVING';
5261 ELSIF status = 9 THEN
5262 cmp_info(i).status := 'OPTION OFF';
5263 ELSIF status = 10 THEN
5264 cmp_info(i).status := 'NO SCRIPT';
5265 ELSIF status = 99 THEN
5266 cmp_info(i).status := 'REMOVED';
5267 ELSE
5268 cmp_info(i).status := NULL;
5269 END IF;
5270 cmp_info(i).version := version;
5271 cmp_info(i).schema := schema;
5272 EXECUTE IMMEDIATE
5273 'SELECT default_tablespace FROM sys.dba_users WHERE username =:1'
5274 INTO cmp_info(i).def_ts
5275 USING schema;
5276 EXCEPTION
5277 WHEN NO_DATA_FOUND THEN NULL;
5278 END store_comp;
5279
5280 -------------------------- is_comp_tablespace ------------------------------------
5281 -- returns TRUE if some existing component has the tablespace as a default
5282
5283 FUNCTION is_comp_tablespace (tsname VARCHAR2) RETURN BOOLEAN
5284 IS
5285 BEGIN
5286 FOR i IN 1..max_components LOOP
5287 IF cmp_info(i).processed AND
5288 tsname = cmp_info(i).def_ts THEN
5289 RETURN TRUE;
5290 END IF;
5291 END LOOP;
5292 RETURN FALSE;
5293 END is_comp_tablespace;
5294
5295 -------------------------- ts_has_queues ---------------------------------
5296 -- returns TRUE if there is at least one queue in the tablespace
5297 FUNCTION ts_has_queues (tsname VARCHAR2) RETURN BOOLEAN
5298 IS
5299 t_null CHAR(1);
5300 BEGIN
5301 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.dba_tables t
5302 WHERE EXISTS
5303 (SELECT 1 FROM sys.dba_queues q
5304 WHERE q.queue_table = t.table_name AND q.owner = t.owner)
5305 AND t.tablespace_name = :1 AND rownum <= 1'
5306 INTO t_null
5307 USING tsname;
5308 RETURN TRUE;
5309 EXCEPTION
5310 WHEN NO_DATA_FOUND THEN RETURN FALSE;
5311 END ts_has_queues;
5312
5313 -------------------------- ts_is_SYS_temporary ---------------------------------
5314 -- returns TRUE if there is at least one queue in the tablespace
5315
5316 FUNCTION ts_is_SYS_temporary (tsname VARCHAR2) RETURN BOOLEAN
5317 IS
5318 t_null CHAR(1);
5319 BEGIN
5320 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.dba_users
5321 WHERE username = ''SYS'' AND temporary_tablespace = :1'
5322 INTO t_null
5323 USING tsname;
5324 RETURN TRUE;
5325 EXCEPTION
5326 WHEN NO_DATA_FOUND THEN RETURN FALSE;
5327 END ts_is_SYS_temporary;
5328
5329 --
5330 -- Note: There could be a verify function on
5331 -- the params passed in, but for now, we assume the
5332 -- caller is passing something DBUA knows how to handle
5333 --
5334 FUNCTION genDBUAXMLCheck (
5335 name VARCHAR2,
5336 eseverity NUMBER,
5337 etext VARCHAR2,
5338 ecause VARCHAR2,
5339 action VARCHAR2,
5340 detailtype VARCHAR2,
5341 detailinfo VARCHAR2,
5342 fixuptype VARCHAR2,
5343 fixupstage VARCHAR2 ) RETURN VARCHAR2
5344 IS
5345 t_severity VARCHAR2(10);
5346
5347 -- name
5348 -- Text name that MUST BE KNOWN BY DBUA. They use it to key off of.
5349 --
5350 -- eseverity
5351 -- c_check_level_warning, _error, _info - tells the DBUA how to handle
5352 -- the condition.
5353 --
5354 -- etext
5355 -- Text of the error (if DBUA has a translated message, they will
5356 -- use that, otherwise, this will be displayed)
5357 --
5358 -- ecause
5359 -- Details of what causes this issue.
5360 --
5361 -- action
5362 -- Action to be taken to resolve the issue.
5363 --
5364 -- detailtype/info
5365 -- Detail is the details for the issue being reported. What check
5366 -- was run that caused this issue to be reported.
5367 --
5368 -- detailtype
5369 -- c_dbua_detail_type_text or _sql. If _text, the DBUA will display
5370 -- it when displaying information about this issue. If _sql, the
5371 -- DBUA will execute it, grab the output and display it. Make
5372 -- sure the SQL generates approporate output.
5373 --
5374 -- detailinfo
5375 -- If _text, a description of what the issue is, if _sql, then
5376 -- its the SQL command to execute to generate output that will be
5377 -- displayed by the DBUA.
5378 --
5379 -- fixuptype
5380 -- c_dbua_fixup_type_auto _manual
5381 -- _auto = there is a fixup function to solve the issue which
5382 -- can be executed to resolve the issue.
5383 -- _manual = There may still be a fixup function, but it must
5384 -- either confirmed, or executed manually (complex issue, or
5385 -- possible data manupulation).
5386 --
5387 -- fixupstage
5388 -- c_dbua_fixup_stage_pre, _post, _now
5389 -- _pre = Should be fixed before the upgrade is executed, usually
5390 -- right before the upgrade is started.
5391 -- _post = Should be fixed after the upgrade is executed
5392 -- _now = Can be solved right now, no need to wait until right
5393 -- before upgrade is executed.
5394 --
5395 BEGIN
5396 IF (eseverity = c_check_level_warning) THEN
5397 t_severity := c_check_level_warning_txt;
5398 ELSIF (eseverity = c_check_level_error) THEN
5399 t_severity := c_check_level_error_txt;
5400 ELSIF (eseverity = c_check_level_info) THEN
5401 t_severity := c_check_level_info_txt;
5402 ELSE
5403 t_severity := c_check_level_success_txt;
5404 END IF;
5405 return ('<PreUpgradeCheck ID="' || name ||
5406 '" Status="' || t_severity || '">' ||
5407 '<Message><Text>' || etext || '</Text>' ||
5408 '<Cause>' || ecause || '</Cause>' ||
5409 '<Action>' || action || '</Action>' ||
5410 '<Detail Type="' || detailtype || '">' ||
5411 detailinfo || '</Detail>' ||
5412 '</Message>' ||
5413 '<FixUp Type="' || fixuptype || '" FixAtStage="' || fixupstage || '"/>' ||
5414 '</PreUpgradeCheck>');
5415 END genDBUAXMLCheck;
5416
5417
5418 FUNCTION htmlentities (intxt varchar2) RETURN VARCHAR2
5419 --
5420 -- Replace chars which DBUA/XML will parse into
5421 -- their HTML equivalents
5422 --
5423 IS
5424 rstr VARCHAR2(4000);
5425 BEGIN
5426 --
5427 -- Because we can't depend on the env turing DEFINE off,
5428 -- use chr(38) for the ampersand character.
5429 --
5430 rstr := replace(intxt, chr(38), chr(38) || 'amp;');
5431 rstr := replace(rstr, '<', chr(38) || 'lt;');
5432 return replace(rstr, '>', chr(38) || 'gt;');
5433 -- dbua testing showed that the ' and " did not need
5434 -- replacing
5435 END htmlentities;
5436
5437 --
5438 -- Output a 'fixup' to the passed file.
5439 -- This is a call to the dbms_preup.run_fixup_and_report
5440 -- routine. That routine will run the fixup and report
5441 -- the problem.
5442 --
5443 PROCEDURE genFixup (name VARCHAR2 )
5444 IS
5445 idx NUMBER;
5446 rstr VARCHAR2(400);
5447 tlevel VARCHAR2(30);
5448 taction VARCHAR2(50);
5449 tfile UTL_FILE.FILE_TYPE;
5450
5451 BEGIN
5452 IF pCheckOnly THEN
5453 return;
5454 END IF;
5455
5456 idx := check_names(name).idx;
5457
5458 rstr := 'dbms_preup.run_fixup_and_report(''' || name || ''');';
5459
5460 IF check_table(idx).fix_type IN (c_fix_source_manual,
5461 c_fix_source_auto,
5462 c_fix_target_manual_pre,
5463 c_fix_target_auto_pre) THEN
5464 tfile := pPreScriptUFT;
5465 ELSE
5466 tfile := pPostScriptUFT;
5467 END IF;
5468
5469 If check_table(idx).fix_type IN (c_fix_source_manual,
5470 c_fix_target_manual_pre,
5471 c_fix_target_manual_post) THEN
5472 taction := pActionRequired;
5473 ELSE
5474 taction := 'Fixup routine';
5475 END IF;
5476
5477 IF check_table(idx).level = c_check_level_info THEN
5478 tlevel := 'Informational';
5479 ELSIF check_table(idx).level = c_check_level_warning THEN
5480 tlevel := 'Warning';
5481 ELSIF check_table(idx).level = c_check_level_error THEN
5482 tlevel := 'Error';
5483 ELSIF check_table(idx).level = c_check_level_recommend THEN
5484 tlevel := 'Recommendation';
5485 END IF;
5486
5487 DisplayLine (tfile, 'BEGIN');
5488 DisplayLine (tfile, '-- ***************** Fixup Details ***********************************');
5489 DisplayLine (tfile, '-- Name: ' || name);
5490 DisplayLine (tfile, '-- Description: ' || check_table(idx).descript);
5491 DisplayLine (tfile, '-- Severity: ' || tlevel);
5492 DisplayLine (tfile, '-- Action: ' || taction);
5493 DisplayLine (tfile, '-- Fix Summary: ');
5494 DisplayLine (tfile, '-- ' || GetHelp(name, c_help_fixup));
5495 DisplayLine (tfile, '');
5496 DisplayLine (tfile, rstr);
5497 DisplayLine (tfile, 'END;');
5498 DisplayBlankLine (tfile); -- we now move '/' to end of block with IF stmt
5499
5500 END genFixup;
5501
5502 -- **********************************************************************************
5503 -- Output routines for each phase of the preupgrade checks
5504 -- **********************************************************************************
5505 PROCEDURE output_summary
5506 IS
5507 t_varchar VARCHAR2(40);
5508 BEGIN
5509 init_package;
5510
5511 --
5512 -- header output to preupgrade.log, preupgrade.<con_name>.log, and upgrade.xml
5513 --
5514 dbms_output.put_line('');
5515 dbms_output.put_line('***************************************************************************');
5516 dbms_output.put_line ('Executing Pre-Upgrade Checks in ' || dbms_preup.get_con_name || '...');
5517 dbms_output.put_line('***************************************************************************');
5518 dbms_output.put_line('');
5519
5520
5521 IF pOutputType = c_output_xml
5522 THEN
5523 -- TODO: DBUA may need to know if this is a
5524 -- restart.
5525 --
5526 -- update info to be passed to dbua now that we support cdbs
5527 DisplayLine ('<RDBMSUP xmlns="http://www.oracle.com/Upgrade" version="'
5528 || c_version || '">');
5529 DisplayLine ('<SupportedOracleVersions value="' || c_supported_versions
5530 || '"/>');
5531 DisplayLine ('<OracleVersion value="' || db_version || '"/>');
5532 DisplayLine ('<Database Name="' || db_name
5533 || '" ContainerName="' || con_name
5534 || '" ContainerId="' || con_id
5535 || '" Version=" ' || db_version
5536 || '" Compatibility="' || db_compat || '"/>');
5537 IF pDBGFailAll THEN
5538 DisplayDiagLine (' ***** DEBUG MODE *****');
5539 END IF;
5540 ELSE
5541 IF pDBGFailAll THEN
5542 t_varchar := ' ***** DEBUG MODE *****';
5543 ELSE
5544 t_varchar := '';
5545 END IF;
5546 DisplayLine('Oracle Database Pre-Upgrade Information Tool ' || TO_CHAR(SYSDATE, 'MM-DD-YYYY HH24:MI:SS'));
5547 DisplayLine('Script Version: ' || c_version || c_patchset ||
5548 ' Build: ' || c_build || t_varchar);
5549 DisplayBanner;
5550 DisplayLine (' Database Name: ' || db_name );
5551 IF con_id = 0 and db_version < c_NA_ver THEN
5552 -- Container info is 'Not Applicable' for pre-12.1 databases
5553 DisplayLine (' Container Name: ' || c_NA_str);
5554 DisplayLine (' Container ID: ' || c_NA_str);
5555 ELSE
5556 DisplayLine (' Container Name: ' || con_name );
5557 DisplayLine (' Container ID: ' || con_id );
5558 END IF;
5559 DisplayLine (' Version: ' || db_version );
5560 DisplayLine (' Compatible: ' || db_compat );
5561 DisplayLine (' Blocksize: ' || db_block_size );
5562 DisplayLine (' Platform: ' || db_platform );
5563 DisplayLine (' Timezone file: V' || db_tz_version );
5564 DisplayLine ('Database log mode: ' || db_log_mode );
5565 IF is_db_readonly = TRUE THEN
5566 DisplayLine (' ReadOnly: TRUE');
5567 END IF;
5568 IF db_is_XE THEN
5569 DisplayLine (' Edition: ' || 'XE' );
5570 END IF;
5571 END IF;
5572 END output_summary;
5573
5574 PROCEDURE output_xml_initparams (minvp IN MINVALUE_TABLE_T)
5575 IS
5576 i NUMBER;
5577 BEGIN
5578 DisplayLine ('<Update>');
5579 FOR i IN 1..max_minvp LOOP
5580 IF minvp(i).display THEN
5581 IF NOT (i = jv_idx and NOT cmp_info(javavm).processed) THEN
5582 IF NOT (i = mt_idx and minvp(i).oldvalue IS NULL) THEN
5583 DisplayLine('<Parameter name="' ||
5584 minvp(i).name ||
5585 '" atleast="' || TO_CHAR(ROUND(minvp(i).newvalue)) ||
5586 '" atleast_32="' || TO_CHAR(ROUND(minvp_db32(i).newvalue)) ||
5587 '" atleast_64="' || TO_CHAR(ROUND(minvp_db64(i).newvalue)) ||
5588 '" type="NUMBER"/>');
5589 END IF;
5590 END IF;
5591 END IF;
5592 END LOOP;
5593
5594 IF db_compat_majorver < c_compat_min_num THEN
5595 --
5596 -- Display the minimum compatibility (manual mode has
5597 -- actual check)
5598 --
5599 DisplayLine (
5600 '<Parameter name="compatible" atleast="' || c_compat_min || '" type="VERSION"/>');
5601 END IF;
5602
5603 --
5604 -- Check the special list for any values that
5605 -- need to be updated and dumped out inside the <update> tags for the DBUA
5606 --
5607 FOR i IN 1..max_sp LOOP
5608 IF sp(i).dbua_OutInUpdate THEN
5609 IF sp(i).db_match = TRUE AND
5610 sp(i).newvalue IS NOT NULL THEN
5611 -- <parameter name="Audit_Trail" newValue="NONE"/>
5612 DisplayLine('<Parameter name="' || sp(i).oldname ||
5613 '" newValue="' || sp(i).newvalue || '" type="STRING"/>');
5614 ELSIF pDBGAllResources THEN
5615 DisplayLine('<Parameter name="' || sp(i).oldname ||
5616 '" newValue="' || sp(i).newvalue || '" type="STRING"/>');
5617 END IF;
5618 END IF;
5619 END LOOP;
5620 DisplayLine ('</Update>');
5621 END output_xml_initparams;
5622
5623 PROCEDURE output_manual_initparams (minvp IN MINVALUE_TABLE_T,
5624 bis64bit IN BOOLEAN)
5625 IS
5626 i NUMBER := 0;
5627 bChangesReq BOOLEAN := FALSE;
5628 bDisplayStartBanner BOOLEAN := FALSE;
5629 bDisplayEndBanner BOOLEAN := FALSE;
5630 bis32bit BOOLEAN := FALSE;
5631 cBit VARCHAR(8) := '64-bit, ';
5632
5633 BEGIN
5634
5635 --
5636 -- Initialize
5637 --
5638 bDisplayStartBanner := TRUE;
5639 bDisplayEndBanner := TRUE;
5640
5641
5642 --
5643 -- Display Section Banner only Once
5644 --
5645 IF bDisplayStartBanner THEN
5646 DisplayBanner;
5647 DisplayCenter('[Update parameters]');
5648 END IF;
5649
5650 --
5651 -- Display the parameters
5652 --
5653 bChangesReq := FALSE;
5654 FOR i IN 1..max_minvp LOOP
5655 IF minvp(i).display THEN
5656 IF NOT (i = jv_idx and NOT cmp_info(javavm).processed) THEN
5657 IF NOT (i = mt_idx and minvp(i).oldvalue IS NULL) THEN
5658 IF NOT (bChangesReq) THEN
5659 IF bDisplayStartBanner THEN
5660 DisplayCenter('[Update Oracle Database ' || db_version ||
5661 ' init.ora or spfile]');
5662 DisplayLine('[The minimum memory/pool size recommendations are for the upgrade process');
5663 DisplayLine(' only. After the upgrade, these values can be reverted or adjusted as');
5664 DisplayLine(' applicable for the target release and production work.]');
5665 END IF;
5666 DisplayLine(' ');
5667 -- DisplayLine('--> If Target Oracle is ' || cBit ||
5668 -- 'refer here for Update Parameters:');
5669 END IF;
5670 bChangesReq := TRUE;
5671 DisplayLine('WARNING: --> "' || minvp(i).name ||
5672 '" needs to be increased to at least ' ||
5673 TO_CHAR(ROUND(minvp(i).newvalue)));
5674 END IF;
5675 END IF;
5676 END IF;
5677 END LOOP;
5678
5679 --
5680 -- Display End Banner Info
5681 --
5682 IF bDisplayEndBanner THEN
5683 IF NOT bChangesReq THEN
5684 DisplayCenter('[No parameters to update]');
5685 END IF;
5686 DisplayBanner;
5687 END IF;
5688
5689 END output_manual_initparams;
5690
5691 PROCEDURE output_initparams
5692 IS
5693 changes_req BOOLEAN;
5694 def_or_obs VARCHAR2(15);
5695 result_txt VARCHAR2(200);
5696 tmp_str VARCHAR2(80);
5697 deprecated_str VARCHAR2(5);
5698 minvp MINVALUE_TABLE_T;
5699 BEGIN
5700 init_package;
5701
5702
5703 IF db_64bit THEN
5704 minvp := minvp_db64;
5705 ELSE
5706 minvp := minvp_db32;
5707 END IF;
5708
5709 IF db_invalid_state = TRUE THEN
5710 IF pOutputType = c_output_xml THEN
5711 --
5712 -- Although the DBUA will ensure the db is
5713 -- opended correctly, leave this error output
5714 --
5715 result_txt:= genDBUAXMLCheck('DATABASE_NOT_OPEN',
5716 c_check_level_error,
5717 'Database must be in "OPEN" state.',
5718 'Database is not in OPEN state',
5719 'SELECT status from V$INSTANCE',
5720 c_dbua_detail_type_text,
5721 'Close the database and reopen it using OPEN as the state',
5722 c_dbua_fixup_type_manual,
5723 c_dbua_fixup_stage_pre );
5724 ELSE
5725 DisplayLine ('Database not in OPEN state.');
5726 DisplayLine (' Database must be in OPEN state for script to execute correctly.');
5727 END IF;
5728 return;
5729 END IF;
5730
5731 IF (pOutputType = c_output_xml)
5732 THEN
5733 DisplayLine ('<InitParams>');
5734
5735 output_xml_initparams(minvp);
5736
5737 -- Migration tag was here
5738
5739 DisplayLine ('<NonHandled>');
5740 -- DisplayLine ('<Parameter name="remote_listener"/>');
5741 DisplayLine ('</NonHandled>');
5742
5743 DisplayLine ('<Rename>');
5744 FOR i IN 1..max_rp LOOP
5745 IF rp(i).db_match = TRUE THEN
5746 DisplayLine(
5747 '<Parameter name="' || rp(i).oldname ||
5748 '" newName="' || rp(i).newname || '"/>');
5749 ELSIF pDBGAllResources THEN
5750 DisplayLine(
5751 '<Parameter name="' || rp(i).oldname ||
5752 '" newName="' || rp(i).newname || '"/>');
5753 END IF;
5754 END LOOP;
5755
5756 -- Display parameters that have a new name and a new value
5757 FOR i IN 1..max_sp LOOP
5758 IF sp(i).db_match = TRUE AND
5759 sp(i).newvalue IS NOT NULL AND
5760 sp(i).dbua_OutInUpdate = FALSE THEN
5761 DisplayLine('<Parameter name="' || sp(i).oldname ||
5762 '" newName="' || sp(i).newname ||
5763 '" newValue="' || sp(i).newvalue || '"/>');
5764 ELSIF pDBGAllResources THEN
5765 IF sp(i).dbua_OutInUpdate = FALSE THEN
5766 DisplayLine('<Parameter name="' || sp(i).oldname ||
5767 '" newName="' || sp(i).newname ||
5768 '" newValue="' || sp(i).newvalue || '"/>');
5769 END IF;
5770 END IF;
5771 END LOOP;
5772 DisplayLine ('</Rename>');
5773
5774 DisplayLine('<Remove>');
5775 FOR i IN 1..max_op LOOP
5776 IF op(i).deprecated = TRUE THEN
5777 deprecated_str := 'TRUE';
5778 ELSE
5779 deprecated_str := 'FALSE';
5780 END IF;
5781 IF op(i).db_match = TRUE THEN
5782 DisplayLine('<Parameter name="' ||
5783 op(i).name || '" deprecated="' || deprecated_str || '"/>');
5784 ELSIF pDBGAllResources THEN
5785 DisplayLine('<Parameter name="' ||
5786 op(i).name || '" deprecated="' || deprecated_str || '"/>');
5787 END IF;
5788 END LOOP;
5789 DisplayLine('</Remove>');
5790 DisplayLine ('</InitParams>');
5791 ELSE
5792
5793 --
5794 -- 12c database only supports 64 bit so no need to display the 32 bit
5795 -- values for manual upgrades.
5796 -- output_manual_initparams(minvp_db32, FALSE);
5797
5798 -- do not display [Update parameters] if the db is a pdb
5799 IF (dbms_preup.is_db_noncdb OR dbms_preup.is_con_root) THEN
5800 output_manual_initparams(minvp_db64, TRUE);
5801 -- the parameters currenly under this section are for memory and
5802 -- processes. all of the parameters in this section - in 12.1.0.1
5803 -- anyway - are still cdb level parameters
5804 END IF;
5805
5806 --
5807 -- Text output
5808 --
5809 --
5810 -- compat check is done as an actual check
5811 -- since it can stop the DB from starting up
5812 --
5813 DisplayBanner;
5814 DisplayCenter('[Renamed Parameters]');
5815 changes_req := FALSE;
5816
5817 FOR i IN 1..max_rp LOOP
5818 IF rp(i).db_match = TRUE THEN
5819 changes_req := TRUE;
5820 DisplayWarning('"' || rp(i).oldname ||
5821 '" new name is "' || rp(i).newname || '"');
5822 ELSIF pDBGAllResources THEN
5823 DisplayWarning('"' || rp(i).oldname ||
5824 '" new name is "' || rp(i).newname || '"');
5825 END IF;
5826 END LOOP;
5827
5828 -- Display parameters that have a new name and a new value
5829
5830 FOR i IN 1..max_sp LOOP
5831 IF sp(i).db_match = TRUE AND
5832 sp(i).newvalue IS NOT NULL
5833 THEN
5834 changes_req := TRUE;
5835 IF sp(i).oldvalue IS NULL
5836 THEN
5837 DisplayWarning('"' || sp(i).oldname ||
5838 '" new name is "' || sp(i).newname ||
5839 '" new value is "' || sp(i).newvalue || '"');
5840 ELSE
5841 DisplayLine('"' || sp(i).oldname ||
5842 '" old value was "' || sp(i).oldvalue || '";');
5843 DisplayLine(' --> new name is "' ||
5844 sp(i).newname || '", new value is "' || sp(i).newvalue || '"');
5845 END IF;
5846 ELSIF pDBGAllResources THEN
5847 IF sp(i).newvalue IS NULL THEN
5848 tmp_str := 'NULL';
5849 ELSE
5850 tmp_str := sp(i).newvalue;
5851 END IF;
5852 IF sp(i).oldvalue IS NULL THEN
5853 DisplayWarning('"' || sp(i).oldname ||
5854 '" new name is "' || sp(i).newname ||
5855 '" new value is "' || tmp_str || '"');
5856 ELSE
5857 DisplayLine('"' || sp(i).oldname ||
5858 '" old value was "' || sp(i).oldvalue || '";');
5859 DisplayLine(' --> new name is "' ||
5860 sp(i).newname || '", new value is "' || tmp_str || '"');
5861 END IF;
5862 END IF;
5863 END LOOP;
5864
5865 IF changes_req THEN
5866 DisplayLine('');
5867 DisplayCenter ('[Changes required in Oracle Database init.ora or spfile]');
5868 DisplayLine('');
5869 ELSE
5870 DisplayCenter('[No Renamed Parameters in use]');
5871 END IF;
5872 DisplayBanner;
5873
5874 changes_req := FALSE;
5875 DisplayBanner;
5876 DisplayCenter ('[Obsolete/Deprecated Parameters]');
5877
5878 FOR i IN 1..max_op LOOP
5879 IF op(i).deprecated = TRUE
5880 THEN
5881 def_or_obs := 'DESUPPORTED';
5882 ELSE
5883 def_or_obs := 'OBSOLETE';
5884 END IF;
5885
5886 IF op(i).db_match = TRUE THEN
5887 changes_req := TRUE;
5888
5889 IF op(i).name NOT IN ('background_dump_dest','user_dump_dest')
5890 THEN
5891 DisplayLine(
5892 '--> ' || rpad(op(i).name, 28) || ' ' ||
5893 rpad(op(i).version, 10) || ' ' ||
5894 rpad(def_or_obs, 12));
5895 ELSE
5896 -- bdump, udump deprecated by diagnostic_dest
5897 -- If core_dump_dest gets back onto this list, it goes here (and above)
5898 DisplayLine (
5899 '--> ' || rpad(op(i).name, 28) || ' ' ||
5900 rpad(op(i).version, 10) || ' ' ||
5901 rpad(def_or_obs, 12) ||
5902 ' replaced by "diagnostic_dest"');
5903 END IF;
5904 ELSIF pDBGAllResources THEN
5905 DisplayLine(
5906 '--> ' || rpad(op(i).name, 28) || ' ' ||
5907 rpad(op(i).version, 10) || ' ' ||
5908 rpad(def_or_obs, 12));
5909 END IF;
5910 END LOOP;
5911
5912 IF changes_req THEN
5913 DisplayLine('');
5914 DisplayCenter('[Changes required in Oracle Database init.ora or spfile]');
5915 DisplayLine('');
5916 ELSE
5917 DisplayCenter ('[No Obsolete or Desupported Parameters in use]');
5918 END IF;
5919 END IF; -- check for terminal output
5920 END output_initparams;
5921
5922 PROCEDURE output_components
5923 IS
5924 post_list_info VARCHAR2(300) := '';
5925 tmp_varchar VARCHAR2(30);
5926 ui VARCHAR2(10);
5927
5928 BEGIN
5929 init_package;
5930
5931 IF db_invalid_state = TRUE THEN
5932 return;
5933 END IF;
5934
5935 IF pOutputType = c_output_xml
5936 THEN
5937 IF (cmp_info(catalog).status = 'VALID' AND cmp_info(catproc).status = 'VALID') THEN
5938 tmp_varchar := cmp_info(catalog).status;
5939 ELSE
5940 tmp_varchar := 'INVALID';
5941 END IF;
5942 DisplayLine ('<Components>');
5943 --
5944 -- For Server status, use Catalog status (catalog and catproc are
5945 -- skipped in the below loop)
5946 --
5947 DisplayLine ('<Component id ="Oracle Server" type="SERVER" cid="RDBMS" version="'
5948 || db_version || '" status="' || tmp_varchar || '"/>');
5949 --
5950 -- Note:
5951 -- 1,2 are catalog and catproc which are skipped
5952 --
5953 FOR i IN 3 .. max_components LOOP
5954 IF cmp_info(i).processed and NOT (cmp_info(i).cid = 'WK') THEN
5955 IF (cmp_info(i).status = NULL) THEN
5956 -- If we get a NULL value, don't dump out the status
5957 tmp_varchar := '';
5958 ELSE
5959 -- Create the status= entry
5960 tmp_varchar := ' status="' || cmp_info(i).status || '"';
5961 END IF;
5962 DisplayLine ('<Component id="' || cmp_info(i).cname ||
5963 '" cid="' || cmp_info(i).cid ||
5964 '" script="' || cmp_info(i).script ||
5965 '" version="' || cmp_info(i).version ||
5966 '"' || tmp_varchar || '/>');
5967 END IF;
5968 END LOOP;
5969 DisplayLine('</Components>');
5970 ELSE
5971 DisplayBanner;
5972 DisplayCenter ('[Component List]');
5973 DisplayBanner;
5974
5975 FOR i IN 1..max_components LOOP
5976 IF cmp_info(i).processed THEN
5977 IF cmp_info(i).install THEN ui := '[install]';
5978 ELSE ui := '[upgrade]';
5979 END IF;
5980 DisplayLine(
5981 '--> ' || rpad(cmp_info(i).cname, 38) || ' ' ||
5982 rpad(ui, 10) || ' ' ||
5983 rpad(cmp_info(i).status, 10));
5984 IF ((cmp_info(i).cid = 'OLS') AND
5985 NOT cmp_info(dv).processed) THEN
5986 post_list_info := post_list_info || crlf
5987 || 'To successfully upgrade Oracle Label Security, choose ' || crlf
5988 || '''Select Options'' in Oracle installer and then select ' || crlf
5989 || 'Oracle Label Security.';
5990 END IF;
5991 END IF;
5992 END LOOP;
5993 IF (length(post_list_info) != 0) THEN
5994 DisplayLine (post_list_info);
5995 END IF;
5996 END IF;
5997 END output_components;
5998
5999 PROCEDURE output_resources
6000 --
6001 -- This calls all the resource routines
6002 --
6003 IS
6004 BEGIN
6005 init_package;
6006
6007 --
6008 -- Make sure resources are set before so
6009 -- everything is re-calculated.
6010 --
6011 init_resources;
6012
6013 IF db_invalid_state = TRUE THEN
6014 RETURN;
6015 END IF;
6016 output_tablespaces;
6017 output_rollback_segs;
6018 output_flashback;
6019 END output_resources;
6020
6021 PROCEDURE output_tablespaces
6022 IS
6023 resourcenum NUMBER (38);
6024 changes_req BOOLEAN := FALSE;
6025 BEGIN
6026 IF pOutputType = c_output_xml
6027 THEN
6028 DisplayLine('<SystemResource>');
6029
6030 FOR i IN 1..max_ts LOOP
6031 DisplayLine (
6032 '<Tablespace name="' || ts_info(i).name ||
6033 '" additional_size="' ||
6034 TO_CHAR(ROUND(ts_info(i).addl)) || '"/>');
6035
6036 IF pDBGSizeResources THEN
6037 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6038 ' used = ' || LPAD(ts_info(i).inuse,10));
6039 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6040 ' delta= ' || LPAD(ts_info(i).delta,10));
6041 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6042 ' total req= ' || LPAD(ts_info(i).min,10));
6043 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6044 ' alloc= ' || LPAD(ts_info(i).alloc,10));
6045 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6046 ' auto_avail= ' || LPAD(ts_info(i).auto,10));
6047 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6048 ' total avail= ' || LPAD(ts_info(i).avail,10));
6049 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6050 ' additional space needed = ' || LPAD(ts_info(i).addl,10));
6051 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6052 ' increment by = ' || LPAD(ts_info(i).inc_by,10));
6053 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6054 ' total avail= ' || LPAD(ts_info(i).avail,10));
6055 END IF;
6056 END LOOP;
6057 --
6058 -- ArchiveLogs and Flashback info
6059 --
6060 -- bug 18038240:
6061 -- note: pMinArchiveLogGen and pMinFlashbackLogGen are in Kb
6062 -- note: DBUA expects these sizes to be in Mb (not Kb)
6063 -- note: so if we divide these variables by c_kb, then they will be in Mb
6064 --
6065 IF db_log_mode = 'ARCHIVELOG' OR pDBGSizeResources THEN
6066 resourcenum := pMinArchiveLogGen / c_kb;
6067 ELSE
6068 resourcenum := 0;
6069 END IF;
6070 DisplayLine (
6071 '<ArchiveLogs name="ArchiveLogs" additional_size="' ||
6072 resourcenum || '" />');
6073
6074 IF db_flashback_on OR pDBGSizeResources THEN
6075 resourcenum := pMinFlashbackLogGen / c_kb;
6076 ELSE
6077 resourcenum := 0;
6078 END IF;
6079 DisplayLine (
6080 '<FlashbackLogs name="FlasbackLogs" additional_size="' ||
6081 resourcenum || '" />');
6082
6083 DisplayLine('</SystemResource>');
6084 ELSE
6085 DisplayBanner;
6086 IF pUnsupportedUpgrade THEN
6087 DisplayCenter('[ Unsupported Upgrade: Tablespace Data Suppressed ]');
6088 ELSE
6089 DisplayCenter('[Tablespaces]');
6090 END IF;
6091 DisplayBanner;
6092
6093 IF max_ts > 0 and pUnsupportedUpgrade = FALSE THEN
6094 FOR i IN 1..max_ts LOOP
6095 --
6096 -- For debugging, dump out the allocated and used info
6097 --
6098 IF pDBGSizeResources THEN
6099 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6100 ' used = ' || LPAD(ts_info(i).inuse,10));
6101 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6102 ' delta= ' || LPAD(ts_info(i).delta,10));
6103 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6104 ' total req= ' || LPAD(ts_info(i).min,10));
6105 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6106 ' alloc= ' || LPAD(ts_info(i).alloc,10));
6107 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6108 ' auto_avail= ' || LPAD(ts_info(i).auto,10));
6109 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6110 ' total avail= ' || LPAD(ts_info(i).avail,10));
6111 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6112 ' additional space needed = ' || LPAD(ts_info(i).addl,10));
6113 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6114 ' increment by = ' || LPAD(ts_info(i).inc_by,10));
6115 DisplayDiagLine(RPAD(ts_info(i).name,10) ||
6116 ' total avail= ' || LPAD(ts_info(i).avail,10));
6117 END IF;
6118
6119 IF ts_info(i).inc_by = 0 THEN
6120 DisplayLine(
6121 '--> ' || ts_info(i).name ||
6122 ' tablespace is adequate for the upgrade.');
6123 DisplayLine(
6124 ' minimum required size: ' ||
6125 TO_CHAR(ROUND(ts_info(i).min)) || ' MB');
6126 ELSE
6127 --
6128 -- need more space in tablespace
6129 --
6130 changes_req := TRUE;
6131 DisplayError(ts_info(i).name ||
6132 ' tablespace is not large enough for the upgrade.');
6133 DisplayLine(
6134 ' currently allocated size: ' ||
6135 TO_CHAR(ROUND(ts_info(i).alloc)) || ' MB');
6136 DisplayLine(
6137 ' minimum required size: ' ||
6138 TO_CHAR(ROUND(ts_info(i).min)) || ' MB');
6139 DisplayLine(
6140 ' increase current size by: ' ||
6141 TO_CHAR(ROUND(ts_info(i).inc_by)) || ' MB');
6142
6143 IF ts_info(i).fauto THEN
6144 DisplayLine(
6145 ' tablespace is AUTOEXTEND ENABLED.');
6146 ELSE
6147 DisplayLine(
6148 ' tablespace is NOT AUTOEXTEND ENABLED.');
6149 END IF;
6150 END IF;
6151 END LOOP;
6152 END IF;
6153
6154 IF pUnsupportedUpgrade = FALSE THEN
6155 DisplayLine('');
6156 IF changes_req THEN
6157 DisplayCenter('[make adjustments in the current environment]');
6158 ELSE
6159 DisplayCenter('[No adjustments recommended]');
6160 END IF;
6161 DisplayLine('');
6162 DisplayBanner;
6163 END IF;
6164 END IF; -- output type text
6165 END output_tablespaces;
6166
6167 PROCEDURE output_rollback_segs
6168 IS
6169 auto VARCHAR2(3);
6170 BEGIN
6171 IF pOutputType = c_output_xml THEN
6172 RETURN;
6173 END IF;
6174
6175 IF max_rs > 0 THEN
6176 DisplayBanner;
6177 DisplayLine('Rollback Segments: [make adjustments ' ||
6178 'immediately prior to upgrading]');
6179 DisplayBanner;
6180 -- Loop through the rs_info table
6181 FOR i IN 1..max_rs LOOP
6182 IF rs_info(i).auto > 0 THEN
6183 auto:='ON';
6184 ELSE
6185 auto:='OFF';
6186 END IF;
6187 DisplayLine(
6188 '--> ' || rs_info(i).seg_name || ' in tablespace ' ||
6189 rs_info(i).tbs_name || ' is ' ||
6190 rs_info(i).status ||
6191 '; AUTOEXTEND is ' || auto);
6192 DisplayLine(
6193 ' currently allocated: ' || rs_info(i).inuse
6194 || 'K');
6195 DisplayLine(
6196 ' next extent size: ' || rs_info(i).next
6197 || 'K; max extents: ' || rs_info(i).max_ext);
6198 END LOOP;
6199 DisplayWarning('For the upgrade, use a large (minimum 70M) ' ||
6200 'public rollback segment');
6201 IF max_rs > 1 THEN
6202 DisplayWarning('Take smaller public rollback segments OFFLINE');
6203 END IF;
6204 DisplayLine ('');
6205 END IF;
6206 END output_rollback_segs;
6207
6208 PROCEDURE output_flashback
6209 IS
6210 min_fra_size number; -- minimum flashback recovery area size suggested
6211 -- for the upgrade
6212 BEGIN
6213
6214 IF pDBGSizeResources THEN
6215 FOR i in 1..max_comps LOOP
6216 IF cmp_info(i).processed THEN
6217 DisplayDiagLine ('Archivelog: ' || rpad(cmp_info(i).cid,10) || ' ' ||
6218 lpad(cmp_info(i).archivelog_kbytes,10));
6219 DisplayDiagLine ('Flashbacklog: ' || rpad(cmp_info(i).cid,10) || ' ' ||
6220 lpad(cmp_info(i).flashbacklog_kbytes,10));
6221 END IF;
6222 END LOOP;
6223 END IF;
6224
6225 IF pOutputType = c_output_xml THEN
6226 RETURN;
6227 END IF;
6228
6229 IF flashback_info.active OR pDBGAllResources THEN
6230
6231 -- calculate min_fra_size or minimum flashback recovery area size (in Mb)
6232 -- note: pMinArchiveLogGen and pMinFlashbackLogGen are in Kb
6233 -- note: the sum of the 2 variables above is saved into min_fra_size
6234 -- note: so if we divide min_fra_size by c_kb, then min_fra_size is in Mb
6235 min_fra_size :=
6236 ROUND( (pMinArchiveLogGen + pMinFlashbackLogGen) / c_kb );
6237
6238 DisplayBanner;
6239 IF pUnsupportedUpgrade THEN
6240 DisplayCenter('[ Unsupported Upgrade: Flashback Data Suppressed ]');
6241 ELSE
6242 DisplayCenter('[Flashback Information]');
6243 END IF;
6244 DisplayBanner;
6245 DisplayLine ('--> name: ' || flashback_info.name );
6246 DisplayLine ('--> limit: ' || TO_CHAR( (flashback_info.limit / c_mb)) || ' MB');
6247 DisplayLine ('--> used: ' || TO_CHAR( round((flashback_info.used / c_mb ),0)) || ' MB');
6248 DisplayLine ('--> size: ' || TO_CHAR( (flashback_info.dsize / c_mb )) || ' MB');
6249 DisplayLine ('--> reclaim: ' || TO_CHAR( (flashback_info.reclaimable / c_mb)) || ' MB');
6250 DisplayLine ('--> files: ' || TO_CHAR(flashback_info.files));
6251 DisplayLine ('');
6252
6253 IF (flashback_info.used/c_mb + min_fra_size >= flashback_info.dsize / c_mb) THEN
6254 pCheckWarningCount := pCheckWarningCount + 1;
6255 DisplayError ('Flashback Database is enabled and the flash recovery area is estimated');
6256 DisplayLine (' not to be large enough for an upgrade.');
6257 DisplayLine (' Ensure adequate disk space exists in the flash recovery area');
6258 DisplayLine (' before performing the upgrade.');
6259 ELSE
6260 pCheckInfoCount := pCheckInfoCount + 1;
6261 DisplayInformation ('Flashback Database is enabled. At present, the flash recovery area');
6262 DisplayLine (' is large enough to handle the bare minimum estimated for the upgrade.');
6263 DisplayLine (' Ensure adequate disk space exists in the flash recovery area');
6264 DisplayLine (' just before performing the upgrade.');
6265 END IF;
6266
6267 -- bug 17545700: display the minimum FRA size ONLY if size is
6268 -- more than 0Mb
6269 IF (min_fra_size > 0) THEN
6270 DisplayLine ('');
6271 DisplayLine (' It is recommended that the recovery area have '
6272 || 'at least ' || TO_CHAR(min_fra_size)
6273 || ' MB -');
6274 DisplayLIne (' or greater - of free space.');
6275 END IF;
6276
6277 DisplayBanner;
6278 END IF;
6279 END output_flashback;
6280
6281 PROCEDURE output_recommendations
6282 --
6283 -- Output both the pre and post recommendations
6284 --
6285 IS
6286 BEGIN
6287 init_package;
6288
6289 IF db_invalid_state = TRUE OR pOutputType = c_output_xml THEN
6290 RETURN;
6291 END IF;
6292 DisplayLine(pPreScriptUFT, 'BEGIN');
6293 DisplayLineBoth(pPreScriptUFT, '');
6294 DisplayBanner(pPreScriptUFT);
6295 DisplayCenter(pPreScriptUFT, '[Pre-Upgrade Recommendations]');
6296 DisplayBanner(pPreScriptUFT);
6297 DisplayLineBoth(pPreScriptUFT, '');
6298 DisplayLine(pPreScriptUFT, 'END;');
6299 DisplayBlankLine(pPreScriptUFT);
6300
6301 --
6302 -- Dump the pre recommendations
6303 --
6304 run_all_recommend (c_type_recommend_pre);
6305
6306 DisplayLine(pPostScriptUFT, 'BEGIN');
6307 DisplayLineBoth(pPostScriptUFT, '');
6308 DisplayBanner(pPostScriptUFT);
6309 DisplayCenter(pPostScriptUFT, '[Post-Upgrade Recommendations]');
6310 DisplayBanner(pPostScriptUFT);
6311 DisplayLineBoth(pPostScriptUFT, '');
6312 DisplayLine(pPostScriptUFT, 'END;');
6313 DisplayBlankLine(pPostScriptUFT);
6314
6315 --
6316 -- Dump the post recommendations
6317 --
6318 run_all_recommend (c_type_recommend_post);
6319 DisplayBanner;
6320 END output_recommendations;
6321
6322 --
6323 -- A quick summary of the checks - this is the last thing
6324 -- seen in the log file.
6325 --
6326 -- The thought is, this may be the last thing seen so
6327 -- if there are things we REALLY need them to know, it should
6328 -- be output here.
6329 --
6330 -- This is ONLY for TEXT output.
6331 --
6332 PROCEDURE output_prolog
6333 IS
6334 toutput VARCHAR2(4000);
6335 tstr VARCHAR2(30);
6336 BEGIN
6337 init_package;
6338
6339 IF pOutputType = c_output_text THEN
6340 --
6341 -- Only output for non XML display
6342 --
6343 DisplayLine (CenterLine('************ Summary ************'));
6344 DisplayLine ('');
6345
6346 tstr := ' ERRORS';
6347 toutput := ' exist that must be addressed prior to performing your upgrade.';
6348 IF (pCheckErrorCount = 1) THEN
6349 tstr := ' ERROR';
6350 ELSIF pCheckErrorCount = 0 THEN
6351 toutput := ' exist in your database.';
6352 END IF;
6353 DisplayLine (LPAD(pCheckErrorCount,2) || tstr || toutput);
6354
6355 tstr := ' WARNINGS';
6356 toutput := ' that Oracle suggests are addressed to improve database performance.';
6357 IF (pCheckWarningCount = 1) THEN
6358 tstr := ' WARNING';
6359 ELSIF pCheckWarningCount = 0 THEN
6360 toutput := ' exist in your database.';
6361 END IF;
6362 DisplayLine (LPAD(pCheckWarningCount,2) || tstr || toutput);
6363
6364 tstr := ' INFORMATIONAL messages';
6365 toutput := ' that should be reviewed prior to your upgrade.';
6366 If pCheckInfoCount = 1 THEN
6367 tstr := ' INFORMATIONAL message';
6368 ELSIF (pCheckInfoCount = 0) THEN
6369 toutput := ' messages have been reported.';
6370 END IF;
6371 DisplayLine (LPAD(pCheckInfoCount,2) || tstr || toutput);
6372
6373 toutput :=
6374 crlf || ' After your database is upgraded and open in normal mode you must run '
6375 || crlf || ' rdbms/admin/catuppst.sql which executes several required tasks and completes'
6376 || crlf || ' the upgrade process.'
6377 || crlf || crlf ||
6378 ' You should follow that with the execution of rdbms/admin/utlrp.sql, and a'
6379 || crlf || ' comparison of invalid objects before and after the upgrade using'
6380 || crlf || ' rdbms/admin/utluiobj.sql'
6381 || crlf || crlf ||
6382 ' If needed you may want to upgrade your timezone data using the process'
6383 || crlf || ' described in My Oracle Support note 1509653.1'
6384 || crlf || CenterLine('***********************************');
6385 DisplayLine(toutput);
6386 END IF;
6387 END output_prolog;
6388
6389 PROCEDURE output_preup_checks
6390 IS
6391 BEGIN
6392 IF db_invalid_state = TRUE THEN
6393 return;
6394 END IF;
6395
6396 IF pOutputType = c_output_xml THEN
6397 DisplayLine ('<PreUpgradeChecks>');
6398 ELSE
6399 DisplayBanner;
6400 DisplayCenter('[Pre-Upgrade Checks]');
6401 DisplayBanner;
6402 END IF;
6403
6404 FOR i IN 1..pCheckCount LOOP
6405 --
6406 -- Dump out the results of the Normal checks only
6407 -- if they failed (and if there is something to display)
6408 --
6409 IF (check_table(i).passed = FALSE AND
6410 ( check_table(i).type = c_type_check OR
6411 check_table(i).type = c_type_check_interactive_only)) THEN
6412 DisplayLine (check_table(i).result_text);
6413 DisplayLine ('');
6414 END IF;
6415 END LOOP;
6416
6417 IF pOutputType = c_output_xml THEN
6418 DisplayLine ('</PreUpgradeChecks>');
6419 DisplayLine ('</RDBMSUP>');
6420 IF pOutputFixupScripts THEN
6421 DisplayLinePL (CenterLine('[Pre and Post Upgrade Fixup Scripts Have been Generated]'));
6422 DisplayLinePL (CenterLine('[Location: ' || get_output_path || ' ]'));
6423 END IF;
6424 END IF;
6425
6426 END output_preup_checks;
6427
6428 --
6429 -- Dump out a summary of the checks that were run
6430 -- and also if there are any errors that require user
6431 -- action.
6432 --
6433 -- This output to TO THE TEMRINAL no matter what.
6434 --
6435 PROCEDURE output_check_summary
6436 IS
6437 path VARCHAR2(500);
6438 tsuccess NUMBER := 0;
6439 tfailed NUMBER := 0;
6440 terrors NUMBER := 0;
6441 ttotal NUMBER := 0;
6442
6443 BEGIN
6444 IF db_invalid_state = TRUE THEN
6445 RETURN;
6446 END IF;
6447
6448 init_package;
6449 IF pOutputType = c_output_text THEN
6450 FOR i IN 1..pCheckCount LOOP
6451 IF (check_table(i).executed) THEN
6452 IF check_table(i).passed THEN
6453 tsuccess := tsuccess +1;
6454 ELSE
6455 tfailed := tfailed +1;
6456 END IF;
6457 IF check_table(i).level = c_check_level_error THEN
6458 terrors := terrors + 1;
6459 END IF;
6460 END IF;
6461 END LOOP;
6462
6463 path := get_output_path;
6464
6465 IF terrors != 0 THEN
6466 DisplayLinePL('');
6467 DisplayLinePL(CenterLine('************************************************************'));
6468 DisplayLinePL('');
6469 DisplayLinePL(CenterLine('====>> ERRORS FOUND for ' || con_name || ' <<===='));
6470 DisplayLinePL('');
6471 --
6472 -- Centerline cuts off long lines so if you are changing this line,
6473 -- be careful of its lenght.
6474 --
6475 DisplayLinePL(CenterLine('The following are *** ERROR LEVEL CONDITIONS *** that must be addressed'));
6476 DisplayLinePl(CenterLine('prior to attempting your upgrade.'));
6477 DisplayLinePL(CenterLine('Failure to do so will result in a failed upgrade.'));
6478 DisplayLinePL('');
6479
6480 FOR i IN 1..pCheckCount LOOP
6481 IF (check_table(i).executed AND
6482 check_table(i).passed = FALSE AND
6483 check_table(i).level = c_check_level_error) THEN
6484 ttotal := ttotal + 1;
6485 DisplayLinePL('');
6486 DisplayLinePL(LPAD(ttotal,2) || ') Check Tag: ' || check_table(i).name);
6487 DisplayLinePL(' Check Summary: ' || check_table(i).descript);
6488 DisplayLinePL(' Fixup Summary: ');
6489 DisplayLinePL(' "' || getHelp(check_table(i).name,c_help_fixup) || '"');
6490 --
6491 -- Then let them know when the manual action is required.
6492 --
6493 IF (check_table(i).fix_type = c_fix_source_manual) THEN
6494 DisplayLinePL(' +++ Source Database Manual Action Required +++');
6495 ELSIF (check_table(i).fix_type = c_fix_target_manual_pre) THEN
6496 DisplayLinePL(' +++ Post Upgraded Database Manual Action Required +++');
6497 END IF;
6498 DisplayLinePL ('');
6499 END IF;
6500 END LOOP;
6501
6502 IF ttotal = 1 THEN
6503 DisplayLinePL(CenterLine('You MUST resolve the above error prior to upgrade'));
6504 ELSE
6505 DisplayLinePL(CenterLine('You MUST resolve the above errors prior to upgrade'));
6506 END IF;
6507 DisplayLinePL('');
6508 DisplayLinePL(CenterLine('************************************************************'));
6509 DisplayLinePL('');
6510 END IF;
6511 END IF; -- output type
6512 END output_check_summary;
6513
6514 --
6515 -- This is called from the pre and post fixup routines to clear out
6516 -- the 'fixup_run' flag (in case the fixups are run multiple times).
6517 --
6518 -- If preup is TRUE, this is the summary for the
6519 -- preupgrade script.
6520 --
6521 PROCEDURE clear_run_flag (preup BOOLEAN)
6522 IS
6523 BEGIN
6524 init_package;
6525 FOR i IN 1..pCheckCount LOOP
6526 check_table(i).fixup_executed := FALSE;
6527 END LOOP;
6528 END clear_run_flag;
6529
6530 --
6531 -- Walk through all the checks and provide a summary of how
6532 -- the fixup routines did.
6533 --
6534 -- This is intended to be run AFTER the fixup (pre or post)
6535 -- scripts have been executed (and is called from those
6536 -- scripts).
6537 --
6538 -- If preup is TRUE, this is the summary for the
6539 -- preupgrade script.
6540 --
6541 PROCEDURE fixup_summary (preup BOOLEAN)
6542 IS
6543 tinfo NUMBER := 0;
6544 tsuccess NUMBER := 0;
6545 tfailed NUMBER := 0;
6546 terrors NUMBER := 0;
6547 ttotal NUMBER := 0;
6548 tinfoerrors NUMBER := 0;
6549
6550 BEGIN
6551 IF p_package_inited = FALSE THEN
6552 EXECUTE IMMEDIATE 'BEGIN
6553 RAISE_APPLICATION_ERROR (-20000,
6554 ''Pre-Upgrade Package Fixup Summary called prior to fixups being executed''); END;';
6555 RETURN;
6556 END IF;
6557
6558 FOR i IN 1..pCheckCount LOOP
6559 --
6560 IF (check_table(i).fixup_executed) THEN
6561 ttotal := ttotal+ 1;
6562 IF check_table(i).fixup_status = c_fixup_status_success THEN
6563 tsuccess := tsuccess +1;
6564 ELSIF check_table(i).fixup_status = c_fixup_status_info THEN
6565 IF check_table(i).level = c_check_level_error THEN
6566 --
6567 -- Fixup returned some info, but its an error level
6568 --
6569 tinfoerrors := tinfoerrors+1;
6570 ELSE
6571 tinfo := tinfo + 1;
6572 END IF;
6573 ELSIF check_table(i).fixup_status = c_fixup_status_failure THEN
6574 tfailed := tfailed + 1;
6575 END IF;
6576 IF (check_table(i).level = c_check_level_error AND
6577 check_table(i).fixup_status != c_fixup_status_success) THEN
6578 --
6579 -- This is an error level (must be fixed), that did not
6580 -- succeed,
6581 -- at the end of this routine, dump out a list of
6582 -- these so they know they need to resolve these prior to upgrade
6583 --
6584 terrors := terrors+1;
6585 END IF;
6586 END IF;
6587 END LOOP;
6588 --
6589 -- Output counts.
6590 --
6591 DisplayLinePL('');
6592 DisplayLinePL(CenterLine('**************************************************'));
6593 DisplayLinePL(CenterLine('************* Fixup Summary ************'));
6594 DisplayLinePL('');
6595 IF ttotal = 0 THEN
6596 DisplayLinePL('No fixup routines were executed.');
6597 DisplayLinePL('');
6598 DisplayLinePL(CenterLine('**************************************************'));
6599 RETURN;
6600 END IF;
6601
6602 IF tsuccess = 1 THEN
6603
6604 DisplayLinePL(' 1 fixup routine was successful.');
6605
6606 ELSIF tsuccess = 0 THEN
6607 --
6608 -- If all we had was 'info' routines, then displaying
6609 -- that none were successful doesn't sound correct
6610 -- so take that into account here by seeing if infocount
6611 -- is the same as total.
6612 --
6613 IF ttotal = tinfo THEN
6614
6615 IF tinfo = 1 THEN
6616 DisplayLinePL(' 1 fixup routine generated an INFORMATIONAL message that should be reviewed.');
6617 ELSE
6618 -- we know its not zero.
6619 DisplayLinePL(LPAD(tinfo,2) || ' fixup routines generated INFORMATIONAL messages that should be reviewed.');
6620 END IF;
6621 END IF;
6622
6623 ELSE
6624 DisplayLinePL(LPAD(tsuccess,2) || ' fixup routines were successful.');
6625 END IF;
6626
6627 IF tinfo != ttotal THEN
6628 --
6629 -- If they are equal, the message is taken care of
6630 -- in the tsuccess block above (all that ran returned info messages.
6631 --
6632 IF tinfo = 1 THEN
6633 DisplayLinePL(' 1 fixup routine returned INFORMATIONAL text that should be reviewed.');
6634 ELSE
6635 DisplayLinePL(LPAD(tinfo,2) || ' fixup routines returned INFORMATIONAL text that should be reviewed.');
6636 END IF;
6637 END IF;
6638
6639 IF tinfoerrors != 0 THEN
6640 IF tinfoerrors = 1 THEN
6641 DisplayLinePL(' 1 ERROR LEVEL check returned INFORMATION that must be acted on prior to upgrade.');
6642 ELSE
6643 DisplayLinePL(LPAD(tinfoerrors,2) || ' ERROR LEVEL checks returned INFORMATION that must be acted on prior to upgrade.');
6644 END IF;
6645 END IF;
6646
6647 IF tfailed = 1 THEN
6648 DisplayLinePL(' 1 fixup routine failed to execute. The output must be reviewed.');
6649 ELSIF tfailed != 0 THEN
6650 DisplayLinePL(LPAD(tfailed,2) || ' fixup routines failed to execute. The output must be reviewed.');
6651 END IF;
6652
6653 --
6654 -- If there is an error level check that was run and did not succeed,
6655 -- make sure we report that they MUST RESOLVE this.
6656 --
6657 IF terrors != 0 THEN
6658 DisplayLinePL('');
6659 DisplayLinePL(CenterLine('************************************************************'));
6660 DisplayLinePL(CenterLine('====>> USER ACTION REQUIRED <<===='));
6661 DisplayLinePL(CenterLine('************************************************************'));
6662
6663 ttotal := 0; -- reuse this variable.
6664 FOR i IN 1..pCheckCount LOOP
6665 --
6666 IF (check_table(i).level = c_check_level_error AND
6667 check_table(i).fixup_status != c_fixup_status_success) THEN
6668 --
6669 -- Report this as a MUST FIX
6670 --
6671 ttotal := ttotal + 1;
6672 DisplayLinePL('');
6673 DisplayLinePL(LPAD(ttotal,2) || ') Check Tag: ' || check_table(i).name || ' failed.');
6674 DisplayLinePL(' Check Summary: ' || check_table(i).descript);
6675 DisplayLinePL(' Fixup Summary: ');
6676 DisplayLinePL(' "' || getHelp(check_table(i).name,c_help_fixup) || '"');
6677 IF check_table(i).fix_type IN (c_fix_source_manual,
6678 c_fix_target_manual_pre,
6679 c_fix_target_manual_post) THEN
6680 --
6681 -- If this is a manual situation, let them know they have
6682 -- something to do (may be redundant given the block we are in but...)
6683 --
6684 DisplayLinePL(' ' || pActionRequired);
6685 END IF;
6686 END IF;
6687 END LOOP;
6688
6689 DisplayLinePL('');
6690 DisplayLinePL(CenterLine('**************************************************'));
6691 IF ttotal = 1 THEN
6692 DisplayLinePL(CenterLine('You MUST resolve the above error prior to upgrade'));
6693 ELSE
6694 DisplayLinePL(CenterLine('You MUST resolve the above errors prior to upgrade'));
6695 END IF;
6696 DisplayLinePL(CenterLine('**************************************************'));
6697 DisplayLinePL('');
6698 END IF;
6699 DisplayLinePL('');
6700 END fixup_summary;
6701
6702 -- ***************************************************************************
6703 -- Specific Check Area
6704 -- ***************************************************************************
6705
6706
6707 -- *****************************************************************
6708 -- AMD_EXISTS Section
6709 -- *****************************************************************
6710 FUNCTION amd_exists_check (result_txt OUT VARCHAR2) RETURN number
6711 IS
6712 n_status NUMBER := -1;
6713 BEGIN
6714 --
6715 -- Is AMD around?
6716 --
6717 BEGIN
6718 EXECUTE IMMEDIATE
6719 'SELECT status FROM sys.registry$ WHERE cid=''AMD''
6720 AND namespace=''SERVER'''
6721 INTO n_status;
6722 EXCEPTION
6723 WHEN OTHERS THEN NULL; -- AMD not in registry
6724 END;
6725
6726 IF n_status = -1 AND pDBGFailCheck = FALSE OR pOutputType = c_output_xml THEN
6727 -- AMD not in registry
6728 -- or output is XML, return success
6729 RETURN c_status_success;
6730 END IF;
6731
6732 --
6733 -- This is a manual only check
6734 --
6735 result_txt := amd_exists_gethelp(c_help_overview);
6736
6737 IF pOutputFixupScripts THEN
6738 genFixup ('AMD_EXISTS');
6739 END IF;
6740 RETURN c_status_failure;
6741
6742 END amd_exists_check ;
6743
6744 FUNCTION amd_exists_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
6745 IS
6746 BEGIN
6747 IF HelpType = c_help_overview THEN
6748 return 'INFORMATION: --> OLAP Catalog(AMD) exists in database' || crlf
6749 || crlf || ' Starting with Oracle Database 12c, OLAP Catalog component is desupported.'
6750 || crlf || ' If you are not using the OLAP Catalog component and want'
6751 || crlf || ' to remove it, then execute the '
6752 || crlf || ' ORACLE_HOME/olap/admin/catnoamd.sql script before or '
6753 || crlf || ' after the upgrade.';
6754 ELSIF HelpType = c_help_fixup THEN
6755 return 'Manually execute ORACLE_HOME/oraolap/admin/catnoamd.sql script to remove OLAP.';
6756 END IF;
6757 END amd_exists_gethelp;
6758 --
6759 PROCEDURE amd_exists_fixup
6760 IS
6761 result VARCHAR2(4000);
6762 status NUMBER;
6763 tSqlcode NUMBER;
6764 BEGIN
6765 -- Call fixup and throw away the result
6766 status := amd_exists_fixup (result, tSqlcode);
6767 END amd_exists_fixup;
6768
6769 FUNCTION amd_exists_fixup (
6770 result_txt IN OUT VARCHAR2,
6771 pSqlcode IN OUT NUMBER) RETURN number
6772 IS
6773 BEGIN
6774 result_txt := amd_exists_gethelp(c_help_overview);
6775 pSqlcode := 0;
6776 return c_fixup_status_info;
6777 END amd_exists_fixup;
6778
6779
6780 -- *****************************************************************
6781 -- AUDIT_ADMIN_ROLE_PRESENT Section
6782 -- *****************************************************************
6783 FUNCTION AAR_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
6784 IS
6785 roll_exists NUMBER := 1;
6786 t_null CHAR(1);
6787 status NUMBER;
6788 BEGIN
6789 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
6790 return c_status_not_for_this_version;
6791 END IF;
6792
6793 BEGIN
6794 EXECUTE IMMEDIATE
6795 'SELECT NULL FROM sys.user$ WHERE name=''AUDIT_ADMIN'''
6796 INTO t_null;
6797 EXCEPTION
6798 WHEN NO_DATA_FOUND then roll_exists := 0;
6799 END;
6800
6801 IF (roll_exists = 0 AND pDBGFailCheck = FALSE)
6802 THEN
6803 RETURN c_status_success;
6804 ELSE
6805 IF pOutputType = c_output_xml THEN
6806 result_txt:= genDBUAXMLCheck('AUDIT_ADMIN_ROLE_PRESENT',
6807 c_check_level_error,
6808 'A user or role named "AUDIT_ADMIN" found in the database.',
6809 'A user or role named "AUDIT_ADMIN" found in the database.',
6810 '"AUDIT_ADMIN" role or user must be dropped prior to upgrading.',
6811 c_dbua_detail_type_text,
6812 'To drop the role "AUDIT_ADMIN", use the command: '||
6813 ' DROP ROLE AUDIT_ADMIN,' || ' and To drop user "AUDIT_ADMIN"'||
6814 ' use the command: DROP USER AUDIT_ADMIN CASCADE',
6815 c_dbua_fixup_type_manual,
6816 c_dbua_fixup_stage_pre );
6817 ELSE
6818 result_txt := AAR_PRESENT_gethelp(c_help_overview);
6819 END IF;
6820 IF pOutputFixupScripts THEN
6821 genFixup ('AUDIT_ADMIN_ROLE_PRESENT');
6822 END IF;
6823 RETURN c_status_failure;
6824 END IF;
6825 END AAR_PRESENT_check;
6826
6827 FUNCTION AAR_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
6828 IS
6829 BEGIN
6830 IF HelpType = c_help_overview THEN
6831 return 'ERROR: --> A user or role with the name "AUDIT_ADMIN" found in the database.' || crlf
6832 || crlf || ' This is an Oracle defined role.'
6833 || crlf || ' You must drop this role or user prior to upgrading.';
6834 ELSIF HelpType = c_help_fixup THEN
6835 return 'The AUDIT_ADMIN roll must be dropped prior to upgrading.';
6836 END IF;
6837 END AAR_PRESENT_gethelp;
6838 --
6839 -- Fixup (Procedure and function)
6840 --
6841 PROCEDURE AAR_PRESENT_fixup
6842 IS
6843 result VARCHAR2(4000);
6844 status NUMBER;
6845 tSqlcode NUMBER;
6846 BEGIN
6847 -- Call fixup and throw away the result
6848 status := AAR_PRESENT_fixup (result, tSqlcode);
6849 END AAR_PRESENT_fixup;
6850
6851 FUNCTION AAR_PRESENT_fixup (
6852 result_txt IN OUT VARCHAR2,
6853 pSqlcode IN OUT NUMBER) RETURN number
6854 IS
6855 BEGIN
6856 result_txt := AAR_PRESENT_gethelp(c_help_overview);
6857 pSqlcode := 0;
6858 return c_fixup_status_info;
6859 END AAR_PRESENT_fixup;
6860 -- *****************************************************************
6861 -- APPQOSSYS_USER_PRESENT Section
6862 -- *****************************************************************
6863 FUNCTION APPQOSSYS_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
6864 IS
6865 user_exists BOOLEAN;
6866 tmp_num1 NUMBER;
6867 t_null CHAR(1);
6868 status NUMBER;
6869
6870 BEGIN
6871 user_exists := TRUE; -- Assume its around
6872
6873 IF (db_n_version NOT IN (102,111) AND pDBGFailCheck = FALSE) THEN
6874 return c_status_not_for_this_version;
6875 END IF;
6876
6877 BEGIN
6878 EXECUTE IMMEDIATE 'SELECT user# FROM sys.user$ WHERE name=''APPQOSSYS'''
6879 INTO tmp_num1;
6880 EXCEPTION
6881 WHEN NO_DATA_FOUND then user_exists := FALSE;
6882 END;
6883
6884 IF user_exists THEN
6885 BEGIN
6886 EXECUTE IMMEDIATE
6887 'SELECT NULL FROM sys.obj$ WHERE owner# = (SELECT user# from SYS.USER$
6888 WHERE name=''APPQOSSYS'') AND
6889 name =''WLM_METRICS_STREAM'' AND type# = 2'
6890 INTO t_null;
6891 EXCEPTION
6892 WHEN NO_DATA_FOUND then user_exists := TRUE;
6893 END;
6894 END IF;
6895
6896 IF user_exists = FALSE AND pDBGFailCheck = FALSE
6897 THEN
6898 RETURN c_status_success; -- No issue
6899 ELSE
6900 IF pOutputType = c_output_xml THEN
6901 result_txt:= genDBUAXMLCheck('APPQOSSYS_USER_PRESENT',
6902 c_check_level_warning,
6903 'User APPQOSSYS present in database',
6904 'User APPQOSSYS present in database',
6905 'Remove APPQOSYS user from database.',
6906 c_dbua_detail_type_text,
6907 'The APPQOSSYS user exists in the database.'
6908 || ' This is an internal account and should be '
6909 || ' removed prior to upgrading your database',
6910 c_dbua_fixup_type_auto,
6911 c_dbua_fixup_stage_pre);
6912 ELSE
6913 result_txt := appqossys_user_present_gethelp (c_help_overview);
6914 END IF;
6915 IF pOutputFixupScripts THEN
6916 genFixup ('APPQOSSYS_USER_PRESENT');
6917 END IF;
6918 RETURN c_status_failure;
6919 END IF;
6920 END APPQOSSYS_USER_PRESENT_check;
6921
6922 FUNCTION APPQOSSYS_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
6923 IS
6924 BEGIN
6925 IF HelpType = c_help_overview THEN
6926 return 'WARNING: --> "APPQOSSYS" user found in database.' || crlf
6927 || crlf || ' This is an internal account used by '
6928 || crlf || ' Oracle Application Quality of Service Management. '
6929 || crlf || ' Please drop this user prior to upgrading.';
6930 ELSIF HelpType = c_help_fixup THEN
6931 return 'The APPQOSSYS user will will be dropped.';
6932 END IF;
6933 END APPQOSSYS_USER_PRESENT_gethelp;
6934 --
6935 -- Fixup (Procedure and function)
6936 --
6937 PROCEDURE APPQOSSYS_USER_PRESENT_fixup
6938 IS
6939 result VARCHAR2(4000);
6940 status NUMBER;
6941 tSqlcode NUMBER;
6942 BEGIN
6943 -- Call fixup and throw away the result
6944 status := APPQOSSYS_USER_PRESENT_fixup (result, tSqlcode);
6945 END APPQOSSYS_USER_PRESENT_fixup;
6946
6947 FUNCTION APPQOSSYS_USER_PRESENT_fixup (
6948 result_txt IN OUT VARCHAR2,
6949 pSqlcode IN OUT NUMBER) RETURN number
6950 IS
6951 BEGIN
6952 return execute_sql_statement ('DROP USER APPQOSSYS CASCADE', result_txt, pSqlcode);
6953 END APPQOSSYS_USER_PRESENT_fixup;
6954 -- *****************************************************************
6955 -- AUDSYS_USER_PRESENT Section
6956 -- *****************************************************************
6957 FUNCTION AUDSYS_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
6958 IS
6959 user_exists NUMBER := 1;
6960 t_null CHAR(1);
6961 status NUMBER;
6962 BEGIN
6963 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
6964 return c_status_not_for_this_version;
6965 END IF;
6966
6967 BEGIN
6968 EXECUTE IMMEDIATE
6969 'SELECT NULL FROM sys.user$ WHERE name = ''AUDSYS'''
6970 INTO t_null;
6971 EXCEPTION
6972 WHEN NO_DATA_FOUND then user_exists := 0;
6973 END;
6974 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
6975 THEN
6976 RETURN c_status_success;
6977 ELSE
6978 IF pOutputType = c_output_xml THEN
6979 result_txt:= genDBUAXMLCheck('AUDSYS_USER_PRESENT',
6980 c_check_level_error,
6981 'A user or role named "AUDSYS" found in the database.',
6982 'A user or role named "AUDSYS" found in the database.',
6983 '"AUDSYS" user or role must be dropped prior to upgrading.',
6984 c_dbua_detail_type_text,
6985 'To drop the user "AUDSYS", use the command: '||
6986 'DROP USER AUDSYS CASCADE'||', and To drop the role "AUDSYS", use the'||
6987 'command: DROP ROLE AUDSYS',
6988 c_dbua_fixup_type_manual,
6989 c_dbua_fixup_stage_pre );
6990 ELSE
6991 result_txt := AUDSYS_USER_PRESENT_gethelp(c_help_overview);
6992 END IF;
6993 IF pOutputFixupScripts THEN
6994 genFixup ('AUDSYS_USER_PRESENT');
6995 END IF;
6996 RETURN c_status_failure;
6997 END IF;
6998 END AUDSYS_USER_PRESENT_check;
6999
7000 FUNCTION AUDSYS_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7001 IS
7002 BEGIN
7003 IF HelpType = c_help_overview THEN
7004 return 'ERROR: --> A user or role with the name "AUDSYS" found in the database.' || crlf
7005 || crlf || ' This is an internal account used by Oracle Database Auditing.'
7006 || crlf || ' You must drop this user or role prior to upgrading.';
7007 ELSIF HelpType = c_help_fixup THEN
7008 return 'The AUDSYS user or roll must be dropped prior to upgrading.';
7009 END IF;
7010 END AUDSYS_USER_PRESENT_gethelp;
7011 --
7012 -- Fixup (Procedure and function)
7013 --
7014 PROCEDURE AUDSYS_USER_PRESENT_fixup
7015 IS
7016 result VARCHAR2(4000);
7017 status NUMBER;
7018 tSqlcode NUMBER;
7019 BEGIN
7020 -- Call fixup and throw away the result
7021 status := AUDSYS_USER_PRESENT_fixup (result, tSqlcode);
7022 END AUDSYS_USER_PRESENT_fixup;
7023
7024 FUNCTION AUDSYS_USER_PRESENT_fixup (
7025 result_txt IN OUT VARCHAR2,
7026 pSqlcode IN OUT NUMBER) RETURN number
7027 IS
7028 BEGIN
7029 result_txt := AUDSYS_USER_PRESENT_gethelp(c_help_overview);
7030 pSqlcode := 0;
7031 return c_fixup_status_info;
7032 END AUDSYS_USER_PRESENT_fixup;
7033
7034 -- *****************************************************************
7035 -- AUDIT_VIEWER Section
7036 -- *****************************************************************
7037 FUNCTION AUDIT_VIEWER_check (result_txt OUT VARCHAR2) RETURN number
7038 IS
7039 roll_exists NUMBER := 1;
7040 t_null CHAR(1);
7041 status NUMBER;
7042 BEGIN
7043
7044 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7045 return c_status_not_for_this_version;
7046 END IF;
7047
7048 BEGIN
7049 EXECUTE IMMEDIATE
7050 'SELECT NULL FROM sys.user$ WHERE NAME = ''AUDIT_VIEWER'''
7051 INTO t_null;
7052 EXCEPTION
7053 WHEN NO_DATA_FOUND then roll_exists := 0;
7054 END;
7055
7056 IF (roll_exists = 0 AND pDBGFailCheck = FALSE)
7057 THEN
7058 RETURN c_status_success;
7059 ELSE
7060 IF pOutputType = c_output_xml THEN
7061 result_txt:= genDBUAXMLCheck('AUDIT_VIEWER',
7062 c_check_level_error,
7063 'A user or role named "AUDIT_VIEWER" found in the database.',
7064 'A user or role named "AUDIT_VIEWER" found in the database.',
7065 '"AUDIT_VIEWER" role or user must be dropped prior to upgrading.',
7066 c_dbua_detail_type_text,
7067 'To drop the role "AUDIT_VIEWER", use the command:'
7068 || ' DROP ROLE AUDIT_VIEWER' || ', and To drop the user "AUDIT_VIEWER"'
7069 || ' use the command: DROP USER AUDIT_VIEWER CASCADE',
7070 c_dbua_fixup_type_manual,
7071 c_dbua_fixup_stage_pre );
7072 ELSE
7073 result_txt := AUDIT_VIEWER_gethelp(c_help_overview);
7074 END IF;
7075 IF pOutputFixupScripts THEN
7076 genFixup ('AUDIT_VIEWER');
7077 END IF;
7078 RETURN c_status_failure;
7079 END IF;
7080 END AUDIT_VIEWER_check;
7081
7082 FUNCTION AUDIT_VIEWER_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7083 IS
7084 BEGIN
7085 IF HelpType = c_help_overview THEN
7086 return 'ERROR: --> A user or role with the name "AUDIT_VIEWER" found in the database.' || crlf
7087 || crlf || ' This is an Oracle defined role.'
7088 || crlf || ' You must drop this role or user prior to upgrading.';
7089 ELSIF HelpType = c_help_fixup THEN
7090 return 'The AUDIT_VIEWER roll or user must be dropped prior to upgrading.';
7091 END IF;
7092 END AUDIT_VIEWER_gethelp;
7093 --
7094 -- Fixup (Procedure and function)
7095 --
7096 PROCEDURE AUDIT_VIEWER_fixup
7097 IS
7098 result VARCHAR2(4000);
7099 status NUMBER;
7100 tSqlcode NUMBER;
7101 BEGIN
7102 -- Call fixup and throw away the result
7103 status := AUDIT_VIEWER_fixup (result, tSqlcode);
7104 END AUDIT_VIEWER_fixup;
7105
7106 FUNCTION AUDIT_VIEWER_fixup (
7107 result_txt IN OUT VARCHAR2,
7108 pSqlcode IN OUT NUMBER) RETURN number
7109 IS
7110 BEGIN
7111 result_txt := AUDIT_VIEWER_gethelp(c_help_overview);
7112 pSqlcode := 0;
7113 return c_fixup_status_info;
7114 END AUDIT_VIEWER_fixup;
7115
7116 -- *****************************************************************
7117 -- SYSBACKUP_USER_PRESENT Section
7118 -- *****************************************************************
7119 FUNCTION SYSBACKUP_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7120 IS
7121 user_exists NUMBER := 1;
7122 t_null CHAR(1);
7123 status NUMBER;
7124 BEGIN
7125
7126 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7127 return c_status_not_for_this_version;
7128 END IF;
7129
7130 BEGIN
7131 EXECUTE IMMEDIATE
7132 'SELECT NULL FROM sys.user$ WHERE NAME = ''SYSBACKUP'''
7133 INTO t_null;
7134 EXCEPTION
7135 WHEN NO_DATA_FOUND then user_exists := 0;
7136 END;
7137
7138 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7139 THEN
7140 RETURN c_status_success;
7141 ELSE
7142 IF pOutputType = c_output_xml THEN
7143 result_txt:= genDBUAXMLCheck('SYSBACKUP',
7144 c_check_level_error,
7145 'A user or role named "SYSBACKUP" found in the database.',
7146 'A user or role named "SYSBACKUP" found in the database.',
7147 '"SYSBACKUP" user or role must be dropped prior to upgrading.',
7148 c_dbua_detail_type_text,
7149 'To drop the role "SYSBACKUP", use the command:'
7150 || ' DROP ROLE SYSBACKUP' || ', and To drop the user "SYSBACKUP"'
7151 || ' use the command: DROP USER SYSBACKUP CASCADE',
7152 c_dbua_fixup_type_manual,
7153 c_dbua_fixup_stage_pre );
7154 ELSE
7155 result_txt := SYSBACKUP_USER_PRESENT_gethelp(c_help_overview);
7156 END IF;
7157 IF pOutputFixupScripts THEN
7158 genFixup ('SYSBACKUP_USER_PRESENT');
7159 END IF;
7160 RETURN c_status_failure;
7161 END IF;
7162 END SYSBACKUP_USER_PRESENT_check;
7163
7164 FUNCTION SYSBACKUP_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7165 IS
7166 BEGIN
7167 IF HelpType = c_help_overview THEN
7168 return 'ERROR: --> A user or role with the name "SYSBACKUP" found in the database.' || crlf
7169 || crlf || ' This is an Oracle defined user.'
7170 || crlf || ' You must drop this user or role prior to upgrading.';
7171 ELSIF HelpType = c_help_fixup THEN
7172 return 'The SYSBACKUP user or role must be dropped prior to upgrading.';
7173 END IF;
7174 END SYSBACKUP_USER_PRESENT_gethelp;
7175 --
7176 -- Fixup (Procedure and function)
7177 --
7178 PROCEDURE SYSBACKUP_USER_PRESENT_fixup
7179 IS
7180 result VARCHAR2(4000);
7181 status NUMBER;
7182 tSqlcode NUMBER;
7183 BEGIN
7184 -- Call fixup and throw away the result
7185 status := SYSBACKUP_USER_PRESENT_fixup (result, tSqlcode);
7186 END SYSBACKUP_USER_PRESENT_fixup;
7187
7188 FUNCTION SYSBACKUP_USER_PRESENT_fixup (
7189 result_txt IN OUT VARCHAR2,
7190 pSqlcode IN OUT NUMBER) RETURN number
7191 IS
7192 BEGIN
7193 result_txt := SYSBACKUP_USER_PRESENT_gethelp(c_help_overview);
7194 pSqlcode := 0;
7195 return c_fixup_status_info;
7196 END SYSBACKUP_USER_PRESENT_fixup;
7197
7198 -- *****************************************************************
7199 -- SYSDG_USER_PRESENT Section
7200 -- *****************************************************************
7201 FUNCTION SYSDG_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7202 IS
7203 user_exists NUMBER := 1;
7204 t_null CHAR(1);
7205 status NUMBER;
7206 BEGIN
7207
7208 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7209 return c_status_not_for_this_version;
7210 END IF;
7211
7212 BEGIN
7213 EXECUTE IMMEDIATE
7214 'SELECT NULL FROM sys.user$ WHERE NAME = ''SYSDG'''
7215 INTO t_null;
7216 EXCEPTION
7217 WHEN NO_DATA_FOUND then user_exists := 0;
7218 END;
7219
7220 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7221 THEN
7222 RETURN c_status_success;
7223 ELSE
7224 IF pOutputType = c_output_xml THEN
7225 result_txt:= genDBUAXMLCheck('SYSDG',
7226 c_check_level_error,
7227 'A user or role named "SYSDG" found in the database.',
7228 'A user or role named "SYSDG" found in the database.',
7229 '"SYSDG" user or role must be dropped prior to upgrading.',
7230 c_dbua_detail_type_text,
7231 'To drop the role "SYSDG", use the command:'
7232 || ' DROP ROLE SYSDG' || ', and To drop the user "SYSDG"'
7233 || ' use the command: DROP USER SYSDG CASCADE',
7234 c_dbua_fixup_type_manual,
7235 c_dbua_fixup_stage_pre );
7236 ELSE
7237 result_txt := SYSDG_USER_PRESENT_gethelp(c_help_overview);
7238 END IF;
7239 IF pOutputFixupScripts THEN
7240 genFixup ('SYSDG_USER_PRESENT');
7241 END IF;
7242 RETURN c_status_failure;
7243 END IF;
7244 END SYSDG_USER_PRESENT_check;
7245
7246 FUNCTION SYSDG_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7247 IS
7248 BEGIN
7249 IF HelpType = c_help_overview THEN
7250 return 'ERROR: --> A user or role with the name "SYSDG" found in the database.' || crlf
7251 || crlf || ' This is an Oracle defined user.'
7252 || crlf || ' You must drop this user or role prior to upgrading.';
7253 ELSIF HelpType = c_help_fixup THEN
7254 return 'The SYSDG role or user must be dropped prior to upgrading.';
7255 END IF;
7256 END SYSDG_USER_PRESENT_gethelp;
7257 --
7258 -- Fixup (Procedure and function)
7259 --
7260 PROCEDURE SYSDG_USER_PRESENT_fixup
7261 IS
7262 result VARCHAR2(4000);
7263 status NUMBER;
7264 tSqlcode NUMBER;
7265 BEGIN
7266 -- Call fixup and throw away the result
7267 status := SYSDG_USER_PRESENT_fixup (result, tSqlcode);
7268 END SYSDG_USER_PRESENT_fixup;
7269
7270 FUNCTION SYSDG_USER_PRESENT_fixup (
7271 result_txt IN OUT VARCHAR2,
7272 pSqlcode IN OUT NUMBER) RETURN number
7273 IS
7274 BEGIN
7275 result_txt := SYSDG_USER_PRESENT_gethelp(c_help_overview);
7276 pSqlcode := 0;
7277 return c_fixup_status_info;
7278 END SYSDG_USER_PRESENT_fixup;
7279
7280 -- *****************************************************************
7281 -- SYSKM_USER_PRESENT Section
7282 -- *****************************************************************
7283 FUNCTION SYSKM_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7284 IS
7285 user_exists NUMBER := 1;
7286 t_null CHAR(1);
7287 status NUMBER;
7288 BEGIN
7289
7290 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7291 return c_status_not_for_this_version;
7292 END IF;
7293
7294 BEGIN
7295 EXECUTE IMMEDIATE
7296 'SELECT NULL FROM sys.user$ WHERE NAME = ''SYSKM'''
7297 INTO t_null;
7298 EXCEPTION
7299 WHEN NO_DATA_FOUND then user_exists := 0;
7300 END;
7301
7302 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7303 THEN
7304 RETURN c_status_success;
7305 ELSE
7306 IF pOutputType = c_output_xml THEN
7307 result_txt:= genDBUAXMLCheck('SYSKM',
7308 c_check_level_error,
7309 'A user or role named "SYSKM" found in the database.',
7310 'A user or role named "SYSKM" found in the database.',
7311 '"SYSKM" user or role must be dropped prior to upgrading.',
7312 c_dbua_detail_type_text,
7313 'To drop the role "SYSKM", use the command:'
7314 || ' DROP ROLE SYSKM' || ', and To drop the user "SYSKM"'
7315 || ' use the command: DROP USER SYSKM CASCADE',
7316 c_dbua_fixup_type_manual,
7317 c_dbua_fixup_stage_pre );
7318 ELSE
7319 result_txt := SYSKM_USER_PRESENT_gethelp(c_help_overview);
7320 END IF;
7321 IF pOutputFixupScripts THEN
7322 genFixup ('SYSKM_USER_PRESENT');
7323 END IF;
7324 RETURN c_status_failure;
7325 END IF;
7326 END SYSKM_USER_PRESENT_check;
7327
7328 FUNCTION SYSKM_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7329 IS
7330 BEGIN
7331 IF HelpType = c_help_overview THEN
7332 return 'ERROR: --> A user or role with the name "SYSKM" found in the database.' || crlf
7333 || crlf || ' This is an Oracle defined user.'
7334 || crlf || ' You must drop this user or role prior to upgrading.';
7335 ELSIF HelpType = c_help_fixup THEN
7336 return 'The SYSKM user or role must be dropped prior to upgrading.';
7337 END IF;
7338 END SYSKM_USER_PRESENT_gethelp;
7339 --
7340 -- Fixup (Procedure and function)
7341 --
7342 PROCEDURE SYSKM_USER_PRESENT_fixup
7343 IS
7344 result VARCHAR2(4000);
7345 status NUMBER;
7346 tSqlcode NUMBER;
7347 BEGIN
7348 -- Call fixup and throw away the result
7349 status := SYSKM_USER_PRESENT_fixup (result, tSqlcode);
7350 END SYSKM_USER_PRESENT_fixup;
7351
7352 FUNCTION SYSKM_USER_PRESENT_fixup (
7353 result_txt IN OUT VARCHAR2,
7354 pSqlcode IN OUT NUMBER) RETURN number
7355 IS
7356 BEGIN
7357 result_txt := SYSKM_USER_PRESENT_gethelp(c_help_overview);
7358 pSqlcode := 0;
7359 return c_fixup_status_info;
7360 END SYSKM_USER_PRESENT_fixup;
7361
7362 -- *****************************************************************
7363 -- CAPT_ADM_ROLE_PRESENT Section
7364 -- *****************************************************************
7365 FUNCTION CAPT_ADM_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7366 IS
7367 role_exists NUMBER := 1;
7368 t_null CHAR(1);
7369 status NUMBER;
7370 BEGIN
7371
7372 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7373 return c_status_not_for_this_version;
7374 END IF;
7375
7376 BEGIN
7377 EXECUTE IMMEDIATE
7378 'SELECT NULL FROM sys.user$ WHERE NAME = ''CAPTURE_ADMIN'''
7379 INTO t_null;
7380 EXCEPTION
7381 WHEN NO_DATA_FOUND then role_exists := 0;
7382 END;
7383
7384 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
7385 THEN
7386 RETURN c_status_success;
7387 ELSE
7388 IF pOutputType = c_output_xml THEN
7389 result_txt:= genDBUAXMLCheck('CAPTURE_ADMIN',
7390 c_check_level_error,
7391 'A user or role named "CAPTURE_ADMIN" found in the database.',
7392 'A user or role named "CAPTURE_ADMIN" found in the database.',
7393 '"CAPTURE_ADMIN" user or role must be dropped prior to upgrading.',
7394 c_dbua_detail_type_text,
7395 'To drop the role "CAPTURE_ADMIN", use the command:'
7396 || ' DROP ROLE CAPTURE_ADMIN' || ', and To drop the user "CAPTURE_ADMIN"'
7397 || ' use the command: DROP USER CAPTURE_ADMIN CASCADE',
7398 c_dbua_fixup_type_manual,
7399 c_dbua_fixup_stage_pre );
7400 ELSE
7401 result_txt := CAPT_ADM_ROLE_PRESENT_gethelp(c_help_overview);
7402 END IF;
7403 IF pOutputFixupScripts THEN
7404 genFixup ('CAPT_ADM_ROLE_PRESENT');
7405 END IF;
7406 RETURN c_status_failure;
7407 END IF;
7408 END CAPT_ADM_ROLE_PRESENT_check;
7409
7410 FUNCTION CAPT_ADM_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7411 IS
7412 BEGIN
7413 IF HelpType = c_help_overview THEN
7414 return 'ERROR: --> A user or role with the name "CAPTURE_ADMIN" found in the database.' || crlf
7415 || crlf || ' This is an Oracle defined role.'
7416 || crlf || ' You must drop this user or role prior to upgrading.';
7417 ELSIF HelpType = c_help_fixup THEN
7418 return 'The CAPTURE_ADMIN user or role must be dropped prior to upgrading.';
7419 END IF;
7420 END CAPT_ADM_ROLE_PRESENT_gethelp;
7421 --
7422 -- Fixup (Procedure and function)
7423 --
7424 PROCEDURE CAPT_ADM_ROLE_PRESENT_fixup
7425 IS
7426 result VARCHAR2(4000);
7427 status NUMBER;
7428 tSqlcode NUMBER;
7429 BEGIN
7430 -- Call fixup and throw away the result
7431 status := CAPT_ADM_ROLE_PRESENT_fixup (result, tSqlcode);
7432 END CAPT_ADM_ROLE_PRESENT_fixup;
7433
7434 FUNCTION CAPT_ADM_ROLE_PRESENT_fixup (
7435 result_txt IN OUT VARCHAR2,
7436 pSqlcode IN OUT NUMBER) RETURN number
7437 IS
7438 BEGIN
7439 result_txt := CAPT_ADM_ROLE_PRESENT_gethelp(c_help_overview);
7440 pSqlcode := 0;
7441 return c_fixup_status_info;
7442 END CAPT_ADM_ROLE_PRESENT_fixup;
7443
7444
7445 -- *****************************************************************
7446 -- GSMCATUSER_PRESENT Section
7447 -- *****************************************************************
7448 FUNCTION GSMCATUSER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7449 IS
7450 user_exists NUMBER := 1;
7451 t_null CHAR(1);
7452 status NUMBER;
7453 BEGIN
7454
7455 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7456 return c_status_not_for_this_version;
7457 END IF;
7458
7459 BEGIN
7460 EXECUTE IMMEDIATE
7461 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSMCATUSER'''
7462 INTO t_null;
7463 EXCEPTION
7464 WHEN NO_DATA_FOUND then user_exists := 0;
7465 END;
7466
7467 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7468 THEN
7469 RETURN c_status_success;
7470 ELSE
7471 IF pOutputType = c_output_xml THEN
7472 result_txt:= genDBUAXMLCheck('GSMCATUSER',
7473 c_check_level_error,
7474 'A user or role named "GSMCATUSER" found in the database.',
7475 'A user or role named "GSMCATUSER" found in the database.',
7476 '"GSMCATUSER" user or role must be dropped prior to upgrading.',
7477 c_dbua_detail_type_text,
7478 'To drop the role "GSMCATUSER", use the command:'
7479 || ' DROP ROLE GSMCATUSER' || ', and To drop the user "GSMCATUSER"'
7480 || ' use the command: DROP USER GSMCATUSER CASCADE',
7481 c_dbua_fixup_type_manual,
7482 c_dbua_fixup_stage_pre );
7483 ELSE
7484 result_txt := GSMCATUSER_PRESENT_gethelp(c_help_overview);
7485 END IF;
7486 IF pOutputFixupScripts THEN
7487 genFixup ('GSMCATUSER_PRESENT');
7488 END IF;
7489 RETURN c_status_failure;
7490 END IF;
7491 END GSMCATUSER_PRESENT_check;
7492
7493 FUNCTION GSMCATUSER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7494 IS
7495 BEGIN
7496 IF HelpType = c_help_overview THEN
7497 return 'ERROR: --> A user or role with the name "GSMCATUSER" found in the database.' || crlf
7498 || crlf || ' This is an Oracle defined user.'
7499 || crlf || ' You must drop this user or role prior to upgrading.';
7500 ELSIF HelpType = c_help_fixup THEN
7501 return 'The GSMCATUSER role or user must be dropped prior to upgrading.';
7502 END IF;
7503 END GSMCATUSER_PRESENT_gethelp;
7504 --
7505 -- Fixup (Procedure and function)
7506 --
7507 PROCEDURE GSMCATUSER_PRESENT_fixup
7508 IS
7509 result VARCHAR2(4000);
7510 status NUMBER;
7511 tSqlcode NUMBER;
7512 BEGIN
7513 -- Call fixup and throw away the result
7514 status := GSMCATUSER_PRESENT_fixup (result, tSqlcode);
7515 END GSMCATUSER_PRESENT_fixup;
7516
7517 FUNCTION GSMCATUSER_PRESENT_fixup (
7518 result_txt IN OUT VARCHAR2,
7519 pSqlcode IN OUT NUMBER) RETURN number
7520 IS
7521 BEGIN
7522 result_txt := GSMCATUSER_PRESENT_gethelp(c_help_overview);
7523 pSqlcode := 0;
7524 return c_fixup_status_info;
7525 END GSMCATUSER_PRESENT_fixup;
7526
7527 -- *****************************************************************
7528 -- GSMUSER_USER_PRESENT Section
7529 -- *****************************************************************
7530 FUNCTION GSMUSER_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7531 IS
7532 user_exists NUMBER := 1;
7533 t_null CHAR(1);
7534 status NUMBER;
7535 BEGIN
7536
7537 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7538 return c_status_not_for_this_version;
7539 END IF;
7540
7541 BEGIN
7542 EXECUTE IMMEDIATE
7543 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSMUSER'''
7544 INTO t_null;
7545 EXCEPTION
7546 WHEN NO_DATA_FOUND then user_exists := 0;
7547 END;
7548
7549 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7550 THEN
7551 RETURN c_status_success;
7552 ELSE
7553 IF pOutputType = c_output_xml THEN
7554 result_txt:= genDBUAXMLCheck('GSMUSER',
7555 c_check_level_error,
7556 'A user or role named "GSMUSER" found in the database.',
7557 'A user or role named "GSMUSER" found in the database.',
7558 '"GSMUSER" user or role must be dropped prior to upgrading.',
7559 c_dbua_detail_type_text,
7560 'To drop the role "GSMUSER", use the command:'
7561 || ' DROP ROLE GSMUSER' || ', and To drop the user "GSMUSER"'
7562 || ' use the command: DROP USER GSMUSER CASCADE',
7563 c_dbua_fixup_type_manual,
7564 c_dbua_fixup_stage_pre );
7565 ELSE
7566 result_txt := GSMUSER_USER_PRESENT_gethelp(c_help_overview);
7567 END IF;
7568 IF pOutputFixupScripts THEN
7569 genFixup ('GSMUSER_USER_PRESENT');
7570 END IF;
7571 RETURN c_status_failure;
7572 END IF;
7573 END GSMUSER_USER_PRESENT_check;
7574
7575 FUNCTION GSMUSER_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7576 IS
7577 BEGIN
7578 IF HelpType = c_help_overview THEN
7579 return 'ERROR: --> A user or role with the name "GSMUSER" found in the database.' || crlf
7580 || crlf || ' This is an Oracle defined user.'
7581 || crlf || ' You must drop this user or role prior to upgrading.';
7582 ELSIF HelpType = c_help_fixup THEN
7583 return 'The GSMUSER role or user must be dropped prior to upgrading.';
7584 END IF;
7585 END GSMUSER_USER_PRESENT_gethelp;
7586 --
7587 -- Fixup (Procedure and function)
7588 --
7589 PROCEDURE GSMUSER_USER_PRESENT_fixup
7590 IS
7591 result VARCHAR2(4000);
7592 status NUMBER;
7593 tSqlcode NUMBER;
7594 BEGIN
7595 -- Call fixup and throw away the result
7596 status := GSMUSER_USER_PRESENT_fixup (result, tSqlcode);
7597 END GSMUSER_USER_PRESENT_fixup;
7598
7599 FUNCTION GSMUSER_USER_PRESENT_fixup (
7600 result_txt IN OUT VARCHAR2,
7601 pSqlcode IN OUT NUMBER) RETURN number
7602 IS
7603 BEGIN
7604 result_txt := GSMUSER_USER_PRESENT_gethelp(c_help_overview);
7605 pSqlcode := 0;
7606 return c_fixup_status_info;
7607 END GSMUSER_USER_PRESENT_fixup;
7608
7609 -- *****************************************************************
7610 -- GSMADM_INT_PRESENT Section
7611 -- *****************************************************************
7612 FUNCTION GSMADM_INT_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7613 IS
7614 user_exists NUMBER := 1;
7615 t_null CHAR(1);
7616 status NUMBER;
7617 BEGIN
7618
7619 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7620 return c_status_not_for_this_version;
7621 END IF;
7622
7623 BEGIN
7624 EXECUTE IMMEDIATE
7625 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSMADMIN_INTERNAL'''
7626 INTO t_null;
7627 EXCEPTION
7628 WHEN NO_DATA_FOUND then user_exists := 0;
7629 END;
7630
7631 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
7632 THEN
7633 RETURN c_status_success;
7634 ELSE
7635 IF pOutputType = c_output_xml THEN
7636 result_txt:= genDBUAXMLCheck('GSMADMIN_INTERNAL',
7637 c_check_level_error,
7638 'A user or role named "GSMADMIN_INTERNAL" found in the database.',
7639 'A user or role named "GSMADMIN_INTERNAL" found in the database.',
7640 '"GSMADMIN_INTERNAL" user or role must be dropped prior to upgrading.',
7641 c_dbua_detail_type_text,
7642 'To drop the role "GSMADMIN_INTERNAL", use the command:'
7643 || ' DROP ROLE GSMADMIN_INTERNAL' || ', and To drop the user "GSMADMIN_INTERNAL"'
7644 || ' use the command: DROP USER GSMADMIN_INTERNAL CASCADE',
7645 c_dbua_fixup_type_manual,
7646 c_dbua_fixup_stage_pre );
7647 ELSE
7648 result_txt := GSMADM_INT_PRESENT_gethelp(c_help_overview);
7649 END IF;
7650 IF pOutputFixupScripts THEN
7651 genFixup ('GSMADM_INT_PRESENT');
7652 END IF;
7653 RETURN c_status_failure;
7654 END IF;
7655 END GSMADM_INT_PRESENT_check;
7656
7657 FUNCTION GSMADM_INT_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7658 IS
7659 BEGIN
7660 IF HelpType = c_help_overview THEN
7661 return 'ERROR: --> A user or role with the name "GSMADMIN_INTERNAL" found in the database.' || crlf
7662 || crlf || ' This is an Oracle defined user.'
7663 || crlf || ' You must drop this user or role prior to upgrading.';
7664 ELSIF HelpType = c_help_fixup THEN
7665 return 'The GSMADMIN_INTERNAL role or user must be dropped prior to upgrading.';
7666 END IF;
7667 END GSMADM_INT_PRESENT_gethelp;
7668 --
7669 -- Fixup (Procedure and function)
7670 --
7671 PROCEDURE GSMADM_INT_PRESENT_fixup
7672 IS
7673 result VARCHAR2(4000);
7674 status NUMBER;
7675 tSqlcode NUMBER;
7676 BEGIN
7677 -- Call fixup and throw away the result
7678 status := GSMADM_INT_PRESENT_fixup (result, tSqlcode);
7679 END GSMADM_INT_PRESENT_fixup;
7680
7681 FUNCTION GSMADM_INT_PRESENT_fixup (
7682 result_txt IN OUT VARCHAR2,
7683 pSqlcode IN OUT NUMBER) RETURN number
7684 IS
7685 BEGIN
7686 result_txt := GSMADM_INT_PRESENT_gethelp(c_help_overview);
7687 pSqlcode := 0;
7688 return c_fixup_status_info;
7689 END GSMADM_INT_PRESENT_fixup;
7690
7691 -- *****************************************************************
7692 -- GSMUSER_ROLE_PRESENT Section
7693 -- *****************************************************************
7694 FUNCTION GSMUSER_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7695 IS
7696 role_exists NUMBER := 1;
7697 t_null CHAR(1);
7698 status NUMBER;
7699 BEGIN
7700
7701 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7702 return c_status_not_for_this_version;
7703 END IF;
7704
7705 BEGIN
7706 EXECUTE IMMEDIATE
7707 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSMUSER_ROLE'''
7708 INTO t_null;
7709 EXCEPTION
7710 WHEN NO_DATA_FOUND then role_exists := 0;
7711 END;
7712
7713 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
7714 THEN
7715 RETURN c_status_success;
7716 ELSE
7717 IF pOutputType = c_output_xml THEN
7718 result_txt:= genDBUAXMLCheck('GSMUSER_ROLE',
7719 c_check_level_error,
7720 'A user or role named "GSMUSER_ROLE" found in the database.',
7721 'A user or role named "GSMUSER_ROLE" found in the database.',
7722 '"GSMUSER_ROLE" user or role must be dropped prior to upgrading.',
7723 c_dbua_detail_type_text,
7724 'To drop the role "GSMUSER_ROLE", use the command:'
7725 || ' DROP ROLE GSMUSER_ROLE' || ', and To drop the user "GSMUSER_ROLE"'
7726 || ' use the command: DROP USER GSMUSER_ROLE CASCADE',
7727 c_dbua_fixup_type_manual,
7728 c_dbua_fixup_stage_pre );
7729 ELSE
7730 result_txt := GSMUSER_ROLE_PRESENT_gethelp(c_help_overview);
7731 END IF;
7732 IF pOutputFixupScripts THEN
7733 genFixup ('GSMUSER_ROLE_PRESENT');
7734 END IF;
7735 RETURN c_status_failure;
7736 END IF;
7737 END GSMUSER_ROLE_PRESENT_check;
7738
7739 FUNCTION GSMUSER_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7740 IS
7741 BEGIN
7742 IF HelpType = c_help_overview THEN
7743 return 'ERROR: --> A user or role with the name "GSMUSER_ROLE" found in the database.' || crlf
7744 || crlf || ' This is an Oracle defined role.'
7745 || crlf || ' You must drop this user or role prior to upgrading.';
7746 ELSIF HelpType = c_help_fixup THEN
7747 return 'The GSMUSER_ROLE user or role must be dropped prior to upgrading.';
7748 END IF;
7749 END GSMUSER_ROLE_PRESENT_gethelp;
7750 --
7751 -- Fixup (Procedure and function)
7752 --
7753 PROCEDURE GSMUSER_ROLE_PRESENT_fixup
7754 IS
7755 result VARCHAR2(4000);
7756 status NUMBER;
7757 tSqlcode NUMBER;
7758 BEGIN
7759 -- Call fixup and throw away the result
7760 status := GSMUSER_ROLE_PRESENT_fixup (result, tSqlcode);
7761 END GSMUSER_ROLE_PRESENT_fixup;
7762
7763 FUNCTION GSMUSER_ROLE_PRESENT_fixup (
7764 result_txt IN OUT VARCHAR2,
7765 pSqlcode IN OUT NUMBER) RETURN number
7766 IS
7767 BEGIN
7768 result_txt := GSMUSER_ROLE_PRESENT_gethelp(c_help_overview);
7769 pSqlcode := 0;
7770 return c_fixup_status_info;
7771 END GSMUSER_ROLE_PRESENT_fixup;
7772
7773 -- *****************************************************************
7774 -- GSM_PAD_ROLE_PRESENT Section
7775 -- *****************************************************************
7776 FUNCTION GSM_PAD_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7777 IS
7778 role_exists NUMBER := 1;
7779 t_null CHAR(1);
7780 status NUMBER;
7781 BEGIN
7782
7783 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7784 return c_status_not_for_this_version;
7785 END IF;
7786
7787 BEGIN
7788 EXECUTE IMMEDIATE
7789 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSM_POOLADMIN_ROLE'''
7790 INTO t_null;
7791 EXCEPTION
7792 WHEN NO_DATA_FOUND then role_exists := 0;
7793 END;
7794
7795 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
7796 THEN
7797 RETURN c_status_success;
7798 ELSE
7799 IF pOutputType = c_output_xml THEN
7800 result_txt:= genDBUAXMLCheck('GSM_POOLADMIN_ROLE',
7801 c_check_level_error,
7802 'A user or role named "GSM_POOLADMIN_ROLE" found in the database.',
7803 'A user or role named "GSM_POOLADMIN_ROLE" found in the database.',
7804 '"GSM_POOLADMIN_ROLE" user or role must be dropped prior to upgrading.',
7805 c_dbua_detail_type_text,
7806 'To drop the role "GSM_POOLADMIN_ROLE", use the command:'
7807 || ' DROP ROLE GSM_POOLADMIN_ROLE' || ', and To drop the user "GSM_POOLADMIN_ROLE"'
7808 || ' use the command: DROP USER GSM_POOLADMIN_ROLE CASCADE',
7809 c_dbua_fixup_type_manual,
7810 c_dbua_fixup_stage_pre );
7811 ELSE
7812 result_txt := GSM_PAD_ROLE_PRESENT_gethelp(c_help_overview);
7813 END IF;
7814 IF pOutputFixupScripts THEN
7815 genFixup ('GSM_PAD_ROLE_PRESENT');
7816 END IF;
7817 RETURN c_status_failure;
7818 END IF;
7819 END GSM_PAD_ROLE_PRESENT_check;
7820
7821 FUNCTION GSM_PAD_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7822 IS
7823 BEGIN
7824 IF HelpType = c_help_overview THEN
7825 return 'ERROR: --> A user or role with the name "GSM_POOLADMIN_ROLE" found in the database.' || crlf
7826 || crlf || ' This is an Oracle defined role.'
7827 || crlf || ' You must drop this user or role prior to upgrading.';
7828 ELSIF HelpType = c_help_fixup THEN
7829 return 'The GSM_POOLADMIN_ROLE user or role must be dropped prior to upgrading.';
7830 END IF;
7831 END GSM_PAD_ROLE_PRESENT_gethelp;
7832 --
7833 -- Fixup (Procedure and function)
7834 --
7835 PROCEDURE GSM_PAD_ROLE_PRESENT_fixup
7836 IS
7837 result VARCHAR2(4000);
7838 status NUMBER;
7839 tSqlcode NUMBER;
7840 BEGIN
7841 -- Call fixup and throw away the result
7842 status := GSM_PAD_ROLE_PRESENT_fixup (result, tSqlcode);
7843 END GSM_PAD_ROLE_PRESENT_fixup;
7844
7845 FUNCTION GSM_PAD_ROLE_PRESENT_fixup (
7846 result_txt IN OUT VARCHAR2,
7847 pSqlcode IN OUT NUMBER) RETURN number
7848 IS
7849 BEGIN
7850 result_txt := GSM_PAD_ROLE_PRESENT_gethelp(c_help_overview);
7851 pSqlcode := 0;
7852 return c_fixup_status_info;
7853 END GSM_PAD_ROLE_PRESENT_fixup;
7854
7855 -- *****************************************************************
7856 -- GSMADMIN_ROLE_PRESENT Section
7857 -- *****************************************************************
7858 FUNCTION GSMADMIN_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7859 IS
7860 role_exists NUMBER := 1;
7861 t_null CHAR(1);
7862 status NUMBER;
7863 BEGIN
7864
7865 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7866 return c_status_not_for_this_version;
7867 END IF;
7868
7869 BEGIN
7870 EXECUTE IMMEDIATE
7871 'SELECT NULL FROM sys.user$ WHERE NAME = ''GSMADMIN_ROLE'''
7872 INTO t_null;
7873 EXCEPTION
7874 WHEN NO_DATA_FOUND then role_exists := 0;
7875 END;
7876
7877 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
7878 THEN
7879 RETURN c_status_success;
7880 ELSE
7881 IF pOutputType = c_output_xml THEN
7882 result_txt:= genDBUAXMLCheck('GSMADMIN_ROLE',
7883 c_check_level_error,
7884 'A user or role named "GSMADMIN_ROLE" found in the database.',
7885 'A user or role named "GSMADMIN_ROLE" found in the database.',
7886 '"GSMADMIN_ROLE" user or role must be dropped prior to upgrading.',
7887 c_dbua_detail_type_text,
7888 'To drop the role "GSMADMIN_ROLE", use the command:'
7889 || ' DROP ROLE GSMADMIN_ROLE' || ', and To drop the user "GSMADMIN_ROLE"'
7890 || ' use the command: DROP USER GSMADMIN_ROLE CASCADE',
7891 c_dbua_fixup_type_manual,
7892 c_dbua_fixup_stage_pre );
7893 ELSE
7894 result_txt := GSMADMIN_ROLE_PRESENT_gethelp(c_help_overview);
7895 END IF;
7896 IF pOutputFixupScripts THEN
7897 genFixup ('GSMADMIN_ROLE_PRESENT');
7898 END IF;
7899 RETURN c_status_failure;
7900 END IF;
7901 END GSMADMIN_ROLE_PRESENT_check;
7902
7903 FUNCTION GSMADMIN_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7904 IS
7905 BEGIN
7906 IF HelpType = c_help_overview THEN
7907 return 'ERROR: --> A user or role with the name "GSMADMIN_ROLE" found in the database.' || crlf
7908 || crlf || ' This is an Oracle defined role.'
7909 || crlf || ' You must drop this user or role prior to upgrading.';
7910 ELSIF HelpType = c_help_fixup THEN
7911 return 'The GSMADMIN_ROLE user or role must be dropped prior to upgrading.';
7912 END IF;
7913 END GSMADMIN_ROLE_PRESENT_gethelp;
7914 --
7915 -- Fixup (Procedure and function)
7916 --
7917 PROCEDURE GSMADMIN_ROLE_PRESENT_fixup
7918 IS
7919 result VARCHAR2(4000);
7920 status NUMBER;
7921 tSqlcode NUMBER;
7922 BEGIN
7923 -- Call fixup and throw away the result
7924 status := GSMADMIN_ROLE_PRESENT_fixup (result, tSqlcode);
7925 END GSMADMIN_ROLE_PRESENT_fixup;
7926
7927 FUNCTION GSMADMIN_ROLE_PRESENT_fixup (
7928 result_txt IN OUT VARCHAR2,
7929 pSqlcode IN OUT NUMBER) RETURN number
7930 IS
7931 BEGIN
7932 result_txt := GSMADMIN_ROLE_PRESENT_gethelp(c_help_overview);
7933 pSqlcode := 0;
7934 return c_fixup_status_info;
7935 END GSMADMIN_ROLE_PRESENT_fixup;
7936
7937 -- *****************************************************************
7938 -- GDS_CT_ROLE_PRESENT Section
7939 -- *****************************************************************
7940 FUNCTION GDS_CT_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
7941 IS
7942 role_exists NUMBER := 1;
7943 t_null CHAR(1);
7944 status NUMBER;
7945 BEGIN
7946
7947 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
7948 return c_status_not_for_this_version;
7949 END IF;
7950
7951 BEGIN
7952 EXECUTE IMMEDIATE
7953 'SELECT NULL FROM sys.user$ WHERE NAME = ''GDS_CATALOG_SELECT'''
7954 INTO t_null;
7955 EXCEPTION
7956 WHEN NO_DATA_FOUND then role_exists := 0;
7957 END;
7958
7959 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
7960 THEN
7961 RETURN c_status_success;
7962 ELSE
7963 IF pOutputType = c_output_xml THEN
7964 result_txt:= genDBUAXMLCheck('GDS_CATALOG_SELECT',
7965 c_check_level_error,
7966 'A user or role named "GDS_CATALOG_SELECT" found in the database.',
7967 'A user or role named "GDS_CATALOG_SELECT" found in the database.',
7968 '"GDS_CATALOG_SELECT" user or role must be dropped prior to upgrading.',
7969 c_dbua_detail_type_text,
7970 'To drop the role "GDS_CATALOG_SELECT", use the command:'
7971 || ' DROP ROLE GDS_CATALOG_SELECT' || ', and To drop the user "GDS_CATALOG_SELECT"'
7972 || ' use the command: DROP USER GDS_CATALOG_SELECT CASCADE',
7973 c_dbua_fixup_type_manual,
7974 c_dbua_fixup_stage_pre );
7975 ELSE
7976 result_txt := GDS_CT_ROLE_PRESENT_gethelp(c_help_overview);
7977 END IF;
7978 IF pOutputFixupScripts THEN
7979 genFixup ('GDS_CT_ROLE_PRESENT');
7980 END IF;
7981 RETURN c_status_failure;
7982 END IF;
7983 END GDS_CT_ROLE_PRESENT_check;
7984
7985 FUNCTION GDS_CT_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
7986 IS
7987 BEGIN
7988 IF HelpType = c_help_overview THEN
7989 return 'ERROR: --> A user or role with the name "GDS_CATALOG_SELECT" found in the database.' || crlf
7990 || crlf || ' This is an Oracle defined role.'
7991 || crlf || ' You must drop this user or role prior to upgrading.';
7992 ELSIF HelpType = c_help_fixup THEN
7993 return 'The GDS_CATALOG_SELECT user or role must be dropped prior to upgrading.';
7994 END IF;
7995 END GDS_CT_ROLE_PRESENT_gethelp;
7996 --
7997 -- Fixup (Procedure and function)
7998 --
7999 PROCEDURE GDS_CT_ROLE_PRESENT_fixup
8000 IS
8001 result VARCHAR2(4000);
8002 status NUMBER;
8003 tSqlcode NUMBER;
8004 BEGIN
8005 -- Call fixup and throw away the result
8006 status := GDS_CT_ROLE_PRESENT_fixup (result, tSqlcode);
8007 END GDS_CT_ROLE_PRESENT_fixup;
8008
8009 FUNCTION GDS_CT_ROLE_PRESENT_fixup (
8010 result_txt IN OUT VARCHAR2,
8011 pSqlcode IN OUT NUMBER) RETURN number
8012 IS
8013 BEGIN
8014 result_txt := GDS_CT_ROLE_PRESENT_gethelp(c_help_overview);
8015 pSqlcode := 0;
8016 return c_fixup_status_info;
8017 END GDS_CT_ROLE_PRESENT_fixup;
8018
8019
8020 -- *****************************************************************
8021 -- AWR_DBIDS_PRESENT Section
8022 -- *****************************************************************
8023 FUNCTION AWR_DBIDS_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
8024 IS
8025 roll_exists NUMBER := 1;
8026 t_null CHAR(1);
8027 status NUMBER;
8028 BEGIN
8029 -- Perform this check only if db version is pre-12
8030 IF (db_n_version NOT IN (102, 111, 112))
8031 THEN
8032 RETURN c_status_not_for_this_version;
8033 END IF;
8034
8035 BEGIN
8036 EXECUTE IMMEDIATE
8037 'SELECT NULL FROM sys.wrm$_wr_control WHERE dbid != (SELECT dbid FROM v$database)'
8038 INTO t_null;
8039 EXCEPTION
8040 WHEN NO_DATA_FOUND then roll_exists := 0;
8041 END;
8042
8043 IF (roll_exists = 0 AND pDBGFailCheck = FALSE)
8044 THEN
8045 RETURN c_status_success;
8046 ELSE
8047 IF pOutputType = c_output_xml THEN
8048 result_txt:= genDBUAXMLCheck('AWR_DBIDS_PRESENT',
8049 c_check_level_warning,
8050 'Inactive DBIDs found in AWR',
8051 'Inactive DBIDs found in AWR.',
8052 'The inactive DBIDs in AWR may need additional updating after ' ||
8053 'upgrading.',
8054 c_dbua_detail_type_text,
8055 'To update the inactive DBIDs in AWR, run the script awrupd12.sql as SYSDBA',
8056 c_dbua_fixup_type_manual,
8057 c_dbua_fixup_stage_post );
8058 ELSE
8059 result_txt := AWR_DBIDS_PRESENT_gethelp(c_help_overview);
8060 END IF;
8061 IF pOutputFixupScripts THEN
8062 genFixup ('AWR_DBIDS_PRESENT');
8063 END IF;
8064 RETURN c_status_failure;
8065 END IF;
8066 END AWR_DBIDS_PRESENT_check;
8067
8068 FUNCTION AWR_DBIDS_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8069 IS
8070 BEGIN
8071 IF HelpType = c_help_overview THEN
8072 return 'WARNING: --> Inactive DBIDs found in AWR' || crlf
8073 || crlf || ' AWR contains inactive DBIDs which may need additional updating after' || crlf || ' upgrading.';
8074 ELSIF HelpType = c_help_fixup THEN
8075 return 'The inactive DBIDs in AWR may need additional updating after upgrading.';
8076 END IF;
8077 END AWR_DBIDS_PRESENT_gethelp;
8078
8079 --
8080 -- Fixup (Procedure and function)
8081 --
8082 PROCEDURE AWR_DBIDS_PRESENT_fixup
8083 IS
8084 result VARCHAR2(4000);
8085 status NUMBER;
8086 tSqlcode NUMBER;
8087 BEGIN
8088 -- Call fixup and throw away the result
8089 status := AWR_DBIDS_PRESENT_fixup (result, tSqlcode);
8090 END AWR_DBIDS_PRESENT_fixup;
8091
8092 FUNCTION AWR_DBIDS_PRESENT_fixup (
8093 result_txt IN OUT VARCHAR2,
8094 pSqlcode IN OUT NUMBER) RETURN number
8095 IS
8096 BEGIN
8097 result_txt := AWR_DBIDS_PRESENT_gethelp(c_help_overview);
8098 pSqlcode := 0;
8099 return c_fixup_status_info;
8100 END AWR_DBIDS_PRESENT_fixup;
8101
8102 -- *****************************************************************
8103 -- compatible_parameter Section
8104 -- *****************************************************************
8105 FUNCTION compatible_parameter_check (result_txt OUT VARCHAR2) RETURN number
8106 IS
8107 status NUMBER;
8108 BEGIN
8109 --
8110 -- If we have the correct min compat and not debug and not XML
8111 -- return success.
8112 --
8113 IF ((db_compat_majorver >= c_compat_min_num AND pDBGFailCheck = FALSE) OR
8114 pOutputType = c_output_xml) THEN
8115 RETURN c_status_success;
8116 END IF;
8117
8118 result_txt := compatible_parameter_gethelp(c_help_overview);
8119 IF pOutputFixupScripts THEN
8120 genFixup ('COMPATIBLE_PARAMETER');
8121 END IF;
8122 RETURN c_status_failure;
8123 END compatible_parameter_check;
8124
8125 FUNCTION compatible_parameter_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8126 IS
8127 result_txt VARCHAR2(4000);
8128 BEGIN
8129 IF HelpType = c_help_overview THEN
8130 result_txt := 'ERROR: --> Compatible set too low' || crlf
8131 || crlf || ' "compatible" currently set at ' || db_compat || ' but must'
8132 || crlf || ' be at least ' || c_compat_min || ' to upgrade the database.';
8133
8134 IF db_n_version = 102 THEN
8135
8136 result_txt := result_txt
8137 || crlf || ' '
8138 || crlf || ' For manual upgrades, update the compatible to 12.1.0 in your'
8139 || crlf || ' init.ora or spfile after shutting down the database, but prior'
8140 || crlf || ' to starting up the database for upgrade. The DBUA will automatically'
8141 || crlf || ' increase the compatible value prior to upgrading.';
8142 ELSE
8143
8144 result_txt := result_txt
8145 || crlf || crlf || ' Update your init.ora or spfile to make this change.';
8146
8147 END IF;
8148
8149 ELSIF HelpType = c_help_fixup THEN
8150 result_txt := '"compatible" parameter must be increased manually prior to upgrade.';
8151 END IF;
8152 RETURN result_txt;
8153 END compatible_parameter_gethelp;
8154 --
8155 -- Fixup (Procedure and function)
8156 --
8157 PROCEDURE compatible_parameter_fixup
8158 IS
8159 result VARCHAR2(4000);
8160 status NUMBER;
8161 tSqlcode NUMBER;
8162 BEGIN
8163 -- Call fixup and throw away the result
8164 status := compatible_parameter_fixup (result, tSqlcode);
8165 END compatible_parameter_fixup;
8166
8167 FUNCTION compatible_parameter_fixup (
8168 result_txt IN OUT VARCHAR2,
8169 pSqlcode IN OUT NUMBER) RETURN number
8170 IS
8171 BEGIN
8172 result_txt := compatible_parameter_gethelp(c_help_overview);
8173 pSqlcode := 0;
8174 return c_fixup_status_info;
8175 END compatible_parameter_fixup;
8176
8177 -- *****************************************************************
8178 -- DBMS_LDAP_DEPENDENCIES_EXIST Section
8179 -- *****************************************************************
8180 FUNCTION DBMS_LDAP_DEP_EXIST_check (result_txt OUT VARCHAR2) RETURN number
8181 IS
8182 t_null CHAR(1);
8183 status NUMBER := 0;
8184 BEGIN
8185
8186 -- Bug 16213268
8187 -- This LDAP dependency check is ONLY required for upgrades from 10.2
8188 IF (db_n_version NOT IN (102) AND pDBGFailCheck = FALSE) THEN
8189 -- Only valid for 10.2 upgrades
8190 return c_status_not_for_this_version;
8191 END IF;
8192
8193 BEGIN
8194 EXECUTE IMMEDIATE 'SELECT NULL FROM dba_dependencies
8195 WHERE referenced_name IN (''DBMS_LDAP'')
8196 AND owner NOT IN (''SYS'',''PUBLIC'',''ORD_PLUGINS'')
8197 AND rownum <= 1'
8198 INTO t_null;
8199 status := 1;
8200 EXCEPTION
8201 WHEN NO_DATA_FOUND THEN NULL;
8202 END;
8203
8204 IF (status = 0 AND pDBGFailCheck = FALSE)
8205 THEN
8206 RETURN c_status_success;
8207 ELSE
8208 IF pOutputType = c_output_xml THEN
8209 result_txt:= genDBUAXMLCheck('DBMS_LDAP_DEPENDENCIES_EXIST',
8210 c_check_level_warning,
8211 'Database contains schemas with objects dependent on DBMS_LDAP package.'
8212 || ' Refer to the Upgrade Guide for instructions to configure Network ACLs.',
8213 'Database contains schemas with objects dependent on DBMS_LDAP package.',
8214 'Refer to the Upgrade Guide for instructions to configure Network ACLs.',
8215 c_dbua_detail_type_sql,
8216 htmlentities('SELECT name FROM dba_dependencies WHERE'
8217 || ' referenced_name IN (''DBMS_LDAP'') '
8218 || ' AND owner NOT IN (''SYS'',''PUBLIC'',''ORD_PLUGINS'')'
8219 || ' AND rownum <= 1'),
8220 c_dbua_fixup_type_auto,
8221 c_dbua_fixup_stage_pre );
8222 ELSE
8223 result_txt := DBMS_LDAP_DEP_EXIST_gethelp(c_help_overview);
8224 END IF;
8225 IF pOutputFixupScripts THEN
8226 genFixup ('DBMS_LDAP_DEPENDENCIES_EXIST');
8227 END IF;
8228 RETURN c_status_failure;
8229 END IF;
8230 END DBMS_LDAP_DEP_EXIST_check;
8231
8232 FUNCTION DBMS_LDAP_DEP_EXIST_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8233 IS
8234 tmp_cursor cursor_t;
8235 tmp_varchar1 VARCHAR2(512);
8236 tstr VARCHAR2(1000);
8237 result_txt VARCHAR2(4000);
8238 BEGIN
8239 IF HelpType = c_help_overview THEN
8240 result_txt := 'WARNING: --> Existing DBMS_LDAP dependent objects' || crlf
8241 || crlf || ' Database contains schemas with objects dependent on DBMS_LDAP package.'
8242 || crlf || ' Refer to the Upgrade Guide for instructions to configure Network ACLs.';
8243 tstr := '';
8244 OPEN tmp_cursor FOR
8245 'SELECT DISTINCT owner FROM DBA_DEPENDENCIES
8246 WHERE referenced_name IN (''DBMS_LDAP'')
8247 AND owner NOT IN (''SYS'',''PUBLIC'',''ORDPLUGINS'')';
8248 LOOP
8249 FETCH tmp_cursor INTO tmp_varchar1;
8250 EXIT WHEN tmp_cursor%NOTFOUND;
8251 tstr := tstr || crlf || ' USER ' || tmp_varchar1 || ' has dependent objects.';
8252 END LOOP;
8253 IF (tstr IS NOT NULL OR tstr != '' ) THEN
8254 result_txt := result_txt || tstr;
8255 END IF;
8256 CLOSE tmp_cursor;
8257 ELSIF HelpType = c_help_fixup THEN
8258 result_txt := 'Network Objects must be reviewed manually.';
8259 END IF;
8260 RETURN result_txt;
8261 END DBMS_LDAP_DEP_EXIST_gethelp;
8262 --
8263 -- Fixup (Procedure and function)
8264 --
8265 PROCEDURE DBMS_LDAP_DEP_EXIST_fixup
8266 IS
8267 result VARCHAR2(4000);
8268 status NUMBER;
8269 tSqlcode NUMBER;
8270 BEGIN
8271 -- Call fixup and throw away the result
8272 status := DBMS_LDAP_DEP_EXIST_fixup (result, tSqlcode);
8273 END DBMS_LDAP_DEP_EXIST_fixup;
8274
8275 FUNCTION DBMS_LDAP_DEP_EXIST_fixup (
8276 result_txt IN OUT VARCHAR2,
8277 pSqlcode IN OUT NUMBER) RETURN number
8278 IS
8279 BEGIN
8280 result_txt := DBMS_LDAP_DEP_EXIST_gethelp(c_help_overview);
8281 return c_fixup_status_info;
8282 END DBMS_LDAP_DEP_EXIST_fixup;
8283
8284 -- *****************************************************************
8285 -- default_process_count Section
8286 -- *****************************************************************
8287 FUNCTION default_process_count_check (result_txt OUT VARCHAR2) RETURN number
8288 IS
8289 processes NUMBER;
8290 status NUMBER;
8291 BEGIN
8292 EXECUTE IMMEDIATE 'SELECT value FROM V$PARAMETER WHERE NAME=''processes'''
8293 INTO processes;
8294 --
8295 -- Right number of processes (and not debug) or XML
8296 -- output, return success
8297 --
8298 IF ( (processes >= c_max_processes AND pDBGFailCheck = FALSE) OR
8299 pOutputType = c_output_xml ) THEN
8300 RETURN c_status_success;
8301 END IF;
8302
8303 result_txt := default_process_count_gethelp(c_help_overview);
8304
8305 IF pOutputFixupScripts THEN
8306 genFixup ('DEFAULT_PROCESS_COUNT');
8307 END IF;
8308 RETURN c_status_failure;
8309 END default_process_count_check;
8310
8311 FUNCTION default_process_count_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8312 IS
8313 processes NUMBER;
8314 BEGIN
8315 IF HelpType = c_help_overview THEN
8316 EXECUTE IMMEDIATE 'SELECT value FROM V$PARAMETER WHERE NAME=''processes'''
8317 INTO processes;
8318 return 'WARNING: --> Process Count may be too low' || crlf
8319 || crlf || ' Database has a maximum process count of '
8320 || processes || ' which is lower than the'
8321 || crlf || ' default value of ' || c_max_processes || ' for this release.'
8322 || crlf || ' You should update your processes value prior to the upgrade'
8323 || crlf || ' to a value of at least ' || c_max_processes || '.'
8324 || crlf || ' For example:'
8325 || crlf || ' ALTER SYSTEM SET PROCESSES=' || c_max_processes || ' SCOPE=SPFILE'
8326 || crlf || ' or update your init.ora file.';
8327 ELSIF HelpType = c_help_fixup THEN
8328 return 'Review and increase if needed, your PROCESSES value.';
8329 END IF;
8330 END default_process_count_gethelp;
8331 --
8332 -- Fixup (Procedure and function)
8333 --
8334 PROCEDURE default_process_count_fixup
8335 IS
8336 result VARCHAR2(4000);
8337 status NUMBER;
8338 tSqlcode NUMBER;
8339 BEGIN
8340 -- Call fixup and throw away the result
8341 status := default_process_count_fixup (result, tSqlcode);
8342 END default_process_count_fixup;
8343
8344 FUNCTION default_process_count_fixup (
8345 result_txt IN OUT VARCHAR2,
8346 pSqlcode IN OUT NUMBER) RETURN number
8347 IS
8348 BEGIN
8349 result_txt := default_process_count_gethelp(c_help_overview);
8350 return c_fixup_status_info;
8351 END default_process_count_fixup;
8352
8353 -- *****************************************************************
8354 -- DV_ENABLED Section
8355 -- *****************************************************************
8356 FUNCTION DV_ENABLED_check (result_txt OUT VARCHAR2) RETURN number
8357 IS
8358 t_null CHAR(1);
8359 status NUMBER;
8360 BEGIN
8361
8362 IF (db_n_version IN (102,111,112) and pDBGFailCheck = FALSE) THEN
8363 -- 12.1 and above...
8364 return c_status_not_for_this_version;
8365 END IF;
8366
8367 BEGIN
8368 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.registry$ r, v$option o
8369 WHERE r.cid = ''DV'' and r.cname = o.parameter and
8370 o.value = ''TRUE'''
8371 INTO t_null;
8372 status := 1;
8373 EXCEPTION
8374 WHEN NO_DATA_FOUND THEN
8375 status := 0;
8376 END;
8377
8378 IF (status = 0 and pDBGFailCheck = FALSE)
8379 THEN
8380 RETURN c_status_success;
8381 ELSE
8382 IF pOutputType = c_output_xml THEN
8383 result_txt:= genDBUAXMLCheck('DV_ENABLED',
8384 c_check_level_error,
8385 'Database Vault option is currently enabled. Database Vault must be manually disabled prior to upgrade'
8386 || ' and re-enabled after the upgrade.',
8387 'Database Vault option is enabled.',
8388 'Disable the Database Vault option prior to Upgrade',
8389 c_dbua_detail_type_sql,
8390 htmlentities ('SELECT r.cid FROM sys.registry$ r, v$option o '
8391 || 'WHERE r.cid = ''DV'' and r.cname = o.parameter and '
8392 || 'o.value = ''TRUE'''),
8393 c_dbua_fixup_type_manual,
8394 c_dbua_fixup_stage_pre );
8395 ELSE
8396 result_txt := DV_ENABLED_gethelp(c_help_overview);
8397 END IF;
8398 IF pOutputFixupScripts THEN
8399 genFixup ('DV_ENABLED');
8400 END IF;
8401 RETURN c_status_failure;
8402 END IF;
8403 END;
8404
8405 FUNCTION DV_ENABLED_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8406 IS
8407 BEGIN
8408 IF HelpType = c_help_overview THEN
8409 return 'WARNING: --> Oracle Database Vault is enabled in this database' || crlf
8410 || crlf || ' Starting with release 12.1, it is REQUIRED that Database Vault be'
8411 || crlf || ' disabled prior to database upgrade. To disable Database Vault, log'
8412 || crlf || ' in as Database Vault administrator and run this operation:'
8413 || crlf || ' DVSYS.DBMS_MACAMD.DISABLE_DV()';
8414 ELSIF HelpType = c_help_fixup THEN
8415 return 'Database Vault must be disabled prior to upgrading.';
8416 END IF;
8417 END DV_ENABLED_gethelp;
8418 --
8419 -- Fixup (Procedure and function)
8420 --
8421 PROCEDURE DV_ENABLED_fixup
8422 IS
8423 result VARCHAR2(4000);
8424 status NUMBER;
8425 tSqlcode NUMBER;
8426 BEGIN
8427 -- Call fixup and throw away the result
8428 status := DV_ENABLED_fixup (result, tSqlcode);
8429 END DV_ENABLED_fixup;
8430
8431 FUNCTION DV_ENABLED_fixup (
8432 result_txt IN OUT VARCHAR2,
8433 pSqlcode IN OUT NUMBER) RETURN number
8434 IS
8435 BEGIN
8436 -- Dump out the same thing we give for help
8437 result_txt := DV_ENABLED_gethelp(c_help_overview);
8438 return c_fixup_status_info;
8439 END DV_ENABLED_fixup;
8440
8441 -- *****************************************************************
8442 -- EM_PRESENT Section
8443 -- *****************************************************************
8444 FUNCTION EM_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
8445 IS
8446 t_null CHAR(1);
8447 status NUMBER;
8448 BEGIN
8449
8450 BEGIN
8451 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.registry$ WHERE cid=''EM''
8452 AND status NOT IN (99,8)'
8453 INTO t_null;
8454 status := 1;
8455 EXCEPTION
8456 WHEN NO_DATA_FOUND THEN
8457 status := 0;
8458 END;
8459
8460 IF (status = 0 and pDBGFailCheck = FALSE)
8461 THEN
8462 -- EM not here.
8463 RETURN c_status_success;
8464 ELSE
8465 IF pOutputType = c_output_xml THEN
8466 result_txt:= genDBUAXMLCheck('EM_PRESENT',
8467 c_check_level_info,
8468 'Enterprise Manager Database Control repository exists in the database.'
8469 || ' In 12c, the database is managed by MiniGC.'
8470 || ' The Enterprise Manager database Control Repository is removed during the upgrade',
8471 'Enterprise Manager Database Control repository is removed',
8472 'Enterprise Manager data can be migrated.',
8473 c_dbua_detail_type_text,
8474 'The EM Database data can be migrated/removed prior to upgrade.',
8475 c_dbua_fixup_type_auto,
8476 c_dbua_fixup_stage_pre );
8477 ELSE
8478 result_txt := EM_PRESENT_gethelp(c_help_overview);
8479 END IF;
8480 IF pOutputFixupScripts THEN
8481 genFixup ('EM_PRESENT');
8482 END IF;
8483 RETURN c_status_failure;
8484 END IF;
8485 END;
8486
8487 FUNCTION EM_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8488 IS
8489 BEGIN
8490 IF HelpType = c_help_overview THEN
8491 return 'WARNING: --> Enterprise Manager Database Control repository found in the database' || crlf
8492 || crlf || ' In Oracle Database 12c, Database Control is removed during'
8493 || crlf || ' the upgrade. To save time during the Upgrade, this action'
8494 || crlf || ' can be done prior to upgrading using the following steps after'
8495 || crlf || ' copying rdbms/admin/emremove.sql from the new Oracle home'
8496 || crlf || ' - Stop EM Database Control:'
8497 || crlf || ' $> emctl stop dbconsole'
8498 || crlf
8499 || crlf || ' - Connect to the Database using the SYS account AS SYSDBA:'
8500 || crlf
8501 || crlf || ' SET ECHO ON;'
8502 || crlf || ' SET SERVEROUTPUT ON;'
8503 || crlf || ' @emremove.sql'
8504 || crlf || ' Without the set echo and serveroutput commands you will not '
8505 || crlf || ' be able to follow the progress of the script.';
8506 ELSIF HelpType = c_help_fixup THEN
8507 return 'Execute emremove.sql prior to upgrade.';
8508 END IF;
8509 END;
8510 --
8511 -- Fixup (Procedure and function)
8512 --
8513 PROCEDURE EM_PRESENT_fixup
8514 IS
8515 result VARCHAR2(4000);
8516 status NUMBER;
8517 tSqlcode NUMBER;
8518 BEGIN
8519 -- Call fixup and throw away the result
8520 status := EM_PRESENT_fixup (result, tSqlcode);
8521 END;
8522 FUNCTION EM_PRESENT_fixup (
8523 result_txt IN OUT VARCHAR2,
8524 pSqlcode IN OUT NUMBER) RETURN number
8525 IS
8526 BEGIN
8527 -- The removal is done during the upgrade.
8528 -- Dump out the same thing we give for help
8529 result_txt := EM_PRESENT_gethelp(c_help_overview);
8530 return c_fixup_status_info;
8531 END;
8532
8533 -- *****************************************************************
8534 -- ENABLED_INDEXES_TBL Section
8535 -- *****************************************************************
8536 FUNCTION ENABLED_INDEXES_TBL_check (result_txt OUT VARCHAR2) RETURN number
8537 IS
8538 status NUMBER := 0;
8539 t_count INTEGER;
8540 BEGIN
8541 --
8542 -- Check for pre-existing temporary table sys.enabled$indexes.
8543 -- If it exists, then warn the user to DROP SYS.ENABLED$INDEXES.
8544 --
8545 BEGIN
8546 EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM sys.enabled$indexes'
8547 INTO t_count;
8548 IF (t_count >= 0) THEN
8549 status := 1;
8550 END IF;
8551 EXCEPTION
8552 WHEN OTHERS THEN NULL;
8553 END;
8554
8555 IF (status = 0 AND pDBGFailCheck = FALSE)
8556 THEN
8557 RETURN c_status_success;
8558 ELSE
8559 IF pOutputType = c_output_xml THEN
8560 result_txt:= genDBUAXMLCheck('ENABLED_INDEXES_TBL',
8561 c_check_level_warning,
8562 'Table sys.enabled$indexes exists in the database',
8563 'Table sys.enabled$indexes exists in the database',
8564 'Drop table prior to upgrade.',
8565 c_dbua_detail_type_text,
8566 'To view if enabled indexes execute, execute the following'
8567 || ' query: SELECT COUNT(1) FROM SYS.ENABLED$INDEXES',
8568 c_dbua_fixup_type_auto,
8569 c_dbua_fixup_stage_pre);
8570 ELSE
8571 result_txt := ENABLED_INDEXES_TBL_gethelp(c_help_overview);
8572 END IF;
8573 IF pOutputFixupScripts THEN
8574 genFixup ('ENABLED_INDEXES_TBL');
8575 END IF;
8576 RETURN c_status_failure;
8577 END IF;
8578 END ENABLED_INDEXES_TBL_check;
8579
8580 FUNCTION ENABLED_INDEXES_TBL_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8581 IS
8582 BEGIN
8583 IF HelpType = c_help_overview THEN
8584 return 'WARNING: --> Table sys.enabled$indexes exists in the database' || crlf
8585 || crlf || ' DROP TABLE sys.enabled$indexes prior to upgrading the database.';
8586 ELSIF HelpType = c_help_fixup THEN
8587 return 'Drop table sys.enabled$indexes.';
8588 END IF;
8589 END ENABLED_INDEXES_TBL_gethelp;
8590 --
8591 -- Fixup (Procedure and function)
8592 --
8593 PROCEDURE ENABLED_INDEXES_TBL_fixup
8594 IS
8595 result VARCHAR2(4000);
8596 status NUMBER;
8597 tSqlcode NUMBER;
8598 BEGIN
8599 -- Call fixup and throw away the result
8600 status := ENABLED_INDEXES_TBL_fixup (result, tSqlcode);
8601 END ENABLED_INDEXES_TBL_fixup;
8602
8603 FUNCTION ENABLED_INDEXES_TBL_fixup (
8604 result_txt IN OUT VARCHAR2,
8605 pSqlcode IN OUT NUMBER) RETURN number
8606 IS
8607 BEGIN
8608 return execute_sql_statement ('DROP TABLE sys.enabled$indexes', result_txt, pSqlcode);
8609 END ENABLED_INDEXES_TBL_fixup;
8610
8611 -- *****************************************************************
8612 -- EXF_RUL_EXISTS Section
8613 -- *****************************************************************
8614 FUNCTION exf_rul_exists_check (result_txt OUT VARCHAR2) RETURN number
8615 IS
8616 n_status NUMBER := -1;
8617 BEGIN
8618 --
8619 -- See if EXF and/or RUL components exist, they will be
8620 -- removed during the upgrade so let them know they can remove them
8621 -- before the upgrade.
8622 --
8623 BEGIN
8624 EXECUTE IMMEDIATE
8625 'SELECT status FROM sys.registry$ WHERE (cid=''RUL'' OR cid=''EXF'')
8626 WHERE namespace=''SERVER'''
8627 INTO n_status;
8628 EXCEPTION
8629 WHEN OTHERS THEN NULL; -- EXF or RUL not in registry
8630 END;
8631
8632 IF n_status = -1 AND pDBGFailCheck = FALSE THEN
8633 --
8634 -- does not exist
8635 --
8636 return c_status_success;
8637 END IF;
8638
8639 IF pOutputType = c_output_xml THEN
8640 result_txt:= genDBUAXMLCheck('EXF_RUL_EXIST',
8641 c_check_level_info,
8642 'Expression Filter (EXF) or Rules Manager (RUL) exist in database.',
8643 'Expression Filter (EXF) and Rules Manager (RUL) are desupported in 12.1.',
8644 'Expression Filter (EXF) and Rules Manager (RUL) will be removed during the upgrade.',
8645 c_dbua_detail_type_text,
8646 htmlentities('To drop EXF and RUL prior to upgrade'||
8647 ' execute @?/rdbms/admin/catnoexf.sql script'),
8648 c_dbua_fixup_type_auto,
8649 c_dbua_fixup_stage_pre );
8650 ELSE
8651 result_txt := exf_rul_exists_gethelp(c_help_overview);
8652 END IF;
8653
8654 IF pOutputFixupScripts THEN
8655 genFixup ('EXF_RUL_EXISTS');
8656 END IF;
8657 RETURN c_status_failure;
8658 END exf_rul_exists_check ;
8659
8660 FUNCTION exf_rul_exists_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8661 IS
8662 BEGIN
8663 IF HelpType = c_help_overview THEN
8664 return 'INFORMATION: --> Expression Filter (EXF) or Rules Manager (RUL) exist in database and will be removed during the upgrade.' || crlf
8665 || crlf || ' Starting with Oracle Database release 12.1, the Expression Filter (EXF) and Database Rules Manager (RUL)'
8666 || crlf || ' features are desupported and will be removed during the upgrade process. To save time during'
8667 || crlf || ' the upgrade, this action can be done prior to upgrading by executing the ORACLE_HOME/rdbms/admin/catnoexf.sql script.';
8668 ELSIF HelpType = c_help_fixup THEN
8669 return 'Manually execute ORACLE_HOME/rdbms/admin/catnoexf.sql script to remove EXF and RUL.';
8670 END IF;
8671 END exf_rul_exists_gethelp;
8672 --
8673 PROCEDURE exf_rul_exists_fixup
8674 IS
8675 result VARCHAR2(4000);
8676 status NUMBER;
8677 tSqlcode NUMBER;
8678 BEGIN
8679 -- Call fixup and throw away the result
8680 status := exf_rul_exists_fixup (result, tSqlcode);
8681 END exf_rul_exists_fixup;
8682
8683 FUNCTION exf_rul_exists_fixup (
8684 result_txt IN OUT VARCHAR2,
8685 pSqlcode IN OUT NUMBER) RETURN number
8686 IS
8687 BEGIN
8688 result_txt := exf_rul_exists_gethelp(c_help_overview);
8689 pSqlcode := 0;
8690 return c_fixup_status_info;
8691 END exf_rul_exists_fixup;
8692
8693
8694 -- *****************************************************************
8695 -- FILES_NEED_RECOVERY Section
8696 -- *****************************************************************
8697 FUNCTION FILES_NEED_RECOVERY_check (result_txt OUT VARCHAR2) RETURN number
8698 IS
8699 t_null CHAR(1);
8700 status NUMBER;
8701 BEGIN
8702 BEGIN
8703 EXECUTE IMMEDIATE 'SELECT NULL FROM v$recover_file WHERE rownum <=1'
8704 INTO t_null;
8705 status := 1;
8706 EXCEPTION
8707 WHEN NO_DATA_FOUND THEN status := 0;
8708 END;
8709
8710 IF (status = 0 and pDBGFailCheck = FALSE)
8711 THEN
8712 RETURN c_status_success;
8713 ELSE
8714 IF pOutputType = c_output_xml THEN
8715 result_txt:= genDBUAXMLCheck('FILES_NEED_RECOVERY',
8716 c_check_level_warning,
8717 'There are files that need media recovery. Ensure no files need media recovery prior to upgrade.',
8718 'There are files that need media recovery.',
8719 'Ensure no files need recovery.',
8720 c_dbua_detail_type_sql,
8721 htmlentities ('SELECT count(*) FROM v$recover_file WHERE rownum <=1'),
8722 c_dbua_fixup_type_manual,
8723 c_dbua_fixup_stage_pre );
8724 ELSE
8725 result_txt := FILES_NEED_RECOVERY_gethelp(c_help_overview);
8726 END IF;
8727 IF pOutputFixupScripts THEN
8728 genFixup ('FILES_NEED_RECOVERY');
8729 END IF;
8730 RETURN c_status_failure;
8731 END IF;
8732 END;
8733
8734 FUNCTION FILES_NEED_RECOVERY_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8735 IS
8736 BEGIN
8737 IF HelpType = c_help_overview THEN
8738 return 'ERROR: --> There are files which need media recovery' || crlf
8739 || crlf || ' Ensure no files need media recovery prior to upgrade.';
8740 ELSIF HelpType = c_help_fixup THEN
8741 return 'Recover or repair these files prior to upgrade.';
8742 END IF;
8743 END FILES_NEED_RECOVERY_gethelp;
8744 --
8745 -- Fixup (Procedure and function)
8746 --
8747 PROCEDURE FILES_NEED_RECOVERY_fixup
8748 IS
8749 result VARCHAR2(4000);
8750 status NUMBER;
8751 tSqlcode NUMBER;
8752 BEGIN
8753 -- Call fixup and throw away the result
8754 status := FILES_NEED_RECOVERY_fixup (result, tSqlcode);
8755 END FILES_NEED_RECOVERY_fixup;
8756
8757 FUNCTION FILES_NEED_RECOVERY_fixup (
8758 result_txt IN OUT VARCHAR2,
8759 pSqlcode IN OUT NUMBER) RETURN number
8760 IS
8761 BEGIN
8762 -- The removal is done during the upgrade.
8763 -- Dump out the same thing we give for help
8764 result_txt := FILES_NEED_RECOVERY_gethelp(c_help_overview);
8765 return c_fixup_status_info;
8766 END FILES_NEED_RECOVERY_fixup;
8767
8768 -- *****************************************************************
8769 -- FILES_BACKUP_MODE Section
8770 -- *****************************************************************
8771 FUNCTION FILES_BACKUP_MODE_check (result_txt OUT VARCHAR2) RETURN number
8772 IS
8773 roll_exists NUMBER := 1;
8774 t_null CHAR(1);
8775 status NUMBER;
8776 BEGIN
8777
8778 IF (db_n_version NOT IN (102,111,112) and pDBGFailCheck = FALSE) THEN
8779 return c_status_not_for_this_version;
8780 END IF;
8781
8782 BEGIN
8783 EXECUTE IMMEDIATE
8784 'SELECT NULL FROM sys.user$ WHERE (name=''FILES_BACKUP_MODE'' and type#=0)'
8785 INTO t_null;
8786 EXCEPTION
8787 WHEN NO_DATA_FOUND then roll_exists := 0;
8788 END;
8789
8790 IF (roll_exists = 0 and pDBGFailCheck = FALSE)
8791 THEN
8792 RETURN c_status_success;
8793 ELSE
8794 IF pOutputType = c_output_xml THEN
8795 result_txt:= genDBUAXMLCheck('FILES_BACKUP_MODE',
8796 c_check_level_warning,
8797 'There are files in backup mode. Ensure no files are in backup mode prior to upgrade.',
8798 'Ensure no files are in backup mode prior to upgrade.',
8799 'Ensure no files are in backup mode prior to upgrade.',
8800 c_dbua_detail_type_sql,
8801 'SELECT name FROM sys.user$ WHERE (name=''FILES_BACKUP_MODE'' and type#=0)',
8802 c_dbua_fixup_type_manual,
8803 c_dbua_fixup_stage_pre);
8804 ELSE
8805 result_txt := FILES_BACKUP_MODE_gethelp(c_help_overview);
8806 END IF;
8807 IF pOutputFixupScripts THEN
8808 genFixup ('FILES_BACKUP_MODE');
8809 END IF;
8810 RETURN c_status_failure;
8811 END IF;
8812 END FILES_BACKUP_MODE_check;
8813
8814 FUNCTION FILES_BACKUP_MODE_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8815 IS
8816 BEGIN
8817 IF HelpType = c_help_overview THEN
8818 return 'ERROR: --> There are files in backup mode' || crlf
8819 || crlf || ' Ensure no files are in backup mode prior to upgrade.';
8820 ELSIF HelpType = c_help_fixup THEN
8821 return 'Verify that no files are in backup mode prior to upgrade.';
8822 END IF;
8823 END FILES_BACKUP_MODE_gethelp;
8824 --
8825 -- Fixup (Procedure and function)
8826 --
8827 PROCEDURE FILES_BACKUP_MODE_fixup
8828 IS
8829 result VARCHAR2(4000);
8830 status NUMBER;
8831 tSqlcode NUMBER;
8832 BEGIN
8833 -- Call fixup and throw away the result
8834 status := FILES_BACKUP_MODE_fixup (result, tSqlcode);
8835 END FILES_BACKUP_MODE_fixup;
8836
8837 FUNCTION FILES_BACKUP_MODE_fixup (
8838 result_txt IN OUT VARCHAR2,
8839 pSqlcode IN OUT NUMBER) RETURN number
8840 IS
8841 BEGIN
8842 -- Dump out the same thing we give for help
8843 result_txt := FILES_BACKUP_MODE_gethelp(c_help_overview);
8844 return c_fixup_status_info;
8845 END FILES_BACKUP_MODE_fixup;
8846
8847 -- *****************************************************************
8848 -- INVALID_LOG_ARCHIVE_FORMAT Section
8849 -- *****************************************************************
8850 FUNCTION INVALID_LAF_check (result_txt OUT VARCHAR2) RETURN number
8851 IS
8852 laf_format VARCHAR2(4000);
8853 tmp_varchar1 VARCHAR2(512);
8854 t_null CHAR(1);
8855 status NUMBER := 0;
8856 BEGIN
8857
8858 --
8859 -- invalid log_archive_format check
8860 --
8861 -- for 9.x, RDBMS set a default value which did not include %r,
8862 -- which is required by 11.2.
8863 -- Grab the format string, and if its defaulted or not,
8864 -- Only report an error if its NOT defaulted (user set) and it is
8865 -- missing the %r.
8866 --
8867 BEGIN
8868 EXECUTE IMMEDIATE
8869 'SELECT value, isdefault FROM v$parameter WHERE name = ''log_archive_format'''
8870 INTO laf_format, tmp_varchar1;
8871 EXCEPTION WHEN OTHERS THEN NULL;
8872 END;
8873
8874 IF (tmp_varchar1 = 'FALSE') AND
8875 (instr (LOWER(laf_format), '%r') = 0) THEN
8876 --
8877 -- no %[r|R] and we are not defaulted by the system - we have to report something...
8878 --
8879 status := 1;
8880 END IF;
8881
8882 IF (status = 0 AND pDBGFailCheck = FALSE)
8883 THEN
8884 RETURN c_status_success;
8885 ELSE
8886 IF pOutputType = c_output_xml THEN
8887 --
8888 -- DBUA will fix this up by changing the param
8889 -- so its an INFO
8890 --
8891 result_txt:= genDBUAXMLCheck('INVALID_LOG_ARCHIVE_FORMAT',
8892 c_check_level_info,
8893 'Initialization parameter log_archive_format must contain %s, %t and %r.'
8894 || ' Database Upgrade Assistant will update this parameter to database'
8895 || ' default value. This value can be customized after the upgrade.',
8896 'log_archive_format is invalid',
8897 'Update your initialization parameter to a valid value.',
8898 c_dbua_detail_type_sql,
8899 htmlentities('select value from v$parameter where name = ''log_archive_format'''),
8900 c_dbua_fixup_type_manual,
8901 c_dbua_fixup_stage_pre );
8902 ELSE
8903 result_txt := INVALID_LAF_gethelp(c_help_overview);
8904 END IF;
8905 IF pOutputFixupScripts THEN
8906 genFixup ('INVALID_LOG_ARCHIVE_FORMAT');
8907 END IF;
8908 RETURN c_status_failure;
8909 END IF;
8910 END INVALID_LAF_check;
8911
8912 FUNCTION INVALID_LAF_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
8913 IS
8914 format VARCHAR2(4000);
8915 log_mode VARCHAR2(30);
8916 result_txt VARCHAR2(4000);
8917 BEGIN
8918 IF HelpType = c_help_overview THEN
8919 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE name = ''log_archive_format'''
8920 INTO format;
8921 EXECUTE IMMEDIATE 'SELECT LOG_MODE from v$database'
8922 INTO log_mode;
8923 result_txt := 'ERROR: --> log_archive_format must be updated' || crlf
8924 || crlf || ' As of 10.1, log_archive_format requires a %r format qualifier'
8925 || crlf || ' be present in its format string. Your current setting is:'
8926 || crlf || ' log_archive_format=''' || format || '''.';
8927 IF log_mode = 'NOARCHIVELOG' THEN
8928 result_txt := result_txt
8929 || crlf || ' Archive Logging is currently OFF, but failure to add the %r to the'
8930 || crlf || ' format string will still prevent the upgraded database from starting up.';
8931 ELSE
8932 result_txt := result_txt
8933 || crlf || ' Archive Logging is currently ON, and failure to add the %r to the'
8934 || crlf || ' format string will prevent the upgraded database from starting up.';
8935 END IF;
8936 ELSIF HelpType = c_help_fixup THEN
8937 result_txt := 'Update log_archive_format prior to upgrade.';
8938 END IF;
8939 RETURN result_txt;
8940 END INVALID_LAF_gethelp;
8941 --
8942 -- Fixup (Procedure and function)
8943 --
8944 PROCEDURE INVALID_LAF_fixup
8945 IS
8946 result VARCHAR2(4000);
8947 status NUMBER;
8948 tSqlcode NUMBER;
8949 BEGIN
8950 -- Call fixup and throw away the result
8951 status := INVALID_LAF_fixup (result, tSqlcode);
8952 END INVALID_LAF_fixup;
8953
8954 FUNCTION INVALID_LAF_fixup (
8955 result_txt IN OUT VARCHAR2,
8956 pSqlcode IN OUT NUMBER) RETURN number
8957 IS
8958 BEGIN
8959 -- Dump out the same thing we give for help
8960 result_txt := INVALID_LAF_gethelp(c_help_overview);
8961 return c_fixup_status_info;
8962 END INVALID_LAF_fixup;
8963
8964 -- *****************************************************************
8965 -- INVALID_OBJECTS_EXIST Section
8966 -- *****************************************************************
8967 FUNCTION INVALID_OBJ_EXIST_check (result_txt OUT VARCHAR2) RETURN number
8968 IS
8969 t_null CHAR(1);
8970 invalid_objs BOOLEAN := FALSE;
8971 status NUMBER;
8972 tbl_exists NUMBER;
8973 nonsys_invalid_objs NUMBER;
8974 BEGIN
8975 --
8976 -- Check for INVALID objects
8977 -- For "inplace" upgrades check for invalid objects that can be excluded
8978 -- as they may have changed between releases and don't need to be reported.
8979 --
8980 -- For all other types of upgrades, use the simple query below to
8981 -- eliminate running the intricate queries except when they are needed.
8982 --
8983 BEGIN
8984 IF NOT db_inplace_upgrade THEN
8985 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.dba_objects
8986 WHERE status = ''INVALID'' AND object_name NOT LIKE ''BIN$%'' AND
8987 rownum <=1'
8988 INTO t_null;
8989 -- For patch release - update the objects in the query below
8990 ELSE
8991 -- V_$ROLLNAME special cased because of references to x$ tables
8992 EXECUTE IMMEDIATE 'SELECT NULL FROM SYS.DBA_OBJECTS
8993 WHERE status = ''INVALID'' AND object_name NOT LIKE ''BIN$%'' AND
8994 rownum <=1 AND
8995 object_name NOT IN
8996 (SELECT name FROM SYS.dba_dependencies
8997 START WITH referenced_name IN (
8998 ''V$LOGMNR_SESSION'', ''V$ACTIVE_SESSION_HISTORY'',
8999 ''V$BUFFERED_SUBSCRIBERS'', ''GV$FLASH_RECOVERY_AREA_USAGE'',
9000 ''GV$ACTIVE_SESSION_HISTORY'', ''GV$BUFFERED_SUBSCRIBERS'',
9001 ''V$RSRC_PLAN'', ''V$SUBSCR_REGISTRATION_STATS'',
9002 ''GV$STREAMS_APPLY_READER'',''GV$ARCHIVE_DEST'',
9003 ''GV$LOCK'',''DBMS_STATS_INTERNAL'',''V$STREAMS_MESSAGE_TRACKING'',
9004 ''GV$SQL_SHARED_CURSOR'',''V$RMAN_COMPRESSION_ALGORITHM'',
9005 ''V$RSRC_CONS_GROUP_HISTORY'',''V$PERSISTENT_SUBSCRIBERS'',''V$RMAN_STATUS'',
9006 ''GV$RSRC_CONSUMER_GROUP'',''V$ARCHIVE_DEST'',''GV$RSRCMGRMETRIC'',
9007 ''GV$RSRCMGRMETRIC_HISTORY'',''V$PERSISTENT_QUEUES'',''GV$CPOOL_CONN_INFO'',
9008 ''GV$RMAN_COMPRESSION_ALGORITHM'',''DBA_BLOCKERS'',''V$STREAMS_TRANSACTION'',
9009 ''V$STREAMS_APPLY_READER'',''GV$SGA_DYNAMIC_FREE_MEMORY'',''GV$BUFFERED_QUEUES'',
9010 ''GV$RSRC_PLAN_HISTORY'',''GV$ENCRYPTED_TABLESPACES'',''V$ENCRYPTED_TABLESPACES'',
9011 ''GV$RSRC_CONS_GROUP_HISTORY'',''GV$RSRC_PLAN'',
9012 ''GV$RSRC_SESSION_INFO'',''V$RSRCMGRMETRIC'',''V$STREAMS_CAPTURE'',
9013 ''V$RSRCMGRMETRIC_HISTORY'',''GV$STREAMS_TRANSACTION'',''DBMS_LOGREP_UTIL'',
9014 ''V$RSRC_SESSION_INFO'',''GV$STREAMS_CAPTURE'',''V$RSRC_PLAN_HISTORY'',
9015 ''GV$FLASHBACK_DATABASE_LOGFILE'',''V$BUFFERED_QUEUES'',
9016 ''GV$PERSISTENT_SUBSCRIBERS'',''GV$FILESTAT'',''GV$STREAMS_MESSAGE_TRACKING'',
9017 ''V$RSRC_CONSUMER_GROUP'',''V$CPOOL_CONN_INFO'',''DBA_DML_LOCKS'',
9018 ''V$FLASHBACK_DATABASE_LOGFILE'',''GV$HM_RECOMMENDATION'',
9019 ''V$SQL_SHARED_CURSOR'',''GV$PERSISTENT_QUEUES'',''GV$FILE_HISTOGRAM'',
9020 ''DBA_WAITERS'',''GV$SUBSCR_REGISTRATION_STATS'')
9021 AND referenced_type in (''VIEW'',''PACKAGE'') OR
9022 name = ''V_$ROLLNAME''
9023 CONNECT BY
9024 PRIOR name = referenced_name and
9025 PRIOR type = referenced_type)'
9026 INTO t_null;
9027 END IF;
9028 invalid_objs := TRUE;
9029 EXCEPTION
9030 WHEN NO_DATA_FOUND THEN NULL;
9031 END;
9032
9033 -- create a table to store invalid objects (create it if necessary)
9034 IF is_db_readonly = FALSE THEN
9035 tbl_exists := 0;
9036 EXECUTE IMMEDIATE
9037 'SELECT count(*) FROM dba_tables
9038 WHERE table_name = ''REGISTRY$SYS_INV_OBJS'''
9039 INTO tbl_exists;
9040
9041 IF tbl_exists != 0 -- if registry$sys_inv_objs table exists
9042 THEN
9043 -- Truncate table first
9044 EXECUTE IMMEDIATE 'TRUNCATE TABLE registry$sys_inv_objs';
9045
9046 -- Insert into table
9047 EXECUTE IMMEDIATE
9048 'INSERT INTO registry$sys_inv_objs
9049 SELECT owner,object_name,object_type
9050 FROM sys.dba_objects
9051 WHERE status !=''VALID'' AND owner in (''SYS'',''SYSTEM'')
9052 ORDER BY owner';
9053 ELSE
9054 -- Create invalid objects table and populate with all SYS and SYSTEM
9055 -- invalid objects
9056 EXECUTE IMMEDIATE
9057 'CREATE TABLE registry$sys_inv_objs AS
9058 SELECT owner,object_name,object_type
9059 FROM sys.dba_objects
9060 WHERE status !=''VALID'' AND owner in (''SYS'',''SYSTEM'')
9061 ORDER BY owner';
9062 END IF; -- IF/ELSE registry$sys_inv_objs exists
9063
9064 -- If there are less than 5000 non-sys invalid objects then create
9065 -- another table with non-SYS/SYSTEM owned objects.
9066 -- If there are more than 5000 total then that is too many
9067 -- for utluiobj.sql to handle so output a message.
9068 EXECUTE IMMEDIATE 'SELECT count(*) FROM sys.dba_objects
9069 WHERE status !=''VALID'' AND owner NOT in (''SYS'',''SYSTEM'')'
9070 INTO nonsys_invalid_objs;
9071
9072 IF nonsys_invalid_objs < 5000 THEN
9073 tbl_exists := 0;
9074 EXECUTE IMMEDIATE
9075 'SELECT count(*) FROM dba_tables
9076 WHERE table_name = ''REGISTRY$NONSYS_INV_OBJS'''
9077 INTO tbl_exists;
9078
9079 IF tbl_exists != 0 -- if registry$nonsys_inv_objs table exists
9080 THEN
9081 -- Truncate table first
9082 EXECUTE IMMEDIATE 'TRUNCATE TABLE registry$nonsys_inv_objs';
9083
9084 -- Insert into table next
9085 EXECUTE IMMEDIATE
9086 'INSERT INTO registry$nonsys_inv_objs
9087 SELECT owner,object_name,object_type
9088 FROM sys.dba_objects
9089 WHERE status !=''VALID'' AND owner NOT in (''SYS'',''SYSTEM'')
9090 ORDER BY owner';
9091 ELSE -- if table does not exist
9092 -- Create invalid objects table and populate with non-SYS and
9093 -- non-SYSTEM invalid objects
9094 EXECUTE IMMEDIATE
9095 'CREATE TABLE registry$nonsys_inv_objs
9096 AS
9097 SELECT owner,object_name,object_type
9098 FROM sys.dba_objects
9099 WHERE status !=''VALID'' AND owner NOT in (''SYS'',''SYSTEM'')
9100 ORDER BY owner';
9101 END IF; -- IF/ELSE registry$nonsys_inv_objs exists
9102 END IF; -- IF/ELSE nonsys_invalid_objs > 5000
9103 COMMIT;
9104 END IF; -- db NOT readonly
9105
9106 --
9107 -- Now get back to reporting the issue if we need to.
9108 --
9109 IF invalid_objs = FALSE AND pDBGFailCheck = FALSE THEN
9110 RETURN c_status_success;
9111 ELSE
9112 IF pOutputType = c_output_xml THEN
9113 result_txt:= genDBUAXMLCheck('INVALID_OBJECTS_EXIST',
9114 c_check_level_warning,
9115 'There are INVALID objects in the database. Invalid SYS/SYSTEM objects'
9116 || ' was written to REGISTRY$SYS_INV_OBJS. Invalid non-SYS/SYSTEM objects'
9117 || ' was written to REGISTRY$NONSYS_INV_OBJS. Use utluiobj.sql after the'
9118 || ' upgrade to identify any new invalid objects due to the upgrade.',
9119 'Invalid object found in the database.',
9120 'It is recommended that utlprp.sql be run to attempt to validate objects',
9121 c_dbua_detail_type_sql,
9122 'SELECT owner,object_name,object_type from registry$sys_inv_objs',
9123 c_dbua_fixup_type_manual,
9124 c_dbua_fixup_stage_pre);
9125 ELSE
9126 result_txt := INVALID_OBJ_EXIST_gethelp(c_help_overview);
9127 END IF;
9128 IF pOutputFixupScripts THEN
9129 genFixup ('INVALID_OBJECTS_EXIST');
9130 END IF;
9131 RETURN c_status_failure;
9132 END IF;
9133 END INVALID_OBJ_EXIST_check;
9134
9135 FUNCTION INVALID_OBJ_EXIST_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9136 IS
9137 BEGIN
9138 IF HelpType = c_help_overview THEN
9139 return 'WARNING: --> Database contains INVALID objects prior to upgrade' || crlf
9140 || crlf || ' The list of invalid SYS/SYSTEM objects was written to'
9141 || crlf || ' registry$sys_inv_objs.'
9142 || crlf || ' The list of non-SYS/SYSTEM objects was written to'
9143 || crlf || ' registry$nonsys_inv_objs unless there were over 5000.'
9144 || crlf || ' Use utluiobj.sql after the upgrade to identify any new invalid'
9145 || crlf || ' objects due to the upgrade.';
9146 ELSIF HelpType = c_help_fixup THEN
9147 return 'Invalid objects are displayed and must be reviewed.';
9148 END IF;
9149 END INVALID_OBJ_EXIST_gethelp;
9150 --
9151 -- Fixup (Procedure and function)
9152 --
9153 PROCEDURE INVALID_OBJ_EXIST_fixup
9154 IS
9155 result VARCHAR2(4000);
9156 status NUMBER;
9157 tSqlcode NUMBER;
9158 BEGIN
9159 -- Call fixup and throw away the result
9160 status := INVALID_OBJ_EXIST_fixup (result, tSqlcode);
9161 END INVALID_OBJ_EXIST_fixup;
9162
9163 FUNCTION INVALID_OBJ_EXIST_fixup (
9164 result_txt IN OUT VARCHAR2,
9165 pSqlcode IN OUT NUMBER) RETURN number
9166 IS
9167 BEGIN
9168 result_txt := INVALID_OBJ_EXIST_gethelp(c_help_overview);
9169 pSqlcode := 0;
9170 return c_fixup_status_info;
9171 --
9172 -- This could be executed by post-fixup
9173 -- return execute_sql_statement ('@?/rdbms/admin/utlprp.sql', result_txt, pSqlcode);
9174 END INVALID_OBJ_EXIST_fixup;
9175
9176 FUNCTION invalid_obj_exclude RETURN VARCHAR2
9177 --
9178 -- The list of invalid objects to 'accept' as invalid
9179 --
9180 IS
9181 BEGIN
9182 return '''V$LOGMNR_SESSION'', ''V$ACTIVE_SESSION_HISTORY'', ''V$BUFFERED_SUBSCRIBERS'','
9183 || '''GV$FLASH_RECOVERY_AREA_USAGE'', ''GV$ACTIVE_SESSION_HISTORY'','
9184 || '''GV$BUFFERED_SUBSCRIBERS'', ''V$RSRC_PLAN'', ''V$SUBSCR_REGISTRATION_STATS'','
9185 || '''GV$STREAMS_APPLY_READER'',''GV$ARCHIVE_DEST'', ''GV$LOCK'',''DBMS_STATS_INTERNAL'','
9186 || '''V$STREAMS_MESSAGE_TRACKING'', ''GV$SQL_SHARED_CURSOR'',''V$RMAN_COMPRESSION_ALGORITHM'','
9187 || '''V$RSRC_CONS_GROUP_HISTORY'',''V$PERSISTENT_SUBSCRIBERS'',''V$RMAN_STATUS'','
9188 || '''GV$RSRC_CONSUMER_GROUP'',''V$ARCHIVE_DEST'',''GV$RSRCMGRMETRIC'','
9189 || '''GV$RSRCMGRMETRIC_HISTORY'',''V$PERSISTENT_QUEUES'',''GV$CPOOL_CONN_INFO'','
9190 || '''GV$RMAN_COMPRESSION_ALGORITHM'',''DBA_BLOCKERS'',''V$STREAMS_TRANSACTION'','
9191 || '''V$STREAMS_APPLY_READER'',''GV$SGA_DYNAMIC_FREE_MEMORY'',''GV$BUFFERED_QUEUES'','
9192 || '''GV$RSRC_PLAN_HISTORY'',''GV$ENCRYPTED_TABLESPACES'',''V$ENCRYPTED_TABLESPACES'','
9193 || '''GV$RSRC_CONS_GROUP_HISTORY'',''GV$RSRC_PLAN'',''GV$RSRC_SESSION_INFO'','
9194 || '''V$RSRCMGRMETRIC'',''V$STREAMS_CAPTURE'',''V$RSRCMGRMETRIC_HISTORY'','
9195 || '''GV$STREAMS_TRANSACTION'',''DBMS_LOGREP_UTIL'',''V$RSRC_SESSION_INFO'','
9196 || '''GV$STREAMS_CAPTURE'',''V$RSRC_PLAN_HISTORY'',''GV$FLASHBACK_DATABASE_LOGFILE'','
9197 || '''V$BUFFERED_QUEUES'',''GV$PERSISTENT_SUBSCRIBERS'',''GV$FILESTAT'','
9198 || '''GV$STREAMS_MESSAGE_TRACKING'',''V$RSRC_CONSUMER_GROUP'',''V$CPOOL_CONN_INFO'','
9199 || '''DBA_DML_LOCKS'', ''V$FLASHBACK_DATABASE_LOGFILE'',''GV$HM_RECOMMENDATION'','
9200 || '''V$SQL_SHARED_CURSOR'',''GV$PERSISTENT_QUEUES'',''GV$FILE_HISTOGRAM'','
9201 || '''DBA_WAITERS'',''GV$SUBSCR_REGISTRATION_STATS'', ''DBA_KGLLOCK''';
9202 END invalid_obj_exclude;
9203
9204 -- *****************************************************************
9205 -- INVALID_SYS_TABLEDATA Section
9206 -- *****************************************************************
9207 FUNCTION INVALID_SYS_TABLEDATA_check (result_txt OUT VARCHAR2) RETURN number
9208 IS
9209 t_count NUMBER;
9210 status NUMBER;
9211 BEGIN
9212 --
9213 BEGIN
9214 EXECUTE IMMEDIATE 'SELECT COUNT(*) ' ||
9215 'FROM SYS.OBJ$ o, SYS.COL$ c, SYS.COLTYPE$ t, SYS.USER$ u ' ||
9216 'WHERE o.OBJ# = t.OBJ# AND c.OBJ# = t.OBJ# ' ||
9217 'AND c.COL# = t.COL# AND t.INTCOL# = c.INTCOL# ' ||
9218 'AND BITAND(t.FLAGS, 256) = 256 AND o.OWNER# = u.USER# ' ||
9219 'AND o.OWNER# in ' ||
9220 '(SELECT r.schema# FROM SYS.REGISTRY$ r ' ||
9221 'WHERE r.NAMESPACE = ''SERVER'')'
9222 INTO t_count;
9223 EXCEPTION
9224 WHEN NO_DATA_FOUND THEN t_count := 0;
9225 END;
9226
9227 IF (t_count <= 0 and pDBGFailCheck = FALSE)
9228 THEN
9229 -- Nothing to do.
9230 RETURN c_status_success;
9231
9232 ELSE
9233 IF pOutputType = c_output_xml THEN
9234 result_txt:= genDBUAXMLCheck('INVALID_SYS_TABLEDATA',
9235 c_check_level_error,
9236 'Database contains table data which has not been upgraded. Proceeding'
9237 || ' with an Upgrade before upgrading the table data can lead to'
9238 || ' data loss. ',
9239 'Invalid table data found in database.',
9240 'Use "ALTER TABLE ... UPGRADE INCLUDING DATA" prior to upgrade.',
9241 c_dbua_detail_type_text,
9242 'Use "ALTER TABLE ... UPGRADE INCLUDING DATA" prior to upgrade.',
9243 c_dbua_fixup_type_auto,
9244 c_dbua_fixup_stage_validation );
9245 ELSE
9246 result_txt := INVALID_SYS_TABLEDATA_gethelp(c_help_overview);
9247 END IF;
9248 IF pOutputFixupScripts THEN
9249 genFixup ('INVALID_SYS_TABLEDATA');
9250 END IF;
9251 RETURN c_status_failure;
9252 END IF;
9253 END;
9254
9255 FUNCTION INVALID_SYS_TABLEDATA_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9256 IS
9257 BEGIN
9258 IF HelpType = c_help_overview THEN
9259 return 'ERROR: --> Invalid Oracle supplied table data found in your database.' || crlf
9260 || crlf || ' Invalid data can be seen prior to the database upgrade'
9261 || crlf || ' or during PDB plug in. This table data must be made'
9262 || crlf || ' valid BEFORE upgrade or plug in.'
9263 || crlf
9264 || crlf || ' - To fix the data, load the Preupgrade package and execute'
9265 || crlf || ' the fixup routine.'
9266 || crlf || ' For plug in, execute the fix up routine in the PDB.'
9267 || crlf
9268 || crlf || ' @?/rdbms/admin/utluppkg.sql'
9269 || crlf || ' SET SERVEROUTPUT ON;'
9270 || crlf || ' exec dbms_preup.run_fixup_and_report(''INVALID_SYS_TABLEDATA'')'
9271 || crlf || ' SET SERVEROUTPUT OFF;';
9272 ELSIF HelpType = c_help_fixup THEN
9273 return 'UPGRADE Oracle supplied table data prior to the database upgrade.';
9274 END IF;
9275 END;
9276 --
9277 -- Fixup (Procedure and function)
9278 --
9279 PROCEDURE INVALID_SYS_TABLEDATA_fixup
9280 IS
9281 result VARCHAR2(4000);
9282 status NUMBER;
9283 tSqlcode NUMBER;
9284 BEGIN
9285 -- Call fixup and throw away the result
9286 status := INVALID_SYS_TABLEDATA_fixup (result, tSqlcode);
9287 END;
9288 FUNCTION INVALID_SYS_TABLEDATA_fixup (
9289 result_txt IN OUT VARCHAR2,
9290 pSqlcode IN OUT NUMBER) RETURN number
9291 IS
9292 t_cursor cursor_t;
9293 t_tabname sys.obj$.name%TYPE;
9294 t_schema sys.user$.name%TYPE;
9295 t_full_name VARCHAR2(261); -- extra for quotes and .
9296 t_sqltxt VARCHAR2(4000);
9297 t_new_err VARCHAR2(500);
9298 t_error BOOLEAN := FALSE;
9299 t_took_error BOOLEAN := FALSE;
9300 t_sqlcode NUMBER; -- The last sql error we took
9301 t_len NUMBER;
9302
9303 BEGIN
9304 result_txt := '';
9305
9306 OPEN t_cursor FOR 'SELECT DISTINCT (o.NAME), u.NAME ' ||
9307 'FROM SYS.OBJ$ o, SYS.COL$ c, SYS.COLTYPE$ t, SYS.USER$ u ' ||
9308 'WHERE o.OBJ# = t.OBJ# AND c.OBJ# = t.OBJ# ' ||
9309 'AND c.COL# = t.COL# AND t.INTCOL# = c.INTCOL# ' ||
9310 'AND BITAND(t.FLAGS, 256) = 256 AND o.OWNER# = u.USER# ' ||
9311 'AND o.OWNER# in (SELECT r.schema# FROM SYS.REGISTRY$ r ' ||
9312 'WHERE r.NAMESPACE = ''SERVER'')';
9313 LOOP
9314 FETCH t_cursor INTO t_tabname,t_schema;
9315 EXIT WHEN t_cursor%NOTFOUND;
9316 --
9317 -- Put quotes around the schema and table name
9318 --
9319 t_full_name := dbms_assert.enquote_name(t_schema, FALSE) || '.' ||
9320 dbms_assert.enquote_name(t_tabname,FALSE);
9321 BEGIN
9322 EXECUTE IMMEDIATE 'ALTER TABLE ' || t_full_name
9323 || ' UPGRADE INCLUDING DATA';
9324 EXCEPTION WHEN OTHERS THEN
9325 t_error := TRUE;
9326 t_sqltxt := SQLERRM;
9327 t_sqlcode := SQLCODE;
9328 t_took_error := TRUE;
9329 END;
9330
9331 IF t_error THEN
9332 IF result_txt != '' THEN
9333 -- If not the first, add a crlf
9334 result_txt := result_txt || crlf;
9335 END IF;
9336
9337 t_new_err :=
9338 ' Error upgrading: ' || t_full_name || crlf ||
9339 ' Error Text: ' || t_sqltxt || crlf;
9340
9341 --
9342 -- length returns NULL (and not zero) for null varchar2's
9343 --
9344 t_len := NVL(length(result_txt), 0);
9345
9346 IF (t_len + length (t_new_err) <= c_str_max) THEN
9347 --
9348 -- will fit into our buffer
9349 --
9350 result_txt := result_txt || t_new_err;
9351 ELSE
9352 t_new_err := crlf ||
9353 ' *** Too Many Tables ***' || crlf ||
9354 ' *** Cleanup and re-execute to see more tables *** ';
9355 --
9356 -- see if this will fit on the end (should be
9357 -- shorter than the actual error)
9358 --
9359 IF (t_len + length (t_new_err) < c_str_max) THEN
9360 -- Fits
9361 result_txt := result_txt || t_new_err;
9362 ELSE
9363 --
9364 -- Won't fit, cut some off and add the above error
9365 --
9366 result_txt := substr (result_txt, 1, t_len -
9367 length(t_new_err) - 1);
9368 result_txt := result_txt || t_new_err;
9369 END IF;
9370 -- We are done.
9371 EXIT; -- Out of the loop
9372 END IF;
9373 t_error := FALSE; -- Reset error
9374 END IF;
9375 END LOOP;
9376
9377 IF t_took_error THEN
9378 pSqlcode := t_sqlcode; -- Return the last failure code
9379 return c_fixup_status_failure;
9380 ELSE
9381 return c_fixup_status_success;
9382 END IF;
9383 END;
9384
9385 -- *****************************************************************
9386 -- INVALID_USR_TABLEDATA Section
9387 -- *****************************************************************
9388 FUNCTION INVALID_USR_TABLEDATA_check (result_txt OUT VARCHAR2) RETURN number
9389 IS
9390 t_count NUMBER;
9391 status NUMBER;
9392 BEGIN
9393 --
9394 -- Exclude tables returned in the _sys_tabledata version
9395 -- by using NOT IN clause
9396 --
9397 BEGIN
9398 EXECUTE IMMEDIATE 'SELECT COUNT(*) ' ||
9399 'FROM SYS.OBJ$ o, SYS.COL$ c, SYS.COLTYPE$ t, SYS.USER$ u ' ||
9400 'WHERE o.OBJ# = t.OBJ# AND c.OBJ# = t.OBJ# ' ||
9401 'AND c.COL# = t.COL# AND t.INTCOL# = c.INTCOL# ' ||
9402 'AND BITAND(t.FLAGS, 256) = 256 AND o.OWNER# = u.USER# ' ||
9403 'AND o.OWNER# NOT IN ' ||
9404 '(SELECT UNIQUE (d.USER_ID) FROM SYS.DBA_USERS d, ' ||
9405 'SYS.REGISTRY$ r WHERE d.USER_ID = r.SCHEMA# ' ||
9406 'AND r.NAMESPACE=''SERVER'')'
9407 INTO t_count;
9408 EXCEPTION
9409 WHEN NO_DATA_FOUND THEN t_count := 0;
9410 END;
9411
9412 IF (t_count <= 0 and pDBGFailCheck = FALSE)
9413 THEN
9414 -- Nothing to do.
9415 RETURN c_status_success;
9416
9417 ELSE
9418 IF pOutputType = c_output_xml THEN
9419 result_txt:= genDBUAXMLCheck('INVALID_USR_TABLEDATA',
9420 c_check_level_error,
9421 'Database contains user table data which has not been upgraded. Proceeding'
9422 || ' with an Upgrade of the database before upgrading the table data can lead to'
9423 || ' data loss.',
9424 'Invalid user table data found in database.',
9425 'Use "ALTER TABLE ... UPGRADE INCLUDING DATA prior to upgrade.',
9426 c_dbua_detail_type_text,
9427 'Use "ALTER TABLE ... UPGRADE INCLUDING DATA" prior to upgrade.',
9428 c_dbua_fixup_type_auto,
9429 c_dbua_fixup_stage_validation );
9430 ELSE
9431 result_txt := INVALID_USR_TABLEDATA_gethelp(c_help_overview);
9432 END IF;
9433 IF pOutputFixupScripts THEN
9434 genFixup ('INVALID_USR_TABLEDATA');
9435 END IF;
9436 RETURN c_status_failure;
9437 END IF;
9438 END;
9439
9440 FUNCTION INVALID_USR_TABLEDATA_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9441 IS
9442 BEGIN
9443 IF HelpType = c_help_overview THEN
9444 return 'ERROR: --> Invalid user table data found in your database.' || crlf
9445 || crlf || ' Invalid data can be seen prior to the database upgrade'
9446 || crlf || ' or during PDB plug in. This table data must be made'
9447 || crlf || ' valid BEFORE upgrade or plug in.'
9448 || crlf
9449 || crlf || ' - To fix the data, load the Preupgrade package and execute'
9450 || crlf || ' the fixup routine.'
9451 || crlf || ' For plug in, execute the fix up routine in the PDB.'
9452 || crlf
9453 || crlf || ' @?/rdbms/admin/utluppkg.sql'
9454 || crlf || ' SET SERVEROUTPUT ON;'
9455 || crlf || ' exec dbms_preup.run_fixup_and_report(''INVALID_USR_TABLEDATA'');'
9456 || crlf || ' SET SERVEROUTPUT OFF;';
9457 ELSIF HelpType = c_help_fixup THEN
9458 return 'UPGRADE user table data prior to the database upgrade.';
9459 END IF;
9460 END;
9461 --
9462 -- Fixup (Procedure and function)
9463 --
9464 PROCEDURE INVALID_USR_TABLEDATA_fixup
9465 IS
9466 result VARCHAR2(4000);
9467 status NUMBER;
9468 tSqlcode NUMBER;
9469 BEGIN
9470 -- Call fixup and throw away the result
9471 status := INVALID_USR_TABLEDATA_fixup (result, tSqlcode);
9472 END;
9473 FUNCTION INVALID_USR_TABLEDATA_fixup (
9474 result_txt IN OUT VARCHAR2,
9475 pSqlcode IN OUT NUMBER) RETURN number
9476 IS
9477 t_cursor cursor_t;
9478 t_tabname sys.obj$.name%TYPE;
9479 t_schema sys.user$.name%TYPE;
9480 t_full_name VARCHAR2(256);
9481 t_sqltxt VARCHAR2(4000);
9482 t_new_err VARCHAR2(500);
9483 t_error BOOLEAN := FALSE;
9484 t_took_error BOOLEAN := FALSE;
9485 t_sqlcode NUMBER; -- The last sql error we took
9486 t_len NUMBER;
9487
9488 BEGIN
9489 result_txt := '';
9490
9491 OPEN t_cursor FOR 'SELECT DISTINCT (o.NAME), u.NAME ' ||
9492 'FROM SYS.OBJ$ o, SYS.COL$ c, SYS.COLTYPE$ t, SYS.USER$ u ' ||
9493 'WHERE o.OBJ# = t.OBJ# AND c.OBJ# = t.OBJ# ' ||
9494 'AND c.COL# = t.COL# AND t.INTCOL# = c.INTCOL# ' ||
9495 'AND BITAND(t.FLAGS, 256) = 256 AND o.OWNER# = u.USER# ' ||
9496 'AND o.OWNER# NOT IN (SELECT UNIQUE (d.USER_ID) FROM ' ||
9497 'SYS.DBA_USERS d, SYS.REGISTRY$ r WHERE ' ||
9498 'd.USER_ID = r.SCHEMA# AND r.NAMESPACE=''SERVER'')';
9499 LOOP
9500 FETCH t_cursor INTO t_tabname,t_schema;
9501 EXIT WHEN t_cursor%NOTFOUND;
9502 --
9503 -- Put quotes around the schema and table name
9504 --
9505 t_full_name := dbms_assert.enquote_name(t_schema, FALSE) || '.' ||
9506 dbms_assert.enquote_name(t_tabname,FALSE);
9507 BEGIN
9508 EXECUTE IMMEDIATE 'ALTER TABLE ' || t_full_name
9509 || ' UPGRADE INCLUDING DATA';
9510 EXCEPTION WHEN OTHERS THEN
9511 t_error := TRUE;
9512 t_sqltxt := SQLERRM;
9513 t_sqlcode := SQLCODE;
9514 t_took_error := TRUE;
9515 END;
9516
9517 IF t_error THEN
9518 IF result_txt != '' THEN
9519 -- If not the first, add a crlf
9520 result_txt := result_txt || crlf;
9521 END IF;
9522
9523 t_new_err :=
9524 ' Error upgrading: ' || t_full_name || crlf ||
9525 ' Error Text: ' || t_sqltxt || crlf;
9526
9527 --
9528 -- length returns NULL (and not zero) for null varchar2's
9529 --
9530 t_len := NVL(length(result_txt), 0);
9531
9532 IF (t_len + length (t_new_err) <= c_str_max) THEN
9533 --
9534 -- will fit into our buffer
9535 --
9536 result_txt := result_txt || t_new_err;
9537 ELSE
9538 t_new_err := crlf ||
9539 ' *** Too Many Tables ***' || crlf ||
9540 ' *** Cleanup and re-execute to see more tables *** ';
9541 --
9542 -- see if this will fit on the end (should be
9543 -- shorter than the actual error)
9544 --
9545 IF (t_len + length (t_new_err) < c_str_max) THEN
9546 -- Fits
9547 result_txt := result_txt || t_new_err;
9548 ELSE
9549 --
9550 -- Won't fit, cut some off and add the above error
9551 --
9552 result_txt := substr (result_txt, 1, t_len -
9553 length(t_new_err));
9554 result_txt := result_txt || t_new_err;
9555 END IF;
9556 -- We are done.
9557 EXIT; -- Out of the loop
9558 END IF;
9559 t_error := FALSE; -- Reset error
9560 END IF;
9561 END LOOP;
9562
9563 IF t_took_error THEN
9564 pSqlcode := t_sqlcode; -- Return the last failure code
9565 return c_fixup_status_failure;
9566 ELSE
9567 return c_fixup_status_success;
9568 END IF;
9569 END;
9570
9571
9572 -- *****************************************************************
9573 -- job_queue_process Section
9574 -- *****************************************************************
9575 FUNCTION job_queue_process_check (result_txt OUT VARCHAR2) RETURN number
9576 IS
9577 p_count NUMBER := -1;
9578 status NUMBER;
9579 idx NUMBER;
9580 p_lowest NUMBER;
9581 edetails VARCHAR2(500);
9582
9583 BEGIN
9584 BEGIN
9585 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE
9586 name=''job_queue_processes'''
9587 INTO p_count;
9588 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
9589 END;
9590
9591 p_lowest := 0;
9592
9593 --
9594 -- If we failed to grab the count (not set),
9595 -- or the count is > 0 then
9596 -- there is no error
9597 --
9598 IF ( (p_count = -1) OR (p_count > p_lowest)
9599 AND pDBGFailCheck = FALSE) THEN
9600 RETURN c_status_success;
9601 END IF;
9602 --
9603 -- Find the index of this routine in the check_array
9604 --
9605 idx := check_names('JOB_QUEUE_PROCESS').idx;
9606
9607 IF (p_count = 0) THEN
9608 check_table(idx).level := c_check_level_error;
9609 edetails := 'JOB_QUEUE_PROCESSES is set at zero which will cause both '
9610 || 'DBMS_SCHEDULER and DBMS_JOB jobs to not run.';
9611 END IF;
9612
9613 IF pOutputType = c_output_xml THEN
9614 result_txt:= genDBUAXMLCheck('JOB_QUEUE_PROCESS',
9615 check_table(idx).level,
9616 'JOB_QUEUE_PROCESSES value must be updated.',
9617 edetails,
9618 'Either remove setting of JOB_QUEUE_PROCESSES value ' ||
9619 'or set it to a value greater than ' || to_char(p_lowest) ||
9620 '.',
9621 c_dbua_detail_type_text,
9622 'Either remove setting of JOB_QUEUE_PROCESSES value ' ||
9623 'or set it to a value greater than ' || to_char(p_lowest) ||
9624 '.',
9625 c_dbua_fixup_type_manual,
9626 c_dbua_fixup_stage_pre );
9627 ELSE
9628 result_txt := JOB_QUEUE_PROCESS_gethelp(c_help_overview);
9629 END IF;
9630 IF pOutputFixupScripts THEN
9631 genFixup ('JOB_QUEUE_PROCESS');
9632 END IF;
9633 RETURN c_status_failure;
9634 END job_queue_process_check;
9635
9636 FUNCTION job_queue_process_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9637 IS
9638 p_count NUMBER := -1;
9639 error_level NUMBER;
9640 status NUMBER;
9641 result_txt VARCHAR2(4000);
9642
9643 BEGIN
9644 IF HelpType = c_help_overview THEN
9645 BEGIN
9646 EXECUTE IMMEDIATE 'SELECT value FROM v$parameter WHERE
9647 name=''job_queue_processes'''
9648 INTO p_count;
9649 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
9650 END;
9651 result_txt := 'ERROR: --> job_queue_processes set to zero' || crlf
9652 || crlf || ' Starting with Oracle Database 11g Release 2 (11.2), setting'
9653 || crlf || ' JOB_QUEUE_PROCESSES to 0 causes both DBMS_SCHEDULER and'
9654 || crlf || ' DBMS_JOB jobs to not run. Previously, setting JOB_QUEUE_PROCESSES'
9655 || crlf || ' to 0 caused DBMS_JOB jobs to not run, but DBMS_SCHEDULER jobs were'
9656 || crlf || ' unaffected and would still run.';
9657
9658 -- Now add the rest
9659 result_txt := result_txt
9660 || crlf || ' This parameter must be removed or updated to a value greater'
9661 || crlf || ' than 0 (default value if not defined is 1000) prior to upgrade.'
9662 || crlf || ' Not doing so will affect the running of features that rely on'
9663 || crlf || ' this parameter, such as utlrp.sql after the upgrade.'
9664 || crlf || crlf || ' Update your init.ora or spfile to make this change.';
9665 ELSIF HelpType = c_help_fixup THEN
9666 result_txt := 'Review and increase or remove the setting of job_queue_processes';
9667 END IF;
9668 RETURN result_txt;
9669 END job_queue_process_gethelp;
9670 --
9671 -- Fixup (Procedure and function)
9672 --
9673 PROCEDURE job_queue_process_fixup
9674 IS
9675 result VARCHAR2(4000);
9676 status NUMBER;
9677 tSqlcode NUMBER;
9678 BEGIN
9679 -- Call fixup and throw away the result
9680 status := job_queue_process_fixup (result, tSqlcode);
9681 END job_queue_process_fixup;
9682
9683 FUNCTION job_queue_process_fixup (
9684 result_txt IN OUT VARCHAR2,
9685 pSqlcode IN OUT NUMBER) RETURN number
9686 IS
9687 BEGIN
9688 result_txt := job_queue_process_gethelp(c_help_overview);
9689 return c_fixup_status_info;
9690 END job_queue_process_fixup;
9691
9692 -- *****************************************************************
9693 -- NACL_OBJECTS_EXIST Section
9694 -- *****************************************************************
9695 FUNCTION nacl_objects_exist_check (result_txt OUT VARCHAR2) RETURN number
9696 IS
9697 t_null CHAR(1);
9698 status NUMBER := 0;
9699 BEGIN
9700 IF (db_n_version NOT IN (102) AND pDBGFailCheck = FALSE) THEN
9701 -- Only valid for 10.2 upgrades
9702 return c_status_not_for_this_version;
9703 END IF;
9704 BEGIN
9705 EXECUTE IMMEDIATE 'SELECT NULL FROM dba_dependencies
9706 WHERE referenced_name IN (''DBMS_LDAP'')
9707 AND owner NOT IN (''SYS'',''PUBLIC'',''ORD_PLUGINS'')
9708 AND rownum <= 1'
9709 INTO t_null;
9710 status := 1;
9711 EXCEPTION
9712 WHEN NO_DATA_FOUND THEN NULL;
9713 END;
9714
9715 IF (status = 0 AND pDBGFailCheck = FALSE)
9716 THEN
9717 RETURN c_status_passed;
9718 END IF;
9719 IF pOutputType = c_output_xml THEN
9720 result_txt:= genDBUAXMLCheck('NACL_OBJECTS_EXIST',
9721 c_check_level_warning,
9722 'Database contains schemas with objects dependent on network packages.',
9723 'Database contains schemas with objects dependent on network packages.',
9724 'Refer to the Upgrade Guide for instructions to configure Network ACLs',
9725 c_dbua_detail_type_text,
9726 'Refer to the Upgrade Guide for instructions on how to re-configure Network ACLs.',
9727 c_dbua_fixup_type_manual,
9728 c_dbua_fixup_stage_pre );
9729 ELSE
9730 result_txt := nacl_objects_exist_gethelp(c_help_overview);
9731 END IF;
9732 IF pOutputFixupScripts THEN
9733 genFixup ('NACL_OBJECTS_EXIST');
9734 END IF;
9735 RETURN c_status_failure;
9736 END nacl_objects_exist_check;
9737
9738 FUNCTION nacl_objects_exist_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9739 IS
9740 owner VARCHAR2(128);
9741 tstr VARCHAR2(1000); -- Because of loop issues, use temp str
9742 tmp_cursor cursor_t;
9743 result_txt VARCHAR2(4000);
9744 BEGIN
9745 IF HelpType = c_help_overview THEN
9746 result_txt := 'WARNING: --> Existing schemas with network ACLs exist' || crlf
9747 || crlf || ' Database contains schemas with objects dependent on network packages.'
9748 || crlf || ' Refer to the Upgrade Guide for instructions to configure Network ACLs.';
9749
9750 tstr := '';
9751 OPEN tmp_cursor FOR
9752 'SELECT DISTINCT owner FROM DBA_DEPENDENCIES'
9753 || ' WHERE referenced_name IN'
9754 || ' (''UTL_TCP'',''UTL_SMTP'',''UTL_MAIL'',''UTL_HTTP'',''UTL_INADDR'')'
9755 || ' AND owner NOT IN (''SYS'',''PUBLIC'',''ORDPLUGINS'')';
9756 LOOP
9757 FETCH tmp_cursor INTO owner;
9758 EXIT WHEN tmp_cursor%NOTFOUND;
9759 tstr := tstr
9760 || crlf || ' USER ' || owner || ' has dependent objects.';
9761 END LOOP;
9762 CLOSE tmp_cursor;
9763 IF (tstr IS NOT NULL OR tstr != '' ) THEN
9764 result_txt := result_txt || tstr;
9765 END IF;
9766
9767 tstr := '';
9768 OPEN tmp_cursor FOR
9769 'SELECT DISTINCT owner FROM all_tab_columns'
9770 || ' WHERE data_type IN'
9771 || ' (''ORDIMAGE'', ''ORDAUDIO'', ''ORDVIDEO'', ''ORDDOC'','
9772 || ' ''ORDSOURCE'', ''ORDDICOM'') AND'
9773 || ' (data_type_owner = ''ORDSYS'' OR'
9774 || ' data_type_owner = owner) AND'
9775 || ' (owner != ''PM'')';
9776 LOOP
9777 FETCH tmp_cursor INTO owner;
9778 EXIT WHEN tmp_cursor%NOTFOUND;
9779 tstr := tstr
9780 || crlf || ' USER ' || owner || ' uses interMedia and may have dependent objects.';
9781 END LOOP;
9782 CLOSE tmp_cursor;
9783 IF (tstr IS NOT NULL OR tstr != '' ) THEN
9784 result_txt := result_txt || tstr;
9785 END IF;
9786 ELSIF HelpType = c_help_fixup THEN
9787 result_txt := 'Objects with network acls are displayed and need to be reviewed.';
9788 END IF;
9789 RETURN result_txt;
9790 END nacl_objects_exist_gethelp;
9791 --
9792 -- Fixup (Procedure and function)
9793 --
9794 PROCEDURE nacl_objects_exist_fixup
9795 IS
9796 result VARCHAR2(4000);
9797 status NUMBER;
9798 tSqlcode NUMBER;
9799 BEGIN
9800 -- Call fixup and throw away the result
9801 status := nacl_objects_exist_fixup (result, tSqlcode);
9802 END nacl_objects_exist_fixup;
9803
9804 FUNCTION nacl_objects_exist_fixup (
9805 result_txt IN OUT VARCHAR2,
9806 pSqlcode IN OUT NUMBER) RETURN number
9807 IS
9808 BEGIN
9809 -- Dump out the same thing we give for help
9810 result_txt := nacl_objects_exist_gethelp(c_help_overview);
9811 return c_fixup_status_info;
9812 END nacl_objects_exist_fixup;
9813
9814 -- *****************************************************************
9815 -- NEW_TIME_ZONES_EXIST Section
9816 -- *****************************************************************
9817 FUNCTION NEW_TIME_ZONES_EXIST_check (result_txt OUT VARCHAR2) RETURN number
9818 IS
9819 status NUMBER;
9820 BEGIN
9821 IF db_tz_version <= c_tz_version AND pDBGFailCheck = FALSE
9822 THEN
9823 RETURN c_status_success; -- success
9824 ELSE
9825 IF pOutputType = c_output_xml THEN
9826 result_txt:= genDBUAXMLCheck('NEW_TIME_ZONES_EXIST',
9827 c_check_level_error,
9828 'Your database contains a time zone file newer than that of the new Oracle software.',
9829 'Your database contains a time zone file newer than that of the new Oracle software.',
9830 'Patch new oracle home with time zone file equivalent to existing Oracle database.',
9831 c_dbua_detail_type_text,
9832 'SELECT version from v$timezone_file',
9833 c_dbua_fixup_type_manual,
9834 c_dbua_fixup_stage_pre );
9835 ELSE
9836 result_txt := NEW_TIME_ZONES_EXIST_gethelp(c_help_overview);
9837 END IF;
9838 IF pOutputFixupScripts THEN
9839 genFixup ('NEW_TIME_ZONES_EXIST');
9840 END IF;
9841 RETURN c_status_failure;
9842 END IF;
9843 END NEW_TIME_ZONES_EXIST_check;
9844
9845 FUNCTION NEW_TIME_ZONES_EXIST_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9846 IS
9847 BEGIN
9848 IF HelpType = c_help_overview THEN
9849 return 'ERROR: --> New Timezone File in use' || crlf
9850 || crlf || ' Database is using a time zone file newer than version '
9851 || c_tz_version || '.'
9852 || crlf || ' BEFORE upgrading the database, patch the new '
9853 || crlf || ' ORACLE_HOME/oracore/zoneinfo/ with a time zone data file of the'
9854 || crlf || ' same version as the one used in the ' || db_version
9855 || ' release database.';
9856 ELSIF HelpType = c_help_fixup THEN
9857 return 'Time zone data file must be updated in the new ORACLE_HOME.';
9858 END IF;
9859 END NEW_TIME_ZONES_EXIST_gethelp;
9860 --
9861 -- Fixup (Procedure and function)
9862 --
9863 PROCEDURE NEW_TIME_ZONES_EXIST_fixup
9864 IS
9865 result VARCHAR2(4000);
9866 status NUMBER;
9867 tSqlcode NUMBER;
9868 BEGIN
9869 -- Call fixup and throw away the result
9870 status := NEW_TIME_ZONES_EXIST_fixup (result, tSqlcode);
9871 END NEW_TIME_ZONES_EXIST_fixup;
9872
9873 FUNCTION NEW_TIME_ZONES_EXIST_fixup (
9874 result_txt IN OUT VARCHAR2,
9875 pSqlcode IN OUT NUMBER) RETURN number
9876 IS
9877 BEGIN
9878 -- Dump out the same thing we give for help
9879 result_txt := NEW_TIME_ZONES_EXIST_gethelp(c_help_overview);
9880 return c_fixup_status_info;
9881 END NEW_TIME_ZONES_EXIST_fixup;
9882 -- *****************************************************************
9883 -- OCM_USER_PRESENT Section
9884 -- *****************************************************************
9885 FUNCTION OCM_USER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
9886 IS
9887 user_exists BOOLEAN;
9888 tmp_num1 NUMBER;
9889 status NUMBER;
9890 t_null CHAR(1);
9891 BEGIN
9892
9893 IF (db_n_version NOT IN (102,111) AND pDBGFailCheck = FALSE) THEN
9894 return c_status_not_for_this_version;
9895 END IF;
9896
9897 user_exists := TRUE;
9898 BEGIN
9899 EXECUTE IMMEDIATE
9900 'SELECT user# from SYS.USER$ WHERE name=''ORACLE_OCM'''
9901 INTO tmp_num1;
9902 EXCEPTION WHEN NO_DATA_FOUND then user_exists := FALSE;
9903 END;
9904
9905 IF user_exists THEN
9906 BEGIN
9907 EXECUTE IMMEDIATE
9908 'SELECT NULL FROM sys.obj$ WHERE owner# = (SELECT user# from SYS.USER$
9909 WHERE name=''ORACLE_OCM'') AND
9910 name =''MGMT_DB_LL_METRICS'' AND type# = 9'
9911 INTO t_null;
9912 EXCEPTION
9913 WHEN NO_DATA_FOUND then user_exists := TRUE;
9914 END;
9915 END IF;
9916
9917 IF user_exists = FALSE AND pDBGFailCheck = FALSE
9918 THEN
9919 RETURN c_status_success; -- No user, not debug
9920 ELSE
9921 IF pOutputType = c_output_xml THEN
9922 result_txt:= genDBUAXMLCheck('OCM_USER_PRESENT',
9923 c_check_level_warning,
9924 'User OCM present in database',
9925 'User OCM present in database',
9926 'Remove OCM user from the database prior to Upgrade',
9927 c_dbua_detail_type_text,
9928 'The OCM internal account is present in your database'
9929 || ' and should be dropped prior to upgrading',
9930 c_dbua_fixup_type_auto,
9931 c_dbua_fixup_stage_pre);
9932 ELSE
9933 result_txt := ocm_user_present_gethelp(c_help_overview);
9934 END IF;
9935 IF pOutputFixupScripts THEN
9936 genFixup ('OCM_USER_PRESENT');
9937 END IF;
9938 RETURN c_status_failure;
9939 END IF;
9940 END OCM_USER_PRESENT_check;
9941
9942 FUNCTION OCM_USER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
9943 IS
9944 BEGIN
9945 IF HelpType = c_help_overview THEN
9946 return 'WARNING: --> "ORACLE_OCM" user found in database' || crlf
9947 || crlf || ' This is an internal account used by Oracle Configuration Manager. '
9948 || crlf || ' Please drop this user prior to upgrading.';
9949 ELSIF HelpType = c_help_fixup THEN
9950 return 'Drop the ORACLE_OCM user.';
9951 END IF;
9952 END OCM_USER_PRESENT_gethelp;
9953 --
9954 -- Fixup (Procedure and function)
9955 --
9956 PROCEDURE OCM_USER_PRESENT_fixup
9957 IS
9958 result VARCHAR2(4000);
9959 status NUMBER;
9960 tSqlcode NUMBER;
9961 BEGIN
9962 -- Call fixup and throw away the result
9963 status := OCM_USER_PRESENT_fixup (result, tSqlcode);
9964 END OCM_USER_PRESENT_fixup;
9965
9966 FUNCTION OCM_USER_PRESENT_fixup (
9967 result_txt IN OUT VARCHAR2,
9968 pSqlcode IN OUT NUMBER) RETURN number
9969 IS
9970 BEGIN
9971 return execute_sql_statement ('DROP USER ORACLE_OCM CASCADE', result_txt, pSqlcode);
9972 END OCM_USER_PRESENT_fixup;
9973
9974 -- *****************************************************************
9975 -- OLD_TIME_ZONES_EXISTS Section
9976 -- *****************************************************************
9977 FUNCTION old_time_zones_exist_check (result_txt OUT VARCHAR2) RETURN number
9978 IS
9979 status NUMBER;
9980 BEGIN
9981 --
9982 -- Do we have a valid time zone for an upgrade
9983 --
9984 IF db_tz_version < c_tz_version OR pDBGFailCheck THEN
9985 IF pOutputType = c_output_xml THEN
9986 result_txt:= genDBUAXMLCheck('OLD_TIME_ZONES_EXIST',
9987 c_check_level_warning,
9988 'Database is using a time zone file older than shipped with the new Oracle Software',
9989 'Your time zone file must be updated, this can be done after the Upgrade is executed.',
9990 'Execute the dbms_dst package after your database is upgraded.',
9991 c_dbua_detail_type_text,
9992 'Execute the dbms_dst package after your database is upgraded.',
9993 c_dbua_fixup_type_auto,
9994 c_dbua_fixup_stage_pre);
9995 ELSE
9996 result_txt := old_time_zones_exist_gethelp(c_help_overview);
9997 END IF;
9998 IF pOutputFixupScripts THEN
9999 genFixup ('OLD_TIME_ZONES_EXIST');
10000 END IF;
10001 RETURN c_status_failure;
10002 END IF;
10003 RETURN c_status_success;
10004 END old_time_zones_exist_check ;
10005
10006 FUNCTION old_time_zones_exist_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10007 IS
10008 BEGIN
10009 IF HelpType = c_help_overview THEN
10010 return 'INFORMATION: --> Older Timezone in use' || crlf
10011 || crlf || ' Database is using a time zone file older than version '
10012 || c_tz_version || '.'
10013 || crlf || ' After the upgrade, it is recommended that DBMS_DST package'
10014 || crlf || ' be used to upgrade the ' || db_version || ' database time zone version'
10015 || crlf || ' to the latest version which comes with the new release.'
10016 || crlf || ' Please refer to My Oracle Support note number 1509653.1 for details.';
10017 ELSIF HelpType = c_help_fixup THEN
10018 return 'Update the timezone using the DBMS_DST package after upgrade is complete.';
10019 END IF;
10020 END old_time_zones_exist_gethelp;
10021 --
10022 PROCEDURE old_time_zones_exist_fixup
10023 IS
10024 result VARCHAR2(4000);
10025 status NUMBER;
10026 tSqlcode NUMBER;
10027 BEGIN
10028 -- Call fixup and throw away the result
10029 status := old_time_zones_exist_fixup (result, tSqlcode);
10030 END old_time_zones_exist_fixup;
10031
10032 FUNCTION old_time_zones_exist_fixup (
10033 result_txt IN OUT VARCHAR2,
10034 pSqlcode IN OUT NUMBER) RETURN number
10035 IS
10036 BEGIN
10037 result_txt := old_time_zones_exist_gethelp(c_help_overview);
10038 pSqlcode := 0;
10039 return c_fixup_status_info;
10040 END old_time_zones_exist_fixup;
10041 -- *****************************************************************
10042 -- ols_sys_move Section
10043 -- *****************************************************************
10044 FUNCTION ols_sys_move_check (result_txt OUT VARCHAR2) RETURN number
10045 IS
10046 preaud_cnt INTEGER := 0;
10047 status NUMBER := -1;
10048 condition_exists BOOLEAN := FALSE;
10049 BEGIN
10050 -- system.aud$ doesn't exist in releases starting in 12.1, its already
10051 -- present in sys.aud$
10052 IF (db_n_version NOT IN (102, 111, 112) AND pDBGFailCheck = FALSE) THEN
10053 RETURN c_status_success;
10054 END IF;
10055
10056 BEGIN
10057 -- Check if OLS is installed in previous version
10058 EXECUTE IMMEDIATE 'SELECT status FROM sys.registry$ WHERE cid=''OLS''
10059 AND namespace=''SERVER'''
10060 INTO status;
10061 EXCEPTION WHEN OTHERS THEN NULL;
10062 END;
10063
10064 -- bug 16317592: check if SYS.aud$ already exists. may be upgrade
10065 -- script was run before. If SYS.aud$ exists, don't do anything
10066 SELECT count(*) INTO preaud_cnt FROM dba_tables
10067 WHERE table_name = 'AUD$' AND owner = 'SYS';
10068
10069 IF ((status != -1) AND (preaud_cnt != 1)) THEN
10070 BEGIN
10071 --
10072 -- This check means the ols script has not been executed
10073 --
10074 EXECUTE IMMEDIATE 'SELECT count(*) FROM dba_tables where OWNER=''SYS'' AND table_name=''PREUPG_AUD$'''
10075 into preaud_cnt;
10076 IF preaud_cnt = 0 THEN
10077 condition_exists := TRUE;
10078 END IF;
10079 END;
10080 END IF;
10081
10082 IF (condition_exists = FALSE AND
10083 pDBGFailCheck = FALSE) THEN
10084 RETURN c_status_success;
10085 END IF;
10086
10087 IF pOutputType = c_output_xml THEN
10088 result_txt:= genDBUAXMLCheck('OLS_SYS_MOVE',
10089 c_check_level_error,
10090 'olspreupgrade.sql has not been executed on this database',
10091 'Oracle requires that olspreupgrade.sql be executed to move audit records into the correct table.',
10092 'The script rdbms/admin/olspreupgrade.sql must be executed to move records over prior to the upgrade.',
10093 c_dbua_detail_type_text,
10094 'To view the number of records that will be moved use the command: SELECT count(*) from system.aud$',
10095 c_dbua_fixup_type_manual,
10096 c_dbua_fixup_stage_pre);
10097 ELSE
10098 result_txt := ols_sys_move_gethelp (c_help_overview);
10099 END IF;
10100 IF pOutputFixupScripts THEN
10101 genFixup ('OLS_SYS_MOVE');
10102 END IF;
10103 RETURN c_status_failure;
10104 END ols_sys_move_check;
10105
10106 FUNCTION ols_sys_move_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10107 IS
10108 aud_rowcnt INTEGER := -1;
10109 result_txt VARCHAR2(4000);
10110 BEGIN
10111 IF HelpType = c_help_overview THEN
10112 BEGIN
10113 EXECUTE IMMEDIATE 'SELECT count(*) FROM SYSTEM.aud$'
10114 INTO aud_rowcnt;
10115 EXCEPTION
10116 WHEN OTHERS THEN NULL;
10117 END;
10118
10119 --
10120 -- In debug mode we want both messages to come out.
10121 --
10122 IF aud_rowcnt = -1 OR pDBGFailCheck = TRUE THEN
10123 result_txt := 'ERROR: --> SYSTEM.AUD$ (audit records) Move'
10124 || crlf || crlf || ' An error occured retrieving a count from SYSTEM.AUD$'
10125 || crlf || ' This can happen when the table has already been cleaned up.'
10126 || crlf || ' The olspreupgrade.sql script should be re-executed.';
10127 END IF;
10128
10129 IF aud_rowcnt != -1 OR pDBGFailCheck = TRUE THEN
10130 result_txt := 'ERROR: --> SYSTEM.AUD$ (audit records) Move'
10131 || crlf || crlf || ' Oracle requires that records in the audit table SYSTEM.AUD$ be moved'
10132 || crlf || ' to SYS.AUD$ prior to upgrading..'
10133 || crlf || crlf || ' The Database has ' || aud_rowcnt || ' rows in SYSTEM.AUD$ which'
10134 || crlf || ' will be moved during the upgrade.'
10135 || crlf || crlf || ' The downtime during the upgrade will be affected if there are a'
10136 || crlf || ' large number of rows to be moved.'
10137 || crlf || crlf || ' The audit data can be moved manually prior to the upgrade by using'
10138 || crlf || ' the script: rdbms/admin/olspreupgrade.sql which is part of the'
10139 || crlf || ' Oracle Database 12c software.'
10140 || crlf || ' Please refer to the Label Security Administrator guide or'
10141 || crlf || ' the Database Upgrade guide.';
10142 END IF;
10143 ELSIF HelpType = c_help_fixup THEN
10144 result_txt := 'Execute olspreupgrade.sql script prior to upgrade.';
10145 END IF;
10146 RETURN result_txt;
10147 END ols_sys_move_gethelp;
10148 --
10149 -- Fixup (Procedure and function)
10150 --
10151 PROCEDURE ols_sys_move_fixup
10152 IS
10153 result VARCHAR2(4000);
10154 status NUMBER;
10155 tSqlcode NUMBER;
10156 BEGIN
10157 -- Call fixup and throw away the result
10158 status := ols_sys_move_fixup (result, tSqlcode);
10159 END ols_sys_move_fixup;
10160
10161 FUNCTION ols_sys_move_fixup (
10162 result_txt IN OUT VARCHAR2,
10163 pSqlcode IN OUT NUMBER) RETURN number
10164 IS
10165 BEGIN
10166 result_txt := ols_sys_move_gethelp(c_help_overview);
10167 return c_fixup_status_info;
10168 END ols_sys_move_fixup;
10169
10170 -- *****************************************************************
10171 -- ORDIMAGEINDEX Section
10172 -- *****************************************************************
10173 FUNCTION ORDIMAGEINDEX_check (result_txt OUT VARCHAR2) RETURN number
10174 IS
10175 t_count NUMBER := 0;
10176 status NUMBER;
10177 BEGIN
10178 --
10179 -- The upgrade will remove them, so the misc warning section will
10180 -- let them know.
10181 --
10182 BEGIN
10183 EXECUTE IMMEDIATE
10184 'SELECT COUNT(*) FROM sys.dba_indexes WHERE index_type = ''DOMAIN''
10185 and ityp_name = ''ORDIMAGEINDEX'''
10186 INTO t_count;
10187 EXCEPTION
10188 WHEN OTHERS THEN NULL;
10189 END;
10190
10191 IF (t_count = 0 AND pDBGFailCheck = FALSE) THEN
10192 RETURN c_status_success;
10193 ELSE
10194 IF pOutputType = c_output_xml THEN
10195 result_txt:= genDBUAXMLCheck('ORDIMAGEINDEX',
10196 c_check_level_info,
10197 'Ordsys.OrdImageIndex is in use. These images are dropped as part of the upgrade',
10198 'Ordsys.OrdImageIndex is in use',
10199 'Images are cleaned up as part of the upgrade process.',
10200 c_dbua_detail_type_sql,
10201 htmlentities('SELECT COUNT(*) FROM sys.dba_indexes WHERE index_type'
10202 || ' = ''DOMAIN'' and ityp_name = ''ORDIMAGEINDEX'''),
10203 c_dbua_fixup_type_auto,
10204 c_dbua_fixup_stage_pre );
10205 ELSE
10206 result_txt := ORDIMAGEINDEX_gethelp(c_help_overview);
10207 END IF;
10208 IF pOutputFixupScripts THEN
10209 genFixup ('ORDIMAGEINDEX');
10210 END IF;
10211 RETURN c_status_failure;
10212 END IF;
10213 END ORDIMAGEINDEX_check;
10214
10215 FUNCTION ORDIMAGEINDEX_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10216 IS
10217 tmp_cursor cursor_t;
10218 tmp_varchar1 VARCHAR2(512);
10219 tmp_varchar2 VARCHAR2(512);
10220 tstr VARCHAR2(1000);
10221 result_txt VARCHAR2(4000);
10222 BEGIN
10223 IF HelpType = c_help_overview THEN
10224 result_txt := 'INFORMATION: --> ORDSYS.OrdImageIndex in use' || crlf
10225 || crlf || ' The previously desupported Oracle Multimedia image domain index,'
10226 || crlf || ' ORDSYS.OrdImageIndex, is no longer supported and has been removed in '
10227 || crlf || ' Oracle Database 11g Release 2 (11.2). '
10228 || crlf || ' Following is the list of affected indexes that are dropped'
10229 || crlf || ' during the upgrade.';
10230 OPEN tmp_cursor FOR
10231 'SELECT dbai.index_name, dbai.owner FROM SYS.DBA_INDEXES dbai
10232 WHERE dbai.index_type = ''DOMAIN'' AND
10233 dbai.ityp_name = ''ORDIMAGEINDEX''
10234 ORDER BY dbai.owner';
10235 tstr := '';
10236 LOOP
10237 FETCH tmp_cursor INTO tmp_varchar1, tmp_varchar2;
10238 EXIT WHEN tmp_cursor%NOTFOUND;
10239 tstr := tstr || crlf || ' USER: ' || RPAD(tmp_varchar2, 32) ||
10240 ' Index: ' || RPAD(tmp_varchar1,32);
10241 END LOOP;
10242 CLOSE tmp_cursor;
10243 IF (tstr IS NOT NULL OR tstr != '' ) THEN
10244 result_txt := result_txt || tstr;
10245 END IF;
10246 ELSIF HelpType = c_help_fixup THEN
10247 result_txt := 'Cleanup of ordimageIndexes is performed during the upgrade';
10248 END IF;
10249 RETURN result_txt;
10250 END ORDIMAGEINDEX_gethelp;
10251 --
10252 -- Fixup (Procedure and function)
10253 --
10254 PROCEDURE ORDIMAGEINDEX_fixup
10255 IS
10256 result VARCHAR2(4000);
10257 status NUMBER;
10258 tSqlcode NUMBER;
10259 BEGIN
10260 -- Call fixup and throw away the result
10261 status := ORDIMAGEINDEX_fixup (result, tSqlcode);
10262 END ORDIMAGEINDEX_fixup;
10263
10264 FUNCTION ORDIMAGEINDEX_fixup (
10265 result_txt IN OUT VARCHAR2,
10266 pSqlcode IN OUT NUMBER) RETURN number
10267 IS
10268 BEGIN
10269 result_txt :=
10270 'OrdimageIndexes are cleaned up as part of the upgrade';
10271 pSqlcode := 1;
10272 return c_fixup_status_info;
10273 END ORDIMAGEINDEX_fixup;
10274 -- *****************************************************************
10275 -- 2PC_TXN_EXIST Section
10276 -- *****************************************************************
10277 FUNCTION PENDING_2PC_TXN_check (result_txt OUT VARCHAR2) RETURN number
10278 IS
10279 t_null CHAR(1);
10280 status NUMBER;
10281 BEGIN
10282
10283 BEGIN
10284 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.dba_2pc_pending WHERE rownum <=1'
10285 INTO t_null;
10286 status := 1;
10287 EXCEPTION
10288 WHEN NO_DATA_FOUND THEN status := 0;
10289 END;
10290
10291 IF (status = 0 AND pDBGFailCheck = FALSE)
10292 THEN
10293 RETURN c_status_success;
10294 ELSE
10295 IF pOutputType = c_output_xml THEN
10296 result_txt:= genDBUAXMLCheck('2PC_TXN_EXIST',
10297 c_check_level_warning,
10298 'There are outstanding unresolved distributed transactions. Resolve outstanding distributed transactions prior to upgrade.',
10299 'Resolve outstanding distributed transactions prior to upgrade.',
10300 'Resolve outstanding distributed transactions prior to upgrade.',
10301 c_dbua_detail_type_sql,
10302 htmlentities('SELECT count(*) FROM sys.dba_2pc_pending WHERE rownum <=1'),
10303 c_dbua_fixup_type_manual,
10304 c_dbua_fixup_stage_pre);
10305 ELSE
10306 result_txt := PENDING_2PC_TXN_gethelp(c_help_overview);
10307 END IF;
10308 IF pOutputFixupScripts THEN
10309 genFixup ('2PC_TXN_EXIST');
10310 END IF;
10311 RETURN c_status_failure;
10312 END IF;
10313 END PENDING_2PC_TXN_check;
10314
10315 FUNCTION PENDING_2PC_TXN_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10316 IS
10317 BEGIN
10318 IF HelpType = c_help_overview THEN
10319 return 'ERROR: --> Unresolved distributed transactions' || crlf
10320 || crlf || ' There are outstanding unresolved distributed transactions.'
10321 || crlf || ' Resolve all outstanding distributed transactions prior to upgrade.';
10322 ELSIF HelpType = c_help_fixup THEN
10323 return 'Distributed transactions must be resolved prior to upgrade.';
10324 END IF;
10325 END PENDING_2PC_TXN_gethelp;
10326 --
10327 -- Fixup (Procedure and function)
10328 --
10329 PROCEDURE PENDING_2PC_TXN_fixup
10330 IS
10331 result VARCHAR2(4000);
10332 status NUMBER;
10333 tSqlcode NUMBER;
10334 BEGIN
10335 -- Call fixup and throw away the result
10336 status := PENDING_2PC_TXN_fixup (result, tSqlcode);
10337 END PENDING_2PC_TXN_fixup;
10338
10339 FUNCTION PENDING_2PC_TXN_fixup (
10340 result_txt IN OUT VARCHAR2,
10341 pSqlcode IN OUT NUMBER) RETURN number
10342 IS
10343 BEGIN
10344 -- Dump out the same thing we give for help
10345 result_txt := PENDING_2PC_TXN_gethelp(c_help_overview);
10346 return c_fixup_status_info;
10347 END PENDING_2PC_TXN_fixup;
10348
10349 -- *****************************************************************
10350 -- Recycle Bin Section
10351 -- *****************************************************************
10352 FUNCTION purge_recyclebin_check (result_txt OUT VARCHAR2) RETURN number
10353 IS
10354 obj_count NUMBER;
10355 BEGIN
10356 EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM sys.recyclebin$'
10357 INTO obj_count;
10358 IF (obj_count > 0 OR pDBGFailCheck)
10359 THEN
10360
10361 IF (pDBGFailCheck AND obj_count = 0) THEN
10362 obj_count := 10; -- Give it some non-zero number
10363 END IF;
10364
10365 IF pOutputType = c_output_xml THEN
10366 result_txt:= genDBUAXMLCheck('PURGE_RECYCLEBIN', c_check_level_error,
10367 'Recycle Bin is not empty',
10368 'Recycle bin is not empty',
10369 'BEGIN dbms_preup.purge_recyclebin_fixup; END;',
10370 c_dbua_detail_type_sql,
10371 'select count(*) from sys.recyclebin$',
10372 c_dbua_fixup_type_auto,
10373 c_dbua_fixup_stage_validation);
10374 ELSE
10375 result_txt := 'ERROR: --> RECYCLE_BIN not empty.'
10376 || crlf || ' Your recycle bin contains ' || TO_CHAR(obj_count) || ' object(s). '
10377 || crlf || ' It is REQUIRED that the recycle bin is empty prior to upgrading.'
10378 || crlf || ' Immediately before performing the upgrade, execute the following'
10379 || crlf || ' command:'
10380 || crlf || ' EXECUTE dbms_preup.purge_recyclebin_fixup;';
10381 END IF;
10382 IF pOutputFixupScripts THEN
10383 genFixup ('PURGE_RECYCLEBIN');
10384 END IF;
10385 RETURN c_status_failure;
10386 ELSE
10387 RETURN c_status_success; -- success
10388 END IF;
10389 END purge_recyclebin_check;
10390
10391 FUNCTION purge_recyclebin_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10392 IS
10393 obj_count NUMBER;
10394 result_txt VARCHAR2(4000);
10395 BEGIN
10396 IF HelpType = c_help_overview THEN
10397 EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM sys.recyclebin$'
10398 INTO obj_count;
10399 IF (pDBGFailCheck AND obj_count = 0) THEN
10400 obj_count := 10; -- Give it some non-zero number
10401 END IF;
10402
10403 result_txt := 'ERROR: --> Recycle Bin not empty' || crlf
10404 || crlf || ' Your recycle bin contains ' || TO_CHAR(obj_count) || ' object(s).'
10405 || crlf || ' It is REQUIRED that the recycle bin is empty prior to upgrading'
10406 || crlf || ' your database. The command:'
10407 || crlf || ' execute dbms_preup.purge_recyclebin_fixup;'
10408 || crlf || ' must be executed immediately prior to executing your upgrade.';
10409 ELSIF HelpType = c_help_fixup THEN
10410 result_txt := 'The recycle bin will be purged.';
10411 END IF;
10412 RETURN result_txt;
10413 END purge_recyclebin_gethelp;
10414 --
10415 -- Fixup
10416 --
10417 PROCEDURE purge_recyclebin_fixup
10418 IS
10419 result VARCHAR2(4000);
10420 status NUMBER;
10421 tSqlcode NUMBER;
10422 BEGIN
10423 -- Call fixup and throw away the result
10424 status := purge_recyclebin_fixup (result, tSqlcode);
10425 END purge_recyclebin_fixup;
10426
10427 FUNCTION purge_recyclebin_fixup (
10428 result_txt IN OUT VARCHAR2,
10429 pSqlcode IN OUT NUMBER) RETURN number
10430 IS
10431 BEGIN
10432 return execute_sql_statement ('PURGE DBA_RECYCLEBIN',
10433 result_txt, pSqlcode);
10434 END purge_recyclebin_fixup;
10435
10436 -- *****************************************************************
10437 -- REMOVE_DMSYS Section
10438 -- *****************************************************************
10439 FUNCTION REMOVE_DMSYS_check (result_txt OUT VARCHAR2) RETURN number
10440 IS
10441 t_null CHAR(1);
10442 status NUMBER := 0;
10443 BEGIN
10444
10445 IF (db_n_version NOT IN (102,111,112,121) AND pDBGFailCheck = FALSE) THEN
10446 RETURN c_status_success;
10447 END IF;
10448
10449 BEGIN
10450 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.user$ WHERE name=''DMSYS'''
10451 INTO t_null;
10452 status := 1;
10453 EXCEPTION
10454 WHEN NO_DATA_FOUND THEN NULL;
10455 END;
10456
10457 IF (status = 0 AND pDBGFailCheck = FALSE)
10458 THEN
10459 RETURN c_status_success;
10460 ELSE
10461 IF pOutputType = c_output_xml THEN
10462 result_txt:= genDBUAXMLCheck('REMOVE_DMSYS',
10463 c_check_level_info,
10464 'The DMSYS schema exists in the database and will be '
10465 || 'removed during the upgrade. '
10466 || 'Refer to the Oracle Data Mining User''s Guide for '
10467 || 'instructions on how to perform this task.',
10468 'The DMSYS schema exists in the database.',
10469 'Refer to the Oracle Data Mining User''s Guide for '
10470 || 'instructions on how to perform this task.',
10471 c_dbua_detail_type_sql,
10472 'select name from sys.user$ where name=''DMSYS''',
10473 c_dbua_fixup_type_manual,
10474 c_dbua_fixup_stage_pre );
10475 ELSE
10476 result_txt := REMOVE_DMSYS_gethelp(c_help_overview);
10477 END IF;
10478 IF pOutputFixupScripts THEN
10479 genFixup ('REMOVE_DMSYS');
10480 END IF;
10481 RETURN c_status_failure;
10482 END IF;
10483 END REMOVE_DMSYS_check;
10484
10485 FUNCTION REMOVE_DMSYS_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10486 IS
10487 BEGIN
10488 IF HelpType = c_help_overview THEN
10489 return 'WARNING: --> "DMSYS" schema exists in the database' || crlf
10490 || crlf || ' The DMSYS schema (Oracle Data Mining) will be removed'
10491 || crlf || ' from the database during the database upgrade.'
10492 || crlf || ' All data in DMSYS will be preserved under the SYS schema.'
10493 || crlf || ' Refer to the Oracle Data Mining User''s Guide for details.';
10494 ELSIF HelpType = c_help_fixup THEN
10495 return 'The DMSYS schema is removed as part of the upgrade.';
10496 END IF;
10497 END REMOVE_DMSYS_gethelp;
10498 --
10499 -- Fixup (Procedure and function)
10500 --
10501 PROCEDURE REMOVE_DMSYS_fixup
10502 IS
10503 result VARCHAR2(4000);
10504 status NUMBER;
10505 tSqlcode NUMBER;
10506 BEGIN
10507 -- Call fixup and throw away the result
10508 status := REMOVE_DMSYS_fixup (result, tSqlcode);
10509 END REMOVE_DMSYS_fixup;
10510
10511 FUNCTION REMOVE_DMSYS_fixup (
10512 result_txt IN OUT VARCHAR2,
10513 pSqlcode IN OUT NUMBER) RETURN number
10514 IS
10515 BEGIN
10516 -- Dump out the same thing we give for help
10517 result_txt := REMOVE_DMSYS_gethelp(c_help_overview);
10518 return c_fixup_status_info;
10519 END REMOVE_DMSYS_fixup;
10520
10521 -- *****************************************************************
10522 -- XBRL_VERSION Section
10523 -- *****************************************************************
10524 FUNCTION XBRL_VERSION_check (result_txt OUT VARCHAR2) RETURN number
10525 IS
10526 t_null CHAR(1);
10527 status NUMBER := 0;
10528 BEGIN
10529
10530 IF (db_n_version NOT IN (112,121) AND pDBGFailCheck = FALSE) THEN
10531 RETURN c_status_success;
10532 END IF;
10533
10534 BEGIN
10535 EXECUTE IMMEDIATE 'SELECT NULL FROM sys.user$ WHERE name=''XBRLSYS'''
10536 INTO t_null;
10537 status := 1;
10538 EXCEPTION
10539 WHEN NO_DATA_FOUND THEN NULL;
10540 END;
10541
10542 IF (status = 0 AND pDBGFailCheck = FALSE)
10543 THEN
10544 RETURN c_status_success;
10545 ELSE
10546 IF pOutputType = c_output_xml THEN
10547 result_txt:= genDBUAXMLCheck('XBRL_VERSION',
10548 c_check_level_info,
10549 'The XBRL Extension to XML DB is installed in the database. '
10550 || 'Before the database upgrade, please make sure the XBRL '
10551 || 'Extension has been upgraded to the latest available version '
10552 || 'on the current database.',
10553 'The XBRLSYS schema exists in the database.',
10554 'Refer to the Oracle Support Note for the latest available '
10555 || 'version on the current database.',
10556 c_dbua_detail_type_sql,
10557 'select name from sys.user$ where name=''XBRLSYS''',
10558 c_dbua_fixup_type_manual,
10559 c_dbua_fixup_stage_pre );
10560 ELSE
10561 result_txt := XBRL_VERSION_gethelp(c_help_overview);
10562 END IF;
10563 IF pOutputFixupScripts THEN
10564 genFixup ('XBRL_VERSION');
10565 END IF;
10566 RETURN c_status_failure;
10567 END IF;
10568 END XBRL_VERSION_check;
10569
10570 FUNCTION XBRL_VERSION_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10571 IS
10572 BEGIN
10573 IF HelpType = c_help_overview THEN
10574 return 'WARNING: --> "XBRLSYS" schema exists in the database' || crlf
10575 || crlf || ' Before the database upgrade, please make sure the XBRL '
10576 || crlf || ' Extension has been upgraded to the latest available version '
10577 || crlf || ' on the current database.'
10578 || crlf || ' Refer to the Oracle Supporte Note for details.';
10579 ELSIF HelpType = c_help_fixup THEN
10580 return 'The XBRL Extension must have the latest available version on the current database';
10581 END IF;
10582 END XBRL_VERSION_gethelp;
10583 --
10584 -- Fixup (Procedure and function)
10585 --
10586 PROCEDURE XBRL_VERSION_fixup
10587 IS
10588 result VARCHAR2(4000);
10589 status NUMBER;
10590 tSqlcode NUMBER;
10591 BEGIN
10592 -- Call fixup and throw away the result
10593 status := XBRL_VERSION_fixup (result, tSqlcode);
10594 END XBRL_VERSION_fixup;
10595
10596 FUNCTION XBRL_VERSION_fixup (
10597 result_txt IN OUT VARCHAR2,
10598 pSqlcode IN OUT NUMBER) RETURN number
10599 IS
10600 BEGIN
10601 -- Dump out the same thing we give for help
10602 result_txt := XBRL_VERSION_gethelp(c_help_overview);
10603 return c_fixup_status_info;
10604 END XBRL_VERSION_fixup;
10605
10606 -- *****************************************************************
10607 -- REMOTE_REDO Section
10608 -- *****************************************************************
10609 FUNCTION REMOTE_REDO_check (result_txt OUT VARCHAR2) RETURN number
10610 IS
10611 tmp_varchar1 VARCHAR2(100);
10612 t_count INTEGER;
10613 status NUMBER := 0;
10614 BEGIN
10615
10616 IF (db_n_version NOT IN (102,111) AND pDBGFailCheck = FALSE) THEN
10617 return c_status_not_for_this_version;
10618 END IF;
10619 --
10620 -- Check to detect if REDO configuration is supported with beyond
10621 -- 11.2
10622 --
10623 -- For 11.2, REDO has changed its maximum number of remote redo transport
10624 -- destinations from 9 to 30, we need to see if 10 is being used, and what
10625 -- its default is, if its local, there is an error.
10626 --
10627 -- Condition 1) Archiving of log files is enabled
10628 --
10629 -- Condition 2) DB_RECOVERY_FILE_DEST is defined
10630 --
10631 -- Condition 3) No local destinations are defined
10632 --
10633 -- Condition 4) LOG_ARCHIVE_DEST_1 is in use, and is a remote destition
10634 --
10635 --
10636 -- Only continue if archive logging is on
10637 --
10638
10639 BEGIN
10640 EXECUTE IMMEDIATE
10641 'SELECT LOG_MODE FROM v$database'
10642 INTO tmp_varchar1;
10643 EXCEPTION
10644 WHEN NO_DATA_FOUND THEN tmp_varchar1 := 'NOARCHIVELOG';
10645 END;
10646
10647 IF tmp_varchar1 != 'ARCHIVELOG' AND pDBGFailCheck = FALSE THEN
10648 RETURN c_status_success;
10649 END IF;
10650
10651 --
10652 -- Check for db_recovery_file_dest
10653 --
10654 tmp_varchar1 := NULL;
10655 BEGIN
10656 EXECUTE IMMEDIATE 'SELECT vp.value FROM v$parameter vp WHERE
10657 UPPER(vp.NAME) = ''DB_RECOVERY_FILE_DEST'''
10658 INTO tmp_varchar1;
10659
10660 EXCEPTION
10661 WHEN NO_DATA_FOUND THEN NULL;
10662 END;
10663
10664 IF tmp_varchar1 IS NOT NULL OR tmp_varchar1 != '' THEN
10665 --
10666 -- See if there are any local destinations defined
10667 -- Note the regexp_like
10668 --
10669 EXECUTE IMMEDIATE '
10670 select count(a.dest_name)
10671 from v$archive_dest a join v$parameter p
10672 on(lower(a.dest_name)=lower(p.name))
10673 where p.name like ''log_archive_dest_%''
10674 and regexp_like(p.value,''*[ ^]?location([ ])?=([ ])?*'',''i'')
10675 and a.status=''VALID'''
10676 INTO t_count;
10677 -- no local archive destination explicitly defined
10678 IF t_count = 0 THEN
10679 -- remote archive destinations
10680 EXECUTE IMMEDIATE '
10681 SELECT count(*) FROM v$parameter v
10682 WHERE v.NAME LIKE ''log_archive_dest_%'' AND
10683 REGEXP_LIKE(v.VALUE,''*[ ^]?service([ ])?=([ ])?*'',''i'')'
10684 INTO t_count;
10685
10686 IF t_count > 0 THEN
10687 --
10688 -- Next is _1 in use, and remote
10689 --
10690 EXECUTE IMMEDIATE '
10691 SELECT count(*) FROM v$archive_dest ad
10692 WHERE ad.dest_id=1 AND
10693 ad.target=''STANDBY'''
10694 INTO t_count;
10695
10696 IF t_count = 1 THEN
10697 --
10698 -- There is an issue to report.
10699 --
10700 status := 1;
10701 END IF;
10702 END IF; -- standby archive destination in #1
10703 END IF; -- no local archive destination defined
10704 END IF; -- having local dest values set
10705
10706 IF (status = 0 AND pDBGFailCheck = FALSE)
10707 THEN
10708 RETURN c_status_success;
10709 ELSE
10710 IF pOutputType = c_output_xml THEN
10711 result_txt:= genDBUAXMLCheck('REMOTE_REDO',
10712 c_check_level_warning,
10713 'Starting with 11.2, only LOG_ARCHIVE_DEST_1 is used for defaulting local'
10714 || 'archival of redo data.'
10715 || ' You must specify a destination for local archiving since '
10716 || 'LOG_ARCHIVE_DEST_1 is not available.',
10717 'You must specify a destination for local archiving since '
10718 || 'LOG_ARCHIVE_DEST_1 is not available.',
10719 'BEGIN dbms_preup.REMOTE_REDO_fixup; END',
10720 c_dbua_detail_type_text,
10721 'You must specify a destination for local archiving since '
10722 || 'LOG_ARCHIVE_DEST_1 is not available.',
10723 c_dbua_fixup_type_manual,
10724 c_dbua_fixup_stage_pre );
10725 ELSE
10726 result_txt := REMOTE_REDO_gethelp(c_help_overview);
10727 END IF;
10728 IF pOutputFixupScripts THEN
10729 genFixup ('REMOTE_REDO');
10730 END IF;
10731 RETURN c_status_failure;
10732 END IF;
10733 END REMOTE_REDO_check;
10734
10735 FUNCTION REMOTE_REDO_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10736 IS
10737 BEGIN
10738 IF HelpType = c_help_overview THEN
10739 return 'ERROR: --> REDO Configuration not supported in 11.2' || crlf
10740 || crlf || ' Your REDO configuration is defaulting the use of'
10741 || crlf || ' LOG_ARCHIVE_DEST_10 for local archiving of redo data to'
10742 || crlf || ' the recovery area and has also defined'
10743 || crlf || ' LOG_ARCHIVE_DEST_1 for remote use.'
10744 || crlf || ' Starting with 11.2, only LOG_ARCHIVE_DEST_1 is used for defaulting local'
10745 || crlf || ' archival of redo data.'
10746 || crlf || ' You must specify a destination for local archiving since'
10747 || crlf || ' LOG_ARCHIVE_DEST_1 is not available.';
10748 ELSIF HelpType = c_help_fixup THEN
10749 return 'Manually specify a destination for local archiving.';
10750 END IF;
10751 END REMOTE_REDO_gethelp;
10752 --
10753 -- Fixup (Procedure and function)
10754 --
10755 PROCEDURE REMOTE_REDO_fixup
10756 IS
10757 result VARCHAR2(4000);
10758 status NUMBER;
10759 tSqlcode NUMBER;
10760 BEGIN
10761 -- Call fixup and throw away the result
10762 status := REMOTE_REDO_fixup (result, tSqlcode);
10763 END REMOTE_REDO_fixup;
10764
10765 FUNCTION REMOTE_REDO_fixup (
10766 result_txt IN OUT VARCHAR2,
10767 pSqlcode IN OUT NUMBER) RETURN number
10768 IS
10769 BEGIN
10770 -- Dump out the same thing we give for help
10771 result_txt := REMOTE_REDO_gethelp(c_help_overview);
10772 return c_fixup_status_info;
10773 END REMOTE_REDO_fixup;
10774
10775 -- *****************************************************************
10776 -- SYNC_STANDBY_DB Section
10777 -- *****************************************************************
10778 FUNCTION SYNC_STANDBY_DB_check (result_txt OUT VARCHAR2) RETURN number
10779 IS
10780 t_null CHAR(1);
10781 status NUMBER := 0;
10782 unsynch_standby_count NUMBER := 0;
10783
10784 BEGIN
10785 BEGIN
10786 EXECUTE IMMEDIATE 'SELECT NULL FROM v$parameter WHERE
10787 name LIKE ''log_archive_dest%'' AND upper(value) LIKE ''SERVICE%''
10788 AND rownum <=1'
10789 INTO t_null;
10790
10791 EXECUTE IMMEDIATE 'SELECT NULL FROM v$database WHERE
10792 database_role=''PRIMARY'''
10793 INTO t_null;
10794
10795 EXECUTE IMMEDIATE 'SELECT COUNT(*)
10796 FROM V$ARCHIVE_DEST_STATUS DS, V$ARCHIVE_DEST D
10797 WHERE DS.DEST_ID = D.DEST_ID
10798 AND D.TARGET = ''STANDBY''
10799 AND NOT (DS.STATUS = ''VALID'' AND DS.GAP_STATUS = ''NO GAP'')'
10800 INTO unsynch_standby_count;
10801 IF (unsynch_standby_count > 0) THEN
10802 status := 1;
10803 END IF;
10804
10805 EXCEPTION
10806 WHEN NO_DATA_FOUND THEN status := 0;
10807 END;
10808
10809 IF (status = 0 AND pDBGFailCheck = FALSE)
10810 THEN
10811 RETURN c_status_success;
10812 ELSE
10813 IF pOutputType = c_output_xml THEN
10814 result_txt:= genDBUAXMLCheck('SYNC_STANDBY_DB',
10815 c_check_level_info,
10816 'Sync standby database prior to upgrade.',
10817 'Sync standby database prior to upgrade.',
10818 'Sync standby database prior to upgrade.',
10819 c_dbua_detail_type_sql,
10820 htmlentities('SELECT name FROM v$parameter WHERE'
10821 || ' name LIKE ''log_archive_dest%'' AND'
10822 || ' upper(value) LIKE ''SERVICE%'' AND rownum <=1'),
10823 c_dbua_fixup_type_manual,
10824 c_dbua_fixup_stage_pre );
10825 ELSE
10826 result_txt := SYNC_STANDBY_DB_gethelp(c_help_overview);
10827 END IF;
10828 IF pOutputFixupScripts THEN
10829 genFixup ('SYNC_STANDBY_DB');
10830 END IF;
10831 RETURN c_status_failure;
10832 END IF;
10833 END SYNC_STANDBY_DB_check;
10834
10835 FUNCTION SYNC_STANDBY_DB_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10836 IS
10837 BEGIN
10838 IF HelpType = c_help_overview THEN
10839 return 'INFORMATION: --> Standby database not synced' || crlf
10840 || crlf || ' Sync standby database prior to upgrade.'
10841 || crlf || ' Your standby databases should be synched prior to upgrading.';
10842 ELSIF HelpType = c_help_fixup THEN
10843 return 'Standby databases should be synced prior to upgrade.';
10844 END IF;
10845 END SYNC_STANDBY_DB_gethelp;
10846 --
10847 -- Fixup (Procedure and function)
10848 --
10849 PROCEDURE SYNC_STANDBY_DB_fixup
10850 IS
10851 result VARCHAR2(4000);
10852 status NUMBER;
10853 tSqlcode NUMBER;
10854 BEGIN
10855 -- Call fixup and throw away the result
10856 status := SYNC_STANDBY_DB_fixup (result, tSqlcode);
10857 END SYNC_STANDBY_DB_fixup;
10858
10859 FUNCTION SYNC_STANDBY_DB_fixup (
10860 result_txt IN OUT VARCHAR2,
10861 pSqlcode IN OUT NUMBER) RETURN number
10862 IS
10863 BEGIN
10864 -- Dump out the same thing we give for help
10865 result_txt := SYNC_STANDBY_DB_gethelp(c_help_overview);
10866 return c_fixup_status_info;
10867 END SYNC_STANDBY_DB_fixup;
10868 -- *****************************************************************
10869 -- SYS_DEFAULT_TABLESPACE Section
10870 -- *****************************************************************
10871 FUNCTION SYS_DEF_TABLESPACE_check (result_txt OUT VARCHAR2) RETURN number
10872 IS
10873 t_ts1 VARCHAR2(30);
10874 t_ts2 VARCHAR2(30);
10875 status NUMBER;
10876 BEGIN
10877
10878 EXECUTE IMMEDIATE 'SELECT default_tablespace FROM sys.dba_users WHERE username = ''SYS'''
10879 INTO t_ts1;
10880 EXECUTE IMMEDIATE 'SELECT default_tablespace FROM sys.dba_users WHERE username = ''SYSTEM'''
10881 INTO t_ts2;
10882
10883 IF (t_ts1 = 'SYSTEM') AND (t_ts2 = 'SYSTEM') AND (pDBGFailCheck = FALSE) THEN
10884 -- Everything is fine.
10885 RETURN c_status_success;
10886 ELSE
10887 IF pOutputType = c_output_xml THEN
10888 result_txt:= genDBUAXMLCheck('SYS_DEFAULT_TABLESPACE',
10889 c_check_level_warning,
10890 'The SYSTEM or SYS schemas have been altered so their default tablespace'
10891 || ' is no longer SYSTEM. Prior to upgrading, the schema default'
10892 || ' tablespace must be reset to the SYSTEM tablespace',
10893 'The SYSTEM or SYS schemas have been altered so their default tablespace',
10894 'BEGIN dbms_preup.SYS_DEF_TABLESPACE_fixup; END;',
10895 c_dbua_detail_type_sql,
10896 htmlentities('select username,default_tablespace from sys.dba_users'
10897 || ' where username IN (''SYS'',''SYSTEM'')'),
10898 c_dbua_fixup_type_auto,
10899 c_dbua_fixup_stage_pre );
10900 ELSE
10901 result_txt := SYS_DEF_TABLESPACE_gethelp(c_help_overview);
10902 END IF;
10903 IF pOutputFixupScripts THEN
10904 genFixup ('SYS_DEFAULT_TABLESPACE');
10905 END IF;
10906 RETURN c_status_failure;
10907 END IF;
10908 END SYS_DEF_TABLESPACE_check;
10909
10910 FUNCTION SYS_DEF_TABLESPACE_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
10911 IS
10912 BEGIN
10913 IF HelpType = c_help_overview THEN
10914 return 'WARNING: --> SYS and SYSTEM schema default tablespace has been altered' || crlf
10915 || crlf || ' Prior to upgrading your database, please ensure both'
10916 || crlf || ' the SYS and SYSTEM schema default their tablespace to SYSTEM.'
10917 || crlf || ' Execute: execute dbms_preup.SYS_DEF_TABLESPACE_fixup; ';
10918 ELSIF HelpType = c_help_fixup THEN
10919 return 'SYSTEM account default tablespace is altered to be SYSTEM.';
10920 END IF;
10921 END SYS_DEF_TABLESPACE_gethelp;
10922 --
10923 -- Fixup (Procedure and function)
10924 --
10925 PROCEDURE SYS_DEF_TABLESPACE_fixup
10926 IS
10927 result VARCHAR2(4000);
10928 status NUMBER;
10929 tSqlcode NUMBER;
10930 BEGIN
10931 -- Call fixup and throw away the result
10932 status := SYS_DEF_TABLESPACE_fixup (result, tSqlcode);
10933 END SYS_DEF_TABLESPACE_fixup;
10934
10935 FUNCTION SYS_DEF_TABLESPACE_fixup (
10936 result_txt IN OUT VARCHAR2,
10937 pSqlcode IN OUT NUMBER) RETURN number
10938 IS
10939 t_result_txt VARCHAR2(4000);
10940 t_ts1 VARCHAR2(128);
10941 rval NUMBER := 1;
10942 BEGIN
10943 --
10944 -- Check both SYS and SYSTEM and reset if needed
10945 --
10946 result_txt := '';
10947 pSqlcode := 1;
10948 EXECUTE IMMEDIATE 'SELECT default_tablespace FROM sys.dba_users WHERE username = ''SYS'''
10949 INTO t_ts1;
10950 IF (t_ts1 != 'SYSTEM') THEN
10951 result_txt := 'Altering SYS schema default tablespace. Result: ';
10952 rval := execute_sql_statement ('ALTER USER SYS DEFAULT TABLESPACE SYSTEM', t_result_txt, pSqlcode);
10953 result_txt := result_txt || TO_CHAR(pSqlcode);
10954 END IF;
10955
10956 EXECUTE IMMEDIATE 'SELECT default_tablespace FROM sys.dba_users WHERE username = ''SYSTEM'''
10957 INTO t_ts1;
10958 IF (t_ts1 != 'SYSTEM') THEN
10959 result_txt := result_txt || crlf || 'Altering SYSTEM schema default tablespace Result: ';
10960 rval := execute_sql_statement ('ALTER USER SYSTEM DEFAULT TABLESPACE SYSTEM', t_result_txt, pSqlcode);
10961 result_txt := result_txt || TO_CHAR(pSqlcode);
10962 END IF;
10963 --
10964 -- If both were executed, only the last status is returned.
10965 --
10966 RETURN rval;
10967 END SYS_DEF_TABLESPACE_fixup;
10968
10969 -- *****************************************************************
10970 -- ULTRASEARCH_DATA Section
10971 -- *****************************************************************
10972 FUNCTION ULTRASEARCH_DATA_check (result_txt OUT VARCHAR2) RETURN number
10973 IS
10974 status NUMBER := 0;
10975 i_count INTEGER;
10976 BEGIN
10977 -- Once Ultra Search instance is created, wk$instance table is populated.
10978 -- The logic determines if Ultra Search has data or not by looking up
10979 -- wk$instance table. WKSYS.WK$INSTANCE table exists when Ultra Search is
10980 -- installed. If it's not installed, WKSYS.WK$INSTANCE doesn't exist and the
10981 -- pl/sql block raises exception.
10982 --
10983 BEGIN
10984 EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM wksys.wk$instance'
10985 INTO i_count;
10986 -- count will be 0 when there are no rows in wksys.wk$instance
10987 -- Otherwise there is at least one row in
10988 -- and an ultra search warning should be displayed
10989 IF (i_count != 0) THEN
10990 status := 1;
10991 END IF;
10992 EXCEPTION WHEN OTHERS THEN NULL;
10993 END;
10994
10995 IF (status = 0 AND pDBGFailCheck = FALSE)
10996 THEN
10997 RETURN c_status_success;
10998 ELSE
10999 IF pOutputType = c_output_xml THEN
11000 result_txt:= genDBUAXMLCheck('ULTRASEARCH_DATA',
11001 c_check_level_warning,
11002 'Ultra Search is not supported beyond 11.2 and is removed automatically during upgrade.'
11003 || ' If you need to preserve Ultra Search data please perform a manual cold backup prior to upgrade.',
11004 'Ultra Search data is present in the Database',
11005 'Optionally backup Ultra Search',
11006 c_dbua_detail_type_text,
11007 'To verify that Ultrasearch data exists, execute'
11008 || ' the following query: SELECT COUNT(*) FROM wksys.wk$instance',
11009 c_dbua_fixup_type_manual,
11010 c_dbua_fixup_stage_pre );
11011 ELSE
11012 result_txt := ULTRASEARCH_DATA_gethelp(c_help_overview);
11013 END IF;
11014 IF pOutputFixupScripts THEN
11015 genFixup ('ULTRASEARCH_DATA');
11016 END IF;
11017 RETURN c_status_failure;
11018 END IF;
11019 END ULTRASEARCH_DATA_check;
11020
11021 FUNCTION ULTRASEARCH_DATA_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11022 IS
11023 BEGIN
11024 IF HelpType = c_help_overview THEN
11025 return 'WARNING: --> Ultra Search not supported' || crlf
11026 || crlf || ' Ultra Search is not supported as of 11.2 and is removed during the upgrade.'
11027 || crlf || ' You may perform this task prior to the upgrade by using wkremov.sql '
11028 || crlf || ' located in the rdbms/admin directory of the new software installation.'
11029 || crlf || ' If you wish to preserve the Ultra Search data please perform a manual'
11030 || crlf || ' cold backup prior to upgrade.';
11031 ELSIF HelpType = c_help_fixup THEN
11032 return 'Ultra Search data may be backed up prior upgrade as it will be removed during the upgrade.';
11033 END IF;
11034 END ULTRASEARCH_DATA_gethelp;
11035 --
11036 -- Fixup (Procedure and function)
11037 --
11038 PROCEDURE ULTRASEARCH_DATA_fixup
11039 IS
11040 result VARCHAR2(4000);
11041 status NUMBER;
11042 tSqlcode NUMBER;
11043 BEGIN
11044 -- Call fixup and throw away the result
11045 status := ULTRASEARCH_DATA_fixup (result, tSqlcode);
11046 END ULTRASEARCH_DATA_fixup;
11047
11048 FUNCTION ULTRASEARCH_DATA_fixup (
11049 result_txt IN OUT VARCHAR2,
11050 pSqlcode IN OUT NUMBER) RETURN number
11051 IS
11052 BEGIN
11053 -- Dump out the same thing we give for help
11054 result_txt := ULTRASEARCH_DATA_gethelp(c_help_overview);
11055 return c_fixup_status_info;
11056 END ULTRASEARCH_DATA_fixup;
11057
11058 -- *****************************************************************
11059 -- unsupported_version Section
11060 -- *****************************************************************
11061 FUNCTION unsupported_version_check (result_txt OUT VARCHAR2) RETURN number
11062 IS
11063 status NUMBER;
11064 BEGIN
11065 --
11066 -- If the major (does not include fifth digit) is in the supported list
11067 -- we're good (if we are not failing all the checks)
11068 -- Also return SUCCESS if we are in XML because this is a manual
11069 -- only test.
11070 --
11071 -- Same check is done in init routine to set pUnsupportedUpgrade
11072 -- Using substr of c_version instead of hard-coding, for example
11073 -- '121' avoids errors while versions are updated.
11074 --
11075
11076 IF ( ( ( (instr (c_supported_versions, db_patch_vers) > 0) -- Supported ver found
11077 OR (db_major_vers = SUBSTR(c_version, 1,6)) -- DB is same version
11078 ) AND pDBGFailCheck = FALSE -- We want to fail all checks
11079 ) OR pOutputType = c_output_xml ) THEN -- Output XML
11080 RETURN c_status_success;
11081 END IF;
11082
11083 --
11084 -- The DBUA has its own check, this is for text version only
11085 --
11086 result_txt := unsupported_version_gethelp(c_help_overview);
11087
11088 IF pOutputFixupScripts THEN
11089 genFixup ('UNSUPPORTED_VERSION');
11090 END IF;
11091 RETURN c_status_failure;
11092 END unsupported_version_check;
11093
11094 FUNCTION unsupported_version_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11095 IS
11096 BEGIN
11097 IF HelpType = c_help_overview THEN
11098 return 'ERROR: --> Unsupported Version Upgrade' || crlf
11099 || crlf || pStarHeader
11100 || crlf || CenterLine('**** YOU CANNOT UPGRADE THIS DATABASE TO THIS RELEASE ****')
11101 || crlf || pStarHeader
11102 || crlf || ' Direct upgrade from ' || db_patch_vers || ' is not supported.'
11103 || crlf || ' Please refer to Chapter 2 of the Oracle Database Upgrade Guide for'
11104 || crlf || ' the matrix of releases supported for direct upgrade.';
11105 ELSIF HelpType = c_help_fixup THEN
11106 return 'Database must be first upgraded to a supported release prior to upgrading to this release.';
11107 END IF;
11108 END unsupported_version_gethelp;
11109 --
11110 -- Fixup (Procedure and function)
11111 --
11112 PROCEDURE unsupported_version_fixup
11113 IS
11114 result VARCHAR2(4000);
11115 status NUMBER;
11116 tSqlcode NUMBER;
11117 BEGIN
11118 -- Call fixup and throw away the result
11119 status := unsupported_version_fixup (result, tSqlcode);
11120 END unsupported_version_fixup;
11121
11122 FUNCTION unsupported_version_fixup (
11123 result_txt IN OUT VARCHAR2,
11124 pSqlcode IN OUT NUMBER) RETURN number
11125 IS
11126 BEGIN
11127 result_txt := unsupported_version_gethelp(c_help_overview);
11128 return c_fixup_status_info;
11129 END unsupported_version_fixup;
11130
11131 -- *****************************************************************
11132 -- PROVISIONER_PRESENT Section
11133 -- *****************************************************************
11134 FUNCTION PROVISIONER_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
11135 IS
11136 user_exists NUMBER := 1;
11137 t_null CHAR(1);
11138 status NUMBER;
11139 BEGIN
11140 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11141 return c_status_not_for_this_version;
11142 END IF;
11143
11144 BEGIN
11145 EXECUTE IMMEDIATE
11146 'SELECT NULL FROM sys.user$ WHERE name = ''PROVISIONER'''
11147 INTO t_null;
11148 EXCEPTION
11149 WHEN NO_DATA_FOUND then user_exists := 0;
11150 END;
11151 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
11152 THEN
11153 RETURN c_status_success;
11154 ELSE
11155 IF pOutputType = c_output_xml THEN
11156 result_txt:= genDBUAXMLCheck('PROVISIONER_PRESENT',
11157 c_check_level_error,
11158 'A user or role named "PROVISIONER" found in the database.',
11159 'A user or role named "PROVISIONER" found in the database.',
11160 '"PROVISIONER" user or role must be dropped prior to upgrading.',
11161 c_dbua_detail_type_text,
11162 'To drop the user "PROVISIONER", use the command: '||
11163 'DROP USER PROVISIONER CASCADE'||', and To drop the role "PROVISIONER", use the'||
11164 'command: DROP ROLE PROVISIONER',
11165 c_dbua_fixup_type_manual,
11166 c_dbua_fixup_stage_pre );
11167 ELSE
11168 result_txt := PROVISIONER_PRESENT_gethelp(c_help_overview);
11169 END IF;
11170 IF pOutputFixupScripts THEN
11171 genFixup ('PROVISIONER_PRESENT');
11172 END IF;
11173 RETURN c_status_failure;
11174 END IF;
11175 END PROVISIONER_PRESENT_check;
11176
11177 FUNCTION PROVISIONER_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11178 IS
11179 BEGIN
11180 IF HelpType = c_help_overview THEN
11181 return 'ERROR: --> A user or role with the name "PROVISIONER" found in the database.' || crlf
11182 || crlf || ' This is an Oracle defined role.'
11183 || crlf || ' You must drop this user or role prior to upgrading.';
11184 ELSIF HelpType = c_help_fixup THEN
11185 return 'The PROVISIONER user or role must be dropped prior to upgrading.';
11186 END IF;
11187 END PROVISIONER_PRESENT_gethelp;
11188 --
11189 -- Fixup (Procedure and function)
11190 --
11191 PROCEDURE PROVISIONER_PRESENT_fixup
11192 IS
11193 result VARCHAR2(4000);
11194 status NUMBER;
11195 tSqlcode NUMBER;
11196 BEGIN
11197 -- Call fixup and throw away the result
11198 status := PROVISIONER_PRESENT_fixup (result, tSqlcode);
11199 END PROVISIONER_PRESENT_fixup;
11200
11201 FUNCTION PROVISIONER_PRESENT_fixup (
11202 result_txt IN OUT VARCHAR2,
11203 pSqlcode IN OUT NUMBER) RETURN number
11204 IS
11205 BEGIN
11206 result_txt := PROVISIONER_PRESENT_gethelp(c_help_overview);
11207 pSqlcode := 0;
11208 return c_fixup_status_info;
11209 END PROVISIONER_PRESENT_fixup;
11210
11211 -- *****************************************************************
11212 -- XS_RESOURCE_PRESENT Section
11213 -- *****************************************************************
11214 FUNCTION XS_RESOURCE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
11215 IS
11216 user_exists NUMBER := 1;
11217 t_null CHAR(1);
11218 status NUMBER;
11219 BEGIN
11220 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11221 return c_status_not_for_this_version;
11222 END IF;
11223
11224 BEGIN
11225 EXECUTE IMMEDIATE
11226 'SELECT NULL FROM sys.user$ WHERE name = ''XS_RESOURCE'''
11227 INTO t_null;
11228 EXCEPTION
11229 WHEN NO_DATA_FOUND then user_exists := 0;
11230 END;
11231 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
11232 THEN
11233 RETURN c_status_success;
11234 ELSE
11235 IF pOutputType = c_output_xml THEN
11236 result_txt:= genDBUAXMLCheck('XS_RESOURCE_PRESENT',
11237 c_check_level_error,
11238 'A user or role named "XS_RESOURCE" found in the database.',
11239 'A user or role named "XS_RESOURCE" found in the database.',
11240 '"XS_RESOURCE" user or role must be dropped prior to upgrading.',
11241 c_dbua_detail_type_text,
11242 'To drop the user "XS_RESOURCE", use the command: '||
11243 'DROP USER XS_RESOURCE CASCADE'||', and To drop the role "XS_RESOURCE", use the'||
11244 'command: DROP ROLE XS_RESOURCE',
11245 c_dbua_fixup_type_manual,
11246 c_dbua_fixup_stage_pre );
11247 ELSE
11248 result_txt := XS_RESOURCE_PRESENT_gethelp(c_help_overview);
11249 END IF;
11250 IF pOutputFixupScripts THEN
11251 genFixup ('XS_RESOURCE_PRESENT');
11252 END IF;
11253 RETURN c_status_failure;
11254 END IF;
11255 END XS_RESOURCE_PRESENT_check;
11256
11257 FUNCTION XS_RESOURCE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11258 IS
11259 BEGIN
11260 IF HelpType = c_help_overview THEN
11261 return 'ERROR: --> A user or role with the name "XS_RESOURCE" found in the database.' || crlf
11262 || crlf || ' This is an Oracle defined role.'
11263 || crlf || ' You must drop this user or role prior to upgrading.';
11264 ELSIF HelpType = c_help_fixup THEN
11265 return 'The XS_RESOURCE user or role must be dropped prior to upgrading.';
11266 END IF;
11267 END XS_RESOURCE_PRESENT_gethelp;
11268 --
11269 -- Fixup (Procedure and function)
11270 --
11271 PROCEDURE XS_RESOURCE_PRESENT_fixup
11272 IS
11273 result VARCHAR2(4000);
11274 status NUMBER;
11275 tSqlcode NUMBER;
11276 BEGIN
11277 -- Call fixup and throw away the result
11278 status := XS_RESOURCE_PRESENT_fixup (result, tSqlcode);
11279 END XS_RESOURCE_PRESENT_fixup;
11280
11281 FUNCTION XS_RESOURCE_PRESENT_fixup (
11282 result_txt IN OUT VARCHAR2,
11283 pSqlcode IN OUT NUMBER) RETURN number
11284 IS
11285 BEGIN
11286 result_txt := XS_RESOURCE_PRESENT_gethelp(c_help_overview);
11287 pSqlcode := 0;
11288 return c_fixup_status_info;
11289 END XS_RESOURCE_PRESENT_fixup;
11290
11291 -- *****************************************************************
11292 -- XS_SESSION_ADMIN Section
11293 -- *****************************************************************
11294 FUNCTION XS_SESSION_ADMIN_check (result_txt OUT VARCHAR2) RETURN number
11295 IS
11296 user_exists NUMBER := 1;
11297 t_null CHAR(1);
11298 status NUMBER;
11299 BEGIN
11300 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11301 return c_status_not_for_this_version;
11302 END IF;
11303
11304 BEGIN
11305 EXECUTE IMMEDIATE
11306 'SELECT NULL FROM sys.user$ WHERE name = ''XS_SESSION_ADMIN'''
11307 INTO t_null;
11308 EXCEPTION
11309 WHEN NO_DATA_FOUND then user_exists := 0;
11310 END;
11311 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
11312 THEN
11313 RETURN c_status_success;
11314 ELSE
11315 IF pOutputType = c_output_xml THEN
11316 result_txt:= genDBUAXMLCheck('XS_SESSION_ADMIN',
11317 c_check_level_error,
11318 'A user or role named "XS_SESSION_ADMIN" found in the database.',
11319 'A user or role named "XS_SESSION_ADMIN" found in the database.',
11320 '"XS_SESSION_ADMIN" user or role must be dropped prior to upgrading.',
11321 c_dbua_detail_type_text,
11322 'To drop the user "XS_SESSION_ADMIN", use the command: '||
11323 'DROP USER XS_SESSION_ADMIN CASCADE'||
11324 ', and To drop the role "XS_SESSION_ADMIN", use the'||
11325 'command: DROP ROLE XS_SESSION_ADMIN',
11326 c_dbua_fixup_type_manual,
11327 c_dbua_fixup_stage_pre );
11328 ELSE
11329 result_txt := XS_SESSION_ADMIN_gethelp(c_help_overview);
11330 END IF;
11331 IF pOutputFixupScripts THEN
11332 genFixup ('XS_SESSION_ADMIN');
11333 END IF;
11334 RETURN c_status_failure;
11335 END IF;
11336 END XS_SESSION_ADMIN_check;
11337
11338 FUNCTION XS_SESSION_ADMIN_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11339 IS
11340 BEGIN
11341 IF HelpType = c_help_overview THEN
11342 return 'ERROR: --> A user or role with the name "XS_SESSION_ADMIN" found in the database.' || crlf
11343 || crlf || ' This is an Oracle defined role.'
11344 || crlf || ' You must drop this user or role prior to upgrading.';
11345 ELSIF HelpType = c_help_fixup THEN
11346 return 'The XS_SESSION_ADMIN user or role must be dropped prior to upgrading.';
11347 END IF;
11348 END XS_SESSION_ADMIN_gethelp;
11349 --
11350 -- Fixup (Procedure and function)
11351 --
11352 PROCEDURE XS_SESSION_ADMIN_fixup
11353 IS
11354 result VARCHAR2(4000);
11355 status NUMBER;
11356 tSqlcode NUMBER;
11357 BEGIN
11358 -- Call fixup and throw away the result
11359 status := XS_SESSION_ADMIN_fixup (result, tSqlcode);
11360 END XS_SESSION_ADMIN_fixup;
11361
11362 FUNCTION XS_SESSION_ADMIN_fixup (
11363 result_txt IN OUT VARCHAR2,
11364 pSqlcode IN OUT NUMBER) RETURN number
11365 IS
11366 BEGIN
11367 result_txt := XS_SESSION_ADMIN_gethelp(c_help_overview);
11368 pSqlcode := 0;
11369 return c_fixup_status_info;
11370 END XS_SESSION_ADMIN_fixup;
11371
11372 -- *****************************************************************
11373 -- XS_NAMESPACE_ADMIN Section
11374 -- *****************************************************************
11375 FUNCTION XS_NAMESPACE_ADMIN_check (result_txt OUT VARCHAR2) RETURN number
11376 IS
11377 user_exists NUMBER := 1;
11378 t_null CHAR(1);
11379 status NUMBER;
11380 BEGIN
11381 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11382 return c_status_not_for_this_version;
11383 END IF;
11384
11385 BEGIN
11386 EXECUTE IMMEDIATE
11387 'SELECT NULL FROM sys.user$ WHERE name = ''XS_NAMESPACE_ADMIN'''
11388 INTO t_null;
11389 EXCEPTION
11390 WHEN NO_DATA_FOUND then user_exists := 0;
11391 END;
11392 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
11393 THEN
11394 RETURN c_status_success;
11395 ELSE
11396 IF pOutputType = c_output_xml THEN
11397 result_txt:= genDBUAXMLCheck('XS_NAMESPACE_ADMIN',
11398 c_check_level_error,
11399 'A user or role named "XS_NAMESPACE_ADMIN" found in the database.',
11400 'A user or role named "XS_NAMESPACE_ADMIN" found in the database.',
11401 '"XS_NAMESPACE_ADMIN" user or role must be dropped prior to upgrading.',
11402 c_dbua_detail_type_text,
11403 'To drop the user "XS_NAMESPACE_ADMIN", use the command: '||
11404 'DROP USER XS_NAMESPACE_ADMIN CASCADE'||
11405 ', and To drop the role "XS_NAMESPACE_ADMIN", use the'||
11406 'command: DROP ROLE XS_NAMESPACE_ADMIN',
11407 c_dbua_fixup_type_manual,
11408 c_dbua_fixup_stage_pre );
11409 ELSE
11410 result_txt := XS_NAMESPACE_ADMIN_gethelp(c_help_overview);
11411 END IF;
11412 IF pOutputFixupScripts THEN
11413 genFixup ('XS_NAMESPACE_ADMIN');
11414 END IF;
11415 RETURN c_status_failure;
11416 END IF;
11417 END XS_NAMESPACE_ADMIN_check;
11418
11419 FUNCTION XS_NAMESPACE_ADMIN_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11420 IS
11421 BEGIN
11422 IF HelpType = c_help_overview THEN
11423 return 'ERROR: --> A user or role with the name "XS_NAMESPACE_ADMIN" found in the database.' || crlf
11424 || crlf || ' This is an Oracle defined role.'
11425 || crlf || ' You must drop this user or role prior to upgrading.';
11426 ELSIF HelpType = c_help_fixup THEN
11427 return 'The XS_NAMESPACE_ADMIN user or role must be dropped prior to upgrading.';
11428 END IF;
11429 END XS_NAMESPACE_ADMIN_gethelp;
11430 --
11431 -- Fixup (Procedure and function)
11432 --
11433 PROCEDURE XS_NAMESPACE_ADMIN_fixup
11434 IS
11435 result VARCHAR2(4000);
11436 status NUMBER;
11437 tSqlcode NUMBER;
11438 BEGIN
11439 -- Call fixup and throw away the result
11440 status := XS_NAMESPACE_ADMIN_fixup (result, tSqlcode);
11441 END XS_NAMESPACE_ADMIN_fixup;
11442
11443 FUNCTION XS_NAMESPACE_ADMIN_fixup (
11444 result_txt IN OUT VARCHAR2,
11445 pSqlcode IN OUT NUMBER) RETURN number
11446 IS
11447 BEGIN
11448 result_txt := XS_NAMESPACE_ADMIN_gethelp(c_help_overview);
11449 pSqlcode := 0;
11450 return c_fixup_status_info;
11451 END XS_NAMESPACE_ADMIN_fixup;
11452
11453 -- *****************************************************************
11454 -- XS_CACHE_ADMIN Section
11455 -- *****************************************************************
11456 FUNCTION XS_CACHE_ADMIN_check (result_txt OUT VARCHAR2) RETURN number
11457 IS
11458 user_exists NUMBER := 1;
11459 t_null CHAR(1);
11460 status NUMBER;
11461 BEGIN
11462 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11463 return c_status_not_for_this_version;
11464 END IF;
11465
11466 BEGIN
11467 EXECUTE IMMEDIATE
11468 'SELECT NULL FROM sys.user$ WHERE name = ''XS_CACHE_ADMIN'''
11469 INTO t_null;
11470 EXCEPTION
11471 WHEN NO_DATA_FOUND then user_exists := 0;
11472 END;
11473 IF (user_exists = 0 AND pDBGFailCheck = FALSE)
11474 THEN
11475 RETURN c_status_success;
11476 ELSE
11477 IF pOutputType = c_output_xml THEN
11478 result_txt:= genDBUAXMLCheck('XS_CACHE_ADMIN',
11479 c_check_level_error,
11480 'A user or role named "XS_CACHE_ADMIN" found in the database.',
11481 'A user or role named "XS_CACHE_ADMIN" found in the database.',
11482 '"XS_CACHE_ADMIN" user or role must be dropped prior to upgrading.',
11483 c_dbua_detail_type_text,
11484 'To drop the user "XS_CACHE_ADMIN", use the command: '||
11485 'DROP USER XS_CACHE_ADMIN CASCADE'||
11486 ', and To drop the role "XS_CACHE_ADMIN", use the'||
11487 'command: DROP ROLE XS_CACHE_ADMIN',
11488 c_dbua_fixup_type_manual,
11489 c_dbua_fixup_stage_pre );
11490 ELSE
11491 result_txt := XS_CACHE_ADMIN_gethelp(c_help_overview);
11492 END IF;
11493 IF pOutputFixupScripts THEN
11494 genFixup ('XS_CACHE_ADMIN');
11495 END IF;
11496 RETURN c_status_failure;
11497 END IF;
11498 END XS_CACHE_ADMIN_check;
11499
11500 FUNCTION XS_CACHE_ADMIN_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11501 IS
11502 BEGIN
11503 IF HelpType = c_help_overview THEN
11504 return 'ERROR: --> A user or role with the name "XS_CACHE_ADMIN" found in the database.' || crlf
11505 || crlf || ' This is an Oracle defined role.'
11506 || crlf || ' You must drop this user or role prior to upgrading.';
11507 ELSIF HelpType = c_help_fixup THEN
11508 return 'The XS_CACHE_ADMIN user or role must be dropped prior to upgrading.';
11509 END IF;
11510 END XS_CACHE_ADMIN_gethelp;
11511 --
11512 -- Fixup (Procedure and function)
11513 --
11514 PROCEDURE XS_CACHE_ADMIN_fixup
11515 IS
11516 result VARCHAR2(4000);
11517 status NUMBER;
11518 tSqlcode NUMBER;
11519 BEGIN
11520 -- Call fixup and throw away the result
11521 status := XS_CACHE_ADMIN_fixup (result, tSqlcode);
11522 END XS_CACHE_ADMIN_fixup;
11523
11524 FUNCTION XS_CACHE_ADMIN_fixup (
11525 result_txt IN OUT VARCHAR2,
11526 pSqlcode IN OUT NUMBER) RETURN number
11527 IS
11528 BEGIN
11529 result_txt := XS_CACHE_ADMIN_gethelp(c_help_overview);
11530 pSqlcode := 0;
11531 return c_fixup_status_info;
11532 END XS_CACHE_ADMIN_fixup;
11533
11534
11535 FUNCTION NOT_UPG_BY_STD_UPGRD_check (result_txt OUT VARCHAR2) RETURN number
11536 IS
11537 my_components_list VARCHAR2(4000) := ' ';
11538 not_my_components_list VARCHAR2(4000) := ' ';
11539 all_components_mine BOOLEAN := TRUE;
11540 not_my_comps_cursor cursor_t;
11541 c_cname SYS.REGISTRY$.CNAME%TYPE;
11542 select_stmt VARCHAR2(500);
11543 BEGIN
11544 BEGIN
11545 -- construct a quoted and comma separated list of components that will
11546 -- be upgraded by the upgrade script.
11547 -- since the list of my components is known, this code won't overflow
11548 -- the my_components_list stringsize
11549 FOR i in 1..max_components LOOP
11550 if (i > 1) THEN
11551 my_components_list := my_components_list || ',';
11552 END IF;
11553 my_components_list := my_components_list || dbms_assert.enquote_literal(cmp_info(i).cid);
11554 END LOOP;
11555
11556 select_stmt := 'SELECT cname FROM sys.registry$ WHERE namespace=' ||
11557 dbms_assert.enquote_literal('SERVER') ||
11558 ' AND cid NOT IN (' ||
11559 my_components_list ||
11560 ')';
11561 OPEN not_my_comps_cursor FOR select_stmt;
11562
11563 LOOP
11564 FETCH not_my_comps_cursor INTO c_cname;
11565 EXIT WHEN not_my_comps_cursor%NOTFOUND;
11566 IF (LENGTH(not_my_components_list) >= (c_str_max-length(c_cname)-12)) THEN
11567 -- the 12 above is the length of ' plus others ' below. Save space for it
11568 -- in case we need it.
11569 not_my_components_list := not_my_components_list || ' plus others';
11570 EXIT;
11571 ELSE
11572 IF (NOT all_components_mine) THEN
11573 not_my_components_list := not_my_components_list || ',';
11574 END IF;
11575 not_my_components_list := not_my_components_list || c_cname;
11576 END IF;
11577 all_components_mine := FALSE;
11578 END LOOP;
11579 CLOSE not_my_comps_cursor;
11580 END;
11581 IF (all_components_mine AND (pDBGFailCheck = FALSE))
11582 THEN
11583 RETURN c_status_success;
11584 ELSE
11585 IF pOutputType = c_output_xml THEN
11586 result_txt:= genDBUAXMLCheck('NOT_UPG_BY_STD_UPGRD',
11587 c_check_level_info,
11588 'The database has components which will not be upgraded.',
11589 'The database has components which will not be upgraded.',
11590 'No action required, but you may wish to upgrade those components as needed using some other procedure appropriate for that component',
11591 c_dbua_detail_type_text,
11592 not_my_components_list,
11593 c_dbua_fixup_type_manual,
11594 c_dbua_fixup_stage_post );
11595 ELSE
11596 result_txt := NOT_UPG_BY_STD_UPGRD_gethelp(c_help_overview)
11597 || crlf || ' Those components are: ' || not_my_components_list;
11598 END IF;
11599 IF pOutputFixupScripts THEN
11600 genFixup ('NOT_UPG_BY_STD_UPGRD');
11601 END IF;
11602 RETURN c_status_failure;
11603 END IF;
11604 END NOT_UPG_BY_STD_UPGRD_check;
11605
11606 FUNCTION NOT_UPG_BY_STD_UPGRD_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11607 IS
11608 BEGIN
11609 IF HelpType = c_help_overview THEN
11610 return 'INFORMATION: --> There are existing Oracle components that will NOT be'
11611 || crlf || ' upgraded by the database upgrade script. Typically, such components'
11612 || crlf || ' have their own upgrade scripts, are deprecated, or obsolete.';
11613 ELSIF HelpType = c_help_fixup THEN
11614 return 'This fixup does not perform any action.';
11615 END IF;
11616 END NOT_UPG_BY_STD_UPGRD_gethelp;
11617
11618 PROCEDURE NOT_UPG_BY_STD_UPGRD_fixup
11619 IS
11620 BEGIN
11621 -- do nothing.
11622 null;
11623 END NOT_UPG_BY_STD_UPGRD_fixup;
11624
11625 FUNCTION NOT_UPG_BY_STD_UPGRD_fixup (
11626 result_txt IN OUT VARCHAR2, pSqlcode IN OUT NUMBER) RETURN number
11627 IS
11628 BEGIN
11629 result_txt := 'This fixup does not perform any action. '
11630 || crlf || 'If you want to upgrade those other components, you must do so manually.';
11631 pSqlcode := 0;
11632 return c_fixup_status_info;
11633
11634 END NOT_UPG_BY_STD_UPGRD_fixup;
11635
11636
11637
11638
11639 -- *****************************************************************
11640 -- EMX_BASIC_ROLE_PRESENT Section
11641 -- *****************************************************************
11642 FUNCTION EMX_BASIC_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
11643 IS
11644 role_exists NUMBER := 1;
11645 t_null CHAR(1);
11646 status NUMBER;
11647 BEGIN
11648
11649 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11650 return c_status_not_for_this_version;
11651 END IF;
11652
11653 BEGIN
11654 EXECUTE IMMEDIATE
11655 'SELECT NULL FROM sys.user$ WHERE NAME = ''EM_EXPRESS_BASIC'''
11656 INTO t_null;
11657 EXCEPTION
11658 WHEN NO_DATA_FOUND then role_exists := 0;
11659 END;
11660
11661 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
11662 THEN
11663 RETURN c_status_success;
11664 ELSE
11665 IF pOutputType = c_output_xml THEN
11666 result_txt:= genDBUAXMLCheck('EM_EXPRESS_BASIC',
11667 c_check_level_error,
11668 'A user or role named "EM_EXPRESS_BASIC" found in the database.',
11669 'A user or role named "EM_EXPRESS_BASIC" found in the database.',
11670 '"EM_EXPRESS_BASIC" role or user must be dropped prior to upgrading.',
11671 c_dbua_detail_type_text,
11672 'To drop the role "EM_EXPRESS_BASIC", use the command:'
11673 || ' DROP ROLE EM_EXPRESS_BASIC' || ', and To drop the user "EM_EXPRESS_BASIC"'
11674 || ' use the command: DROP USER EM_EXPRESS_BASIC CASCADE',
11675 c_dbua_fixup_type_manual,
11676 c_dbua_fixup_stage_pre );
11677 ELSE
11678 result_txt := EMX_BASIC_ROLE_PRESENT_gethelp(c_help_overview);
11679 END IF;
11680 IF pOutputFixupScripts THEN
11681 genFixup ('EMX_BASIC_ROLE_PRESENT');
11682 END IF;
11683 RETURN c_status_failure;
11684 END IF;
11685 END EMX_BASIC_ROLE_PRESENT_check;
11686
11687 FUNCTION EMX_BASIC_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11688 IS
11689 BEGIN
11690 IF HelpType = c_help_overview THEN
11691 return 'ERROR: --> A user or role with the name "EM_EXPRESS_BASIC" found in the database.' || crlf
11692 || crlf || ' This is an Oracle defined role.'
11693 || crlf || ' You must drop this role or user prior to upgrading.';
11694 ELSIF HelpType = c_help_fixup THEN
11695 return 'The EM_EXPRESS_BASIC role or user must be dropped prior to upgrading.';
11696 END IF;
11697 END EMX_BASIC_ROLE_PRESENT_gethelp;
11698 --
11699 -- Fixup (Procedure and function)
11700 --
11701 PROCEDURE EMX_BASIC_ROLE_PRESENT_fixup
11702 IS
11703 result VARCHAR2(4000);
11704 status NUMBER;
11705 tSqlcode NUMBER;
11706 BEGIN
11707 -- Call fixup and throw away the result
11708 status := EMX_BASIC_ROLE_PRESENT_fixup (result, tSqlcode);
11709 END EMX_BASIC_ROLE_PRESENT_fixup;
11710
11711 FUNCTION EMX_BASIC_ROLE_PRESENT_fixup (
11712 result_txt IN OUT VARCHAR2,
11713 pSqlcode IN OUT NUMBER) RETURN number
11714 IS
11715 BEGIN
11716 result_txt := EMX_BASIC_ROLE_PRESENT_gethelp(c_help_overview);
11717 pSqlcode := 0;
11718 return c_fixup_status_info;
11719 END EMX_BASIC_ROLE_PRESENT_fixup;
11720
11721 -- *****************************************************************
11722 -- EMX_ALL_ROLE_PRESENT Section
11723 -- *****************************************************************
11724 FUNCTION EMX_ALL_ROLE_PRESENT_check (result_txt OUT VARCHAR2) RETURN number
11725 IS
11726 role_exists NUMBER := 1;
11727 t_null CHAR(1);
11728 status NUMBER;
11729 BEGIN
11730
11731 IF (db_n_version NOT IN (102,111,112) AND pDBGFailCheck = FALSE) THEN
11732 return c_status_not_for_this_version;
11733 END IF;
11734
11735 BEGIN
11736 EXECUTE IMMEDIATE
11737 'SELECT NULL FROM sys.user$ WHERE NAME = ''EM_EXPRESS_ALL'''
11738 INTO t_null;
11739 EXCEPTION
11740 WHEN NO_DATA_FOUND then role_exists := 0;
11741 END;
11742
11743 IF (role_exists = 0 AND pDBGFailCheck = FALSE)
11744 THEN
11745 RETURN c_status_success;
11746 ELSE
11747 IF pOutputType = c_output_xml THEN
11748 result_txt:= genDBUAXMLCheck('EM_EXPRESS_ALL',
11749 c_check_level_error,
11750 'A user or role named "EM_EXPRESS_ALL" found in the database.',
11751 'A user or role named "EM_EXPRESS_ALL" found in the database.',
11752 '"EM_EXPRESS_ALL" role or user must be dropped prior to upgrading.',
11753 c_dbua_detail_type_text,
11754 'To drop the role "EM_EXPRESS_ALL", use the command:'
11755 || ' DROP ROLE EM_EXPRESS_ALL' || ', and To drop the user "EM_EXPRESS_ALL"'
11756 || ' use the command: DROP USER EM_EXPRESS_ALL CASCADE',
11757 c_dbua_fixup_type_manual,
11758 c_dbua_fixup_stage_pre );
11759 ELSE
11760 result_txt := EMX_ALL_ROLE_PRESENT_gethelp(c_help_overview);
11761 END IF;
11762 IF pOutputFixupScripts THEN
11763 genFixup ('EMX_ALL_ROLE_PRESENT');
11764 END IF;
11765 RETURN c_status_failure;
11766 END IF;
11767 END EMX_ALL_ROLE_PRESENT_check;
11768
11769 FUNCTION EMX_ALL_ROLE_PRESENT_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11770 IS
11771 BEGIN
11772 IF HelpType = c_help_overview THEN
11773 return 'ERROR: --> A user or role with the name "EM_EXPRESS_ALL" found in the database.' || crlf
11774 || crlf || ' This is an Oracle defined role.'
11775 || crlf || ' You must drop this role or user prior to upgrading.';
11776 ELSIF HelpType = c_help_fixup THEN
11777 return 'The EM_EXPRESS_ALL role or user must be dropped prior to upgrading.';
11778 END IF;
11779 END EMX_ALL_ROLE_PRESENT_gethelp;
11780 --
11781 -- Fixup (Procedure and function)
11782 --
11783 PROCEDURE EMX_ALL_ROLE_PRESENT_fixup
11784 IS
11785 result VARCHAR2(4000);
11786 status NUMBER;
11787 tSqlcode NUMBER;
11788 BEGIN
11789 -- Call fixup and throw away the result
11790 status := EMX_ALL_ROLE_PRESENT_fixup (result, tSqlcode);
11791 END EMX_ALL_ROLE_PRESENT_fixup;
11792
11793 FUNCTION EMX_ALL_ROLE_PRESENT_fixup (
11794 result_txt IN OUT VARCHAR2,
11795 pSqlcode IN OUT NUMBER) RETURN number
11796 IS
11797 BEGIN
11798 result_txt := EMX_ALL_ROLE_PRESENT_gethelp(c_help_overview);
11799 pSqlcode := 0;
11800 return c_fixup_status_info;
11801 END EMX_ALL_ROLE_PRESENT_fixup;
11802
11803
11804 -- *****************************************************************
11805 -- open_cursors Section
11806 --
11807 -- 1) If APEX is in the registry, then check the value of open_cursors.
11808 -- Alert only if open_cursors is < 150.
11809 -- This is an error condition check as APEX upgrades to 12102 can fail.
11810 -- 2) If APEX is not in the registry, then no check is needed.
11811 --
11812 -- *****************************************************************
11813 FUNCTION open_cursors_check (result_txt OUT VARCHAR2) RETURN number
11814 IS
11815 open_cursors NUMBER;
11816 status NUMBER;
11817 check_stmt VARCHAR2(100); -- stmt to execute in this open_cursors check
11818 BEGIN
11819
11820 -- query to execute in this open_cursors check
11821 check_stmt := 'select value from v$parameter where name=''open_cursors''';
11822
11823 -- we only want to find out what open_cursors value is if apex is in db
11824 IF (cmp_info(apex).processed = TRUE) THEN -- apex exists in registry$
11825 EXECUTE IMMEDIATE
11826 check_stmt
11827 INTO open_cursors;
11828 ELSE
11829 -- if apex is not in the registry, then no need to find out what
11830 -- the open_cursors value is.
11831 -- just go ahead and return success status.
11832 RETURN c_status_success;
11833 END IF;
11834
11835 --
11836 -- open_cursors is bigger than min needed (and not debug) -> return success
11837 --
11838 IF (open_cursors >= c_min_open_cursors AND pDBGFailCheck = FALSE) THEN
11839 RETURN c_status_success;
11840 END IF;
11841
11842 IF pOutputType = c_output_xml THEN
11843 result_txt:= genDBUAXMLCheck('OPEN_CURSORS',
11844 c_check_level_error,
11845 'OPEN_CURSORS initialization parameter must be increased.',
11846 'OPEN_CURSORS value is too low for the upgrade. It is currently ' ||
11847 'set at ' || open_cursors || '.',
11848 'Increase OPEN_CURSORS value to at least ' ||
11849 to_char(c_min_open_cursors) || '. ' ||
11850 'For example, to change parameter file: update the PFILE or use ' ||
11851 '"ALTER SYSTEM SET OPEN_CURSORS=' || c_min_open_cursors || ' ' ||
11852 'SCOPE=SPFILE". Note the update in the PFILE/SPFILE will not take ' ||
11853 'effect until the next database startup.',
11854 c_dbua_detail_type_text,
11855 'To avoid exceeding number of open cursors during Oracle ' ||
11856 'Application Express (APEX) upgrade, ' ||
11857 'increase OPEN_CURSORS before upgrading the database.',
11858 c_dbua_fixup_type_manual,
11859 c_dbua_fixup_stage_validation);
11860 ELSE
11861 result_txt := open_cursors_gethelp(c_help_overview);
11862 END IF;
11863
11864 IF pOutputFixupScripts THEN
11865 genFixup ('OPEN_CURSORS');
11866 END IF;
11867
11868 RETURN c_status_failure;
11869 END open_cursors_check;
11870
11871 FUNCTION open_cursors_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11872 IS
11873 open_cursors NUMBER;
11874 BEGIN
11875 IF HelpType = c_help_overview THEN
11876 EXECUTE IMMEDIATE
11877 'SELECT value FROM V$PARAMETER WHERE NAME=''open_cursors'''
11878 INTO open_cursors;
11879
11880 return 'ERROR: --> OPEN_CURSORS initialization parameter value is too low'
11881 || crlf
11882 || crlf || ' OPEN_CURSORS is currently set at ' || open_cursors || '.'
11883 || crlf || ' o To avoid exceeding number of open cursors during'
11884 || crlf || ' Oracle Application Express (APEX) upgrade, increase'
11885 || crlf || ' OPEN_CURSORS to a value of at least '
11886 || c_min_open_cursors || ' before upgrading'
11887 || crlf || ' the database.'
11888 || crlf || ' o For example, to change parameter file: update the PFILE'
11889 || crlf || ' or use "ALTER SYSTEM SET OPEN_CURSORS='
11890 || c_min_open_cursors || ' SCOPE=SPFILE".'
11891 || crlf || ' Note the update in the PFILE/SPFILE will not take'
11892 || crlf || ' effect until the next database startup.';
11893 ELSIF HelpType = c_help_fixup THEN
11894 return 'Increase OPEN_CURSORS initialization parameter to at least ' ||
11895 c_min_open_cursors || '.';
11896 END IF;
11897 END open_cursors_gethelp;
11898
11899 --
11900 -- Fixup (Procedure and function)
11901 --
11902 PROCEDURE open_cursors_fixup
11903 IS
11904 result VARCHAR2(4000);
11905 status NUMBER;
11906 tSqlcode NUMBER;
11907 BEGIN
11908 -- Call fixup and throw away the result
11909 status := open_cursors_fixup (result, tSqlcode);
11910 END open_cursors_fixup;
11911
11912 FUNCTION open_cursors_fixup (
11913 result_txt IN OUT VARCHAR2,
11914 pSqlcode IN OUT NUMBER) RETURN number
11915 IS
11916 BEGIN
11917 result_txt := open_cursors_gethelp(c_help_overview);
11918 return c_fixup_status_info;
11919 END open_cursors_fixup;
11920
11921 --
11922 -- end of OPEN_CURSORS
11923 --
11924 FUNCTION jvm_mitigation_patch_check (result_txt OUT VARCHAR2) RETURN NUMBER
11925 IS
11926 t_null CHAR(1);
11927 BEGIN
11928 select null into t_null
11929 from sys.dba_triggers
11930 where trigger_name='DBMS_JAVA_DEV_TRG' and owner='SYS'
11931 and status='ENABLED';
11932 IF pOutputType = c_output_xml THEN
11933 result_txt:= genDBUAXMLCheck('JVM_MITIGATION_PATCH',
11934 c_check_level_warning,
11935 'The temporary OJVM Mitigation patch is currently installed and active in the database.',
11936 'The temporary OJVM Mitigation patch is currently installed and active in the database, '||
11937 'securing it against the known threat but disabling Java development until you can install '||
11938 'the latest OJVM PSU.',
11939 'If you plan on continuing to use the Oracle mitigation patch instead of installing the Oracle recommended'||
11940 'Oracle JavaVM (OJVM) Patch Set Update (PSU), then you should enable Java development just before the upgrade '||
11941 'using the command: EXECUTE SYS.DBMS_JAVA_DEV.ENABLE; '||crlf||
11942 'Taking this action will make your database subject to a known security vulnerability, but without the PSU patch'||
11943 'Java development must still be enabled to allow some upgrade actions to complete. Extreme caution is advised.',
11944 c_dbua_detail_type_text,
11945 'The upgrade may fail if Java development is disabled. When active, the OJVM Mitigation patch disables Java development '||
11946 'in the database, Oracle strongly recommends installing the latest OJVM PSU in both '|| db_version|| ' and ' ||
11947 c_version||' ORACLE_HOMEs which will eliminate the need for the mitigation patch. Doing that in '|| c_version||
11948 ' will not incur in any database downtime and will eliminate the same vulnerability during the next upgrade. '||
11949 'If you cannot apply the OJVM PSU, you may opt to retain the mitigation patch in '|| db_version||', but Java development '||
11950 'still must be enabled during the upgrade. '||
11951 'Please refer to MOS note 1929745.1 for more details.',
11952 c_dbua_fixup_type_manual,
11953 c_dbua_fixup_stage_pre);
11954 ELSE
11955 result_txt := jvm_mitigation_patch_gethelp(c_help_overview);
11956 END IF;
11957 RETURN c_status_failure;
11958 EXCEPTION
11959 WHEN NO_DATA_FOUND THEN RETURN c_status_success;
11960 END jvm_mitigation_patch_check;
11961
11962 FUNCTION jvm_mitigation_patch_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
11963 IS
11964 BEGIN
11965 IF HelpType = c_help_overview THEN
11966 return 'WARNING: --> The temporary OJVM Mitigation patch is currently installed and active '
11967 || crlf || ' in the database, securing it against the known threat but disabling JAVA '
11968 || crlf || ' development until you can install the latest OJVM PSU.'||crlf
11969 || crlf || ' The upgrade may fail if Java development is disabled.'
11970 || crlf || ' When active, the OJVM Mitigation patch disables Java development '
11971 || crlf || ' in the database, Oracle strongly recommends installing the latest '
11972 || crlf || ' OJVM PSU in both '|| db_version||' and '||c_version||' ORACLE_HOMEs which will '
11973 || crlf || ' eliminate the need for the mitigation patch. Doing that in '|| c_version
11974 || crlf || ' will not incur in any database downtime and will eliminate the same '
11975 || crlf || ' vulnerability during the next upgrade.'||crlf
11976 || crlf || ' If you cannot apply the OJVM PSU, you may opt to retain the mitigation patch'
11977 || crlf || ' in '|| db_version||', but Java development still must be enabled during '
11978 || crlf || ' the upgrade. Please refer to MOS note 1929745.1 for more details.'||crlf
11979 || crlf || ' If you plan on continuing to use the Oracle mitigation patch instead of '
11980 || crlf || ' installing the Oracle recommended Oracle JavaVM (OJVM) Patch Set Update (PSU), '
11981 || crlf || ' then you should enable Java development just before upgrade using the command: '||crlf
11982 || crlf || ' EXECUTE SYS.DBMS_JAVA_DEV.ENABLE;'||crlf
11983 || crlf || ' Taking this action will make your database subject to a known security vulnerability, '
11984 || crlf || ' but without the PSU patch, Java development must still be enabled to allow some'
11985 || crlf || ' upgrade actions to complete. Extreme caution is advised.';
11986 ELSIF HelpType = c_help_fixup THEN
11987 return 'Enable JAVA development prior to the database upgrade by executing command: EXECUTE SYS.DBMS_JAVA_DEV.ENABLE;';
11988 END IF;
11989 END;
11990
11991 PROCEDURE jvm_mitigation_patch_fixup
11992 IS
11993 result VARCHAR2(4000);
11994 status NUMBER;
11995 tSqlcode NUMBER;
11996 BEGIN
11997 -- Call fixup and throw away the result
11998 status := jvm_mitigation_patch_fixup (result, tSqlcode);
11999 END jvm_mitigation_patch_fixup;
12000
12001 --
12002 -- Fixup javavm_mitigat_patch
12003 --
12004 FUNCTION jvm_mitigation_patch_fixup (
12005 result_txt IN OUT VARCHAR2,
12006 pSqlcode IN OUT NUMBER) RETURN NUMBER
12007 IS
12008 BEGIN
12009 result_txt := jvm_mitigation_patch_gethelp(c_help_overview);
12010 return c_fixup_status_info;
12011 END jvm_mitigation_patch_fixup;
12012
12013
12014
12015 FUNCTION post_jvm_mitigat_patch_check (result_txt OUT VARCHAR2) RETURN NUMBER
12016 IS
12017 t_null CHAR(1);
12018 BEGIN
12019 select null into t_null
12020 from sys.dba_triggers
12021 where trigger_name='DBMS_JAVA_DEV_TRG' and owner='SYS'
12022 and status='ENABLED';
12023 IF pOutputType = c_output_xml THEN
12024 result_txt:= genDBUAXMLCheck('POST_JVM_MITIGAT_PATCH',
12025 c_check_level_warning,
12026 'The temporary OJVM Mitigation patch is currently installed and active in the database.',
12027 'The temporary OJVM Mitigation patch is currently installed and active in the database, '||
12028 'securing it against the known threat but disabling Java development until you can install '||
12029 'the latest OJVM PSU.',
12030 'After upgrade, apply latest Oracle JavaVM (OJVM) Bundle Patch (BP) or '||
12031 'Patch Set Update (PSU) if it was not applied before database upgrade '||
12032 'on '||db_version||' ORACLE_HOME.'||' Please refer to MOS note 1929745.1 for more details.',
12033 c_dbua_detail_type_text,
12034 'Oracle JavaVM Component Database PSU is released as part of the Critical Patch Update program from October 2014 onwards. '||
12035 'Oracle recommends applying the latest OJVM PSU patch to ALL databases that have Oracle JavaVM present in the database, '||
12036 'regardless of whether you are explicitly using it or not. Even if Oracle JavaVM is not present in the database it is '||
12037 'best practice to install the OJVM PSU in case a new database is created in the ORACLE_HOME.',
12038 c_dbua_fixup_type_manual,
12039 c_dbua_fixup_stage_post);
12040 ELSE
12041 result_txt := post_jvm_mitigat_patch_gethelp(c_help_overview);
12042 END IF;
12043 RETURN c_status_failure;
12044 EXCEPTION
12045 WHEN NO_DATA_FOUND THEN RETURN c_status_success;
12046 END post_jvm_mitigat_patch_check;
12047
12048 FUNCTION post_jvm_mitigat_patch_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
12049 IS
12050 BEGIN
12051 IF HelpType = c_help_overview THEN
12052 return 'INFORMATION: --> The temporary OJVM Mitigation patch is currently installed and active'
12053 || crlf || ' in the database, securing it against the known threat but disabling JAVA'
12054 || crlf || ' development until you can install the latest OJVM PSU.'||crlf
12055 || crlf || ' Oracle JavaVM Component Database PSU is released as part of the'
12056 || crlf || ' Critical Patch Update program from October 2014 onwards.'
12057 || crlf || ' Oracle recommends applying the latest OJVM PSU patch to ALL'
12058 || crlf || ' databases that have Oracle JavaVM present in the database,'
12059 || crlf || ' regardless of whether you are explicitly using it or not.'
12060 || crlf || ' Even if Oracle JavaVM is not present in the database it is'
12061 || crlf || ' best practice to install the OJVM PSU in case a new database'
12062 || crlf || ' is created in the ORACLE_HOME.'||crlf
12063 || crlf || ' After upgrade, apply latest Oracle JavaVM (OJVM) Bundle Patch (BP) or '
12064 || crlf || ' or Patch Set Update (PSU) if it was not applied before database upgrade '
12065 || crlf || ' on '||db_version||' ORACLE_HOME. Please refer to MOS note 1929745.1 for more details.';
12066 ELSIF HelpType = c_help_fixup THEN
12067 return 'Apply latest Oracle JavaVM (OJVM) Bundle Patch (BP) or Patch Set Update (PSU).';
12068 END IF;
12069 END;
12070
12071 PROCEDURE post_jvm_mitigat_patch_fixup
12072 IS
12073 result VARCHAR2(4000);
12074 status NUMBER;
12075 tSqlcode NUMBER;
12076 BEGIN
12077 -- Call fixup and throw away the result
12078 status := post_jvm_mitigat_patch_fixup (result, tSqlcode);
12079 END post_jvm_mitigat_patch_fixup;
12080
12081 --
12082 -- Fixup post_jvm_mitigat_patch
12083 --
12084 FUNCTION post_jvm_mitigat_patch_fixup (
12085 result_txt IN OUT VARCHAR2,
12086 pSqlcode IN OUT NUMBER) RETURN NUMBER
12087 IS
12088 BEGIN
12089 result_txt := post_jvm_mitigat_patch_gethelp(c_help_overview);
12090 return c_fixup_status_info;
12091 END post_jvm_mitigat_patch_fixup;
12092
12093 -- *****************************************************************
12094 -- apex_upgrade_msg Section
12095 --
12096 -- bug 18523430: if the apex version in the database-to-be-upgraded
12097 -- is older than the one shipped in the target oracle home, then
12098 -- let user know that that apex can be manually upgraded outside of
12099 -- and prior to database upgrade
12100 --
12101 -- note: we are comparing the 1st 6 digits in apex versions.
12102 -- confirmed with apex that there is no need to compare the entire
12103 -- apex version string.
12104 --
12105 -- *****************************************************************
12106 FUNCTION apex_upgrade_msg_check (result_txt OUT VARCHAR2) RETURN number
12107 IS
12108 n_current_version number; -- current apex version # in database
12109 s_current_version VARCHAR2(20); -- current apex version string in db
12110 check_stmt VARCHAR2(300); -- stmt to execute in this check condition
12111 n_shipped_version number; -- c_apex_version in target oracle home
12112 convert_stmt VARCHAR2(160); -- convert c_apex_version to number
12113 BEGIN
12114
12115 -- a) check if apex needs to be upgraded by getting the apex version
12116 -- b) take the 1st 6 places in apex version string and convert to number by:
12117 -- => replace 1st 6 places in apex version string '.' with ''
12118 -- => convert to #
12119 -- e.g., "4.2.5.00.08" => "4.2.5." => number 425
12120 -- c) note: it's better to compare #s than strings because apex versions
12121 -- can eventually reach 10.x.x.xx.xx
12122 check_stmt :=
12123 'SELECT version, to_number(replace(substr(version,1,6), ''.'', '''')) ' ||
12124 'FROM sys.registry$ ' ||
12125 'WHERE cid = ''APEX'' and namespace=''SERVER''';
12126
12127 BEGIN
12128 EXECUTE IMMEDIATE
12129 check_stmt
12130 INTO s_current_version, n_current_version;
12131 EXCEPTION
12132 -- if apex is not found, then set n_current_version to 0
12133 WHEN NO_DATA_FOUND THEN
12134 n_current_version := 0;
12135 WHEN OTHERS THEN
12136 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
12137 END;
12138
12139 -- if current apex version is 0, then just return success;
12140 -- i.e., no need to continue
12141 IF n_current_version = 0
12142 THEN
12143 -- no current apex version to compare
12144 RETURN c_status_success;
12145 END IF;
12146
12147 -- convert c_apex_version to number
12148 convert_stmt :=
12149 'SELECT to_number(replace(substr(''' || c_apex_version ||
12150 ''',1,6), ''.'', '''')) FROM sys.dual';
12151 EXECUTE IMMEDIATE convert_stmt INTO n_shipped_version;
12152
12153 -- if current apex version is same or newer than the apex version in
12154 -- the target oracle home, then just return success
12155 IF n_current_version >= n_shipped_version
12156 AND pDBGFailCheck = FALSE
12157 THEN
12158 -- no apex upgrade msg needed
12159 return c_status_success;
12160 END IF;
12161
12162 -- if we are here, then current apex version is older than the one in
12163 -- target oracle home
12164 IF pOutputType = c_output_xml THEN
12165 check_stmt := 'SELECT version FROM sys.registry$ ' ||
12166 'WHERE cid = ''APEX'' and namespace=''SERVER''';
12167
12168 result_txt:= genDBUAXMLCheck('APEX_UPGRADE_MSG',
12169 c_check_level_info,
12170 'Oracle Application Express (APEX) can be manually upgraded ' ||
12171 'prior to database upgrade.' ,
12172 'APEX is currently at version ' || s_current_version || ' and will ' ||
12173 'need to be upgraded.',
12174 'To reduce database upgrade time, APEX can be manually ' ||
12175 'upgraded outside of and prior to database upgrade. ' ||
12176 'See MOS Note 1088970.1 for information on ' ||
12177 'APEX installation upgrades.' ,
12178 c_dbua_detail_type_text,
12179 'APEX in the database-to-be-upgraded is at version ' ||
12180 s_current_version ||'. APEX shipped with the new release is at ' ||
12181 c_apex_version || '.',
12182 c_dbua_fixup_type_manual,
12183 c_dbua_fixup_stage_validation);
12184 ELSE
12185 result_txt := apex_upgrade_msg_gethelp(c_help_overview);
12186 END IF;
12187
12188 IF pOutputFixupScripts THEN
12189 genFixup ('APEX_UPGRADE_MSG');
12190 END IF;
12191
12192 RETURN c_status_failure;
12193 END apex_upgrade_msg_check;
12194
12195 FUNCTION apex_upgrade_msg_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
12196 IS
12197 s_version VARCHAR2(20); -- apex version string in db-to-be-upgraded
12198 check_stmt VARCHAR2(200); -- stmt to execute to check condition
12199 BEGIN
12200
12201 check_stmt := 'SELECT version FROM sys.registry$ ' ||
12202 'WHERE cid = ''APEX'' and namespace=''SERVER''';
12203
12204 IF HelpType = c_help_overview THEN
12205 EXECUTE IMMEDIATE
12206 check_stmt
12207 INTO s_version;
12208
12209 return 'INFORMATION: --> Oracle Application Express (APEX) can be'
12210 || crlf || ' manually upgraded prior to database upgrade'
12211 || crlf
12212 || crlf || ' APEX is currently at version ' || s_version || ' and '
12213 || 'will need to be'
12214 || crlf || ' upgraded to APEX version ' || c_apex_version || ' '
12215 || 'in the new release.'
12216 || crlf || ' Note 1: To reduce database upgrade time, APEX can '
12217 || 'be manually'
12218 || crlf || ' upgraded outside of and prior to database upgrade.'
12219 || crlf || ' Note 2: See MOS Note 1088970.1 for information on APEX'
12220 || crlf || ' installation upgrades.';
12221 ELSIF HelpType = c_help_fixup THEN
12222 return 'Oracle Application Express can be manually upgraded prior to database upgrade.';
12223 END IF;
12224 END apex_upgrade_msg_gethelp;
12225
12226 --
12227 -- Fixup (Procedure and function)
12228 --
12229 PROCEDURE apex_upgrade_msg_fixup
12230 IS
12231 result VARCHAR2(4000);
12232 status NUMBER;
12233 tSqlcode NUMBER;
12234 BEGIN
12235 -- Call fixup and throw away the result
12236 status := apex_upgrade_msg_fixup (result, tSqlcode);
12237 END apex_upgrade_msg_fixup;
12238
12239 FUNCTION apex_upgrade_msg_fixup (
12240 result_txt IN OUT VARCHAR2,
12241 pSqlcode IN OUT NUMBER) RETURN number
12242 IS
12243 BEGIN
12244 result_txt := apex_upgrade_msg_gethelp(c_help_overview);
12245 return c_fixup_status_info;
12246 END apex_upgrade_msg_fixup;
12247
12248 --
12249 -- end of APEX_UPGRADE_MSG
12250 --
12251
12252
12253 -- *****************************************************************
12254 -- default_resource_limit Section
12255 --
12256 -- 1) Initialization parameter RESOURCE_LIMIT 's default value is
12257 -- changing from FALSE to TRUE starting in 12.1.0.2.
12258 -- 2) Will warn customers about the default value changing.
12259 -- This would only affect customers who have applied a resource limit
12260 -- to a user and does not already have resource_limit set in their
12261 -- parameter file. If they don't have resource_limit set, which
12262 -- means default is FALSE in pre-12102 but TRUE in 12102 and post-12102.
12263 --
12264 -- *****************************************************************
12265 FUNCTION default_resource_limit_check (result_txt OUT VARCHAR2) RETURN number
12266 IS
12267 ret_val NUMBER := 0; -- return value from check_stmt
12268 check_stmt VARCHAR2(1000); -- check if resource_limit warning is needed
12269 BEGIN
12270
12271 -- RESOURCE_LIMIT warning is needed IF 1 is returned because all conditions
12272 -- are met:
12273 -- a) if RESOURCE_LIMIT init parameter is currently using the default value
12274 -- AND
12275 -- b) there are non-default/non-unlimited customized resource limits
12276 -- applied to 1 or more users
12277 -- AND
12278 -- c) db-to-be-upgraded's version is at 12.1.0.1 or older
12279 --
12280 check_stmt :=
12281 'SELECT 1 FROM sys.v$parameter ' ||
12282 'WHERE ' ||
12283 '( ' || -- criteria (a)
12284 ' (upper(name) = ''RESOURCE_LIMIT'' AND isdefault = ''TRUE'') ' ||
12285 ' AND ' || -- criteria (b)
12286 ' 0 < (SELECT count(*) ' ||
12287 ' FROM sys.dba_users ' ||
12288 ' WHERE profile in ' ||
12289 ' (SELECT unique(profile) ' ||
12290 ' FROM sys.dba_profiles ' ||
12291 ' WHERE resource_type = ''KERNEL'' and ' ||
12292 ' limit not in (''UNLIMITED'', ''DEFAULT'')) ' ||
12293 ' ) ' ||
12294 ' AND ' || -- criteria (c)
12295 ' 1 = (SELECT count(*) ' ||
12296 ' FROM sys.registry$ ' ||
12297 ' WHERE ' ||
12298 ' upper(cid) = ''CATPROC'' AND ' ||
12299 ' (substr(version, 1, 4) in (''10.2'', ''11.1'', ''11.2'') ' ||
12300 ' OR substr(version, 1, 8) = ''12.1.0.1'') ' ||
12301 ' ) ' ||
12302 ')';
12303
12304 -- check if a warning - about RESOURCE_LIMIT defaulting to TRUE starting
12305 -- in 12102 - needs to be generated
12306 BEGIN
12307 EXECUTE IMMEDIATE
12308 check_stmt
12309 INTO ret_val;
12310 EXCEPTION
12311 WHEN NO_DATA_FOUND THEN
12312 ret_val := 0;
12313 WHEN OTHERS THEN
12314 dbms_output.put_line('ORA' || SQLCODE ||
12315 ': Error in DEFAULT_RESOURCE_LIMITS check_stmt:');
12316 dbms_output.put_line(SQLERRM);
12317 END;
12318
12319 -- return success status if check returns a 0
12320 -- i.e., don't generate warning if ret_val is 0 and do generate warning
12321 -- if ret_val is 1.
12322 IF (ret_val = 0 AND pDBGFailCheck = FALSE) THEN
12323 return c_status_success;
12324 END IF;
12325
12326 -- if we are here, then warning needs to be generated
12327 IF pOutputType = c_output_xml THEN
12328 result_txt:= genDBUAXMLCheck('DEFAULT_RESOURCE_LIMIT',
12329 c_check_level_warning,
12330 'RESOURCE_LIMIT default has changed to TRUE starting with 12.1.0.2',
12331 'Resource limits defined for users via database profiles may not ' ||
12332 'be currently enforced because RESOURCE_LIMIT init parameter in ' ||
12333 'this ' || db_version || ' database is shown to be defaulted to FALSE.',
12334 'To continue having these database resource limits disabled for users ' ||
12335 'after database upgrade, set RESOURCE_LIMIT to FALSE. ' ||
12336 'For example, to change parameter file: update PFILE or use ' ||
12337 '"ALTER SYSTEM SET RESOURCE_LIMIT=FALSE SCOPE=SPFILE". ' ||
12338 'Note that the update in the PFILE/SPFILE will not take ' ||
12339 'effect until the next database startup.',
12340 c_dbua_detail_type_text,
12341 'RESOURCE_LIMIT default value is FALSE in 12.1.0.1 release and ' ||
12342 'earlier but is TRUE in 12.1.0.2 onwards.',
12343 c_dbua_fixup_type_manual,
12344 c_dbua_fixup_stage_validation);
12345 ELSE
12346 result_txt := default_resource_limit_gethelp(c_help_overview);
12347 END IF;
12348
12349 IF pOutputFixupScripts THEN
12350 genFixup ('DEFAULT_RESOURCE_LIMIT');
12351 END IF;
12352
12353 RETURN c_status_failure;
12354 END default_resource_limit_check;
12355
12356 FUNCTION default_resource_limit_gethelp (HelpType IN NUMBER) RETURN VARCHAR2
12357 IS
12358 BEGIN
12359
12360 IF HelpType = c_help_overview THEN
12361 return 'WARNING: --> RESOURCE_LIMIT default has changed to TRUE '
12362 || 'starting with 12.1.0.2'
12363 ||crlf
12364 ||crlf||' Resource limits defined for users via database profiles may not'
12365 ||crlf||' be currently enforced because RESOURCE_LIMIT init parameter in'
12366 ||crlf||' this ' || db_version || ' database is shown to be defaulted to FALSE.'
12367 ||crlf||' o RESOURCE_LIMIT in 12.1.0.1 release and earlier is FALSE by'
12368 ||crlf||' default but is TRUE starting with 12.1.0.2.'
12369 ||crlf||' o To continue having these resource limits disabled for users'
12370 ||crlf||' after database upgrade, set RESOURCE_LIMIT to FALSE.'
12371 ||crlf||' o For example, to change parameter file: update PFILE or use'
12372 ||crlf||' "ALTER SYSTEM SET RESOURCE_LIMIT=FALSE SCOPE=SPFILE". Note that'
12373 ||crlf||' the update will not take effect until next database startup.';
12374 ELSIF HelpType = c_help_fixup THEN
12375 return 'Examine RESOURCE_LIMIT before upgrading to the new release';
12376 END IF;
12377 END default_resource_limit_gethelp;
12378
12379 --
12380 -- Fixup (Procedure and function)
12381 --
12382 PROCEDURE default_resource_limit_fixup
12383 IS
12384 result VARCHAR2(4000);
12385 status NUMBER;
12386 tSqlcode NUMBER;
12387 BEGIN
12388 -- Call fixup and throw away the result
12389 status := default_resource_limit_fixup (result, tSqlcode);
12390 END default_resource_limit_fixup;
12391
12392 FUNCTION default_resource_limit_fixup (
12393 result_txt IN OUT VARCHAR2,
12394 pSqlcode IN OUT NUMBER) RETURN number
12395 IS
12396 BEGIN
12397 result_txt := default_resource_limit_gethelp(c_help_overview);
12398 return c_fixup_status_info;
12399 END default_resource_limit_fixup;
12400
12401 --
12402 -- end of DEFAULT_RESOURCE_LIMIT
12403 --
12404
12405 -- ****************************************************************************
12406 -- Specific Recommendation Area
12407 -- ****************************************************************************
12408 --
12409 -- "check-name"_recommend()
12410 -- These checks are usually just dumping out text either to the log or to
12411 -- the scripts
12412 --
12413 PROCEDURE dictionary_stats_recommend
12414 IS
12415 BEGIN
12416 IF pOutputType = c_output_text THEN
12417 --
12418 -- Stale Stats
12419 --
12420 DisplayLine(pPreScriptUFT,'BEGIN');
12421 DisplayCenter(pPreScriptUFT,pStarHeader);
12422 DisplayCenter(pPreScriptUFT,CenterLine('********* Dictionary Statistics *********'));
12423 DisplayCenter(pPreScriptUFT,pStarHeader);
12424 DisplayLineBoth(pPreScriptUFT, '');
12425 DisplayLineBoth(pPreScriptUFT, 'Please gather dictionary statistics 24 hours prior to');
12426 DisplayLineBoth(pPreScriptUFT, 'upgrading the database.');
12427 DisplayLineBoth(pPreScriptUFT, 'To gather dictionary statistics execute the following command');
12428 DisplayLineBoth(pPreScriptUFT, 'while connected as SYSDBA:');
12429 DisplayLineBoth(pPreScriptUFT, ' EXECUTE dbms_stats.gather_dictionary_stats;');
12430 DisplayLineBoth(pPreScriptUFT, '');
12431 DisplayLineBoth(pPreScriptUFT, pActionSuggested);
12432 DisplayLineBoth(pPreScriptUFT, '');
12433 DisplayLine(pPreScriptUFT,'END;');
12434 DisplayBlankLine(pPreScriptUFT); -- '/' is at end of block with IF stmt
12435 END IF;
12436 END dictionary_stats_recommend;
12437
12438
12439 --
12440 -- parameters_display()
12441 -- 1) depending on the input argument, this procedure queries for
12442 -- underscore/hidden parameters or event parameters used in the instance
12443 -- 2) if input is 1 : queries for and displays underscore/hidden parameters
12444 -- 3) if input is 2 : queries for and displays events
12445 --
12446 PROCEDURE parameters_display (param_type_to_display IN NUMBER)
12447 -- c_display_underscore_params = 1 <-- display underscore/hidden params
12448 -- c_display_events = 2 <-- display events
12449 IS
12450 hidden_param_name sys.v$parameter.name%TYPE;
12451 hidden_param_value sys.v$parameter.value%TYPE;
12452 event_value sys.v$parameter2.value%TYPE;
12453
12454 rowcount NUMBER; -- # of rows fetched
12455 c_none_stmt CONSTANT VARCHAR2(30) := 'NONE found'; -- none found
12456 BEGIN
12457
12458 rowcount := 0;
12459
12460 -- for each hidden/underscore parameter set, display it and its value
12461 -- note: _trace_events as a separate section have been removed since
12462 -- _trace_events will show up as part of underscore parameters anyway.
12463 -- note: use the ismodified criteria below to
12464 -- filter out underscore parameters set during 'alter session' when
12465 -- preupgrade tool is run
12466 IF (param_type_to_display = 1) THEN
12467 FOR i
12468 IN ( select name hidden_param_name, value hidden_param_value
12469 from SYS.V$PARAMETER
12470 where name LIKE '\_%' ESCAPE '\'
12471 and ismodified != 'MODIFIED'
12472 order by name )
12473 LOOP
12474 IF pOutputDest = c_output_file AND pOutputType = c_output_text THEN
12475 -- write into preupgrade.log
12476 DisplayLine(pOutputUFT,
12477 i.hidden_param_name || ' = ' || i.hidden_param_value);
12478 ELSE
12479 -- screen output
12480 dbms_output.put_line(i.hidden_param_name || ' = ' ||
12481 i.hidden_param_value);
12482 END IF;
12483 rowcount := rowcount + 1;
12484 END LOOP;
12485
12486 -- if no rows returned, then print "NONE found"
12487 IF (rowcount = 0) THEN
12488 dbms_output.put_line(c_none_stmt);
12489 END IF;
12490
12491 -- for each event set, display its value
12492 ELSIF (param_type_to_display = 2) THEN
12493 FOR i
12494 IN ( select (translate(value,chr(13)||chr(10),' ')) event_value
12495 from sys.v$parameter2
12496 where upper(name) ='EVENT' and isdefault='FALSE' order by name )
12497 LOOP
12498 IF pOutputDest = c_output_file AND pOutputType = c_output_text THEN
12499 -- write to preupgrade.log
12500 DisplayLine(pOutputUFT, i.event_value);
12501 ELSE
12502 -- screen output
12503 dbms_output.put_line(i.event_value);
12504 END IF;
12505 rowcount := rowcount + 1;
12506 END LOOP;
12507
12508 -- if no rows returned, then print "NONE found"
12509 IF (rowcount = 0) THEN
12510 dbms_output.put_line(c_none_stmt);
12511 END IF;
12512 END IF;
12513
12514 END parameters_display;
12515
12516
12517 PROCEDURE hidden_params_recommend
12518 IS
12519 t_boolean BOOLEAN;
12520 t_status NUMBER;
12521 BEGIN
12522 IF pOutputType = c_output_text THEN
12523 --
12524 -- If there are no hidden params set, no need to recommend review.
12525 --
12526 t_boolean := FALSE;
12527 BEGIN
12528 EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM sys.v$parameter WHERE name LIKE ''\_%'' ESCAPE ''\'' AND ismodified != ''MODIFIED'''
12529 INTO t_status;
12530 IF (t_status >= 1) THEN
12531 t_boolean := TRUE;
12532 END IF;
12533 EXCEPTION
12534 WHEN OTHERS THEN NULL;
12535 END;
12536 IF t_boolean THEN
12537 DisplayLine(pPreScriptUFT,'BEGIN');
12538 DisplayLineBoth(pPreScriptUFT, '');
12539 DisplayCenter(pPreScriptUFT,pStarHeader);
12540 DisplayCenter(pPreScriptUFT,CenterLine('*********** Hidden Parameters ***********'));
12541 DisplayCenter(pPreScriptUFT,pStarHeader);
12542 DisplayLineBoth(pPreScriptUFT, '');
12543 DisplayLineBoth(pPreScriptUFT, 'Please review and remove any unnecessary hidden/underscore parameters prior');
12544 DisplayLineBoth(pPreScriptUFT, 'to upgrading. It is strongly recommended that these be removed before upgrade');
12545 DisplayLineBoth(pPreScriptUFT, 'unless your application vendors and/or Oracle Support state differently.');
12546 DisplayLineBoth(pPreScriptUFT, 'Changes will need to be made in the init.ora or spfile.');
12547 DisplayLineBoth(pPreScriptUFT, '');
12548
12549 IF pOutputType = c_output_text THEN
12550 -- display parameters in TEXT to either screen or preupgrade.log
12551 parameters_display(1);
12552 DisplayLine(pOutputUFT, '');
12553 DisplayLine(pOutputUFT, pActionSuggested);
12554 END IF;
12555
12556 DisplayLine(pPreScriptUFT,'END;');
12557 DisplayBlankLine(pPreScriptUFT);
12558
12559 --
12560 -- Write to preupgrade_fixups.sql to display hidden parameters
12561 --
12562 IF pOutputFixupScripts THEN
12563 DisplayLine('');
12564 DisplayLine(pPreScriptUFT,'BEGIN');
12565 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line
12566 (' ******** Existing Hidden Parameters ********');!');
12567 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12568 DisplayLine(pPreScriptUFT, 'dbms_preup.parameters_display(1);');
12569 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12570 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line
12571 ('^^^ MANUAL ACTION SUGGESTED ^^^');!');
12572 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12573 DisplayLine(pPreScriptUFT, 'END;');
12574 DisplayBlankLine(pPreScriptUFT);
12575 END IF;
12576 END IF; -- end of hidden_params_in_use
12577 END IF;
12578 END hidden_params_recommend;
12579
12580 PROCEDURE underscore_events_recommend
12581 IS
12582 t_boolean BOOLEAN;
12583 t_status NUMBER;
12584 BEGIN
12585
12586 IF pOutputType = c_output_text THEN
12587 --
12588 -- underscore events that are set.
12589 --
12590 t_boolean := FALSE;
12591 BEGIN
12592 EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM sys.v$parameter2 WHERE (UPPER(name) = ''EVENT''
12593 OR UPPER(name)=''_TRACE_EVENTS'') AND isdefault=''FALSE'''
12594 INTO t_status;
12595 IF (t_status >= 1) THEN
12596 t_boolean := TRUE;
12597 END IF;
12598 EXCEPTION
12599 WHEN OTHERS THEN NULL;
12600 END;
12601
12602 IF t_boolean THEN
12603 DisplayLine(pPreScriptUFT, 'BEGIN');
12604 DisplayLineBoth(pPreScriptUFT, '');
12605 DisplayCenter(pPreScriptUFT,pStarHeader);
12606 DisplayCenter(pPreScriptUFT,CenterLine('************ Existing Events ************'));
12607 DisplayCenter(pPreScriptUFT,pStarHeader);
12608 DisplayLineBoth(pPreScriptUFT, '');
12609 DisplayLineBoth(pPreScriptUFT, 'Please review and remove any unnecessary events prior to upgrading.');
12610 DisplayLineBoth(pPreScriptUFT, 'It is strongly recommended that these be removed before upgrade unless');
12611 DisplayLineBoth(pPreScriptUFT, 'your application vendors and/or Oracle Support state differently.');
12612 DisplayLineBoth(pPreScriptUFT, 'Changes will need to be made in the init.ora or spfile.');
12613 DisplayLineBoth(pPreScriptUFT, '');
12614
12615 IF pOutputType = c_output_text THEN
12616 -- display parameters in TEXT to either screen or preupgrade.log
12617 parameters_display(2);
12618 DisplayLine(pOutputUFT, '');
12619 DisplayLine(pOutputUFT, pActionSuggested);
12620 END IF;
12621
12622 DisplayLine(pPreScriptUFT, 'END;');
12623 DisplayBlankLine(pPreScriptUFT);
12624
12625 --
12626 -- Write to preupgrade_fixups.sql to display events
12627 --
12628 IF pOutputFixupScripts THEN
12629 DisplayLine('');
12630
12631 DisplayLine(pPreScriptUFT, 'BEGIN');
12632 DisplayLine(pPreScriptUFT,q'!dbms_output.put_line (' ******** Existing Events ********');!');
12633 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12634 DisplayLine(pPreScriptUFT, 'dbms_preup.parameters_display(2);');
12635 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12636 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line
12637 ('^^^ MANUAL ACTION SUGGESTED ^^^');!');
12638 DisplayLine(pPreScriptUFT, q'!dbms_output.put_line ('');!');
12639 DisplayLine(pPreScriptUFT, 'END;');
12640 DisplayBlankLine(pPreScriptUFT);
12641 END IF;
12642 END IF; -- end of non_default_events
12643 END IF;
12644 END underscore_events_recommend;
12645
12646 PROCEDURE audit_records_recommend
12647 IS
12648 t_boolean BOOLEAN;
12649 t_status NUMBER;
12650 BEGIN
12651 IF pOutputType = c_output_text THEN
12652 t_boolean := FALSE;
12653 t_status := 0;
12654 -- There are three checks here - for various options of audit records.
12655 BEGIN
12656 EXECUTE IMMEDIATE 'SELECT count(*) FROM sys.aud$ WHERE dbid is null'
12657 INTO t_status;
12658 IF t_status > 250000 THEN
12659 t_boolean := TRUE;
12660 END IF;
12661 EXCEPTION
12662 WHEN OTHERS THEN NULL;
12663 END;
12664 BEGIN
12665 -- Standard Auditing, only when Oracle Label Security (OLS)
12666 -- and/or Database Vault (DV) is installed
12667 EXECUTE IMMEDIATE 'SELECT count(*) FROM system.aud$ WHERE dbid is null'
12668 INTO t_status;
12669 IF t_status > 250000 THEN
12670 t_boolean := TRUE;
12671 END IF;
12672 EXCEPTION
12673 WHEN OTHERS THEN NULL;
12674 END;
12675 BEGIN
12676 -- Fine Grained Auditing
12677 EXECUTE IMMEDIATE 'SELECT count(*) FROM sys.fga_log$ WHERE dbid is null'
12678 INTO t_status;
12679 IF t_status > 250000 THEN
12680 t_boolean := TRUE;
12681 END IF;
12682 EXCEPTION
12683 WHEN OTHERS THEN NULL;
12684 END;
12685
12686 IF t_boolean THEN
12687 DisplayLine(pPreScriptUFT, 'BEGIN');
12688 DisplayLineBoth(pPreScriptUFT, '');
12689 DisplayCenter(pPreScriptUFT,pStarHeader);
12690 DisplayCenter(pPreScriptUFT,CenterLine('******** Audit Record Pre-Processing ********'));
12691 DisplayCenter(pPreScriptUFT,pStarHeader);
12692 DisplayLineBoth(pPreScriptUFT, '');
12693 DisplayLineBoth(pPreScriptUFT, 'The database contains a large number of Audit records which can slow down');
12694 DisplayLineBoth(pPreScriptUFT, 'an upgrade. Please review My Oracle Support note number 1329590.1 ');
12695 DisplayLineBoth(pPreScriptUFT, 'for options on processing these records prior to the upgrade to save');
12696 DisplayLineBoth(pPreScriptUFT, 'upgrade down time');
12697 DisplayLineBoth(pPreScriptUFT, '');
12698 DisplayLineBoth(pPreScriptUFT, pActionSuggested);
12699 DisplayLineBoth(pPreScriptUFT, '');
12700 DisplayLine(pPreScriptUFT, 'END;');
12701 DisplayBlankLine(pPreScriptUFT);
12702 END IF;
12703 END IF;
12704 END audit_records_recommend;
12705
12706 PROCEDURE fixed_objects_recommend
12707 IS
12708 BEGIN
12709 IF pOutputType = c_output_text THEN
12710 DisplayLine(pPostScriptUFT, 'BEGIN');
12711 DisplayCenter(pPostScriptUFT,pStarHeader);
12712 DisplayCenter(pPostScriptUFT,CenterLine('******** Fixed Object Statistics ********'));
12713 DisplayCenter(pPostScriptUFT,pStarHeader);
12714
12715 DisplayLineBoth(pPostScriptUFT,'');
12716 DisplayLineBoth(pPostScriptUFT,'Please create stats on fixed objects two weeks');
12717 DisplayLineBoth(pPostScriptUFT,'after the upgrade using the command:');
12718 DisplayLineBoth(pPostScriptUFT,' EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;');
12719 DisplayLineBoth(pPostScriptUFT,'');
12720 DisplayLineBoth(pPostScriptUFT, pActionSuggested);
12721 DisplayLineBoth(pPostScriptUFT, '');
12722 DisplayLine(pPostScriptUFT, 'END;');
12723 DisplayBlankLine(pPostScriptUFT);
12724 END IF;
12725 END fixed_objects_recommend;
12726
12727
12728 -- if db is a noncdb, return TRUE
12729 -- if db is a cdb, return FALSE
12730 FUNCTION is_db_noncdb RETURN BOOLEAN
12731 IS
12732 b_isCdb BOOLEAN := FALSE;
12733 s_isCdb VARCHAR2(3) := 'NO';
12734 e_noColumnFound EXCEPTION; -- ORA-00904: "...": invalid identifier
12735 PRAGMA exception_init(e_noColumnFound, -904);
12736 BEGIN
12737 begin
12738 execute immediate 'select cdb from v$database'
12739 into s_isCdb;
12740 exception
12741 WHEN e_noColumnFound THEN s_isCdb := 'NO'; -- ORA-00904: invalid identifier
12742 end;
12743
12744 if (s_isCdb = 'YES') then
12745 return FALSE; -- is this db a non-cdb? no, this db is a cdb.
12746 else
12747 return TRUE; -- is this db a non-cdb? yes, this db is a non-cdb.
12748 end if;
12749
12750 END is_db_noncdb;
12751
12752
12753 -- if db is a cdb, return container name.
12754 -- if db is a noncdb, return container name (which is basically the db name).
12755 -- if db is pre-12.1, then it doesn't have a CON_NAME. just return db name.
12756 -- note: name returned is in uppercase.
12757 FUNCTION get_con_name RETURN VARCHAR2
12758 IS
12759 conName VARCHAR2(30) := '';
12760 e_noParamFound EXCEPTION; -- ORA-02003: invalid USERENV parameter
12761 PRAGMA exception_init(e_noParamFound, -2003);
12762 BEGIN
12763
12764 -- get container name
12765 begin
12766 execute immediate
12767 'select upper(SYS_CONTEXT(''USERENV'', ''CON_NAME'')) from sys.dual'
12768 into conName;
12769 exception
12770 WHEN e_noParamFound THEN conName := '';
12771 end;
12772
12773 -- if container name is null, then this must be a pre-121 db.
12774 -- just get db name.
12775 if conName is NULL then
12776 execute immediate 'select upper(name) from sys.v$database' into conName;
12777 end if;
12778
12779 return conName;
12780 END get_con_name;
12781
12782
12783 -- if db is a cdb, return container id.
12784 -- if db is a noncdb, return container id (which is 0).
12785 -- if db is pre-12.1, then it doesn't have a CON_ID. just return 0.
12786 -- note: a noncdb in 12.1 has a con id of 0.
12787 FUNCTION get_con_id RETURN NUMBER
12788 IS
12789 conId NUMBER := 0;
12790 e_noParamFound EXCEPTION; -- ORA-02003: invalid USERENV parameter
12791 PRAGMA exception_init(e_noParamFound, -2003);
12792 BEGIN
12793 begin
12794 execute immediate
12795 'select SYS_CONTEXT(''USERENV'', ''CON_ID'') from sys.dual'
12796 into conId;
12797 exception
12798 WHEN e_noParamFound THEN conId := 0;
12799 end;
12800
12801 return conId;
12802 END get_con_id;
12803
12804
12805 -- if run from the root, return total # of pdbs (including seed) in the cdb
12806 -- if run from the pdb, then return 1
12807 -- if this db is not a cdb or # of pdbs cannot be found, then return 0
12808 FUNCTION get_npdbs RETURN NUMBER
12809 IS
12810 nPdbs NUMBER := 0;
12811 e_noTblFound EXCEPTION; -- ORA-00942: table or view does not exist
12812 PRAGMA exception_init(e_noTblFound, -942);
12813 BEGIN
12814 begin
12815 execute immediate
12816 'select count(*) from sys.v$pdbs'
12817 into nPdbs;
12818 exception
12819 WHEN e_noTblFound THEN nPdbs := 0;
12820 end;
12821
12822 return nPdbs;
12823 END get_npdbs;
12824
12825
12826 --
12827 -- add an entry to registry$log to indicate preupgrade tool will start to run
12828 --
12829 PROCEDURE begin_log_preupg_action
12830 IS
12831 PRAGMA AUTONOMOUS_TRANSACTION;
12832 sqlString varchar2(500); -- string to build sql stmt to execute
12833 BEGIN
12834 IF tracing_on_xxx THEN
12835 dbms_output.put_line('XXX in begin_log_preupg_action');
12836 END IF;
12837
12838 -- only log upgrade entries into registry$log if db is opened for read write
12839 IF is_db_readonly = FALSE THEN
12840 IF tracing_on_xxx THEN
12841 dbms_output.put_line('XXX readOnlyMode is 0') ;
12842 END IF;
12843
12844 BEGIN
12845 sqlString :=
12846 'insert into sys.registry$log (cid, namespace, operation, optime) ' ||
12847 ' values (''PREUPG_BGN'', ' ||
12848 ' SYS_CONTEXT(''REGISTRY$CTX'', ''NAMESPACE''), -1, SYSTIMESTAMP)';
12849 EXECUTE IMMEDIATE sqlString;
12850 COMMIT;
12851 END;
12852 END IF;
12853 END begin_log_preupg_action;
12854
12855
12856 --
12857 -- add an entry to registry$log to indicate preupgrade tool had been run
12858 --
12859 PROCEDURE end_log_preupg_action
12860 IS
12861 PRAGMA AUTONOMOUS_TRANSACTION;
12862 conId NUMBER := sys.dbms_preup.get_con_id;
12863 conName VARCHAR2(30) := sys.dbms_preup.get_con_name;
12864 sqlString VARCHAR2(500); -- string to build sql stmt to execute
12865 BEGIN
12866
12867 IF tracing_on_xxx THEN
12868 dbms_output.put_line('XXX in end_log_preupg_action');
12869 END IF;
12870
12871 -- only log upgrade entries into registry$log if db is opened for read write
12872 IF is_db_readonly = FALSE THEN
12873 IF tracing_on_xxx THEN
12874 dbms_output.put_line('XXX readOnlyMode is 0') ;
12875 END IF;
12876
12877 BEGIN
12878 sqlString :=
12879 'insert into sys.registry$log (cid, namespace, operation, optime) ' ||
12880 ' values (''PREUPG_END'', ' ||
12881 ' SYS_CONTEXT(''REGISTRY$CTX'', ''NAMESPACE''), -1, SYSTIMESTAMP)';
12882 EXECUTE IMMEDIATE sqlString;
12883 COMMIT;
12884 END;
12885 END IF;
12886 END end_log_preupg_action;
12887
12888
12889 -- is db read only?
12890 -- return TRUE if db open mode is READ ONLY, else FALSE if READ WRITE
12891 FUNCTION is_db_readonly RETURN BOOLEAN
12892 IS
12893 b_retStat BOOLEAN := FALSE; -- default is FALSE or db is NOT read only
12894 open_mode VARCHAR2(80); -- open mode string
12895 BEGIN
12896 EXECUTE IMMEDIATE 'SELECT open_mode FROM sys.v$database' INTO open_mode;
12897 IF SUBSTR(open_mode, 1, 9) = 'READ ONLY' THEN
12898 b_retStat := TRUE;
12899 END IF;
12900
12901 return b_retStat;
12902 END is_db_readonly;
12903
12904
12905 -- is current container CDB$ROOT?
12906 -- if db is a cdb and current container connected to is root, return TRUE.
12907 -- else return FALSE.
12908 FUNCTION is_con_root RETURN BOOLEAN
12909 IS
12910 b_isCdb BOOLEAN := FALSE;
12911 b_retStat BOOLEAN := FALSE;
12912 conId NUMBER;
12913 BEGIN
12914
12915 IF sys.dbms_preup.is_db_noncdb = TRUE THEN -- this db is a non-cdb
12916 b_retStat := FALSE; -- no, it can't be the ROOT
12917 ELSE -- this db is a cdb
12918 conId := sys.dbms_preup.get_con_id; -- check con id
12919 IF (conId = 1) THEN -- ROOT's con id is 1
12920 b_retStat := TRUE; -- yes, current container is CDB$ROOT
12921 END IF;
12922 END IF;
12923
12924 return b_retStat;
12925 END is_con_root;
12926
12927
12928 --
12929 -- write_pdb_file:
12930 -- append a pdb file to a main destination file
12931 -- note: this is done if a write lock file is created.
12932 --
12933 PROCEDURE write_pdb_file (locDirObj IN VARCHAR2,
12934 pdbFileName IN VARCHAR2,
12935 pdbFilePtr IN OUT UTL_FILE.FILE_TYPE,
12936 destFileName IN VARCHAR2
12937 )
12938 -- locDirObj VARCHAR2(512) -- PREUPGRADE_DIR
12939 -- pdbFileName VARCHAR2(512) -- pdb file name to concat from
12940 -- pdbFilePtr UTL_FILE.FILE_TYPE -- pdb file pointer to concat from
12941 -- destFileName VARCHAR2(512) -- main destination file to write to
12942 IS
12943 destFilePtr UTL_FILE.FILE_TYPE; -- destination file to concat to
12944 buf VARCHAR2(15010); -- read line buffer (c_max_lsz + 10)
12945 line_num NUMBER := 0; -- line number to the pdb file
12946 invalidFileRename EXCEPTION;
12947 PRAGMA exception_init(invalidFileRename, -29292);
12948 BEGIN
12949 IF tracing_on_xxx THEN
12950 dbms_output.put_line('XXX in write_pdb_file');
12951 dbms_output.put_line('XXX pdbFileName is ' || pdbFileName);
12952 dbms_output.put_line('XXX destFileName is ' || destFileName);
12953 END IF;
12954
12955 -- Do not open the destination dest files unless write lock file is created.
12956 -- Possible destination files if this db is a PDB : preupgrade.log,
12957 -- preupgrade_fixups.sql, and postupgrade_fixups.sql.
12958 destFilePtr := UTL_FILE.FOPEN(locDirObj, destFileName, 'A');
12959
12960 -- close the pdb source file (currently opened for writes) so that it
12961 -- can be reopened for READ
12962 BEGIN
12963 UTL_FILE.FCLOSE(pdbFilePtr);
12964 pdbFilePtr := UTL_FILE.FOPEN(locDirObj, pdbFileName, 'R');
12965 EXCEPTION
12966 WHEN OTHERS THEN
12967 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
12968 END;
12969
12970 IF tracing_on_xxx THEN
12971 dbms_output.put_line('XXX open pdb file for read only ' || pdbFileName);
12972 END IF;
12973
12974 -- for each line in the pdb file, append it to the final destination file
12975 line_num := 0;
12976 LOOP
12977 BEGIN
12978 UTL_FILE.GET_LINE(pdbFilePtr, buf);
12979 line_num := line_num + 1;
12980 UTL_FILE.PUT_LINE(destFilePtr, buf, false);
12981 EXCEPTION
12982 WHEN NO_DATA_FOUND THEN
12983 EXIT; -- if here, then have read past the end of the file
12984 WHEN OTHERS THEN
12985 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
12986 END;
12987 END LOOP;
12988
12989 IF tracing_on_xxx THEN
12990 dbms_output.put_line('XXX ' || line_num || ' lines copied from pdb file');
12991 END IF;
12992
12993 -- clean up after concatenating pdb file to final destination file
12994 BEGIN
12995 -- after copying the pdb file into the main destination file, then
12996 -- close pdb file (source file)
12997 UTL_FILE.FCLOSE(pdbFilePtr); -- close pdb file
12998
12999 -- close final destination file
13000 UTL_FILE.FCLOSE(destFilePtr);
13001 EXCEPTION
13002 WHEN OTHERS THEN
13003 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
13004 END;
13005
13006 -- The pdb file was first created in the top level PREUPGRADE_DIR.
13007 -- After concatenating the pdb file into the main destination file, then let's
13008 -- move the pdb file to the pdbfiles subdirectory (under PREUPGRADE_DIR).
13009 IF pCreatedPdbDirObj = TRUE THEN
13010 BEGIN
13011 UTL_FILE.FRENAME(c_dir_obj, pdbFileName,
13012 c_pdb_dir_obj, pdbFileName, TRUE);
13013 IF tracing_on_xxx THEN
13014 dbms_output.put_line('XXX moving pdb file ' || pdbFileName ||
13015 ' to pdbfiles subdirectory');
13016 END IF;
13017 EXCEPTION
13018 WHEN invalidFileRename THEN NULL;
13019 WHEN OTHERS THEN
13020 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
13021 END;
13022 END IF; -- if pdb directory object exists
13023
13024 END write_pdb_file;
13025
13026 --
13027 -- get_write_lock:
13028 -- Returns TRUE if able to create an exclusive write lock file; else returns
13029 -- FALSE.
13030 -- Is only used for when concatenating a pdb file into a main destination
13031 -- file.
13032 --
13033 PROCEDURE get_write_lock
13034 IS
13035 lockFilePtr UTL_FILE.FILE_TYPE; -- lock file handle for exclusive write
13036 wr_loops NUMBER := 0; -- # of times looping for write lock file to be freed
13037 fileExist BOOLEAN := FALSE; -- file exists T/F
13038 fileSz NUMBER; -- file size
13039 blkLen NUMBER; -- block length
13040
13041 BEGIN
13042
13043 IF tracing_on_xxx THEN
13044 dbms_output.put_line('XXX getting write lock file');
13045 END IF;
13046
13047 -- loop until a lock file is created or until max # of looping have been hit,
13048 -- whichever comes first
13049 pGotWriteLock := FALSE;
13050 wr_loops := 0;
13051 WHILE (pGotWriteLock = FALSE AND wr_loops <= c_wrlock_max_waits)
13052 LOOP
13053 IF tracing_on_xxx THEN
13054 dbms_output.put_line('XXX write lock: wr_loops is ' || wr_loops);
13055 END IF;
13056
13057 -- does the lock file for exclusive writes exist?
13058 UTL_FILE.FGETATTR(pOutputLocation, c_wrlock_fname, fileExist, fileSz,
13059 blkLen);
13060
13061 -- if the lock file does not exist yet => create the write lock file
13062 -- else if the lock file already exists => sleep and then try again
13063 IF (fileExist = FALSE) THEN
13064 BEGIN
13065 -- create write lock file
13066 lockFilePtr := UTL_FILE.FOPEN(pOutputLocation, c_wrlock_fname, 'W');
13067 UTL_FILE.FCLOSE(lockFilePtr);
13068 pGotWriteLock := TRUE; -- got lock file
13069 IF tracing_on_xxx THEN
13070 dbms_output.put_line('XXX got write lock' );
13071 END IF;
13072 EXCEPTION
13073 WHEN OTHERS THEN
13074 pGotWriteLock := FALSE;
13075 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
13076 END;
13077 END IF;
13078
13079 IF pGotWriteLock = FALSE THEN
13080 -- sleep 1 sec per loop/wait for write lock
13081 dbms_lock.sleep(c_wrlock_sleep_secs);
13082 wr_loops := wr_loops + 1;
13083 END IF;
13084 END LOOP;
13085
13086 -- If # of loops exceeded, then just give up trying to get the
13087 -- write lock. Instead, just leave the output in the pdb *.<con_name>.* files
13088 -- output files and let user know.
13089 IF wr_loops > c_wrlock_max_waits THEN
13090 DisplayLinePL('');
13091 DisplayLinePL('====>> Note: Was not able to write output into log file ''' || c_output_fn || ''' in ' || pTextLogDir || '.');
13092 DisplayLinePL('The output from this run in ' || dbms_preup.get_con_name || ' will remain in ' || pOutputFName || '.');
13093 DisplayLinePL('Note: before running preupgrade tool, please make sure lock file ''' || c_wrlock_fname || ''' in ' || pTextLogDir || ' is removed.');
13094 DisplayLinePL('');
13095 END IF;
13096
13097 END get_write_lock;
13098
13099
13100 --
13101 -- concat_pdb_file
13102 -- 1. create a write lock file
13103 -- 2. if a lock file is gotten, then call write_pdb_file to append pdb files
13104 -- (preupgrd.<con_name>.log, preupgrade_fixups.<con_name>.sql,
13105 -- postupgrade_fixups.<con_name>.sql) to the main destination files
13106 -- (preupgrd.log, preupgrade_fixups.log, postupgrade_fixups.log).
13107 --
13108 PROCEDURE concat_pdb_file
13109 IS
13110
13111 pdbFilePtr UTL_FILE.FILE_TYPE; -- pdb file to concat from
13112 destFilePtr UTL_FILE.FILE_TYPE; -- final destination file to concat to
13113 e_userCancel EXCEPTION; -- ORA-01013: user requested cancel of current operation
13114 e_noOraConnect1 EXCEPTION; -- ORA-03113: end-of-file on communication channel
13115 e_noOraConnect2 EXCEPTION; -- ORA-03114: not connected to ORACLE
13116 PRAGMA exception_init(e_userCancel, -1013);
13117 PRAGMA exception_init(e_noOraConnect1, -3113);
13118 PRAGMA exception_init(e_noOraConnect2, -3114);
13119
13120 BEGIN
13121
13122 -- determine if if we are stay to concat or leave
13123 IF (pConcatToMainFile = FALSE) THEN
13124 -- nothing to concat into since the writes are already going directly
13125 -- to the final destination file
13126 -- and no write lock to get
13127
13128 IF tracing_on_xxx THEN
13129 dbms_output.put_line('XXX pConcatToMainFile is FALSE');
13130 END IF;
13131
13132 RETURN; -- exit procedure
13133 ELSE
13134 IF tracing_on_xxx THEN
13135 dbms_output.put_line('XXX pConcatToMainFile is TRUE');
13136 END IF;
13137 END IF; -- end of if pConcatToMainFile is TRUE
13138
13139 -- this is the meat of concat-ing pdb files into main destination files
13140 BEGIN
13141 -- create write lock file
13142 get_write_lock;
13143
13144 -- If we couldn't create the write lock file exclusively
13145 -- then just leave the output in the pdb *.<con_name>.* files
13146 -- and update the final destination variables.
13147 -- Else write from pdb files into main destinations files.
13148 --
13149 IF pGotWriteLock = FALSE THEN
13150 -- since we couldn't get the write lock, the final destination files are
13151 -- now the pdb files
13152 finalDestLogFn := pOutputFName;
13153
13154 IF (pOutputType = c_output_text) THEN
13155 -- preupgrade_fixups.sql and postupgrade_fixups.sql are only generated
13156 -- if file type is TEXT
13157 finalDestPreScriptFn := pPreScriptFname;
13158 finalDestPostScriptFn := pPostScriptFname;
13159 END IF;
13160
13161 ELSIF pGotWriteLock = TRUE THEN
13162 -- if we are here, that means write lock file was created
13163 -- now write from pdb files to main destination files
13164
13165 write_pdb_file(pOutputLocation, pOutputFName,
13166 pOutputUFT, finalDestLogFn);
13167 IF (pOutputType = c_output_text) THEN
13168 -- preupgrade_fixups.sql and postupgrade_fixups.sql are only generated
13169 -- if file type is TEXT
13170 write_pdb_file(pOutputLocation, pPreScriptFname,
13171 pPreScriptUFT, c_pre_script_fn);
13172 write_pdb_file(pOutputLocation, pPostScriptFname,
13173 pPostScriptUFT, c_post_script_fn);
13174 END IF;
13175
13176 -- clean up: remove lock file
13177 BEGIN
13178 UTL_FILE.FREMOVE(pOutputLocation, c_wrlock_fname);
13179 pGotWriteLock := FALSE;
13180 IF tracing_on_xxx THEN
13181 dbms_output.put_line('XXX removing write lock file');
13182 dbms_output.put_line('XXX pOutputLocation ' || pOutputLocation);
13183 dbms_output.put_line('XXX c_wrlock_fname ' || c_wrlock_fname);
13184 END IF;
13185 EXCEPTION
13186 WHEN OTHERS THEN
13187 dbms_output.put_line('');
13188 dbms_output.put_line(
13189 'Error when trying to remove write lock file. ' ||
13190 'Please check that file ' || c_wrlock_fname || 'is not in ' ||
13191 pTextLogDir || ' before rerunning the preupgrade tool.');
13192 dbms_output.put_line('');
13193 RAISE_APPLICATION_ERROR(-20000, 'Error: ' || SQLERRM);
13194 END;
13195 END IF; -- end if pGotWriteLock = TRUE
13196
13197 EXCEPTION
13198 -- if for some reason preupgrade tool is killed or we are not
13199 -- connected to oracle, then we have to clean up the write lock
13200 -- file and move the pdb files to pdbfiles subdir before exiting
13201 WHEN e_userCancel OR e_noOraConnect1 OR e_noOraConnect2 THEN
13202 IF pGotWriteLock = TRUE THEN
13203 BEGIN
13204 UTL_FILE.FREMOVE(pOutputLocation, c_wrlock_fname);
13205 EXCEPTION WHEN OTHERS THEN NULL;
13206 END;
13207
13208 BEGIN
13209 UTL_FILE.FRENAME(pOutputLocation, pOutputFName,
13210 c_pdb_dir_obj, pOutputFName, TRUE);
13211 EXCEPTION WHEN OTHERS THEN NULL;
13212 END;
13213
13214 BEGIN
13215 UTL_FILE.FRENAME(pOutputLocation, pPreScriptFname,
13216 c_pdb_dir_obj, pPreScriptFname, TRUE);
13217 EXCEPTION WHEN OTHERS THEN NULL;
13218 END;
13219
13220 BEGIN
13221 UTL_FILE.FRENAME(pOutputLocation, pPostScriptFname,
13222 c_pdb_dir_obj, pPostScriptFname, TRUE);
13223 EXCEPTION WHEN OTHERS THEN NULL;
13224 END;
13225
13226 pGotWriteLock := FALSE;
13227 ELSE -- IF pGotWriteLock is FALSE
13228 BEGIN
13229 UTL_FILE.FREMOVE(pOutputLocation, pOutputFName);
13230 EXCEPTION WHEN OTHERS THEN NULL;
13231 END;
13232
13233 BEGIN
13234 UTL_FILE.FREMOVE(pOutputLocation, pPreScriptFname);
13235 EXCEPTION WHEN OTHERS THEN NULL;
13236 END;
13237
13238 BEGIN
13239 UTL_FILE.FREMOVE(pOutputLocation, pPostScriptFname);
13240 EXCEPTION WHEN OTHERS THEN NULL;
13241 END;
13242 END IF;
13243
13244 RAISE_APPLICATION_ERROR(-20000,'Error: ' || SQLERRM);
13245 END;
13246 END concat_pdb_file;
13247
13248
13249 --
13250 -- end_preupgd:
13251 -- finishing steps to the preupgrade tool to be placed here
13252 --
13253 PROCEDURE end_preupgrd
13254 IS
13255 BEGIN
13256
13257 IF tracing_on_xxx THEN
13258 dbms_output.put_line('XXX in end_preupgrd');
13259 END IF;
13260
13261 --
13262 -- display a msg that the preupgrade checks are done
13263 --
13264 dbms_output.put_line('');
13265 dbms_output.put_line('***************************************************************************');
13266 dbms_output.put_line ('Pre-Upgrade Checks in ' || dbms_preup.get_con_name || ' Completed.');
13267 dbms_output.put_line('***************************************************************************');
13268 dbms_output.put_line('');
13269 dbms_output.put_line('***************************************************************************');
13270 DisplayLinePL('***************************************************************************');
13271
13272 --
13273 -- if db is NOT opened in read only mode, then log in registry$log that
13274 -- preupgrade tool has been run
13275 --
13276 IF is_db_readonly = FALSE
13277 THEN
13278 end_log_preupg_action;
13279 END IF;
13280
13281 IF pCreatedPdbDirObj THEN
13282 -- drop pdbfiles dir obj
13283 BEGIN
13284 EXECUTE IMMEDIATE 'DROP DIRECTORY :1' USING c_pdb_dir_obj;
13285 pCreatedPdbDirObj := FALSE;
13286 IF tracing_on_xxx THEN
13287 dbms_output.put_line('XXX PDB_PREUPGRADE_DIR dropped');
13288 END IF;
13289 EXCEPTION
13290 WHEN OTHERS THEN NULL;
13291 END;
13292
13293 IF pGotWriteLock = TRUE THEN
13294 UTL_FILE.FREMOVE(c_dir_obj, c_wrlock_fname);
13295 pGotWriteLock := FALSE;
13296 END IF;
13297 END IF; -- if pdb directory object exists
13298
13299 END end_preupgrd;
13300
13301 END dbms_preup;