DatabaseProcApplicationCreatedLinks
sybsystemprocssp_deletesmobj  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /*
4     ** This procedure deletes Backup objects backed up at Storage Manager.
5     ** It sends bs_deletesmobj 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_deleteobj() 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_deletesmobj"
16    **
17    ** 17260, "Can't run %1! from within a transaction."
18    ** 18255, "%1! cannot be NULL."
19    ** 19980, "You are not authorized to execute this stored procedure.
20    ** Only the System Administrator (SA) or a user with '%s'
21    ** authorization can execute this stored procedure."
22    **
23    */
24    
25    create or replace procedure sp_deletesmobj
26        @sm_api_name varchar(30) = NULL, /* SM Interface Stream name*/
27        @server_name varchar(30) = NULL, /* Server Instance name */
28        @database_name varchar(30) = NULL, /* Database name */
29        @object_name varchar(255) = NULL, /* Archive object name */
30        @dump_type varchar(30) = NULL, /* Database dump type */
31        @until_time varchar(30) = NULL, /* Until point in time */
32        @bs_name varchar(30) = NULL /* Backup Server name */
33    as
34    
35        begin
36    
37            declare @status int /* RPC status */
38            declare @bs_rpc varchar(255) /* RPC site and proc name */
39            declare @dummy int
40            declare @nullarg char(1)
41            declare @gp_enabled int
42            declare @status1 int
43            declare @status2 int
44    
45            select @status1 = 1
46            select @status2 = 1
47    
48            if @@trancount > 0
49            begin
50                /* 17260, "Can't run %1! from within a transaction." */
51                raiserror 17260, "sp_deletesmobj"
52                return (1)
53            end
54    
55            /*
56            **  If granular permissions is not enabled, 
57            **  accounts with sa_role or oper_role role can execute it.
58            **  If granular permissions is enabled then users with 
59            ** 'dump any database' permission can execute it.
60            */
61            select @nullarg = NULL
62            execute @status1 = sp_aux_checkroleperm "sa_role", "dump any database",
63                @nullarg, @gp_enabled output
64    
65            if (@gp_enabled = 0)
66            begin
67                if (@status1 != 0)
68                begin
69                    execute @status2 = sp_aux_checkroleperm "oper_role",
70                        @nullarg, @nullarg, @gp_enabled output
71    
72                    if (@status2 != 0)
73                    begin
74                        /* 
75                        ** proc_role() will raise permission errors
76                        ** and send audit records to the audit trail.
77                        */
78                        select @dummy = proc_role("sa_role")
79                        select @dummy = proc_role("oper_role")
80                        return (1)
81                    end
82                end
83                if (@status1 = 0)
84                begin
85                    select @dummy = proc_role("sa_role")
86                end
87    
88                if (@status2 = 0)
89                begin
90                    select @dummy = proc_role("oper_role")
91                end
92            end
93            else
94            begin
95                select @dummy = proc_auditperm("dump any database",
96                        @status1)
97                if (@status1 != 0)
98                    return 1
99            end
100   
101           /*
102           ** Check for mandatory parameters supplied.
103           **
104           */
105           if (@sm_api_name is NULL)
106           begin
107               raiserror 18255, "Storage Manager API module name"
108               return (1)
109           end
110   
111           if (@server_name is NULL)
112           begin
113               raiserror 18255, "Server name"
114               return (1)
115           end
116   
117           /* Select SYB_BACKUP as default Backup Server */
118           if (@bs_name is NULL)
119           begin
120               select @bs_rpc = 'SYB_BACKUP...bs_deletesmobj'
121           end
122           else
123           begin
124               select @bs_rpc = @bs_name + '...bs_deletesmobj'
125           end
126   
127           /* Issue bs_deletesmobj RPC to Backup Server */
128           exec @status = @bs_rpc @sm_api_name, @server_name, @database_name, @object_name, @dump_type, @until_time, @bs_name
129   
130           return (@status)
131   
132       end
133   


exec sp_procxmode 'sp_deletesmobj', 'AnyMode'
go

Grant Execute on sp_deletesmobj to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_deletesmobj  
 MUCO 3 Useless Code Useless Begin-End Pair 35
 MUCO 3 Useless Code Useless Brackets 52
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 67
 MUCO 3 Useless Code Useless Brackets 72
 MUCO 3 Useless Code Useless Brackets 80
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 88
 MUCO 3 Useless Code Useless Brackets 97
 MUCO 3 Useless Code Useless Brackets 105
 MUCO 3 Useless Code Useless Brackets 108
 MUCO 3 Useless Code Useless Brackets 111
 MUCO 3 Useless Code Useless Brackets 114
 MUCO 3 Useless Code Useless Brackets 118
 MUCO 3 Useless Code Useless Brackets 130
 MZMB 3 Zombie: use of non-existent object SYB_BACKUP...bs_deletesmobj 0
 VNRD 3 Variable is not read @gp_enabled 70
 VNRD 3 Variable is not read @dummy 95
 MDYE 2 Dynamic Exec Marker exec @status 128
 MTR1 2 Metrics: Comments Ratio Comments: 44% 25
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 11dec - 6exi + 2 25
 MTR3 2 Metrics: Query Complexity Complexity: 50 25

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