DatabaseProcApplicationCreatedLinks
sybsystemprocssp_jdbc_getxacoordinator  14 déc. 14Defects Propagation Dependencies

1     
2     /* end of dbo.sp_jdbc_getattributes */
3     
4     
5     
6     /* Don't delete the following line. This is where sp_jdbc_getxacoordinator gets inserted. */
7     /*** ADDPOINT_JTA ***/
8     /*
9     ** JDBC 2.0 extensions (JTA support)
10    ** 
11    ** SybDatabaseMetaData.getXACoordinatorType()
12    ** 
13    ** returns a resultset of the form:
14    ** TxnStyle (indicating which transaction coordinator is being used.
15    ** 0 means none.
16    **
17    ** RequiredRoles (indicates what role the user must have to use)
18    ** NULL means none.
19    **
20    ** Status (a bitmask of capabilities that the coordinator provides)
21    ** 0x00000001 - set if user has necessary role
22    ** 0x00000002 - set if txns can migrate among connections
23    ** 0x00000004 - set if multiple connections can participate in same txn simultaneously
24    **
25    ** UniqueID (a string which uniquely identifies this server)
26    */
27    create or replace procedure sp_jdbc_getxacoordinator
28    as
29    
30        declare @txnMode int
31        declare @status int
32        declare @uniqueID varchar(12)
33        declare @curvalue int
34        declare @sqlCurValue varchar(200)
35        /* For 12.0 and higher, jConnect expects to use DTM001. */
36        /* DTM001 is defined as 2 in SybDataSource.RMTYPE_ASE_XA_DTM. */
37        /* Users must have dtm_tm_role to use DTM.   */
38        /* Next, determine whether or not user has */
39        /* dtm_tm_role when setting the status bits. */
40        /* Lastly, return the unique ID for this resource. */
41    
42        /* verify that the 15.0 server is configured for XA using DTM */
43    
44        select @sqlCurValue = 'select @curvalue=cur.value from master.dbo.syscurconfigs cur, master.dbo.sysconfigures conf
45         where conf.comment = ''enable DTM'' and cur.config = conf.config '
46        /* The columns syscurconfigs.instanceid is present only if server is in sdc mode'*/
47        if (@@clustermode = 'shared disk cluster')
48        begin
49            select @sqlCurValue = @sqlCurValue + 'and cur.instanceid=@@instanceid'
50        end
51    
52        execute (@sqlCurValue)
53    
54        if (@curvalue != 0)
55        begin
56            /* verify that the 12.0 server is licensed for XA using DTM */
57            if (license_enabled('ASE_DTM') = 1)
58            begin
59                select @txnMode = 2
60            end
61        end
62        else
63        begin
64            select @txnMode = 0
65        end
66    
67        /* now check for role permission */
68        if (charindex('dtm_tm_role', show_role()) != 0)
69        begin
70            select @status = 7
71        end
72        else
73        begin
74            select @status = 6
75        end
76    
77        /* return results and name the columns */
78        select TxnStyle = @txnMode, RequiredRole = 'dtm_tm_role', Status = @status, UniqueID = @@nodeid
79    


exec sp_procxmode 'sp_jdbc_getxacoordinator', 'AnyMode'
go

Grant Execute on sp_jdbc_getxacoordinator to public
go
RESULT SETS
sp_jdbc_getxacoordinator_rset_001

DEFECTS
 VRUN 4 Variable is read and not initialized @curvalue 54
 MDYN 3 Proc uses Dynamic SQL but is not flagged with Dynamic Ownership Chain 27
 MGTP 3 Grant to public sybsystemprocs..sp_jdbc_getxacoordinator  
 MUCO 3 Useless Code Useless Brackets 47
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 57
 MUCO 3 Useless Code Useless Brackets 68
 VUNU 3 Variable is not used @uniqueID 32
 MDYS 2 Dynamic SQL Marker 52
 MRST 2 Result Set Marker 78
 MTR1 2 Metrics: Comments Ratio Comments: 53% 27
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 6 = 5dec - 1exi + 2 27
 MTR3 2 Metrics: Query Complexity Complexity: 22 27

DEPENDENCIES
PROCS AND TABLES USED
writes table sybsystemprocs..sp_jdbc_getxacoordinator_rset_001