DatabaseProcApplicationCreatedLinks
sybsystemprocssyb_aux_privunion  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
3     
4     
5     create or replace procedure syb_aux_privunion
6         @left_binary varbinary(133), /* left operand of UNION operation */
7         @right_binary varbinary(133), /* right operand of UNION operation */
8         @col_count smallint, /* number of columns in the table */
9         @result_binary varbinary(133) output /* operand to return the result into */
10    as
11    
12        declare @loop_count tinyint /* loop count for all 133 bytes in varbinary */
13        declare @left_opr tinyint /* integer representation of a byte in left operand */
14        declare @right_opr tinyint /* integer representation of a byte in right operand */
15        declare @result_opr tinyint /* result of anding two bytes */
16        declare @loop_bound tinyint /* stores the loop upper bound */
17    
18        /* 
19        ** initialize the loop count 
20        */
21        select @loop_count = 1
22    
23        /* 
24        ** initialize loop_bound
25        */
26        select @loop_bound = @col_count / 8 + 1
27    
28        /*
29        ** check for boundary conditions. If any of the operand is all one's, the result
30        ** will also be all ones
31        */
32        if ((@left_binary = 0x01) or (@right_binary = 0x01))
33        begin
34            select @result_binary = 0x01
35            return
36        end
37        /*
38        ** loop through all the bytes in the operand and compute the UNION (i.e OR) byte
39        ** by byte 
40        */
41    
42        While (@loop_count <= @loop_bound)
43        begin
44            select @left_opr = convert(tinyint, substring(@left_binary, @loop_count, 1))
45            select @right_opr = convert(tinyint, substring(@right_binary, @loop_count, 1))
46            select @result_opr = @left_opr | @right_opr
47    
48    
49            if (@loop_count = 1)
50            Begin
51                /* first bytes is treated differently, as there is nothing to 
52                ** be concatenated 
53                */
54                select @result_binary = convert(binary(1), @result_opr)
55            end
56            else
57            begin
58                /* 
59                ** concatenate the result from byte 2 onwards 
60                */
61                select @result_binary = @result_binary + convert(binary(1), @result_opr)
62            end
63    
64            select @loop_count = @loop_count + 1
65        end
66    

DEFECTS
 MBLI 3 Integer Value of Binary Literal is Platform Dependant 32
 MBLI 3 Integer Value of Binary Literal is Platform Dependant 34
 MUCO 3 Useless Code Useless Brackets 32
 MUCO 3 Useless Code Useless Brackets 42
 MUCO 3 Useless Code Useless Brackets 49
 MTR1 2 Metrics: Comments Ratio Comments: 40% 5
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 5dec - 2exi + 2 5
 MTR3 2 Metrics: Query Complexity Complexity: 23 5

DEPENDENCIES
CALLERS
called by proc sybsystemprocs..sp_changegroup  
called by proc sybsystemprocs..sp_aux_computeprivs  
   called by proc sybsystemprocs..sp_table_privileges  
   called by proc sybsystemprocs..sp_column_privileges  
called by proc sybsystemprocs..sp_ijdbc_aux_computeprivs  
called by proc sybsystemprocs..sp_jdbc_computeprivs