DatabaseProcApplicationCreatedLinks
sybsystemprocssp_hadr_admin  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** SP_HADR_ADMIN
4     ** This procedure is used to implement the Soft Quiesce mechanism for
5     ** HADR and also managing the local state of the server in the HADR
6     ** configuration.
7     **
8     */
9     
10    create or replace procedure sp_hadr_admin
11        @cmd varchar(255) = null, /* desired hadr admin command */
12        @arg1 varchar(255) = null,
13        @arg2 varchar(255) = null,
14        @arg3 varchar(255) = null,
15        @arg4 varchar(255) = null,
16        @arg5 varchar(255) = null,
17        @arg6 varchar(255) = null
18    as
19        declare @hadrmode int, /* Current HADR mode */
20            @hadrstate int, /* Current HADR State */
21            @retstat int, /* return value of executing a SQL */
22            @gp_enabled int, /* Save whether GP enabled or not */
23            @status int,
24            @hadrsuid int,
25            @hadrlogin varchar(255),
26            @nullarg char(1),
27            @dummy int,
28            @dbid int, /* Current Database id */
29            @srvstatus2 unsigned int,
30            @propagate int,
31            @srvstate varchar(32),
32            @sname varchar(255), /* server logical name */
33            @HADR_CLASS int, /* HADR class id */
34            @HADRMEMBER int,
35            @DRAIN_LABEL int, /* replication drain label attribute id */
36            @sysdbname varchar(30), /* sysdatabases.name */
37            @sysdbid int, /* sysdatabases.dbid */
38            @drain_status int, /* replication drain status */
39            @log_pages int, /* log pages to replicate */
40            @msg varchar(1024),
41            @total int,
42            @st datetime,
43            @eng int,
44            @time int,
45            @now datetime,
46            @kpi_enabled int,
47            @grp varchar(255), /* HADR group name */
48            @srvnetname varchar(255),
49            @srvid int,
50            @maxlen int
51    
52        declare tranc cursor for
53        select starttime from master..systransactions
54    
55    
56        /*
57        ** Disallow running sp_hadr_admin within a transaction since it might make
58        ** recovery impossible.
59        */
60        if @@trancount > 0
61        begin
62            /*
63            ** 17260, "Can't run %1! from within a transaction."
64            */
65            raiserror 17260, "sp_hadr_admin"
66            return (1)
67        end
68        else
69        begin
70            set chained off
71        end
72    
73        /* Initialize the defaults */
74        select @hadrmode = @@hadr_mode,
75            @hadrstate = @@hadr_state,
76            @retstat = 0,
77            @dbid = db_id(),
78            @propagate = 0,
79            @HADR_CLASS = 43,
80            @HADRMEMBER = 16,
81            @DRAIN_LABEL = 1,
82            @kpi_enabled = 0
83    
84        /* Make sure server is configured for HADR 
85        ** We make an exception for the 'init' command
86        ** so that HADR mode can be changed dynamically
87        ** in dbcc hadr_admin
88        */
89        if (@hadrmode = - 1 and not @cmd in ('init', 'config_bs'))
90        begin
91            /*
92            ** 17158, "Cannot run this command as %1! is not configured. 
93            ** A user with System Administrator (SA) role must reconfigure 
94            ** the system to enable %2!.
95            */
96    
97            raiserror 17158, "HADR", "HADR"
98            return (1)
99        end
100   
101       /*
102       ** Do execution checks
103       **
104       **	If granular permissions is not enabled then sa_role is required.
105       **	If granular permissions is enabled then the permission 'manage hadr'
106       **	is required.
107       **	Make sure that the procedure is executed from master database
108       */
109   
110       select @nullarg = NULL
111       execute @status = sp_aux_checkroleperm "sa_role", "manage hadr",
112           @nullarg, @gp_enabled output
113   
114       if (@gp_enabled = 0)
115       begin
116           if (proc_role("sa_role") = 0)
117               return (1)
118       end
119       else
120       begin
121           select @dummy = proc_auditperm("manage hadr", @status)
122       end
123   
124       if (@status != 0)
125           return (1)
126   
127       if (@@clustermode = "shared disk cluster")
128       begin
129           return (1)
130       end
131   
132       if (@dbid != 1)
133       begin
134           raiserror 18703, "sp_hadr_admin"
135           return (1)
136       end
137   
138       if (@cmd IS NULL or @cmd = 'help')
139       begin
140           /*
141           ** If procedure is invoked without any cmd,
142           ** just return the usage
143           */
144   
145           print "Usage: sp_hadr_admin command [,arguments]"
146           print ""
147           if @arg1 IS NULL or @arg1 = 'activate'
148               print "sp_hadr_admin activate"
149           if @arg1 IS NULL or @arg1 = 'deactivate'
150               print "sp_hadr_admin deactivate, timeout, 'label' [,{'force' | NULL}[,'nodrain']]"
151           if @arg1 IS NULL or @arg1 = 'cancel'
152               print "sp_hadr_admin cancel"
153           if @arg1 IS NULL or @arg1 = 'drain'
154               print "sp_hadr_admin drain, 'label'"
155           if @arg1 IS NULL or @arg1 = 'status'
156               print "sp_hadr_admin status [, 'label' [, dbname | all]]"
157           if @arg1 IS NULL or @arg1 = 'primary'
158               print "sp_hadr_admin primary, ['force']"
159           if @arg1 IS NULL or @arg1 = 'standby'
160               print "sp_hadr_admin standby"
161           if @arg1 IS NULL or @arg1 = 'init'
162               print "sp_hadr_admin init, 'groupname'[, 'local HADR name']"
163           if @arg1 IS NULL or @arg1 = 'map'
164               print "sp_hadr_admin map"
165           if @arg1 IS NULL or @arg1 = 'addserver'
166               print "sp_hadr_admin addserver, 'HADR name' [,{HADR netname|NULL} [,'nopropagate' [,status]]]]"
167           if @arg1 IS NULL or @arg1 = 'dropserver'
168               print "sp_hadr_admin dropserver, 'server'[, 'nopropagate']"
169           if @arg1 IS NULL or @arg1 = 'listserver'
170               print "sp_hadr_admin listserver"
171           if @arg1 IS NULL or @arg1 = 'propagate'
172               print "sp_hadr_admin propagate [,'standby list']"
173           if @arg1 IS NULL or @arg1 = 'failover_timeestimate'
174               print "sp_hadr_admin failover_timeestimate [standby server name]"
175           if @arg1 IS NULL or @arg1 = 'config_bs'
176               print "sp_hadr_admin 'config_bs', 'Backup Server host' | NULL, 'host to authorize'"
177   
178           return (0)
179       end
180   
181       select @srvstate = ""
182       if @hadrmode = 0
183           select @srvstate = @srvstate + "STANDBY"
184       else if @hadrmode = 1
185           select @srvstate = @srvstate + "PRIMARY"
186       else
187           select @srvstate = "UNKNOWN"
188   
189       if @hadrstate = 1
190           select @srvstate = @srvstate + " : ACTIVE"
191       else if @hadrstate = 2
192           select @srvstate = @srvstate + " : INACTIVE"
193       else if @hadrstate = 3
194           select @srvstate = @srvstate + " : DEACTIVATING"
195       else
196           select @srvstate = @srvstate + " : UNKNOWN"
197   
198       /* Verify the arguments to the procedure */
199       exec @retstat = sp_hadrvrfyargs @cmd, @arg1, @arg2, @arg3, @arg4, @arg5, @arg6, @srvstate
200   
201       if (@retstat != 0)
202           return (1)
203   
204       if (@cmd = "addserver")
205       begin
206           /* 
207           ** Append the lname with 'DR' to add a unique entry for
208           ** HADR_MEMBER class.
209           */
210           select @sname = @arg1 + 'DR'
211           select @srvnetname = @arg2
212           if @arg2 IS NULL
213               select @srvnetname = @arg1
214   
215   
216           /* check name */
217   
218           select @maxlen = length from master.dbo.syscolumns
219           where id = object_id("master.dbo.sysservers") and name = "srvname"
220   
221           if valid_name(@sname, @maxlen) = 0
222           begin
223               /*
224               ** 17240, "'" + @sname + "' is not a valid name." 
225               */
226               raiserror 17240, @sname
227               return (1)
228           end
229   
230           /* check net name */
231           select @maxlen = length from master.dbo.syscolumns
232           where id = object_id("master.dbo.sysservers") and name = "srvnetname"
233   
234           if (len(@srvnetname) > @maxlen)
235           begin
236               /*
237               ** 17240, "'" + @sname + "' is not a valid name." 
238               */
239               raiserror 17240, @srvnetname
240               return (1)
241           end
242   
243           /* check already exists */
244           if exists (select *
245                   from master.dbo.sysservers
246                   where srvname = @sname)
247   
248           begin
249               /*
250               ** 17290, "There is already a server named '%1!', physical name '%2!'."
251               */
252               raiserror 17290, @sname, "(any)"
253               return (1)
254           end
255   
256           /* generate server id */
257           select @srvid = isnull(max(srvid), 0) + 1
258           from master.dbo.sysservers where srvid != 999
259   
260           insert into master.dbo.sysservers
261           (srvid, srvstatus, srvname, srvnetname, srvclass, srvcost, srvstatus2)
262           values (@srvid, 0, @sname, @srvnetname, @HADRMEMBER, 0, 0)
263           if (@@error != 0)
264               return (1)
265   
266           if @arg3 = 'nopropagate'
267           begin
268               begin tran hadr_update_server
269               /* Update sysservers to indicate this is not propagated */
270               select @srvstatus2 = isnull(srvstatus2, 0) from master.dbo.sysservers
271               where srvname = @sname
272               update master.dbo.sysservers
273               set srvstatus2 = @srvstatus2 | 16
274               where srvname = @sname
275   
276               if (@@error != 0)
277               begin
278                   /* Cleanup and return */
279                   rollback tran hadr_update_server
280                   exec sp_dropserver @sname
281                   return (1)
282               end
283               commit tran hadr_update_server
284           end
285           else
286           begin
287               /* configuration is to be propagated */
288               select @propagate = 1
289           end
290       end
291       else
292       if (@cmd = "dropserver")
293       begin
294           select @sname = @arg1 + 'DR'
295   
296           begin tran hadr_update_server
297           /* Just mark for deletion without actually droping the server */
298           select @srvstatus2 = isnull(srvstatus2, 0) from master.dbo.sysservers
299           where srvname = @sname
300           update master.dbo.sysservers
301           set srvstatus2 = @srvstatus2 | 32
302           where srvname = @sname
303           if (@@error != 0)
304           begin
305               rollback tran hadr_update_server
306               return (1)
307           end
308   
309           commit tran hadr_update_server
310   
311           if @arg2 = 'nopropagate'
312           begin
313               /* Nothing to do, return Success */
314               goto success_return
315           end
316           else
317           begin
318               /* If propagate, then set the flag to actually drop the server */
319               select @propagate = 1
320           end
321       end
322       else
323       if (@cmd = "listserver")
324       begin
325           create table #spt_hadrserver
326           (
327               name varchar(32),
328               network varchar(255),
329           )
330           insert into #spt_hadrserver
331           select substring(s.srvname, 1, len(s.srvname) - 2), s.srvnetname
332           from master.dbo.sysservers s
333           where s.srvclass = 16 and s.srvstatus2 & 16 != 16
334   
335           exec sp_autoformat @fulltabname = #spt_hadrserver,
336               @selectlist = " name, 'network_name' = network",
337               @orderby = "order by name"
338   
339           /* Nothing to do for the listserver sub command, return from here */
340           return (0)
341       end
342       else
343       if (@cmd = "setlogin")
344       begin
345           select @hadrlogin = @arg1
346           select @hadrsuid = suid from master.dbo.syslogins where name = @hadrlogin
347           if (@hadrsuid is null)
348           begin
349               /* 17231, "No login with the specified name exists." */
350               raiserror 17231
351           end
352           else
353           begin
354               update master.dbo.sysservers set srvstatus2 = @hadrsuid where srvclass = 17
355           end
356           return 0
357       end
358       else
359       if (@cmd = "failover_timeestimate")
360       begin
361           select @now = getdate()
362           if not isnull(object_id('#FTETEMP'), 0) = 0
363               drop table #FTETEMP
364   
365           /* calculate transaction rollback times
366           ** use #FTETEMP to accumulate rollback time per engine
367           */
368           select engine, time = 0 into #FTETEMP from master..sysengines
369   
370           open tranc
371           fetch tranc into @st
372           while (@@sqlstatus = 0)
373           begin
374               select @time = datediff(minute, @st, @now)
375               select @eng = engine from #FTETEMP having time = min(time)
376               update #FTETEMP set time = time + @time where engine = @eng
377               fetch tranc into @st
378           end
379           close tranc
380   
381           select "total potential rollback time (mins)" = max(time) from #FTETEMP
382   
383           /* rep drain times */
384           select dbid,
385               "rep_drain_time" = rep_drain_time(dbid, rep_log_pages(dbid))
386           into #FTETEMP2
387           from master..sysdatabases
388           where is_rep_agent_enabled(dbid) = 1
389   
390           /* Adaptive Server has expanded all '*' elements in the following statement */ select #FTETEMP2.dbid, #FTETEMP2.rep_drain_time from #FTETEMP2
391           select "total potential rep drain time" = sum(rep_drain_time)
392           from #FTETEMP2
393           drop table #FTETEMP
394           drop table #FTETEMP2
395   
396       /* TBD: output repserver queue processing time goes here
397       ** this relies on RPC support from repserver and
398       ** cannot currently be implemented
399       */
400       end
401       else
402       if @cmd = 'propagate'
403       begin
404           select @propagate = 1
405       end
406   
407       if (@propagate = 1)
408       begin
409           begin tran hadr_server_update
410   
411           /* First drop the rows which has the drop status bit set */
412           delete master.dbo.sysservers
413           where srvclass = 16
414               and srvstatus2 & 32 = 32
415   
416           /* Clear the status bit for all newly added server */
417           update master.dbo.sysservers
418           set srvstatus2 = srvstatus2 & ~ 16
419           where srvclass = 16
420   
421           commit tran hadr_server_update
422       end
423   
424       if (@cmd = "status")
425       begin --{
426           /* If we have turned on TF2295, then measure KPI */
427           dbcc istraceon(2295)
428           if @@error != - 1
429           begin
430               select @kpi_enabled = 1
431               select @now = getdate()
432           end
433           /*
434           ** for deactivating print list of outstanding processes preventing deactivation
435           */
436           if @hadrstate = 3
437           begin --{
438               select "Number of user connections at start of deactivation" = hadr_deact_status(1)
439               select "Number of privileged user connections" = hadr_deact_status(2)
440               select "Number of user connections in tran" = hadr_deact_status(3)
441               select "Number of user connections in chained mode" = hadr_deact_status(4)
442               select "Number of user connections in unchained mode" = hadr_deact_status(5)
443               select "Number of user connections holding server side cursor" = hadr_deact_status(6)
444           end --}
445   
446           /* 
447           ** For Primary, print:
448           ** - the progress of the log replication drain of the HADR databases 
449           ** (for any HADR state)
450           */
451           if @hadrmode = 1
452           begin --{
453               create table #rep_progress(
454                   dbname varchar(30),
455                   drain_status varchar(20),
456                   log_pages int null)
457   
458               declare db_cursor cursor for
459               select name, dbid
460               from master.dbo.sysdatabases
461               where (is_rep_agent_enabled(dbid) != 0)
462   
463               open db_cursor
464               fetch db_cursor into @sysdbname, @sysdbid
465   
466               while (@@sqlstatus = 0)
467               begin --{
468                   select @drain_status = rep_drain_status(@sysdbid),
469                       @log_pages = rep_log_pages(@sysdbid)
470                   insert #rep_progress(dbname, drain_status, log_pages)
471                   select @sysdbname,
472                       case
473                           when (@drain_status = 1)
474                           then "inactive"
475                           when (@drain_status = 2)
476                           then "in progress"
477                           when (@drain_status = 3)
478                           then "completed"
479                           else "unavailable"
480                       end,
481                       @log_pages
482   
483                   fetch db_cursor into @sysdbname, @sysdbid
484               end --}
485   
486               close db_cursor
487               deallocate cursor db_cursor
488   
489               exec sp_autoformat @fulltabname = #rep_progress,
490                   @selectlist = " 'Database Name' = dbname, 'Log Drain Status' = drain_status, 'Log Pages Left' = log_pages",
491                   @orderby = "order by drain_status"
492   
493               drop table #rep_progress
494               if @kpi_enabled = 1
495                   select datediff(ms, @now, getdate()) as 'HADR_KPI for status (ms)'
496               return (0)
497           end --}
498   
499           /* For Standby, print the replication status of the HADR databases. */
500           if @hadrmode = 0
501           begin --{
502               create table #rep_status(
503                   dbname varchar(30),
504                   status varchar(20))
505   
506               declare db_cursor cursor for
507               select name
508               from master.dbo.sysdatabases
509               where (is_rep_agent_enabled(dbid) != 0)
510   
511               open db_cursor
512               fetch db_cursor into @sysdbname
513   
514               while (@@sqlstatus = 0)
515               begin --{
516                   execute ('insert #rep_status select ''' + @sysdbname +
517                   ''', case when (exists (select 1 from ' +
518                   @sysdbname + '.dbo.sysattributes 
519   				 where class = @HADR_CLASS and 
520   				 attribute = @DRAIN_LABEL and 
521   				 char_value = ''' + @arg1 + ''')) then ''completed'' 
522   				 else ''pending'' end')
523   
524                   fetch db_cursor into @sysdbname
525               end --}
526   
527               close db_cursor
528               deallocate cursor db_cursor
529   
530               exec sp_autoformat @fulltabname = #rep_status,
531                   @selectlist = " 'Database Name' = dbname, 'Replication Status' = status",
532                   @orderby = "order by status"
533   
534               drop table #rep_status
535   
536               if @kpi_enabled = 1
537                   select datediff(ms, @now, getdate()) as 'HADR_KPI for status (ms)'
538               return (0)
539           end --}
540   
541           /* For Primary in Active state, just print the server state */
542           if @hadrmode = 1 and @hadrstate = 1
543           begin
544               select "Server State: " + @srvstate
545               return (0)
546           end
547   
548           if @kpi_enabled = 1
549               select datediff(ms, @now, getdate()) as 'HADR_KPI for status (ms)'
550       end --}
551   
552       if @cmd = "dropgroup"
553       begin
554           if (select count(*) from master.dbo.sysservers where srvclass = 16) != 0
555           begin
556               print "You need to drop all HADR servers before issuing the dropgroup subcommand"
557               return (1)
558           end
559   
560           select @grp = srvname from master.dbo.sysservers where srvclass = 17
561   
562           if (@grp != @arg1)
563           begin
564               print "invalid HADR group"
565               return (1)
566           end
567   
568           begin tran hadr_dropgroup
569   
570           delete master.dbo.sysservers where srvname = @arg1
571           delete master.dbo.sysattributes where class = 43
572           if (@@error != 0)
573           begin
574               /* Cleanup and return */
575               rollback tran hadr_dropgroup
576               return (1)
577           end
578           commit tran hadr_dropgroup
579   
580           return (0)
581       end
582   
583   
584   
585       if @cmd != 'failover_timeestimate'
586       begin
587           dbcc hadr_admin(@cmd, @arg1, @arg2, @arg3, @arg4, @arg5, @arg6)
588   
589           if (@@error != 0)
590           begin
591               /* 19842, "'%1!' encountered an error and could not succeed." */
592               raiserror 19842, @cmd
593               return (1)
594           end
595       end
596   
597   success_return:
598   
599       /* 19538, "Command '%1!' successful." */
600       exec sp_getmessage 19538, @msg output
601       print @msg, @cmd
602   
603       return (0)
604   


exec sp_procxmode 'sp_hadr_admin', 'AnyMode'
go

Grant Execute on sp_hadr_admin to public
go
RESULT SETS
sp_hadr_admin_rset_009
sp_hadr_admin_rset_008
sp_hadr_admin_rset_007
sp_hadr_admin_rset_006
sp_hadr_admin_rset_005
sp_hadr_admin_rset_004
sp_hadr_admin_rset_003
sp_hadr_admin_rset_002
sp_hadr_admin_rset_001
sp_hadr_admin_rset_013
sp_hadr_admin_rset_012
sp_hadr_admin_rset_011
sp_hadr_admin_rset_010

DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 268
 MCTR 4 Conditional Begin Tran or Commit Tran 283
 MCTR 4 Conditional Begin Tran or Commit Tran 296
 MCTR 4 Conditional Begin Tran or Commit Tran 309
 MCTR 4 Conditional Begin Tran or Commit Tran 409
 MCTR 4 Conditional Begin Tran or Commit Tran 421
 MCTR 4 Conditional Begin Tran or Commit Tran 568
 MCTR 4 Conditional Begin Tran or Commit Tran 578
 MEST 4 Empty String will be replaced by Single Space 146
 MEST 4 Empty String will be replaced by Single Space 181
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MPSI 4 Possible SQL Injection @arg1 516
 MTYP 4 Assignment type mismatch srvclass: smallint = int 262
 MTYP 4 Assignment type mismatch srvid: smallint = int 262
 MTYP 4 Assignment type mismatch srvname: varchar(30) = varchar(255) 262
 MTYP 4 Assignment type mismatch srvstatus2: uint = int 354
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 335
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 489
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 530
 QCSC 4 Costly 'select count()', use 'exists()' 554
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 258
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 333
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 354
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 376
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 413
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 419
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 554
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 560
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 571
 TNOI 4 Table with no index master..sysengines master..sysengines
 TNOI 4 Table with no index master..systransactions master..systransactions
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause tranc 53
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause db_cursor 459
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause db_cursor 507
 MAW1 3 Warning message on %name% master..syscolumns.id: Warning message on syscolumns 219
 MAW1 3 Warning message on %name% master..syscolumns.id: Warning message on syscolumns 232
 MDYN 3 Proc uses Dynamic SQL but is not flagged with Dynamic Ownership Chain 10
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..syscolumns  
 MGTP 3 Grant to public master..sysdatabases  
 MGTP 3 Grant to public master..sysengines  
 MGTP 3 Grant to public master..syslogins  
 MGTP 3 Grant to public master..sysservers  
 MGTP 3 Grant to public master..systransactions  
 MGTP 3 Grant to public sybsystemprocs..sp_hadr_admin  
 MNER 3 No Error Check should check return value of exec 280
 MNER 3 No Error Check should check @@error after insert 330
 MNER 3 No Error Check should check return value of exec 335
 MNER 3 No Error Check should check @@error after update 354
 MNER 3 No Error Check should check @@error after select into 368
 MNER 3 No Error Check should check @@error after update 376
 MNER 3 No Error Check should check @@error after select into 384
 MNER 3 No Error Check should check @@error after delete 412
 MNER 3 No Error Check should check @@error after update 417
 MNER 3 No Error Check should check @@error after insert 470
 MNER 3 No Error Check should check return value of exec 489
 MNER 3 No Error Check should check return value of exec 530
 MNER 3 No Error Check should check @@error after delete 570
 MNER 3 No Error Check should check return value of exec 600
 MUCO 3 Useless Code Useless Brackets 66
 MUCO 3 Useless Code Useless Brackets 89
 MUCO 3 Useless Code Useless Brackets 98
 MUCO 3 Useless Code Useless Brackets 114
 MUCO 3 Useless Code Useless Brackets 116
 MUCO 3 Useless Code Useless Brackets 117
 MUCO 3 Useless Code Useless Brackets 124
 MUCO 3 Useless Code Useless Brackets 125
 MUCO 3 Useless Code Useless Brackets 127
 MUCO 3 Useless Code Useless Brackets 129
 MUCO 3 Useless Code Useless Brackets 132
 MUCO 3 Useless Code Useless Brackets 135
 MUCO 3 Useless Code Useless Brackets 138
 MUCO 3 Useless Code Useless Brackets 178
 MUCO 3 Useless Code Useless Brackets 201
 MUCO 3 Useless Code Useless Brackets 202
 MUCO 3 Useless Code Useless Brackets 204
 MUCO 3 Useless Code Useless Brackets 227
 MUCO 3 Useless Code Useless Brackets 234
 MUCO 3 Useless Code Useless Brackets 240
 MUCO 3 Useless Code Useless Brackets 253
 MUCO 3 Useless Code Useless Brackets 263
 MUCO 3 Useless Code Useless Brackets 264
 MUCO 3 Useless Code Useless Brackets 276
 MUCO 3 Useless Code Useless Brackets 281
 MUCO 3 Useless Code Useless Brackets 292
 MUCO 3 Useless Code Useless Brackets 303
 MUCO 3 Useless Code Useless Brackets 306
 MUCO 3 Useless Code Useless Brackets 323
 MUCO 3 Useless Code Useless Brackets 340
 MUCO 3 Useless Code Useless Brackets 343
 MUCO 3 Useless Code Useless Brackets 347
 MUCO 3 Useless Code Useless Brackets 359
 MUCO 3 Useless Code Useless Brackets 372
 MUCO 3 Useless Code Useless Brackets 407
 MUCO 3 Useless Code Useless Brackets 424
 MUCO 3 Useless Code Useless Brackets 461
 MUCO 3 Useless Code Useless Brackets 466
 MUCO 3 Useless Code Useless Brackets 473
 MUCO 3 Useless Code Useless Brackets 475
 MUCO 3 Useless Code Useless Brackets 477
 MUCO 3 Useless Code Useless Brackets 496
 MUCO 3 Useless Code Useless Brackets 509
 MUCO 3 Useless Code Useless Brackets 514
 MUCO 3 Useless Code Useless Brackets 538
 MUCO 3 Useless Code Useless Brackets 545
 MUCO 3 Useless Code Useless Brackets 557
 MUCO 3 Useless Code Useless Brackets 562
 MUCO 3 Useless Code Useless Brackets 565
 MUCO 3 Useless Code Useless Brackets 572
 MUCO 3 Useless Code Useless Brackets 576
 MUCO 3 Useless Code Useless Brackets 580
 MUCO 3 Useless Code Useless Brackets 589
 MUCO 3 Useless Code Useless Brackets 593
 MUCO 3 Useless Code Useless Brackets 603
 MUIN 3 Column created using implicit nullability 325
 MUIN 3 Column created using implicit nullability 453
 MUIN 3 Column created using implicit nullability 502
 MUOT 3 Updates outside transaction 354
 QAFM 3 Var Assignment from potentially many rows 218
 QAFM 3 Var Assignment from potentially many rows 231
 QAFM 3 Var Assignment from potentially many rows 375
 QAFM 3 Var Assignment from potentially many rows 560
 QCRS 3 Conditional Result Set 381
 QCRS 3 Conditional Result Set 390
 QCRS 3 Conditional Result Set 391
 QCRS 3 Conditional Result Set 438
 QCRS 3 Conditional Result Set 439
 QCRS 3 Conditional Result Set 440
 QCRS 3 Conditional Result Set 441
 QCRS 3 Conditional Result Set 442
 QCRS 3 Conditional Result Set 443
 QCRS 3 Conditional Result Set 495
 QCRS 3 Conditional Result Set 537
 QCRS 3 Conditional Result Set 544
 QCRS 3 Conditional Result Set 549
 QCTC 3 Conditional Table Creation 325
 QCTC 3 Conditional Table Creation 368
 QCTC 3 Conditional Table Creation 384
 QCTC 3 Conditional Table Creation 453
 QCTC 3 Conditional Table Creation 502
 QIWC 3 Insert with not all columns specified missing 2 columns out of 9 261
 QNAM 3 Select expression has no name "Server State: " + @srvstate 544
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
219
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
232
 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}
571
 VNRD 3 Variable is not read @HADR_CLASS 79
 VNRD 3 Variable is not read @DRAIN_LABEL 81
 VNRD 3 Variable is not read @dummy 121
 VUNU 3 Variable is not used @total 41
 CUPD 2 Updatable Cursor Marker (updatable by default) 53
 CUPD 2 Updatable Cursor Marker (updatable by default) 459
 CUPD 2 Updatable Cursor Marker (updatable by default) 507
 MDYS 2 Dynamic SQL Marker 516
 MRST 2 Result Set Marker 381
 MRST 2 Result Set Marker 390
 MRST 2 Result Set Marker 391
 MRST 2 Result Set Marker 438
 MRST 2 Result Set Marker 439
 MRST 2 Result Set Marker 440
 MRST 2 Result Set Marker 441
 MRST 2 Result Set Marker 442
 MRST 2 Result Set Marker 443
 MRST 2 Result Set Marker 495
 MRST 2 Result Set Marker 537
 MRST 2 Result Set Marker 544
 MRST 2 Result Set Marker 549
 MSUB 2 Subquery Marker 244
 MSUB 2 Subquery Marker 554
 MTR1 2 Metrics: Comments Ratio Comments: 20% 10
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 65 = 86dec - 23exi + 2 10
 MTR3 2 Metrics: Query Complexity Complexity: 374 10

DATA PROPAGATION detailed
ColumnWritten To
@arg1sysservers.srvname   °.srvnetname   sp_checknames_rset_006.remoteusername sp_checknames_rset_007.srvname sp_checkreswords_rset_001.Owner sp_checkreswords_rset_002.Table
@arg2sysservers.srvnetname   sp_checkreswords_rset_001.Owner

DEPENDENCIES
PROCS AND TABLES USED
writes table tempdb..#rep_progress (1) 
calls proc sybsystemprocs..sp_getmessage  
   reads table master..syslanguages (1)  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
   reads table sybsystemprocs..sysusermessages  
writes table sybsystemprocs..sp_hadr_admin_rset_006 
writes table sybsystemprocs..sp_hadr_admin_rset_002 
read_writes table tempdb..#FTETEMP (1) 
reads table master..syscolumns (1)  
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_010 
reads table master..syslogins (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_009 
calls proc sybsystemprocs..sp_autoformat  
   writes table sybsystemprocs..sp_autoformat_rset_003 
   reads table tempdb..syscolumns (1)  
   read_writes table tempdb..#colinfo_af (1) 
   writes table sybsystemprocs..sp_autoformat_rset_001 
   reads table tempdb..systypes (1)  
   reads table master..systypes (1)  
   writes table sybsystemprocs..sp_autoformat_rset_005 
   writes table sybsystemprocs..sp_autoformat_rset_002 
   calls proc sybsystemprocs..sp_autoformat  
   calls proc sybsystemprocs..sp_namecrack  
   writes table sybsystemprocs..sp_autoformat_rset_004 
   reads table master..syscolumns (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_008 
writes table sybsystemprocs..sp_hadr_admin_rset_004 
writes table sybsystemprocs..sp_hadr_admin_rset_011 
reads table master..systransactions (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_012 
calls proc sybsystemprocs..sp_dropserver  
   read_writes table sybsystemdb..syscoordinations (1)  
   reads table master..sysdatabases (1)  
   read_writes table master..sysremotelogins (1)  
   read_writes table master..sysservers (1)  
   calls proc sybsystemprocs..sp_aux_checkroleperm  
   calls proc sybsystemprocs..sp_ha_check_certified  
      reads table tempdb..sysobjects (1)  
   calls proc sybsystemprocs..sp_getmessage  
   read_writes table master..sysattributes (1)  
   reads table master..spt_values (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_005 
reads table master..sysdatabases (1)  
writes table master..sysattributes (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_013 
reads table master..sysengines (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_003 
writes table sybsystemprocs..sp_hadr_admin_rset_001 
read_writes table tempdb..#FTETEMP2 (1) 
calls proc sybsystemprocs..sp_hadrvrfyargs  
   reads table master..sysservers (1)  
   reads table master..sysdatabases (1)  
writes table tempdb..#rep_status (1) 
read_writes table master..sysservers (1)  
writes table sybsystemprocs..sp_hadr_admin_rset_007 
writes table tempdb..#spt_hadrserver (1) 

CALLERS
called by proc sybsystemprocs..sp_hadr_update