Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql proper API call

The page at https://dev.mysql.com/doc/c-api/9.2/en/mysql-use-result.html states:

When using mysql_use_result(), you must execute mysql_fetch_row() until a NULL value is returned, otherwise, the unfetched rows are returned as part of the result set for your next query. The C API gives the error Commands out of sync; you can't run this command now if you forget to do this!

However I plan to use another call to MYSQL on another thread using different MYSQL result set.

Will this work properly? Documentation does not say anything in this regards...

like image 551
Igor Avatar asked Oct 15 '25 03:10

Igor


1 Answers

No, you cannot use the same connection on two threads when using mysql_use_result, quoting Writing C API Threaded Client Programs

To use mysql_use_result(), you must ensure that no other thread uses the same connection until the result set is closed. However, it really is best for threaded clients that share the same connection to use mysql_store_result().

like image 98
Ahmed AEK Avatar answered Oct 17 '25 21:10

Ahmed AEK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!