DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dtx_purge_completedxacts  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** sp_dtx_purge_completedxacts
4     **
5     ** This stored procedure deletes all the logically deleted distributed
6     ** transaction meta-data in sybsystemdb..syscoordinations system catalog.
7     ** As a part of diagnostics, the server can be booted with an option to
8     ** not physically delete syscoordinations meta-data after a distributed
9     ** transaction commits or aborts. Instead, the row(s) will be logically
10    ** deleted. With this stored procedure, such row(s) can physically
11    ** deleted.
12    **
13    ** Parameters:
14    **	None.
15    **
16    ** Returns:
17    **	1 - if error.
18    **	0 - if no error.
19    */
20    
21    create or replace procedure sp_dtx_purge_completedxacts
22    as
23    
24        declare @nullarg char(1)
25        declare @dummy int
26        declare @status int
27        declare @gp_enabled int
28    
29    
30        if @@trancount > 0
31        begin
32            /* 17260, "Can't run %1! from within a transaction." */
33            raiserror 17260, "sp_dtx_purge_completedxacts"
34            return (1)
35        end
36    
37        /* we don't want row count information */
38        set nocount on
39    
40        /* 
41        ** If granular permissions is not enabled then sa_role is required.
42        ** If granular permissions is enabled then the role 'sybase_ts_role' is
43        ** required.  proc_role and proc_auditperm will also do auditing
44        ** if required. Both will also print error message if required.
45        */
46    
47        select @nullarg = NULL
48        execute @status = sp_aux_checkroleperm "sa_role", "sybase_ts_role",
49            @nullarg, @gp_enabled output
50    
51        /* For Auditing */
52        if (@gp_enabled = 0)
53        begin
54            if (proc_role("sa_role") = 0)
55                return (1)
56        end
57        else
58        begin
59            if (proc_role("sybase_ts_role") = 0)
60            begin
61                return (1)
62            end
63        end
64    
65        /*
66        ** Deletes syscoordinations distributed transactions meta-data that
67        ** are logically deleted and managed by dtm services.
68        */
69        delete from sybsystemdb.dbo.syscoordinations
70        where (owner = 1) and ((status & 1) = 1)
71    
72        return (0)
73    


exec sp_procxmode 'sp_dtx_purge_completedxacts', 'AnyMode'
go

Grant Execute on sp_dtx_purge_completedxacts to public
go
DEFECTS
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: syscoordinations.csyscoordinations unique clustered
(xactkey, participant, owner)
Intersection: {owner}
70
 QTYP 4 Comparison type mismatch Comparison type mismatch: tinyint vs int 70
 MGTP 3 Grant to public sybsystemdb..syscoordinations  
 MGTP 3 Grant to public sybsystemprocs..sp_dtx_purge_completedxacts  
 MNER 3 No Error Check should check return value of exec 48
 MNER 3 No Error Check should check @@error after delete 69
 MUCO 3 Useless Code Useless Brackets 34
 MUCO 3 Useless Code Useless Brackets 52
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 55
 MUCO 3 Useless Code Useless Brackets 59
 MUCO 3 Useless Code Useless Brackets 61
 MUCO 3 Useless Code Useless Brackets 72
 VNRD 3 Variable is not read @status 48
 VUNU 3 Variable is not used @dummy 25
 MTR1 2 Metrics: Comments Ratio Comments: 59% 21
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 3 = 5dec - 4exi + 2 21
 MTR3 2 Metrics: Query Complexity Complexity: 25 21

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)  
writes table sybsystemdb..syscoordinations (1)