Database | Proc | Application | Created | Links |
sybsystemprocs | sp_showcontrolinfo ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = %Z% generic/sproc/%M% %I% %G% */ 3 4 /* 5 ** Messages for "sp_showcontrolinfo" ???? 6 ** 7 ** 17260, "Can't run %1! from within a transaction." 8 ** 18276, "'%1!" is not a valid object type." 9 ** 18291, "The parameter value '%1!' is invalid." 10 */ 11 12 create procedure sp_showcontrolinfo 13 @object_type varchar(2) = NULL, /* type of object */ 14 @object_name varchar(255) = NULL, /* name of object */ 15 @spid int = NULL /* SQL Server process id */ 16 as 17 18 declare @attrib_id int, 19 @user_name varchar(255), 20 @upcase_str varchar(2) 21 22 select @attrib_id = 0 /* initialization */ 23 24 /* 25 ** If we're in a transaction, disallow this since it might make recovery 26 ** impossible. 27 */ 28 IF @@trancount > 0 29 BEGIN 30 /* 31 ** 17260, "Can't run %1! from within a transaction." 32 */ 33 raiserror 17260, "sp_showcontrolinfo" 34 return (1) 35 END 36 ELSE 37 BEGIN 38 /* Use TSQL mode of unchained transactions */ 39 set chained off 40 END 41 42 /* Dont use any "Dirty Reads" */ 43 set transaction isolation level 1 44 45 /* convert object_type to upper case */ 46 IF (@object_type is not NULL) 47 select @object_type = upper(@object_type) 48 49 /* 50 ** Check to see that the input params are correct 51 */ 52 IF @object_type not in (NULL, 'AP', 'LG', 'PR', 'PS', 'EG', 'DF', 'SV') 53 BEGIN 54 /* 55 ** 18276,"'%1!' is not a valid object type." 56 */ 57 raiserror 18276, @object_type 58 return (1) 59 END 60 61 IF ((@object_type = 'DF') AND ((@object_name is not NULL) OR (@spid is not NULL))) 62 BEGIN 63 /* 18291, "The parameter value '%1!' is invalid." */ 64 raiserror 18291, "for object name or spid" 65 return 1 66 END 67 68 /* 69 ** Create Table to hold results 70 ** For SDC, there is one extra column, instance id; For SMP, column value null. 71 */ 72 CREATE table #shcinfo_res 73 (type varchar(2), 74 object_name varchar(255) null, 75 scope varchar(255) null, 76 exec_class varchar(255) null, 77 engine_group varchar(255) null, 78 engines varchar(390) null, 79 spid int null, 80 attribute varchar(255) null, 81 attribute_value varchar(255) null, 82 instanceid int null) 83 84 /* 85 ** Now look into Sysattributes Table... 86 ** Note that this sp looks into the sysattributes table of the current db. 87 */ 88 DECLARE appl_info cursor for 89 select object_type, object, object_info1, object_info3, 90 object_cinfo, int_value, convert(varchar(416), char_value) 91 from sysattributes 92 where (class = 6) 93 94 DECLARE @type varchar(2), 95 @obj int, 96 @info1 int, 97 @info3 int, 98 @cinfo varchar(255), 99 @intval int, 100 @charval varchar(768), 101 @eng_str varchar(768), 102 @eng_num varchar(10), 103 @eng_list varchar(768), 104 @len int, 105 @term int 106 107 OPEN appl_info 108 109 FETCH appl_info into @type, @obj, @info1, @info3, @cinfo, @intval, @charval 110 WHILE (@@sqlstatus != 2) 111 BEGIN 112 /* 113 ** Get the definitions for the given object type or all 114 ** object types in the sysattributes table. 115 */ 116 IF ((@object_type is NULL) OR (@object_type = @type)) 117 118 /* Look for class bindings for an user */ 119 120 IF (@type = "LG") 121 BEGIN 122 select @user_name = (select name from 123 master..syslogins where (suid = @obj)) 124 IF ((@object_name is NULL) OR 125 (@object_name = @user_name)) 126 BEGIN 127 insert into #shcinfo_res 128 values (@type, @user_name, 129 @cinfo, @charval, NULL, 130 NULL, NULL, NULL, NULL, @info3) 131 END 132 END 133 134 /* Look for class bindings for an application */ 135 136 ELSE IF (@type = "AP") 137 BEGIN 138 IF ((@object_name is NULL) OR 139 (@object_name = @cinfo)) 140 BEGIN 141 IF (@info1 >= 0) 142 select @user_name = 143 (select name from 144 master..syslogins 145 where (suid = @info1)) 146 147 insert into #shcinfo_res 148 values (@type, @cinfo, 149 @user_name, @charval, 150 NULL, NULL, NULL, 151 NULL, NULL, @info3) 152 END 153 END 154 155 /* Look for class bindings for a stored proc */ 156 157 ELSE IF (@type = "PR") 158 BEGIN 159 IF ((@object_name is NULL) OR 160 (@object_name = @cinfo)) 161 BEGIN 162 select @user_name = 163 (select name from sysusers 164 where (uid = @info1)) 165 insert into #shcinfo_res 166 values (@type, @cinfo, @user_name, 167 @charval, NULL, NULL, NULL, 168 NULL, NULL, @info3) 169 END 170 END 171 172 /* Look for Session level attribute definitions */ 173 174 ELSE IF (@type = "PS") 175 BEGIN 176 IF ((@spid is NULL) OR 177 (@spid = @info1)) 178 BEGIN 179 insert into #shcinfo_res 180 values (@type, NULL, NULL, NULL, 181 NULL, NULL, @info1, @cinfo, 182 @charval, @info3) 183 END 184 END 185 186 /* Look for engine attribute values */ 187 188 ELSE IF (@type = "EG") 189 BEGIN 190 IF ((@object_name is NULL) OR 191 (@object_name = @cinfo)) 192 BEGIN 193 194 /* format the list of engines */ 195 select @len = 0 196 select @term = charindex(":", @charval) 197 198 IF (@term != 0) 199 BEGIN 200 select @eng_str = 201 rtrim(@charval) 202 while (@len < 203 char_length(@eng_str)) 204 BEGIN 205 select @eng_num = 206 substring(@eng_str, 207 (@len + 1), (@term - 1)) 208 209 IF (@len = 0) 210 select 211 @eng_list = 212 ltrim(@eng_num) 213 ELSE 214 select 215 @eng_list = 216 @eng_list + 217 "," + 218 ltrim(@eng_num) 219 select @len = @len + 220 @term 221 END 222 END 223 ELSE 224 BEGIN 225 select @eng_list = @charval 226 END 227 228 /* 229 ** For SMP, instanceid column is null 230 ** For SDC, it shows instance id. 231 */ 232 insert into #shcinfo_res 233 values (@type, NULL, NULL, NULL, 234 @cinfo, @eng_list, NULL, 235 NULL, NULL, @info3) 236 END 237 END 238 239 /* Look for default class attributes */ 240 ELSE IF (@type = "DF") 241 BEGIN 242 insert into #shcinfo_res 243 values (@type, NULL, NULL, @charval, 244 NULL, NULL, NULL, NULL, NULL, @info3) 245 END 246 247 /* Look for service task bindings */ 248 ELSE IF (@type = "SV") 249 BEGIN 250 insert into #shcinfo_res 251 values (@type, @cinfo, NULL, @charval, 252 NULL, NULL, NULL, NULL, NULL, @info3) 253 END 254 255 /* Fetch the next row from sysattributes table */ 256 FETCH appl_info into @type, @obj, @info1, @info3, @cinfo, 257 @intval, @charval 258 END 259 260 /* Now print out all the results we got */ 261 IF (@@kernelmode = 'process') 262 exec sp_autoformat #shcinfo_res 263 ELSE 264 exec sp_autoformat #shcinfo_res, 'type, object_name, scope, exec_class, threadpool = engine_group, spid, attribute, attribute_value, instanceid' 265 266 /* Cleanup */ 267 close appl_info 268 deallocate cursor appl_info 269 drop table #shcinfo_res 270 return (0) 271
exec sp_procxmode 'sp_showcontrolinfo', 'AnyMode' go Grant Execute on sp_showcontrolinfo to public go
DEPENDENCIES |
PROCS AND TABLES USED calls proc sybsystemprocs..sp_autoformat ![]() reads table tempdb..syscolumns (1) ![]() read_writes table tempdb..#colinfo_af (1) calls proc sybsystemprocs..sp_autoformat ![]() reads table master..syscolumns (1) ![]() reads table tempdb..systypes (1) ![]() reads table master..systypes (1) ![]() calls proc sybsystemprocs..sp_namecrack ![]() reads table master..syslogins (1) ![]() writes table tempdb..#shcinfo_res (1) reads table sybsystemprocs..sysusers ![]() reads table sybsystemprocs..sysattributes ![]() |