DatabaseProcApplicationCreatedLinks
sybsystemprocssp_setsuspect_error  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G% */
3     
4     /*
5     ** 17260, "Can't run %1! from within a transaction." 
6     ** 17421, "No such database -- run sp_helpdb to list databases."
7     ** 17422, "The 'master' database's options can not be changed."
8     ** 17428, "You must be in the 'master' database in order to change
9     **	database options."                                
10    */
11    
12    /*  *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING 
13    **
14    **  This procedure is solely for testing and debugging purposes only.
15    **           DO NOT USE IT ON PRODUCTION SYSTEMS.
16    */
17    
18    create or replace procedure sp_setsuspect_error
19        @dbname varchar(255) = NULL,
20        @errornum int = - 1
21    as
22        declare @dbid int, /* dbid of the database */
23            @attrib_id int,
24            @action int,
25            @object_type varchar(2),
26            @msg varchar(1024),
27            @class int,
28            @errortype int,
29            @error_freq int,
30            @sptlang int,
31            @sysdbid int,
32            @comment varchar(255),
33            @whichone int /* which language? */
34    
35        select @attrib_id = 4 /* attribute is SUSPECT error */
36        select @object_type = 'D'
37        select @errortype = 80
38        select @error_freq = 80
39        select @class = 10
40    
41    
42    
43        if @@trancount = 0
44        begin
45            set chained off
46        end
47    
48        set transaction isolation level 1
49    
50        select @sptlang = @@langid, @whichone = 0
51    
52        if @@langid != 0
53        begin
54            if not exists (
55                    select * from master.dbo.sysmessages where error
56                        between 17050 and 17069
57                        and langid = @@langid)
58                select @sptlang = 0
59        end
60    
61    
62        /*
63        **  If no @dbname given, assume the current database
64        */
65    
66        if @dbname is null
67            select @dbname = db_name()
68    
69        /*
70        **  Verify the database name and get the @dbid 
71        */
72        select @dbid = dbid from master.dbo.sysdatabases
73        where name = @dbname
74    
75        /*
76        **  If @dbname not found, say so.
77        */
78        if @dbid is NULL
79        begin
80            /*
81            ** 17421, "No such database -- run sp_helpdb to list databases."
82            */
83            exec sp_getmessage 17421, @msg output
84            print @msg
85            return (1)
86        end
87    
88        if @dbname in ("master", "model", "tempdb", "sybsecurity", "sybsystemprocs", "sybsystemdb")
89        begin
90            /*
91            ** 18523, "'%1!': Not allowed for System databases."
92            */
93            raiserror 18523, "sp_setsuspect_error"
94            return (1)
95        end
96    
97        /*
98        ** If only dbname is provided, then display the setting
99        */
100   
101       if @errornum = - 1
102       begin
103   
104           select "DBName" = @dbname, "Error Num" = int_value
105           from master.dbo.sysattributes
106           where class = @class AND
107               attribute = @attrib_id AND
108               object_type = @object_type AND
109               object = @dbid
110   
111           return (0)
112       end
113   
114       /*
115       **  Only the Accounts with sybase_ts_role can execute it.
116       */
117       if (proc_role("sybase_ts_role") < 1)
118       begin
119           return (1)
120       end
121   
122   
123       if db_name() != "master"
124       begin
125           /*
126           ** 17428, "You must be in the 'master' database in order to change database options."                                
127           */
128           exec sp_getmessage 17428, @msg output
129           print "sp_setsuspect_error: '%1!'", @msg
130           return (1)
131       end
132   
133       /*
134       **  If we're in a transaction, disallow this since it might make recovery
135       **  impossible.
136       */
137       if @@trancount > 0
138       begin
139           /*
140           ** 17260, "Can't run %1! from within a transaction." 
141           */
142           exec sp_getmessage 17260, @msg output
143           print @msg, "sp_setsuspect_error"
144           return (1)
145       end
146       else
147       begin
148           set chained off
149       end
150   
151       set transaction isolation level 1
152   
153   
154       /*
155       ** if an entry already exists for this database then update the entry,
156       ** otherwise insert a new row for this database.
157       ** When updating, change only the config value (object_info2) and not the
158       ** current value (int_value). The config value will take effect only
159       ** during the next boot/load time recovery of the database, during which
160       ** time the current value will be updated to the config value.
161       */
162       IF not exists (select * from master.dbo.sysattributes where
163                   class = @class AND
164                   attribute = @attrib_id AND
165                   object_type = @object_type AND
166                   object = @dbid AND
167                   int_value = @errornum)
168       begin
169           select @comment = "This error number will be added to the errors Recovery Fault Isolation can isolate"
170           insert master.dbo.sysattributes
171           (class, attribute, object_type, object, object_info1, int_value)
172           values (@class, @attrib_id, @object_type, @dbid, @errornum,
173               @errornum)
174       end
175   
176   
177   
178       /*
179       ** Display the setting 
180       */
181   
182       select "Database Name" = @dbname,
183           "Error Num" = int_value
184       from master.dbo.sysattributes
185       where class = @class AND
186           attribute = @attrib_id AND
187           object_type = @object_type AND
188           object = @dbid AND
189           int_value = @errornum
190   
191   
192       /*
193       ** 18526, "'%1!': The new values will become effective during the next recovery of the database."
194       */
195       exec sp_getmessage 18526, @msg output
196       print @msg, "sp_setsuspect_error", @dbname
197       return (0)
198   


