DatabaseProcApplicationCreatedLinks
sybsystemprocssp_shmdumpconfig_config  31 Aug 14Defects Dependencies

1     
2     /*
3     ** SP_SHMDUMPCONFIG_CONFIG
4     **
5     ** This file contains the definition of the sp_shmdumpconfig_config system
6     ** stored procedure.  This stored procedure is used to set "global" shared
7     ** memory dump configuration options (these are options not specified on a
8     ** per-condition basis. The sa_role is required to make any changes to the
9     ** system configuration.
10    **
11    ** Security: The sa_role role is required in order to execute this
12    ** stored procedure
13    **
14    ** History:
15    ** 06apr05	dwein		Initial coding
16    */
17    
18    create procedure sp_shmdumpconfig_config
19        /* -------------- Stored Procedure Parameters ----------------------- */
20        @option varchar(20), /* config option requested by user   */
21        @value int /* new value for config option	      */
22    
23    as
24    
25        /* ----------------- Declare Local Variables ------------------------ */
26        declare @cfgitem int, /* configuration option	      */
27            @not_status int, /* notification return status */
28            @ret_value int /* return value */
29    
30        /*
31        ** The following variables are treated as constants within this
32        ** stored procedure. They are set below.
33        */
34        declare @DUMPCOND_CLASS int, /* sysattributes class		*/
35            @OBJTYPE char(2), /* sysattributes object type	*/
36            @ATTRIB int, /* attribute column value	*/
37            @CFG_ERRORLOG int, /* include errorlog record id	*/
38            @CFG_MERGE int, /* merge pll dump record id	*/
39            @ATTR_ADD int, /* add notification value	*/
40            @ATTR_CHANGE int, /* change notification value	*/
41            @ATTR_DROP int, /* drop notification value	*/
42            @ATTR_FETCH int /* fetch notification value	*/
43    
44    
45        /* ----------------- Setup and Validation ------------------------ */
46        set nocount on
47    
48        /*
49        ** Verify that the user has sufficient permissions to
50        ** update the dump configuration
51        */
52        if (proc_role("sa_role") < 1)
53        begin
54            return 1
55        end
56    
57        /*
58        ** Class ID and type defined in utils/attrib.lst
59        */
60        select @DUMPCOND_CLASS = 7
61        select @OBJTYPE = "DC"
62        select @ATTRIB = 0
63    
64        /*
65        ** The following constants define record types for the dump condition
66        ** class in the sysattributes table for the config records. The values 
67        ** set here must be the same as those defined in utils/shmdump.c.
68        */
69        select @CFG_ERRORLOG = 1
70        select @CFG_MERGE = 2
71    
72        /*
73        ** The following must correspond to values in sysattr.h
74        */
75        select @ATTR_ADD = 1
76        select @ATTR_CHANGE = 2
77        select @ATTR_DROP = 3
78        select @ATTR_FETCH = 4
79    
80        select @ret_value = 0
81    
82        /* Validate the config option */
83        if (@option = "merge files")
84        begin
85            select @cfgitem = @CFG_MERGE
86        end
87        else if @option = "include errorlog"
88        begin
89            select @cfgitem = @CFG_ERRORLOG
90        end
91        else if @option is NULL
92        begin
93            goto usage
94        end
95        else
96        begin
97            /* 
98            ** 19401, "Invalid dump configuration option: '%1!'"
99            */
100           raiserror 19401, @option
101           select @ret_value = 2
102           goto usage
103       end
104   
105       /* Validate the value against the config option */
106       if (@cfgitem in (@CFG_MERGE, @CFG_ERRORLOG))
107       begin
108           /* valid values are 0 or 1 */
109           if (@value not in (0, 1))
110           begin
111               /* 
112               ** 19402, "Invalid configuration value '%1!' for option '%2!'"
113               */
114               raiserror 19402, @value, @option
115               select @ret_value = 3
116               goto usage
117           end
118       end
119   
120       begin tran update_dump_config
121   
122       /*
123       ** The sysattributes rows that represent this configuration options
124       ** do not exist until a user explicitly configures an option.  Prior
125       ** to that point ASE will use a hard coded default.  This procedure
126       ** needs to determine if it will be creating the row for the first
127       ** time, or if it will be updating an existing row
128       */
129       if exists (select * from master.dbo.sysattributes
130               where class = @DUMPCOND_CLASS
131                   and attribute = @ATTRIB
132                   and object = @cfgitem)
133       begin
134           /* the row already exists, update it */
135           update master.dbo.sysattributes
136           set int_value = @value
137           where class = @DUMPCOND_CLASS
138               and attribute = @ATTRIB
139               and object = @cfgitem
140       end
141       else
142       begin
143           /* insert the new row */
144           insert master.dbo.sysattributes
145           (class, attribute, object_type, object, int_value)
146           values
147           (@DUMPCOND_CLASS, @ATTRIB, @OBJTYPE,
148               @cfgitem, @value)
149       end
150   
151       if (@@error = 0)
152       begin
153           select @not_status
154               = attrib_notify(@DUMPCOND_CLASS, /*cl*/
155                   @ATTRIB, /*attrib*/
156                   @OBJTYPE, /*type*/
157                   @cfgitem, /*object*/
158                   NULL, /*info1*/
159                   NULL, /*info2*/
160                   NULL, /*info3*/
161                   NULL, /*cinfo*/
162                   @value, /*intval*/
163                   NULL, /*charval*/
164                   NULL, /*textval*/
165                   NULL, /*imageval*/
166                   NULL, /*comment*/
167                   @ATTR_CHANGE)
168   
169           if (@not_status = 0)
170           begin
171               /*
172               ** 18510, "Notification failed. Your change did not take affect."
173               */
174               raiserror 18510
175               rollback tran update_dump_config
176               return 3
177           end
178       end
179       else
180       begin
181           /* we had an error either inserting into or updating sysattributes */
182           rollback tran update_dump_config
183           return 4
184       end
185   
186       /*
187       ** Delete of rows and notification were successful.
188       ** Commit transaction.
189       */
190       commit tran uppdate_dump_config
191   
192       /*
193       ** Indicate success
194       */
195       return 0
196   
197   usage:
198       print ""
199       print "Valid CSMD configuration options:"
200       print "---------------------------------"
201       print "  'include errorlog', 0 | 1  (include the ASE errorlog in the dump file)"
202       print "  'merge files', 0 | 1  (merge dump files after a parellel dump)"
203       print ""
204   
205       return @ret_value
206   
207   /*
208   ** End sp_shmdumpconfig_config
209   */
210   


