[ODBC-386] Optimizing empty tables corrupts the MariaDB connection via ODBC Created: 2023-03-13  Updated: 2023-03-13  Resolved: 2023-03-13

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.17
Fix Version/s: 3.2.0, 3.1.18

Type: Bug Priority: Minor
Reporter: David Gausmann Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows 10 x64



 Description   

I am using the ODBC Connector on Windows with a VBScript like this:

Option Explicit
 
Dim oADO
 
Set oADO = CreateObject("ADODB.Connection")
Call oADO.Open("Driver={MariaDB ODBC 3.1 Driver};NAMEDPIPE=1;NO_PROMPT=1;SOCKET=myNamedPipe;USER=root;PASSWORD=myPassword")
On Error Resume Next
  Call oADO.Execute("DROP DATABASE `optimizetest`")
On Error GoTo 0
Call oADO.Execute("CREATE DATABASE `optimizetest`")
Call oADO.Execute("USE `optimizetest`")
Call AdoExecute("CREATE TABLE `table1` (id BIGINT NOT NULL AUTO_INCREMENT, name varchar(255) not null, PRIMARY KEY (id));")
Call AdoExecute("CREATE TABLE `table2` (id BIGINT NOT NULL AUTO_INCREMENT, name varchar(255) not null, PRIMARY KEY (id));")
Call AdoExecute("INSERT INTO `table1` (name) VALUES ('test');")
Call AdoExecute("OPTIMIZE TABLE `table1`;")
Call AdoExecute("OPTIMIZE TABLE `table2`;")
Call WScript.Echo("Finished")
 
Sub AdoExecute(ByVal sSQL)
  Call WScript.Echo(sSQL)
  Call oADO.Execute(sSQL)
End Sub

Unfortunately I get errors from the MariaDB driver when I am optimizing an empty table (table2 in the example).
The error message is:

Microsoft OLE DB Provider for ODBC Drivers: [ma-3.1.17][10.11.2-MariaDB]Unknown error

If I execute the same statement in HeidiSQL, then it works fine, but I get a notice that nothing has been done and I should recreate the table.
I guess the driver has problems due to this notice and then throws an error.

After you got this error, you cannot use the ADO connection anymore. You need to reconnect for further actions.



 Comments   
Comment by Lawrin Novitsky [ 2023-03-13 ]

I think your report is a duplicate of ODBC-378, it's been already fixed and closed. If you have doubts and/or would like to verify - you can build driver library from the current repo, or I can provide you the one. Btw, the error fixed in ODBC-378 would break the protocol and make the connection unusable as well

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