diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 496ae461d2f..6409e7a4ef2 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3040,8 +3040,18 @@ reexecute: // Only one reprepare is required in case of parameter mismatch assert(!reprepared_for_types); reprepared_for_types = true; - if (reprepare(thd)) return true; - goto reexecute; + /** + * Infinite loop protection mechanism. + * + * When prepared statement parameter types mismatch, re-preparation should be triggered. + * However, if types still mismatch after re-preparation, it may lead to infinite loops. + * + * DEBUG mode: Assert failure to generate core dump for development debugging + * RELEASE mode: Return error code to ensure service stability + */ + assert(0); + my_error(ER_UNKNOWN_ERROR, MYF(0)); + return true; } reprepared_for_types = false;