DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dump_info  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Messages for "sp_dump_info"             17590
4     **
5     */
6     create or replace procedure sp_dump_info
7         @dbname varchar(255) = NULL,
8         @dump_type varchar(30) = 'cumulative'
9     as
10        declare @data_pages unsigned int,
11            @log_pages unsigned int,
12            @tot_pages unsigned int,
13            @damstat unsigned int,
14            @numpgs_data float,
15            @numpgs_log float,
16            @numpgsgb float,
17            @numpgsmb float,
18            @numpgskb float,
19            @data_unit char(3),
20            @log_unit char(3)
21    
22        set nocount on
23    
24        /*
25        **  If no database name given, use current database
26        */
27        if @dbname is null
28            select @dbname = db_name()
29    
30        if (db_id(@dbname) is null)
31        begin
32            /* 17590, "The specified database does not exist." */
33            raiserror 17590
34            return 1
35        end
36    
37        if (@dump_type = 'cumulative')
38        begin
39            select @damstat = convert(unsigned int, dbinfo_get(@dbname, 'damstat'))
40    
41            if (@damstat & 1 = 0)
42            begin
43                /*
44                ** Incremental dumps are not enabled in this database.
45                */
46                raiserror 17154, @dbname
47                return 1
48            end
49    
50            if (@damstat & 2 = 0)
51            begin
52                /*
53                ** There isn't any incremental dump information available 
54                ** for database %1! because the database has not been fully dumped yet.
55                */
56                raiserror 17155, @dbname
57                return 1
58            end
59        end
60    
61        select @numpgskb = 1024. / @@maxpagesize
62        select @numpgsmb = @numpgskb * 1024.
63        select @numpgsgb = @numpgsmb * 1024.
64    
65        if (@dump_type = 'tran')
66            select @data_pages = 0,
67                @log_pages = dumpinfo(@dbname, @dump_type, 'log_pages')
68        else
69            select @data_pages = dumpinfo(@dbname, @dump_type, 'data_pages_thresh'),
70                @log_pages = dumpinfo(@dbname, @dump_type, 'active_log_pages')
71    
72        select @tot_pages = sum(size) from master.dbo.sysusages
73        where dbid = db_id(@dbname) and vdevno >= 0
74    
75        if (@data_pages / @numpgsgb > 1024.0)
76            select @data_unit = " GB", @numpgs_data = @numpgsgb
77        else if (@data_pages / @numpgsmb > 1024.0)
78            select @data_unit = " MB", @numpgs_data = @numpgsmb
79        else
80            select @data_unit = " KB", @numpgs_data = @numpgskb
81    
82        if (@log_pages / @numpgsgb > 1024.)
83            select @log_unit = " GB", @numpgs_log = @numpgsgb
84        else if (@log_pages / @numpgsmb > 1024.)
85            select @log_unit = " MB", @numpgs_log = @numpgsmb
86        else
87            select @log_unit = " KB", @numpgs_log = @numpgskb
88    
89        select "Data" = convert(varchar(10),
90            convert(unsigned int, @data_pages / @numpgs_data))
91            + @data_unit,
92            "Log" = convert(varchar(10),
93            convert(unsigned int, @log_pages / @numpgs_log))
94            + @log_unit,
95            "Database percentage" =
96            convert(int, 100 * (convert(float, @data_pages + @log_pages)
97            / convert(float, @tot_pages))),
98            "Allocation threshold" = @@dump_allocation_threshold
99    
100       return 0
101   


exec sp_procxmode 'sp_dump_info', 'AnyMode'
go

Grant Execute on sp_dump_info to public
go
RESULT SETS
sp_dump_info_rset_001

DEFECTS
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 73
 QTYP 4 Comparison type mismatch smallint = int 73
 MGTP 3 Grant to public master..sysusages  
 MGTP 3 Grant to public sybsystemprocs..sp_dump_info  
 MUCO 3 Useless Code Useless Brackets 30
 MUCO 3 Useless Code Useless Brackets 37
 MUCO 3 Useless Code Useless Brackets 41
 MUCO 3 Useless Code Useless Brackets 50
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 77
 MUCO 3 Useless Code Useless Brackets 82
 MUCO 3 Useless Code Useless Brackets 84
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysusages.csysusages unique clustered
(dbid, lstart)
Intersection: {dbid}
73
 MRST 2 Result Set Marker 89
 MTR1 2 Metrics: Comments Ratio Comments: 14% 6
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 10 = 12dec - 4exi + 2 6
 MTR3 2 Metrics: Query Complexity Complexity: 48 6

DATA PROPAGATION detailed
ColumnWritten To
@dbnamesp_dump_info_rset_001.Data °.Log °.Database percentage
@dump_typesp_dump_info_rset_001.Data °.Log °.Database percentage

DEPENDENCIES
PROCS AND TABLES USED
writes table sybsystemprocs..sp_dump_info_rset_001 
reads table master..sysusages (1)