DatabaseProcApplicationCreatedLinks
sybsystemprocssp_volchanged  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
3     
4     /*
5     ** Messages for "sp_volchanged"
6     ** 
7     ** 19958, "Backup Server policy is set to '%1!'."
8     */
9     
10    create or replace procedure sp_volchanged
11        @session_id int, /* session identifier		*/
12        @devname varchar(255), /* device requesting vol chg	*/
13        @action varchar(255) = NULL, /* BServer action string	*/
14        @fname varchar(17) = NULL, /* file name on device		*/
15        @vname varchar(6) = NULL, /* name to init new volume with */
16        @bs_name varchar(255) = NULL /* name of backup server */
17    as
18    
19        declare @server varchar(30) /* server name, if network dump	*/
20        declare @blank int /* index to " " when parsing @devname	*/
21        declare @len int /* length of @devname, for parsing	*/
22        declare @pname varchar(255) /* translated physical device name	*/
23        declare @status int /* RPC status				*/
24    
25        declare @bs_policy varchar(255) /* Backup server policy */
26        declare @msg varchar(1024) /* Display BS policy */
27        declare @bs_rpc varchar(255)
28        declare @bs_net_name varchar(255)
29    
30        if @@trancount = 0
31        begin
32            set chained off
33        end
34        set cis_rpc_handling off
35        set transaction isolation level 1
36    
37        if (lower(@devname) like "% at %")
38        begin
39            /*
40            **  AT  -- parse the device and host
41            ** names into separate arguments for transmission
42            */
43            select @len = datalength(@devname)
44            select @blank = charindex(" ", @devname)
45            select @server = ltrim(
46                    substring(
47                        ltrim(
48                            substring(@devname, @blank, @len)), 3, @len))
49            select @devname = rtrim(substring(@devname, 1, @blank))
50        end
51        else
52        begin
53            /* No host given -- select the local server */
54            select @server = NULL
55    
56            /* and do logical name translation */
57            select @pname = phyname
58            from master..sysdevices
59            where name = @devname
60                and (status & 16) = 16
61            if (@pname is not NULL)
62                select @devname = @pname
63        end
64    
65        /*
66        ** If the Multiple Backup server feature is enabled with Backup server policy
67        ** as $dedicated or $roundrobin and parameter bs_name is not provided,
68        ** raise error to specify particular Backup server name.
69        */
70        if (@bs_name = NULL)
71        begin
72            select @bs_policy = srvnetname from master..sysservers where srvname = "SYB_BACKUP"
73    
74            if ((lower(@bs_policy) = "$dedicated") or (lower(@bs_policy) = "$roundrobin"))
75            begin
76                /* 19958, "Backup Server policy is set to '%1!'." */
77                exec sp_getmessage 19958, @msg output
78                print @msg, @bs_policy
79                return
80            end
81            else
82                select @bs_name = "SYB_BACKUP"
83        end
84        else
85        begin
86            select @bs_net_name = @bs_name
87            select @bs_name = NULL
88            select @bs_name = srvname from master..sysservers where srvnetname = @bs_net_name
89    
90            if (@bs_name = NULL)
91            begin
92                select @bs_name = @bs_net_name
93                select @bs_net_name = NULL
94                select @bs_net_name = srvnetname from master..sysservers where srvname = @bs_name
95    
96                if (@bs_net_name = NULL)
97                begin
98                    /* 19960, "Backup Server '%1!' is not configured in sysservers." */
99                    exec sp_getmessage 19960, @msg output
100                   print @msg, @bs_name
101                   return
102               end
103           end
104   
105           /* 19970, "Executing RPC as_volume_changed at Backup Server '%1!'('%2!')." */
106           exec sp_getmessage 19970, @msg output
107           print @msg, @bs_name, @bs_net_name
108       end
109   
110       select @bs_rpc = @bs_name + '...as_volume_changed'
111       exec @status = @bs_rpc @server, @session_id, @devname, @action, @fname, @vname
112       return (@status)
113   


exec sp_procxmode 'sp_volchanged', 'AnyMode'
go

Grant Execute on sp_volchanged to public
go
DEFECTS
 MGTP 3 Grant to public master..sysdevices  
 MGTP 3 Grant to public master..sysservers  
 MGTP 3 Grant to public sybsystemprocs..sp_volchanged  
 MNAC 3 Not using ANSI 'is null' 70
 MNAC 3 Not using ANSI 'is null' 90
 MNAC 3 Not using ANSI 'is null' 96
 MNER 3 No Error Check should check return value of exec 77
 MNER 3 No Error Check should check return value of exec 99
 MNER 3 No Error Check should check return value of exec 106
 MUCO 3 Useless Code Useless Brackets 37
 MUCO 3 Useless Code Useless Brackets 61
 MUCO 3 Useless Code Useless Brackets 70
 MUCO 3 Useless Code Useless Brackets 74
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Brackets 96
 MUCO 3 Useless Code Useless Brackets 112
 QAFM 3 Var Assignment from potentially many rows 88
 QISO 3 Set isolation level 35
 MDYE 2 Dynamic Exec Marker exec @status 111
 MTR1 2 Metrics: Comments Ratio Comments: 32% 10
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 9 = 10dec - 3exi + 2 10
 MTR3 2 Metrics: Query Complexity Complexity: 63 10

DEPENDENCIES
PROCS AND TABLES USED
reads table master..sysdevices (1)  
calls proc sybsystemprocs..sp_getmessage  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
reads table master..sysservers (1)