markuman / mex-mariadb

MariaDB Client for GNU Octave (maybe this is compatible for MySQL and Matlab too)
MIT License
2 stars 0 forks source link

Octave 5.2 @ Ubuntu 20.04: "Port must be a double error", although port IS numeric #2

Closed Schinzilord closed 3 years ago

Schinzilord commented 3 years ago

Hi Markuman,

many thanks for your project, really nice and easy! Compilation and running your code was easily possible with Ubuntu 18.04 + Octave 4.4, but after upgrading to Ubuntu 5.2 + Octave 5.2 I encounted the following problem:

Compilation of the mex file was possible (I used your command), but after setting up a database connection incl. username, passwort and port (3306) the following error was shown: "Error setting up mariadb connection: Port must be a double."

I could somehow trace it down to the if condition, where the type of prhs[PORT] is determined by mxIsDouble function. After a brutal hack I could fix it:

// get port
    // convert port to double
    double* tmpvar;
    tmpvar = 0.0 + mxGetPr(prhs[PORT]);

    if ( mxIsDouble(tmpvar) ) {
        // convert double to integer :: PORT
        double* data = tmpvar; //mxGetPr(prhs[PORT]);
        port = (int)floor(data[0]);
        #ifdef DEBUG
            mexPrintf("Port: %d\n", port);
        #endif
      } else {
        mexErrMsgIdAndTxt("MATLAB:mariadb:nrhs", "Error setting up mariadb connection: Port must be a double.");
    }

Maybe this helps other people or you can fix it properly. If have no idea on the root cause, but maybe this has something to do with the g++ compiler used in Octave 5.2 or with the mex file generation. Best, Stefan

markuman commented 3 years ago

@Schinzilord thx for the report.
There are already integrationtests against octave 4,5 and 6.
So I guess something has changed on the mariadb library part.

The port musst be simply changed to a double

I will check it next days if it is compatible with older mariadb connectors.

Can you tell me what's your mariadb connector library version you are using?

but after upgrading to Ubuntu 5.2 + Octave 5.2

You mean ubuntu 20.04 oder 20.10?

Schinzilord commented 3 years ago

Thanks for coming back so quickly and sorry for the confusion! Was quite late yesterday... I am currently running Linux Mint 20 based on Ubuntu 20.04 release. Mariadb connector: libmariadb-dev-compat Version: 1:10.3.25-0ubuntu0.20.04.1 g++: Version: 4:9.3.0-1ubuntu2

I also tried to compile it with Octave 6.1.0, and there my hack above also did not work out, I had to remove the outer if condition entirely. However, the Octave method is ensuring that the port is numeric in any case.

So to sum up, both Octave 5.2.0 and 6.1.0 running on Linux Mint 20 (Ubuntu 20.04) throw the above error on compilation.

Best, Stefan

markuman commented 3 years ago

Ok, I'm wrong.
The error message you've seen is made by my mex function :)

https://mariadb.com/kb/en/configuring-mariadb-connectorc-with-option-files/#port
The port must be INT.

I've added a ubuntu 20.04 integration test which pass

So the integrationtest file works.

How does your connection string looks like?

So to sum up, both Octave 5.2.0 and 6.1.0 running on Linux Mint 20 (Ubuntu 20.04) throw the above error on compilation.

On compilation? I thought on trying to connect?

markuman commented 3 years ago

I've reworked the integrationtests: https://gitlab.com/markuman/mex-mariadb/-/pipelines/225721071
they all pass - even with octave 6. It is marked as failed, because mUnittest does not seem to be compatible with octave 6 anymore.
So I'm a bit lost in what error you exactly run.

Schinzilord commented 3 years ago

Sorry for that confusion.

I tried to reproduce the error messages with starting from scratch and compiled the mex sources again. Now everything is working as expected, both on Octave 5.2.0 and Octave 6.1.0.

I do not know what happened yesterday, but cannot rule out user error :)

So thanks for your effort and sorry for wasting your time! Best, Stefan