Commit d0760667 authored by unknown's avatar unknown
Browse files

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/Users/kent/mysql/bk/mysql-5.0

parents 67660275 9832367a
Loading
Loading
Loading
Loading
+0 −0

Empty file added.

+192 −37
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
		opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
		opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
                opt_complete_insert= 0, opt_drop_database= 0,
                opt_dump_triggers= 0;
                opt_dump_triggers= 0, opt_routines=0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*sock=0;
static my_bool insert_pat_inited=0;
@@ -339,6 +339,9 @@ static struct my_option my_long_options[] =
  {"result-file", 'r',
   "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"routines", 'R', "Dump routines FUNCTIONS and PROCEDURES.",
     (gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL,
     NO_ARG, 0, 0, 0, 0, 0, 0},
  {"set-charset", OPT_SET_CHARSET,
   "Add 'SET NAMES default_character_set' to the output. Enabled by default; suppress with --skip-set-charset.",
   (gptr*) &opt_set_charset, (gptr*) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
@@ -1177,6 +1180,112 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
  check_io(xml_file);
}

/*
  dump_routines_for_db
  -- retrievs list of routines for a given db, and prints out
  the CREATE PROCEDURE definition into the output (the dump).

  This function has logic to print the appropriate syntax depending on whether
  this is a procedure or functions

  RETURN 0 succes, 1 if error
*/

static uint dump_routines_for_db (char *db)
{
  char       query_buff[512], routine_type[10];
  char       db_name_buff[NAME_LEN+3], name_buff[NAME_LEN+3];
  int        i;
  FILE       *sql_file = md_result_file;
  MYSQL_RES  *routine_res= NULL;
  MYSQL_RES  *routine_list_res= NULL;
  MYSQL_ROW  row, routine_list_row;

  DBUG_ENTER("dump_routines_for_db");

  mysql_real_escape_string(sock, db_name_buff, db, strlen(db));
  DBUG_PRINT("enter", ("db: '%s'", db_name_buff));

  /* nice comments */
  if (opt_comments)
    fprintf(sql_file, "\n--\n-- Dumping routines for database '%s'\n--\n", db);

  /*
    not using "mysql_query_with_error_report" because of privileges 
  */
  if (opt_lock)
    mysql_query(sock, "LOCK TABLES mysql.proc READ");

  fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
  fprintf(sql_file, "DELIMITER //\n");

  /* 0, retrieve and dump functions, 1, procedures */
  for (i=0; i <= 1; i++)
  {
    my_snprintf(routine_type, sizeof(routine_type),
                  "%s", i == 0 ? "FUNCTION" : "PROCEDURE");

    my_snprintf(query_buff, sizeof(query_buff),
                "SHOW %s STATUS WHERE Db = '%s'",
                routine_type, db_name_buff);

    if (mysql_query_with_error_report(sock, &routine_list_res, query_buff))
      DBUG_RETURN(1);

    if (mysql_num_rows(routine_list_res))
    {

      while((routine_list_row= mysql_fetch_row(routine_list_res)))
      {
        DBUG_PRINT("info", ("retrieving CREATE %s for %s", routine_type, name_buff));
        mysql_real_escape_string(sock, name_buff,
                                 routine_list_row[1], strlen(routine_list_row[1]));
        my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s",
                    routine_type, name_buff);

        if (mysql_query_with_error_report(sock, &routine_res, query_buff))
          DBUG_RETURN(1);

        while ((row=mysql_fetch_row(routine_res)))
        {
          /*
            the user can see routine names, but NOT the routine body of other
            routines that are not the creator of!
          */
          DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
                             name_buff, row[2], strlen(row[2])));
          if (strlen(row[2]))
          {
            fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n",
                    row[1] /* sql_mode */);

            if (opt_drop)
              fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */ //\n",
                      routine_type, name_buff);
            /*
              the i==0 is temporary until we can figure out why functions
              can't be in comments
            */
            /* create proc/func body */;
            fprintf(sql_file, "/*!50003 %s */ //\n", row[2]);
          }
        } /* end of routine printing */
      } /* end of list of routines */
      mysql_free_result(routine_res);
      routine_res=NULL;
    }
    mysql_free_result(routine_list_res);
    routine_list_res=NULL;
  } /* end of for i (0 .. 1)  */
  /* set the delimiter back to ';' */
  fprintf(sql_file, "DELIMITER ;\n");
  fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;\n");

  /* again, no error report due to permissions */
  if (opt_lock)
    mysql_query(sock, "UNLOCK TABLES");
  DBUG_RETURN(0);
}

