Commit 505caa28 authored by unknown's avatar unknown
Browse files

Remove usage of !$ from mysql-tests

Added protocol::flush() for easier embedded-server code
Increase block allocation variables a bit as they where a bit too small for MySQL 4.1
Added option --silent to client_test


client/mysqltest.c:
  Removed compiler warning
  Fixed identation & comments from earlier push
  Renamed variable 'disable_abort_on_error' to 'abort_on_error'
  Ensure that '$mysql_errno' also with --ps-protocol
include/mysql_com.h:
  Removed special handling of net_flush for embedded server
mysql-test/r/mysqltest.result:
  Remove usage of !$ in tests
mysql-test/t/client_test.test:
  Use --silent
mysql-test/t/comments.test:
  Remove usage of !$ in tests
mysql-test/t/join_outer.test:
  Remove usage of !$ in tests
mysql-test/t/key.test:
  Remove usage of !$ in tests
mysql-test/t/mysqltest.test:
  Remove usage of !$ in tests
mysql-test/t/show_check.test:
  Remove usage of !$ in tests
mysql-test/t/temp_table.test:
  Remove usage of !$ in tests
mysql-test/t/type_ranges.test:
  Remove usage of !$ in tests
sql/mysqld.cc:
  Increase block allocation variables a bit as they where a bit too small for MySQL 4.1
sql/net_serv.cc:
  Remove special usage of net_flush in embedded server
sql/protocol.cc:
  Added protocol::flush() for easier embedded-server code
sql/protocol.h:
  Added protocol::flush() for easier embedded-server code
sql/sql_prepare.cc:
  Added protocol::flush() for easier embedded-server code
  Remove one extra flush() for prepared statements
sql/sql_show.cc:
  Added protocol::flush() for easier embedded-server code
tests/client_test.c:
  Added option --silent
parent 3200d66f
Loading
Loading
Loading
Loading
+53 −37
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@

**********************************************************************/

#define MTEST_VERSION "2.3"
#define MTEST_VERSION "2.4"

#include <my_global.h>
#include <mysql_embed.h>
@@ -243,8 +243,7 @@ VAR var_reg[10];
HASH var_hash;
my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0;
my_bool disable_info= 1;			/* By default off */
/* default for disable_abort_on_error: false = abort on unmasked error */
my_bool disable_abort_on_error= 0;
my_bool abort_on_error= 1;

struct connection cons[MAX_CONS];
struct connection* cur_con, *next_con, *cons_end;
@@ -370,7 +369,7 @@ const char *command_names[]=
};

TYPELIB command_typelib= {array_elements(command_names),"",
			  command_names};
			  command_names, 0};

DYNAMIC_STRING ds_res;
static void die(const char *fmt, ...);
@@ -744,7 +743,7 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw,
  DBUG_RETURN(0);
}

static VAR* var_obtain(char* name, int len)
static VAR *var_obtain(const char* name, int len)
{
  VAR* v;
  if ((v = (VAR*)hash_search(&var_hash, name, len)))
@@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len)
  return v;
}

int var_set(char* var_name, char* var_name_end, char* var_val,
	    char* var_val_end)
int var_set(const char *var_name, const char *var_name_end,
            const char *var_val, const char *var_val_end)
{
  int digit;
  VAR* v;
  DBUG_ENTER("var_set");
  DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)",
                       (int) (var_name_end - var_name), var_name,
                       (int) (var_val_end - var_val), var_val,
                       (int) (var_val_end - var_val)));

  if (*var_name++ != '$')
  {
      --var_name;
      *var_name_end = 0;
    var_name--;
    die("Variable name in %s does not start with '$'", var_name);
  }
  digit = *var_name - '0';
  if (!(digit < 10 && digit >= 0))
  {
      v = var_obtain(var_name, var_name_end - var_name);
    v = var_obtain(var_name, (uint) (var_name_end - var_name));
  }
  else
    v = var_reg + digit;

  return eval_expr(v, var_val, (const char**)&var_val_end);
}


int open_file(const char* name)
{
  char buff[FN_REFLEN];
@@ -1244,18 +1248,22 @@ int do_let(struct st_query* q)
  return var_set(var_name, var_name_end, var_val_start, q->end);
}

/* Store an integer (typically the returncode of the last SQL)  */
/* statement in the mysqltest builtin variable $mysql_errno, by */
/* simulating of a user statement "let $mysql_errno= <integer>" */

/*
  Store an integer (typically the returncode of the last SQL)
  statement in the mysqltest builtin variable $mysql_errno, by
  simulating of a user statement "let $mysql_errno= <integer>"
*/

int var_set_errno(int sql_errno)
{
  char var_name[] = "$mysql_errno", var_val[30];
  sprintf(var_val, "%d", sql_errno);
  /* On some odd systems, the return value from sprintf() isn't */
  /* always the length of the string, so we use strlen()        */
   return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val));
  const char *var_name= "$mysql_errno";
  char var_val[21];
  uint length= my_sprintf(var_val, (var_val, "%d", sql_errno));
  return var_set(var_name, var_name + 12, var_val, var_val + length);
}


