MySQL Forums
Forum List  »  Connector/ODBC

Re: 8.0.24 connector odbc breaks previously working queries
Posted by: Bogdan Degtyariov
Date: May 20, 2021 06:03PM

First of all, the sequence COM_STMT_PREPARE/COM_STMT_EXECUTE and the appearance of PREPARE/EXECUTE in the general query log is caused by your program calling SQLPrepare()/SQLExecute() ODBC functions. In other words, it explicitly requested not to run COM_QUERY right away, but first prepare the statement.

In previous versions the driver would check if the query contained any parameter markers '?' and then decide not to PREPARE/EXECUTE, but do QUERY if no parameter markers were detected.

However, this would lead to inefficiency and decreased performance if the same SQL is to be executed as QUERY each time. The client needs to send the SQL each time and the server will parse it each time. With PREPARE/EXECUTE the query is only sent once upon SQLPrepare() and the server has to parse it only once. Then SQLExecute() can send a short COM_STMT_EXECUTE and the server already has the corresponding statement parsed and prepared, which is many times faster with SQL that runs repeatedly.

If you wish to ensure using of COM_QUERY your program needs to call SQLExecDirect() function instead of SQLPrepare()/SQLExecute() pair.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.