/*
  getTableStructure -- retrievs database structure, prints out corresponding
@@ -1330,41 +1439,6 @@ static uint get_table_structure(char *table, char *db)
      fprintf(sql_file, "%s;\n", row[1]);
      check_io(sql_file);
      mysql_free_result(tableRes);
      if (opt_dump_triggers &&
          mysql_get_server_version(sock) >= 50009)
      {
        my_snprintf(query_buff, sizeof(query_buff),
                    "SHOW TRIGGERS LIKE %s",
                    quote_for_like(table, name_buff));


        if (mysql_query_with_error_report(sock, &tableRes, query_buff))
        {
          if (path)
            my_fclose(sql_file, MYF(MY_WME));
          safe_exit(EX_MYSQLERR);
          DBUG_RETURN(0);
        }
        if (mysql_num_rows(tableRes))
          fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
DELIMITER //;\n");
        while ((row=mysql_fetch_row(tableRes)))
        {
          fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s*/ //\n\n",
                  row[6], /* sql_mode */
                  quote_name(row[0], name_buff, 0), /* Trigger */
                  row[4], /* Timing */
                  row[1], /* Event */
                  result_table,
                  row[3] /* Statement */);
        }
        if (mysql_num_rows(tableRes))
          fprintf(sql_file,
                  "DELIMITER ;//\n\
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;");
        mysql_free_result(tableRes);
      }
    }
    my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
		result_table);
@@ -1657,6 +1731,68 @@ DELIMITER //;\n");
} /* get_table_structure */


/*

  dump_triggers_for_table

  Dumps the triggers given a table/db name. This should be called after
  the tables have been dumped in case a trigger depends on the existence
  of a table

  INPUT
    char * tablename and db name
  RETURNS
   0 Failure
   1 Succes

*/

static void dump_triggers_for_table (char *table, char *db)
{
  MYSQL_RES  *result;
  MYSQL_ROW  row;
  char	     *result_table;
  char	     name_buff[NAME_LEN+3], table_buff[NAME_LEN*2+3];
  char       query_buff[512];
  FILE       *sql_file = md_result_file;

  DBUG_ENTER("dump_triggers_for_table");
  DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
  result_table=     quote_name(table, table_buff, 1);

  my_snprintf(query_buff, sizeof(query_buff),
              "SHOW TRIGGERS LIKE %s",
              quote_for_like(table, name_buff));

  if (mysql_query_with_error_report(sock, &result, query_buff))
  {
    if (path)
      my_fclose(sql_file, MYF(MY_WME));
    safe_exit(EX_MYSQLERR);
    DBUG_VOID_RETURN;
  }
  if (mysql_num_rows(result))
    fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
DELIMITER //;\n");
  while ((row=mysql_fetch_row(result)))
  {
    fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */ //\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */ //\n\n",
            row[6], /* sql_mode */
            quote_name(row[0], name_buff, 0), /* Trigger */
            row[4], /* Timing */
            row[1], /* Event */
            result_table,
            row[3] /* Statement */);
  }
  if (mysql_num_rows(result))
    fprintf(sql_file,
            "DELIMITER ;//\n\
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;");
  mysql_free_result(result);
  DBUG_VOID_RETURN;
}

static char *add_load_option(char *ptr,const char *object,
			     const char *statement)
{
@@ -2376,8 +2512,17 @@ static int dump_all_tables_in_db(char *database)
      dump_table(numrows,table);
      my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
      order_by= 0;
      if (opt_dump_triggers && ! opt_xml &&
          mysql_get_server_version(sock) >= 50009)
        dump_triggers_for_table(table, database);
    }
  }
  if (opt_routines && !opt_xml &&
      mysql_get_server_version(sock) >= 50009)
  {
    DBUG_PRINT("info", ("Dumping routines for database %s", database));
    dump_routines_for_db(database);
  }
  if (opt_xml)
  {
    fputs("</database>\n", md_result_file);
@@ -2569,6 +2714,9 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
    DBUG_PRINT("info",("Dumping table %s", table_name));
    numrows= get_table_structure(table_name, db);
    dump_table(numrows, table_name);
    if (opt_dump_triggers &&
        mysql_get_server_version(sock) >= 50009)
      dump_triggers_for_table(table_name, db);
  }

  /* Dump each selected view */
@@ -2580,6 +2728,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
      get_view_structure(table_name, db);
    }
  }
  /* obtain dump of routines (procs/functions) */
  if (opt_routines  && !opt_xml &&
      mysql_get_server_version(sock) >= 50009)
  {
    DBUG_PRINT("info", ("Dumping routines for database %s", db));
    dump_routines_for_db(db);
  }
  hash_free(&dump_tables);
  my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
  order_by= 0;
