DatabaseProcApplicationCreatedLinks
sybsystemprocssp_memlog  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** SP_MEMLOG
4     **
5     ** This file contains the definition of the sp_memlog system
6     ** stored procedure.  This stored procedure is used to change settings
7     ** of Memory Log.
8     ** The sybase_ts_role is required to make any changes to the
9     ** system configuration.
10    **
11    ** Security: The sybase_ts_role role is required in order to change memlog settings.
12    **
13    ** History:
14    ** May 2006	frankl		Initial coding, based on sp_shmdumpconfig
15    */
16    
17    create or replace procedure sp_memlog
18        /* -------------- Stored Procedure Parameters ----------------------- */
19        @action varchar(20) = "help", /* action requested by user   */
20        @dumps_per_file int = 10 /* dump count value           */
21    as
22    
23        /* ----------------- Declare Local Variables ------------------------ */
24        declare @object_info1 int, /* object_info1 column value  */
25            @attrib int, /* attribute column value     */
26            @not_status int, /* notification return status */
27            @int_value int
28    
29        /*
30        ** The following variables are treated as constants within this
31        ** stored procedure. They are set below.
32        */
33        declare @MEMLOG_CLASS int, /* sysattributes class        */
34            @OBJTYPE char(2), /* sysattributes object typ   */
35            @ATTR_ADD int, /* add notification value     */
36            @ATTR_CHANGE int, /* change notification val    */
37            @ATTR_DROP int, /* drop notification value    */
38            @ATTR_FETCH int /* fetch notification value   */
39    
40        /* 
41        ** The following variables are need for permission checking.
42        */
43        declare @nullarg char(1),
44            @dummy int,
45            @status int,
46            @gp_enabled int
47    
48    
49        /* ----------------- Setup and Validation ------------------------ */
50        set nocount on
51    
52        /*
53        ** Class ID and type defined in utils/attrib.lst
54        */
55        select @MEMLOG_CLASS = 30
56        select @OBJTYPE = "ML"
57    
58        /*
59        ** The following must correspond to values in sysattr.h
60        */
61        select @ATTR_ADD = 1
62        select @ATTR_CHANGE = 2
63        select @ATTR_DROP = 3
64        select @ATTR_FETCH = 4
65    
66        /*
67        ** Determine the attribute number and int_value for the attribute indicated
68        ** by the @action.
69        **
70        ** NOTE: The integer values used for attrib must correspond to values
71        ** defined in utils/attrib.lst.  Any changes made here must also be made
72        ** in attrib.lst, and vice versa.
73        **	0: suspend
74        **	1: sequence numbers
75        **	2: dump when full
76        **	3: dump destination
77        */
78        create table #actions(attrib int, int_val int, action varchar(20))
79    
80        insert #actions select 0, 0, 'enable logging'
81        insert #actions select 0, 1, 'disable logging'
82        insert #actions select 1, 0, 'disable sequence num'
83        insert #actions select 1, 1, 'enable sequence num'
84        insert #actions select 2, 0, 'no dump when full'
85        insert #actions select 2, 1, 'dump when full'
86    
87        /*
88        ** The following constants define record types for the melog dump destination
89        ** defined in cinclude/memlog.h.
90        */
91        insert #actions select 3, 0, 'dump to errorlog'
92        insert #actions select 3, 1, 'dump to file'
93        insert #actions select 3, 2, 'dump to shm'
94        insert #actions select 3, 3, 'dump to table'
95        insert #actions select 3, 4, 'disable dump'
96    
97        /*
98        ** End Common Definition Section
99        */
100   
101   
102       if @action = 'help'
103       begin
104   usage:
105           print ""
106           print "Usage: sp_memlog 'help'"
107           print "       sp_memlog 'list'"
108           print "       sp_memlog 'enable logging' | 'disable logging'"
109           print "       sp_memlog 'enable sequence num' | 'disable sequence num'"
110           print "       sp_memlog 'dump to errorlog' | 'dump to file'"
111           print "               | 'dump to shm' | 'dump to table' | 'disable dump'"
112           print "       sp_memlog '[no ]dump when full' [, dumps_per_file]"
113   
114           return 0
115       end
116   
117       if @action = 'list'
118       begin
119           goto list
120       end
121   
122       /*
123       ** Change settings section.
124       */
125   
126       /* 
127       ** The role sybase_ts_role is required to run this stored procedure.
128       ** proc_role and will also do auditing
129       ** if required. It will also print error message if required.
130       */
131   
132       select @nullarg = NULL
133       execute @status = sp_aux_checkroleperm "sybase_ts_role",
134           "sybase_ts_role", @nullarg, @gp_enabled output
135   
136       /* For Auditing */
137       if (@status != 0)
138       begin
139           if (proc_role("sybase_ts_role") < 1)
140               return (2)
141       end
142   
143       /*
144       ** Translate @action to attrib and int_value.
145       */
146       select @attrib = attrib, @int_value = int_val
147       from #actions
148       where action = @action
149   
150       if @@rowcount = 0
151       begin
152           /*
153           ** 18516, "Invalid action %1!"
154           */
155           raiserror 18516, @action
156           goto usage
157       end
158   
159       /*
160       ** Special case for 'dump when full': object_info1
161       ** becomes number of dumps per file.
162       */
163       select @object_info1 = NULL
164   
165       if @attrib = 2
166       begin
167           select @object_info1 = @dumps_per_file
168       end
169   
170       begin tran ChangeMemlog
171       /*
172       ** Delete existing entry, if there is one
173       */
174       delete master.dbo.sysattributes
175       where class = @MEMLOG_CLASS
176           and attribute = @attrib
177           and object_type = @OBJTYPE
178   
179       /*
180       ** Insert new values
181       */
182       insert master.dbo.sysattributes
183       (class, attribute, object_type,
184           int_value, object_info1)
185       values (@MEMLOG_CLASS, @attrib, @OBJTYPE,
186           @int_value, @object_info1)
187   
188       if (@@error = 0)
189       begin
190           select @not_status
191               = attrib_notify(@MEMLOG_CLASS, /*cl*/
192                   @attrib, /*attrib */
193                   @OBJTYPE, /*type*/
194                   NULL, /*object*/
195                   @object_info1, /*info1*/
196                   0, /*info2*/
197                   NULL, /*info3*/
198                   NULL, /*cinfo*/
199                   @int_value, /*intval*/
200                   NULL, /*charval*/
201                   NULL, /*textval*/
202                   NULL, /*imageval*/
203                   NULL, /*comment*/
204                   @ATTR_CHANGE)
205   
206           if (@not_status = 0)
207           begin
208               /*
209               ** 18505, "Notification failed. Condition not set."
210               */
211               raiserror 18505
212               goto error_exit
213           end
214       end
215       else
216       begin
217           goto error_exit
218       end
219   
220       commit ChangeMemlog
221   
222   list:
223       /*
224       ** Display current setting based on what is in sysattributes
225       */
226       print "Current settings"
227       print ""
228       select act.action,
229           dumps_per_file = att.object_info1
230       from master.dbo.sysattributes att,
231           #actions act
232       where att.class = @MEMLOG_CLASS
233           and object_type = @OBJTYPE
234           and act.attrib = att.attribute
235           and act.int_val = att.int_value
236   
237       /*
238       ** Indicate success
239       */
240       return 0
241   
242   error_exit:
243       /*
244       ** An error occured while inserting rows into the sysattributes table.
245       */
246       if (@@trancount > 0)
247       begin
248           /*
249           ** Rollback the current transaction
250           */
251           rollback tran ChangeMemlog
252       end
253   
254       return 18
255   
256   /*
257   ** End of sp_memlog
258   */
259   


