Database | Proc | Application | Created | Links |
sybsystemprocs | sp_multdb_unbindall_gr | 31 Aug 14 | Defects Dependencies |
1 2 3 /* 4 ** Messages for "sp_multdb_unbindall_gr" 5 ** 6 ** 17240, "'%1!' is not a valid name." 7 ** 17260, "Can't run %1! from within a transaction." 8 ** 18608, "%1!: Delete row from master.dbo.sysattributes failed. 9 ** Command aborted." 10 ** 18947, "Group '%1!' does not exist." 11 */ 12 13 /* 14 ** Procedure sp_multdb_unbindall_gr 15 ** 16 ** This procedure removes all login/application bindings from SYSATTRIBUTES for 17 ** a given temporary database group. 18 */ 19 create procedure sp_multdb_unbindall_gr 20 @group_name varchar(255) /* temporary database group name */ 21 as 22 23 declare @class_id smallint, /* class in SYSATTRIBUTES */ 24 @attrib_id smallint, /* attribute in SYSATTRIBUTES */ 25 @int_val int, /* int_value in SYSATTRIBUTES */ 26 @MULTDB_BINDGRP int, /* binding is to a tempdb group */ 27 @svrmode int, /* Indicates the SMP or SDC mode */ 28 @SMP int, /* Indicates SMP Server */ 29 @SDC int, /* Indicates SDC Server */ 30 @action int, /* action for built in */ 31 @ATTR_DROP int /* indicates a binding deletion */ 32 33 select @SMP = 0, 34 @SDC = 1 35 36 if @@clustermode != "shared disk cluster" 37 begin 38 select @svrmode = @SMP 39 end 40 else 41 begin 42 select @svrmode = @SDC 43 end 44 45 /* 46 ** If we're in a transaction, disallow this since it might make recovery 47 ** impossible. 48 */ 49 if @@trancount > 0 50 begin 51 /* 52 ** 17260, "Can't run %1! from within a transaction." 53 */ 54 raiserror 17260, "sp_multdb_unbindall_gr" 55 return (1) 56 end 57 else 58 begin 59 /* Use TSQL mode of unchained transactions */ 60 set chained off 61 end 62 63 /* Don't do "Dirty Reads" */ 64 set transaction isolation level 1 65 66 select @class_id = 16 /* class is MULTEMPDB_CLASS */ 67 select @attrib_id = 1 /* attribute is MULTEMPDB_BIND */ 68 69 /* 70 ** Following constants must be consistent with their definition in 71 ** multempdb.c 72 */ 73 select @MULTDB_BINDGRP = 1 74 75 /* keep in sync with sysattr.h */ 76 select @ATTR_DROP = 3 77 78 /* 79 ** Make sure group name is valid. Since 'default' is a reserved keyword 80 ** it will fail the valid name test, so handle it separately. 81 */ 82 if ((@group_name != "default") AND (valid_name(@group_name) = 0)) 83 begin 84 /* 85 ** 17240, "'%1!' is not a valid name." 86 */ 87 raiserror 17240, @group_name 88 return (1) 89 end 90 91 92 /* 93 ** Make sure that the specified group exists. 94 */ 95 select @attrib_id = 0 /* attribute is MULTEMPDB_GROUP */ 96 if not exists (select * from master..sysattributes 97 where class = @class_id 98 AND attribute = @attrib_id 99 AND object_type = 'GR' 100 AND object_cinfo = @group_name) 101 begin 102 103 /* 104 ** 18947, "Group '%1!' does not exist." 105 */ 106 raiserror 18947, @group_name 107 return (1) 108 end 109 110 111 /* 112 ** Delete all login and application bindings to the specified group. 113 */ 114 select @attrib_id = 1 /* Attribute is for binding */ 115 select @int_val = @MULTDB_BINDGRP /* Binding is to a group */ 116 117 select @action = @ATTR_DROP 118 119 begin transaction multdb_unbindall_gr 120 121 /* 122 ** Delete the entry representing login/application bindings to the 123 ** given temporary database group. 124 */ 125 delete from master..sysattributes 126 where class = @class_id 127 AND attribute = @attrib_id 128 AND char_value = @group_name 129 AND int_value = @int_val 130 131 if (@@error != 0) 132 begin 133 /* 134 ** 18608, "%1!: Delete row from master.dbo.sysattributes failed. 135 ** Command aborted." 136 */ 137 raiserror 18608, "sp_multdb_unbindall_gr" 138 goto error_exit 139 end 140 141 /* 142 ** Currently, no action is required upon notification of an unbindall event. 143 ** Uncomment the notification below when some action needs to be implemented. 144 ** Send only one notification for this operation. The notified routine needs 145 ** to decode the operation code as 'unbindall_gr' by examining the received 146 ** arguments. 147 */ 148 -- select @notify_status = 149 -- attrib_notify (@class_id, @attrib_id, NULL, NULL, 150 -- NULL, NULL, NULL, NULL, 151 -- @MULTDB_BINDGRP, @group_name, NULL, NULL, "", @action) 152 -- 153 --if (@notify_status = 0) 154 --begin 155 -- print "Internal error: Failed to remove binding." 156 -- goto error_exit 157 --end 158 159 commit transaction multdb_unbindall_gr 160 return (0) 161 162 error_exit: 163 rollback transaction multdb_unbindall_gr 164 return (1) 165
DEFECTS | |
MINU 4 Unique Index with nullable columns master..sysattributes | master..sysattributes |
MGTP 3 Grant to public master..sysattributes | |
MUCO 3 Useless Code Useless Brackets | 55 |
MUCO 3 Useless Code Useless Brackets | 82 |
MUCO 3 Useless Code Useless Brackets | 88 |
MUCO 3 Useless Code Useless Brackets | 107 |
MUCO 3 Useless Code Useless Brackets | 131 |
MUCO 3 Useless Code Useless Brackets | 160 |
MUCO 3 Useless Code Useless Brackets | 164 |
QISO 3 Set isolation level | 64 |
QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {object_type, object_cinfo, attribute, class} | 97 |
QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered (class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo) Intersection: {attribute, class} | 126 |
VNRD 3 Variable is not read @svrmode | 42 |
VNRD 3 Variable is not read @action | 117 |
MSUB 2 Subquery Marker | 96 |
MTR1 2 Metrics: Comments Ratio Comments: 57% | 19 |
MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 9dec - 4exi + 2 | 19 |
MTR3 2 Metrics: Query Complexity Complexity: 51 | 19 |
DEPENDENCIES |
PROCS AND TABLES USED read_writes table master..sysattributes (1) CALLERS called by proc sybsystemprocs..sp_tempdb |