DatabaseProcApplicationCreatedLinks
sybsystemprocssp_flush_query_tuning  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Generated by spgenmsgs.pl on Tue Dec 19 13:41:30 2006 
4     */
5     /*
6     ** raiserror Messages for flush_query_tuning [Total 0]
7     */
8     /*
9     ** sp_getmessage Messages for flush_query_tuning [Total 0]
10    */
11    /*
12    ** End spgenmsgs.pl output.
13    */
14    
15    /*
16    ** sp_flush_query_tuning
17    **
18    ** Dump query_tuning metrics in memory to system catalog
19    ** Requires Galaxy or later
20    **
21    */
22    
23    create or replace procedure sp_flush_query_tuning
24    as
25    
26        declare @nullarg char(1)
27        declare @dummy int
28        declare @status int
29        declare @gp_enabled int
30    
31        if @@trancount = 0
32        begin
33            set chained off
34        end
35    
36        set transaction isolation level 1
37    
38        /*
39        ** If granular permissions is not enabled then sa_role is required by dbcc
40        ** flushmetrics so we will check for it here. 
41        ** If granular permissions is enabled then the permission
42        ** 'monitor qp performance' is required.  proc_role and proc_auditperm will
43        ** also do auditing if required. Both will print an error message if
44        ** required.
45        */
46    
47        select @nullarg = NULL
48        execute @status = sp_aux_checkroleperm "sa_role", "monitor qp performance",
49            @nullarg, @gp_enabled output
50        /* For Auditing */
51        if (@gp_enabled = 0)
52        begin
53            select @dummy = proc_role("sa_role")
54        end
55        else
56        begin
57            select @dummy = proc_auditperm("monitor qp performance", @status)
58        end
59        if (@status != 0)
60            return (1)
61    
62        dbcc traceon(3604)
63        dbcc flushmetrics
64        dbcc traceoff(3604)
65    
66        return (0)
67    


exec sp_procxmode 'sp_flush_query_tuning', 'AnyMode'
go

Grant Execute on sp_flush_query_tuning to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_flush_query_tuning  
 MUCO 3 Useless Code Useless Brackets 51
 MUCO 3 Useless Code Useless Brackets 59
 MUCO 3 Useless Code Useless Brackets 60
 MUCO 3 Useless Code Useless Brackets 66
 QISO 3 Set isolation level 36
 VNRD 3 Variable is not read @dummy 57
 MTR1 2 Metrics: Comments Ratio Comments: 44% 23
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 4dec - 1exi + 2 23
 MTR3 2 Metrics: Query Complexity Complexity: 22 23

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

CALLERS
called by proc sybsystemprocs..sp_query_tuning