+2 −1
Original line number Diff line number Diff line
@@ -37,8 +37,9 @@ static char *add_load_option(char *ptr,const char *object,
			     const char *statement);

static my_bool	verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
		replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0,
		replace=0,silent=0,ignore=0,opt_compress=0,
                opt_low_priority= 0, tty_password= 0;
static uint     opt_local_file=0;
static MYSQL	mysql_connection;
static char	*opt_password=0, *current_user=0,
		*current_host=0, *current_db=0, *fields_terminated=0,
+107 −154
Original line number Diff line number Diff line
@@ -481,9 +481,10 @@ my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
				      int len);
static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
static int normal_handle_error(const char *query, struct st_query *q,
                               MYSQL *mysql, DYNAMIC_STRING *ds);
static int normal_handle_no_error(struct st_query *q);
static int handle_error(const char *query, struct st_query *q,
                        unsigned int err_errno, const char *err_error,
                        const char *err_sqlstate, DYNAMIC_STRING *ds);
static int handle_no_error(struct st_query *q);

static void do_eval(DYNAMIC_STRING* query_eval, const char *query)
{
@@ -2071,11 +2072,12 @@ int connect_n_handle_errors(struct st_query *q, MYSQL* con, const char* host,
  if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
                          CLIENT_MULTI_STATEMENTS))
  {
    error= normal_handle_error("connect", q, con, ds);
    error= handle_error("connect", q, mysql_errno(con), mysql_error(con),
                        mysql_sqlstate(con), ds);
    *create_conn= 0;
    goto err;
  }
  else if (normal_handle_no_error(q))
  else if (handle_no_error(q))
  {
    /*
      Fail if there was no error but we expected it.
@@ -2380,8 +2382,10 @@ int read_line(char *buf, int size)
    if (feof(cur_file->file))
    {
  found_eof:
      if (cur_file->file != stdin)
      if (cur_file->file != stdin){
	my_fclose(cur_file->file, MYF(0));
        cur_file->file= 0;
      }
      my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
      cur_file->file_name= 0;
      lineno--;
@@ -2755,10 +2759,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
	argument= buff;
      }
      fn_format(buff, argument, "", "", 4);
      DBUG_ASSERT(cur_file->file == 0);
      DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
      if (!(cur_file->file=
            my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
	die("Could not open %s: errno = %d", argument, errno);
	die("Could not open %s: errno = %d", buff, errno);
      cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
      break;
    }
  case 'm':
@@ -2961,8 +2966,6 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
static int run_query_normal(MYSQL *mysql, struct st_query *q, int flags);
static int run_query_stmt  (MYSQL *mysql, struct st_query *q, int flags);
static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds);
static int run_query_stmt_handle_error(char *query, struct st_query *q,
                                       MYSQL_STMT *stmt, DYNAMIC_STRING *ds);
static void run_query_display_metadata(MYSQL_FIELD *field, uint num_fields,
                                       DYNAMIC_STRING *ds);

@@ -3046,12 +3049,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
	 (!(last_result= res= mysql_store_result(mysql)) &&
	  mysql_field_count(mysql)))
    {
      if (normal_handle_error(query, q, mysql, ds))
      if (handle_error(query, q, mysql_errno(mysql), mysql_error(mysql),
                       mysql_sqlstate(mysql), ds))
        error= 1;
      goto end;
    }

    if (normal_handle_no_error(q))
    if (handle_no_error(q))
    {
      error= 1;
      goto end;
@@ -3166,14 +3170,15 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)


/*
  Handle errors which occurred after execution of conventional (non-prepared)
  statement.
  Handle errors which occurred after execution

  SYNOPSIS
    normal_handle_error()
    handle_error()
      query - query string
      q     - query context
      mysql - connection through which query was sent to server
      err_errno - error number
      err_error - error message
      err_sqlstate - sql state
      ds    - dynamic string which is used for output buffer

  NOTE
@@ -3185,35 +3190,35 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
    1 - Some other error was expected.
*/

static int normal_handle_error(const char *query, struct st_query *q,
                               MYSQL *mysql, DYNAMIC_STRING *ds)
static int handle_error(const char *query, struct st_query *q,
                        unsigned int err_errno, const char *err_error,
                        const char* err_sqlstate, DYNAMIC_STRING *ds)
{
  uint i;
 
  DBUG_ENTER("normal_handle_error");
  DBUG_ENTER("handle_error");

  if (q->require_file)
    abort_not_supported_test();
 
  if (q->abort_on_error)
    die("query '%s' failed: %d: %s", query,
        mysql_errno(mysql), mysql_error(mysql));
  else
  {
        err_errno, err_error);

  for (i= 0 ; (uint) i < q->expected_errors ; i++)
  {
    if (((q->expected_errno[i].type == ERR_ERRNO) &&
            (q->expected_errno[i].code.errnum == mysql_errno(mysql))) ||
         (q->expected_errno[i].code.errnum == err_errno)) ||
        ((q->expected_errno[i].type == ERR_SQLSTATE) &&
           (strcmp(q->expected_errno[i].code.sqlstate, mysql_sqlstate(mysql)) == 0)))
         (strcmp(q->expected_errno[i].code.sqlstate, err_sqlstate) == 0)))
    {
      if (q->expected_errors == 1)
      {
        /* Only log error if there is one possible error */
        dynstr_append_mem(ds, "ERROR ", 6);
          replace_dynstr_append(ds, mysql_sqlstate(mysql));
        replace_dynstr_append(ds, err_sqlstate);
        dynstr_append_mem(ds, ": ", 2);
          replace_dynstr_append(ds, mysql_error(mysql));
        replace_dynstr_append(ds, err_error);
        dynstr_append_mem(ds,"\n",1);
      }
      /* Don't log error if we may not get an error */
@@ -3229,20 +3234,20 @@ static int normal_handle_error(const char *query, struct st_query *q,
  DBUG_PRINT("info",("i: %d  expected_errors: %d", i, q->expected_errors));

  dynstr_append_mem(ds, "ERROR ",6);
    replace_dynstr_append(ds, mysql_sqlstate(mysql));
  replace_dynstr_append(ds, err_sqlstate);
  dynstr_append_mem(ds, ": ", 2);
    replace_dynstr_append(ds, mysql_error(mysql));
  replace_dynstr_append(ds, err_error);
  dynstr_append_mem(ds, "\n", 1);

  if (i)
  {
    if (q->expected_errno[0].type == ERR_ERRNO)
      verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
                    q->query, mysql_errno(mysql),
                  q->query, err_errno,
                  q->expected_errno[0].code.errnum);
    else
      verbose_msg("query '%s' failed with wrong sqlstate %s instead of %s...",
                    q->query, mysql_sqlstate(mysql),
                  q->query, err_sqlstate,
                  q->expected_errno[0].code.sqlstate);
    DBUG_RETURN(1);
  }
@@ -3251,19 +3256,17 @@ static int normal_handle_error(const char *query, struct st_query *q,
    If we do not abort on error, failure to run the query does not fail the
    whole test case.
  */
    verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
                mysql_error(mysql));
  verbose_msg("query '%s' failed: %d: %s", q->query, err_errno,
              err_error);
  DBUG_RETURN(0);
}
  return 0; /* Keep compiler happy */
}


