I've been trying to migrate a Foxpro application from MySQL ODBC connector to MariaDB ODBC connector.
While I've been testing the new connector, I found that every COUNT(*) field in SQL queries is being created in the cursors as a Char fields (instead of a Numeric field).
I've been reviewing the connector settings, the server settings, comparing server settings between the development server and a MariaDB-XAMPP local server, to no avail. And, where I have a number being expected, since the SQL query returns a char, I get a "Data Type Mismatch" error.
Here is the minimal example that makes COUNT(*) return strings
LOCAL cConnectionString
&&string is for default XAMPP MariaDB Server
cConnectionString ="Driver={MariaDB ODBC 3.1 Driver};SERVER=localhost;UID=root;DB=mydb;PORT=3306;OPTION=3"
nOpt="3"
* Establish the ODBC connection and return if fails
lnConnection = SQLStringConnect(cConnectionString)
cSQLQuery = "SELECT COUNT(id) as myCount from mytable"
lnResult = SQLEXEC(lnConnection, cSQLQuery, "mycursor")
IF lnResult > 0
select mycursor
typeOfCount=VARTYPE(mycursor.myCount)
msg="MyCount vartype (expected N): "+typeOfCount+" ["+ALLTRIM(mycursor.myCount)+"] - Option: "+nOpt &&No STR() needed, its already a string
MESSAGEBOX(msg)
ELSE
MESSAGEBOX("Error executing SQL query:"+MESSAGE())
ENDIF
SQLDISCONNECT(lnConnection)
RETURN &&End the program
1.- I tried options from 1 to 332987 (throught a loop, no results, VARTYPE(myCount) was C all the time) 2.- I tried changing server configuration to be the same as one server which returned good results with MySQL ODBC (throught a function to set every global variable, no results). 3.- I Tried converting using COUNT(*)/1 syntax and this convertion works, but, per documentation, COUNT returns a bigint, not a char. Also, in application code, there are a lot of COUNTs. I found out Foxpro does not support bigints (like the ones in COUNT). I found in here: text That I can do something like this: DBSetProp("rv_view.bigintfield", "Field", "Datatype", "N(19)") What would be the Prop to disable bigints in MariaDB ODBC?
4.- In previous configuration, the MySQL ODBC Driver had an "OPTIONS=16387", and that includes converting bigints as ints. Is there a flag to do the same convertion in MariaDB ODBC Driver?
5.- I also traced both ODBC Drivers (MySQL ODBC / MariaDB ODBC), whats odd from there is, the SQLDescribeCol's SWORD value for column datatype parameter in MySQL ODBC is 4, and -5 in MariaDB ODBC. Maybe this is a bug in MariaDB ODBC Driver being unable to detect bigints?