DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dropexeclass  31 Aug 14Defects 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 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        select @action = 3 /* drop action */
26        select @attrib_id = 2 /* attribute is USERCLASS_DEFN */
27        select @object_type = 'UC' /* the type for USERCLASS_DEFN */
28    
29        /*
30        **  IF we're in a transaction, disallow this since it might make recovery
31        **  impossible.
32        */
33        IF @@trancount > 0
34        BEGIN
35            /*
36            ** 17260, "Can't run %1! from within a transaction."
37            */
38            raiserror 17260, "sp_dropexeclass"
39            return (1)
40        END
41        ELSE
42        BEGIN
43            /* Use TSQL mode of unchained transactions */
44            set chained off
45        END
46    
47        /* Dont do "Dirty Reads" */
48        set transaction isolation level 1
49    
50        /*
51        ** Check to see that the input params are correct
52        */
53        select @upcase_str = upper(@classname)
54        IF ((@upcase_str = "EC0") OR (@upcase_str = "EC1") OR
55                (@upcase_str = "EC2") OR (@upcase_str = "EC3"))
56        BEGIN
57            /*
58            ** 18555, "%1! is a system defined execution class which cannot be
59            **	   dropped."
60            */
61            raiserror 18555, @classname
62            return (1)
63        END
64    
65        IF not exists (select * from master..sysattributes where
66                    class = 6 AND
67                    attribute = @attrib_id AND
68                    object_type = @object_type AND
69                    object_cinfo = @classname)
70        BEGIN
71            /*
72            ** 18272, "'%1!' is not a valid execution class name"
73            */
74            raiserror 18272, @classname
75            return (1)
76        END
77    
78        /* Check that the execution class is not bound to any object in any db */
79        IF attrib_valid(6, @attrib_id, @object_type, NULL, NULL, NULL,
80                NULL, @classname, NULL, NULL, NULL, NULL, "",
81                @action) = 0
82    
83        BEGIN
84            /*
85            ** 18273, "Either '%1!' is being used so it cannot be dropped or
86            **	   an internal error occurred. Check server errorlog for
87            **	   any additional information."
88            */
89            raiserror 18273, @classname
90            return (1)
91        END
92    
93        /* Now delete exec class definition entry from Sysattributes Table in master */
94    
95        BEGIN
96            delete master..sysattributes
97            where class = 6 AND
98                attribute = @attrib_id AND
99                object_type = 'UC' AND
100               object_cinfo = @classname
101       END
102   
103       return (0)
104   
105   

DEFECTS
 MEST 4 Empty String will be replaced by Single Space 80
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 66
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 67
 QTYP 4 Comparison type mismatch smallint = int 67
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 97
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 98
 QTYP 4 Comparison type mismatch smallint = int 98
 MGTP 3 Grant to public master..sysattributes  
 MNER 3 No Error Check should check @@error after delete 96
 MUCO 3 Useless Code Useless Brackets 39
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 62
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Begin-End Pair 95
 MUCO 3 Useless Code Useless Brackets 103
 QISO 3 Set isolation level 48
 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}
66
 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}
97
 MSUB 2 Subquery Marker 65
 MTR1 2 Metrics: Comments Ratio Comments: 49% 15
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 10dec - 5exi + 2 15
 MTR3 2 Metrics: Query Complexity Complexity: 39 15

DEPENDENCIES
PROCS AND TABLES USED
read_writes table master..sysattributes (1)