/*
  Handle absence of errors after execution of convetional statement.
  Handle absence of errors after execution

  SYNOPSIS
    normal_handle_error()
    handle_no_error()
      q - context of query

  RETURN VALUE
@@ -3271,9 +3274,9 @@ static int normal_handle_error(const char *query, struct st_query *q,
    1 - Some error was expected from this query.
*/

static int normal_handle_no_error(struct st_query *q)
static int handle_no_error(struct st_query *q)
{
  DBUG_ENTER("normal_handle_no_error");
  DBUG_ENTER("handle_no_error");

  if (q->expected_errno[0].type == ERR_ERRNO &&
      q->expected_errno[0].code.errnum != 0)
@@ -3367,17 +3370,17 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
  {
    if (q->abort_on_error)
    {
      die("unable to prepare statement '%s': "
          "%s (mysql_stmt_errno=%d returned=%d)",
          query,
          mysql_stmt_error(stmt), mysql_stmt_errno(stmt), err);
      die("query '%s' failed: %d: %s", query,
          mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
    }
    else
    {
      /*
        Preparing is part of normal execution and some errors may be expected
      */
      error= run_query_stmt_handle_error(query, q, stmt, ds);
      error= handle_error(query, q, mysql_stmt_errno(stmt),
                          mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
                          ds);
      goto end;
    }
  }
@@ -3410,7 +3413,9 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
    else
    {
      /* We got an error, maybe expected */
      error= run_query_stmt_handle_error(query, q, stmt, ds);
      error= handle_error(query, q, mysql_stmt_errno(stmt),
                          mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
                          ds);
      goto end;
    }
  }
@@ -3446,18 +3451,16 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
    else
    {
      /* We got an error, maybe expected */
      error= run_query_stmt_handle_error(query, q, stmt, ds);
      error= handle_error(query, q, mysql_stmt_errno(stmt),
                          mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
                          ds);
      goto end;
    }
  }

  /* If we got here the statement was both executed and read succeesfully */

  if (q->expected_errno[0].type == ERR_ERRNO &&
      q->expected_errno[0].code.errnum != 0)
  if (handle_no_error(q))
  {
    verbose_msg("query '%s' succeeded - should have failed with errno %d...",
                q->query, q->expected_errno[0].code.errnum);
    error= 1;
    goto end;
  }