int do_rpl_probe(struct st_query* q __attribute__((unused)))
{
  DBUG_ENTER("do_rpl_probe");
@@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused)))
  DBUG_RETURN(0);
}


int do_enable_rpl_parse(struct st_query* q __attribute__((unused)))
{
  mysql_enable_rpl_parse(&cur_con->mysql);
  return 0;
}


int do_disable_rpl_parse(struct st_query* q __attribute__((unused)))
{
  mysql_disable_rpl_parse(&cur_con->mysql);
@@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr)
  memcpy((gptr) q->expected_errno, (gptr) global_expected_errno,
	 sizeof(global_expected_errno));
  q->expected_errors= global_expected_errors;
  q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error);
  q->abort_on_error= (global_expected_errors == 0 && abort_on_error);
  bzero((gptr) global_expected_errno, sizeof(global_expected_errno));
  global_expected_errors=0;
  if (p[0] == '-' && p[1] == '-')
@@ -2659,9 +2669,12 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
    dynstr_free(&ds_tmp);
  if (q->type == Q_EVAL)
    dynstr_free(&eval_query);
  /* We save the return code (mysql_errno(mysql)) from the last call sent */
  /* to the server into the mysqltest builtin variable $mysql_errno. This */
  /* variable then can be used from the test case itself.                 */

  /*
    We save the return code (mysql_errno(mysql)) from the last call sent
    to the server into the mysqltest builtin variable $mysql_errno. This
    variable then can be used from the test case itself.
  */
  var_set_errno(mysql_errno(mysql));
  DBUG_RETURN(error);
}
@@ -3012,6 +3025,7 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
    dynstr_free(&ds_tmp);
  if (q->type == Q_EVAL)
    dynstr_free(&eval_query);
  var_set_errno(mysql_stmt_errno(stmt));
  mysql_stmt_close(stmt);
  DBUG_RETURN(error);
}
@@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val)
  if (!(tmp = getenv(name)))
    tmp = def_val;

  v = var_init(0, name, 0, tmp, 0);
  v = var_init(0, name, strlen(name), tmp, strlen(tmp));
  my_hash_insert(&var_hash, (byte*)v);
  return v;
}
@@ -3416,9 +3430,11 @@ int main(int argc, char **argv)

  init_var_hash(&cur_con->mysql);

  /* Initialize $mysql_errno with -1, so we can                  */
  /* - distinguish it from valid values ( >= 0 )   and           */
  /* - detect if there was never a command sent to the server    */
  /*
    Initialize $mysql_errno with -1, so we can
    - distinguish it from valid values ( >= 0 ) and
    - detect if there was never a command sent to the server
  */
  var_set_errno(-1);

  while (!read_query(&q))
@@ -3440,8 +3456,8 @@ int main(int argc, char **argv)
      case Q_DISABLE_RPL_PARSE:  do_disable_rpl_parse(q); break;
      case Q_ENABLE_QUERY_LOG:	 disable_query_log=0; break;
      case Q_DISABLE_QUERY_LOG:  disable_query_log=1; break;
      case Q_ENABLE_ABORT_ON_ERROR:  disable_abort_on_error=0; break;
      case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break;
      case Q_ENABLE_ABORT_ON_ERROR:  abort_on_error=1; break;
      case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
      case Q_ENABLE_RESULT_LOG:  disable_result_log=0; break;
      case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
      case Q_ENABLE_WARNINGS:    disable_warnings=0; break;
+0 −6
Original line number Diff line number Diff line
@@ -282,13 +282,7 @@ void my_net_local_init(NET *net);
void	net_end(NET *net);
void	net_clear(NET *net);
my_bool net_realloc(NET *net, unsigned long length);

#ifndef EMBEDDED_LIBRARY /* To be removed by HF */
my_bool	net_flush(NET *net);
#else
#define net_flush(A)
#endif

my_bool	my_net_write(NET *net,const char *packet,unsigned long len);
my_bool	net_write_command(NET *net,unsigned char command,
			  const char *header, unsigned long head_len,
+0 −7
Original line number Diff line number Diff line
@@ -7,11 +7,6 @@ otto
select otto from (select 1 as otto) as t1;
otto
1
select otto from (select 1 as otto) as t1;
otto
1
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
@@ -147,5 +142,3 @@ after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
+1 −1
Original line number Diff line number Diff line
--disable_result_log
--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT
--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@
select 1+2/*hello*/+3;
select 1 /* long
multi line comment */;
!$1065 ;
--error 1065
 ;
select 1 /*!32301 +1 */;
select 1 /*!52301 +1 */;
select 1--1;
Loading