exec sp_procxmode 'sp_memlog', 'AnyMode'
go

Grant Execute on sp_memlog to public
go
RESULT SETS
sp_memlog_rset_001

DEFECTS
 MEST 4 Empty String will be replaced by Single Space 105
 MEST 4 Empty String will be replaced by Single Space 227
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch attribute: smallint = int 185
 MTYP 4 Assignment type mismatch class: smallint = int 185
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use JOIN Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {attribute}
Uncovered: [object, object_info1, object_info2, object_info3, object_cinfo]
234
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 175
 QTYP 4 Comparison type mismatch smallint = int 175
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 176
 QTYP 4 Comparison type mismatch smallint = int 176
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 232
 QTYP 4 Comparison type mismatch smallint = int 232
 QTYP 4 Comparison type mismatch Comparison type mismatch: int vs smallint 234
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public sybsystemprocs..sp_memlog  
 MNER 3 No Error Check should check @@error after insert 80
 MNER 3 No Error Check should check @@error after insert 81
 MNER 3 No Error Check should check @@error after insert 82
 MNER 3 No Error Check should check @@error after insert 83
 MNER 3 No Error Check should check @@error after insert 84
 MNER 3 No Error Check should check @@error after insert 85
 MNER 3 No Error Check should check @@error after insert 91
 MNER 3 No Error Check should check @@error after insert 92
 MNER 3 No Error Check should check @@error after insert 93
 MNER 3 No Error Check should check @@error after insert 94
 MNER 3 No Error Check should check @@error after insert 95
 MNER 3 No Error Check should check @@error after delete 174
 MUCO 3 Useless Code Useless Brackets 137
 MUCO 3 Useless Code Useless Brackets 139
 MUCO 3 Useless Code Useless Brackets 140
 MUCO 3 Useless Code Useless Brackets 188
 MUCO 3 Useless Code Useless Brackets 206
 MUCO 3 Useless Code Useless Brackets 246
 MUIN 3 Column created using implicit nullability 78
 QAFM 3 Var Assignment from potentially many rows 146
 QIWC 3 Insert with not all columns specified missing 10 columns out of 15 183
 QNAJ 3 Not using ANSI Inner Join 230
 QNUA 3 Should use Alias: Column object_type should use alias att 233
 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}
