Database | Proc | Application | Created | Links |
sybsystemprocs | syb_aux_privnots | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */ 3 4 5 create procedure syb_aux_privnots 6 @left_binary varbinary(133), /* operand for the complement */ 7 @col_count smallint, /* number of columns in the table */ 8 @result_binary varbinary(133) output /* result of the complement */ 9 as 10 11 declare @loop_count tinyint /* loop counter for 133 bytes in varbinary */ 12 declare @left_opr tinyint /* integer represenation of a byte in left operand */ 13 declare @right_opr tinyint /* integer representation of a byte in right opr */ 14 declare @result_opr tinyint /* result integer byte */ 15 declare @expand_bin varbinary(133) /* expanded bit map with all 1s */ 16 declare @temp_resbin varbinary(133) /* transient value store for the result */ 17 declare @loop_bound tinyint /* stores the loop upper bound */ 18 19 20 /* 21 ** initialize the loop_count 22 */ 23 24 select @loop_count = 1 25 26 /* 27 ** initialize loop_bound 28 */ 29 select @loop_bound = @col_count / 8 + 1 30 31 /* 32 ** boundary condition. If left operand is 0, then the NOT of that is all 1s 33 */ 34 if (@left_binary = 0x00) 35 begin 36 select @result_binary = 0x01 37 return 38 end 39 40 /* 41 ** if left operand is all 1s, then NOT of of it is all 0s 42 */ 43 if (@left_binary = 0x01) 44 begin 45 select @result_binary = 0x00 46 return 47 end 48 49 /* 50 ** loop for each byte of 133 bytes varbinary operand 51 */ 52 while (@loop_count <= @loop_bound) 53 begin 54 select @left_opr = convert(tinyint, substring(@left_binary, @loop_count, 1)) 55 56 select @result_opr =~ @left_opr /* complement the byte */ 57 58 59 /* 60 ** first byte is treated differently as there is nothing to concatenate 61 */ 62 if (@loop_count = 1) 63 begin 64 select @result_opr = @result_opr & 0xfe /* do this as bit 0 has a special 65 meaning. make it 0*/ 66 select @temp_resbin = convert(binary(1), @result_opr) 67 end 68 else 69 begin 70 select @temp_resbin = @temp_resbin + convert(binary(1), @result_opr) 71 end 72 73 select @loop_count = @loop_count + 1 74 end 75 76 77 /* need to zero out the unnecessary one's */ 78 exec sybsystemprocs.dbo.syb_aux_expandbitmap @col_count, @expand_bin output 79 80 select @loop_count = 1 81 82 /* 83 ** the temp_resbin has 1's beyond number of columns. We need to zero them out 84 */ 85 while (@loop_count <= @loop_bound) 86 begin 87 select @left_opr = convert(tinyint, substring(@temp_resbin, @loop_count, 1)) 88 select @right_opr = convert(tinyint, substring(@expand_bin, @loop_count, 1)) 89 select @result_opr = @left_opr & @right_opr 90 91 if (@loop_count = 1) 92 begin 93 select @result_binary = convert(binary(1), @result_opr) 94 end 95 else 96 begin 97 select @result_binary = @result_binary + convert(binary(1), @result_opr) 98 end 99 100 select @loop_count = @loop_count + 1 101 end 102
exec sp_procxmode 'syb_aux_privnots', 'AnyMode' go Grant Execute on syb_aux_privnots to public go
DEFECTS | |
MBLI 3 Integer Value of Binary Literal is Platform Dependant | 34 |
MBLI 3 Integer Value of Binary Literal is Platform Dependant | 36 |
MBLI 3 Integer Value of Binary Literal is Platform Dependant | 43 |
MBLI 3 Integer Value of Binary Literal is Platform Dependant | 45 |
MBLI 3 Integer Value of Binary Literal is Platform Dependant | 64 |
MGTP 3 Grant to public sybsystemprocs..syb_aux_privnots | |
MNER 3 No Error Check should check return value of exec | 78 |
MUCO 3 Useless Code Useless Brackets | 34 |
MUCO 3 Useless Code Useless Brackets | 43 |
MUCO 3 Useless Code Useless Brackets | 52 |
MUCO 3 Useless Code Useless Brackets | 62 |
MUCO 3 Useless Code Useless Brackets | 85 |
MUCO 3 Useless Code Useless Brackets | 91 |
MTR1 2 Metrics: Comments Ratio Comments: 34% | 5 |
MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 6dec - 3exi + 2 | 5 |
MTR3 2 Metrics: Query Complexity Complexity: 40 | 5 |
DEPENDENCIES |
PROCS AND TABLES USED calls proc sybsystemprocs..syb_aux_expandbitmap CALLERS called by proc sybsystemprocs..sp_changegroup |