@@ -3737,71 +3740,6 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds)
}


static int run_query_stmt_handle_error(char *query, struct st_query *q,
                                       MYSQL_STMT *stmt, DYNAMIC_STRING *ds)
{
  if (q->require_file)              /* FIXME don't understand this one */
  {
    abort_not_supported_test();
  }

  if (q->abort_on_error)
    die("query '%s' failed: %d: %s", query,
        mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
  else
  {
    int i;

    for (i=0 ; (uint) i < q->expected_errors ; i++)
    {
      if (((q->expected_errno[i].type == ERR_ERRNO) &&
           (q->expected_errno[i].code.errnum == mysql_stmt_errno(stmt))) ||
          ((q->expected_errno[i].type == ERR_SQLSTATE) &&
           (strcmp(q->expected_errno[i].code.sqlstate,
                   mysql_stmt_sqlstate(stmt)) == 0)))
      {
        if (i == 0 && q->expected_errors == 1)
        {
          /* Only log error if there is one possible error */
          dynstr_append_mem(ds,"ERROR ",6);
          replace_dynstr_append(ds, mysql_stmt_sqlstate(stmt));
          dynstr_append_mem(ds, ": ", 2);
          replace_dynstr_append(ds,mysql_stmt_error(stmt));
          dynstr_append_mem(ds,"\n",1);
        }
        /* Don't log error if we may not get an error */
        else if (q->expected_errno[0].type == ERR_SQLSTATE ||
                 (q->expected_errno[0].type == ERR_ERRNO &&
                  q->expected_errno[0].code.errnum != 0))
          dynstr_append(ds,"Got one of the listed errors\n");
        return 0; /* Ok */
      }
    }
    DBUG_PRINT("info",("i: %d  expected_errors: %d", i,
                       q->expected_errors));
    dynstr_append_mem(ds, "ERROR ",6);
    replace_dynstr_append(ds, mysql_stmt_sqlstate(stmt));
    dynstr_append_mem(ds,": ",2);
    replace_dynstr_append(ds, mysql_stmt_error(stmt));
    dynstr_append_mem(ds,"\n",1);
    if (i)
    {
      verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
                  q->query, mysql_stmt_errno(stmt), q->expected_errno[0]);
      return 1; /* Error */
    }
    verbose_msg("query '%s' failed: %d: %s", q->query, mysql_stmt_errno(stmt),
                mysql_stmt_error(stmt));
    /*
      if we do not abort on error, failure to run the query does
      not fail the whole test case
    */
    return 0;
  }

  return 0;
}

/****************************************************************************\
 *  Functions to match SQL statements that can be prepared
\****************************************************************************/
@@ -3898,6 +3836,22 @@ void get_query_type(struct st_query* q)
        q->type != Q_DISABLE_PARSING)
      q->type= Q_COMMENT;
  }
  else if (q->type == Q_COMMENT_WITH_COMMAND &&
           q->query[q->first_word_len-1] == ';')
  {
    /*
       Detect comment with command using extra delimiter
       Ex --disable_query_log;
                             ^ Extra delimiter causing the command
                               to be skipped
    */
    save= q->query[q->first_word_len-1];
    q->query[q->first_word_len-1]= 0;
    type= find_type(q->query, &command_typelib, 1+2);
    q->query[q->first_word_len-1]= save;
    if (type > 0)
      die("Extra delimiter \";\" found");
  }
  DBUG_VOID_RETURN;
}

@@ -4025,9 +3979,8 @@ int main(int argc, char **argv)
			embedded_server_args,
			(char**) embedded_server_groups))
    die("Can't initialize MySQL server");
  if (cur_file == file_stack)
  if (cur_file == file_stack && cur_file->file == 0)
  {
    DBUG_ASSERT(cur_file->file == 0);
    cur_file->file= stdin;
    cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
  }
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ AC_DEFUN([MYSQL_CHECK_FEDERATED], [
  AC_ARG_WITH([federated-storage-engine],
              [
  --with-federated-storage-engine
                        Enable the MySQL Storage Engine],
                        Enable the MySQL Federated Storage Engine],
              [federateddb="$withval"],
              [federateddb=no])
  AC_MSG_CHECKING([for MySQL federated storage engine])
Loading