db.mysql query
and real_query
with ConnectionFlag.client_multi_statements
makes the Connection
instance useless
#18061
Labels
Bug
This tag is applied to issues which reports bugs.
Describe the bug
When creating a
mysql.Connection
using theConnectionFlag.client_multi_statements
, executing a query with multiple statements returns multiple resoluts.The mysql wrapper lacks the ability to fetch all the results, because it does not wrap mysql_more_results() nor mysql_next_result().
Because these results aren't fetched, they remain allocated and the connection cannot be reused for any new statement without triggering a
V panic: Commands out of sync; you can't run this command now; code: 2014
This problem forces to create independent connections whenever a query with multiple statements needs to be run.
Expected Behavior
Results should be able to be fetched and memory cleared.
The execution of a new query in the same connection should be possible.
Current Behavior
V panic: Commands out of sync; you can't run this command now; code: 2014
Reproduction Steps
file_data := os.read_file(file_path)!
mysql_conn.real_query(file_data)!
// Here one would loop through all results until no more results are available
// and then call mysql_free_result()
mysql_conn.real_query(query_string)!
Possible Solution
Wrap mysql_more_results() nor mysql_next_result().
Ideally the functions available already should include these functions and return an array of results instead, calling
mysql_free_result()
automatically. This is becausemysql_free_result()
requires anunsafe
block which is no good for basic V users.Additional Information/Context
No response
V version
Current V version: V 0.3.3 0a8a0fd, timestamp: 2023-03-25 14:38:47 +0200
Environment details (OS name and version, etc.)
The text was updated successfully, but these errors were encountered: