DatabaseProcApplicationCreatedLinks
sybsystemprocssp_shmdumpdrop  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** SP_SHMDUMPDROP
4     **
5     ** This stored procedure is used to drop shared memory dump conditions.
6     ** It is called by the sp_shmdumpconfig stored procedure when I user
7     ** invokes sp_shmdumpconfig to drop a dump condition.
8     **
9     ** Security: If granular permissions is not enabled the sa_role role is 
10    ** required in order to execute this stored procedure. If granular permissions
11    ** is enabled then the permission 'manage server configuration' is required.
12    **
13    ** History:
14    ** 19sept96	pdorfman	Initial coding
15    ** 07Apr97	pdorfman	Created separate stored procedure
16    ** 18apr11	malloy		Added support for granular permissions.
17    */
18    
19    create or replace procedure sp_shmdumpdrop
20        /* -------------- Stored Procedure Parameters ----------------------- */
21        @type varchar(20), /* type of attribute affected */
22        @value int, /* attribute value            */
23        @attrib int /* attribute id from caller   */
24    as
25    
26        /* ----------------- Declare Local Variables ------------------------ */
27        declare @object int, /* object column value        */
28            @not_status int, /* notification return status */
29            @nullarg char(1),
30            @dummy int,
31            @status int,
32            @gp_enabled int
33    
34    
35    
36        /*
37        ** The following variables are treated as constants within this
38        ** stored procedure. They are set below.
39        */
40        declare @DUMPCOND_CLASS int, /* sysattributes class        */
41            @OBJTYPE char(2), /* sysattributes object typ   */
42            @CFG_PRIMARY int, /* primary record id          */
43            @CFG_FILENAME int, /* file name record id        */
44            @CFG_DIRNAME int, /* directory name record id   */
45            @CFG_MAXDUMPS int, /* maxdumps record id         */
46            @CFG_PAGECACHE int, /* page cache record id       */
47            @CFG_PROCCACHE int, /* proc cache record id       */
48            @CFG_UNUSED int, /* unused memory record id    */
49            @ATTR_ADD int, /* add notification value     */
50            @ATTR_CHANGE int, /* change notification val    */
51            @ATTR_DROP int, /* drop notification value    */
52            @ATTR_FETCH int, /* fetch notification value   */
53            @CFG_INCLUDE int, /* include memory type        */
54            @CFG_OMIT int, /* omit memory type           */
55            @CFG_DEFAULT int /* use default mem setting    */
56    
57        /* ----------------- Setup and Validation ------------------------ */
58        set nocount on
59    
60        /* 
61        ** If granular permissions is not enabled then sa_role is required.
62        ** If granular permissions is enabled then the permission 
63        ** 'manage server configuration' is required.  proc_role and proc_auditperm 
64        ** will also do auditing if required. Both will also print error message if 
65        ** required.
66        */
67    
68        select @nullarg = NULL
69        execute @status = sp_aux_checkroleperm "sa_role", "manage server configuration",
70            @nullarg, @gp_enabled output
71    
72        /* For Auditing */
73        if (@gp_enabled = 0)
74        begin
75            if (proc_role("sa_role") = 0)
76                return (1)
77        end
78        else
79        begin
80            select @dummy = proc_auditperm("manage server configuration", @status)
81        end
82    
83        if (@status != 0)
84            return (1)
85    
86        /*
87        **  Common Definition Section: Note: any changes made to the following
88        **  values must also be made in shmdumpconfig and shmdumpdisp
89        */
90    
91        /*
92        ** Class ID and type defined in utils/attrib.lst
93        */
94        select @DUMPCOND_CLASS = 7
95        select @OBJTYPE = "DC"
96    
97        /*
98        ** The following constants define record types for the dump condition
99        ** class in the sysattributes table.The values set here must be the 
100       ** same as those defined in utils/cfgdump.c.
101       */
102       select @CFG_PRIMARY = 1
103       select @CFG_FILENAME = 2
104       select @CFG_DIRNAME = 3
105       select @CFG_MAXDUMPS = 4
106       select @CFG_PAGECACHE = 5
107       select @CFG_PROCCACHE = 6
108       select @CFG_UNUSED = 7
109   
110       /*
111       ** The following must correspond to values in sysattr.h
112       */
113       select @ATTR_ADD = 1
114       select @ATTR_CHANGE = 2
115       select @ATTR_DROP = 3
116       select @ATTR_FETCH = 4
117   
118       /*
119       ** End Common Definition Section
120       */
121   
122       /* ----------------- Identify and Perform the Command ----------- */
123   
124       if (@type = 'defaults')
125       begin
126           /*
127           ** 18508, "You cannot drop the system default settings"
128           */
129           raiserror 18508
130           return 1
131       end
132   
133       begin tran drop_condition
134   
135       /*
136       ** Delete all rows belonging to this condition from
137       ** the sysattributes table.
138       */
139       if (@type in ('severity', 'timeslice', 'defaults', 'panic', 'dbcc')
140               and @value is NULL)
141       begin
142           /*
143           ** Value not required in order to drop
144           ** a severity, timeslice, panic, dbcc or defaults condition
145           */
146           delete master.dbo.sysattributes
147           where class = @DUMPCOND_CLASS
148               and object_type = @OBJTYPE
149               and attribute = @attrib
150       end
151       else
152       begin
153           /*
154           ** For other condition types a value
155           ** must also be supplied.
156           */
157           select @object = @value
158           delete master.dbo.sysattributes
159           where class = @DUMPCOND_CLASS
160               and object_type = @OBJTYPE
161               and attribute = @attrib
162               and object = @object
163       end
164   
165       if (@@rowcount = 0)
166       begin
167           /*
168           ** 18509, "There is no condition set for %1! %2!"
169           */
170           raiserror 18509, @type, @object
171           rollback tran drop_condition
172           return 1
173       end
174   
175       if (@@error = 0)
176       begin
177           select @not_status = attrib_notify(
178                   @DUMPCOND_CLASS, /*cl*/
179                   @attrib, /*attrib */
180                   @OBJTYPE, /*type*/
181                   @object, /*object*/
182                   @CFG_PRIMARY, /*info1*/
183                   NULL, /*info2*/
184                   NULL, /*info3*/
185                   NULL, /*cinfo*/
186                   NULL, /*intval*/
187                   NULL, /*charval*/
188                   NULL, /*textval*/
189                   NULL, /*imageval*/
190                   NULL, /*comment*/
191                   @ATTR_DROP)
192   
193           if (@not_status = 0)
194           begin
195               /*
196               ** 18510, "Notification failed. Your change did not take affect."
197               */
198               raiserror 18510
199               rollback tran drop_condition
200               return 1
201           end
202       end
203   
204       /*
205       ** Delete of rows and notification were successful.
206       ** Commit transaction.
207       */
208       commit tran drop_condition
209   
210       /*
211       ** Indicate success
212       */
213       return 0
214   
215   /*
216   ** End sp_shmdumpdrop
217   */
218   