exec sp_procxmode 'sp_shmdumpconfig_config', 'AnyMode'
go

Grant Execute on sp_shmdumpconfig_config to public
go
DEFECTS
 MEST 4 Empty String will be replaced by Single Space 198
 MEST 4 Empty String will be replaced by Single Space 203
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch attribute: smallint = int 147
 MTYP 4 Assignment type mismatch class: smallint = int 147
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 130
 QTYP 4 Comparison type mismatch smallint = int 130
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 131
 QTYP 4 Comparison type mismatch smallint = int 131
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 137
 QTYP 4 Comparison type mismatch smallint = int 137
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 138
 QTYP 4 Comparison type mismatch smallint = int 138
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public sybsystemprocs..sp_shmdumpconfig_config  
 MNER 3 No Error Check should check @@error after update 135
 MNER 3 No Error Check should check @@error after insert 144
 MUCO 3 Useless Code Useless Brackets 52
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 106
 MUCO 3 Useless Code Useless Brackets 109
 MUCO 3 Useless Code Useless Brackets 151
 MUCO 3 Useless Code Useless Brackets 169
 QIWC 3 Insert with not all columns specified missing 10 columns out of 15 145
 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, class, attribute}
130
 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, class, attribute}
137
 VNRD 3 Variable is not read @ATTR_ADD 75
 VNRD 3 Variable is not read @ATTR_DROP 77
 VNRD 3 Variable is not read @ATTR_FETCH 78
 MSUB 2 Subquery Marker 129
 MTR1 2 Metrics: Comments Ratio Comments: 51% 18
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 9 = 11dec - 4exi + 2 18
 MTR3 2 Metrics: Query Complexity Complexity: 70 18

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

CALLERS
called by proc sybsystemprocs..sp_shmdumpconfig