[MDEV-12973] CONNECT Engine table_type=JDBC CATFUNC=TABLES w/Microsoft JDBC driver not working Created: 2017-06-01  Updated: 2017-08-11  Resolved: 2017-06-13

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.1.24
Fix Version/s: 10.1.26, 10.0.32, 10.2.8

Type: Bug Priority: Major
Reporter: Robert Dyas Assignee: Olivier Bertrand
Resolution: Fixed Votes: 0
Labels: None
Environment:

centOS7 on Google Compute Engine



 Description   

When using CONNECT engine with table_type=JDBC and CATFUNC=TABLES and the official Microsoft JDBC driver (latest v6 for jre 8 environment) the list of tables comes back (there are multiple rows) but all the table names are blank.

The test case:

CREATE OR REPLACE TABLE parasql_connect_tables
ENGINE=CONNECT 
TABLE_TYPE=JDBC 
CATFUNC=TABLES  
CONNECTION='jdbc:sqlserver://parasqleu.database.windows.net:1433;databaseName=ParaSQL;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=15;' 
OPTION_LIST='USER=parasqleu,PASSWORD=WillProvidePassInPrivateMessage,MEMORY=3,DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver' 
QUOTED=1  
 
select * from  parasql_connect_tables
 
[results below are tab separated, only Table_Type is not blank]
 
Table_Cat	Table_Schema	Table_Name	Table_Type	Remark
			                             TABLE	
			                             TABLE	
			                             TABLE	
			                             VIEW	
			                             VIEW	

And similar for CATFUNC=COLUMNS if I manually specify a valid table on the remote server:

CREATE OR REPLACE TABLE parasql_connect_columns 
ENGINE=CONNECT 
TABLE_TYPE=JDBC 
CATFUNC=COLUMNS 
TABNAME='customerNew'  
CONNECTION='jdbc:sqlserver://parasqleu.database.windows.net:1433;databaseName=ParaSQL;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=15;' 
OPTION_LIST='USER=parasqleu,PASSWORD=WillProvidePassInPrivateMessage,MEMORY=3' 
QUOTED=1 

select * from  parasql_connect_columns 
 
[results below, Data_Type etc are filled in but the first 4 columns are not]
 
Table_Cat	Table_Schema	Table_Name	Column_Name	Data_Type	Type_Name	Column_Size	Buffer_Length	Decimal_Digits	Radix	Nullable	Remarks
				4		10	4	0	10	1	
				12		30	30	0	0	1	
				91		10	6	0	0	1	
				93		23	16	3	0	1	

The latest Microsoft JDBC driver can be downloaded here:
https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

NOTE: To ease testing, I can provide the password for the above Microsoft server in a private message so you don't have to set up an environment to test.

Thank you.



 Comments   
Comment by Robert Dyas [ 2017-06-02 ]

I've created a simple java command line program that you can compile and test - it produces the CORRECT output, so something must be strange with how CONNECT is doing it.

import java.sql.*;
public class ListTables {
  public static void main(String [] args) {
    Connection con = null;
    try {
      con = DriverManager.getConnection("jdbc:sqlserver://parasqltest.database.windows.net:1433;database=test6;user=testuser1@parasqltest;password=AskForPassword;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;");
 
      DatabaseMetaData meta = con.getMetaData();
 
      ResultSet res = meta.getTables(null, null, null,  null);
 
      System.out.println("List of tables: ");
      while (res.next()) {
         System.out.println(
            "   "+res.getString("TABLE_CAT")
           + ", "+res.getString("TABLE_SCHEM")
           + ", "+res.getString("TABLE_NAME")
           + ", "+res.getString("TABLE_TYPE")
           + ", "+res.getString("REMARKS"));
      }
 
      res.close();
 
      con.close();
 
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

complile:
javac ListTables.java

run:
java -cp .:/path/to/sqljdbc42.jar ListTables

produces out like this (CORRECT):

List of tables: 
   test6, dbo, rob_test, TABLE, null
   test6, dbo, rob_test_vendor, TABLE, null
   test6, sys, trace_xe_action_map, TABLE, null
   test6, sys, trace_xe_event_map, TABLE, null
   test6, INFORMATION_SCHEMA, CHECK_CONSTRAINTS, VIEW, null

For some reason in CONNECT, the first 3 columns are blank.

Comment by Robert Dyas [ 2017-06-09 ]

Olivier,

Will your fix for table names & column names make it into 10.1.25?

Comment by Olivier Bertrand [ 2017-06-10 ]

I pushed the fix. Whether or not it is included in the distribution of the next versions does not depend on me.

Comment by Robert Dyas [ 2017-06-13 ]

I was just wondering since the Status for this one is still showing Open rather than Confirmed, In Progress or Fixed (or whatever the right status is).

Comment by Olivier Bertrand [ 2017-06-13 ]

I just forgot to close it!

Comment by Robert Dyas [ 2017-07-05 ]

I just installed 10.1.25 and this fix is NOT included in that release
We really need this fix.

Was it not included by accident or on purpose? I noticed the change log for 10.1.25 did not list MDEV-12973 either.

Comment by Olivier Bertrand [ 2017-07-05 ]

Surely not on purpose. But I had confirmation that CONNECT changes had not been included in Version 10.1.25... by accident?

Comment by Robert Dyas [ 2017-07-12 ]

Just saw that this is not listed as fixed in the 10.2.7 Changelog.

Strange... it looks like other CONNECT changes were included in 10.2.7 but not this one... any idea why not included?

Comment by Sergei Golubchik [ 2017-07-14 ]

Sorry for this. Because of a merge mistake this fix didn't end up in 10.2.7, it'll only be in 10.2.8.

Comment by Robert Dyas [ 2017-08-11 ]

Is this now actually included in 10.1.26 ?
It is not listed in the change log nor the release notes.

Comment by Robert Dyas [ 2017-08-11 ]

OK, initial testing of NVARCHAR is working, so I guess the changes were integrated just not listed in the change log. Pretty big change not to list!

Comment by Olivier Bertrand [ 2017-08-11 ]

There has been a git problem in the change log that caused it to be lost. However hopefully all the recent fixes should be included.

Generated at Thu Feb 08 08:01:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.