[ODBC-103] ODBC not working on current stable debian Created: 2017-06-27  Updated: 2017-07-31  Resolved: 2017-07-31

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 3.0.0, 2.0.15
Fix Version/s: 3.0.0, 2.0.15

Type: Bug Priority: Major
Reporter: Nikolay Engyozov Assignee: Lawrin Novitsky
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

I'm trying to use MariaDB ODBC connector in Debian stretch (Debian doesn't provide mariadb odbc driver itself). I downloaded the last stable ODBC connector, version 2.0.15 from mariadb.com, extacted the library libmaodbc.so and configured
/etc/odbcinst.ini
[MariaDB ODBC 3.0 Driver]
Description = MariaDB driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so

/etc/odbc.ini:
[MariaDB-asterisk]
Description = MariaDB ODBC Driver
DSN = MariaDB-asterisk
Driver = MariaDB ODBC 3.0 Driver
Trace = Yes
TraceFile = /tmp/odbc.log
Socket = /var/run/asterisk/mysqld.sock
Server = 192.168.1.11
User = ******
Password = ******
Database = ********

isql fails to connect:

  1. isql MariaDB-asterisk -v
    [01000][unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so' : file not found
    [ISQL]ERROR: Could not SQLConnect

The file /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so exists and is readable so the problem is somewhere else.

Same happens with version 3.0 too.



 Comments   
Comment by Lawrin Novitsky [ 2017-06-27 ]

Thank you for your report.

What version did you download? "generic" or debian?

Probably some dependency is missing. Could you please verify which one?

If happens that all dependencies are in place, but could you also verify that the library is really 64bit?

Comment by Nikolay Engyozov [ 2017-06-28 ]

The problem occurs with stable 2.0.15 version for debian as well as alpha 3.0.0 version.
Building 2.0.15 version of libmaodbc.so from source doesn't change anything, same error happens.

ldd doesn't report missing library dependencies:

version 2.0.15 (debian):
ldd /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
linux-vdso.so.1 (0x00007ffee10b7000)
libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007f8692a9d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8692799000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f86923fa000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f86921f0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8691fd3000)
/lib64/ld-linux-x86-64.so.2 (0x0000557db2d5b000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8691dcd000)

varsion 3.0.0:
ldd /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
linux-vdso.so.1 (0x00007ffd39783000)
libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007f53e2c7b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f53e2977000)
libssl.so.1.0.0 => not found
libcrypto.so.1.0.0 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f53e25d8000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f53e23cc000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f53e21af000)
/lib64/ld-linux-x86-64.so.2 (0x000055c13225a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f53e1fab000)

Building version 3.0.0 from source fails with error:

