• Jon Olav Hauglid's avatar
    Bug #54106 assert in Protocol::end_statement, · d62bfebc
    Jon Olav Hauglid authored
               INSERT IGNORE ... SELECT ... UNION SELECT ...
    
    This assert was triggered by INSERT IGNORE ... SELECT. The assert checks that a
    statement either sends OK or an error to the client. If the bug was triggered
    on release builds, it caused OK to be sent to the client instead of the correct
    error message (in this case ER_FIELD_SPECIFIED_TWICE).
    
    The reason the assert was triggered, was that lex->no_error was set to TRUE
    during JOIN::optimize() because of IGNORE. This causes all errors to be ignored.
    However, not all errors can be ignored. Some, such as ER_FIELD_SPECIFIED_TWICE
    will cause the INSERT to fail no matter what. But since lex->no_error was set,
    the critical errors were ignored, the INSERT failed and neither OK nor the
    error message was sent to the client.
    
    This patch fixes the problem by temporarily turning off lex->no_error in
    places where errors cannot be ignored during processing of INSERT ... SELECT.
    
    Test case added to insert.test.
    d62bfebc
sql_select.cc 548 KB