MariaDB Connector/ODBC <-> Connector/C compatibility issue?

I’m working on a port of a product from Ubuntu 24.04 LTS to Rocky Linux 9.6. Among other things, the product is based on MariaDB 10.11.10, via the Connector/ODBC library. When I use the package manager (dnf) to install that release of the Mariadb server “devel” package I get version 3.2.6 of mariadb-connector-odbc as well as version 3.2.6 of mariadb-connector-c as a dependency. However, the release notes for that version of the ODBC connector say that it is built on version 3.4.5 of the C connector, which suggests that the package should include mariadb-connector-c-3.4.5 instead of the 3.2.6 release. I ask because building and testing the ported app (which runs flawlessly on Ubuntu) results in the following errors when it tries to execute the first ODBC SQLPrepare() call:

SQLSTATE: 42000, Native Error: 0
[ma-3.2.6][10.11.10-MariaDB]Syntax error or access violation

What little I could find in searches suggested a possible version mismatch between the two connector versions, which seems to make sense given the disparity between what the ODBC Connector release notes say about its C Connector dependency. Does this issue look familiar to anyone? And if so, am I at least barking up the correct tree with regard to a version mismatch?

P.S.

I’ve already verified, using the command-line utility connected using the same User that the application connects as, that the query being passed to SQLPrepare()…a simple “DO 1”…prepares and runs without error, so it is not a syntax error or access violation, despite the text of the error message.

Rocky is based on RHEL, and doesn’t have the 3.4.6 version. If the app was designed to run on Ubuntu, then it will need to be changed to run on Rocky. This means fixing the app to work with MariaDB 3.2.6 packages.

I think there’s some confusion. When I used dnf to install the MariaDB devel packages (using the default repos(s)) it installed mariadb-connector-odbc-3.2.6. As part of the same install it also installed mariadb-connector-c-3.2.6. But according to the MariaDB Release notes for Connector/ODBC 3.2.6…

“MariaDB Connector/ODBC 3.2.6 is built on top of MariaDB Connector/C v.3.4.5

(Note: I erroneously cited v3.4.6 in my original post.) So I AM trying to use the 3.2.6 Connector/ODBC package, but the release notes say that has a dependency on release 3.4.5 of Connector/C, even though the package installs 3.2.6 as the dependency. I’m just trying to determine if this is a package error or not, and if the runtime error I’m seeing is truly due to an internal (to MariaDB) library incompatibility. There is at this point no indication at all of any issue with the application itself having any sort of compatibility problems, nor requiring any changes as a result thereof.

First thing to remember is that 9.6 has two different types of MariaDB. Normal DNF and Stream. If you are using the stream version, show the exact commands you used.

For the server and dev package:

sudo dnf install mariadb-server mariadb-devel

For the ODBC connector dev package:

sudo dnf install mariadb-connector-odbc-devel

OK, can you show, as root or sudo
dnf list mariadb*

Here, with extraneous blank columns removed for readability:

So it looks like you are using the stream and module version; I don’t think you are supposed to have the ‘devel’ repo enabled (3rd column), and what’s with the double at sign followed by ‘commandline’, and you show two devel packages being installed above, but they are not showing as installed here?

That means they installed an rpm from the command line, not from a repository. Eg: downloaded manually and installed it.

That’s the bit that was worrying me, some oddball package that came from who knows where…

My apologies for the delayed response, but I was out-of-pocket all day yesterday. I do appreciate the responses.

It would appear that something was done without my knowledge that altered the original installation situation. So I uninstalled the ODBC and C Mariadb Connector packages and reinstalled them using:

sudo dnf install mariadb-connector-x.

The result is the following:

So I’m now using release 3.1.12 of the ODBC connector (which is fine for my purposes), which in turn is using release 3.2.6 of the C connector, which appears to be OK as well (the Connector/ODBC 3.1.12 release notes state that it is based on Connector/ODBC 3.1.12, with which I’m assuming 3.2.6 is backwards-compatible).

In any event, the exact same runtime error that prompted all this is still occurring, so either my backwards-compatibility assumption above is not valid, or the error is not in fact being caused by compatibility issues between the two connector libraries. So, back the old drawing board.

@iwalker @gerry666uk Problem resolved.

It turns out that somewhere along the line between the older version of MariaDB Connector/ODBC we’re using on Ubuntu 24.04 LTS and this newer one on Rocky 9.6, 2 changes were made that broke the existing application code:

  1. A call to SQLSetEnvAttr() to set the SQL_ATTR_ODBC_VERSION attribute is now mandatory prior to allocating a connection handle. The application did not contain such a call (as it was previously optional) which caused the failure on the SQLAllocHandle() call for the connection handle.
  2. Although MariaDB server still successfully prepares and executes the “DO 1” query via the command line and other non-ODBC interfaces, the Connector/ODBC parser now declares it to be invalid syntax and rejects it.

Adding the requisite call to SQLSetEnvAttr() and replacing the “DO 1” prepared statement with something like “DO @dummy=0” addresses both issues above, so the problem is now solved. Much thanks for the responses received.

1 Like