Database | Proc | Application | Created | Links |
sybsystemprocs | sp_shmdumpconfig ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* 3 ** SP_SHMDUMPCONFIG 4 ** 5 ** This file contains the definition of the sp_dumpconfig system 6 ** stored procedure. This stored procedure is used to set shared 7 ** memory dump conditions and to display the current dump condition 8 ** settings. The sa_role is required to make any changes to the 9 ** system configuration, but public access is granted to display the 10 ** current settings. 11 ** 12 ** This stored procedure calls sp_shmdumpdrop to drop shared memory 13 ** dump conditions; and it calls sp_shmdumpdisp to display current 14 ** settings. 15 ** 16 ** Security: The sa_role role is required in order to add a dump condition. 17 ** The sa_role role is required by sp_shmdumpdrop to drop a dump 18 ** condition. 19 ** 20 ** History: 21 ** 19sept96 pdorfman Initial coding 22 ** 07apr97 pdorfman Code complete 23 ** 21jan02 dwein Added support for message dump type 24 ** 20jun03 panchaks Added support for dbcc dump type 25 ** 12dec03 dwein Added support for the halt / no_halt option 26 */ 27 28 create procedure sp_shmdumpconfig 29 /* -------------- Stored Procedure Parameters ----------------------- */ 30 @action varchar(10) = "display", /* action requested by user */ 31 @type varchar(20) = "", /* type of attribute affected */ 32 @value int = NULL, /* attribute value */ 33 @maxdumps int = NULL, /* maximum # of dumps */ 34 @dirname varchar(255) = NULL, /* dump directory */ 35 @filename varchar(128) = NULL, /* dump file name. Maximum */ 36 /* length is 30 but declare */ 37 /* longer here to avoid */ 38 /* truncation */ 39 @optarg1 varchar(20) = NULL, /* in/exclude memory type or option */ 40 @optarg2 varchar(20) = NULL, /* in/exclude memory type or option */ 41 @optarg3 varchar(20) = NULL, /* in/exclude memory type or option */ 42 @optarg4 varchar(20) = NULL, /* in/exclude memory type or option */ 43 @optarg5 varchar(20) = NULL /* in/exclude memory type or option */ 44 as 45 46 /* ----------------- Declare Local Variables ------------------------ */ 47 declare @object int, /* object column value */ 48 @attrib int, /* attribute column value */ 49 @not_status int, /* notification return status */ 50 @curarg varchar(20), /* memory mode working var */ 51 @opttype int, /* type of memory for obj */ 52 @optsetting int, /* setting for this memtype */ 53 @counter int, /* counter */ 54 @recfound int, /* record already exists */ 55 @notify_cnt int, /* count notification done */ 56 @maxconds int, /* max # dump conditions */ 57 @curcount int, /* current # dump cond's */ 58 @trancount int, /* receiver for @@trancount */ 59 @print_str varchar(1024), /* Buffer for messages */ 60 @windows int, /* indicates if this is the windows platform */ 61 @hvalue char(8), /* value as a hex number */ 62 @temp_maxdumps int /* used to check maxdumps */ 63 64 /* 65 ** The following variables are treated as constants within this 66 ** stored procedure. They are set below. 67 */ 68 declare @DUMPCOND_CLASS int, /* sysattributes class */ 69 @OBJTYPE char(2), /* sysattributes object typ */ 70 @CFG_PRIMARY int, /* primary record id */ 71 @CFG_FILENAME int, /* file name record id */ 72 @CFG_DIRNAME int, /* directory name record id */ 73 @CFG_MAXDUMPS int, /* maxdumps record id */ 74 @CFG_PAGECACHE int, /* page cache record id */ 75 @CFG_PROCCACHE int, /* proc cache record id */ 76 @CFG_UNUSED int, /* unused memory record id */ 77 @CFG_HALT int, /* halt option record id */ 78 @ATTR_ADD int, /* add notification value */ 79 @ATTR_CHANGE int, /* change notification val */ 80 @ATTR_DROP int, /* drop notification value */ 81 @ATTR_FETCH int, /* fetch notification value */ 82 @CFG_INCLUDE int, /* include memory type */ 83 @CFG_OMIT int, /* omit memory type */ 84 @CFG_DEFAULT int, /* use default mem setting */ 85 @CFG_CLUSTER int /* behavior of dump in cluster*/ 86 87 /* ----------------- Setup and Validation ------------------------ */ 88 set nocount on 89 90 /* 91 ** Common Definition Section: Note: any changes made to the following 92 ** values must also be made in shmdumpdrop and shmdumpdisp 93 */ 94 95 /* 96 ** Class ID and type defined in utils/attrib.lst 97 */ 98 select @DUMPCOND_CLASS = 7 99 select @OBJTYPE = "DC" 100 101 /* 102 ** The following constants define record types for the dump condition 103 ** class in the sysattributes table. The values set here must be the 104 ** same as those defined in utils/cfgdump.c. 105 */ 106 select @CFG_PRIMARY = 1 107 select @CFG_FILENAME = 2 108 select @CFG_DIRNAME = 3 109 select @CFG_MAXDUMPS = 4 110 select @CFG_PAGECACHE = 5 111 select @CFG_PROCCACHE = 6 112 select @CFG_UNUSED = 7 113 select @CFG_HALT = 8 114 select @CFG_CLUSTER = 9 115 116 /* 117 ** The following constants are used for setting memory modes and other 118 ** options. These values must correspond to those used in utils/cfgdump.c. 119 */ 120 select @CFG_DEFAULT = 0 /* Use the default value */ 121 select @CFG_INCLUDE = 1 /* Include memory / Option On */ 122 select @CFG_OMIT = 2 /* Omit memory / Option off */ 123 124 /* 125 ** The following must correspond to values in sysattr.h 126 */ 127 select @ATTR_ADD = 1 128 select @ATTR_CHANGE = 2 129 select @ATTR_DROP = 3 130 select @ATTR_FETCH = 4 131 132 /* 133 ** Determine if we are running on the windows platform 134 */ 135 if (select charindex("Windows", @@version)) > 0 136 begin 137 select @windows = 1 138 end 139 else 140 begin 141 select @windows = 0 142 end 143 144 /* 145 ** End Common Definition Section 146 */ 147 148 select @notify_cnt = 0 149 150 /* 151 ** Validate the action value 152 */ 153 if (@action not in ('add', 'drop', 'update', 'reset', 154 'display', 'debug', 'config')) 155 begin 156 /* 157 ** 18516, "Invalid action %1!" 158 */ 159 raiserror 18516, @action 160 return 17 161 end 162 163 /* 164 ** Determine the attribute number for the attribute indicated 165 ** by the @type parameter. 166 ** 167 ** NOTE: The integer values used for @attrib here must correspond to values 168 ** defined in utils/attrib.lst. Any changes made here must also be made 169 ** in attrib.lst, and vice versa. 170 */ 171 172 if @type = 'error' 173 select @attrib = 1 174 else if @type = 'signal' 175 select @attrib = 2 176 else if (@windows = 1 and @type = 'exception') 177 select @attrib = 2 178 else if @type = 'severity' 179 select @attrib = 3 180 else if @type = 'module' 181 select @attrib = 4 182 else if @type = 'defaults' 183 select @attrib = 5 184 else if @type = 'timeslice' 185 select @attrib = 6 186 else if @type = 'panic' 187 select @attrib = 7 188 else if @type = 'message' 189 select @attrib = 8 190 else if @type = 'dbcc' 191 select @attrib = 9 192 else if @type = 'codepoint' 193 select @attrib = 10 194 else if @action = 'debug' 195 begin 196 select @action = 'display' 197 select @type = 'debug' 198 end 199 else if @action not in ('display', 'config') 200 begin 201 /* 202 ** We are here because @type does not have a valid value 203 ** and the @action value is not 'display' or 'config'. 204 ** The 'config' option is responsible for validating its own 205 ** types. The display option does not have a type flag. 206 */ 207 /* 208 ** 18492, "Invalid dump condition type %1!" 209 */ 210 raiserror 18492, @type 211 return 1 212 end 213 214 /* 215 ** If we are on windows and the user entered the "exception" condition 216 ** then we need to byte-swap the value stored in @value. 217 */ 218 if (@windows = 1 and @type = 'exception') 219 begin 220 select @hvalue = inttohex(@value) 221 select @hvalue = substring(@hvalue, 7, 2) + 222 substring(@hvalue, 5, 2) + 223 substring(@hvalue, 3, 2) + 224 substring(@hvalue, 1, 2) 225 select @value = hextoint(@hvalue) 226 end 227 228 /* ----------------- Identify and Perform the Command ----------- */ 229 230 /* 231 ** Add a new dump condition or configuration parameter 232 */ 233 if (@action in ('add', 'update', 'reset')) 234 begin 235 /* 236 ** Verify that the user has sufficient permissions to 237 ** update the dump configuration 238 */ 239 if (proc_role("sa_role") < 1) 240 begin 241 return 2 242 end 243 244 /* 245 ** Make sure valid parameters were provided 246 */ 247 if (@action = 'add') 248 begin 249 if (@type = 'defaults') 250 begin 251 /* 252 ** 18493 "You cannot add the system default settings. Use update." 253 */ 254 raiserror 18493 255 return 3 256 end 257 258 if ((@value is NULL) and 259 (@type not in ('timeslice', 'panic', 'dbcc'))) 260 begin 261 /* 262 ** 18494 "No value for %1! was given." 263 */ 264 raiserror 18494, @type 265 return 4 266 end 267 268 /* 269 ** Determine whether there is room to add another dump condition. 270 ** Get configured maximum number of dump conditions 271 */ 272 select @maxconds = value 273 from master.dbo.sysconfigures 274 where name = 'maximum dump conditions' 275 276 /* 277 ** Count number of conditions set for type error, signal or module 278 */ 279 select @curcount = count(*) 280 from master.dbo.sysattributes 281 where class = @DUMPCOND_CLASS 282 and object_info1 = @CFG_PRIMARY 283 and attribute != 5 /* Skip default entry */ 284 285 /* 286 ** Raise an error if there is no more room 287 */ 288 if (@curcount >= @maxconds) 289 begin 290 /* 291 ** 18495, "The maximum number of dump conditions (%1!) are already set." 292 */ 293 raiserror 18495, @maxconds 294 295 /* 296 ** 18496, "Either drop a dump condition or increase the value of 'maximum dump conditions'." 297 */ 298 raiserror 18496 299 return 5 300 end 301 end 302 else if (@action != 'reset') 303 begin 304 /* 305 ** Make sure that the user has provided arguments for at 306 ** least one updatable value. 307 */ 308 if (@maxdumps is NULL and @dirname is NULL and @filename is NULL 309 and @optarg1 is NULL and @optarg2 is NULL 310 and @optarg3 is NULL and @optarg4 is NULL 311 and @optarg5 is NULL) 312 begin 313 /* 314 ** 18497, "No values to update were given." 315 */ 316 raiserror 18497 317 return 6 318 end 319 end 320 321 select @object = @value 322 323 /* 324 ** Determine whether there are currently any records for the 325 ** the conditions supplied by the user. This information is 326 ** used below. 327 */ 328 if (@type in ('severity', 'defaults', 'timeslice', 'panic', 'dbcc')) 329 begin 330 if exists (select * from master.dbo.sysattributes 331 where class = @DUMPCOND_CLASS 332 and attribute = @attrib) 333 begin 334 select @recfound = 1 335 end 336 else 337 begin 338 select @recfound = 0 339 end 340 end 341 else 342 begin 343 if exists (select * from master.dbo.sysattributes 344 where class = @DUMPCOND_CLASS 345 and attribute = @attrib 346 and object = @object) 347 begin 348 select @recfound = 1 349 end 350 else 351 begin 352 select @recfound = 0 353 end 354 end 355 356 /* 357 ** Determine whether action can proceed. For add, record must 358 ** not already exist, for update it must exist. 359 */ 360 if (@action = 'add' and @recfound = 1) 361 begin 362 if (@type in ('severity', 'defaults', 'timeslice', 363 'panic', 'dbcc')) 364 begin 365 /* 366 ** 18498, "There is already a condition of type %1!" 367 */ 368 raiserror 18498, @type 369 end 370 else 371 begin 372 /* 373 ** 18499, "There is already a condition of type %1! and value %2!" 374 */ 375 raiserror 18499, @type, @value 376 end 377 return 7 378 end 379 else if (@action = 'update' and @recfound = 0 and @type != 'defaults') 380 begin 381 if (@type in ('severity', 'timeslice', 'panic', 'dbcc')) 382 begin 383 /* 384 ** 18500, "No record found for %1!" 385 */ 386 raiserror 18500, @type 387 end 388 else 389 begin 390 /* 391 ** 18501, "No record found for %1! %2!" 392 */ 393 raiserror 18501, @type, @value 394 end 395 return 8 396 end 397 398 /* 399 ** Validate the dump condition. Signal value cannot be 400 ** verified, since this is determined by the operating 401 ** system. Message value cannot be validated either 402 ** since there is no way to look this up. Dbcc type 403 ** has no value specified. Codepoint also has no lookup. 404 */ 405 if (@type = 'error') 406 begin 407 /* 408 ** Verify that an row exists for this error number 409 ** in the master..sysmessages table 410 */ 411 if not exists (select * from master..sysmessages 412 where error = @value) 413 begin 414 /* 415 ** 18502, "%1! is not a valid error number" 416 */ 417 raiserror 18502, @value 418 return 9 419 end 420 end 421 else if (@type = 'module') 422 begin 423 /* 424 ** Make sure there is at least one error in 425 ** master..sysmessages that belongs to this module 426 */ 427 if ((@value % 100 != 0) 428 or not exists (select * from master..sysmessages 429 where error between @value 430 and @value + 99)) 431 begin 432 /* 433 ** 18503, "%1! is not a valid module" 434 */ 435 raiserror 18503, @value 436 return 10 437 end 438 end 439 else if (@type = 'severity') 440 begin 441 /* 442 ** Minimum severity = 10; maximum severity = 26 443 */ 444 if (@value < 10 or @value > 26) 445 begin 446 /* 447 `** 18504, "Severity must be between 10 and 26" 448 */ 449 raiserror 18504 450 return 11 451 end 452 453 /* 454 ** Make sure we have the correct severity value 455 */ 456 if (@action = 'update') 457 begin 458 select @object = object 459 from master.dbo.sysattributes 460 where class = @DUMPCOND_CLASS 461 and attribute = @attrib 462 end 463 end 464 else if (@type = 'defaults') 465 begin 466 if (@value is not null) 467 begin 468 /* 469 ** 18536, "The value parameter must be NULL when setting system defaults." 470 */ 471 raiserror 18536 472 goto error_exit 473 end 474 475 /* 476 ** If there is not a default record, add one. 477 */ 478 if (@recfound = 0) 479 begin 480 select @action = 'add' 481 end 482 end 483 484 /* 485 ** Reset the dump count for this condition. This does not require 486 ** updating the sysattributes table, but a call must be made to 487 ** attrib_notify() to reset the value. 488 */ 489 if (@action = 'reset') 490 begin 491 if (@type = 'defaults') 492 begin 493 /* 494 ** 18518, "You cannot reset the dump count for the default setting." 495 */ 496 raiserror 18518 497 return 12 498 end 499 500 /* 501 ** A non-zero value for info2 for the maxdumps entry 502 ** indicates that the dump count should be reset. 503 */ 504 select @not_status 505 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 506 @attrib, /*attrib */ 507 @OBJTYPE, /*type*/ 508 @object, /*object*/ 509 @CFG_MAXDUMPS, /*info1*/ 510 1, /*info2*/ 511 NULL, /*info3*/ 512 NULL, /*cinfo*/ 513 NULL, /*intval*/ 514 NULL, /*charval*/ 515 NULL, /*textval*/ 516 NULL, /*imageval*/ 517 NULL, /*comment*/ 518 @ATTR_CHANGE) 519 520 if (@not_status = 0) 521 begin 522 /* 523 ** 18505, "Notification failed. Condition not set." 524 */ 525 raiserror 18505 526 return 13 527 end 528 529 /* 530 ** 18517, "Dump count reset for %1! %2!" 531 */ 532 exec sp_getmessage 18517, @print_str output 533 print @print_str, @type, @value 534 return 0 535 end 536 537 /* 538 ** Values have been validated. Begin transaction and 539 ** insert primary row if needed. 540 */ 541 begin tran add_condition 542 543 /* 544 ** For add action, the primary record must first be added. For 545 ** update, it already exists. 546 */ 547 if (@action = 'add') 548 begin 549 /* 550 ** Insert primary record for new entry in sysattributes 551 ** table and invoke the notification routine if insert 552 ** is successful. 553 */ 554 insert master.dbo.sysattributes 555 (class, attribute, object_type, object, object_info1) 556 values (@DUMPCOND_CLASS, @attrib, @OBJTYPE, @object, 557 @CFG_PRIMARY) 558 559 if (@@error = 0) 560 begin 561 select @not_status = attrib_notify(@DUMPCOND_CLASS, 562 @attrib, @OBJTYPE, 563 @object, @CFG_PRIMARY, 564 NULL, NULL, NULL, NULL, 565 NULL, NULL, NULL, NULL, 566 @ATTR_ADD) 567 568 if (@not_status = 0) 569 begin 570 /* 571 ** 18505, "Notification failed. Condition not set." 572 */ 573 raiserror 18505 574 goto error_exit 575 end 576 577 select @notify_cnt = @notify_cnt + 1 578 end 579 else 580 begin 581 /* 582 ** 18506, "Insert of new record for %1! %2! failed." 583 */ 584 raiserror 18506, @type, @value 585 goto error_exit 586 end 587 end 588 589 /* 590 ** Now insert rows for any additional condition settings 591 ** that were specified by the user. 592 */ 593 if (@maxdumps is not NULL) 594 begin 595 if (@maxdumps <= 0) 596 begin 597 /* 598 ** 18519, "The maxdumps parameter value must be greater than zero." 599 */ 600 raiserror 18519 601 goto error_exit 602 end 603 604 /* 605 ** A value of 0 means that the existing maxdumps setting 606 ** for this condition is being dropped. The sysattributes 607 ** row is removed and attrib_notify() is called to unset 608 ** the maxdumps value internally. 609 */ 610 /* 611 ** Delete existing entry, if there is one 612 */ 613 if (@action = 'update' 614 and exists (select * from master.dbo.sysattributes 615 where class = @DUMPCOND_CLASS 616 and attribute = @attrib 617 and object_type = @OBJTYPE 618 and object = @object 619 and object_info1 = @CFG_MAXDUMPS)) 620 begin 621 delete master.dbo.sysattributes 622 where class = @DUMPCOND_CLASS 623 and attribute = @attrib 624 and object_type = @OBJTYPE 625 and object = @object 626 and object_info1 = @CFG_MAXDUMPS 627 end 628 629 if (@maxdumps != 0) 630 begin 631 insert master.dbo.sysattributes 632 (class, attribute, object_type, object, 633 object_info1, int_value) 634 values (@DUMPCOND_CLASS, @attrib, @OBJTYPE, 635 @object, @CFG_MAXDUMPS, @maxdumps) 636 end 637 638 if (@@error = 0) 639 begin 640 /* 641 ** info2 must be set to zero to indicate the 642 ** the maxdumps value should be updated. 643 */ 644 select @not_status 645 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 646 @attrib, /*attrib */ 647 @OBJTYPE, /*type*/ 648 @object, /*object*/ 649 @CFG_MAXDUMPS, /*info1*/ 650 0, /*info2*/ 651 NULL, /*info3*/ 652 NULL, /*cinfo*/ 653 @maxdumps, /*intval*/ 654 NULL, /*charval*/ 655 NULL, /*textval*/ 656 NULL, /*imageval*/ 657 NULL, /*comment*/ 658 @ATTR_CHANGE) 659 660 if (@not_status = 0) 661 begin 662 /* 663 ** 18505, "Notification failed. Condition not set." 664 */ 665 raiserror 18505 666 goto error_exit 667 end 668 669 select @notify_cnt = @notify_cnt + 1 670 end 671 else 672 begin 673 goto error_exit 674 end 675 676 /* 677 ** Warn the user that there is a dump file specified 678 ** for this condition and that setting maxdumps > 1 may 679 ** lead to dump files being oeverwritten. 680 */ 681 if (@maxdumps > 1 682 and exists (select * 683 from master.dbo.sysattributes 684 where class = @DUMPCOND_CLASS 685 and attribute = @attrib 686 and object_type = @OBJTYPE 687 and object = @object 688 and object_info1 = @CFG_FILENAME)) 689 begin 690 /* 691 ** WARNING: There is a dump file name configured for 692 ** this dump condition. Setting maxdumps to a value 693 ** greater than 1 may cause the dump file to be 694 ** overwritten if more than one shared memory dump 695 ** is performed. 696 */ 697 raiserror 19440 698 end 699 end 700 701 /* 702 ** Set dump directory name if specified. If user supplies a 703 ** @dirname value of "", drop the current value. 704 */ 705 if (@dirname is not NULL) 706 begin 707 /* 708 ** Delete existing entry, if there is one 709 */ 710 if (@action = 'update' 711 and exists (select * from master.dbo.sysattributes 712 where class = @DUMPCOND_CLASS 713 and attribute = @attrib 714 and object_type = @OBJTYPE 715 and object = @object 716 and object_info1 = @CFG_DIRNAME)) 717 begin 718 delete master.dbo.sysattributes 719 where class = @DUMPCOND_CLASS 720 and attribute = @attrib 721 and object_type = @OBJTYPE 722 and object = @object 723 and object_info1 = @CFG_DIRNAME 724 end 725 726 /* 727 ** If user supplies a @dirname value of "", then just 728 ** drop the current setting but do not insert a new one. 729 */ 730 if (@dirname != "") 731 begin 732 insert master.dbo.sysattributes 733 (class, attribute, object_type, object, 734 object_info1, char_value) 735 values (@DUMPCOND_CLASS, @attrib, @OBJTYPE, 736 @object, @CFG_DIRNAME, @dirname) 737 738 if (@@error = 0) 739 begin 740 select @not_status 741 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 742 @attrib, /*attrib*/ 743 @OBJTYPE, /*type*/ 744 @object, /*object*/ 745 @CFG_DIRNAME, /*info1*/ 746 NULL, /*info2*/ 747 NULL, /*info3*/ 748 NULL, /*cinfo*/ 749 NULL, /*intval*/ 750 @dirname, /*charval*/ 751 NULL, /*textval*/ 752 NULL, /*imageval*/ 753 NULL, /*comment*/ 754 @ATTR_CHANGE) 755 756 if (@not_status = 0) 757 begin 758 /* 759 ** 18505, "Notification failed. Condition not set." 760 */ 761 raiserror 18505 762 goto error_exit 763 end 764 765 select @notify_cnt = @notify_cnt + 1 766 end 767 else 768 begin 769 goto error_exit 770 end 771 end 772 else 773 begin 774 /* 775 ** Drop the dump directory entry for this 776 ** condition. 777 */ 778 if (@@error = 0) 779 begin 780 select @not_status 781 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 782 @attrib, /*attrib*/ 783 @OBJTYPE, /*type*/ 784 @object, /*object*/ 785 @CFG_DIRNAME, /*info1*/ 786 NULL, /*info2*/ 787 NULL, /*info3*/ 788 NULL, /*cinfo*/ 789 NULL, /*intval*/ 790 NULL, /*charval*/ 791 NULL, /*textval*/ 792 NULL, /*imageval*/ 793 NULL, /*comment*/ 794 @ATTR_DROP) 795 796 if (@not_status = 0) 797 begin 798 /* 799 ** 18505, "Notification failed. Condition not set." 800 */ 801 raiserror 18505 802 goto error_exit 803 end 804 select @notify_cnt = @notify_cnt + 1 805 end 806 else 807 begin 808 goto error_exit 809 end 810 end 811 end 812 813 /* 814 ** Set dump file name if specified. Drop the current value if 815 ** the user supplies a @filename value of "". 816 */ 817 if (@filename is not NULL) 818 begin 819 /* 820 ** Delete existing entry, if there is one 821 */ 822 if (@action = 'update' 823 and exists (select * from master.dbo.sysattributes 824 where class = @DUMPCOND_CLASS 825 and attribute = @attrib 826 and object_type = @OBJTYPE 827 and object = @object 828 and object_info1 = @CFG_FILENAME)) 829 begin 830 delete master.dbo.sysattributes 831 where class = @DUMPCOND_CLASS 832 and attribute = @attrib 833 and object_type = @OBJTYPE 834 and object = @object 835 and object_info1 = @CFG_FILENAME 836 end 837 838 /* 839 ** If the user supplies a @filename value of "", drop 840 ** the current value but do not insert a new one. 841 */ 842 if (@filename != "") 843 begin 844 /* 845 ** Make sure the new file name is not longer than 846 ** 30 characters 847 */ 848 if ((select char_length(@filename)) > 30) 849 begin 850 /* 851 ** The shared memory dump file name must be 30 852 ** characters or less in length. 853 */ 854 raiserror 19441 855 goto error_exit 856 end 857 858 insert master.dbo.sysattributes 859 (class, attribute, object_type, object, 860 object_info1, char_value) 861 values (@DUMPCOND_CLASS, @attrib, @OBJTYPE, 862 @object, @CFG_FILENAME, @filename) 863 864 if (@@error = 0) 865 begin 866 select @not_status 867 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 868 @attrib, /*attrib */ 869 @OBJTYPE, /*type*/ 870 @object, /*object*/ 871 @CFG_FILENAME, /*info1*/ 872 NULL, /*info2*/ 873 NULL, /*info3*/ 874 NULL, /*cinfo*/ 875 NULL, /*intval*/ 876 @filename, /*charval*/ 877 NULL, /*textval*/ 878 NULL, /*imageval*/ 879 NULL, /*comment*/ 880 @ATTR_CHANGE) 881 882 if (@not_status = 0) 883 begin 884 /* 885 ** 18505, "Notification failed. Condition not set." 886 */ 887 raiserror 18505 888 goto error_exit 889 end 890 select @notify_cnt = @notify_cnt + 1 891 end 892 else 893 begin 894 goto error_exit 895 end 896 897 /* 898 ** Warn the user that maxdumps is > 1 so using 899 ** a fixed file name may result in dump files 900 ** being overwritten but continue processing. 901 */ 902 select @temp_maxdumps = int_value 903 from master.dbo.sysattributes 904 where class = @DUMPCOND_CLASS 905 and attribute = @attrib 906 and object_type = @OBJTYPE 907 and object = @object 908 and object_info1 = @CFG_MAXDUMPS 909 910 if (@temp_maxdumps > 1) 911 begin 912 /* 913 ** WARNING: The maxdumps value for this dump 914 ** condition is greater than 1. Using a 915 ** configured file name may cause the dump file 916 ** to be overwritten if more than one 917 ** shared memory dump is performed. 918 */ 919 raiserror 19439 920 end 921 end 922 else 923 begin 924 /* 925 ** Drop the dump file name entry for this 926 ** condition. 927 */ 928 if (@@error = 0) 929 begin 930 select @not_status 931 = attrib_notify(@DUMPCOND_CLASS, /*cl*/ 932 @attrib, /*attrib*/ 933 @OBJTYPE, /*type*/ 934 @object, /*object*/ 935 @CFG_FILENAME, /*info1*/ 936 NULL, /*info2*/ 937 NULL, /*info3*/ 938 NULL, /*cinfo*/ 939 NULL, /*intval*/ 940 NULL, /*charval*/ 941 NULL, /*textval*/ 942 NULL, /*imageval*/ 943 NULL, /*comment*/ 944 @ATTR_DROP) 945 946 if (@not_status = 0) 947 begin 948 /* 949 ** 18505, "Notification failed. Condition not set." 950 */ 951 raiserror 18505 952 goto error_exit 953 end 954 select @notify_cnt = @notify_cnt + 1 955 end 956 else 957 begin 958 goto error_exit 959 end 960 end 961 end 962 963 if (@optarg1 is not NULL or @optarg2 is not NULL or @optarg3 is not NULL 964 or @optarg4 is not NULL or @optarg5 is not NULL) 965 begin 966 select @counter = 0 967 while (@counter < 5) 968 begin 969 /* 970 ** Set @curarg to current argument's value 971 */ 972 if (@counter = 0) 973 select @curarg = @optarg1 974 else if (@counter = 1) 975 select @curarg = @optarg2 976 else if (@counter = 2) 977 select @curarg = @optarg3 978 else if (@counter = 3) 979 select @curarg = @optarg4 980 else if (@counter = 4) 981 select @curarg = @optarg5 982 983 /* 984 ** If arg is unset, go to next one 985 */ 986 if (@curarg is NULL) 987 begin 988 select @counter = @counter + 1 989 continue 990 end 991 992 /* 993 ** Determine settings based on user's input 994 */ 995 if (@curarg = "include_page") 996 begin 997 select @opttype = @CFG_PAGECACHE 998 select @optsetting = @CFG_INCLUDE 999 end 1000 else if (@curarg = "omit_page") 1001 begin 1002 select @opttype = @CFG_PAGECACHE 1003 select @optsetting = @CFG_OMIT 1004 end 1005 else if (@curarg = "default_page") 1006 begin 1007 select @opttype = @CFG_PAGECACHE 1008 select @optsetting = @CFG_DEFAULT 1009 end 1010 else if (@curarg = "include_proc") 1011 begin 1012 select @opttype = @CFG_PROCCACHE 1013 select @optsetting = @CFG_INCLUDE 1014 end 1015 else if (@curarg = "omit_proc") 1016 begin 1017 select @opttype = @CFG_PROCCACHE 1018 select @optsetting = @CFG_OMIT 1019 end 1020 else if (@curarg = "default_proc") 1021 begin 1022 select @opttype = @CFG_PROCCACHE 1023 select @optsetting = @CFG_DEFAULT 1024 end 1025 else if (@curarg = "include_unused") 1026 begin 1027 select @opttype = @CFG_UNUSED 1028 select @optsetting = @CFG_INCLUDE 1029 end 1030 else if (@curarg = "omit_unused") 1031 begin 1032 select @opttype = @CFG_UNUSED 1033 select @optsetting = @CFG_OMIT 1034 end 1035 else if (@curarg = "default_unused") 1036 begin 1037 select @opttype = @CFG_UNUSED 1038 select @optsetting = @CFG_DEFAULT 1039 end 1040 else if (@curarg = "halt") 1041 begin 1042 select @opttype = @CFG_HALT 1043 select @optsetting = @CFG_INCLUDE 1044 end 1045 else if (@curarg = "no_halt") 1046 begin 1047 select @opttype = @CFG_HALT 1048 select @optsetting = @CFG_OMIT 1049 end 1050 else if (@curarg = "default_halt") 1051 begin 1052 select @opttype = @CFG_HALT 1053 select @optsetting = @CFG_DEFAULT 1054 end 1055 else if (@curarg = "cluster_all") 1056 begin 1057 select @opttype = @CFG_CLUSTER 1058 select @optsetting = @CFG_INCLUDE 1059 end 1060 else if (@curarg = "cluster_local") 1061 begin 1062 select @opttype = @CFG_CLUSTER 1063 select @optsetting = @CFG_OMIT 1064 end 1065 else if (@curarg = "default_cluster") 1066 begin 1067 select @opttype = @CFG_CLUSTER 1068 select @optsetting = @CFG_DEFAULT 1069 end 1070 else 1071 begin 1072 /* 1073 ** 18507, "Invalid option mode %1!" 1074 */ 1075 raiserror 18507, @curarg 1076 goto error_exit 1077 end 1078 1079 /* 1080 ** Delete existing entry, if there is one 1081 */ 1082 if (@action = 'update' 1083 and exists (select * from master.dbo.sysattributes 1084 where class = @DUMPCOND_CLASS 1085 and attribute = @attrib 1086 and object_type = @OBJTYPE 1087 and object = @object 1088 and object_info1 = @opttype)) 1089 begin 1090 delete master.dbo.sysattributes 1091 where class = @DUMPCOND_CLASS 1092 and attribute = @attrib 1093 and object_type = @OBJTYPE 1094 and object = @object 1095 and object_info1 = @opttype 1096 end 1097 1098 /* 1099 ** There is no need to insert a row to set 1100 ** option setting to default. Any previous 1101 ** row should be deleted and the notification 1102 ** function must be called. 1103 */ 1104 if (@optsetting != @CFG_DEFAULT) 1105 begin 1106 /* 1107 ** Insert row into sysattributes table 1108 */ 1109 insert master.dbo.sysattributes 1110 (class, attribute, object_type, 1111 object, object_info1, 1112 int_value) 1113 values (@DUMPCOND_CLASS, @attrib, 1114 @OBJTYPE, @object, @opttype, 1115 @optsetting) 1116 1117 if (@@error = 0) 1118 begin 1119 select @not_status 1120 = attrib_notify( 1121 @DUMPCOND_CLASS, /*cl*/ 1122 @attrib, /*attrib */ 1123 @OBJTYPE, /*type*/ 1124 @object, /*object*/ 1125 @opttype, /*info1*/ 1126 NULL, /*info2*/ 1127 NULL, /*info3*/ 1128 NULL, /*cinfo*/ 1129 @optsetting, /*intval*/ 1130 NULL, /*charval*/ 1131 NULL, /*textval*/ 1132 NULL, /*imageval*/ 1133 NULL, /*comment*/ 1134 @ATTR_CHANGE) 1135 1136 if (@not_status = 0) 1137 begin 1138 /* 1139 ** 18505, "Notification failed. Condition not set." 1140 */ 1141 raiserror 18505 1142 goto error_exit 1143 end 1144 select @notify_cnt = @notify_cnt + 1 1145 end 1146 else 1147 begin 1148 goto error_exit 1149 end 1150 end 1151 else 1152 begin 1153 /* 1154 ** Drop this option setting for this 1155 ** condition. 1156 */ 1157 if (@@error = 0) 1158 begin 1159 select @not_status 1160 = attrib_notify( 1161 @DUMPCOND_CLASS, /*cl*/ 1162 @attrib, /*attrib */ 1163 @OBJTYPE, /*type*/ 1164 @object, /*object*/ 1165 @opttype, /*info1*/ 1166 NULL, /*info2*/ 1167 NULL, /*info3*/ 1168 NULL, /*cinfo*/ 1169 NULL, /*intval*/ 1170 NULL, /*charval*/ 1171 NULL, /*textval*/ 1172 NULL, /*imageval*/ 1173 NULL, /*comment*/ 1174 @ATTR_DROP) 1175 1176 if (@not_status = 0) 1177 begin 1178 /* 1179 ** 18505, "Notification failed. Condition not set." 1180 */ 1181 raiserror 18505 1182 goto error_exit 1183 end 1184 select @notify_cnt = @notify_cnt + 1 1185 end 1186 else 1187 begin 1188 goto error_exit 1189 end 1190 end 1191 1192 select @counter = @counter + 1 1193 end 1194 end 1195 1196 /* 1197 ** All rows successfully added for this condition. 1198 ** Commit transaction. 1199 */ 1200 commit tran add_condition 1201 end 1202 /* 1203 ** Drop a dump condition 1204 */ 1205 else if (@action = 'drop') 1206 begin 1207 exec sp_shmdumpdrop @type, @value, @attrib 1208 end 1209 /* 1210 ** Display current dump condition configuration 1211 */ 1212 else if (@action = 'display') 1213 begin 1214 exec sp_shmdumpdisp @type 1215 end 1216 /* 1217 ** Execute the config action 1218 */ 1219 else if (@action = 'config') 1220 begin 1221 exec sp_shmdumpconfig_config @type, @value 1222 end 1223 1224 /* 1225 ** Indicate success 1226 */ 1227 return 0 1228 1229 /* 1230 ** An error occured while inserting rows into the sysattributes table. 1231 ** Check to see whether this was an add operation. If so, remove any in-memory 1232 ** entries added before error occured. There is a possibility that the 1233 ** in-memory data structure will be left in a state that is not consistent 1234 ** with the sysattributes table entries. This would be the case if we were 1235 ** performing an update of an existing dump condition and one or more 1236 ** rows had been successfully added to sysattributes before the failure 1237 ** occured. In that case, the in-memory table would also have been updated. 1238 ** These updates are not transactional and we have no way of restoring them 1239 ** to their state prior to the execution of the stored procedure. This 1240 ** will only happen in the case of an update operation. In the case of an 1241 ** add operation, the in-memory entries will be removed by the call to 1242 ** attrib_notify() below. To correct this problem, drop and re-add the 1243 ** dump condition. 1244 */ 1245 error_exit: 1246 1247 if (@action = 'add' and @notify_cnt > 0) 1248 begin 1249 /* 1250 ** An error occured while adding a new dump 1251 ** condition but the runtime has already been notified. 1252 ** Remove the reference to this condition before 1253 ** returning. 1254 */ 1255 select @not_status = attrib_notify( 1256 @DUMPCOND_CLASS, /*class*/ 1257 @attrib, /*attrib */ 1258 @OBJTYPE, /*type*/ 1259 @object, /*object*/ 1260 @CFG_PRIMARY, /*info1*/ 1261 NULL, /*info2*/ 1262 NULL, /*info3*/ 1263 NULL, /*cinfo*/ 1264 NULL, /*intval*/ 1265 NULL, /*charval*/ 1266 NULL, /*textval*/ 1267 NULL, /*imageval*/ 1268 NULL, /*comment*/ 1269 @ATTR_DROP) 1270 1271 if (@not_status = 0) 1272 begin 1273 /* 1274 ** 18505, "Notification failed. Condition not set." 1275 */ 1276 raiserror 18505 1277 end 1278 end 1279 1280 /* 1281 ** Rollback any active transaction to undo changes 1282 ** made to the sysattributes table. 1283 */ 1284 select @trancount = @@trancount 1285 1286 if (@trancount > 0) 1287 begin 1288 /* 1289 ** Rollback the current transaction 1290 */ 1291 rollback tran add_condition 1292 end 1293 1294 return 18 1295 1296 /* 1297 ** End of sp_shmdumpconfig 1298 */ 1299
exec sp_procxmode 'sp_shmdumpconfig', 'AnyMode' go Grant Execute on sp_shmdumpconfig to public go
DEFECTS | |
![]() | 541 |
![]() | 1200 |
![]() | 31 |
![]() | 730 |
![]() | 842 |
![]() | master..sysattributes |
![]() | master..sysconfigures |
![]() | master..sysmessages |
![]() | 556 |
![]() | 556 |
![]() | 634 |
![]() | 634 |
![]() | 735 |
![]() | 735 |
![]() | 861 |
![]() | 861 |
![]() | 1113 |
![]() | 1113 |
![]() | 281 |
![]() | 281 |
![]() | 283 |
![]() | 331 |
![]() | 331 |
![]() | 332 |
![]() | 332 |
![]() | 344 |
![]() | 344 |
![]() | 345 |
![]() | 345 |
![]() | 460 |
![]() | 460 |
![]() | 461 |
![]() | 461 |
![]() | 615 |
![]() | 615 |
![]() | 616 |
![]() | 616 |
![]() | 622 |
![]() | 622 |
![]() | 623 |
![]() | 623 |
![]() | 684 |
![]() | 684 |
![]() | 685 |
![]() | 685 |
![]() | 712 |
![]() | 712 |
![]() | 713 |
![]() | 713 |
![]() | 719 |
![]() | 719 |
![]() | 720 |
![]() | 720 |
![]() | 824 |
![]() | 824 |
![]() | 825 |
![]() | 825 |
![]() | 831 |
![]() | 831 |
![]() | 832 |
![]() | 832 |
![]() | 904 |
![]() | 904 |
![]() | 905 |
![]() | 905 |
![]() | 1084 |
![]() | 1084 |
![]() | 1085 |
![]() | 1085 |
![]() | 1091 |
![]() | 1091 |
![]() | 1092 |
![]() | 1092 |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | 532 |
![]() | 621 |
![]() | 631 |
![]() | 718 |
![]() | 830 |
![]() | 1090 |
![]() | 1207 |
![]() | 1214 |
![]() | 1221 |
![]() | 153 |
![]() | 176 |
![]() | 218 |
![]() | 233 |
![]() | 239 |
![]() | 247 |
![]() | 249 |
![]() | 258 |
![]() | 288 |
![]() | 302 |
![]() | 308 |
![]() | 328 |
![]() | 360 |
![]() | 362 |
![]() | 379 |
![]() | 381 |
![]() | 405 |
![]() | 421 |
![]() | 427 |
![]() | 439 |
![]() | 444 |
![]() | 456 |
![]() | 464 |
![]() | 466 |
![]() | 478 |
![]() | 489 |
![]() | 491 |
![]() | 520 |
![]() | 547 |
![]() | 559 |
![]() | 568 |
![]() | 593 |
![]() | 595 |
![]() | 613 |
![]() | 629 |
![]() | 638 |
![]() | 660 |
![]() | 681 |
![]() | 705 |
![]() | 710 |
![]() | 730 |
![]() | 738 |
![]() | 756 |
![]() | 778 |
![]() | 796 |
![]() | 817 |
![]() | 822 |
![]() | 842 |
![]() | 848 |
![]() | 864 |
![]() | 882 |
![]() | 910 |
![]() | 928 |
![]() | 946 |
![]() | 963 |
![]() | 967 |
![]() | 972 |
![]() | 974 |
![]() | 976 |
![]() | 978 |
![]() | 980 |
![]() | 986 |
![]() | 995 |
![]() | 1000 |
![]() | 1005 |
![]() | 1010 |
![]() | 1015 |
![]() | 1020 |
![]() | 1025 |
![]() | 1030 |
![]() | 1035 |
![]() | 1040 |
![]() | 1045 |
![]() | 1050 |
![]() | 1055 |
![]() | 1060 |
![]() | 1065 |
![]() | 1082 |
![]() | 1104 |
![]() | 1117 |
![]() | 1136 |
![]() | 1157 |
![]() | 1176 |
![]() | 1205 |
![]() | 1212 |
![]() | 1219 |
![]() | 1247 |
![]() | 1271 |
![]() | 1286 |
![]() | 272 |
![]() | 458 |
![]() | 902 |
![]() | 555 |
![]() | 632 |
![]() | 733 |
![]() | 859 |
![]() | 1110 |
![]() (name, parent, config) Intersection: {name} | 274 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, object_info1, attribute} | 281 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, attribute} | 331 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object, class, attribute} | 344 |
![]() (error, dlevel, langid) Intersection: {error} | 412 |
![]() (error, dlevel, langid) Intersection: {error} | 429 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {class, attribute} | 460 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 615 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 622 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 684 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 712 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 719 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 824 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 831 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 904 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 1084 |
![]() (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_info1, object_type, object, attribute, class} | 1091 |
![]() | 130 |
![]() | 330 |
![]() | 343 |
![]() | 411 |
![]() | 428 |
![]() | 614 |
![]() | 682 |
![]() | 711 |
![]() | 823 |
![]() | 1083 |
![]() | 28 |
![]() | 28 |
![]() | 28 |