DatabaseProcApplicationCreatedLinks
sybsystemprocssp_jdbc_getxacoordinator  31 Aug 14Defects Dependencies

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


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 51
 MDYN 3 Proc uses Dynamic SQL but is not flagged with Dynamic Ownership Chain 24
 MGTP 3 Grant to public sybsystemprocs..sp_jdbc_getxacoordinator  
 MUCO 3 Useless Code Useless Brackets 44
 MUCO 3 Useless Code Useless Brackets 51
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 65
 VUNU 3 Variable is not used @uniqueID 29
 MDYS 2 Dynamic SQL Marker 49
 MRST 2 Result Set Marker 75
 MTR1 2 Metrics: Comments Ratio Comments: 58% 24
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 4dec - 1exi + 2 24
 MTR3 2 Metrics: Query Complexity Complexity: 22 24

DEPENDENCIES