DatabaseProcApplicationCreatedLinks
sybsystemprocssp_querysmobj  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /*
4     ** This procedure performs queries Backup objects backed up at Storage Manager.
5     ** It sends bs_querysmobj RPC to the Backup Server, passing all the 
6     ** parameters to the stored procedure as it is. The parsing of all the 
7     ** options is done by the Backup Server. The actual Query operation is 
8     ** performed by Backup Server using the syb_queryobj() API call of the 
9     ** API interface supplied as an argument.
10    **
11    ** This can be issued only by users with SA role or oper_role.
12    */
13    
14    /*
15    ** Messages for "sp_querysmobj"
16    **
17    ** 17260, "Can't run %1! from within a transaction."
18    ** 18255, "%1! cannot be NULL."
19    */
20    
21    create or replace procedure sp_querysmobj
22        @sm_api_name varchar(30) = NULL, /* SM Interface Stream name*/
23        @output_fname varchar(255) = NULL, /* Output filename path */
24        @server_name varchar(30) = NULL, /* Server Instance name */
25        @database_name varchar(30) = NULL, /* Database name */
26        @object_name varchar(255) = NULL, /* Archive object name */
27        @dump_type varchar(30) = NULL, /* Database dump type */
28        @until_time varchar(30) = NULL, /* Until point in time */
29        @bs_name varchar(30) = NULL /* Backup Server name */
30    as
31    
32        begin
33    
34            declare @status int /* RPC status */
35            declare @bs_rpc varchar(255) /* RPC site and proc name */
36            declare @dummy int
37            declare @nullarg char(1)
38            declare @gp_enabled int
39            declare @status1 int
40            declare @status2 int
41    
42            select @status1 = 1
43            select @status2 = 1
44    
45    
46            if @@trancount > 0
47            begin
48                /* 17260, "Can't run %1! from within a transaction." */
49                raiserror 17260, "sp_querysmobj"
50                return (1)
51            end
52    
53            /*
54            **  If granular permissions is not enabled, 
55            **  accounts with sa_role or oper_role role can execute it.
56            **  If granular permissions is enabled then users with 
57            ** 'dump any database' permission can execute it.
58            */
59            select @nullarg = NULL
60            execute @status1 = sp_aux_checkroleperm "sa_role", "dump any database",
61                @nullarg, @gp_enabled output
62    
63            if (@gp_enabled = 0)
64            begin
65                if (@status1 != 0)
66                begin
67                    execute @status2 = sp_aux_checkroleperm "oper_role",
68                        @nullarg, @nullarg, @gp_enabled output
69    
70                    if (@status2 != 0)
71                    begin
72                        /* 
73                        ** proc_role() will raise permission errors
74                        ** and send audit records to the audit trail.
75                        */
76                        select @dummy = proc_role("sa_role")
77                        select @dummy = proc_role("oper_role")
78                        return (1)
79                    end
80                end
81                if (@status1 = 0)
82                begin
83                    select @dummy = proc_role("sa_role")
84                end
85    
86                if (@status2 = 0)
87                begin
88                    select @dummy = proc_role("oper_role")
89                end
90            end
91            else
92            begin
93                select @dummy = proc_auditperm("dump any database",
94                        @status1)
95                if (@status1 != 0)
96                    return 1
97            end
98    
99            /*
100           ** Check for mandatory parameters supplied.
101           **
102           */
103           if (@sm_api_name is NULL)
104           begin
105               raiserror 18255, "Storage Manager API module name"
106               return (1)
107           end
108   
109           if (@output_fname is NULL)
110           begin
111               raiserror 18255, "Query output filename"
112               return (1)
113           end
114   
115           if (@server_name is NULL)
116           begin
117               raiserror 18255, "Server name"
118               return (1)
119           end
120   
121           /* Select SYB_BACKUP as default Backup Server */
122           if (@bs_name is NULL)
123           begin
124               select @bs_rpc = 'SYB_BACKUP...bs_querysmobj'
125           end
126           else
127           begin
128               select @bs_rpc = @bs_name + '...bs_querysmobj'
129           end
130   
131           exec @status = @bs_rpc @sm_api_name, @output_fname, @server_name, @database_name, @object_name, @dump_type, @until_time, @bs_name
132   
133           return (@status)
134   
135       end
136   
137   


exec sp_procxmode 'sp_querysmobj', 'AnyMode'
go

Grant Execute on sp_querysmobj to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_querysmobj  
 MUCO 3 Useless Code Useless Begin-End Pair 32
 MUCO 3 Useless Code Useless Brackets 50
 MUCO 3 Useless Code Useless Brackets 63
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 70
 MUCO 3 Useless Code Useless Brackets 78
 MUCO 3 Useless Code Useless Brackets 81
 MUCO 3 Useless Code Useless Brackets 86
 MUCO 3 Useless Code Useless Brackets 95
 MUCO 3 Useless Code Useless Brackets 103
 MUCO 3 Useless Code Useless Brackets 106
 MUCO 3 Useless Code Useless Brackets 109
 MUCO 3 Useless Code Useless Brackets 112
 MUCO 3 Useless Code Useless Brackets 115
 MUCO 3 Useless Code Useless Brackets 118
 MUCO 3 Useless Code Useless Brackets 122
 MUCO 3 Useless Code Useless Brackets 133
 MZMB 3 Zombie: use of non-existent object SYB_BACKUP...bs_querysmobj 0
 VNRD 3 Variable is not read @gp_enabled 68
 VNRD 3 Variable is not read @dummy 93
 MDYE 2 Dynamic Exec Marker exec @status 131
 MTR1 2 Metrics: Comments Ratio Comments: 38% 21
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 12dec - 7exi + 2 21
 MTR3 2 Metrics: Query Complexity Complexity: 54 21

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