Commit f3efb3dc authored by unknown's avatar unknown
Browse files

Added more descriptive error message of why statement was automaticly dropped

Print information if net_clear() skipped bytes (As this otherwise hides critical timeing bugs)
Added DBUG_ASSERT if we get packets out of order
mysql_change_user() could on error send multiple packets, which caused mysql_client_test to randomly fail


include/errmsg.h:
  Added more descriptive error message of why statement was automaticly dropped
libmysql/client_settings.h:
  Added more descriptive error message of why statement was automaticly dropped
libmysql/errmsg.c:
  Added more descriptive error message of why statement was automaticly dropped
libmysql/libmysql.c:
  Added more descriptive error message of why statement was automaticly dropped
sql-common/client.c:
  Added more descriptive error message of why statement was automaticly dropped
sql/net_serv.cc:
  Print information if net_clear() skipped bytes (As this otherwise hides critical timeing bugs)
  Added DBUG_ASSERT if we get packets out of order
sql/sql_class.cc:
  We need to set killed to NOT_KILLED after cleanup() if we want to continue using THD
  (If not, the connection will be closed after the current stmt)
sql/sql_parse.cc:
  mysql_change_user() could on error send multiple packets, which caused mysql_client_test to randomly fail
tests/mysql_client_test.c:
  More DBUG information
  Better usage of --silent
  Always print 'OK' the same way.
  Disable test_bug17667 if run outside of mysql-test-run
parent 2671ba02
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NO_RESULT_SET                        2053
#define CR_NOT_IMPLEMENTED                      2054
#define CR_SERVER_LOST_EXTENDED			2055
#define CR_ERROR_LAST  /*Copy last error nr:*/  2055
#define CR_STMT_CLOSED				2056
#define CR_ERROR_LAST  /*Copy last error nr:*/  2056
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename);

void mysql_read_default_options(struct st_mysql_options *options,
				const char *filename,const char *group);
void mysql_detach_stmt_list(LIST **stmt_list);
void mysql_detach_stmt_list(LIST **stmt_list, const char *func_name);
MYSQL *
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
		       const char *passwd, const char *db,
+3 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ const char *client_errors[]=
  "Attempt to read a row while there is no result set associated with the statement",
  "This feature is not implemented yet",
  "Lost connection to MySQL server at '%s', system error: %d",
  "Statement closed indirectly because of a preceeding %s() call",
  ""
};

@@ -147,6 +148,7 @@ const char *client_errors[]=
  "Attempt to read a row while there is no result set associated with the statement",
  "This feature is not implemented yet",
  "Lost connection to MySQL server at '%s', system error: %d",
  "Statement closed indirectly because of a preceeding %s() call",
  ""
};

@@ -209,6 +211,7 @@ const char *client_errors[]=
  "Attempt to read a row while there is no result set associated with the statement",
  "This feature is not implemented yet",
  "Lost connection to MySQL server at '%s', system error: %d",
  "Statement closed indirectly because of a preceeding %s() call",
  ""
};
#endif
+2 −2
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
    The server will close all statements no matter was the attempt
    to change user successful or not.
  */
  mysql_detach_stmt_list(&mysql->stmts);
  mysql_detach_stmt_list(&mysql->stmts, "mysql_change_user");
  if (rc == 0)
  {
    /* Free old connect information */
@@ -2872,7 +2872,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)

  if (!mysql)
  {
    set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
    /* Error is already set in mysql_detatch_stmt_list */
    DBUG_RETURN(1);
  }

+10 −2
Original line number Diff line number Diff line
@@ -2596,24 +2596,32 @@ static void mysql_close_free(MYSQL *mysql)
  SYNOPSYS
    mysql_detach_stmt_list()
      stmt_list  pointer to mysql->stmts
      func_name  name of calling function

  NOTE
    There is similar code in mysql_reconnect(), so changes here
    should also be reflected there.
*/

void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)))
void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)),
                            const char *func_name)
{
#ifdef MYSQL_CLIENT
  /* Reset connection handle in all prepared statements. */
  LIST *element= *stmt_list;
  char buff[MYSQL_ERRMSG_SIZE];
  DBUG_ENTER("mysql_detach_stmt_list");

  my_snprintf(buff, sizeof(buff)-1, ER(CR_STMT_CLOSED), func_name);
  for (; element; element= element->next)
  {
    MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
    set_stmt_errmsg(stmt, buff, CR_STMT_CLOSED, unknown_sqlstate);
    stmt->mysql= 0;
    /* No need to call list_delete for statement here */
  }
  *stmt_list= 0;
  DBUG_VOID_RETURN;
#endif /* MYSQL_CLIENT */
}

@@ -2634,7 +2642,7 @@ void STDCALL mysql_close(MYSQL *mysql)
    }
    mysql_close_free_options(mysql);
    mysql_close_free(mysql);
    mysql_detach_stmt_list(&mysql->stmts);
    mysql_detach_stmt_list(&mysql->stmts, "mysql_close");
#ifndef TO_BE_DELETED
    /* free/close slave list */
    if (mysql->rpl_pivot)
Loading