DatabaseProcApplicationCreatedLinks
sybsystemprocssp_config_rep_agent  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Messages for "sp_config_rep_agent"	18373
4     **
5     ** 17240, "'%1!' is not a valid name."
6     ** 17260, "Can't run %1! from within a transaction."
7     ** 17329, "Warning: the configuration property 'multithread rep agent' should be true to allow multiple paths or scanners."
8     ** 17410, "Configuration option doesn't exist."
9     ** 17411, "Configuration option is not unique."
10    ** 17421, "No such database -- run sp_helpdb to list databases."
11    ** 17431 "true"
12    ** 17432 "false"
13    ** 17756, "The execution of the stored procedure '%1!' in database
14    **         '%2!' was aborted because there was an error in writing the
15    **         replication log record."
16    ** 18373, "SQL Server is not currently configured to use Replication Agent threads. Use sp_configure to set this property."
17    ** 18374, "Database '%1!' is not configured to use Replication Agent. Run sp_config_rep_agent without parameters to see a list of databases that use Replication Agent. Use the ENABLE option of sp_config_rep_agent to configure a database to use this feature."
18    ** 18375, "You are not authorized to execute this stored procedure. Only the System Administrator (SA), the Database Owner (DBO) or a user with replication_role authorization can execute this stored procedure."
19    ** 18381, "You must be in the specified database '%1!' to configure its Replication Agent thread."
20    ** 18382, "Database '%1!' is already configured to use Replication Agent. Request to enable Replication Agent has been ignored."
21    ** 18383, "Replication Agent enabled for database '%1!'. The Replication Agent thread needs to be started using sp_start_rep_agent."
22    ** 18384, "Replication Agent disabled for database '%1!'. The secondary truncation point in the database is preserved."
23    ** 18385, "Replication Agent disabled for database '%1!'. The secondary truncation point in the database is no longer active."
24    ** 18423, "Incorrect syntax for sp_config_rep_agent. Usage: sp_config_rep_agent , enable, ,,. Replication Agent was not enabled for this database."
25    ** 18424, "Failed to enable Replication Agent for database '%1!'."
26    ** 18426, "Incorrect syntax for sp_config_rep_agent. Usage: sp_config_rep_agent , disable [,'preserve secondary truncpt']. Replication Agent was not disabled for database '%1!'."
27    ** 18427, "Failed to disable Replication Agent for database '%1!'."
28    ** 18428, "Incorrect syntax for sp_config_rep_agent. Usage: sp_config_rep_agent , '%1!',. Replication Agent configuration has not been changed."
29    ** 18429, "Incorrect syntax for sp_config_rep_agent. Usage: sp_config_rep_agent , '%1!', {true| false}. Replication Agent configuration has not been changed."
30    ** 18430, "Replication Agent configuration changed for database '%1!'."
31    ** 18431, "Failed to configure the Replication Agent for database '%1!'."
32    ** 18432, "Replication Agent configuration changed for database '%1!'. The changes will take effect the next time the Replication Agent thread is started."
33    ** 18895, "Illegal send buffer size '%1!' specified, legal send buffer sizes are 2K, 4K, 8K and 16K."
34    ** 18896, "Illegal data limits filter mode '%1!' specified, legal filter modes are off, stop, truncate, and skip."
35    ** 18368, "Illegal ddl path for unbound objects '%1!' specified, legal paths are all, and default."
36    ** 18386, "WARNING: The 'filter' distribution model requires multiple scanners to be configured ('multiple scanners' = true)."
37    */
38    create or replace procedure sp_config_rep_agent
39        @dbname varchar(30) = NULL, /* database name - optional */
40        @configname varchar(30) = NULL, /* option to configure */
41        @configvalue varchar(255) = NULL, /* value */
42        @rs_username varchar(30) = NULL, /* used only for 'enable' */
43        @rs_password varchar(30) = NULL, /* used only for 'enable' */
44        @rs_encpwd varbinary(256) = NULL /* encrypted rs password */
45    as
46    
47        declare @dbid int /* dbid of the database */
48        declare @dbuid int /* id of the owner of the database */
49        declare @msg varchar(1024)
50        declare @sptlang int
51        declare @true varchar(10)
52        declare @false varchar(10)
53        declare @procval int
54        declare @type int /* Type of the config. parameter */
55        declare @hidden int /* whether parameter is hidden */
56        declare @dynamic int /* whether parameter is dynamic */
57        declare @in_context int /* whether the parameter is currently in context */
58        declare @attrib_id int /* id of the parameter */
59        declare @preserve_trunc_pt int /*  whether to preserve trunc. pt */
60        declare @intvalue int /* converted from char parameter */
61        declare @charvalue varchar(255) /* copy of char parameter */
62        declare @attrname varchar(30)
63        declare @realoption varchar(30) /* real option - user may type
64        in abbreviation*/
65        declare @action int
66        declare @rows_found int
67        declare @oldvalue int
68        declare @tracenum int
69        declare @traceoffset int
70        declare @trc_low int /* used for trace flags 0-30  */
71        declare @trc_high varchar(255) /* used for trace flags 31-99 */
72        declare @trc_char_lohi char(8) /* used for trace flags 31-61 */
73        declare @trc_char_hilo char(8) /* used for trace flags 62-92 */
74        declare @trc_char_hihi char(8) /* used for trace flags 93-99 */
75        declare @configcount int
76        declare @class int
77        declare @curdbname varchar(30)
78        declare @dbstatus3 int /* Database's status3         */
79        declare @tempdb_mask int /* Mask indicating this is a
80        ** temporary database */
81        declare @dummy int
82        declare @nullarg char(1)
83        declare @gp_enabled int
84        declare @status1 int
85        declare @status2 int
86    
87        select @status1 = 1
88        select @status2 = 1
89        declare @mrp_class int /* replication path class */
90        declare @pp int /* Attribute for physical paths */
91        declare @num_physical_paths int /* Number of physical paths */
92        declare @multithread_repagent varchar(5) /* True/false value or config */
93        declare @total_paths int /* Total number of paths */
94        declare @stakey int /* for rs password encryption */
95    
96        declare @multiple_scanners varchar(5) /* multiple scanners true/false */
97        declare @mrp_distrib_model varchar(20) /* MRP distribution model */
98        declare @multithread_warning varchar(250)
99    
100       declare @maxlen int
101   
102       declare @show_all int /* Flag to indicate that all 
103       ** config properties should be
104       ** displayed. */
105       declare @show_context int /* Flag to indicate that only 
106       ** controlling attributes should
107       ** be displayed. */
108       declare @controlling_attr varchar(30)
109       declare @control varchar(10)
110       declare @META_ALL int
111       declare @META_LTL_ONLY int
112   
113       select @class = 11,
114           @mrp_class = 41,
115           @stakey = 54
116   
117       /* Initialize the show_all flag to off */
118       select @show_all = 0
119   
120       /* Initialize the show_context flag to off */
121       select @show_context = 0
122   
123       /*
124       ** Set the META_ALL and META_LTL_ONLY values. 
125       ** These values must correspond to the related #defines in rep_priv.h
126       */
127       select @META_ALL = - 1
128       select @META_LTL_ONLY = - 2
129   
130       /* If we're in a transaction, disallow this */
131       if @@trancount > 0
132       begin
133           /*
134           ** 17260, "Can't run %1! from within a transaction."
135           */
136           raiserror 17260, "sp_config_rep_agent"
137           return (1)
138       end
139       else
140       begin
141           set chained off
142       end
143   
144       set transaction isolation level 1
145   
146       /*
147       ** Initialize 'true' and 'false' strings
148       */
149       /* 17431, "true" */
150       exec sp_getmessage 17431, @true out
151       /* 17432, "false" */
152       exec sp_getmessage 17432, @false out
153   
154       select @sptlang = @@langid
155   
156       if @@langid != 0
157       begin
158           if not exists (
159                   select * from master.dbo.sysmessages where error
160                       between 17050 and 17069
161                       and langid = @@langid)
162               select @sptlang = 0
163       end
164   
165       /* 
166       ** Initialize the mask for temporary databases
167       */
168       select @tempdb_mask = number
169       from master.dbo.spt_values
170       where type = "D3" and name = "TEMPDB STATUS MASK"
171   
172       /* Use lower case */
173       select @configname = lower(@configname)
174   
175       if (@dbname is not NULL)
176       begin -- {
177           /*
178           **  Verify the database name and get the @dbid and @dbuid
179           */
180           select @dbid = dbid, @dbuid = suid, @dbstatus3 = status3
181           from master.dbo.sysdatabases
182           where name = @dbname
183   
184           /*
185           **  If @dbname not found, say so and list the databases.
186           */
187           if @dbid is NULL
188           begin
189               /*
190               ** 17421, "No such database -- run sp_helpdb to list databases."
191               */
192               raiserror 17421
193               return (1)
194           end
195   
196           /*
197           ** Verify that this database is not being shutdown, or the shutdown
198           ** is complete after a HA takeover.
199           **      status3 = 8    : Database is being shutdown
200           **      status3 = 4096 : Shutdown of the database is complete
201           ** or it is a temporary database.
202           */
203           if (((@dbstatus3 & 8) = 8) or
204                   ((@dbstatus3 & 4096) = 4096) or
205                   ((@dbstatus3 & @tempdb_mask) != 0))
206           begin
207               raiserror 18374, @dbname
208               return (1)
209           end
210   
211       end --}
212   
213       /*
214       **  If granular permissions is not enabled, 
215       **  Accounts with SA role or replication role can execute it, 
216       **  and it can also be executed for a specific database by the DBO.
217       **  If granular permissions is enabled then users with 
218       **  'monitor server replication' can execute it only to display information, 
219       **  and it can also be executed for a specific database by users 
220       **  with 'manage replication' permission who are allowed to alter 
221       **  the configuration.
222       */
223       select @nullarg = NULL
224   
225       execute @status1 = sp_aux_checkroleperm "sa_role", "monitor server replication",
226           @nullarg, @gp_enabled output
227   
228       execute @status2 = sp_aux_checkroleperm "replication_role",
229           "manage replication", @dbname, @gp_enabled output
230   
231       if (@gp_enabled = 0)
232       begin --{
233           /*
234           **  Only the Database Owner (DBO) or
235           **  Accounts with SA role or replication role can execute it.
236           **  First check if we are the DBO if the database name is specified.
237           */
238           if (@dbname is NULL) or (suser_id() != @dbuid)
239           begin
240               /* Check if we have sa_role or replication_role. */
241               if ((@status1 != 0) and (@status2 != 0))
242               begin
243                   /*
244                   ** Audit failure. This will result in three messages, 
245                   ** but we will live with that until there is a 
246                   ** better 'proc_role()' interface.
247                   */
248                   select @procval = proc_role("sa_role")
249                   select @procval = proc_role("replication_role")
250   
251                   /* 18375, "You are not authorized to execute this 
252                   ** stored procedure. Only the System Administrator (SA),
253                   **  the Database Owner (DBO) or a user with 
254                   ** replication_role authorization can execute this 
255                   ** stored procedure."
256                   */
257                   raiserror 18375
258                   return (1)
259               end
260           end
261   
262           /* Audit success(es) */
263           if (@status1 = 0)
264               select @procval = proc_role("sa_role")
265           if (@status2 = 0)
266               select @procval = proc_role("replication_role")
267       end --}
268       else
269       begin --{
270   
271           if (@dbname is not NULL)
272           begin
273               /*
274               ** 'manage replication' is required to alter the configuration.
275               ** Specifying a configuration parameter is assumed to be 
276               ** an attempt to alter the configuration to account 
277               ** for action parameters like 'disable'.
278               */
279               if ((@configname is not NULL) and (@status2 != 0))
280               begin
281                   select @dummy = proc_auditperm("manage replication",
282                           @status2, @dbname)
283                   return 1
284               end
285               else if ((@status1 != 0) and (@status2 != 0))
286               begin
287                   select @dummy = proc_auditperm(
288                           "monitor server replication", @status1)
289                   return 1
290               end
291           end
292           else
293           begin
294               if (@status1 != 0)
295               begin
296                   select @dummy = proc_auditperm(
297                           "monitor server replication", @status1)
298                   return 1
299               end
300           end
301   
302           if (@status1 = 0)
303               select @dummy = proc_auditperm("monitor server replication",
304                       @status1, @dbname)
305           if ((@dbname is not null) and (@status2 = 0))
306               select @dummy = proc_auditperm("manage replication", @status2,
307                       @dbname)
308       end --}
309   
310       /* 
311       ** If the database is not specified, then print out a list of databases
312       ** that use the Rep Agent.
313       */
314   
315       if @dbname is NULL
316       begin
317   
318           select "Databases that use Rep Agent" = name
319           from master.dbo.sysdatabases
320           where 1 = case when ((status3 & @tempdb_mask) = 0)
321                   then is_rep_agent_enabled(dbid)
322                   else 0
323               end
324               and ((status3 & 4096) = 0)
325               and ((status3 & 8) = 0)
326               and dbid != 2
327   
328   
329           return (0)
330       end
331   
332       /*
333       ** Create a temporary table with the supported distribution models
334       ** and the corresponding attribute value for the binding type(s) 
335       ** that are distributed under that distribution model (i.e. under
336       ** the 'object' distribution the attribute 23 ('object binding')
337       ** is supported.
338       **
339       **	Column		Description/contents
340       **      ------------	----------------------------------------------
341       **	distribution	The distribution model to configure; must
342       **			be one of {connection|object|filter}
343       **	attribute	The attribute value of the associated binding
344       **			in sysattributes. Note that we use 'NULL' to
345       **			indicate that the 'connection' distribution
346       **			model has no associated binding types.
347       **			The values for the attributes must be the same
348       **			as the values defined in attrib.lst for the
349       **			various binding types.
350       */
351       create table #mrp_supported_bindings(distribution varchar(20) not null,
352           attribute int null)
353       insert #mrp_supported_bindings values ('connection', NULL)
354       insert #mrp_supported_bindings values ('object', 23)
355       insert #mrp_supported_bindings values ('filter', 24)
356   
357       /* 
358       ** Create a temporary table with the names of all configuration parameters.
359       ** The first column is the configuration parameter 
360       ** The second column is the sysattributes attribute id. For options that
361       ** 	are not in sysattributes, for example enable,disable, etc, use -1.
362       ** The third column is the optiontype, which can be
363       ** 	0 (not in sysattributes),
364       **	1 (char),
365       **	2 (int),
366       **	3 (boolean).
367       ** The fourth column is true if column is hidden, and false otherwise.
368       **	A hidden column is not displayed.
369       ** The fifth column is true if the variable is dynamic and false
370       **	otherwise. A dynamic variable takes effect immediately.
371       ** The sixth column indicates whether the attribute is used within
372       ** 	the current configuration context (attributes associated with
373       ** 	a disabled feature set are not displayed). The configuration
374       **	context is explained in detail in ra_attr.c.
375       ** There is no relevance between the attribute ids and 
376       **	RA_CFG_CFG_XXXX defines in $DBMS/include/rep_priv.h
377       */
378       create table #rep_ag_options(optionname varchar(30), attrib_id int,
379           optiontype int, hidden int, dynamic int, in_context int)
380   
381       /* "show all" option overrides context sensitive display */
382       insert into #rep_ag_options values ("show all", - 1, 0, 1, 0, rep_cfg_valid_context(@dbid, @META_ALL))
383       /* "current context" option displays the current values of the controlling attributes */
384       insert into #rep_ag_options values ("current context", - 1, 0, 1, 0, rep_cfg_valid_context(@dbid, @META_ALL))
385   
386       insert into #rep_ag_options values ("enable", - 1, 0, 1, 0, rep_cfg_valid_context(@dbid, @META_ALL))
387       insert into #rep_ag_options values ("disable", - 1, 0, 1, 0, rep_cfg_valid_context(@dbid, @META_ALL))
388       insert into #rep_ag_options values ("rs servername", 0, 1, 0, 0, rep_cfg_valid_context(@dbid, 0))
389       insert into #rep_ag_options values ("rs username", 1, 1, 0, 0, rep_cfg_valid_context(@dbid, 1))
390       insert into #rep_ag_options values ("rs password", 2, 1, 1, 0, rep_cfg_valid_context(@dbid, 2))
391       insert into #rep_ag_options values ("scan batch size", 3, 2, 0, 0, rep_cfg_valid_context(@dbid, 3))
392       insert into #rep_ag_options values ("scan timeout", 4, 2, 0, 0, rep_cfg_valid_context(@dbid, 4))
393       insert into #rep_ag_options values ("retry timeout", 5, 2, 0, 0, rep_cfg_valid_context(@dbid, 5))
394       insert into #rep_ag_options values ("fade timeout", 6, 2, 1, 0, rep_cfg_valid_context(@dbid, 6))
395       insert into #rep_ag_options values ("skip ltl errors", 7, 3, 0, 0, rep_cfg_valid_context(@dbid, 7))
396       insert into #rep_ag_options values ("batch ltl", 8, 3, 0, 0, rep_cfg_valid_context(@dbid, 8))
397       insert into #rep_ag_options values ("send warm standby xacts", 9, 3, 0, 0, rep_cfg_valid_context(@dbid, 9))
398       insert into #rep_ag_options values ("connect dataserver", 10, 1, 0, 0, rep_cfg_valid_context(@dbid, 10))
399       insert into #rep_ag_options values ("connect database", 11, 1, 0, 0, rep_cfg_valid_context(@dbid, 11))
400       insert into #rep_ag_options values ("send maint xacts to replicate", 12, 3, 0, 0, rep_cfg_valid_context(@dbid, 12))
401       insert into #rep_ag_options values ("traceon", 13, 2, 0, 1, rep_cfg_valid_context(@dbid, 13))
402       insert into #rep_ag_options values ("traceoff", 13, 2, 0, 1, rep_cfg_valid_context(@dbid, 13))
403       insert into #rep_ag_options values ("trace log file", 14, 1, 0, 1, rep_cfg_valid_context(@dbid, 14))
404       insert into #rep_ag_options values ("security mechanism", 15, 1, 0, 0, rep_cfg_valid_context(@dbid, 15))
405       insert into #rep_ag_options values ("unified login", 16, 3, 0, 0, rep_cfg_valid_context(@dbid, 16))
406       insert into #rep_ag_options values ("msg confidentiality", 17, 3, 0, 0, rep_cfg_valid_context(@dbid, 17))
407       insert into #rep_ag_options values ("msg integrity", 18, 3, 0, 0, rep_cfg_valid_context(@dbid, 18))
408       insert into #rep_ag_options values ("msg replay detection", 19, 3, 0, 0, rep_cfg_valid_context(@dbid, 19))
409       insert into #rep_ag_options values ("msg origin check", 20, 3, 0, 0, rep_cfg_valid_context(@dbid, 20))
410       insert into #rep_ag_options values ("msg out-of-sequence check", 21, 3, 0, 0, rep_cfg_valid_context(@dbid, 21))
411       insert into #rep_ag_options values ("mutual authentication", 22, 3, 0, 0, rep_cfg_valid_context(@dbid, 22))
412       insert into #rep_ag_options values ("net password encryption", 31, 3, 0, 0, rep_cfg_valid_context(@dbid, 31))
413       insert into #rep_ag_options values ("skip unsupported features", 23, 3, 0, 0, rep_cfg_valid_context(@dbid, 23))
414       insert into #rep_ag_options values ("ha failover", - 1, 3, 0, 1, rep_cfg_valid_context(@dbid, @META_LTL_ONLY))
415       insert into #rep_ag_options values ("short ltl keywords", 24, 3, 0, 0, rep_cfg_valid_context(@dbid, 24))
416       insert into #rep_ag_options values ("send buffer size", 25, 1, 0, 0, rep_cfg_valid_context(@dbid, 25))
417       insert into #rep_ag_options values ("priority", 26, 2, 0, 0, rep_cfg_valid_context(@dbid, 26))
418       insert into #rep_ag_options values ("send structured oqids", 27, 3, 0, 0, rep_cfg_valid_context(@dbid, 27))
419       insert into #rep_ag_options values ("data limits filter mode", 29, 1, 0, 0, rep_cfg_valid_context(@dbid, 29))
420       insert into #rep_ag_options values ("auto start", - 1, 3, 0, 1, rep_cfg_valid_context(@dbid, @META_ALL))
421       insert into #rep_ag_options values ("startup delay", 30, 2, 0, 0, rep_cfg_valid_context(@dbid, 30))
422       insert into #rep_ag_options values ("bind to engine", 32, 2, 0, 0, rep_cfg_valid_context(@dbid, 32))
423       insert into #rep_ag_options values ("ltl batch size", 34, 2, 0, 0, rep_cfg_valid_context(@dbid, 34))
424       insert into #rep_ag_options values ("multithread rep agent", 36, 3, 0, 0, rep_cfg_valid_context(@dbid, 36))
425       insert into #rep_ag_options values ("number of send buffers", 37, 2, 0, 1, rep_cfg_valid_context(@dbid, 37))
426       insert into #rep_ag_options values ("max number replication paths", 38, 2, 0, 0, rep_cfg_valid_context(@dbid, 38))
427       insert into #rep_ag_options values ("ltl metadata reduction", 39, 3, 0, 0, rep_cfg_valid_context(@dbid, 39))
428       insert into #rep_ag_options values ("activate monitoring", 40, 3, 0, 1, rep_cfg_valid_context(@dbid, 40))
429       insert into #rep_ag_options values ("ddl path for unbound objects", 41, 1, 0, 0, rep_cfg_valid_context(@dbid, 41))
430       insert into #rep_ag_options values ("multipath distribution model", 42, 1, 0, 0, rep_cfg_valid_context(@dbid, 42))
431       insert into #rep_ag_options values ("multiple scanners", 43, 3, 0, 0, rep_cfg_valid_context(@dbid, 43))
432       insert into #rep_ag_options values ("max schema cache per scanner", 44, 2, 0, 0, rep_cfg_valid_context(@dbid, 44))
433       insert into #rep_ag_options values ("trunc point request interval", 45, 2, 0, 1, rep_cfg_valid_context(@dbid, 45))
434       /* Note: 'max writetext groups' is out of sequence (needs to be before CI propreties). */
435       insert into #rep_ag_options values ("max writetext groups", 53, 2, 0, 0, rep_cfg_valid_context(@dbid, 53))
436   
437       /* 
438       ** Keep 'stream replication' as the last non-CI attribute so that it always immediately
439       ** precedes the CI specific attributes when displayed - there is on functional reason 
440       ** why we need to do this, but it makes the grouping more clear in the display
441       */
442       insert into #rep_ag_options values ("stream replication", 46, 3, 0, 0, rep_cfg_valid_context(@dbid, 46))
443   
444       /* BEGIN RA_CI ATTRS */
445       insert into #rep_ag_options values ("stream mode", 47, 1, 0, 1, rep_cfg_valid_context(@dbid, 47))
446       insert into #rep_ag_options values ("max stream retry", 48, 2, 0, 0, rep_cfg_valid_context(@dbid, 48))
447       insert into #rep_ag_options values ("number of threads", 49, 2, 1, 0, rep_cfg_valid_context(@dbid, 49))
448       insert into #rep_ag_options values ("buffer pool size", 50, 2, 0, 0, rep_cfg_valid_context(@dbid, 50))
449       insert into #rep_ag_options values ("stream buffer size", 51, 2, 0, 0, rep_cfg_valid_context(@dbid, 51))
450       insert into #rep_ag_options values ("max commit wait", 52, 2, 0, 1, rep_cfg_valid_context(@dbid, 52))
451   
452   
453       if @configname is not NULL
454       begin
455           /* Verify that the option is valid */
456           select @configcount = count(*)
457           from #rep_ag_options
458           where optionname like "%" + @configname + "%"
459   
460           /* If more than one option, show duplicates */
461           if @configcount > 1
462           begin
463               select "List of Matching Options" = optionname
464               from #rep_ag_options
465               where optionname like "%" + @configname + "%"
466               /*
467               ** 17411, "Configuration option is not unique."
468               */
469               raiserror 17411
470               return (1)
471           end
472   
473           /* Now we know that there is a unique option */
474           select @type = - 1
475   
476           select @realoption = optionname, @attrib_id = attrib_id,
477               @type = optiontype, @hidden = hidden,
478               @dynamic = dynamic, @in_context = in_context
479           from #rep_ag_options
480           where optionname like "%" + @configname + "%"
481   
482           /* if no match found */
483           if @type = - 1
484           begin
485               /* The option specified was incorrect */
486               select "List of Options" = optionname
487               from #rep_ag_options
488               where optionname != "fade timeout"
489               /*
490               ** 17410, "Configuration option doesn't exist."
491               */
492               raiserror 17410
493               return (1)
494           end
495           if @realoption = "show all"
496           begin
497               /*
498               ** If we got "show all" then set the flag indicating
499               ** this so we retrieve the list of options correctly
500               ** later on. Also reset the @realoption to NULL so we
501               ** will fall into the path to print the full list of
502               ** options below.
503               */
504               select @show_all = 1
505               select @realoption = NULL
506           end
507           if @realoption = "current context"
508           begin
509               /*
510               ** If we got "current context" then set the flag
511               ** indicating so we only retrieve the controlling
512               ** attributes. Also reset the @realoption to NULL
513               ** so we will fall into the path to only print the
514               ** list of options below.
515               */
516               select @show_context = 1
517               select @realoption = NULL
518           end
519       end
520   
521       /* Get the name of the sysattributes entry */
522       if @realoption in ("traceon", "traceoff")
523       begin
524           select @attrname = "trace flags"
525       end
526       else
527       begin
528           select @attrname = @realoption
529       end
530   
531       /* Check if Rep Agent threads are enabled for everything except disable */
532       if (@realoption != "disable") and (is_rep_agent_enabled() = 0)
533       begin
534           /* 18373, "SQL Server is not currently configured to use Replication 
535           ** Agent threads. Use sp_configure to set this property."
536           */
537           raiserror 18373
538           return (1)
539       end
540   
541       /* If the database name is specified but no configuration parameter is 
542       ** specified then print out the current settings for the database.
543       */
544       if @realoption is NULL
545       begin
546           if is_rep_agent_enabled(@dbid) = 0
547           begin
548               /* 18374, "Database '%1!' is not configured to use Replication Agent. 
549               ** Run sp_config_rep_agent without parameters to see a list of 
550               ** databases that use Replication Agent. Use the ENABLE option of 
551               ** sp_config_rep_agent to configure a database to use this feature."
552               */
553               raiserror 18374, @dbname
554               return (1)
555           end
556   
557           if @show_context = 0
558           begin
559               /*
560               ** 'select into' the configuration information into a temp table.
561               ** Unless we specifically request out of context options with the
562               ** explicit "show all" parameter we will show only the in-context
563               ** options.
564               */
565               select "Parameter_Name" = optionname,
566                   "Default_Value" = rep_agent_config(@dbid, "default config", optionname),
567                   "Config_Value" = rep_agent_config(@dbid, "current config", optionname),
568                   "Run_Value" = rep_agent_config(@dbid, "config", optionname)
569               into #config_rep_agent_all
570               from #rep_ag_options
571               where hidden = 0
572                   and attrib_id != 13
573                   and (in_context = 0 or @show_all = 1)
574   
575               /* Insert 'trace flags'	information into the temp table. */
576               insert into #config_rep_agent_all values ("trace flags",
577                   rep_agent_config(@dbid, "default config", "trace flags"),
578                   rep_agent_config(@dbid, "current config", "trace flags"),
579                   rep_agent_config(@dbid, "config", "trace flags"))
580   
581               /* Output and format the content of the	temp table. */
582               exec sp_autoformat #config_rep_agent_all
583   
584               /* drop the temp table */
585               drop table #config_rep_agent_all
586           end
587           else
588           begin
589               /*
590               ** 'select into' the controlling attribute information
591               ** into a temp table. We will select the controlling
592               ** attributes by name rather than attribute id simply
593               ** for ease of reading here.
594               */
595               select "Parameter_Name" = optionname,
596                   "Default_Value" = rep_agent_config(@dbid, "default config", optionname),
597                   "Config_Value" = rep_agent_config(@dbid, "current config", optionname),
598                   "Run_Value" = rep_agent_config(@dbid, "config", optionname)
599               into #config_rep_agent_cc
600               from #rep_ag_options
601               where (optionname = 'stream replication'
602                       or optionname = 'multithread rep agent')
603   
604               /* Output and format the content of the	temp table. */
605               exec sp_autoformat #config_rep_agent_cc
606   
607               /* drop the temp table */
608               drop table #config_rep_agent_cc
609           end
610   
611           return (0)
612       end
613       /* If the option is specified, but no value is given, then we print out the
614       ** value unless the option is hidden.
615       */
616       else if (@configvalue is NULL) and (@rs_username is NULL)
617           and (@rs_password is NULL) and (@hidden = 0)
618       begin
619           /* If the config option was specified, but no value, then we will
620           ** print out the settings for the option.	
621           */
622   
623           /* 'select into' the configuration information into a temp table. */
624           select "Parameter_Name" = @attrname,
625               "Default_Value" = rep_agent_config(@dbid, "default config", @attrname),
626               "Config_Value" = rep_agent_config(@dbid, "current config", @attrname),
627               "Run_Value" = rep_agent_config(@dbid, "config", @attrname)
628           into #config_rep_agent_someone
629   
630           /* Output and format the content of the	temp table. */
631           exec sp_autoformat #config_rep_agent_someone
632   
633           /* drop the temp table */
634           drop table #config_rep_agent_someone
635   
636           return (0)
637       end
638   
639       /* Now, we are here to modify the current settings for the specified database.
640       ** Enforce that the current database is the same as the one specified. 
641       */
642   
643       if @dbid != db_id()
644       begin
645           /* 18381, "You must be in the specified database '%1!' to configure 
646           ** its Replication Agent thread."
647           */
648           raiserror 18381, @dbname
649           return (1)
650       end
651   
652   
653       /* Else, it means that we have found a match with one of the options */
654   
655       if @realoption = "enable"
656       begin
657           /* Check if the database already has the Rep Agent enabled. */
658           if is_rep_agent_enabled(@dbid) = 1
659           begin
660               /* 18382, "Database '%1!' is already configured to use 
661               ** Replication Agent. Request to enable Replication Agent has 
662               ** been ignored."
663               */
664               raiserror 18382, @dbname
665               return (1)
666           end
667           if (@configvalue is NULL
668                   or @rs_username is NULL
669                   or @rs_password is NULL)
670           begin
671               /* 18423, "Incorrect syntax for sp_config_rep_agent. Usage: 
672               ** sp_config_rep_agent , enable, ,
673               ** ,. Replication Agent was not 
674               ** enabled for this database."
675               */
676               raiserror 18423
677               return (1)
678           end
679   
680           if (@rs_encpwd is NULL)
681           begin
682               /* 
683               ** The rs password (@rs_password) needs to be 
684               ** encrypted.
685               */
686               select @rs_encpwd = internal_encrypt(@rs_password, @stakey, 0)
687   
688               if (@rs_encpwd is NULL)
689               begin
690                   /*
691                   ** 17067 "Unable to encrypt password for '%1!'.
692                   ** See prior error message for reason."
693                   */
694                   raiserror 17067, @dbname
695                   return (1)
696               end
697   
698               select @rs_password = NULL
699           end
700   
701           /* Check RS name length. */
702           select @maxlen = length from master.dbo.syscolumns
703           where id = object_id("master.dbo.sysservers") and name = "srvnetname"
704   
705           if (datalength(@configvalue) > @maxlen)
706           begin
707               /*
708               ** 17240, "'%1!' is not a valid name."
709               */
710               raiserror 17240, @configvalue
711               return (1)
712           end
713   
714           if (rep_agent_admin("enable", @dbid, @configvalue, @rs_username,
715                       @rs_encpwd) = 0)
716           begin
717               /* 18424, "Failed to enable Replication Agent for database '%1!'." */
718               raiserror 18424, @dbname
719               return (1)
720           end
721   
722           /* 18383, "Replication Agent enabled for database '%1!'. The 
723           ** Replication Agent thread needs to be started using 
724           ** sp_start_rep_agent."
725           */
726           exec sp_getmessage 18383, @msg output
727           print @msg, @dbname
728           return (0)
729       end
730   
731       if is_rep_agent_enabled(@dbid) = 0
732       begin
733           /* 18374, "Database '%1!' is not configured to use Replication Agent. 
734           ** Run sp_config_rep_agent without parameters to see a list of 
735           ** databases that use Replication Agent. Use the ENABLE option of 
736           ** sp_config_rep_agent to configure a database to use this feature."
737           */
738           raiserror 18374, @dbname
739           return (1)
740       end
741   
742       if @realoption = "disable"
743       begin
744           if (@configvalue = "preserve secondary truncpt")
745           begin
746               select @preserve_trunc_pt = 1
747           end
748           else if (@configvalue is NULL)
749           begin
750               select @preserve_trunc_pt = 0
751           end
752           else
753           begin
754               /* 18426, "Incorrect syntax for sp_config_rep_agent. Usage: 
755               ** sp_config_rep_agent , disable [,'preserve secondary
756               **  truncpt']. Replication Agent was not disabled for database
757               **  '%1!'."
758               */
759               raiserror 18426, @dbname
760   
761               return (1)
762           end
763   
764           /* Now go ahead and call the builtin */
765           if (rep_agent_admin("disable", @dbid, @preserve_trunc_pt) = 0)
766           begin
767               /* 18427, "Failed to disable Replication Agent for
768               **         database '%1!'."
769               */
770               raiserror 18427, @dbname
771               return (1)
772           end
773   
774           if @preserve_trunc_pt = 1
775           begin
776               /* 18384, "Replication Agent disabled for database '%1!'. The 
777               ** secondary truncation point in the database is preserved."
778               */
779               exec sp_getmessage 18384, @msg output
780               print @msg, @dbname
781               return (0)
782           end
783           else
784           begin
785               /* 18385, "Replication Agent disabled for database '%1!'. The 
786               ** secondary truncation point in the database is no longer 
787               ** active."
788               */
789               exec sp_getmessage 18385, @msg output
790               print @msg, @dbname
791               return (0)
792           end
793   
794       end
795   
796       else if @realoption in ("ha failover", "auto start")
797       begin
798           /*
799           ** HA failover takes a boolean arguement, but does not have a row in
800           ** sysattributes.
801           */
802           select @intvalue = NULL
803   
804           /* Verify that value is passed in and other parameters are NULL */
805           if (@configvalue is NULL
806                   or @rs_username is not NULL
807                   or @rs_password is not NULL)
808           begin
809               /* 
810               ** 18428, "Incorrect syntax for sp_config_rep_agent. Usage:
811               ** sp_config_rep_agent 812               ** Agent configuration has not been changed."
813               */
814               raiserror 18428, @realoption
815               return (1)
816           end
817           if (lower(@configvalue) in ("true", @true))
818           begin
819               select @intvalue = 1
820           end
821           else if (lower(@configvalue) in ("false", @false))
822           begin
823               select @intvalue = 0
824           end
825           else
826           begin
827               /* 18429, "Incorrect syntax for sp_config_rep_agent.
828               ** Usage: sp_config_rep_agent 829               ** false}. Replication Agent configuration has not
830               ** been changed."
831               */
832               raiserror 18429, @realoption
833               return (1)
834           end
835   
836           /* Now go ahead and call the builtin */
837           if (rep_agent_admin(@attrname, @dbid, @intvalue) != 0)
838           begin
839               /* 'select into' the configuration information into a temp table. */
840               select "Parameter_Name" = @attrname,
841                   "Default_Value" = rep_agent_config(@dbid, "default config", @attrname),
842                   "Config_Value" = rep_agent_config(@dbid, "current config", @attrname),
843                   "Run_Value" = rep_agent_config(@dbid, "config", @attrname)
844               into #config_rep_agent_ha
845   
846               /* Output and format the content of the	temp table. */
847               exec sp_autoformat #config_rep_agent_ha
848   
849               /* drop the temp table */
850               drop table #config_rep_agent_ha
851   
852           end
853       end
854   
855       else
856       begin
857           /* Instead of repeating code for ints and chars, use @charvalue
858           ** and @intvalue (only one of them will be non-NULL except for trace flags).
859           */
860           select @charvalue = NULL
861           select @intvalue = NULL
862   
863           /* Verify that value is passed in and other parameters are NULL */
864           if ((@configvalue is NULL and @rs_encpwd is NULL)
865                   or (@configvalue is not NULL and @rs_encpwd is not NULL)
866                   or @rs_username is not NULL
867                   or @rs_password is not NULL)
868           begin
869               /* 18428, "Incorrect syntax for sp_config_rep_agent. Usage: 
870               ** sp_config_rep_agent , '%1!',. Replication 
871               ** Agent configuration has not been changed."
872               */
873               raiserror 18428, @realoption
874               return (1)
875           end
876   
877           /* For booleans */
878           if @type = 3
879           begin
880               if (lower(@configvalue) in ("true", @true))
881               begin
882                   select @intvalue = 1
883               end
884               else if (lower(@configvalue) in ("false", @false))
885               begin
886                   select @intvalue = 0
887               end
888               else
889               begin
890                   /* 18429, "Incorrect syntax for sp_config_rep_agent. 
891                   ** Usage: sp_config_rep_agent , '%1!', {true| 
892                   ** false}. Replication Agent configuration has not 
893                   ** been changed."
894                   */
895                   raiserror 18429, @realoption
896                   return (1)
897               end
898           end
899           else if @type = 2 /* integers */
900           begin
901               select @intvalue = convert(int, @configvalue)
902           end
903           else /* characters */
904           begin
905               select @charvalue = @configvalue
906           end
907   
908           /*
909           ** Special case check for send buffer size, which only allows
910           ** 2k, 4k, 8k, and 16k as arguments.
911           */
912           if @realoption = "send buffer size"
913           begin
914               /* Check for legal sizes. */
915               select @charvalue = lower(@charvalue)
916               if not (@charvalue in ('2k', '4k', '8k', '16k'))
917               begin
918                   raiserror 18895, @charvalue
919                   return (1)
920               end
921   
922               /*
923               ** Convert char value to integer.
924               ** Note that this attribute will have both a charvalue and
925               ** an intvalue.
926               */
927               select @intvalue
928                   = convert(int, substring(@charvalue, 1,
929                       charindex('k', @charvalue) - 1))
930           end
931   
932           /*
933           ** Special case check for multithread rep agent false and
934           ** max number replication paths > 1.
935           */
936           if @realoption = "multithread rep agent"
937           begin
938               /* Check number of replication paths when setting
939               ** multithread rep agent to false. If greater than 1
940               ** warn user. @intvalue = 0 means property is false.
941               */
942               if (@intvalue = 0)
943               begin
944                   /* Get number of physical paths defined for this database.
945                   ** attribute = 0 is connection info
946                   */
947                   select @pp = 0
948                   select @num_physical_paths = count(*) from sysattributes
949                   where class = @mrp_class and attribute = @pp
950   
951                   /* Add 1 for default path */
952                   select @total_paths = @num_physical_paths + 1
953   
954                   if (@total_paths > 1)
955                   begin
956                       exec sp_getmessage 17329, @multithread_warning output
957                       print "%1!", @multithread_warning
958                   end
959               end
960           end
961           else
962           if (@realoption = "max number replication paths" and @intvalue > 1)
963           /* Check if multithread rep agent is false when setting
964           ** "max number replication paths" > 1. If multithread rep agent 
965           ** is false, warn user. @intvalue is max number of replication paths.
966           */
967           begin
968               /*
969               ** Get multithread rep agent config value defined for this database.
970               */
971               select @multithread_repagent =
972                   convert(varchar(5), rep_agent_config(@dbid, "current config", "multithread rep agent"))
973               if @multithread_repagent = "false"
974               begin
975                   exec sp_getmessage 17329, @multithread_warning output
976                   print "%1!", @multithread_warning
977               end
978           end
979           else
980           if @realoption = "multiple scanners"
981           /* Check if multithread rep agent is false when setting
982           ** "max number replication paths" > 1 or "multiple scanners"
983           ** = true. If multithread rep agent is false, warn user.
984           ** @intvalue is max number of replication paths or for multiple
985           ** scanners means true (i.e. enabled).
986           */
987           begin
988               if @intvalue = 1
989               begin
990                   /*
991                   ** Get multithread rep agent config value defined for
992                   ** this database.
993                   */
994                   select @multithread_repagent =
995                       convert(varchar(5),
996                       rep_agent_config(@dbid,
997                           "current config",
998                           "multithread rep agent"))
999   
1000                  if @multithread_repagent = "false"
1001                  begin
1002                      exec sp_getmessage 17329, @multithread_warning output
1003                      print "%1!", @multithread_warning
1004                  end
1005              end
1006              else
1007              begin
1008                  /*
1009                  ** If we are changing "multiple scanners"
1010                  ** to false (0, turning off multiple scanners) then we need
1011                  ** to check if the "multipath distribution model" is
1012                  ** set to 'filter' and warn the user if it is that 
1013                  ** multiple scanners is required for filter model.
1014                  */
1015                  select @mrp_distrib_model =
1016                      convert(varchar(20),
1017                      rep_agent_config(@dbid,
1018                          "current config",
1019                          "multipath distribution model"))
1020                  if (@mrp_distrib_model = "filter")
1021                  begin
1022                      /*
1023                      ** Continue, but raise a warning!
1024                      **
1025                      ** WARNING: The 'filter' distribution model 
1026                      ** requires multiple scanners to be configured
1027                      ** ('multiple scanners' = true).  
1028                      */
1029                      exec sp_getmessage 18386, @multithread_warning output
1030                      print "%1!", @multithread_warning
1031                  end
1032              end
1033          end
1034          else
1035          if @realoption = "ddl path for unbound objects"
1036          begin
1037              /* special syntax check for DDL path of unbound objects */
1038              select @charvalue = lower(@charvalue)
1039              if not (@charvalue in ('all', 'default'))
1040              begin
1041                  raiserror 18368, @charvalue
1042                  return (1)
1043              end
1044          end
1045          else
1046          if @realoption = "multipath distribution model"
1047          begin
1048              /*
1049              ** if 'multipath distribution type' is true we need to check:
1050              ** 	1) is 'multithread rep agent' true? warn otherwise
1051              ** 	2) are there bindings? if type is 'connection', 
1052              **         warn they will be ignored.
1053              */
1054              if (@charvalue is NOT NULL)
1055              begin
1056                  select @charvalue = lower(@charvalue)
1057                  /*
1058                  ** ensure the distribution type is valid
1059                  */
1060                  if NOT (@charvalue in (select distribution
1061                              from #mrp_supported_bindings))
1062                  begin
1063                      /*
1064                      ** The parameter value '%1!' is invalid.
1065                      */
1066                      raiserror 18291, @charvalue
1067                      return (1)
1068                  end
1069  
1070                  /*
1071                  ** If we are changing the distribution model to
1072                  ** filter we must be in multiple scanners. At this
1073                  ** point we only need to raise a warning.
1074                  */
1075                  if (@charvalue = "filter")
1076                  begin
1077                      select @multiple_scanners =
1078                          convert(varchar(5),
1079                          rep_agent_config(@dbid,
1080                              "current config",
1081                              "multiple scanners"))
1082  
1083                      if (@multiple_scanners = "false")
1084                      begin
1085                          /*
1086                          ** Continue, but raise a warning!
1087                          **
1088                          ** WARNING: The 'filter' distribution model 
1089                          ** requires multiple scanners to be configured
1090                          ** ('multiple scanners' = true).  
1091                          */
1092                          exec sp_getmessage 18386, @multithread_warning output
1093                          print "%1!", @multithread_warning
1094                      end
1095                  end
1096  
1097                  /*
1098                  ** Raise a warning if there are bindings of  
1099                  ** types other than specified already defined
1100                  ** in sysattributes - this is only a warning,
1101                  ** but these bindings will be ignored when
1102                  ** Rep Agent starts.
1103                  */
1104                  if ((select count(*) from sysattributes
1105                              where class = @mrp_class and attribute in
1106                                      (select attribute from #mrp_supported_bindings
1107                                      where distribution != @charvalue)) > 0)
1108                  begin
1109                      /*
1110                      ** Warning: There are existing bindings
1111                      ** that will be ignored while the '%1!'
1112                      ** property is '%2!.
1113                      */
1114                      raiserror 18701, @realoption, @charvalue
1115                  end
1116              end
1117          end
1118          else
1119          if @realoption = "data limits filter mode"
1120          begin
1121              /* Special case check for legal filter modes. */
1122              select @charvalue = lower(@charvalue)
1123              if not (@charvalue in ('off', 'stop', 'truncate', 'skip'))
1124              begin
1125                  raiserror 18896, @charvalue
1126                  return (1)
1127              end
1128          end
1129          else
1130          if @realoption = "cluster instance name" and
1131              lower(@charvalue) = 'coordinator'
1132          begin
1133              select @charvalue = lower(@charvalue)
1134          end
1135          else
1136          if @realoption = "stream mode"
1137          begin
1138              select @charvalue = lower(@charvalue)
1139              if not (@charvalue in ('async', 'near sync', 'sync'))
1140              begin
1141                  /*
1142                  ** The parameter value '%1!' is invalid.
1143                  */
1144                  raiserror 18291, @charvalue
1145                  return (1)
1146              end
1147          end
1148          else
1149          if @realoption = "trace log file"
1150          begin
1151              if (@charvalue is NOT NULL)
1152              begin
1153                  /*
1154                  ** The output to a trace file can be
1155                  ** unset using the value 'none'. This
1156                  ** is however not stored as such because
1157                  ** the logic will assume this is a valid
1158                  ** filename. We set the actual value
1159                  ** to NULL.
1160                  */
1161                  select @charvalue = lower(@charvalue)
1162                  if (@charvalue = "none")
1163                  begin
1164                      select @charvalue = NULL
1165                  end
1166              end
1167          end
1168          else
1169          if @realoption = "rs servername"
1170          begin
1171              /* Check RS name length. */
1172              select @maxlen = length from master.dbo.syscolumns
1173              where id = object_id("master.dbo.sysservers")
1174                  and name = "srvnetname"
1175  
1176              if (datalength(@charvalue) > @maxlen)
1177              begin
1178                  /*
1179                  ** 17240, "'%1!' is not a valid name."
1180                  */
1181                  raiserror 17240, @charvalue
1182                  return (1)
1183              end
1184          end
1185  
1186          /* 
1187          ** If we are not configuring the trace flags then figure out whether
1188          ** or not we need to insert a row or update in sysattributes.
1189          */
1190          if ((@realoption != "traceon") AND (@realoption != "traceoff"))
1191          begin
1192              select @oldvalue = int_value
1193              from sysattributes where class = @class
1194                  and attribute = @attrib_id
1195                  and object_type = "RA"
1196                  and object_cinfo = @attrname
1197  
1198              set @rows_found = @@rowcount
1199          end
1200          else
1201          begin
1202              /*
1203              ** We need one hundred bits for the full range of trace flags.
1204              ** We don't really have a convenient place to handle this all
1205              ** in one piece so we store the traces in pieces across the 
1206              ** int_value (bits 0-30) and the charvalue (bits 31-99).    
1207              **
1208              ** Get the current value for each column (defaults to zeroes  
1209              ** if the column is NULL).
1210              */
1211  
1212              select @trc_low = isnull(int_value, 0),
1213                  @trc_high = isnull(char_value, "000000000000000000000000")
1214              from sysattributes where class = @class
1215                  and attribute = @attrib_id
1216                  and object_type = "RA"
1217                  and object_cinfo = @attrname
1218  
1219              set @rows_found = @@rowcount
1220  
1221              if (@rows_found = 0)
1222              begin
1223                  select @trc_low = 0
1224                  select @trc_high = "000000000000000000000000" /* default trace values 31-99 */
1225              end
1226  
1227              select @trc_char_lohi = substring(@trc_high, 17, 24)
1228              select @trc_char_hilo = substring(@trc_high, 9, 16)
1229              select @trc_char_hihi = substring(@trc_high, 1, 8)
1230  
1231              if @intvalue between 9200 and 9230
1232              begin
1233                  select @traceoffset = 9200
1234                  select @oldvalue = @trc_low
1235              end
1236              else if @intvalue between 9231 and 9261
1237              begin
1238                  select @traceoffset = 9231
1239                  select @oldvalue = hextoint(@trc_char_lohi)
1240              end
1241              else if @intvalue between 9262 and 9292
1242              begin
1243                  select @traceoffset = 9262
1244                  select @oldvalue = hextoint(@trc_char_hilo)
1245              end
1246              else if @intvalue between 9293 and 9299
1247              begin
1248                  select @traceoffset = 9293
1249                  select @oldvalue = hextoint(@trc_char_hihi)
1250              end
1251          end
1252  
1253          if (@rows_found != 0)
1254          begin
1255              if ((@realoption = 'cluster instance name') and
1256                      (@charvalue = 'coordinator'))
1257              begin
1258                  select @action = 3 /* ATTR_DROP */
1259              end
1260              else
1261              begin
1262                  select @action = 2 /* ATTR_CHANGE */
1263              end
1264          end
1265          else
1266          begin
1267              select @action = 1 /* ATTR_ADD */
1268              select @oldvalue = 0
1269          end
1270  
1271          /* 
1272          ** If traceoff is the operation, then there should have been an
1273          ** entry in sysattributes. 
1274          */
1275          if (@realoption = "traceoff" and @action = 1)
1276          begin
1277              /* 18430, "Replication Agent configuration changed for database '%1!'." */
1278              exec sp_getmessage 18430, @msg output
1279              print @msg, @dbname
1280              return (0)
1281          end
1282  
1283          if (@attrname = "rs password")
1284          begin
1285              if (@rs_encpwd is NULL)
1286              begin
1287                  /* 
1288                  ** The rs password (@configvalue) needs to be 
1289                  ** encrypted.
1290                  */
1291                  select @rs_encpwd = internal_encrypt(@configvalue,
1292                          @stakey, 0)
1293  
1294                  if (@rs_encpwd is NULL)
1295                  begin
1296                      /*
1297                      ** 17067 "Unable to encrypt password for '%1!'.
1298                      ** See prior error message for reason."
1299                      */
1300                      raiserror 17067, @dbname
1301                      return (1)
1302                  end
1303  
1304                  select @configvalue = NULL
1305              end
1306  
1307              select @charvalue = @rs_encpwd
1308          end
1309  
1310          begin transaction rs_logexec
1311  
1312          if attrib_valid(@class, @attrib_id, 'RA', @dbid, NULL, NULL, NULL,
1313                  @attrname, @intvalue, @charvalue, NULL, NULL, NULL, @action) = 0
1314          begin
1315              rollback transaction rs_logexec
1316  
1317              /* 18431, "Failed to configure the 
1318              ** Replication Agent for database '%1!'." 
1319              */
1320              raiserror 18431, @dbname
1321              return (1)
1322          end
1323  
1324          /* If this is for trace flags, figure out what to set */
1325          if @attrname = "trace flags"
1326          begin
1327              select @tracenum = @intvalue
1328              if @realoption = "traceon"
1329              begin
1330                  select @intvalue = @oldvalue |
1331                      (power(2, (@tracenum - @traceoffset)))
1332              end
1333              else
1334              begin
1335                  select @intvalue = @oldvalue &
1336                      (~ power(2, (@tracenum - @traceoffset)))
1337              end
1338  
1339              if @traceoffset = 9231
1340              begin
1341                  select @trc_char_lohi = inttohex(@intvalue)
1342              end
1343              else if @traceoffset = 9262
1344              begin
1345                  select @trc_char_hilo = inttohex(@intvalue)
1346              end
1347              else if @traceoffset = 9293
1348              begin
1349                  select @trc_char_hihi = inttohex(@intvalue)
1350              end
1351  
1352              /*
1353              ** Update and insert to sysattributes use both @charvalue and @intvalue
1354              ** when changing trace flags. Only one field can be changed at one time.
1355              */
1356              if @traceoffset = 9200
1357              begin
1358                  select @charvalue = @trc_high
1359              end
1360              else
1361              begin
1362                  select @intvalue = @trc_low
1363                  select @charvalue = @trc_char_hihi || @trc_char_hilo || @trc_char_lohi
1364              end
1365          end
1366  
1367          /* 
1368          ** For the RS credential attributes  the insert/update 
1369          ** in sysattributes is done by attrib_notify.
1370          ** Beginning with 15.7 the object_info1 field is required for
1371          ** all rows. For configuration values manipulated by this proc
1372          ** the value will always be 0 for the default path, the MRP 
1373          ** specific sp_replication_path proc handles non-default rows
1374          */
1375          if @attrname not in ("rs servername", "rs username", "rs password")
1376          begin
1377              if (@action = 2) /* ATTR_CHANGE */
1378              begin
1379                  update sysattributes
1380                  set char_value = @charvalue,
1381                      int_value = @intvalue
1382                  where class = @class
1383                      and attribute = @attrib_id
1384                      and object_type = "RA"
1385                      and object_cinfo = @attrname
1386                      and object_info1 = 0
1387                  /*
1388                  ** If there was an error, @@error will be non-zero
1389                  */
1390                  if @@error != 0
1391                  begin
1392                      if @@trancount != 0
1393                          rollback transaction rs_logexec
1394                      /* 18431, "Failed to configure the 
1395                      ** Replication Agent for database '%1!'." 
1396                      */
1397                      raiserror 18431, @dbname
1398                      return (1)
1399                  end
1400              end
1401              else
1402              if (@action = 3) /* DROP attribute */
1403              begin
1404                  delete from sysattributes
1405                  where class = @class
1406                      and attribute = @attrib_id
1407                      and object_type = "RA"
1408                      and object_cinfo = @attrname
1409                      and object_info1 = 0
1410              end
1411              else /* ADD attribute */
1412              begin
1413  
1414                  insert into sysattributes(class, attribute, object_type,
1415                      object, object_cinfo, object_info1, int_value, char_value)
1416                  values (@class, @attrib_id, "RA", 0, @attrname, 0,
1417                      @intvalue, @charvalue)
1418  
1419                  /*
1420                  ** If there was an error, @@error will be non-zero
1421                  */
1422                  if @@error != 0
1423                  begin
1424                      if @@trancount != 0
1425                          rollback transaction rs_logexec
1426                      /* 18431, "Failed to configure the 
1427                      ** Replication Agent for database '%1!'." 
1428                      */
1429                      raiserror 18431, @dbname
1430                      return (1)
1431                  end
1432              end
1433  
1434          end
1435  
1436          /* Notify */
1437          if attrib_notify(@class, @attrib_id, "RA", @dbid, NULL, NULL, NULL,
1438                  @attrname, @intvalue, @charvalue, NULL, NULL, NULL, @action) = 0
1439          /* Unable to notify ? */
1440          begin
1441              rollback transaction rs_logexec
1442  
1443              /* 18431, "Failed to configure the 
1444              ** Replication Agent for database '%1!'." 
1445              */
1446              raiserror 18431, @dbname
1447              return (1)
1448          end
1449  
1450          /*
1451          ** Write the log record to replicate this invocation 
1452          ** of the stored procedure.
1453          */
1454          if (logexec(@dbid) != 1)
1455          begin
1456              /*
1457              ** 17756, "The execution of the stored procedure '%1!'
1458              ** 	   in database '%2!' was aborted because there
1459              ** 	   was an error in writing the replication log
1460              **	   record."
1461              */
1462              select @curdbname = db_name()
1463              raiserror 17756, "sp_config_rep_agent", @curdbname
1464  
1465              rollback transaction rs_logexec
1466              return (1)
1467          end
1468  
1469          commit tran
1470          /* If the attribute is visible */
1471          if @hidden = 0
1472          begin
1473              /* 'select into' the configuration information into a temp table. */
1474              select "Parameter_Name" = @attrname,
1475                  "Default_Value" = rep_agent_config(@dbid, "default config", @attrname),
1476                  "Config_Value" = rep_agent_config(@dbid, "current config", @attrname),
1477                  "Run_Value" = rep_agent_config(@dbid, "config", @attrname)
1478              into #config_rep_agent_rs
1479  
1480              /* Output and format the content of the	temp table. */
1481              exec sp_autoformat #config_rep_agent_rs
1482  
1483              /* drop the temp table */
1484              drop table #config_rep_agent_rs
1485  
1486          end
1487          if @in_context = 0
1488          begin
1489              if @dynamic = 0
1490              begin
1491                  /* 18432, "Replication Agent configuration changed for database '%1!'.
1492                  ** The changes will take effect the next time the Replication Agent 
1493                  ** thread is started."
1494                  */
1495                  exec sp_getmessage 18432, @msg output
1496                  print @msg, @dbname
1497              end
1498              else
1499              begin
1500                  /* 18430, "Replication Agent configuration changed for database '%1!'." */
1501                  exec sp_getmessage 18430, @msg output
1502                  print @msg, @dbname
1503              end
1504          end
1505          else
1506          begin
1507              /*
1508              ** If the attribute is not active in the current context
1509              ** retrieve the controlling context (@in_context is the
1510              ** attribute id of the control) and indicate whether the
1511              ** controlling attribute needs to be enabled or disabled 
1512              ** for the attribute to be used.
1513              */
1514              select @controlling_attr = optionname
1515              from #rep_ag_options
1516              where attrib_id = abs(@in_context)
1517  
1518              if (@in_context > 0)
1519              begin
1520                  select @control = 'enabled'
1521              end
1522              else
1523              begin
1524                  select @control = 'disabled'
1525              end
1526              /*
1527              ** 17171, "The Replication Agent configuration property '%1!'
1528              ** is changed for database '%2!'. This property is not
1529              ** currently active, the change will take effect the next
1530              ** time the Replication Agent is started with the '%3!'
1531              ** property %4!."
1532              */
1533              exec sp_getmessage 17171, @msg output
1534              print @msg, @attrname, @dbname, @controlling_attr, @control
1535          end
1536          return (0)
1537  
1538      end
1539  
1540      return (0)
1541  


exec sp_procxmode 'sp_config_rep_agent', 'AnyMode'
go

Grant Execute on sp_config_rep_agent to public
go
RESULT SETS
sp_config_rep_agent_rset_003
sp_config_rep_agent_rset_002
sp_config_rep_agent_rset_001

DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 1310
 MCTR 4 Conditional Begin Tran or Commit Tran 1469
 MINU 4 Unique Index with nullable columns master..sysmessages master..sysmessages
 MINU 4 Unique Index with nullable columns sybsystemprocs..sysattributes sybsystemprocs..sysattributes
 MTYP 4 Assignment type mismatch attribute: smallint = int 1416
 MTYP 4 Assignment type mismatch class: smallint = int 1416
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 582
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 605
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 631
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 847
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: parameter # 1 1481
 QCSC 4 Costly 'select count()', use 'exists()' 1104
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
170
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 161
 QTYP 4 Comparison type mismatch smallint = int 161
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 326
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 949
 QTYP 4 Comparison type mismatch smallint = int 949
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1105
 QTYP 4 Comparison type mismatch smallint = int 1105
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1193
 QTYP 4 Comparison type mismatch smallint = int 1193
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1194
 QTYP 4 Comparison type mismatch smallint = int 1194
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1214
 QTYP 4 Comparison type mismatch smallint = int 1214
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1215
 QTYP 4 Comparison type mismatch smallint = int 1215
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1382
 QTYP 4 Comparison type mismatch smallint = int 1382
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1383
 QTYP 4 Comparison type mismatch smallint = int 1383
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1405
 QTYP 4 Comparison type mismatch smallint = int 1405
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 1406
 QTYP 4 Comparison type mismatch smallint = int 1406
 TNOU 4 Table with no unique index master..spt_values master..spt_values
 MAW1 3 Warning message on %name% master..syscolumns.id: Warning message on syscolumns 703
 MAW1 3 Warning message on %name% master..syscolumns.id: Warning message on syscolumns 1173
 MGTP 3 Grant to public master..spt_values  
 MGTP 3 Grant to public master..syscolumns  
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public master..sysmessages  
 MGTP 3 Grant to public sybsystemprocs..sp_config_rep_agent  
 MGTP 3 Grant to public sybsystemprocs..sysattributes  
 MNER 3 No Error Check should check return value of exec 150
 MNER 3 No Error Check should check return value of exec 152
 MNER 3 No Error Check should check return value of exec 225
 MNER 3 No Error Check should check @@error after insert 353
 MNER 3 No Error Check should check @@error after insert 354
 MNER 3 No Error Check should check @@error after insert 355
 MNER 3 No Error Check should check @@error after insert 382
 MNER 3 No Error Check should check @@error after insert 384
 MNER 3 No Error Check should check @@error after insert 386
 MNER 3 No Error Check should check @@error after insert 387
 MNER 3 No Error Check should check @@error after insert 388
 MNER 3 No Error Check should check @@error after insert 389
 MNER 3 No Error Check should check @@error after insert 390
 MNER 3 No Error Check should check @@error after insert 391
 MNER 3 No Error Check should check @@error after insert 392
 MNER 3 No Error Check should check @@error after insert 393
 MNER 3 No Error Check should check @@error after insert 394
 MNER 3 No Error Check should check @@error after insert 395
 MNER 3 No Error Check should check @@error after insert 396
 MNER 3 No Error Check should check @@error after insert 397
 MNER 3 No Error Check should check @@error after insert 398
 MNER 3 No Error Check should check @@error after insert 399
 MNER 3 No Error Check should check @@error after insert 400
 MNER 3 No Error Check should check @@error after insert 401
 MNER 3 No Error Check should check @@error after insert 402
 MNER 3 No Error Check should check @@error after insert 403
 MNER 3 No Error Check should check @@error after insert 404
 MNER 3 No Error Check should check @@error after insert 405
 MNER 3 No Error Check should check @@error after insert 406
 MNER 3 No Error Check should check @@error after insert 407
 MNER 3 No Error Check should check @@error after insert 408
 MNER 3 No Error Check should check @@error after insert 409
 MNER 3 No Error Check should check @@error after insert 410
 MNER 3 No Error Check should check @@error after insert 411
 MNER 3 No Error Check should check @@error after insert 412
 MNER 3 No Error Check should check @@error after insert 413
 MNER 3 No Error Check should check @@error after insert 414
 MNER 3 No Error Check should check @@error after insert 415
 MNER 3 No Error Check should check @@error after insert 416
 MNER 3 No Error Check should check @@error after insert 417
 MNER 3 No Error Check should check @@error after insert 418
 MNER 3 No Error Check should check @@error after insert 419
 MNER 3 No Error Check should check @@error after insert 420
 MNER 3 No Error Check should check @@error after insert 421
 MNER 3 No Error Check should check @@error after insert 422
 MNER 3 No Error Check should check @@error after insert 423
 MNER 3 No Error Check should check @@error after insert 424
 MNER 3 No Error Check should check @@error after insert 425
 MNER 3 No Error Check should check @@error after insert 426
 MNER 3 No Error Check should check @@error after insert 427
 MNER 3 No Error Check should check @@error after insert 428
 MNER 3 No Error Check should check @@error after insert 429
 MNER 3 No Error Check should check @@error after insert 430
 MNER 3 No Error Check should check @@error after insert 431
 MNER 3 No Error Check should check @@error after insert 432
 MNER 3 No Error Check should check @@error after insert 433
 MNER 3 No Error Check should check @@error after insert 435
 MNER 3 No Error Check should check @@error after insert 442
 MNER 3 No Error Check should check @@error after insert 445
 MNER 3 No Error Check should check @@error after insert 446
 MNER 3 No Error Check should check @@error after insert 447
 MNER 3 No Error Check should check @@error after insert 448
 MNER 3 No Error Check should check @@error after insert 449
 MNER 3 No Error Check should check @@error after insert 450
 MNER 3 No Error Check should check @@error after select into 565
 MNER 3 No Error Check should check @@error after insert 576
 MNER 3 No Error Check should check return value of exec 582
 MNER 3 No Error Check should check @@error after select into 595
 MNER 3 No Error Check should check return value of exec 605
 MNER 3 No Error Check should check @@error after select into 624
 MNER 3 No Error Check should check return value of exec 631
 MNER 3 No Error Check should check return value of exec 726
 MNER 3 No Error Check should check return value of exec 779
 MNER 3 No Error Check should check return value of exec 789
 MNER 3 No Error Check should check @@error after select into 840
 MNER 3 No Error Check should check return value of exec 847
 MNER 3 No Error Check should check return value of exec 956
 MNER 3 No Error Check should check return value of exec 975
 MNER 3 No Error Check should check return value of exec 1002
 MNER 3 No Error Check should check return value of exec 1029
 MNER 3 No Error Check should check return value of exec 1092
 MNER 3 No Error Check should check return value of exec 1278
 MNER 3 No Error Check should check @@error after delete 1404
 MNER 3 No Error Check should check @@error after select into 1474
 MNER 3 No Error Check should check return value of exec 1481
 MNER 3 No Error Check should check return value of exec 1495
 MNER 3 No Error Check should check return value of exec 1501
 MNER 3 No Error Check should check return value of exec 1533
 MUCO 3 Useless Code Useless Brackets 137
 MUCO 3 Useless Code Useless Brackets 175
 MUCO 3 Useless Code Useless Brackets 193
 MUCO 3 Useless Code Useless Brackets 203
 MUCO 3 Useless Code Useless Brackets 208
 MUCO 3 Useless Code Useless Brackets 231
 MUCO 3 Useless Code Useless Brackets 241
 MUCO 3 Useless Code Useless Brackets 258
 MUCO 3 Useless Code Useless Brackets 263
 MUCO 3 Useless Code Useless Brackets 265
 MUCO 3 Useless Code Useless Brackets 271
 MUCO 3 Useless Code Useless Brackets 279
 MUCO 3 Useless Code Useless Brackets 285
 MUCO 3 Useless Code Useless Brackets 294
 MUCO 3 Useless Code Useless Brackets 302
 MUCO 3 Useless Code Useless Brackets 305
 MUCO 3 Useless Code Useless Brackets 320
 MUCO 3 Useless Code Useless Brackets 329
 MUCO 3 Useless Code Useless Brackets 470
 MUCO 3 Useless Code Useless Brackets 493
 MUCO 3 Useless Code Useless Brackets 538
 MUCO 3 Useless Code Useless Brackets 554
 MUCO 3 Useless Code Useless Brackets 601
 MUCO 3 Useless Code Useless Brackets 611
 MUCO 3 Useless Code Useless Brackets 636
 MUCO 3 Useless Code Useless Brackets 649
 MUCO 3 Useless Code Useless Brackets 665
 MUCO 3 Useless Code Useless Brackets 667
 MUCO 3 Useless Code Useless Brackets 677
 MUCO 3 Useless Code Useless Brackets 680
 MUCO 3 Useless Code Useless Brackets 688
 MUCO 3 Useless Code Useless Brackets 695
 MUCO 3 Useless Code Useless Brackets 705
 MUCO 3 Useless Code Useless Brackets 711
 MUCO 3 Useless Code Useless Brackets 714
 MUCO 3 Useless Code Useless Brackets 719
 MUCO 3 Useless Code Useless Brackets 728
 MUCO 3 Useless Code Useless Brackets 739
 MUCO 3 Useless Code Useless Brackets 744
 MUCO 3 Useless Code Useless Brackets 748
 MUCO 3 Useless Code Useless Brackets 761
 MUCO 3 Useless Code Useless Brackets 765
 MUCO 3 Useless Code Useless Brackets 771
 MUCO 3 Useless Code Useless Brackets 781
 MUCO 3 Useless Code Useless Brackets 791
 MUCO 3 Useless Code Useless Brackets 805
 MUCO 3 Useless Code Useless Brackets 815
 MUCO 3 Useless Code Useless Brackets 817
 MUCO 3 Useless Code Useless Brackets 821
 MUCO 3 Useless Code Useless Brackets 833
 MUCO 3 Useless Code Useless Brackets 837
 MUCO 3 Useless Code Useless Brackets 864
 MUCO 3 Useless Code Useless Brackets 874
 MUCO 3 Useless Code Useless Brackets 880
 MUCO 3 Useless Code Useless Brackets 884
 MUCO 3 Useless Code Useless Brackets 896
 MUCO 3 Useless Code Useless Brackets 919
 MUCO 3 Useless Code Useless Brackets 942
 MUCO 3 Useless Code Useless Brackets 954
 MUCO 3 Useless Code Useless Brackets 962
 MUCO 3 Useless Code Useless Brackets 1020
 MUCO 3 Useless Code Useless Brackets 1042
 MUCO 3 Useless Code Useless Brackets 1054
 MUCO 3 Useless Code Useless Brackets 1067
 MUCO 3 Useless Code Useless Brackets 1075
 MUCO 3 Useless Code Useless Brackets 1083
 MUCO 3 Useless Code Useless Brackets 1104
 MUCO 3 Useless Code Useless Brackets 1126
 MUCO 3 Useless Code Useless Brackets 1145
 MUCO 3 Useless Code Useless Brackets 1151
 MUCO 3 Useless Code Useless Brackets 1162
 MUCO 3 Useless Code Useless Brackets 1176
 MUCO 3 Useless Code Useless Brackets 1182
 MUCO 3 Useless Code Useless Brackets 1190
 MUCO 3 Useless Code Useless Brackets 1221
 MUCO 3 Useless Code Useless Brackets 1253
 MUCO 3 Useless Code Useless Brackets 1255
 MUCO 3 Useless Code Useless Brackets 1275
 MUCO 3 Useless Code Useless Brackets 1280
 MUCO 3 Useless Code Useless Brackets 1283
 MUCO 3 Useless Code Useless Brackets 1285
 MUCO 3 Useless Code Useless Brackets 1294
 MUCO 3 Useless Code Useless Brackets 1301
 MUCO 3 Useless Code Useless Brackets 1321
 MUCO 3 Useless Code Useless Brackets 1331
 MUCO 3 Useless Code Useless Brackets 1336
 MUCO 3 Useless Code Useless Brackets 1377
 MUCO 3 Useless Code Useless Brackets 1398
 MUCO 3 Useless Code Useless Brackets 1402
 MUCO 3 Useless Code Useless Brackets 1430
 MUCO 3 Useless Code Useless Brackets 1447
 MUCO 3 Useless Code Useless Brackets 1454
 MUCO 3 Useless Code Useless Brackets 1466
 MUCO 3 Useless Code Useless Brackets 1518
 MUCO 3 Useless Code Useless Brackets 1536
 MUCO 3 Useless Code Useless Brackets 1540
 MUIN 3 Column created using implicit nullability 378
 QAFM 3 Var Assignment from potentially many rows 168
 QAFM 3 Var Assignment from potentially many rows 476
 QAFM 3 Var Assignment from potentially many rows 702
 QAFM 3 Var Assignment from potentially many rows 1172
 QAFM 3 Var Assignment from potentially many rows 1192
 QAFM 3 Var Assignment from potentially many rows 1212
 QAFM 3 Var Assignment from potentially many rows 1514
 QCRS 3 Conditional Result Set 318
 QCRS 3 Conditional Result Set 463
 QCRS 3 Conditional Result Set 486
 QCTC 3 Conditional Table Creation 565
 QCTC 3 Conditional Table Creation 595
 QCTC 3 Conditional Table Creation 624
 QCTC 3 Conditional Table Creation 840
 QCTC 3 Conditional Table Creation 1474
 QISO 3 Set isolation level 144
 QIWC 3 Insert with not all columns specified missing 7 columns out of 15 1414
 QJWT 3 Join or Sarg Without Index on temp table 1105
 QPNC 3 No column in condition 573
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysmessages.ncsysmessages unique
(error, dlevel, langid)
Intersection: {error, langid}
159
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
703
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class, attribute}
949
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {class}
1105
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
1173
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
1193
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
1214
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_info1, object_type, object_cinfo, attribute, class}
1382
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_info1, object_type, object_cinfo, attribute, class}
1405
 VNRD 3 Variable is not read @sptlang 162
 VNRD 3 Variable is not read @procval 266
 VNRD 3 Variable is not read @dummy 306
 VNRD 3 Variable is not read @configvalue 1304
 MRST 2 Result Set Marker 318
 MRST 2 Result Set Marker 463
 MRST 2 Result Set Marker 486
 MSUB 2 Subquery Marker 158
 MSUB 2 Subquery Marker 1104
 MSUB 2 Subquery Marker 1106
 MTR1 2 Metrics: Comments Ratio Comments: 43% 38
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 118 = 161dec - 45exi + 2 38
 MTR3 2 Metrics: Query Complexity Complexity: 746 38

