Commit 821683a1 authored by Sergei Golubchik's avatar Sergei Golubchik
Browse files

merge

parents 50e23ee8 597fe73c
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -2101,6 +2101,37 @@ static bool add_line(String &buffer,char *line,char *in_string,
	continue;
      }
    }
    else if (!*ml_comment && !*in_string &&
             (end_of_line - pos) >= 10 &&
             !my_strnncoll(charset_info, (uchar*) pos, 10,
                           (const uchar*) "delimiter ", 10))
    {
      // Flush previously accepted characters
      if (out != line)
      {
        buffer.append(line, (uint32) (out - line));
        out= line;
      }

      // Flush possible comments in the buffer
      if (!buffer.is_empty())
      {
        if (com_go(&buffer, 0) > 0) // < 0 is not fatal
          DBUG_RETURN(1);
        buffer.length(0);
      }

      /*
        Delimiter wants the get rest of the given line as argument to
        allow one to change ';' to ';;' and back
      */
      buffer.append(pos);
      if (com_delimiter(&buffer, pos) > 0)
        DBUG_RETURN(1);

      buffer.length(0);
      break;
    }
    else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter))
    {
      // Found a statement. Continue parsing after the delimiter
+127 −54
Original line number Diff line number Diff line
@@ -171,6 +171,8 @@ static ulonglong timer_now(void);

static ulonglong progress_start= 0;

static ulong connection_retry_sleep= 100000; /* Microseconds */

/* Precompiled re's */
static my_regex_t ps_re;     /* the query can be run using PS protocol */
static my_regex_t sp_re;     /* the query can be run as a SP */
@@ -495,6 +497,9 @@ void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val);
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input);

static int match_expected_error(struct st_command *command,
                                unsigned int err_errno,
                                const char *err_sqlstate);
void handle_error(struct st_command*,
                  unsigned int err_errno, const char *err_error,
                  const char *err_sqlstate, DYNAMIC_STRING *ds);
@@ -848,30 +853,26 @@ void check_command_args(struct st_command *command,
  DBUG_VOID_RETURN;
}


void handle_command_error(struct st_command *command, uint error)
{
  DBUG_ENTER("handle_command_error");
  DBUG_PRINT("enter", ("error: %d", error));
  if (error != 0)
  {
    uint i;
    int i;

    if (command->abort_on_error)
      die("command \"%.*s\" failed with error %d",
          command->first_word_len, command->query, error);
    for (i= 0; i < command->expected_errors.count; i++)
    {
      DBUG_PRINT("info", ("expected error: %d",
                          command->expected_errors.err[i].code.errnum));
      if ((command->expected_errors.err[i].type == ERR_ERRNO) &&
          (command->expected_errors.err[i].code.errnum == error))

    i= match_expected_error(command, error, NULL);

    if (i >= 0)
    {
      DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %d",
                          command->first_word_len, command->query, error));
      DBUG_VOID_RETURN;
    }
    }
    die("command \"%.*s\" failed with wrong error: %d",
        command->first_word_len, command->query, error);
  }
