DatabaseProcApplicationCreatedLinks
sybsystemprocssp_repdbsync  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /*
4     ** This system procedure is normally called by Replication Server.
5     ** It is used to mark a replicate database with a label identifying 
6     ** an HADR deactivate command executed on a primary node.
7     ** The label is written in sysattributes to indicate that replication 
8     ** is complete, i.e. the transaction log of the source database 
9     ** on the primary node has been drained.
10    **
11    ** Parameter:
12    **	label	- label identifying the HADR deactivate command and used 
13    **		  on the primary node when executing sp_hadr_admin.
14    */
15    create or replace procedure sp_repdbsync
16        @label varchar(255) = NULL
17    as
18    
19        declare @gp_enabled int,
20            @nullarg char(1),
21            @dummy int,
22            @status int,
23            @HADR_CLASS int, /* HADR class id */
24            @DRAIN_LABEL int /* replication drain label attribute id */
25    
26        /*
27        ** This stored procedure needs to be allowed to be executed within 
28        ** a transaction for the case when it is injected directly in 
29        ** Replication Server queues through rs_ticket which is itself enclosed 
30        ** in a transaction.
31        ** Do the @@trancount check before initializing any local variables, 
32        ** because "select" statement itself will start a transaction 
33        ** if chained mode is on.
34        */
35        if @@trancount = 0
36        begin
37            set chained off
38        end
39    
40        set transaction isolation level 1
41        set nocount on
42    
43        select @nullarg = NULL, @HADR_CLASS = 43, @DRAIN_LABEL = 1
44    
45        /*
46        ** If granular permissions is not enabled then sa_role is required.
47        ** If granular permissions is enabled then the permission 'manage hadr'
48        ** is required.
49        */
50        execute @status = sp_aux_checkroleperm "sa_role", "manage hadr",
51            @nullarg, @gp_enabled output
52    
53        if (@gp_enabled = 0)
54        begin
55            if (proc_role("sa_role") = 0)
56            begin
57                return (1)
58            end
59        end
60        else
61        begin
62            select @dummy = proc_auditperm("manage hadr", @status)
63        end
64    
65        if (@status != 0)
66        begin
67            return (1)
68        end
69    
70        /* Insert or update existing row. */
71        if exists (select 1 from sysattributes where
72                    class = @HADR_CLASS and attribute = @DRAIN_LABEL)
73        begin
74            update sysattributes set char_value = @label
75            where class = @HADR_CLASS and attribute = @DRAIN_LABEL
76        end
77        else
78        begin
79            insert into sysattributes(class, attribute, object_type, char_value)
80            values (@HADR_CLASS, @DRAIN_LABEL, "RA", @label)
81        end
82    
83        return (0)
84    


exec sp_procxmode 'sp_repdbsync', 'AnyMode'
go

Grant Execute on sp_repdbsync to public
go
DEFECTS
 MINU 4 Unique Index with nullable columns sybsystemprocs..sysattributes sybsystemprocs..sysattributes
 MTYP 4 Assignment type mismatch attribute: smallint = int 80
 MTYP 4 Assignment type mismatch class: smallint = int 80
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 72
 QTYP 4 Comparison type mismatch smallint = int 72
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 75
 QTYP 4 Comparison type mismatch smallint = int 75
 MGTP 3 Grant to public sybsystemprocs..sp_repdbsync  
 MGTP 3 Grant to public sybsystemprocs..sysattributes  
 MNER 3 No Error Check should check @@error after update 74
 MNER 3 No Error Check should check @@error after insert 79
 MUCO 3 Useless Code Useless Brackets 53
 MUCO 3 Useless Code Useless Brackets 55
 MUCO 3 Useless Code Useless Brackets 57
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 67
 MUCO 3 Useless Code Useless Brackets 83
 MUOT 3 Updates outside transaction 79
 QISO 3 Set isolation level 40
 QIWC 3 Insert with not all columns specified missing 11 columns out of 15 79
 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}
72
 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}
75
 VNRD 3 Variable is not read @dummy 62
 MSUB 2 Subquery Marker 71
 MTR1 2 Metrics: Comments Ratio Comments: 50% 15
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 7dec - 3exi + 2 15
 MTR3 2 Metrics: Query Complexity Complexity: 30 15

DATA PROPAGATION detailed
ColumnWritten To
@labelsysattributes.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 sybsystemprocs..sysattributes  
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)