DATA PROPAGATION detailed
ColumnWritten To
@configvaluesysattributes.int_value   °.char_value   sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference
@rs_encpwdsysattributes.int_value   °.char_value   sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference
@rs_passwordsysattributes.int_value   °.char_value   sp_passwordpolicy_rset_002.value sp_passwordpolicy_rset_003.value sp_passwordpolicy_rset_004.Policy_option sp_ssladmin_rset_001.certificate_path sp_ssladmin_rset_002.Cipher Suite Name °.Preference

DEPENDENCIES
PROCS AND TABLES USED
read_writes table tempdb..#mrp_supported_bindings (1) 
writes table tempdb..#config_rep_agent_cc (1) 
writes table sybsystemprocs..sp_config_rep_agent_rset_001 
reads table master..sysmessages (1)  
writes table sybsystemprocs..sp_config_rep_agent_rset_003 
writes table sybsystemprocs..sp_config_rep_agent_rset_002 
reads table master..sysdatabases (1)  
writes table tempdb..#config_rep_agent_someone (1) 
calls proc sybsystemprocs..sp_getmessage  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
reads table master..spt_values (1)  
reads table master..syscolumns (1)  
read_writes table tempdb..#rep_ag_options (1) 
writes table tempdb..#config_rep_agent_rs (1) 
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)  
writes table tempdb..#config_rep_agent_ha (1) 
calls proc sybsystemprocs..sp_autoformat  
   writes table sybsystemprocs..sp_autoformat_rset_001 
   writes table sybsystemprocs..sp_autoformat_rset_002 
   writes table sybsystemprocs..sp_autoformat_rset_005 
   calls proc sybsystemprocs..sp_namecrack  
   reads table master..syscolumns (1)  
   writes table sybsystemprocs..sp_autoformat_rset_004 
   read_writes table tempdb..#colinfo_af (1) 
   reads table tempdb..systypes (1)  
   reads table master..systypes (1)  
   calls proc sybsystemprocs..sp_autoformat  
   reads table tempdb..syscolumns (1)  
   writes table sybsystemprocs..sp_autoformat_rset_003 
read_writes table sybsystemprocs..sysattributes  
writes table tempdb..#config_rep_agent_all (1)