175
 VNRD 3 Variable is not read @ATTR_ADD 61
 VNRD 3 Variable is not read @ATTR_DROP 63
 VNRD 3 Variable is not read @ATTR_FETCH 64
 VNRD 3 Variable is not read @gp_enabled 134
 VUNU 3 Variable is not used @dummy 44
 MRST 2 Result Set Marker 228
 MTR1 2 Metrics: Comments Ratio Comments: 42% 17
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 9 = 10dec - 3exi + 2 17
 MTR3 2 Metrics: Query Complexity Complexity: 101 17

DATA PROPAGATION detailed
ColumnWritten To
@dumps_per_filesysattributes.object_info1   °.char_value   sysattributes.object_info1   °.int_value   °.char_value   sp_dropdevice_rset_001.device sp_displayroles_rset_001.Role Name sp_displayroles_rset_002.Role Name sp_displayroles_rset_003.Role Name sp_displayroles_rset_004.Role Name
sp_dropdevice_rset_001.device sp_forceonline_object_rset_001.Object °.status sp_forceonline_object_rset_002.Object °.status sp_forceonline_page_rset_001.status sp_forceonline_page_rset_002.status sp_listsuspect_object_rset_001.Object °.Access sp_listsuspect_page_rset_001.Object
°.Access sp_makesuspect_obj_rset_001.Obj °.Indid °.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_002.Obj °.Indid
°.LogType °.PageType °.ErrType °.Delay °.TotalNum sp_makesuspect_obj_rset_003.Obj °.Indid °.LogType °.PageType °.ErrType
°.Delay °.TotalNum sp_memlog_rset_001.dumps_per_file sp_passwordpolicy_rset_001.message sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_rjs_retrieve_rset_001.host_name sp_setsuspect_granularity_rset_001.Online mode sp_ssladmin_rset_001.certificate_path
sp_ssladmin_rset_002.Cipher Suite Name °.Preference

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)  
read_writes table tempdb..#actions (1) 
writes table sybsystemprocs..sp_memlog_rset_001