DatabaseProcApplicationCreatedLinks
sybsystemprocssp_extengine  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "@(#) generic/sproc/src/%M% %I% %G%" */
3     /*      5.0     14.2    11/12/91        sproc/src/extengine */
4     
5     /*
6     ** Messages for "sp_extengine"      
7     **
8     ** 18888, "The server name specified does not exist."
9     ** 18889, "The specified command '%1!' does not exist."
10    ** 18892, "Unable to start the EJB Server. Check server errorlog for any additional 
11    ** information."
12    ** 18893, "Unable to stop the EJB Server. Check server errorlog for any additional 
13    ** information."
14    ** 18894, "Unable to determine the status of the EJB Server. Check server errorlog for 
15    ** any additional information."
16    **
17    */
18    create or replace procedure sp_extengine
19        @servername varchar(30),
20        @command varchar(30)
21    as
22        declare @srvclass smallint
23        declare @upper_command varchar(30)
24        declare @physname varchar(32)
25        declare @msg varchar(250)
26        declare @nullarg varchar(1)
27        declare @dummy int
28        declare @status int
29        declare @gp_enabled int
30    
31    
32    
33        select @upper_command = upper(@command)
34    
35        /*
36        **  if we're in a transaction, disallow this since it might make recovery
37        **  impossible.
38        */
39        if @@trancount > 0
40        begin
41            /*
42            ** 17260, "Can't run %1! from within a transaction."
43            */
44            raiserror 17260, "sp_extengine"
45            return (1)
46        end
47        else
48        begin
49            /* Use TSQL mode of unchained transactions */
50            set chained off
51        end
52    
53        /* Dont do "Dirty Reads" */
54        set transaction isolation level 1
55    
56        /* 
57        ** If granular permissions is not enabled then sa_role is required.
58        ** If granular permissions is enabled then the permission manage server is 
59        ** required.
60        */
61        select @nullarg = NULL
62        execute @status = sp_aux_checkroleperm "sa_role",
63            "manage server", @nullarg, @gp_enabled output
64    
65        /* For Auditing */
66        if (@gp_enabled = 0)
67        begin
68            if (proc_role("sa_role") = 0)
69                return 1
70        end
71        else
72        begin
73            select @dummy = proc_auditperm("manage server", @status)
74        end
75    
76        if (@status != 0)
77            return 1
78    
79        /* Get the class id corresponding to the server name being passed */
80        select @srvclass = srvclass from master.dbo.sysservers
81        where srvname = @servername
82    
83    
84        /*
85        ** Make sure that the class being passed, the server being passed and the
86        ** command being passed are valid commands
87        */
88        select @physname = srvnetname from master.dbo.sysservers
89        where srvclass = @srvclass and srvname = @servername
90    
91        if @@rowcount = 0
92        begin
93            /* 
94            ** 18888, "The server name specified does not exist."
95            */
96            raiserror 18888
97            return (1)
98        end
99        /* EJB Resolve : Put these commands into spt_values */
100   
101       if (@upper_command != "START" AND @upper_command != "STOP" AND @upper_command != "STATUS")
102       begin
103           /*
104           ** 18889, "The specified command '%1!' does not exist."
105           */
106           raiserror 18889, @command
107           return (1)
108       end
109   
110       /* Commands associate with the EJB Class of Server */
111       if (@srvclass = 10)
112       begin
113           if (@upper_command = "START")
114           begin
115               /* Server entry exists, start the server */
116               dbcc extengine(@physname, @srvclass, @command)
117               if (@@error != 0)
118               begin
119                   raiserror 18892
120                   return (1)
121               end
122           end
123           if (@upper_command = "STOP")
124           begin
125               /* Server entry exists, start the server */
126               dbcc extengine(@physname, @srvclass, @command)
127               if (@@error != 0)
128               begin
129                   raiserror 18893
130                   return (1)
131               end
132           end
133           if (@upper_command = "STATUS")
134           begin
135               /* Server entry exists, start the server */
136               dbcc extengine(@physname, @srvclass, @command)
137               if (@@error != 0)
138               begin
139                   raiserror 18894
140                   return (1)
141               end
142           end
143       end
144   


exec sp_procxmode 'sp_extengine', 'AnyMode'
go

Grant Execute on sp_extengine to public
go
DEFECTS
 MTYP 4 Assignment type mismatch @physname: varchar(32) = varchar(255) 88
 MGTP 3 Grant to public master..sysservers  
 MGTP 3 Grant to public sybsystemprocs..sp_extengine  
 MUCO 3 Useless Code Useless Brackets 45
 MUCO 3 Useless Code Useless Brackets 66
 MUCO 3 Useless Code Useless Brackets 68
 MUCO 3 Useless Code Useless Brackets 76
 MUCO 3 Useless Code Useless Brackets 97
 MUCO 3 Useless Code Useless Brackets 101
 MUCO 3 Useless Code Useless Brackets 107
 MUCO 3 Useless Code Useless Brackets 111
 MUCO 3 Useless Code Useless Brackets 113
 MUCO 3 Useless Code Useless Brackets 117
 MUCO 3 Useless Code Useless Brackets 120
 MUCO 3 Useless Code Useless Brackets 123
 MUCO 3 Useless Code Useless Brackets 127
 MUCO 3 Useless Code Useless Brackets 130
 MUCO 3 Useless Code Useless Brackets 133
 MUCO 3 Useless Code Useless Brackets 137
 MUCO 3 Useless Code Useless Brackets 140
 QISO 3 Set isolation level 54
 VNRD 3 Variable is not read @dummy 73
 VUNU 3 Variable is not used @msg 25
 MTR1 2 Metrics: Comments Ratio Comments: 45% 18
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 11 = 17dec - 8exi + 2 18
 MTR3 2 Metrics: Query Complexity Complexity: 67 18

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)  
reads table master..sysservers (1)