diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ce9cb9bd7..1eea1d5e9 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -4440,12 +4440,10 @@ handler_again: stmt_info=GloMyStmt->find_prepared_statement_by_stmt_id(CurrentQuery.stmt_global_id); CurrentQuery.QueryLength=stmt_info->query_length; CurrentQuery.QueryPointer=(unsigned char *)stmt_info->query; - // NOTE: Since 'first_comment' is part of the info used to - // compute 'stmt' hashes, it's required to be copied here. - // Not doing so will lead to a loop of 'PREPARE' and 'EXECUTE', - // since the correct prepared statement will never be found - // due to the missing information to compute the hash. - CurrentQuery.QueryParserArgs.first_comment=stmt_info->first_comment; + // NOTE: Update 'first_comment' with the the from the retrieved + // 'stmt_info' from the found prepared statement. 'CurrentQuery' requires its + // own copy of 'first_comment' because it will later be free by 'QueryInfo::end'. + CurrentQuery.QueryParserArgs.first_comment=strdup(stmt_info->first_comment); previous_status.push(PROCESSING_STMT_EXECUTE); NEXT_IMMEDIATE(PROCESSING_STMT_PREPARE); if (CurrentQuery.stmt_global_id!=stmt_info->statement_id) {