Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.2.2, 3.2.3
-
None
-
Arch Linux x86_64 running MariaDB 11.5.2 or 11.4.2
Description
When using prepared statements with SQLPrepare, the Prepared_stmt_count increases on MariaDB (when shown with SHOW GLOBAL STATUS LIKE 'Prepared_stmt_count'). It does not decrease when calling SQLFreeHandle(SQL_HANDLE_STMT, stmt) on the statement handle that was made as a prepared statement. Disconnecting and reconnecting, however, does lower the Prepared_stmt_count.
On long-lived connections or connections with many prepared statements, this can have the effect of throwing errors like:
STATE 42000: ODBC ECode 1461: EMsg [ma-3.2.2][11.4.2-MariaDB-log]Can't create more than max_prepared_stmt_count statements (current value: 16382)
Attached is a test program that demonstrates this.
Expected Output:
Initial - 0
After SQLExecDirect - 0
After SQLPrepare - 1
After SQLExecute - 1
After SQLCloseCursor - 1
After SQLFreeHandle - 0
After Reconnect - 0
Actual Output:
Initial - 0
After SQLExecDirect - 0
After SQLPrepare - 1
After SQLExecute - 1
After SQLCloseCursor - 1
After SQLFreeHandle - 1
After Reconnect - 0