In file included from /root/mariadb-connector-odbc-odbc-3.0/odbc_3_api.c:21:0:
/root/mariadb-connector-odbc-odbc-3.0/ma_odbc.h:377:3: error: unknown type name ‘MARIADB_CHARSET_INFO’
MARIADB_CHARSET_INFO *cs_info;
^~~~~~~~~~~~~~~~~~~~
In file included from /root/mariadb-connector-odbc-odbc-3.0/ma_odbc.h:458:0,
from /root/mariadb-connector-odbc-odbc-3.0/odbc_3_api.c:21:
/root/mariadb-connector-odbc-odbc-3.0/ma_string.h:41:60: error: unknown type name ‘MARIADB_CHARSET_INFO’
SQLLEN MbstrOctetLen(const char *str, SQLLEN *CharLen, MARIADB_CHARSET_INFO *cs);
^~~~~~~~~~~~~~~~~~~~
/root/mariadb-connector-odbc-odbc-3.0/ma_string.h:42:63: error: unknown type name ‘MARIADB_CHARSET_INFO’
SQLLEN MbstrCharLen(const char *str, SQLINTEGER OctetLen, MARIADB_CHARSET_INFO *cs);
^~~~~~~~~~~~~~~~~~~~
In file included from /root/mariadb-connector-odbc-odbc-3.0/ma_odbc.h:461:0,
from /root/mariadb-connector-odbc-odbc-3.0/odbc_3_api.c:21:
/root/mariadb-connector-odbc-odbc-3.0/ma_helper.h:39:69: error: unknown type name ‘MARIADB_CHARSET_INFO’
size_t MADB_GetDataSize(MADB_DescRecord *Record, MYSQL_FIELD Field, MARIADB_CHARSET_INFO *charset);
^~~~~~~~~~~~~~~~~~~~
/root/mariadb-connector-odbc-odbc-3.0/ma_helper.h:46:48: error: unknown type name ‘MARIADB_CHARSET_INFO’
size_t MADB_GetDisplaySize(MYSQL_FIELD field, MARIADB_CHARSET_INFO *charset);
^~~~~~~~~~~~~~~~~~~~
CMakeFiles/maodbc.dir/build.make:62: recipe for target 'CMakeFiles/maodbc.dir/odbc_3_api.c.o' failed
make[2]: *** [CMakeFiles/maodbc.dir/odbc_3_api.c.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/maodbc.dir/all' failed
make[1]: *** [CMakeFiles/maodbc.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Comment by Lawrin Novitsky [ 2017-06-28 ]

To build C/ODBC v3.0 from source, one needs MariaDB Connector/C v3.0, and for C/ODBC v2.0 - C/C v2.3
Sorry, that has to be checked on cmake level.

is that possible, that isql is 32bit? If file is in place, is not corrupt, and all dependencies are met - that doesn't make much sense why isql cannot load it. or did you also try it with you application?

Comment by Nikolay Engyozov [ 2017-06-28 ]

isql is part of unixodbc installed from official debian repository (64bit version):
unixodbc 2.3.4-1 amd64 Basic ODBC tools

I'm using ODBC to connect asterisk with mariadb. Asterisk segfaults when loading res_odbc module. Here is the relevant dmesg message:

asterisk[19594]: segfault at 8 ip 00007ff4aa1f3d8e sp 00007ffeae7823e0 error 4 in libmariadbclient.so.18.0.0[7ff4aa1ca000+37c000]

Comment by Lawrin Novitsky [ 2017-06-28 ]

c/odbc links c/c statically, and libmariadbclient.so.18.0.0 seems to be C client library from MariaDB server distribution. Thus you have 2 sets of mysql C API functions in your system, and that creates some mess.

Still not clear what is going on with isql. I am going to install stretch and try it myself.

And btw, 3.0 is of alpha quality, and pretty old release, that does not have fixed, that 2.0.15 has. Thus using it is not the best idea.

Comment by Lawrin Novitsky [ 2017-06-28 ]

I will appreciate if you share any new findings.

Comment by Nikolay Engyozov [ 2017-06-29 ]

A few more details on this:
-using the generic version of libmaodbc.so instead of debian one, worked for isql, but asterisk still crashes (it happens with libamariadbclient.so.18.0.0 still present)
-after removal of libmariadbclient and other mariadb libraries, now everything works fine - isql as well as asterisk, no matter if generic or debian version of libmaodbc.so is used

Thank you for your help!

Comment by Lawrin Novitsky [ 2017-06-29 ]

I am glad you could overcome your problems.
But it is still not clear what was going on with isql. And if in case of asterisk crash, I can imagine more or less what could cause it, isql case is not explained yet. I can't really close the bug report.

Could that happen because of file permissions, btw?
I could not repeat it so far. What exactly mariadb or mysql packages had you installed, and then removed?

And as for crash - I would appreciate if you uploaded here backtrace or dump for the crash.

Comment by Nikolay Engyozov [ 2017-07-18 ]

Sorry for the late reply but I was out of office for 2 weeks.
Unfortunately I cannot achieve the problem again - after installation of libmariadbclient18 isql and asterisk work fine with ODBC. I suppose there was some permissions problem before.
If you have idea what else to install or check for, let me know.

Comment by Lawrin Novitsky [ 2017-07-31 ]

I guess wrong file permissions is most probable cause here. Thus I am closing it as not a bug

Generated at Thu Feb 08 03:26:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.