Database | Proc | Application | Created | Links |
sybsystemprocs | sp_setreptable | 31 Aug 14 | Defects Dependencies |
1 2 /* 3 ** Generated by spgenmsgs.pl on Wed Feb 8 14:55:58 2006 4 */ 5 /* 6 ** raiserror Messages for setreptable [Total 10] 7 ** 8 ** 17756, "The execution of the stored procedure '%1!' in database '%2!' was aborted because there was an error in writing the replication log record." 9 ** 17962, "The replication status for '%1!' is already set to %2!. Replication status for '%3!' does not change." 10 ** 17966, "Due to system failure, the replication status for '%1!' has not been changed." 11 ** 18100, "Usage: sp_setreptable [ table_name [, {true | false} [, {owner_on | owner_off} ] ] ]" 12 ** 18101, "The specified table must be in the current database." 13 ** 18102, "Table '%1!' does not exist in this database." 14 ** 18103, "An object with the same name, but owned by a different user, is already being replicated. The table '%1!' cannot be replicated." 15 ** 18409, "The built-in function '%1!' failed. Please see any other messages printed along with this message." 16 ** 18410, "The replication status of '%1!' is corrupt. Please contact Sybase Technical Support." 17 ** 18418, "Only the System Administrator (SA), the Database Owner (dbo) or a user with REPLICATION authorization may execute this stored procedure." 18 */ 19 /* 20 ** sp_getmessage Messages for setreptable [Total 7] 21 ** 22 ** 17431, "true" 23 ** 17432, "false" 24 ** 17964, "The replication status for '%1!' is set to %2!." 25 ** 17965, "The replication status for '%1!' is currently %2!." 26 ** 17968, "The built-in function logschema() failed for '%1!'. See the other messages printed along with this message for more information." 27 ** 18538, "owner_on" 28 ** 18539, "owner_off" 29 */ 30 /* 31 ** End spgenmsgs.pl output. 32 */ 33 34 create procedure sp_setreptable 35 @replicate_name varchar(767) = NULL, /* obj we want to mark as replicate */ 36 @setflag varchar(5) = NULL, /* set or unset the replicate status.*/ 37 @repdefmode varchar(10) = NULL, /* Send Owner Information ? */ 38 @use_index varchar(12) = NULL /* Use indexes for text columns */ 39 as 40 41 declare @current_status int /* current sysstat value for the object. */ 42 declare @current_mode int /* current repdef mode for the object. */ 43 declare @current_index_mode 44 int /* current index mode for the object. */ 45 declare @current_never int /* current never mode for the object. */ 46 declare @new_status int /* new sysstat value for the object. */ 47 declare @new_status2 int /* new sysstat2 value for the object. */ 48 declare @rep_constant smallint /* bit which indicates a replicated object. */ 49 declare @setrep_repl int /* setrepstatus() LT_SETREP_REPLICATE flag 50 ** for setting the replication bit. 51 */ 52 declare @setrep_owner int /* Bit which indicates if the replicated object 53 ** will use owner information for replication 54 */ 55 declare @setrep_index int /* Bit which indicates if the replicated object 56 ** will use internal indexes for text 57 ** replication */ 58 declare @setrep_never int /* Bit which indicates if the object will be 59 ** marked as never replicated regardless of the 60 ** database configuration setting. 61 */ 62 declare @colrepalwys smallint 63 declare @colrepifch smallint 64 declare @tipsa_in_index smallint 65 declare @pkindid int /* PK index id */ 66 declare @pkname varchar(255) /* PK index name */ 67 declare @db varchar(255) /* db of object. */ 68 declare @owner varchar(255) /* owner of object. */ 69 declare @object varchar(255) /* object's name. */ 70 declare @true varchar(10) 71 declare @false varchar(10) 72 declare @never varchar(10) 73 declare @msg varchar(1024) 74 declare @tmpstr varchar(302) 75 declare @sptlang int 76 declare @procval int 77 declare @texttype smallint 78 declare @imagetype smallint 79 declare @unitexttype smallint /* UNITEXT type. */ 80 declare @xtype_type smallint 81 declare @offrow smallint 82 declare @objid int 83 declare @rep_on_schema int /* log schema when turning replication on? */ 84 declare @rep_off_schema int /* log schema when turning replication off? */ 85 declare @owner_on varchar(10) 86 declare @owner_off varchar(10) 87 declare @user_tran int /* are we inside a user tran? */ 88 declare @after_image int /* log the after image of the schema */ 89 declare @mod_versionts int /* modify version timestamp after logging 90 ** the schema 91 */ 92 declare @owner_bit int 93 declare @index_bit int 94 declare @setrep_flags int /* repflags parm passed to setrepstatus(). */ 95 declare @retstat int 96 declare @omsg varchar(40) 97 declare @dbname varchar(255) 98 declare @col_name varchar(255) 99 100 declare @curstat int 101 declare @reptostandbyon int /* 1: standby server is running */ 102 declare @db_rep_level_all int /* All level replication */ 103 declare @db_rep_level_none int /* no replication */ 104 declare @db_rep_level_l1 int /* L1 level replication */ 105 declare @lt_rep_get_failed int /* LT_GET_REP_FAILED */ 106 declare @lt_rep_all int /* LT_REP_ALL */ 107 declare @lt_rep_l1 int /* LT_REP_L1 */ 108 109 110 if @@trancount = 0 111 begin 112 set transaction isolation level 1 113 set chained off 114 end 115 116 if (@@trancount > 0) 117 select @user_tran = 1 118 else 119 select @user_tran = 0 120 121 /* 122 ** Replication enabled flag is 8000H (which is -32768D) 123 */ 124 select @rep_constant = - 32768, 125 @colrepalwys = 1, 126 @colrepifch = 2, 127 @imagetype = 34, 128 @texttype = 35, 129 @xtype_type = 36, 130 @unitexttype = 174, 131 @offrow = 1, 132 @owner_bit = 4096, /* 0x1000 in sysstat2 */ 133 @db_rep_level_all = - 1, 134 @db_rep_level_l1 = 1, 135 @tipsa_in_index = 2048, 136 @setrep_index = 8, /* LT_SETREP_TIPSA_INDEX */ 137 @setrep_owner = 16, /* LT_SETREP_OWNER */ 138 @setrep_never = 1024, /* LT_REP_NEVER */ 139 @retstat = 1, 140 @index_bit = 8388608, /* 0x800000 in sysstat2 */ 141 @lt_rep_get_failed = - 2, /* LT_GET_REP_FAILED */ 142 @lt_rep_all = 2048, /* LT_REP_ALL */ 143 @lt_rep_l1 = 4096 /* LT_REP_L1 */ 144 145 /* 146 ** Initialize @setrep_repl to LT_SETREP_REPLICATE (0x00000001). 147 ** setrepstatus() flags are defined in logtrans.h 148 */ 149 select @setrep_repl = 1 150 151 /* set @rep_on_schema and rep_off_schema to false initially */ 152 select @rep_on_schema = 0 153 select @rep_off_schema = 0 154 155 /* 156 ** Initialize 'true' and 'false' strings 157 */ 158 /* 17431, "true" */ 159 exec sp_getmessage 17431, @true out 160 /* 17432, "false" */ 161 exec sp_getmessage 17432, @false out 162 /* 18538, "owner_on" */ 163 exec sp_getmessage 18538, @owner_on out 164 /* 18539, "owner_off" */ 165 exec sp_getmessage 18539, @owner_off out 166 /* 19896, "never" */ 167 exec sp_getmessage 19896, @never out 168 169 /* Create the temporary table for printing the values */ 170 create table #repdefmode(val int, str varchar(10)) 171 172 insert #repdefmode values (0, @owner_off) 173 insert #repdefmode values (@owner_bit, @owner_on) 174 175 /* Create the temporary table for printing index status value */ 176 create table #indexmode(val int, str varchar(15)) 177 178 insert #indexmode values (0, 'no index') 179 insert #indexmode values (@index_bit, 'using index') 180 181 /* Create the temporary table for printing primary key */ 182 create table #primarykey(val int, str varchar(255)) 183 184 select @dbname = db_name() 185 186 /* 187 ** Set 'sptlang' for proper printing of object information. Used mainly 188 ** for the 'select' statement which is executed when we are invoked with 189 ** no parameters. Copied from similar code in 'sp_help' 190 */ 191 select @sptlang = @@langid 192 if @@langid != 0 193 begin 194 if not exists ( 195 select * from master.dbo.sysmessages where error 196 between 17100 and 17109 197 and langid = @@langid) 198 select @sptlang = 0 199 end 200 201 /* 202 ** If we are invoked with no parameters, then just print out all objects 203 ** which are marked for replication. The 'select' statement is heavily 204 ** based upon the one found in 'sp_help'. 205 */ 206 if (@replicate_name is NULL and @setflag is NULL and @use_index is NULL) 207 /* 208 ** First obtain the information needed to print the primary 209 ** or unique index name chosen for replication. 210 */ 211 begin 212 select @objid = min(id) 213 from sysobjects 214 where type = "U" 215 and (sysstat & @rep_constant) = @rep_constant 216 217 while (@objid is not NULL) 218 begin 219 select @pkindid = getreppkindid(@objid) 220 221 if (@pkindid > 0) 222 begin 223 select @pkname = name 224 from sysindexes 225 where id = @objid 226 and 227 indid = @pkindid 228 229 insert #primarykey values (@objid, @pkname) 230 end 231 else if (@pkindid = 0) 232 insert #primarykey values (@objid, "no primary key") 233 else 234 begin 235 /* 236 ** 18409, "The built-in function '%1!' failed. Please see any 237 ** other messages printed along with this message." 238 */ 239 raiserror 18409, "getreppkindid" 240 return (1) 241 end 242 243 select @objid = min(id) 244 from sysobjects 245 where type = "U" 246 and (sysstat & @rep_constant) = @rep_constant 247 and id > @objid 248 end 249 250 select 251 Name = o.name, 252 "Repdef_Mode" = t.str, 253 "Index_Mode" = x.str, 254 "Primary_Key" = i.str 255 into #show_replicate_table 256 from 257 sysobjects o, 258 #repdefmode t, 259 #indexmode x, 260 #primarykey i 261 where 262 o.id = i.val 263 and (o.sysstat2 & @owner_bit) = t.val 264 and (o.sysstat2 & @index_bit) = x.val 265 order by o.name 266 267 exec sp_autoformat #show_replicate_table, 268 "Name = Name, 269 'Repdef Mode' = Repdef_Mode, 270 'Index Mode' = Index_Mode, 271 'Primary Key' = Primary_Key" 272 273 drop table #show_replicate_table, #repdefmode, 274 #indexmode, #primarykey 275 276 return (0) 277 end 278 279 /* 280 ** Crack the name into its corresponding pieces. 281 */ 282 execute sp_namecrack @replicate_name, 283 @db = @db output, 284 @owner = @owner output, 285 @object = @object output 286 287 /* 288 ** Make sure that the object is in the current database. 289 */ 290 if (@db is not NULL and @db != db_name()) 291 begin 292 /* 293 ** 18101, "Table must be in the current database." 294 */ 295 raiserror 18101 296 return (1) 297 end 298 299 /* 300 ** Make sure that the object actually exists. 301 */ 302 select @objid = object_id(@replicate_name) 303 304 if (@objid is NULL) or 305 (not exists (select name from sysobjects where 306 id = @objid and 307 type = "U" 308 )) 309 begin 310 /* 311 ** 18102, "Table '%1!' does not exist in this database." 312 */ 313 raiserror 18102, @replicate_name 314 return (1) 315 end 316 317 /* 318 ** Currently, marking for replication user tables in the 'master' database 319 ** is not allowed. 320 ** 321 ** Therefore, if the current database is the 'master' database, reset the 322 ** '@setflag' to NULL so that the system procedure will report the current 323 ** status of the user table. A proper error message should be implemented 324 ** at a later date. 325 */ 326 if (db_name() = "master") 327 begin 328 select @setflag = NULL 329 end 330 331 /* 332 ** If the 'setflag' parameter is NULL, then we are only interested in the 333 ** current replication status of the specified object. 334 */ 335 if (@setflag is NULL) 336 begin 337 select 338 @current_status = (sysstat & @rep_constant), 339 @current_mode = (sysstat2 & @owner_bit), 340 @current_index_mode = (sysstat2 & @index_bit) 341 from 342 sysobjects 343 where 344 id = @objid 345 346 select @current_never = getrepdefmode(@objid) 347 348 if (@current_never < 0) 349 begin 350 /* 351 ** 18409, "The built-in function '%1!' failed. Please see any 352 ** other messages printed along with this message." 353 */ 354 raiserror 18409, "getrepdefmode" 355 return (1) 356 end 357 358 /* 359 ** Obtain the primary or unique index chosen for 360 ** the replication of this object. 361 */ 362 select @pkindid = getreppkindid(@objid) 363 364 if (@pkindid < 0) 365 begin 366 /* 367 ** 18409, "The built-in function '%1!' failed. Please see any 368 ** other messages printed along with this message." 369 */ 370 raiserror 18409, "getreppkindid" 371 return (1) 372 end 373 374 if (@pkindid > 0) 375 begin 376 select 377 @pkname = name 378 from 379 sysindexes 380 where 381 id = @objid 382 and 383 indid = @pkindid 384 end 385 386 if @current_status = @rep_constant 387 select @tmpstr = @true 388 else 389 begin 390 if ((@current_never & @setrep_never) != 0) 391 select @tmpstr = @never 392 else 393 select @tmpstr = @false 394 end 395 if @current_mode = 0 396 select @tmpstr = @tmpstr + ", " + @owner_off 397 else 398 select @tmpstr = @tmpstr + ", " + @owner_on 399 if @current_index_mode = @index_bit 400 select @tmpstr = @tmpstr + ", " + "using index" 401 if @pkindid = 0 402 select @tmpstr = @tmpstr + ", " + "no primary key" 403 else 404 select @tmpstr = @tmpstr + ", " + "primary key = '" + @pkname + "'" 405 /* 406 ** 17965 "The replication status for '%1!' is currently %2!." 407 */ 408 exec sp_getmessage 17965, @msg output 409 print @msg, @replicate_name, @tmpstr 410 411 return (0) 412 end 413 414 /* 415 ** You must be SA, dbo or have REPLICATION role to execute this 416 ** sproc. 417 */ 418 if (user_id() != 1) 419 begin 420 if (charindex("sa_role", show_role()) = 0 and 421 charindex("replication_role", show_role()) = 0) 422 begin 423 /* 424 ** 18418, "Only the System Administrator (SA), the 425 ** Database Owner (dbo) or a user with REPLICATION 426 ** authorization may execute this stored 427 ** procedure." 428 */ 429 raiserror 18418 430 return (1) 431 end 432 else 433 begin 434 /* 435 ** Call proc_role() with each role that the user has 436 ** in order to send the success audit records. 437 ** Note that this could mean 1 or 2 audit records. 438 */ 439 if (charindex("sa_role", show_role()) > 0) 440 select @procval = proc_role("sa_role") 441 if (charindex("replication_role", show_role()) > 0) 442 select @procval = proc_role("replication_role") 443 end 444 end 445 446 /* 447 ** Check for a valid setflag parameter 448 */ 449 if (lower(@setflag) not in ("true", "false", "never", @true, @false, @never)) 450 begin 451 /* 452 ** 18100 "Usage: sp_setreptable table_name, {true | false | never} 453 ** {owner_on | owner_off} 454 ** [, use_index ]" 455 */ 456 raiserror 18100 457 return (1) 458 end 459 460 /* Default repdefmode is "owner_off" 461 */ 462 if (@repdefmode is NULL) 463 select @repdefmode = @owner_off 464 /* 465 ** Check for a valid repdefmode parameter 466 */ 467 if (lower(@repdefmode) not in (@owner_on, @owner_off, "owner_on", "owner_off")) 468 begin 469 /* 470 ** 18100, "Usage: sp_setreptable table_name, {true | false | never}, 471 ** {owner_on | owner_off} 472 ** [, use_index ]" 473 */ 474 raiserror 18100 475 return (1) 476 end 477 478 /* 479 ** Check for valid use_index parameter 480 */ 481 if (@use_index is not null and (lower(@use_index) != "use_index")) 482 begin 483 /* 484 ** 18100, "Usage: sp_setreptable table_name, {true | false | never}, 485 ** {owner_on | owner_off} 486 ** [, use_index ]" 487 */ 488 raiserror 18100 489 return (1) 490 end 491 if (@use_index is not null) 492 begin 493 select @setrep_repl = @setrep_repl | @setrep_index 494 end 495 496 /* 497 ** First, determine the current replication status of the database. 498 */ 499 select @curstat = getdbrepstat() 500 501 /* 502 ** Perform sanity checks on the returned value 503 ** getdbrepstat() return current status of replication server. Check returned 504 ** message, system supports only L1 and All level replication. 505 */ 506 if (@curstat = @lt_rep_get_failed) 507 begin 508 /* 509 ** 18409, "The built-in function '%1!' failed. Please 510 ** see any other messages printed along with this message." 511 */ 512 raiserror 18409, "getdbrepstat" 513 return (1) 514 end 515 516 if ((@curstat & @lt_rep_all = @lt_rep_all) or 517 (@curstat & @lt_rep_l1 = @lt_rep_l1)) 518 begin 519 select @reptostandbyon = 1 520 end 521 else 522 begin 523 select @reptostandbyon = 0 524 end 525 526 /* 527 ** Get the object's current status. Hold a read lock on sysobjects so that 528 ** the status cannot be changed until we're done. 529 */ 530 select @current_status = sysstat, @current_mode = sysstat2 531 from sysobjects holdlock 532 where id = @objid 533 534 /* 535 ** Perform the requested operation on the object. 536 ** If setflag is FALSE or NEVER, we ignore the other parameters. 537 */ 538 if lower(@setflag) in ("false", @false) 539 begin 540 select @current_never = getrepdefmode(@objid) 541 542 /* 543 ** Check if we have to remove the replication status 544 */ 545 if ((@current_never & @setrep_never) = 0) 546 and (@current_status & @rep_constant) = 0 547 begin 548 /* 549 ** 17962 "The replication status for '%1!' is already 550 ** set to %2!. Replication status for '%3!' 551 ** does not change." 552 */ 553 raiserror 17962, @replicate_name, @setflag, @replicate_name 554 return (1) 555 end 556 557 select @new_status = @current_status & ~ @rep_constant 558 select @new_status2 = @current_mode & ~ (@owner_bit | @index_bit) 559 select @rep_off_schema = 1 560 select @setrep_flags = 0 561 562 /* 563 ** Even if the user gives a third parameter, set it to 564 ** "owner_off" so that the message printed out at the end 565 ** of the procedure is correct. 566 */ 567 select @repdefmode = @owner_off 568 end 569 else if lower(@setflag) in ("never", @never) 570 begin 571 select @current_never = getrepdefmode(@objid) 572 573 if (@current_never & @setrep_never) != 0 574 begin 575 /* 576 ** 17962 "The replication status for '%1!' is already 577 ** set to %2!. Replication status for '%3!' 578 ** does not change." 579 */ 580 raiserror 17962, @replicate_name, @setflag, @replicate_name 581 return (1) 582 end 583 set @setrep_flags = @setrep_never 584 end 585 else 586 begin 587 /* 588 ** We are turning ON replication on this table. 589 ** 590 ** Is the replicate status bit already set? 591 */ 592 if (@current_status & @rep_constant) != 0 593 begin 594 /* 595 ** 17962 "The replication status for '%1!' is already 596 ** set to %2!. Replication status for '%3!' 597 ** does not change." 598 */ 599 raiserror 17962, @replicate_name, @setflag, @replicate_name 600 return (1) 601 end 602 603 if (lower(@repdefmode) in (@owner_off, "owner_off")) 604 begin 605 /* 606 ** Make sure that no like object with the same name, but a 607 ** different owner, exists. We need to do this because 608 ** the SQL Server does not send owner information along 609 ** with the object to the Replication Server. This 610 ** restriction may be lifted in future versions. 611 */ 612 if exists (select * from sysobjects 613 where name = @object 614 and ( 615 (type = "U ") /* user table */ 616 or 617 (type = "P ") /* stored procedure */ 618 ) 619 and sysstat & @rep_constant != 0 620 and sysstat2 & @owner_bit = 0) 621 begin 622 /* 623 ** 18103 "An object with the same name, but owned by a 624 ** different user is already being replicated. 625 ** The table '%1!' cannot be replicated." 626 */ 627 raiserror 18103, @replicate_name 628 return (1) 629 end 630 631 select @new_status = @current_status | @rep_constant 632 select @new_status2 = @current_mode & ~ @owner_bit 633 select @rep_on_schema = 1 634 select @setrep_flags = @setrep_repl 635 end 636 else 637 begin 638 /* We are setting owner mode to ON */ 639 select @new_status = @current_status | @rep_constant 640 select @new_status2 = @current_mode | @owner_bit 641 select @rep_on_schema = 1 642 select @setrep_flags = @setrep_repl 643 end 644 645 /* Check if we want to use indexes for replication */ 646 if @use_index is not null 647 begin 648 select @new_status2 = @new_status2 | @index_bit 649 end 650 end 651 652 /* 653 ** Update the object's sysstat column 654 ** 655 ** IMPORTANT: This transaction name is significant and is used by 656 ** Replication Server 657 */ 658 begin transaction rs_logexec 659 660 /* log the schema first if we are turning off replication 661 ** or if we repdefmode has ower_mode on, or if standby replication 662 ** server is running. 663 */ 664 if ((@rep_off_schema = 1) or (@repdefmode = @owner_on) 665 or (@reptostandbyon = 1)) 666 begin 667 select @after_image = 0 668 select @mod_versionts = 1 669 if (logschema(@objid, @user_tran, @after_image, 670 @mod_versionts) != 1) 671 begin 672 /* 673 ** 17968 "The built-in function logschema() failed 674 ** for '%1!'." 675 */ 676 exec sp_getmessage 17968, @msg output 677 print @msg, @replicate_name 678 679 rollback transaction 680 return (1) 681 end 682 end 683 684 /* 685 ** Update the column bits for text/image/off-row-object columns 686 */ 687 if (@setrep_flags = @setrep_repl) 688 begin 689 update syscolumns 690 set status = status | @colrepalwys, 691 status2 = 692 case 693 when status2 is null 694 and @use_index is not null 695 then @tipsa_in_index 696 when status2 is not null 697 and @use_index is not null 698 then status2 | @tipsa_in_index 699 else status2 700 end 701 where 702 id = @objid 703 and (type in (@imagetype, @texttype, @unitexttype) 704 or (type = @xtype_type 705 and (xstatus & @offrow) = @offrow)) 706 707 end 708 /* If we are turning off replication, reset status in syscolumns */ 709 else if (@setrep_flags = 0) 710 begin 711 update syscolumns 712 set status = status & ~ (@colrepalwys | @colrepifch), 713 status2 = status2 & ~ (@tipsa_in_index) 714 where 715 id = @objid 716 and (type in (@imagetype, @texttype, @unitexttype) 717 or (type = @xtype_type 718 and (xstatus & @offrow) = @offrow)) 719 720 end 721 722 /* 723 ** Log the schema now if we are turning on replication and we are 724 ** inside a user transaction. 725 */ 726 if ((@rep_on_schema = 1) and (@user_tran = 1)) 727 begin 728 select @after_image = 1 729 select @mod_versionts = 0 730 if (logschema(@objid, @user_tran, @after_image, 731 @mod_versionts) != 1) 732 begin 733 /* 734 ** 17968 "The built-in function logschema() failed 735 ** for '%1!'." 736 */ 737 exec sp_getmessage 17968, @msg output 738 print @msg, @replicate_name 739 740 goto clear_all 741 end 742 end 743 744 /* 745 ** Update the object's status in cache. 746 */ 747 if (setrepstatus(@objid, @setrep_flags) != 1) 748 begin 749 /* 750 ** 17966 "Due to system failure, the replication status 751 ** for '%1!' has not been changed." 752 */ 753 raiserror 17966, @replicate_name, @setflag 754 755 goto clear_all 756 end 757 758 /* We are turning on /off replication. Update status */ 759 if (@setrep_flags = @setrep_repl) or (@setrep_flags = 0) 760 begin 761 /* We are turning on replication */ 762 if (@setrep_flags = @setrep_repl) 763 begin 764 /* Set individual status bits in the cache */ 765 if ((@new_status2 & @owner_bit) != 0) 766 begin 767 select @retstat = setrepdefmode(@objid, 768 @setrep_owner, 1) 769 end 770 if (@retstat = 1) and ((@new_status2 & @index_bit) != 0) 771 begin 772 select @retstat = setrepdefmode(@objid, 773 @setrep_index, 1) 774 end 775 end 776 else 777 begin 778 /* 779 ** We are turning off replication, remove the 780 ** index status from the cache 781 */ 782 select @retstat = setrepdefmode(@objid, 783 @setrep_index, 0) 784 if (@retstat = 1) 785 begin 786 /* Remove the owner status from the cache */ 787 select @retstat = setrepdefmode(@objid, 788 @setrep_owner, 0) 789 end 790 end 791 if (@retstat != 1) 792 begin 793 /* 794 ** 17966 "Due to system failure, the replication status 795 ** for '%1!' has not been changed." 796 */ 797 raiserror 17966, @replicate_name, @setflag 798 799 goto clear_all 800 end 801 802 /* 803 ** Set status at table level 804 */ 805 update sysobjects set sysstat = @new_status, 806 sysstat2 = @new_status2 807 where 808 id = @objid 809 end 810 811 /* 812 ** Write the log record to replicate this invocation 813 ** of the stored procedure. 814 */ 815 if (logexec() != 1) 816 begin 817 /* 818 ** 17756, "The execution of the stored procedure '%1!' 819 ** in database '%2!' was aborted because there 820 ** was an error in writing the replication log 821 ** record." 822 */ 823 raiserror 17756, "sp_setreptable", @dbname 824 825 goto clear_all 826 end 827 828 commit transaction 829 830 /* 831 ** 17964 "The replication status for '%1!' is set to %2!." 832 */ 833 if (@use_index is not null) 834 select @use_index = ", " + @use_index 835 836 if (@setrep_flags = @setrep_never) 837 select @omsg = @setflag 838 else 839 select @omsg = @setflag + ", " + @repdefmode + @use_index 840 841 exec sp_getmessage 17964, @msg output 842 print @msg, @replicate_name, @omsg 843 return (0) 844 845 clear_all: 846 rollback transaction rs_logexec 847 return (1) 848
exec sp_procxmode 'sp_setreptable', 'AnyMode' go Grant Execute on sp_setreptable to public go
DEPENDENCIES |
PROCS AND TABLES USED read_writes table tempdb..#primarykey (1) calls proc sybsystemprocs..sp_getmessage calls proc sybsystemprocs..sp_validlang reads table master..syslanguages (1) reads table master..syslanguages (1) reads table sybsystemprocs..sysusermessages reads table master..sysmessages (1) reads table sybsystemprocs..sysindexes calls proc sybsystemprocs..sp_namecrack writes table tempdb..#show_replicate_table (1) read_writes table sybsystemprocs..sysobjects writes table sybsystemprocs..syscolumns read_writes table tempdb..#repdefmode (1) read_writes table tempdb..#indexmode (1) calls proc sybsystemprocs..sp_autoformat read_writes table tempdb..#colinfo_af (1) reads table tempdb..syscolumns (1) calls proc sybsystemprocs..sp_autoformat reads table master..systypes (1) calls proc sybsystemprocs..sp_namecrack reads table master..syscolumns (1) reads table tempdb..systypes (1) reads table master..sysmessages (1) |