mysql_store_result()@MySQL C API - 它是否真的在每个调用中分配内存?

时间:2010-03-05 03:39:13

标签: mysql c api

我已经读过MySQL C API中的mysql_store_result()将为每次调用分配内存;

mysql_store_result() reads the entire result of a query to the client, allocates a MYSQL_RES structure, and places the result into this structure.

真的是这样吗? 我问,因为我要在服务器应用程序中多次调用它。 为了我的目的,分配/释放是可怕的。

有没有办法为它提供自定义缓冲区?也许一些“未记录的”API?

2 个答案:

答案 0 :(得分:2)

请参阅以下有关使用mysql_use_result的链接: http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html

我在所有选择查询中使用“use_result”而不是“store_result”。

答案 1 :(得分:0)

是的,确实如此。为什么不呢?

也许您的意思是将您的问题编辑为“我该怎么办?”而不是“它真的如此吗?”根据您的意见,这似乎更像是您真正想知道的。