From 57160763af14ac3ff73d85bc1202312369601ace Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 15 Sep 2006 23:11:35 +0000 Subject: [PATCH] Fixed threaded queries not having an IQuery assignment --- dlls/mysqlx/basic_sql.cpp | 3 ++- dlls/mysqlx/threading.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dlls/mysqlx/basic_sql.cpp b/dlls/mysqlx/basic_sql.cpp index cff77756..dc3d70d2 100644 --- a/dlls/mysqlx/basic_sql.cpp +++ b/dlls/mysqlx/basic_sql.cpp @@ -377,7 +377,8 @@ static cell AMX_NATIVE_CALL SQL_FieldNumToName(AMX *amx, cell *params) static cell AMX_NATIVE_CALL SQL_GetQueryString(AMX *amx, cell *params) { AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query); - if (!qInfo) + + if (!qInfo || !qInfo->pQuery) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]); return 0; diff --git a/dlls/mysqlx/threading.cpp b/dlls/mysqlx/threading.cpp index 6c39e4e3..7bdf6cce 100644 --- a/dlls/mysqlx/threading.cpp +++ b/dlls/mysqlx/threading.cpp @@ -172,15 +172,13 @@ void MysqlThread::RunThread(IThreadHandle *pHandle) if (m_qrInfo.query_success && m_qrInfo.amxinfo.info.rs) { m_atomicResult.CopyFrom(m_qrInfo.amxinfo.info.rs); - m_qrInfo.amxinfo.pQuery = NULL; + m_qrInfo.amxinfo.pQuery = pQuery; m_qrInfo.amxinfo.info.rs = &m_atomicResult; - } - - if (pQuery) - { + } else { pQuery->FreeHandle(); pQuery = NULL; } + if (pDatabase) { pDatabase->FreeHandle(); @@ -248,6 +246,11 @@ void MysqlThread::Execute() (cell)0, data_addr, m_datalen); + /* this should always be true I think */ + if (m_qrInfo.amxinfo.pQuery) + { + m_qrInfo.amxinfo.pQuery->FreeHandle(); + } FreeHandle(hndl); } }