DBA Data[Home] [Help]

PROCEDURE: SYS.VALIDATE_CONTEXT

Source


1 procedure validate_context
2 is
3   l_type#       binary_integer;
4   l_owner#      binary_integer;
5   l_ltype       varchar2(30) := 'FIRST';
6   l_status      binary_integer;
7   l_compile_sql varchar2(2000);
8   l_dbo_name    varchar2(32);
9   l_errcnt      number := 0;
10   l_upg_mode    boolean := FALSE;
11 begin
12 
13   select user# into l_owner# from sys.user$ where name = 'CTXSYS';
14   for c1 in (select dbo_name, dbo_type
15                from ctxsys.dr$dbo
16               where dbo_type != 'PUBLIC SYNONYM'
17               order by dbo_type, dbo_name)
18   loop
19     if (c1.dbo_type != l_ltype) then
20       select decode(c1.dbo_type, 'INDEX',         1,
21                                  'TABLE',         2,
22                                  'VIEW',          4,
23                                  'SEQUENCE',      6,
24                                  'PROCEDURE',     7,
25                                  'FUNCTION',      8,
26                                  'PACKAGE',       9,
27                                  'PACKAGE BODY', 11,
28                                  'TYPE',         13,
29                                  'TYPE BODY',    14,
30                                  'LIBRARY',      22,
31                                  'INDEXTYPE',    32,
32                                  'OPERATOR',     33,
33                                  0)
34         into l_type#
35         from dual;
36       l_ltype := c1.dbo_type;
37     end if;
38 
39     l_status := -1;
40     for c2 in (select status from sys.obj$
41                 where owner# = l_owner#
42                   and name = c1.dbo_name
43                   and type# = l_type#)
44     loop
45       l_status := c2.status;
46     end loop;
47 
48     if (l_status != 1) then
49       -- 3591109: Attempt to recompile invalid objects before issuing the
50       -- failure notice
51       l_dbo_name := dbms_assert.enquote_name(c1.dbo_name);
52       l_compile_sql :=
53         case c1.dbo_type
54           when 'VIEW' then
55             'alter view ctxsys.' || l_dbo_name || ' compile'
56           when 'PROCEDURE' then
57             'alter procedure ctxsys.' || l_dbo_name || ' compile'
58           when 'FUNCTION' then
59             'alter function ctxsys.' || l_dbo_name || ' compile'
60           when 'PACKAGE' then
61             'alter package ctxsys.' || l_dbo_name || ' compile'
62           when 'PACKAGE BODY' then
63             'alter package ctxsys.' || l_dbo_name || ' compile body'
64           when 'TYPE' then
65             'alter type ctxsys.' || l_dbo_name || ' compile'
66           when 'TYPE BODY' then
67             'alter type ctxsys.' || l_dbo_name || ' compile body'
68           when 'INDEXTYPE' then
69             'alter indextype ctxsys.' || l_dbo_name || ' compile'
70           when 'OPERATOR' then
71             'alter operator ctxsys.' || l_dbo_name || ' compile'
72           else null
73         end;
74 
75       if l_compile_sql is null then
76         dbms_output.put_line(
77           'FAILED CHECK FOR '||c1.dbo_type||' '||c1.dbo_name);
78         dbms_registry.invalid('CONTEXT');
79         goto endfunc;
80       else
81         begin
82           execute immediate l_compile_sql;
83         exception
84           when others then
85             dbms_output.put_line(
86               'FAILED CHECK FOR '||c1.dbo_type||' '||c1.dbo_name);
87             dbms_registry.invalid('CONTEXT');
88             goto endfunc;
89         end;
90       end if;
91     end if;
92   end loop;
93 
94   /* Bug 16936854 : Check if there were any errors during CONTEXT upgrade */
95   l_upg_mode := sys.dbms_registry.is_in_upgrade_mode();
96   if (l_upg_mode = TRUE) then
97     select count(*) into l_errcnt
98        from sys.registry$error
99       where identifier = 'CONTEXT';
100     if (l_errcnt != 0) then
101       dbms_registry.invalid('CONTEXT');
102       goto endfunc;
103     end if;
104   end if;
105 
106   dbms_registry.valid('CONTEXT');
107 
108 <<endfunc>>
109   null;
110 
111 exception
112   when others then
113     ctxsys.drue.text_on_stack(sqlerrm, 'validate_context');
114     dbms_registry.invalid('CONTEXT');
115     ctxsys.drue.raise;
116 end validate_context;