• unknown's avatar
    Remove net_printf_error(). Do not talk to network directly in · 28c15316
    unknown authored
    check_user()/check_connection()/check_for_max_user_connections().
    
    This is a pre-requisite patch for the fix for Bug#12713 "Error in a stored 
    function called from a SELECT doesn't cause ROLLBACK of statem"
    
    Implement review comments.
    
    
    sql/mysql_priv.h:
      check_for_max_user_connections() is used in one place only, make it static.
    sql/mysqld.cc:
      Remove net_printf_error(): a consolidation of error reporting facilities
      is necessary to simplify maintenance of the query cache, the 
      client-server protocol, stored procedure continue handlers. 
      Rewrite the only place where its use is somewhat justified 
      (my_error() can not be used since we need to report an error for the thread 
      that does not exist) with my_snprintf()/net_send_error().
    sql/protocol.cc:
      Remove net_printf_error().
    sql/protocol.h:
      Remove net_printf_error().
    sql/sql_connect.cc:
      Remove net_printf_error(). In check_connection()/check_user()/
      check_for_max_user_connections() do not write directly to the network,
      but use the standard my_error() mechanism to record an error in THD.
      It will be sent to the client by the caller. This was the last place
      in the server that would attempt to send an error directly, mainly left 
      untouched by 5.0 refactoring because it is executed only during 
      thread startup.
    sql/sql_parse.cc:
      In the old code, when res was greater than 0, it contained an exact 
      error code, e.g. ER_OUT_OF_RESOURCES or NO SUCH DATABASE, 
      or ER_HANDSHAKE_ERROR. I don't know the reason why this error code was 
      ignored, and instead a generic  ER_UNKNOWN_COM_ERROR was pushed into the
      error stack, but knowing the relaxed attitude towards preserving the error
      codes in the old code, I'm inclinded to think that it was a bug.
      
      After this patch, the most specific error message is already pushed,
      so calling my_message() again is useless.
      
      If res is < 0, the error used to be already sent. This is not done
      by the new code, but will be done later, in the end
      of dispatch_command(). When this is done, clear_error() will be called 
      for us - it is in the first lines of do_command.
      
      To sum up, this change is to remove COM_CHANGE_USER specific error handling
      in favor of the standard one employed for all other COM_* commands.
    28c15316
protocol.h 6.21 KB