[ODBC-378] OPTIMIZE TABLE returns no resultset Created: 2023-01-12  Updated: 2023-03-08  Resolved: 2023-03-08

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.12
Fix Version/s: 3.1.18

Type: Bug Priority: Major
Reporter: Callum Walker Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

AlmaLinux 8.7
MariaDB connector ODBC 3.1.12
MariaDB 10.3.35



 Description   

When using the ODBC connector to run an OPTIMIZE TABLE query no resultset is returned, subsequent queries to the database then result in an "Unknown MySQL error".

When using isql with MariaDB connector ODBC 3.1.12

SQL> SELECT object_id FROM bc_bcde_index.object LIMIT 1;
+-----------+
| object_id |
+-----------+
| 1         |
+-----------+
SQLRowCount returns 1
1 rows fetched
SQL> OPTIMIZE TABLE bc_bcde_index.object;
SQLRowCount returns 0
SQL> SELECT object_id FROM bc_bcde_index.object LIMIT 1;
[S1000][ma-3.1.12][10.3.35-MariaDB]Unknown MySQL error
[ISQL]ERROR: Could not SQLPrepare

When using isql with MySQL Connector/ODBC 8.0.31

SQL> SELECT object_id FROM bc_bcde_index.object LIMIT 1;
+------------+
| object_id  |
+------------+
| 1          |
+------------+
SQLRowCount returns 1
1 rows fetched
SQL> OPTIMIZE TABLE bc_bcde_index.object;
+---------------------------------------------------------------------------------------------------------------------------------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table                                                                                                                           | Op        | Msg_type  | Msg_text                                                                                                                                                                                                                                                                                                    |
+---------------------------------------------------------------------------------------------------------------------------------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| bc_bcde_index.object                                                                                                            | optimize  | note      | Table does not support optimize, doing recreate + analyze instead                                                                                                                                                                                                                                           |
| bc_bcde_index.object                                                                                                            | optimize  | status    | OK                                                                                                                                                                                                                                                                                                          |
+---------------------------------------------------------------------------------------------------------------------------------+-----------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 2
2 rows fetched
SQL> SELECT object_id FROM bc_bcde_index.object LIMIT 1;
+------------+
| object_id  |
+------------+
| 1          |
+------------+
SQLRowCount returns 1
1 rows fetched

ANALZYE TABLE does not result in the same issue.



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

Thank you for the report! The fix has been pushed to the master branch

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