Database | Proc | Application | Created | Links |
sybsystemprocs | sp_addumpdevice ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */ 3 /* 4.8 1.1 06/14/90 sproc/src/addumpdevice */ 4 5 /* 6 ** Messages for "sp_addumpdevice" 17310 7 ** 8 ** 17260, "Can't run %1! from within a transaction." 9 ** 17240, "'" + @logicalname + "' is not a valid name." 10 ** 17310, "Unknown device type. Use 'disk' or 'tape'." 11 ** 17311, "@logicalname may not be NULL." 12 ** 17312, "@physicalname may not be NULL." 13 ** 17314, "Device with same logical name already exists." 14 ** 17317, "Please specify media capacity in megabytes (1 MB minimum)." 15 ** 17318, "WARNING: specified size parameter is not used for the disk device type." 16 ** 17319, "'Disk' device added." 17 ** 17320, "'Tape' device added." 18 ** 17321, "WARNING: physical device name '%1!' is not unique." 19 ** 17325, "The length of input parameter '%1!' is longer than the permissible %2! characters." 20 ** 18388, "You must be in the master database to run %1!" 21 */ 22 create procedure sp_addumpdevice 23 @devtype varchar(30), /* disk, tape, or special */ 24 @logicalname varchar(255), /* logical name of the device */ 25 @physicalname varchar(128), /* physical name of the device */ 26 @tapesize int = NULL /* capacity of tape in MB */ 27 28 as 29 30 declare @status smallint /* status bits for device */ 31 declare @msg varchar(1024) 32 declare @tapeblocksize int 33 declare @cntrltype smallint 34 declare @maxlen int 35 declare @maxphylen int 36 37 /* check the lenghts of the input parameters */ 38 select @maxlen = length from master.dbo.syscolumns 39 where id = object_id("master.dbo.sysdevices") and name = "name" 40 41 if char_length(@logicalname) > @maxlen 42 begin 43 /* 44 ** 17325, "The length of input parameter '%1!' is longer than the permissible %2! characters." 45 */ 46 raiserror 17325, @logicalname, @maxlen 47 return (1) 48 end 49 select @maxphylen = length from master.dbo.syscolumns 50 where id = object_id("master.dbo.sysdevices") and name = "phyname" 51 52 if char_length(@physicalname) > @maxphylen 53 begin 54 /* 55 ** 17325, "The length of input parameter '%1!' is longer than the permissible %2! characters." 56 */ 57 raiserror 17325, @physicalname, @maxphylen 58 return (1) 59 end 60 61 /* 62 ** If we're in a transaction, disallow this since it might make recovery 63 ** impossible. 64 */ 65 if @@trancount > 0 66 begin 67 /* 68 ** 17260, "Can't run %1! from within a transaction." 69 */ 70 raiserror 17260, "sp_addumpdevice" 71 return (1) 72 end 73 else 74 begin 75 set chained off 76 end 77 78 set transaction isolation level 1 79 80 /* check if user has sa role, proc_role will also do auditing 81 ** if required. proc_role will also print error message if required. 82 */ 83 84 if (proc_role("sa_role") = 0) 85 return (1) 86 87 /* 88 ** Check to see that the @logicalname is valid. 89 */ 90 if valid_name(@logicalname, @maxlen) = 0 91 begin 92 /* 93 ** 17240, "'%1!' is not a valid name." 94 */ 95 raiserror 17240, @logicalname 96 return (1) 97 end 98 99 /* 100 ** The rules for updating sysdevices are as follows: 101 ** devtype - may be 'disk', 'tape' or 'archive database'. 102 ** If 'disk' then cntrltype will be 2, 103 ** If 'tape' then 3. 104 ** cntrltype is not used for 'archive database'. 105 ** logicalname - may be any identifier but must be unique 106 ** physicalname - may be anything and doesn't have to be unique 107 ** If it contains illegal id characters, e.g., '/', then 108 ** it must be in quotes. 109 ** tapesize - for a tape device, this is the tape capacity in MB. It 110 ** is ignored on VMS. 111 */ 112 113 114 /* 115 ** Check out the @devtype. 116 */ 117 select @devtype = lower(@devtype) 118 119 if (@devtype = "tape") 120 begin 121 select @cntrltype = 3 122 end 123 else if (@devtype = "disk") 124 begin 125 select @cntrltype = 2 126 end 127 else if (@devtype != "archive database") 128 begin 129 /* 130 ** 17310, "Unknown device type. Use 'disk' or 'tape'." 131 */ 132 raiserror 17310 133 return (1) 134 end 135 136 /* 137 ** Check the args are not NULL. 138 */ 139 if @logicalname is NULL 140 begin 141 /* 142 ** 17311, "@logicalname may not be NULL." 143 */ 144 raiserror 17311, @logicalname 145 return (1) 146 end 147 148 149 if @physicalname is NULL 150 begin 151 /* 152 ** 17312, "@physicalname may not be NULL." 153 */ 154 raiserror 17312, @physicalname 155 return (1) 156 end 157 158 /* 159 ** Make sure that a device with @logicalname doesn't already exist. 160 */ 161 if exists (select * 162 from master.dbo.sysdevices 163 where name = @logicalname) 164 begin 165 /* 166 ** 17314, "Device with same logical name already exists." 167 */ 168 raiserror 17314 169 return (1) 170 end 171 172 /* 173 ** Always turn on the dump status bit. 174 */ 175 select @status = 16 176 177 /* 178 ** If @devtype is a tape then check to see if devstatus is 'skip'. 179 */ 180 if @devtype = "tape" 181 begin 182 /* 183 ** If this is not VMS, then @tapesize is required. 184 */ 185 if not exists (select * 186 from master.dbo.spt_values 187 where type = "E" 188 and name = "vms") 189 begin 190 if @tapesize is NULL or @tapesize < 1 191 begin 192 /* 193 ** 17317, "Please specify media capacity in megabytes (1 MB minimum)." 194 */ 195 raiserror 17317 196 return (1) 197 end 198 199 select @tapeblocksize = 32768 200 201 select @tapesize = 202 convert(int, ((@tapesize * 1048576.) 203 + @tapeblocksize - 1) / @tapeblocksize) 204 end 205 else 206 begin 207 select @tapesize = 0 208 end 209 end 210 else 211 begin 212 if @tapesize is not NULL 213 begin 214 /* 215 ** 17318, "WARNING: specified size parameter is not used for the disk device type." 216 */ 217 raiserror 17318 218 end 219 select @tapesize = 0 220 end 221 222 if @devtype = "archive database" 223 begin 224 225 /* 226 ** If we're not in the master database, the do not allow the adding 227 ** of archive database devices. 228 */ 229 if db_name() != "master" 230 begin 231 /* 232 ** 18388, "You must be in the master database in order to run %1! 233 */ 234 raiserror 18388, "sp_addumpdevice 'archive database'" 235 return (1) 236 end 237 disk reinit name = @logicalname, physname = @physicalname, adb 238 239 if (@@error != 0) 240 return (1) 241 end 242 else 243 begin 244 /* Tell the server about the device by inserting into sysdevices */ 245 insert into master.dbo.sysdevices(vdevno, low, high, status, status2, cntrltype, name, phyname) 246 values (0, 0, @tapesize, @status, 0, @cntrltype, @logicalname, @physicalname) 247 end 248 249 if @devtype = "disk" or @devtype = "archive database" 250 /* 251 ** 17319, "'Disk' device added." 252 */ 253 exec sp_getmessage 17319, @msg output 254 else 255 /* 256 ** 17320, "'Tape' device added." 257 */ 258 exec sp_getmessage 17320, @msg output 259 260 print @msg 261 262 /* 263 ** Warn about duplicate physical names. 264 */ 265 if (select count(*) 266 from master.dbo.sysdevices 267 where phyname = @physicalname) > 1 268 begin 269 /* 270 ** 17321, "WARNING: physical device name '%1!' is not unique." 271 */ 272 exec sp_getmessage 17321, @msg output 273 print @msg, @physicalname 274 end 275 276 return (0) 277
exec sp_procxmode 'sp_addumpdevice', 'AnyMode' go Grant Execute on sp_addumpdevice to public go
DEPENDENCIES |
PROCS AND TABLES USED read_writes table master..sysdevices (1) ![]() calls proc sybsystemprocs..sp_getmessage ![]() reads table sybsystemprocs..sysusermessages ![]() reads table master..sysmessages (1) ![]() reads table master..syslanguages (1) ![]() calls proc sybsystemprocs..sp_validlang ![]() reads table master..syslanguages (1) ![]() reads table master..syscolumns (1) ![]() reads table master..spt_values (1) ![]() |