Database | Proc | Application | Created | Links |
sybsystemprocs | sp_bindexeclass ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/%M% %I% %G% */ 3 4 /* 5 ** Messages for "sp_bindexeclass" 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 ** 18257, "No definition for classname '%1!' exists." 10 ** 18259, "No login with the specified name '%1!' exists." 11 ** 18260, "Validation of execution class binding failed. Check server 12 ** errorlog for any additional information." 13 ** 18261, "Failed to bind '%1!' to execution class '%2!'. Check server 14 ** errorlog for any additional information." 15 ** 18535, "Permission denied: 'sybase_ts_role' is required for binding 16 ** with execution class 'EC0'. 17 ** 18551, "Stored procedure %1!, owned by %2!, does not exist in this database. 18 ** 18552, "%1! is not a valid user of this database. 19 ** 18291, "The parameter value '%1!' is invalid." 20 */ 21 22 create procedure sp_bindexeclass 23 @object_name varchar(255), /* name of object */ 24 @object_type varchar(2), /* Type of object */ 25 @scope varchar(30), /* user scope of binding */ 26 @classname varchar(255) /* class name assigned */ 27 as 28 29 declare @attrib_id int, 30 @user_id int, 31 @action int, 32 @role int, 33 @sp_objid int, 34 @owner_id int, 35 @upcase_str varchar(255), 36 @instanceid int 37 38 select @action = 1 39 select @user_id = NULL /* Id of user from Syslogins table */ 40 41 /* 42 ** IF we're in a transaction, disallow this since it might make recovery 43 ** impossible. 44 */ 45 IF @@trancount > 0 46 BEGIN 47 /* 48 ** 17260, "Can't run %1! from within a transaction." 49 */ 50 raiserror 17260, "sp_bindexeclass" 51 return (1) 52 END 53 ELSE 54 BEGIN 55 /* Use TSQL mode of unchained transactions */ 56 set chained off 57 END 58 59 /* Dont do "Dirty Reads" */ 60 set transaction isolation level 1 61 62 /* convert to upper case, system supported types and names */ 63 select @upcase_str = upper(@classname) 64 IF ((@upcase_str = "EC0") OR (@upcase_str = "EC1") OR 65 (@upcase_str = "EC2") OR (@upcase_str = "EC3")) 66 select @classname = @upcase_str 67 68 select @upcase_str = upper(@object_type) 69 IF ((@upcase_str = "LG") OR (@upcase_str = "AP") OR 70 (@upcase_str = "PR") OR (@upcase_str = "DF") OR 71 (@upcase_str = "SV")) 72 select @object_type = @upcase_str 73 74 /* 75 ** Check to see that the input params are correct 76 */ 77 IF ((@object_name is NULL) AND (@object_type != 'DF')) 78 BEGIN 79 /* 80 ** 18255, "%1! cannot be NULL." 81 */ 82 raiserror 18255, "Object name" 83 return (1) 84 END 85 86 IF ((@object_type = 'PR') AND (@scope is NULL)) 87 BEGIN 88 /* 89 ** 18255, "%1! cannot be NULL." 90 */ 91 raiserror 18255, "Scope" 92 return (1) 93 END 94 95 /* For object_type SV, scope should be NULL */ 96 IF ((@object_type = 'SV') AND (@scope is not NULL)) 97 BEGIN 98 /* 99 ** 18291, "The parameter value '%1!' is invalid." 100 */ 101 raiserror 18291, "scope" 102 return (1) 103 END 104 105 /* object_type SV is only usable in threaded mode */ 106 IF ((@object_type = 'SV') AND (@@kernelmode != 'threaded')) 107 BEGIN 108 /* 109 ** 18119, "'%1!' is not available in process mode." 110 */ 111 raiserror 18119, "Service task binding" 112 return (1) 113 END 114 115 /* For object_type DF the object name and scope should be NULL */ 116 IF ((@object_type = 'DF') AND ((@object_name is not NULL) 117 OR (@scope is not NULL))) 118 BEGIN 119 /* 120 ** 18291, "The parameter value '%1!' is invalid." 121 */ 122 raiserror 18291, "Object name or scope" 123 return (1) 124 END 125 126 127 /* check that @object_type value specified is valid */ 128 IF ((@object_type != 'LG') and (@object_type != 'AP') 129 and (@object_type != 'PR') and (@object_type != 'DF') 130 and (@object_type != 'SV')) 131 BEGIN 132 /* 133 ** 18256, "%1! is not a valid object type for this stored procedure." 134 */ 135 raiserror 18256, @object_type 136 return (1) 137 END 138 139 /* in case of stored procs, check that the object exists */ 140 IF (@object_type = "PR") 141 BEGIN 142 /* get owner id from scope param */ 143 IF not exists (select uid from sysusers 144 where (name = @scope)) 145 BEGIN 146 /* 147 ** 18552 "%1! is not a valid user of this database." 148 */ 149 raiserror 18552, @scope 150 return (1) 151 END 152 ELSE 153 select @owner_id = (select uid from sysusers 154 where (name = @scope)) 155 156 IF not exists (select id from sysobjects 157 where ((name = @object_name) AND (uid = @owner_id))) 158 BEGIN 159 /* 160 ** 18551 "Stored procedure %1!, owned by %2!, does not exist 161 ** in this database. 162 */ 163 raiserror 18551, @object_name, @scope 164 return (1) 165 END 166 ELSE 167 select @sp_objid = (select id from sysobjects 168 where ((name = @object_name) AND (uid = @owner_id))) 169 END 170 171 select @attrib_id = 2 /* attribute is class definition */ 172 173 /* check the class name passed in */ 174 IF ((@classname != "EC0") 175 AND (@classname != "EC1") 176 AND (@classname != "EC2") 177 AND (@classname != "EC3")) 178 BEGIN 179 IF not exists (select object_cinfo from master..sysattributes 180 where class = 6 AND 181 attribute = @attrib_id AND 182 object_type = 'UC' AND 183 object_cinfo = @classname) 184 BEGIN 185 /* 186 ** 18257, "No definition for classname '%1!' exists." 187 */ 188 raiserror 18257, @classname 189 return (1) 190 END 191 192 193 /* 194 ** For SDC, binding only to local execution class 195 */ 196 IF (@@clustermode = "shared disk cluster") 197 BEGIN 198 select @instanceid = object_info3 from master..sysattributes 199 where class = 6 AND 200 attribute = @attrib_id AND 201 object_type = 'UC' AND 202 object_cinfo = @classname 203 204 if ((@instanceid != NULL) AND 205 (@instanceid != @@instanceid)) 206 BEGIN 207 /* 208 ** RESOLVE: change error to new message: 209 ** "Class '%1!' is bound to instance '%2!'." 210 */ 211 /* raiserror 17260, "sp_bindexeclass" */ 212 raiserror 19659, @classname, @instanceid 213 return (1) 214 END 215 END 216 END 217 218 /* check that for class EC0, caller has sybase_ts_role. */ 219 IF (@classname = "EC0") 220 BEGIN 221 select @role = proc_role("sybase_ts_role") 222 IF (@role = 0) 223 BEGIN 224 /* 225 ** 18535, "Permission denied: 'sybase_ts_role' is required 226 ** for binding with execution class EC0" 227 */ 228 raiserror 18535 229 return (1) 230 END 231 END 232 233 /* Now convert user name to user id after checking its existence */ 234 IF (@object_type = "LG") 235 BEGIN 236 IF not exists (select suid from master..syslogins 237 where (name = @object_name) and 238 ((status & 512) != 512)) /* not LOGIN PROFILE */ 239 BEGIN 240 /* 241 ** 17231, "No login with the specified name '%1!' exists" 242 */ 243 raiserror 17231, @object_name 244 return (1) 245 END 246 247 select @user_id = (select suid from master..syslogins 248 where (name = @object_name) and 249 ((status & 512) != 512)) /* not LOGIN PROFILE */ 250 END 251 ELSE IF ((@object_type = "AP") and (@scope is not NULL)) 252 BEGIN 253 IF not exists (select suid from master..syslogins where (name = @scope) and 254 ((status & 512) != 512)) /* not LOGIN PROFILE */ 255 BEGIN 256 /* 257 ** 18259, "No login with specified name '%1!' exists" 258 */ 259 raiserror 18259, @scope 260 return (1) 261 END 262 263 select @user_id = (select suid from master..syslogins 264 where (name = @scope) and 265 ((status & 512) != 512)) /* not LOGIN PROFILE */ 266 END 267 268 /* 269 ** Now hook up with Sysattributes Table.. 270 ** Verify that the attributes passed to sysattributes is correct. 271 ** Note that for stored procedures, the sysattributes table in the current 272 ** database is used. For other objects, the sysattributes table in master 273 ** is used. 274 */ 275 276 select @attrib_id = 0 277 278 IF (@object_type = "LG") 279 BEGIN 280 IF attrib_valid(6, @attrib_id, @object_type, @user_id, NULL, NULL, 281 NULL, @scope, NULL, @classname, NULL, NULL, "", @action) = 0 282 BEGIN 283 /* 284 ** 18260, "Validation of execution class binding failed. 285 ** Check server errorlog for any additional 286 ** information." 287 */ 288 raiserror 18260 289 return (1) 290 END 291 ELSE 292 BEGIN 293 IF exists (select * from master..sysattributes where 294 class = 6 AND 295 attribute = @attrib_id AND 296 object_type = @object_type AND 297 object = @user_id AND 298 object_cinfo = @scope) 299 BEGIN 300 update master..sysattributes 301 set char_value = @classname 302 where class = 6 AND 303 attribute = @attrib_id AND 304 object_type = @object_type AND 305 object = @user_id AND 306 object_cinfo = @scope 307 END 308 ELSE 309 BEGIN 310 insert master..sysattributes 311 (class, attribute, object_type, object, 312 object_cinfo, char_value) 313 values (6, @attrib_id, @object_type, @user_id, 314 @scope, @classname) 315 END 316 317 IF attrib_notify(6, @attrib_id, @object_type, @user_id, 318 NULL, NULL, NULL, @scope, NULL, @classname, 319 NULL, NULL, "", @action) = 0 320 BEGIN 321 /* 322 ** 18261, "Failed to bind '%1!' to execution class 323 ** '%2!'. Check server errorlog for any 324 ** additional information." 325 */ 326 delete master..sysattributes where (class = 6 AND 327 attribute = @attrib_id AND 328 object_type = @object_type AND 329 object = @user_id AND 330 object_cinfo = @scope) 331 raiserror 18261, @object_name, @classname 332 return (1) 333 END 334 END 335 END 336 ELSE IF (@object_type = "AP") 337 BEGIN 338 IF attrib_valid(6, @attrib_id, @object_type, NULL, @user_id, NULL, 339 NULL, @object_name, NULL, @classname, NULL, NULL, "", 340 @action) = 0 341 BEGIN 342 /* 343 ** 18260, "Validation of execution class binding failed. 344 ** Check server errorlog for any additional 345 ** information." 346 */ 347 raiserror 18260 348 return (1) 349 END 350 ELSE 351 BEGIN 352 IF exists (select * from master..sysattributes where 353 class = 6 AND 354 attribute = @attrib_id AND 355 object_type = @object_type AND 356 object_info1 = @user_id AND 357 object_cinfo = @object_name) 358 BEGIN 359 update master..sysattributes 360 set char_value = @classname 361 where class = 6 AND 362 attribute = @attrib_id AND 363 object_type = @object_type AND 364 object_info1 = @user_id AND 365 object_cinfo = @object_name 366 END 367 ELSE 368 BEGIN 369 insert master..sysattributes 370 (class, attribute, object_type, object_info1, 371 object_cinfo, char_value) 372 values (6, @attrib_id, @object_type, @user_id, 373 @object_name, @classname) 374 END 375 376 IF attrib_notify(6, @attrib_id, @object_type, NULL, 377 @user_id, NULL, NULL, @object_name, NULL, @classname, 378 NULL, NULL, "", @action) = 0 379 BEGIN 380 /* 381 ** 18261, "Error on binding '%1!' to execution class 382 ** '%2!'. Check server errorlog for any 383 ** additional information." 384 */ 385 delete master..sysattributes where (class = 6 AND 386 attribute = @attrib_id AND 387 object_type = @object_type AND 388 object_info1 = @user_id AND 389 object_cinfo = @object_name) 390 raiserror 18261, @object_name, @classname 391 return (1) 392 END 393 END 394 END 395 ELSE IF (@object_type = "DF") 396 BEGIN 397 IF attrib_valid(6, @attrib_id, @object_type, NULL, NULL, NULL, 398 NULL, NULL, NULL, @classname, NULL, NULL, "", 399 @action) = 0 400 401 BEGIN 402 /* 403 ** 18260, "Validation of execution class binding failed. 404 ** Check server errorlog for any additional 405 ** information." 406 */ 407 raiserror 18260 408 return (1) 409 END 410 ELSE 411 BEGIN 412 IF exists (select * from master..sysattributes where 413 class = 6 AND 414 attribute = @attrib_id AND 415 object_type = @object_type) 416 BEGIN 417 update master..sysattributes 418 set char_value = @classname 419 where class = 6 AND 420 attribute = @attrib_id AND 421 object_type = @object_type 422 END 423 ELSE 424 BEGIN 425 insert master..sysattributes 426 (class, attribute, object_type, char_value) 427 values (6, @attrib_id, @object_type, @classname) 428 END 429 430 IF attrib_notify(6, @attrib_id, @object_type, NULL, NULL, NULL, 431 NULL, NULL, NULL, @classname, NULL, NULL, "", 432 @action) = 0 433 BEGIN 434 /* 435 ** 18261, "Error on binding '%1!' to execution class 436 ** '%2!'. Check server errorlog for any 437 ** additional information." 438 */ 439 delete master..sysattributes where (class = 6 AND 440 attribute = @attrib_id AND 441 object_type = @object_type AND 442 char_value = @classname) 443 raiserror 18261, @object_name, @classname 444 return (1) 445 END 446 END 447 END 448 ELSE IF (@object_type = "PR") 449 BEGIN 450 /* For stored procs, we store the owner id and object id of the sp in 451 ** sysattributes. 452 */ 453 IF attrib_valid(6, @attrib_id, @object_type, @sp_objid, @owner_id, 454 NULL, NULL, @object_name, NULL, @classname, NULL, NULL, "", 455 @action) = 0 456 BEGIN 457 /* 458 ** 18260, "Validation of execution class binding failed. 459 ** Check server errorlog for any additional 460 ** information." 461 */ 462 raiserror 18260 463 return (1) 464 END 465 ELSE 466 BEGIN 467 IF exists (select * from sysattributes where 468 class = 6 AND 469 attribute = @attrib_id AND 470 object_type = @object_type AND 471 object = @sp_objid AND 472 object_info1 = @owner_id AND 473 object_cinfo = @object_name) 474 BEGIN 475 update sysattributes 476 set char_value = @classname 477 where class = 6 AND 478 attribute = @attrib_id AND 479 object_type = @object_type AND 480 object = @sp_objid AND 481 object_info1 = @owner_id AND 482 object_cinfo = @object_name 483 END 484 ELSE 485 BEGIN 486 insert sysattributes 487 (class, attribute, object_type, object, 488 object_info1, object_cinfo, char_value) 489 values (6, @attrib_id, @object_type, @sp_objid, 490 @owner_id, @object_name, @classname) 491 END 492 IF attrib_notify(6, @attrib_id, @object_type, @sp_objid, 493 NULL, NULL, NULL, @object_name, NULL, @classname, 494 NULL, NULL, "", @action) = 0 495 BEGIN 496 /* 497 ** 18261, "Failed to bind '%1!' to execution class 498 ** '%2!'. Check server errorlog for any 499 ** additional information." 500 */ 501 delete sysattributes where (class = 6 AND 502 attribute = @attrib_id AND 503 object_type = @object_type AND 504 object = @sp_objid AND 505 object_info1 = @owner_id AND 506 object_cinfo = @object_name) 507 raiserror 18261, @object_name, @classname 508 return (1) 509 END 510 END 511 END 512 ELSE /* object is of type "SV" */ 513 BEGIN 514 /* 515 ** Verify if object_name and other parameters passed are valid 516 */ 517 IF attrib_valid(6, @attrib_id, @object_type, NULL, NULL, 518 NULL, NULL, @object_name, NULL, @classname, NULL, NULL, "", 519 @action) = 0 520 BEGIN 521 /* 522 ** 18260, "Validation of execution class binding failed. 523 ** Check server errorlog for any additional information. 524 */ 525 raiserror 18260 526 return (1) 527 END 528 ELSE 529 BEGIN 530 IF exists (select * from master..sysattributes where 531 class = 6 AND 532 attribute = @attrib_id AND 533 object_type = @object_type AND 534 object_cinfo = @object_name) 535 BEGIN 536 update master..sysattributes 537 set char_value = @classname 538 where class = 6 AND 539 attribute = @attrib_id AND 540 object_type = @object_type AND 541 object_cinfo = @object_name 542 END 543 ELSE 544 BEGIN 545 insert master..sysattributes 546 (class, attribute, object_type, 547 object_cinfo, char_value) 548 values (6, @attrib_id, @object_type, 549 @object_name, @classname) 550 END 551 552 IF attrib_notify(6, @attrib_id, @object_type, NULL, 553 NULL, NULL, NULL, @object_name, NULL, @classname, 554 NULL, NULL, "", @action) = 0 555 BEGIN 556 /* 557 ** 18261, "Failed to bind '%1!' to execution class 558 ** '%2!'. Check server errorlog for any 559 ** additional information." 560 */ 561 delete sysattributes where (class = 6 AND 562 attribute = @attrib_id AND 563 object_type = @object_type AND 564 char_value = @classname AND 565 object_cinfo = @object_name) 566 raiserror 18261, @object_name, @classname 567 return (1) 568 END 569 END 570 END 571 572 return (0) 573
DEFECTS | |
![]() | 281 |
![]() | 319 |
![]() | 339 |
![]() | 378 |
![]() | 398 |
![]() | 431 |
![]() | 454 |
![]() | 494 |
![]() | 518 |
![]() | 554 |
![]() | master..sysattributes |
![]() | sybsystemprocs..sysattributes |
![]() | 72 |
![]() | 313 |
![]() | 372 |
![]() | 427 |
![]() | 489 |
![]() | 548 |
![]() | 180 |
![]() | 181 |
![]() | 181 |
![]() | 199 |
![]() | 200 |
![]() | 200 |
![]() | 294 |
![]() | 295 |
![]() | 295 |
![]() | 302 |
![]() | 303 |
![]() | 303 |
![]() | 326 |
![]() | 327 |
![]() | 327 |
![]() | 353 |
![]() | 354 |
![]() | 354 |
![]() | 361 |
![]() | 362 |
![]() | 362 |
![]() | 385 |
![]() | 386 |
![]() | 386 |
![]() | 413 |
![]() | 414 |
![]() | 414 |
![]() | 419 |
![]() | 420 |
![]() | 420 |
![]() | 439 |
![]() | 440 |
![]() | 440 |
![]() | 468 |
![]() | 469 |
![]() | 469 |
![]() | 477 |
![]() | 478 |
![]() | 478 |
![]() | 501 |
![]() | 502 |
![]() | 502 |
![]() | 531 |
![]() | 532 |
![]() | 532 |
![]() | 538 |
![]() | 539 |
![]() | 539 |
![]() | 561 |
![]() | 562 |
![]() | 562 |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | 204 |
![]() | 300 |
![]() | 310 |
![]() | 326 |
![]() | 359 |
![]() | 369 |
![]() | 385 |
![]() | 417 |
![]() | 425 |
![]() | 439 |
![]() | 475 |
![]() | 486 |
![]() | 501 |
![]() | 536 |
![]() | 545 |
![]() | 561 |
![]() | 51 |
![]() | 64 |
![]() | 69 |
![]() | 77 |
![]() | 83 |
![]() | 86 |
![]() | 92 |
![]() | 96 |
![]() | 102 |
![]() | 106 |
![]() | 112 |
![]() | 116 |
![]() | 123 |
![]() | 128 |
![]() | 136 |
![]() | 140 |
![]() | 144 |
![]() | 150 |
![]() | 154 |
![]() | 157 |
![]() | 164 |
![]() | 168 |
![]() | 174 |
![]() | 189 |
![]() | 196 |
![]() | 204 |
![]() | 213 |
![]() | 219 |
![]() | 222 |
![]() | 229 |
![]() | 234 |
![]() | 244 |
![]() | 251 |
![]() | 260 |
![]() | 278 |
![]() | 289 |
![]() | 326 |
![]() | 332 |
![]() | 336 |
![]() | 348 |
![]() | 385 |
![]() | 391 |
![]() | 395 |
![]() | 408 |
![]() | 439 |
![]() | 444 |
![]() | 448 |
![]() | 463 |
![]() | 501 |
![]() | 508 |
![]() | 526 |
![]() | 561 |
![]() | 567 |
![]() | 572 |
![]() | 561 |
![]() | 198 |
![]() | 60 |
![]() | 311 |
![]() | 370 |
![]() | 426 |
![]() | 487 |
![]() | 546 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 180 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 199 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object, object_cinfo, attribute, class} | 294 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object, object_cinfo, attribute, class} | 302 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object, object_cinfo, attribute, class} | 326 |
![]() (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} | 361 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object_cinfo, attribute, class} | 385 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, object_type, attribute} | 413 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, object_type, attribute} | 419 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, attribute, class} | 439 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {attribute, object_type, object_info1, object_cinfo, object, class} | 468 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {attribute, object_type, object_info1, object_cinfo, object, class} | 477 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {attribute, object_type, object_info1, object_cinfo, object, class} | 501 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 531 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 538 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 561 |
![]() | 143 |
![]() | 153 |
![]() | 156 |
![]() | 167 |
![]() | 179 |
![]() | 236 |
![]() | 247 |
![]() | 253 |
![]() | 263 |
![]() | 293 |
![]() | 352 |
![]() | 412 |
![]() | 467 |
![]() | 530 |
![]() | 22 |
![]() | 22 |
![]() | 22 |
DEPENDENCIES |
PROCS AND TABLES USED reads table master..syslogins (1) ![]() read_writes table sybsystemprocs..sysattributes ![]() reads table sybsystemprocs..sysobjects ![]() reads table sybsystemprocs..sysusers ![]() read_writes table master..sysattributes (1) ![]() |