Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Not a Bug
-
Affects Version/s: 10.0.15
-
Fix Version/s: N/A
-
Component/s: Storage Engine - Connect
-
Labels:
-
Environment:CentOS 7
Description
I have been attempting to try out using the CONNECT storage engine to connect to MS SQL Server via MariaDB 10.0 on CentOS 7.
I did the following to set up the environment:
#Install EPEL sudo rpm -ivh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm #Install unixODBC sudo yum install unixODBC unixODBC-devel #Install FreeTDS sudo yum install freetds freetds-devel #Install and load CONNECT sudo yum install MariaDB-connect-engine mysql -u root --execute="INSTALL SONAME 'ha_connect';"
Then I created the two files tds.driver.template and tds.datasource.template.
tds.driver.template
[FreeTDS]
Description = ODBC for TDS protocol
Driver = /usr/lib64/libtdsodbc.so
tds.datasource.template
[connect_test] Driver = FreeTDS Description = MSSQL Server Trace = No Server = 192.168.1.12 Database = connect_test Port = 1433 TDS_Version = 7.1
And executed:
#Install FreeTDS Driver for ODBC sudo odbcinst -i -d -f tds.driver.template #Install data source for ODBC sudo odbcinst -i -s -l -f tds.datasource.template
Everything appears to work via ODBC's isql client:
[gmontee@localhost ~]$ isql connect_test sa 'password' +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> SELECT * FROM dbo.test_table; +------------+---------------------------------------------------+ | a | b | +------------+---------------------------------------------------+ +------------+---------------------------------------------------+ SQLRowCount returns 0 SQL> INSERT INTO dbo.test_table VALUES(1, 'correct'); SQLRowCount returns 1 SQL> INSERT INTO dbo.test_table VALUES(2, 'horse'); SQLRowCount returns 1 SQL> INSERT INTO dbo.test_table VALUES(3, 'battery'); SQLRowCount returns 1 SQL> SELECT * FROM dbo.test_table; +------------+---------------------------------------------------+ | a | b | +------------+---------------------------------------------------+ | 1 | correct | | 2 | horse | | 3 | battery | +------------+---------------------------------------------------+ SQLRowCount returns 3 3 rows fetched
However, connecting to the same data source with CONNECT doesn't work. I've tried the following different table options:
-- DSN
-- fields not specified
-- schema qualified in TABNAME
CREATE TABLE test_table
ENGINE=CONNECT
TABLE_TYPE=ODBC
TABNAME='dbo.test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN
-- fields not specified
-- schema in DBNAME
CREATE TABLE test_table
ENGINE=CONNECT
TABLE_TYPE=ODBC
DBNAME='dbo'
TABNAME='test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN
-- fields not specified
-- use default schema
CREATE TABLE test_table
ENGINE=CONNECT
TABLE_TYPE=ODBC
TABNAME='test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN
-- fields specified
-- schema qualified in TABNAME
CREATE TABLE test_table (
a int,
b varchar(50)
)
ENGINE=CONNECT
TABLE_TYPE=ODBC
TABNAME='dbo.test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN
-- fields specified
-- schema in DBNAME
CREATE TABLE test_table (
a int,
b varchar(50)
)
ENGINE=CONNECT
TABLE_TYPE=ODBC
DBNAME='dbo'
TABNAME='test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN
-- fields specified
-- use default schema
CREATE TABLE test_table (
a int,
b varchar(50)
)
ENGINE=CONNECT
TABLE_TYPE=ODBC
TABNAME='test_table'
CONNECTION='DSN=connect_test;UID=sa;PWD=password';
-- DSN-less
-- fields specified
-- schema qualified in TABNAME
CREATE TABLE test_table (
a int,
b varchar(50)
)
ENGINE=CONNECT
TABLE_TYPE=ODBC
TABNAME='dbo.test_table'
CONNECTION='DRIVER=FreeTDS;Server=192.168.1.12;Port=1433;TDS_Version=7.1;Database=connect_test;UID=sa;PWD=password';
They all return the same vague error when attempting to connect:
ERROR 1296 (HY000): Got error 174 '[unixODBC][FreeTDS][SQL Server]Unable to connect to data source' from CONNECT
I am using MS SQL Server Express 2012 which can be downloaded for free.
Considering how many components are in play here (SQL Server, FreeTDS, unixODBC, CONNECT, MariaDB), there's a good chance I'm missing an option, but I'm not sure what that would be.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
I got ODBC logging to work. isql and CONNECT appear to be using different mechanisms to connect to the data source.
isql's trace log (connecting via SQLConnect.c):
[ODBC][5693][1422469905.334248][__handles.c][460] Exit:[SQL_SUCCESS] Environment = 0x1e39750 [ODBC][5693][1422469905.334334][SQLAllocHandle.c][375] Entry: Handle Type = 2 Input Handle = 0x1e39750 [ODBC][5693][1422469905.334373][SQLAllocHandle.c][493] Exit:[SQL_SUCCESS] Output Handle = 0x1e3a050 [ODBC][5693][1422469905.334414][SQLConnect.c][3700] Entry: Connection = 0x1e3a050 Server Name = [connect_test][length = 12 (SQL_NTS)] User Name = [sa][length = 2 (SQL_NTS)] Authentication = [********][length = 8 (SQL_NTS)] UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' [ODBC][5693][1422469905.366705][SQLConnect.c][4273] Exit:[SQL_SUCCESS]And CONNECT's trace log (connecting via SQLDriverConnect.c):
[ODBC][2474][1422469178.558581][__handles.c][460] Exit:[SQL_SUCCESS] Environment = 0x7ffdad374c00 [ODBC][2474][1422469178.558675][SQLAllocHandle.c][375] Entry: Handle Type = 2 Input Handle = 0x7ffdad374c00 [ODBC][2474][1422469178.558714][SQLAllocHandle.c][493] Exit:[SQL_SUCCESS] Output Handle = 0x7ffda6b74000 [ODBC][2474][1422469178.558755][SQLSetConnectOption.c][345] Entry: Connection = 0x7ffda6b74000 Option = SQL_ATTR_LOGIN_TIMEOUT Value = 15 [ODBC][2474][1422469178.558791][SQLSetConnectOption.c][508] Exit:[SQL_SUCCESS] [ODBC][2474][1422469178.558828][SQLSetConnectOption.c][345] Entry: Connection = 0x7ffda6b74000 Option = SQL_ATTR_ACCESS_MODE Value = 1 [ODBC][2474][1422469178.558859][SQLSetConnectOption.c][508] Exit:[SQL_SUCCESS] [ODBC][2474][1422469178.558900][SQLDriverConnect.c][726] Entry: Connection = 0x7ffda6b74000 Window Hdl = 0x1 Str In = [DSN=connect_test;UID=sa;PWD=********][length = 36 (SQL_NTS)] Str Out = 0x7ffd92800090 Str Out Max = 512 Str Out Ptr = 0x7ffdc285ea50 Completion = 0 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' DIAG [08S01] [FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to data source [ODBC][2474][1422469178.585108][SQLDriverConnect.c][1353] Exit:[SQL_ERROR]