DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dropexeclass  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G% */
3     
4     /*
5     ** Messages for "sp_dropexeclass"
6     **
7     ** 17260, "Can't run %1! from within a transaction."
8     ** 18272, "'%1!' is not a valid execution class name"
9     ** 18273, "Either '%1!' is being used so it cannot be dropped or an
10    **	   internal error occurred. Check server errorlog for any
11    **	   additional information."
12    ** 18555, "%1! is a system defined execution class which cannot be dropped."
13    */
14    
15    create or replace procedure sp_dropexeclass
16        @classname varchar(255) /* name of class */
17    
18    as
19    
20        declare @attrib_id int,
21            @action int,
22            @object_type varchar(2),
23            @upcase_str varchar(255)
24    
25        declare @nullarg char(1)
26        declare @dummy int
27        declare @status int
28        declare @gp_enabled int
29    
30    
31        select @action = 3 /* drop action */
32        select @attrib_id = 2 /* attribute is USERCLASS_DEFN */
33        select @object_type = 'UC' /* the type for USERCLASS_DEFN */
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_dropexeclass"
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        ** Check to see that the input params are correct
58        */
59        select @upcase_str = upper(@classname)
60        IF ((@upcase_str = "EC0") OR (@upcase_str = "EC1") OR
61                (@upcase_str = "EC2") OR (@upcase_str = "EC3"))
62        BEGIN
63            /*
64            ** 18555, "%1! is a system defined execution class which cannot be
65            **	   dropped."
66            */
67            raiserror 18555, @classname
68            return (1)
69        END
70    
71        IF not exists (select * from master..sysattributes where
72                    class = 6 AND
73                    attribute = @attrib_id AND
74                    object_type = @object_type AND
75                    object_cinfo = @classname)
76        BEGIN
77            /*
78            ** 18272, "'%1!' is not a valid execution class name"
79            */
80            raiserror 18272, @classname
81            return (1)
82        END
83    
84        /* Check that the execution class is not bound to any object in any db */
85        IF attrib_valid(6, @attrib_id, @object_type, NULL, NULL, NULL,
86                NULL, @classname, NULL, NULL, NULL, NULL, "",
87                @action) = 0
88    
89        BEGIN
90            /*
91            ** 18273, "Either '%1!' is being used so it cannot be dropped or
92            **	   an internal error occurred. Check server errorlog for
93            **	   any additional information."
94            */
95            raiserror 18273, @classname
96            return (1)
97        END
98    
99    
100       /*
101       ** If granular permissions is not enabled then sa_role is required.
102       ** If granular permissions is enabled then the permission 
103       ** 'manage any execution class' is required.  proc_role and proc_auditperm 
104       ** will also do auditing if required. Both will also print error message 
105       ** if required.
106       */
107   
108       select @nullarg = NULL
109       execute @status = sp_aux_checkroleperm "sa_role", "manage any execution class",
110           @nullarg, @gp_enabled output
111   
112       /* For Auditing */
113       if (@gp_enabled = 0)
114       begin
115           if (proc_role("sa_role") = 0)
116               return (1)
117       end
118       else
119       begin
120           select @dummy = proc_auditperm("manage any execution class", @status)
121       end
122   
123       if (@status != 0)
124           return (1)
125   
126       /* Now delete exec class definition entry from Sysattributes Table in master */
127   
128       BEGIN
129           delete master..sysattributes
130           where class = 6 AND
131               attribute = @attrib_id AND
132               object_type = 'UC' AND
133               object_cinfo = @classname
134       END
135   
136       return (0)
137   
138   


exec sp_procxmode 'sp_dropexeclass', 'AnyMode'
go

Grant Execute on sp_dropexeclass to public
go
DEFECTS
 MEST 4 Empty String will be replaced by Single Space 86
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 72
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 73
 QTYP 4 Comparison type mismatch smallint = int 73
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 130
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 131
 QTYP 4 Comparison type mismatch smallint = int 131
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public sybsystemprocs..sp_dropexeclass  
 MNER 3 No Error Check should check @@error after delete 129
 MUCO 3 Useless Code Useless Brackets 45
 MUCO 3 Useless Code Useless Brackets 60
 MUCO 3 Useless Code Useless Brackets 68
 MUCO 3 Useless Code Useless Brackets 81
 MUCO 3 Useless Code Useless Brackets 96
 MUCO 3 Useless Code Useless Brackets 113
 MUCO 3 Useless Code Useless Brackets 115
 MUCO 3 Useless Code Useless Brackets 116
 MUCO 3 Useless Code Useless Brackets 123
 MUCO 3 Useless Code Useless Brackets 124
 MUCO 3 Useless Code Useless Begin-End Pair 128
 MUCO 3 Useless Code Useless Brackets 136
 QISO 3 Set isolation level 54
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
72
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
130
 VNRD 3 Variable is not read @dummy 120
 MSUB 2 Subquery Marker 71
 MTR1 2 Metrics: Comments Ratio Comments: 44% 15
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 10 = 14dec - 6exi + 2 15
 MTR3 2 Metrics: Query Complexity Complexity: 54 15

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