exec sp_procxmode 'sp_setsuspect_error', 'AnyMode'
go

Grant Execute on sp_setsuspect_error to public
go
RESULT SETS
sp_setsuspect_error_rset_002
sp_setsuspect_error_rset_001

DEFECTS
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MINU 4 Unique Index with nullable columns master..sysmessages master..sysmessages
 MTYP 4 Assignment type mismatch attribute: smallint = int 172
 MTYP 4 Assignment type mismatch class: smallint = int 172
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 57
 QTYP 4 Comparison type mismatch smallint = int 57
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 106
 QTYP 4 Comparison type mismatch smallint = int 106
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 107
 QTYP 4 Comparison type mismatch smallint = int 107
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 163
 QTYP 4 Comparison type mismatch smallint = int 163
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 164
 QTYP 4 Comparison type mismatch smallint = int 164
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 185
 QTYP 4 Comparison type mismatch smallint = int 185
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 186
 QTYP 4 Comparison type mismatch smallint = int 186
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public master..sysmessages  
 MGTP 3 Grant to public sybsystemprocs..sp_setsuspect_error  
 MNER 3 No Error Check should check return value of exec 83
 MNER 3 No Error Check should check return value of exec 128
 MNER 3 No Error Check should check return value of exec 142
 MNER 3 No Error Check should check @@error after insert 170
 MNER 3 No Error Check should check return value of exec 195
 MUCO 3 Useless Code Useless Brackets 85
 MUCO 3 Useless Code Useless Brackets 94
 MUCO 3 Useless Code Useless Brackets 111
 MUCO 3 Useless Code Useless Brackets 117
 MUCO 3 Useless Code Useless Brackets 119
 MUCO 3 Useless Code Useless Brackets 130
 MUCO 3 Useless Code Useless Brackets 144
 MUCO 3 Useless Code Useless Brackets 197
 QCRS 3 Conditional Result Set 104
 QISO 3 Set isolation level 48
 QISO 3 Set isolation level 151
 QIWC 3 Insert with not all columns specified missing 9 columns out of 15 171
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
55
 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}
106
 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}
163
 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}
185
 VNRD 3 Variable is not read @errortype 37
 VNRD 3 Variable is not read @error_freq 38
 VNRD 3 Variable is not read @whichone 50
 VNRD 3 Variable is not read @sptlang 58
 VNRD 3 Variable is not read @comment 169
 VUNU 3 Variable is not used @action 24
 VUNU 3 Variable is not used @sysdbid 31
 MRST 2 Result Set Marker 104
 MRST 2 Result Set Marker 182
 MSUB 2 Subquery Marker 54
 MSUB 2 Subquery Marker 162
 MTR1 2 Metrics: Comments Ratio Comments: 39% 18
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 13 = 18dec - 7exi + 2 18
 MTR3 2 Metrics: Query Complexity Complexity: 80 18

DATA PROPAGATION detailed
ColumnWritten To
@dbnamesp_setsuspect_error_rset_001.DBName sp_setsuspect_error_rset_002.Database Name
@errornumsysattributes.object   °.object_info1   °.object_info3   °.int_value   °.char_value   sysremotelogins.remoteserverid   sysservers.srvid   sysattributes.object_info1   °.object_info3   °.int_value  
°.char_value   sp_dropdevice_rset_001.device sp_checknames_rset_006.remoteserverid sp_checknames_rset_007.srvid sp_checknames_rset_008.srvid sp_dbrecovery_order_rset_001.Database Name °.Database id °.Recovery Order sp_dbrecovery_order_rset_002.Recovery Order sp_displayroles_rset_001.Role Name
sp_displayroles_rset_002.Role Name °.Grantee sp_displayroles_rset_003.Role Name sp_displayroles_rset_004.Role Name sp_dropdevice_rset_001.device sp_forceonline_object_rset_001.Objid °.Object °.status sp_forceonline_object_rset_002.Objid °.Object
°.status sp_forceonline_page_rset_001.Pageid °.status sp_forceonline_page_rset_002.Pageid °.status sp_listsuspect_object_rset_001.Objid °.Object °.Access sp_listsuspect_page_rset_001.Pageid °.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 °.host_port sp_setsuspect_error_rset_001.Error Num
sp_setsuspect_error_rset_002.Error Num sp_setsuspect_granularity_rset_001.Online mode sp_setsuspect_threshold_rset_001.Cur. Suspect threshold sp_setsuspect_threshold_rset_002.Cur. Suspect Threshold sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference

DEPENDENCIES
PROCS AND TABLES USED
reads table master..sysmessages (1)  
calls proc sybsystemprocs..sp_getmessage  
   reads table master..sysmessages (1)  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
read_writes table master..sysattributes (1)  
writes table sybsystemprocs..sp_setsuspect_error_rset_002 
writes table sybsystemprocs..sp_setsuspect_error_rset_001 
reads table master..sysdatabases (1)