OS:windows2000
执行以下过程(4条语句)
mysql_real_connect
mysql_prepare
//测试,去掉中间过程
mysql_stmt_close
mysql_close()//每次执行到这条语句的时候,mysql服务总是占到100%cpu,谢谢!
执行以下过程(4条语句)
mysql_real_connect
mysql_prepare
//测试,去掉中间过程
mysql_stmt_close
mysql_close()//每次执行到这条语句的时候,mysql服务总是占到100%cpu,谢谢!
如果不用mysql_prepare()不会出现cpu100%的情况。
就加了这个函数才倒致的。
楼上有试过加这个函数试过吗?测试代码如下:
int main()
{
MYSQL* m_pData = mysql_init((MYSQL*) 0);
if(!m_pData)
return FALSE;
if(!mysql_real_connect( m_pData, NULL,"root","","test", MYSQL_PORT,NULL, 0 ) )
return false;
const char* szSql = "select col1 from test;";
//以下两行去掉,一切正常
MYSQL_STMT* m_pStmt = mysql_prepare(m_pData, szSql, strlen(szSql));
if (m_pStmt)
mysql_stmt_close(m_pStmt); mysql_close( m_pData ) ;
//执行完这条,cpu100%
return 0;
}
Given the statement handle returned by mysql_stmt_init(), prepares the SQL statement pointed to by the string query and returns a status value. The string length should be given by the length argument. The string must consist of a single SQL statement. You should not add a terminating semicolon (`;') or \g to the statement.
Create a MYSQL_STMT handle. This function was added in MySQL 4.1.2. Return values
A pointer to a MYSQL_STMT structure in case of success. NULL if out of memory.