exec sp_procxmode 'sp_shmdumpdrop', 'AnyMode'
go

Grant Execute on sp_shmdumpdrop to public
go
DEFECTS
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 147
 QTYP 4 Comparison type mismatch smallint = int 147
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 149
 QTYP 4 Comparison type mismatch smallint = int 149
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 159
 QTYP 4 Comparison type mismatch smallint = int 159
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 161
 QTYP 4 Comparison type mismatch smallint = int 161
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public sybsystemprocs..sp_shmdumpdrop  
 MNER 3 No Error Check should check @@error after delete 146
 MNER 3 No Error Check should check @@error after delete 158
 MUCO 3 Useless Code Useless Brackets 73
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 76
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 84
 MUCO 3 Useless Code Useless Brackets 124
 MUCO 3 Useless Code Useless Brackets 139
 MUCO 3 Useless Code Useless Brackets 165
 MUCO 3 Useless Code Useless Brackets 175
 MUCO 3 Useless Code Useless Brackets 193
 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: {class, object_type, attribute}
147
 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, attribute, class}
159
 VNRD 3 Variable is not read @dummy 80
 VNRD 3 Variable is not read @CFG_FILENAME 103
 VNRD 3 Variable is not read @CFG_DIRNAME 104
 VNRD 3 Variable is not read @CFG_MAXDUMPS 105
 VNRD 3 Variable is not read @CFG_PAGECACHE 106
 VNRD 3 Variable is not read @CFG_PROCCACHE 107
 VNRD 3 Variable is not read @CFG_UNUSED 108
 VNRD 3 Variable is not read @ATTR_ADD 113
 VNRD 3 Variable is not read @ATTR_CHANGE 114
 VNRD 3 Variable is not read @ATTR_FETCH 116
 VUNU 3 Variable is not used @CFG_INCLUDE 53
 VUNU 3 Variable is not used @CFG_OMIT 54
 VUNU 3 Variable is not used @CFG_DEFAULT 55
 MTR1 2 Metrics: Comments Ratio Comments: 54% 19
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 10dec - 5exi + 2 19
 MTR3 2 Metrics: Query Complexity Complexity: 63 19

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

CALLERS
called by proc sybsystemprocs..sp_shmdumpconfig