@@ -2465,8 +2466,8 @@ void do_exec(struct st_command *command)
  error= pclose(res_file);
  if (error > 0)
  {
    uint status= WEXITSTATUS(error), i;
    my_bool ok= 0;
    uint status= WEXITSTATUS(error);
    int i;

    if (command->abort_on_error)
    {
@@ -2478,19 +2479,13 @@ void do_exec(struct st_command *command)

    DBUG_PRINT("info",
               ("error: %d, status: %d", error, status));
    for (i= 0; i < command->expected_errors.count; i++)
    {
      DBUG_PRINT("info", ("expected error: %d",
                          command->expected_errors.err[i].code.errnum));
      if ((command->expected_errors.err[i].type == ERR_ERRNO) &&
          (command->expected_errors.err[i].code.errnum == status))
      {
        ok= 1;

    i= match_expected_error(command, status, NULL);

    if (i >= 0)
      DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
                          command->first_argument, status));
      }
    }
    if (!ok)
    else
    {
      dynstr_free(&ds_cmd);
      die("command \"%s\" failed with wrong error: %d",
@@ -4290,7 +4285,6 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
                  int port, const char *sock)
{
  int failed_attempts= 0;
  static ulong connection_retry_sleep= 100000; /* Microseconds */

  DBUG_ENTER("safe_connect");
  while(!mysql_real_connect(mysql, host,user, pass, db, port, sock,
@@ -4357,6 +4351,7 @@ int connect_n_handle_errors(struct st_command *command,
                            const char* db, int port, const char* sock)
{
  DYNAMIC_STRING *ds;
  int failed_attempts= 0;

  ds= &ds_res;

@@ -4385,9 +4380,41 @@ int connect_n_handle_errors(struct st_command *command,
    dynstr_append_mem(ds, delimiter, delimiter_length);
    dynstr_append_mem(ds, "\n", 1);
  }
  if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
  while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
                          CLIENT_MULTI_STATEMENTS))
  {
    /*
      If we have used up all our connections check whether this
      is expected (by --error). If so, handle the error right away.
      Otherwise, give it some extra time to rule out race-conditions.
      If extra-time doesn't help, we have an unexpected error and
      must abort -- just proceeding to handle_error() when second
      and third chances are used up will handle that for us.

      There are various user-limits of which only max_user_connections
      and max_connections_per_hour apply at connect time. For the
      the second to create a race in our logic, we'd need a limits
      test that runs without a FLUSH for longer than an hour, so we'll
      stay clear of trying to work out which exact user-limit was
      exceeded.
    */

    if (((mysql_errno(con) == ER_TOO_MANY_USER_CONNECTIONS) ||
         (mysql_errno(con) == ER_USER_LIMIT_REACHED)) &&
        (failed_attempts++ < opt_max_connect_retries))
    {
      int i;

      i= match_expected_error(command, mysql_errno(con), mysql_sqlstate(con));

      if (i >= 0)
        goto do_handle_error;                 /* expected error, handle */

      my_sleep(connection_retry_sleep);       /* unexpected error, wait */
      continue;                               /* and give it 1 more chance */
    }

do_handle_error:
    var_set_errno(mysql_errno(con));
    handle_error(command, mysql_errno(con), mysql_error(con),
		 mysql_sqlstate(con), ds);
@@ -6149,6 +6176,56 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
}


/*
  Check whether given error is in list of expected errors

  SYNOPSIS
    match_expected_error()

  PARAMETERS
    command        the current command (and its expect-list)
    err_errno      error number of the error that actually occurred
    err_sqlstate   SQL-state that was thrown, or NULL for impossible
                   (file-ops, diff, etc.)

  RETURNS
    -1 for not in list, index in list of expected errors otherwise

  NOTE
    If caller needs to know whether the list was empty, they should
    check command->expected_errors.count.
*/

static int match_expected_error(struct st_command *command,
                                unsigned int err_errno,
                                const char *err_sqlstate)
{
  uint i;

  for (i= 0 ; (uint) i < command->expected_errors.count ; i++)
  {
    if ((command->expected_errors.err[i].type == ERR_ERRNO) &&
        (command->expected_errors.err[i].code.errnum == err_errno))
      return i;

    if (command->expected_errors.err[i].type == ERR_SQLSTATE)
    {
      /*
        NULL is quite likely, but not in conjunction with a SQL-state expect!
      */
      if (unlikely(err_sqlstate == NULL))
        die("expecting a SQL-state (%s) from query '%s' which cannot produce one...",
            command->expected_errors.err[i].code.sqlstate, command->query);

      if (strncmp(command->expected_errors.err[i].code.sqlstate,
                  err_sqlstate, SQLSTATE_LENGTH) == 0)
        return i;
    }
  }
  return -1;
}


/*
  Handle errors which occurred during execution

@@ -6169,7 +6246,7 @@ void handle_error(struct st_command *command,
                  unsigned int err_errno, const char *err_error,
                  const char *err_sqlstate, DYNAMIC_STRING *ds)
{
  uint i;
  int i;

  DBUG_ENTER("handle_error");

@@ -6195,13 +6272,10 @@ void handle_error(struct st_command *command,

  DBUG_PRINT("info", ("expected_errors.count: %d",
                      command->expected_errors.count));
  for (i= 0 ; (uint) i < command->expected_errors.count ; i++)
  {
    if (((command->expected_errors.err[i].type == ERR_ERRNO) &&
         (command->expected_errors.err[i].code.errnum == err_errno)) ||
        ((command->expected_errors.err[i].type == ERR_SQLSTATE) &&
         (strncmp(command->expected_errors.err[i].code.sqlstate,
                  err_sqlstate, SQLSTATE_LENGTH) == 0)))

  i= match_expected_error(command, err_errno, err_sqlstate);

  if (i >= 0)
  {
    if (!disable_result_log)
    {
@@ -6223,7 +6297,6 @@ void handle_error(struct st_command *command,
    /* OK */
    DBUG_VOID_RETURN;
  }
  }

  DBUG_PRINT("info",("i: %d  expected_errors: %d", i,
                     command->expected_errors.count));
@@ -6237,7 +6310,7 @@ void handle_error(struct st_command *command,
    dynstr_append_mem(ds, "\n", 1);
  }

  if (i)
  if (command->expected_errors.count > 0)
  {
    if (command->expected_errors.err[0].type == ERR_ERRNO)
      die("query '%s' failed with wrong errno %d: '%s', instead of %d...",
+18 −0
Original line number Diff line number Diff line
@@ -1103,6 +1103,24 @@ set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
set global innodb_commit_concurrency=0;
set global innodb_commit_concurrency=@my_innodb_commit_concurrency;

#
# Bug #37830: ORDER BY ASC/DESC - no difference
#

CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
 ENGINE=InnoDB;

INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;

# should be range access
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;

# should produce '8 7 6 5 4' for a
SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;

DROP TABLE t1;

--echo End of 5.0 tests

# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
+63 −55
Original line number Diff line number Diff line
############## mysql-test\t\query_prealloc_size_basic.test ###############
################# mysql-test\t\query_prealloc_size_basic.test ##################
#                                                                              #
# Variable Name: query_prealloc_size                                           #
# Scope: GLOBAL | SESSION                                                      #
@@ -18,10 +18,13 @@
#              * Scope & Access method                                         #
#              * Data Integrity                                                #
#                                                                              #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
#  server-system-variables.html                                               #
# Reference:                                                                   #
#      http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html     #
#                                                                              #
###############################################################################
# Last Modification:                                                           #
# 2008-07-14 hhunger removed values for 64 bit platforms.                      #
#                                                                              #
################################################################################

--source include/load_sysvars.inc

@@ -67,30 +70,32 @@ SELECT @@session.query_prealloc_size = 8192;


--echo '#--------------------FN_DYNVARS_005_03-------------------------#'
##################################################################################
################################################################################
# Change the value of query_prealloc_size   to a valid value for GLOBAL Scope  #
##################################################################################
################################################################################

SET @@global.query_prealloc_size   = 8192;
SELECT @@global.query_prealloc_size  ;

SET @@global.query_prealloc_size   = 4294967295;
SELECT @@global.query_prealloc_size  ;
# Due to problems with 64 bit machines having less than 6 GB main memory.
#SET @@global.query_prealloc_size   = 4294967295;
#SELECT @@global.query_prealloc_size  ;

SET @@global.query_prealloc_size   = 655354;
SELECT @@global.query_prealloc_size  ;


--echo '#--------------------FN_DYNVARS_005_04-------------------------#'
###################################################################################
##################################################################################
# Change the value of query_prealloc_size   to a valid value for SESSION Scope   #
###################################################################################
##################################################################################

SET @@session.query_prealloc_size   = 8192;
SELECT @@session.query_prealloc_size  ;

SET @@session.query_prealloc_size   = 4294967295;
SELECT @@session.query_prealloc_size  ;
# Due to problems with 64 bit machines having less than 6 GB main memory.
#SET @@session.query_prealloc_size   = 4294967295;
#SELECT @@session.query_prealloc_size  ;

SET @@session.query_prealloc_size   = 655345;
SELECT @@session.query_prealloc_size  ;
@@ -109,8 +114,9 @@ SELECT @@global.query_prealloc_size ;
SET @@global.query_prealloc_size   = -1024;
SELECT @@global.query_prealloc_size  ;

SET @@global.query_prealloc_size   = 429496729533;
SELECT @@global.query_prealloc_size  ;
# Due to problems with 64 bit machines having less than 6 GB main memory.
#SET @@global.query_prealloc_size   = 429496729533;
#SELECT @@global.query_prealloc_size  ;


--Error ER_PARSE_ERROR
@@ -188,18 +194,19 @@ SELECT @@global.query_prealloc_size ;


--echo '#---------------------FN_DYNVARS_001_09----------------------#'
#################################################################################### 
################################################################################
# Check if accessing variable with and without GLOBAL point to same variable   #
#################################################################################### 
################################################################################

SET @@global.query_prealloc_size   = 10;
SELECT @@query_prealloc_size   = @@global.query_prealloc_size  ;


--echo '#---------------------FN_DYNVARS_001_10----------------------#'
########################################################################################################
#    Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable  #
########################################################################################################
##############################################################################
# Check if accessing variable with SESSION,LOCAL and without SCOPE points to #
# to the same session variable                                               #
##############################################################################

SET @@query_prealloc_size   = 100;
SELECT @@query_prealloc_size   = @@local.query_prealloc_size  ;
@@ -207,9 +214,9 @@ SELECT @@local.query_prealloc_size = @@session.query_prealloc_size ;


--echo '#---------------------FN_DYNVARS_001_11----------------------#'
###################################################################################  
################################################################################
#    Check if query_prealloc_size   can be accessed with and without @@ sign   #
###################################################################################
################################################################################

SET query_prealloc_size   = 1;
SELECT @@query_prealloc_size  ;
@@ -237,3 +244,4 @@ SELECT @@session.query_prealloc_size ;
#############################################################
#                 END OF query_prealloc_size   TESTS        #
#############################################################
+1 −0
Original line number Diff line number Diff line
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
drop table if exists t1;
create table t1 (
`a&b` int,
`a<b` int,
Loading