Database | Proc | Application | Created | Links |
sybsystemprocs | sp_unbindexeclass ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */ 3 4 /* 5 ** Messages for "sp_unbindexeclass" 6 ** 17260, "Can't run %1! from within a transaction." 7 ** 18255, "%1! cannot be NULL." 8 ** 18256, "%1! is not a valid object type for this stored procedure." 9 ** 18259, "No login with the specified name '%1!' exists." 10 ** 18278, "Failed to unbind '%1!' from execution class. Check server errorlog 11 ** for any additional information." 12 ** 18279, "The specified binding to be dropped does not exist" 13 ** 18552, "%1! is not a valid user of this database. 14 ** 18291, "The parameter value '%1!' is invalid." 15 */ 16 17 create procedure sp_unbindexeclass 18 @object_name varchar(255), /* name of object */ 19 @object_type varchar(2), /* Type of object */ 20 @scope varchar(255) = null /* user scope of the class */ 21 as 22 23 declare @attrib_id int, 24 @user_id int, 25 @action int, 26 @classname varchar(255), 27 @sp_objid int, 28 @owner_id int, 29 @stored_objid int, 30 @upcase_str varchar(2), 31 @instanceid int 32 33 select @action = 3 /* drop action */ 34 select @user_id = NULL /* Id of user from Syslogins table */ 35 select @attrib_id = 0 /* Execution class attribute */ 36 select @sp_objid = 0 /* object id of a stored proc */ 37 select @instanceid = NULL /* instance id */ 38 39 /* 40 ** If we're in a transaction, disallow this since it might make recovery 41 ** impossible. 42 */ 43 IF @@trancount > 0 44 BEGIN 45 /* 46 ** 17260, "Can't run %1! from within a transaction." 47 */ 48 raiserror 17260, "sp_dropexeclass" 49 return (1) 50 END 51 ELSE 52 BEGIN 53 /* Use TSQL mode of unchained transactions */ 54 set chained off 55 END 56 57 /* Dont do "Dirty Reads" */ 58 set transaction isolation level 1 59 60 /* convert types to upper case */ 61 select @upcase_str = upper(@object_type) 62 IF ((@upcase_str = "LG") OR (@upcase_str = "AP") OR 63 (@upcase_str = "PR") OR (@upcase_str = "DF") OR 64 (@upcase_str = "SV")) 65 BEGIN 66 select @object_type = @upcase_str 67 END 68 69 /* 70 ** Check to see that the input params are correct 71 */ 72 IF ((@object_name is NULL) and (@object_type != 'DF')) 73 BEGIN 74 /* 75 ** 18255, "%1! cannot be NULL." 76 */ 77 raiserror 18255, "Object name" 78 return (1) 79 END 80 81 IF ((@object_type = "PR") AND (@scope is NULL)) 82 BEGIN 83 /* 84 ** 18255, "%1! cannot be NULL." 85 */ 86 raiserror 18255, "Scope" 87 return (1) 88 END 89 90 /* For object_type SV, scope should be NULL */ 91 IF ((@object_type = 'SV') AND (@scope is not NULL)) 92 BEGIN 93 /* 94 ** 18291, "The parameter value '%1!' is invalid." 95 */ 96 raiserror 18291, "scope" 97 return (1) 98 END 99 100 /* object_type SV is only usable in threaded mode */ 101 IF ((@object_type = 'SV') AND (@@kernelmode != 'threaded')) 102 BEGIN 103 /* 104 ** 18119, "'%1!' is not available in process mode." 105 */ 106 raiserror 18119, "Service task binding" 107 return (1) 108 END 109 110 /* For object_type DF the object name and scope should be NULL */ 111 IF ((@object_type = 'DF') AND ((@object_name is not NULL) OR 112 (@scope is not NULL))) 113 BEGIN 114 /* 115 ** 18291, "The parameter value '%1!' is invalid." 116 */ 117 raiserror 18291, "Object name or scope" 118 return (1) 119 END 120 121 122 IF ((@object_type != "LG") AND (@object_type != "AP") 123 AND (@object_type != "PR") AND (@object_type != "DF") 124 AND (@object_type != "SV")) 125 BEGIN 126 /* 127 ** 18256, "%1! is not a valid object type for this stored procedure." 128 */ 129 raiserror 18256, @object_type 130 return (1) 131 END 132 133 /* In case of a stored proc, if the object still exits, get obj id */ 134 IF (@object_type = "PR") 135 BEGIN 136 137 /* get owner id from scope param */ 138 IF not exists (select uid from sysusers 139 where (name = @scope)) 140 BEGIN 141 /* 142 ** 18552 "%1! is not a valid user of this database." 143 */ 144 raiserror 18552, @scope 145 return (1) 146 END 147 ELSE 148 select @owner_id = (select uid from sysusers 149 where (name = @scope)) 150 151 IF exists (select id from sysobjects 152 where ((name = @object_name) AND (uid = @owner_id))) 153 select @sp_objid = (select id from sysobjects 154 where ((name = @object_name) AND (uid = @owner_id))) 155 END 156 157 158 /* Now convert user name to user id */ 159 IF (@object_type = "LG") 160 BEGIN 161 IF not exists (select suid from master..syslogins 162 where (name = @object_name) 163 and ((status & 512) != 512)) /* not LOGIN PROFILE */ 164 BEGIN 165 /* 166 ** 18259, "No login with specified name '%1!' exists." 167 */ 168 raiserror 18259, @object_name 169 return (1) 170 END 171 172 select @user_id = 173 (select suid from master..syslogins 174 where (name = @object_name)) 175 END 176 ELSE IF ((@object_type = "AP") and (@scope is not NULL)) 177 BEGIN 178 IF not exists (select suid from master..syslogins where (name = @scope) 179 and ((status & 512) != 512)) /* not LOGIN PROFILE */ 180 BEGIN 181 /* 182 ** 18259, "No login with specified name '%1!' exists" 183 */ 184 raiserror 18259, @scope 185 return (1) 186 END 187 188 select @user_id = (select suid from master..syslogins 189 where (name = @scope)) 190 END 191 192 /* 193 ** Now delete the matching entry from Sysattributes Table... 194 ** Verify that the attributes passed to sysattributes is correct. Note 195 ** that for stored procedures, the sysattributes table in the current 196 ** database is searched. For other objects, the sysattributes table in 197 ** master is searched. 198 */ 199 IF (@object_type = "LG") 200 BEGIN 201 202 select @classname = char_value 203 204 from 205 master..sysattributes where 206 class = 6 AND 207 attribute = @attrib_id AND 208 object_type = @object_type AND 209 object = @user_id AND 210 object_cinfo = @scope 211 212 IF (@classname is not NULL) 213 BEGIN 214 215 delete master..sysattributes 216 where class = 6 AND 217 attribute = @attrib_id AND 218 object_type = @object_type AND 219 object = @user_id AND 220 object_cinfo = @scope 221 END 222 ELSE 223 BEGIN 224 /* 225 ** 18279, "The specified binding to be dropped does 226 ** not exist" 227 */ 228 raiserror 18279 229 return (1) 230 END 231 232 IF attrib_notify(6, @attrib_id, @object_type, @user_id, 233 NULL, NULL, NULL, @scope, NULL, NULL, 234 NULL, NULL, "", @action) = 0 235 BEGIN 236 insert master..sysattributes 237 (class, attribute, object_type, object, 238 object_info3, object_cinfo, char_value) 239 values (6, @attrib_id, @object_type, @user_id, 240 @instanceid, 241 @scope, @classname) 242 243 /* 244 ** 18278,"Failed to unbind '%1!' from execution class. 245 ** Check server errorlog for any additional 246 ** information." 247 */ 248 raiserror 18278, @object_name 249 return (1) 250 END 251 END 252 ELSE IF (@object_type = "AP") 253 BEGIN 254 select @classname = char_value, 255 @instanceid = object_info3 from 256 master..sysattributes where 257 class = 6 AND 258 attribute = @attrib_id AND 259 object_type = @object_type AND 260 object_info1 = @user_id AND 261 object_cinfo = @object_name 262 263 IF (@classname is not NULL) 264 BEGIN 265 266 delete master..sysattributes 267 where class = 6 AND 268 attribute = @attrib_id AND 269 object_type = @object_type AND 270 object_info1 = @user_id AND 271 object_cinfo = @object_name 272 END 273 ELSE 274 BEGIN 275 /* 276 ** 18279, "The specified binding to be dropped does 277 ** not exist" 278 */ 279 raiserror 18279 280 return (1) 281 END 282 283 IF attrib_notify(6, @attrib_id, @object_type, NULL, 284 @user_id, NULL, NULL, @object_name, NULL, NULL, 285 NULL, NULL, "", @action) = 0 286 BEGIN 287 insert master..sysattributes 288 (class, attribute, object_type, object_info1, 289 object_info3, object_cinfo, char_value) 290 values (6, @attrib_id, @object_type, @user_id, 291 @instanceid, @object_name, @classname) 292 /* 293 ** 18278,"Failed to unbind '%1!' from execution class. 294 ** Check server errorlog for any additional 295 ** information." 296 */ 297 raiserror 18278, @object_name 298 return (1) 299 END 300 END 301 ELSE IF (@object_type = "DF") 302 BEGIN 303 select @classname = char_value, 304 @instanceid = object_info3 from 305 master..sysattributes where 306 class = 6 AND 307 attribute = @attrib_id AND 308 object_type = @object_type 309 310 IF (@classname is not NULL) 311 BEGIN 312 313 delete master..sysattributes 314 where class = 6 AND 315 attribute = @attrib_id AND 316 object_type = @object_type 317 END 318 ELSE 319 BEGIN 320 /* 321 ** 18279, "The specified binding to be dropped does 322 ** not exist" 323 */ 324 raiserror 18279 325 return (1) 326 END 327 328 IF attrib_notify(6, @attrib_id, @object_type, NULL, 329 NULL, NULL, NULL, NULL, NULL, @classname, 330 NULL, NULL, "", @action) = 0 331 BEGIN 332 insert master..sysattributes 333 (class, attribute, object_type, object_info3, char_value) 334 values (6, @attrib_id, @object_type, @instanceid, @classname) 335 END 336 END 337 ELSE IF (@object_type = "PR") 338 BEGIN 339 select @classname = (select char_value from sysattributes where 340 class = 6 AND 341 attribute = @attrib_id AND 342 object_type = @object_type AND 343 object_info1 = @owner_id AND 344 object_cinfo = @object_name), 345 @stored_objid = (select object from sysattributes where 346 class = 6 AND 347 attribute = @attrib_id AND 348 object_type = @object_type AND 349 object_info1 = @owner_id AND 350 object_cinfo = @object_name), 351 @instanceid = (select object_info3 from sysattributes where 352 353 class = 6 AND 354 attribute = @attrib_id AND 355 object_type = @object_type AND 356 object_info1 = @owner_id AND 357 object_cinfo = @object_name) 358 359 IF (@classname != NULL) 360 BEGIN 361 362 delete sysattributes 363 where class = 6 AND 364 attribute = @attrib_id AND 365 object_type = @object_type AND 366 object_info1 = @owner_id AND 367 object_cinfo = @object_name 368 END 369 ELSE 370 BEGIN 371 /* 372 ** 18279, "The specified binding to be dropped does 373 ** not exist" 374 */ 375 raiserror 18279 376 return (1) 377 END 378 379 IF attrib_notify(6, @attrib_id, @object_type, @sp_objid, 380 NULL, NULL, NULL, @object_name, NULL, NULL, 381 NULL, NULL, "", @action) = 0 382 BEGIN 383 insert sysattributes 384 (class, attribute, object_type, object, 385 object_info1, object_info3, 386 object_cinfo, char_value) 387 values (6, @attrib_id, @object_type, 388 @stored_objid, @owner_id, @instanceid, 389 @object_name, @classname) 390 391 /* 392 ** 18278,"Failed to unbind '%1!' from execution class. 393 ** Check server errorlog for any additional 394 ** information." 395 */ 396 raiserror 18278, @object_name 397 return (1) 398 END 399 END 400 ELSE /* object is of type "SV" */ 401 BEGIN 402 delete master..sysattributes 403 where class = 6 AND 404 attribute = @attrib_id AND 405 object_type = @object_type AND 406 object_cinfo = @object_name 407 408 IF attrib_notify(6, @attrib_id, @object_type, NULL, 409 NULL, NULL, NULL, @object_name, NULL, @classname, 410 NULL, NULL, "", @action) = 0 411 BEGIN 412 insert sysattributes 413 (class, attribute, object_type, object_cinfo, 414 char_value) values 415 (6, @attrib_id, @object_type, @object_name, 416 @classname) 417 /* 418 ** 18278,"Failed to unbind '%1!' from execution class. 419 ** Check server errorlog for any additional information." 420 */ 421 raiserror 18278, @object_name 422 return (1) 423 END 424 END 425 426 return (0) 427
DEFECTS | |
![]() | 234 |
![]() | 285 |
![]() | 330 |
![]() | 381 |
![]() | 410 |
![]() | master..sysattributes |
![]() | sybsystemprocs..sysattributes |
![]() | 202 |
![]() | 239 |
![]() | 254 |
![]() | 290 |
![]() | 303 |
![]() | 334 |
![]() | 387 |
![]() | 415 |
![]() | 206 |
![]() | 207 |
![]() | 207 |
![]() | 216 |
![]() | 217 |
![]() | 217 |
![]() | 257 |
![]() | 258 |
![]() | 258 |
![]() | 267 |
![]() | 268 |
![]() | 268 |
![]() | 306 |
![]() | 307 |
![]() | 307 |
![]() | 314 |
![]() | 315 |
![]() | 315 |
![]() | 340 |
![]() | 341 |
![]() | 341 |
![]() | 346 |
![]() | 347 |
![]() | 347 |
![]() | 353 |
![]() | 354 |
![]() | 354 |
![]() | 363 |
![]() | 364 |
![]() | 364 |
![]() | 403 |
![]() | 404 |
![]() | 404 |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | 359 |
![]() | 215 |
![]() | 236 |
![]() | 266 |
![]() | 287 |
![]() | 313 |
![]() | 332 |
![]() | 362 |
![]() | 383 |
![]() | 402 |
![]() | 412 |
![]() | 49 |
![]() | 62 |
![]() | 72 |
![]() | 78 |
![]() | 81 |
![]() | 87 |
![]() | 91 |
![]() | 97 |
![]() | 101 |
![]() | 107 |
![]() | 111 |
![]() | 118 |
![]() | 122 |
![]() | 130 |
![]() | 134 |
![]() | 139 |
![]() | 145 |
![]() | 149 |
![]() | 152 |
![]() | 154 |
![]() | 159 |
![]() | 169 |
![]() | 174 |
![]() | 176 |
![]() | 185 |
![]() | 189 |
![]() | 199 |
![]() | 212 |
![]() | 229 |
![]() | 249 |
![]() | 252 |
![]() | 263 |
![]() | 280 |
![]() | 298 |
![]() | 301 |
![]() | 310 |
![]() | 325 |
![]() | 337 |
![]() | 359 |
![]() | 376 |
![]() | 397 |
![]() | 422 |
![]() | 426 |
![]() | 412 |
![]() | 202 |
![]() | 254 |
![]() | 303 |
![]() | 58 |
![]() | 237 |
![]() | 288 |
![]() | 333 |
![]() | 384 |
![]() | 413 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object, object_cinfo, attribute, class} | 206 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object, object_cinfo, attribute, class} | 216 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 257 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 267 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, object_type, attribute} | 306 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, object_type, attribute} | 314 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 340 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 346 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 353 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 363 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 403 |
![]() | 138 |
![]() | 148 |
![]() | 151 |
![]() | 153 |
![]() | 161 |
![]() | 173 |
![]() | 178 |
![]() | 188 |
![]() | 339 |
![]() | 345 |
![]() | 351 |
![]() | 17 |
![]() | 17 |
![]() | 17 |
DEPENDENCIES |
PROCS AND TABLES USED reads table sybsystemprocs..sysobjects ![]() reads table sybsystemprocs..sysusers ![]() read_writes table sybsystemprocs..sysattributes ![]() read_writes table master..sysattributes (1) ![]() reads table master..syslogins (1) ![]() |