Commit e35e3800 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge bk-internal:/home/bk/mysql-5.1-new

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1
parents b18f91ab b0b002e4
......@@ -25,10 +25,13 @@ endif
INCLUDES = -I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_srcdir)/regex \
$(openssl_includes) $(yassl_includes)
$(openssl_includes) $(yassl_includes)
LIBS = @CLIENT_LIBS@
LDADD= @CLIENT_EXTRA_LDFLAGS@ $(CLIENT_THREAD_LIBS) \
$(top_builddir)/libmysql/libmysqlclient.la
LDADD_R= @CLIENT_EXTRA_LDFLAGS@ \
$(CLIENT_THREAD_LIBS) \
$(top_builddir)/libmysql_r/libmysqlclient_r.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
mysqldump mysqlimport mysqltest mysqlbinlog \
mysqltestmanagerc mysqltestmanager-pwgen \
......@@ -48,15 +51,11 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \
$(top_srcdir)/mysys/my_vle.c \
$(top_srcdir)/mysys/base64.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
@CLIENT_EXTRA_LDFLAGS@ \
$(top_builddir)/libmysql_r/libmysqlclient_r.la \
$(top_builddir)/mysys/libmysys.a
mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
@CLIENT_EXTRA_LDFLAGS@ \
$(top_builddir)/libmysql_r/libmysqlclient_r.la \
$(top_builddir)/mysys/libmysys.a
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
mysqlslap_LDADD = $(CXXLDFLAGS) $(LDADD_R) \
$(top_builddir)/mysys/libmysys.a
mysqlimport_LDADD = $(CXXLDFLAGS) $(LDADD_R) \
$(top_builddir)/mysys/libmysys.a
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix)
mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
......
......@@ -860,6 +860,27 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
return 0;
}
/*
Open a new .sql file to dump the table or view into
SYNOPSIS
open_sql_file_for_table
name name of the table or view
RETURN VALUES
0 Failed to open file
> 0 Handle of the open file
*/
static FILE* open_sql_file_for_table(const char* table)
{
FILE* res;
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
return res;
}
static void safe_exit(int error)
{
......@@ -1411,11 +1432,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
if (!(sql_file= open_sql_file_for_table(table)))
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
......@@ -1580,11 +1597,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
if (!(sql_file= open_sql_file_for_table(table)))
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
......@@ -3345,6 +3358,41 @@ static char *primary_key_fields(const char *table_name)
}
/*
Replace a substring
SYNOPSIS
replace
ds_str The string to search and perform the replace in
search_str The string to search for
search_len Length of the string to search for
replace_str The string to replace with
replace_len Length of the string to replace with
RETURN
0 String replaced
1 Could not find search_str in str
*/
static int replace(DYNAMIC_STRING *ds_str,
const char *search_str, ulong search_len,
const char *replace_str, ulong replace_len)
{
const char *start= strstr(ds_str->str, search_str);
if (!start)
return 1;
DYNAMIC_STRING ds_tmp;
init_dynamic_string(&ds_tmp, "",
ds_str->length + replace_len, 256);
dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str);
dynstr_append_mem(&ds_tmp, replace_str, replace_len);
dynstr_append(&ds_tmp, start + search_len);
dynstr_set(ds_str, ds_tmp.str);
dynstr_free(&ds_tmp);
return 0;
}
/*
Getting VIEW structure
......@@ -3366,11 +3414,11 @@ static my_bool get_view_structure(char *table, char* db)
char *result_table, *opt_quoted_table;
char table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3];
char buff[20+FN_REFLEN];
char query[QUERY_LENGTH];
FILE *sql_file = md_result_file;
DBUG_ENTER("get_view_structure");
if (tFlag)
if (tFlag) /* Don't write table creation info */
DBUG_RETURN(0);
if (verbose)
......@@ -3384,36 +3432,32 @@ static my_bool get_view_structure(char *table, char* db)
result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
sprintf(buff,"show create table %s", result_table);
if (mysql_query(sock, buff))
snprintf(query, sizeof(query), "SHOW CREATE TABLE %s", result_table);
if (mysql_query_with_error_report(sock, &table_res, query))
{
fprintf(stderr, "%s: Can't get CREATE TABLE for view %s (%s)\n",
my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
}
/* Check if this is a view */
field= mysql_fetch_field_direct(table_res, 0);
if (strcmp(field->name, "View") != 0)
{
if (verbose)
fprintf(stderr, "-- It's base table, skipped\n");
DBUG_RETURN(0);
}
/* If requested, open separate .sql file for this view */
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
if (!(sql_file= open_sql_file_for_table(table)))
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(1);
}
write_header(sql_file, db);
}
table_res= mysql_store_result(sock);
field= mysql_fetch_field_direct(table_res, 0);
if (strcmp(field->name, "View") != 0)
{
if (verbose)
fprintf(stderr, "-- It's base table, skipped\n");
DBUG_RETURN(0);
}
if (!opt_xml && opt_comments)
{
......@@ -3430,11 +3474,102 @@ static my_bool get_view_structure(char *table, char* db)
check_io(sql_file);
}
row= mysql_fetch_row(table_res);
fprintf(sql_file, "/*!50001 %s*/;\n", row[1]);
check_io(sql_file);
mysql_free_result(table_res);
snprintf(query, sizeof(query),
"SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE " \
"FROM information_schema.views " \
"WHERE table_name=\"%s\" AND table_schema=\"%s\"", table, db);
if (mysql_query(sock, query))
{
/*
Use the raw output from SHOW CREATE TABLE if
information_schema query fails.
*/
row= mysql_fetch_row(table_res);
fprintf(sql_file, "/*!50001 %s */;\n", row[1]);
check_io(sql_file);
mysql_free_result(table_res);
}
else
{
char *ptr;
ulong *lengths;
char search_buf[256], replace_buf[256];
ulong search_len, replace_len;
DYNAMIC_STRING ds_view;
/* Save the result of SHOW CREATE TABLE in ds_view */
row= mysql_fetch_row(table_res);
lengths= mysql_fetch_lengths(table_res);
init_dynamic_string(&ds_view, row[1], lengths[1] + 1, 1024);
mysql_free_result(table_res);
/* Get the result from "select ... information_schema" */
if (!(table_res= mysql_store_result(sock)))
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(1);
}
row= mysql_fetch_row(table_res);
lengths= mysql_fetch_lengths(table_res);
/*
"WITH %s CHECK OPTION" is available from 5.0.2
Surround it with !50002 comments
*/
if (strcmp(row[0], "NONE"))
{
ptr= search_buf;
search_len= (ulong)(strxmov(ptr, "WITH ", row[0],
" CHECK OPTION", NullS) - ptr);
ptr= replace_buf;
replace_len=(ulong)(strxmov(ptr, "*/\n/*!50002 WITH ", row[0],
" CHECK OPTION", NullS) - ptr);
replace(&ds_view, search_buf, search_len, replace_buf, replace_len);
}
/*
"DEFINER=%s SQL SECURITY %s" is available from 5.0.13
Surround it with !50013 comments
*/
{
uint user_name_len;
char user_name_str[USERNAME_LENGTH + 1];
char quoted_user_name_str[USERNAME_LENGTH * 2 + 3];
uint host_name_len;
char host_name_str[HOSTNAME_LENGTH + 1];
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
parse_user(row[1], lengths[1], user_name_str, &user_name_len,
host_name_str, &host_name_len);
ptr= search_buf;
search_len=
(ulong)(strxmov(ptr, "DEFINER=",
quote_name(user_name_str, quoted_user_name_str, FALSE),
"@",
quote_name(host_name_str, quoted_host_name_str, FALSE),
" SQL SECURITY ", row[2], NullS) - ptr);
ptr= replace_buf;
replace_len=
(ulong)(strxmov(ptr, "*/\n/*!50013 DEFINER=",
quote_name(user_name_str, quoted_user_name_str, FALSE),
"@",
quote_name(host_name_str, quoted_host_name_str, FALSE),
" SQL SECURITY ", row[2],
" */\n/*!50001", NullS) - ptr);
replace(&ds_view, search_buf, search_len, replace_buf, replace_len);
}
/* Dump view structure to file */
fprintf(sql_file, "/*!50001 %s */;\n", ds_view.str);
check_io(sql_file);
mysql_free_result(table_res);
dynstr_free(&ds_view);
}
/* If a separate .sql file was opened, close it now */
if (sql_file != md_result_file)
{
fputs("\n", sql_file);
......
......@@ -145,13 +145,11 @@ static struct my_option my_long_options[] =
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h>
#if 0
{"use-threads", OPT_USE_THREADS,
"Load files in parallel. The argument is the number "
"of threads to use for loading data.",
(gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
#ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &current_user,
(gptr*) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
......@@ -292,7 +290,7 @@ static int write_to_table(char *filename, MYSQL *mysql)
DBUG_PRINT("enter",("filename: %s",filename));
fn_format(tablename, filename, "", "", 1 | 2); /* removes path & ext. */
if (! opt_local_file)
if (!opt_local_file)
strmov(hard_path,filename);
else
my_load_path(hard_path, filename, NULL); /* filename includes the path */
......@@ -640,9 +638,9 @@ int main(int argc, char **argv)
if (lock_tables)
lock_table(mysql, argc, argv);
for (; *argv != NULL; argv++)
if ((error=write_to_table(*argv, mysql)))
if ((error= write_to_table(*argv, mysql)))
if (exitcode == 0)
exitcode = error;
exitcode= error;
db_disconnect(current_host, mysql);
}
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
......
......@@ -74,7 +74,6 @@
#define MAX_QUERY (256*1024)
#define MAX_VAR_NAME 256
#define MAX_COLUMNS 256
#define PAD_SIZE 128
#define MAX_CONS 128
#define MAX_INCLUDE_DEPTH 16
#define INIT_Q_LINES 1024
......@@ -309,18 +308,6 @@ typedef struct
char *env_s;
} VAR;
#if defined(__NETWARE__) || defined(__WIN__)
/*
Netware doesn't proved environment variable substitution that is done
by the shell in unix environments. We do this in the following function:
*/
static char *subst_env_var(const char *cmd);
static FILE *my_popen(const char *cmd, const char *mode);
#undef popen
#define popen(A,B) my_popen((A),(B))
#endif /* __NETWARE__ */
VAR var_reg[10];
/*Perl/shell-like variable registers */
HASH var_hash;
......@@ -501,20 +488,20 @@ typedef struct st_pointer_array { /* when using array-strings */
struct st_replace;
struct st_replace *init_replace(my_string *from, my_string *to, uint count,
my_string word_end_chars);
uint replace_strings(struct st_replace *rep, my_string *start,
uint *max_length, const char *from);
void free_replace();
static void free_replace_regex();
static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name);
static void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
const char *from, int len);
void free_pointer_array(POINTER_ARRAY *pa);
static int initialize_replace_buffer(void);
static void do_eval(DYNAMIC_STRING *query_eval, const char *query);
static void str_to_file(const char *fname, char *str, int size);
int do_server_op(struct st_query *q,const char *op);
#ifdef __WIN__
static void free_win_path_patterns();
#endif
struct st_replace *glob_replace;
static char *out_buff;
static uint out_length;
static int eval_result = 0;
/* For column replace */
......@@ -542,7 +529,7 @@ static void handle_no_error(struct st_query *q);
static void do_eval(DYNAMIC_STRING* query_eval, const char *query)
{
const char *p;
register char c;
register char c, next_c;
register int escaped = 0;
VAR* v;
DBUG_ENTER("do_eval");
......@@ -564,13 +551,19 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char *query)
}
break;
case '\\':
next_c= *(p+1);
if (escaped)
{
escaped = 0;
dynstr_append_mem(query_eval, p, 1);
}
else
else if (next_c == '\\' || next_c == '$')
{
/* Set escaped only if next char is \ or $ */
escaped = 1;
}
else
dynstr_append_mem(query_eval, p, 1);
break;
default:
dynstr_append_mem(query_eval, p, 1);
......@@ -646,6 +639,9 @@ static void free_used_memory()
free_defaults(default_argv);
mysql_server_end();
free_re();
#ifdef __WIN__
free_win_path_patterns();
#endif
DBUG_VOID_RETURN;
}
......@@ -1031,17 +1027,7 @@ int do_require_manager(struct st_query *query __attribute__((unused)) )
}
#ifndef EMBEDDED_LIBRARY
int do_server_start(struct st_query *q)
{
return do_server_op(q, "start");
}
int do_server_stop(struct st_query *q)
{
return do_server_op(q, "stop");
}
int do_server_op(struct st_query *q, const char *op)
static int do_server_op(struct st_query *q, const char *op)
{
char *p= q->first_argument;
char com_buf[256], *com_p;
......@@ -1071,6 +1057,17 @@ int do_server_op(struct st_query *q, const char *op)
q->last_argument= p;
return 0;
}
int do_server_start(struct st_query *q)
{
return do_server_op(q, "start");
}
int do_server_stop(struct st_query *q)
{
return do_server_op(q, "stop");
}
#endif
......@@ -1124,16 +1121,21 @@ int do_source(struct st_query *query)
expected error array, previously set with the --error command.
It can thus be used to execute a command that shall fail.
NOTE
Although mysqltest is executed from cygwin shell, the command will be
executed in "cmd.exe". Thus commands like "rm" etc can NOT be used, use
system for those commands.
*/
static void do_exec(struct st_query *query)
{
int error;
DYNAMIC_STRING *ds= NULL;
char buf[1024];
FILE *res_file;
char *cmd= query->first_argument;
DYNAMIC_STRING ds_cmd;
DBUG_ENTER("do_exec");
DBUG_PRINT("enter", ("cmd: '%s'", cmd));
while (*cmd && my_isspace(charset_info, *cmd))
cmd++;
......@@ -1141,24 +1143,28 @@ static void do_exec(struct st_query *query)
die("Missing argument in exec");
query->last_argument= query->end;
DBUG_PRINT("info", ("Executing '%s'", cmd));
init_dynamic_string(&ds_cmd, 0, strlen(cmd)+256, 256);
/* Eval the command, thus replacing all environment variables */
do_eval(&ds_cmd, cmd);
cmd= ds_cmd.str;
DBUG_PRINT("info", ("Executing '%s' as '%s'",
query->first_argument, cmd));
if (!(res_file= popen(cmd, "r")) && query->abort_on_error)
die("popen(\"%s\", \"r\") failed", cmd);
die("popen(\"%s\", \"r\") failed", query->first_argument);
if (disable_result_log)
while (fgets(buf, sizeof(buf), res_file))
{
while (fgets(buf, sizeof(buf), res_file))
if (disable_result_log)
{
buf[strlen(buf)-1]=0;
DBUG_PRINT("exec_result",("%s", buf));
}
}
else
{
ds= &ds_res;
while (fgets(buf, sizeof(buf), res_file))
replace_dynstr_append(ds, buf);
else
{
replace_dynstr_append(&ds_res, buf);
}
}
error= pclose(res_file);
if (error != 0)
......@@ -1167,7 +1173,7 @@ static void do_exec(struct st_query *query)
my_bool ok= 0;
if (query->abort_on_error)
die("command \"%s\" failed", cmd);
die("command \"%s\" failed", query->first_argument);
DBUG_PRINT("info",
("error: %d, status: %d", error, status));
......@@ -1182,19 +1188,19 @@ static void do_exec(struct st_query *query)
{
ok= 1;
DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
cmd, status));
query->first_argument, status));
}
}
if (!ok)
die("command \"%s\" failed with wrong error: %d",
cmd, status);
query->first_argument, status);
}
else if (query->expected_errno[0].type == ERR_ERRNO &&
query->expected_errno[0].code.errnum != 0)
{
/* Error code we wanted was != 0, i.e. not an expected success */
die("command \"%s\" succeeded - should have failed with errno %d...",
cmd, query->expected_errno[0].code.errnum);
query->first_argument, query->expected_errno[0].code.errnum);
}
free_replace();
......@@ -1406,38 +1412,49 @@ int do_modify_var(struct st_query *query, const char *name,
}
int do_system(struct st_query *q)
/*
SYNOPSIS
do_system
command called command
DESCRIPTION
system <command>
Eval the query to expand any $variables in the command.
Execute the command withe the "system" command.
NOTE
If mysqltest is executed from cygwin shell, the command will be
executed in cygwin shell. Thus commands like "rm" etc can be used.
*/
int do_system(struct st_query *command)
{
DYNAMIC_STRING *ds;
char *p=q->first_argument;
VAR v;
var_init(&v, 0, 0, 0, 0);
eval_expr(&v, p, 0); /* NULL terminated */
ds= &ds_res;
DYNAMIC_STRING ds_cmd;
if (v.str_val_len)
if (strlen(command->first_argument) == 0)
die("Missing arguments to system, nothing to do!");
init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256);
/* Eval the system command, thus replacing all environment variables */
do_eval(&ds_cmd, command->first_argument);
DBUG_PRINT("info", ("running system command '%s' as '%s'",
command->first_argument, ds_cmd.str));
if (system(ds_cmd.str))
{
char expr_buf[1024];
if ((uint)v.str_val_len > sizeof(expr_buf) - 1)
v.str_val_len = sizeof(expr_buf) - 1;
memcpy(expr_buf, v.str_val, v.str_val_len);
expr_buf[v.str_val_len] = 0;
DBUG_PRINT("info", ("running system command '%s'", expr_buf));
if (system(expr_buf))
{
if (q->abort_on_error)
die("system command '%s' failed", expr_buf);
if (command->abort_on_error)
die("system command '%s' failed", command->first_argument);
/* If ! abort_on_error, log message and continue */
dynstr_append(ds, "system command '");
replace_dynstr_append(ds, expr_buf);
dynstr_append(ds, "' failed\n");
}
/* If ! abort_on_error, log message and continue */
dynstr_append(&ds_res, "system command '");
replace_dynstr_append(&ds_res, command->first_argument);
dynstr_append(&ds_res, "' failed\n");
}
else
die("Missing arguments to system, nothing to do!");
var_free(&v);
q->last_argument= q->end;
command->last_argument= command->end;
return 0;
}
......@@ -2205,8 +2222,7 @@ static void get_replace(struct st_query *q)
if (!(glob_replace=init_replace((char**) from_array.typelib.type_names,
(char**) to_array.typelib.type_names,
(uint) from_array.typelib.count,
word_end_chars)) ||
initialize_replace_buffer())
word_end_chars)))
die("Can't initialize replace from '%s'", q->query);
free_pointer_array(&from_array);
free_pointer_array(&to_array);
......@@ -2234,7 +2250,6 @@ void free_replace()
{
my_free((char*) glob_replace,MYF(0));
glob_replace=0;
my_free(out_buff,MYF(MY_WME));
}
DBUG_VOID_RETURN;
}
......@@ -2712,12 +2727,41 @@ int do_done(struct st_query *q)
}
/*
Process start of a "if" or "while" statement
SYNOPSIS
do_block()
cmd Type of block
q called command
DESCRIPTION
if ([!]<expr>)
{
<block statements>
}
while ([!]<expr>)
{
<block statements>
}
Evaluates the <expr> and if it evaluates to
greater than zero executes the following code block.
A '!' can be used before the <expr> to indicate it should
be executed if it evaluates to zero.
*/
int do_block(enum block_cmd cmd, struct st_query* q)
{
char *p= q->first_argument;
const char *expr_start, *expr_end;
VAR v;
const char *cmd_name= (cmd == cmd_while ? "while" : "if");
my_bool not_expr= FALSE;
DBUG_ENTER("do_block");
DBUG_PRINT("enter", ("%s", cmd_name));
/* Check stack overflow */
if (cur_block == block_stack_end)
......@@ -2738,8 +2782,16 @@ int do_block(enum block_cmd cmd, struct st_query* q)
/* Parse and evaluate test expression */
expr_start= strchr(p, '(');
if (!expr_start)
if (!expr_start++)
die("missing '(' in %s", cmd_name);
/* Check for !<expr> */
if (*expr_start == '!')
{
not_expr= TRUE;
expr_start++; /* Step past the '!' */
}
/* Find ending ')' */
expr_end= strrchr(expr_start, ')');
if (!expr_end)
die("missing ')' in %s", cmd_name);
......@@ -2753,14 +2805,20 @@ int do_block(enum block_cmd cmd, struct st_query* q)
die("Missing '{' after %s. Found \"%s\"", cmd_name, p);
var_init(&v,0,0,0,0);
eval_expr(&v, ++expr_start, &expr_end);
eval_expr(&v, expr_start, &expr_end);
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
cur_block->ok= (v.int_val ? TRUE : FALSE);
if (not_expr)
cur_block->ok = !cur_block->ok;
DBUG_PRINT("info", ("OK: %d", cur_block->ok));
var_free(&v);
DBUG_VOID_RETURN;
return 0;
}
......@@ -2878,10 +2936,16 @@ int read_line(char *buf, int size)
continue;
}
/* Line counting is independent of state */
if (c == '\n')
{
/* Line counting is independent of state */
cur_file->lineno++;
/* Convert cr/lf to lf */
if (p != buf && *(p-1) == '\r')
*(p-1)= 0;
}
switch(state) {
case R_NORMAL:
/* Only accept '{' in the beginning of a line */
......@@ -3050,7 +3114,7 @@ int read_query(struct st_query** q_ptr)
check_eol_junk(read_query_buf);
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("query: %s", read_query_buf));
if (*p == '#')
{
......@@ -3575,34 +3639,136 @@ static int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
}
/* Append the string to ds, with optional replace */
#ifdef __WIN__
static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
int len)
DYNAMIC_ARRAY patterns;
/*
init_win_path_patterns
DESCRIPTION
Setup string patterns that will be used to detect filenames that
needs to be converted from Win to Unix format
*/
static void init_win_path_patterns()
{
if (glob_replace)
/* List of string patterns to match in order to find paths */
const char* paths[] = { "$MYSQL_TEST_DIR", "./test/", 0 };
int num_paths= 2;
int i;
char* p;
DBUG_ENTER("init_win_path_patterns");
my_init_dynamic_array(&patterns, sizeof(const char*), 16, 16);
/* Loop through all paths in the array */
for (i= 0; i < num_paths; i++)
{
VAR* v;
if (*(paths[i]) == '$')
{
v= var_get(paths[i], 0, 0, 0);
p= my_strdup(v->str_val, MYF(MY_FAE));
}
else
p= my_strdup(paths[i], MYF(MY_FAE));
if (insert_dynamic(&patterns, (gptr) &p))
die(NullS);
DBUG_PRINT("info", ("p: %s", p));
while (*p)
{
if (*p == '/')
*p='\\';
p++;
}
}
DBUG_VOID_RETURN;
}
static void free_win_path_patterns()
{
int i= 0;
for (i=0 ; i < patterns.elements ; i++)
{
len=(int) replace_strings(glob_replace, &out_buff, &out_length, val);
if (len == -1)
die("Out of memory in replace");
val=out_buff;
const char** pattern= dynamic_element(&patterns, i, const char**);
my_free((gptr) *pattern, MYF(0));
}
delete_dynamic(&patterns);
}
/*
fix_win_paths
DESCRIPTION
Search the string 'val' for the patterns that are known to be
strings that contain filenames. Convert all \ to / in the
filenames that are found.
Ex:
val = 'Error "c:\mysql\mysql-test\var\test\t1.frm" didn't exist'
=> $MYSQL_TEST_DIR is found by strstr
=> all \ from c:\mysql\m... until next space is converted into /
*/
static void fix_win_paths(const char* val, int len)
{
uint i;
char *p;
DBUG_ENTER("fix_win_paths");
for (i= 0; i < patterns.elements; i++)
{
const char** pattern= dynamic_element(&patterns, i, const char**);
DBUG_PRINT("info", ("pattern: %s", *pattern));
/* Search for the path in string */
while ((p= strstr(val, *pattern)))
{
DBUG_PRINT("info", ("Found %s in val p: %s", *pattern, p));
while (*p && !my_isspace(charset_info, *p))
{
if (*p == '\\')
*p= '/';
p++;
}
DBUG_PRINT("info", ("Converted \\ to /, p: %s", p));
}
}
DBUG_PRINT("exit", (" val: %s, len: %d", val, len));
DBUG_VOID_RETURN;
}
#endif
/* Append the string to ds, with optional replace */
static void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
const char *val, int len)
{
#ifdef __WIN__
fix_win_paths(val, len);
#endif
if (glob_replace_regex)
{
if (!multi_reg_replace(glob_replace_regex,(char*)val))
{
val= glob_replace_regex->buf;
if (!multi_reg_replace(glob_replace_regex, (char*)val))
{
val= glob_replace_regex->buf;
len= strlen(val);
}
}
}
dynstr_append_mem(ds, val, len);
if (glob_replace)
replace_strings_append(glob_replace, ds, val, len);
else
dynstr_append_mem(ds, val, len);
}
/* Append zero-terminated string to ds, with optional replace */
static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val)
{
replace_dynstr_append_mem(ds, val, strlen(val));
......@@ -3616,8 +3782,6 @@ static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val)
static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
const char* val, ulonglong len, bool is_null)
{
char buf[256];
if (col_idx < max_replace_column && replace_column[col_idx])
{
val= replace_column[col_idx];
......@@ -4920,6 +5084,10 @@ int main(int argc, char **argv)
init_var_hash(&cur_con->mysql);
#ifdef __WIN__
init_win_path_patterns();
#endif
/*
Initialize $mysql_errno with -1, so we can
- distinguish it from valid values ( >= 0 ) and
......@@ -5990,60 +6158,57 @@ static uint replace_len(my_string str)
}
/* Replace strings; Return length of result string */
uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
const char *from)
/* Replace strings while appending to ds */
void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
const char *str, int len)
{
reg1 REPLACE *rep_pos;
reg2 REPLACE_STRING *rep_str;
my_string to,end,pos,new_str;
const char *start, *from;
DBUG_ENTER("replace_strings_append");
end=(to= *start) + *max_length-1;
start= from= str;
rep_pos=rep+1;
for (;;)
{
/* Loop through states */
DBUG_PRINT("info", ("Looping through states"));
while (!rep_pos->found)
{
rep_pos= rep_pos->next[(uchar) *from];
if (to == end)
{
(*max_length)+=8192;
if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
to=new_str+(to - *start);
end=(*start=new_str)+ *max_length-1;
}
*to++= *from++;
}
rep_pos= rep_pos->next[(uchar) *from++];
/* Does this state contain a string to be replaced */
if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string)
return (uint) (to - *start)-1;
to-=rep_str->to_offset;
for (pos=rep_str->replace_string; *pos ; pos++)
{
if (to == end)
{
(*max_length)*=2;
if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
to=new_str+(to - *start);
end=(*start=new_str)+ *max_length-1;
}
*to++= *pos;
/* No match found */
dynstr_append_mem(ds, start, from - start - 1);
DBUG_PRINT("exit", ("Found no more string to replace, appended: %s", start));
DBUG_VOID_RETURN;
}
/* Found a string that needs to be replaced */
DBUG_PRINT("info", ("found: %d, to_offset: %d, from_offset: %d, string: %s",
rep_str->found, rep_str->to_offset,
rep_str->from_offset, rep_str->replace_string));
/* Append part of original string before replace string */
dynstr_append_mem(ds, start, (from - rep_str->to_offset) - start);
/* Append replace string */
dynstr_append_mem(ds, rep_str->replace_string,
strlen(rep_str->replace_string));
if (!*(from-=rep_str->from_offset) && rep_pos->found != 2)
return (uint) (to - *start);
{
/* End of from string */
DBUG_PRINT("exit", ("Found end of from string"));
DBUG_VOID_RETURN;
}
DBUG_ASSERT(from <= str+len);
start= from;
rep_pos=rep;
}
}
static int initialize_replace_buffer(void)
{
out_length=8192;
if (!(out_buff=my_malloc(out_length,MYF(MY_WME))))
return(1);
return 0;
}
/****************************************************************************
Replace results for a column
......@@ -6102,105 +6267,6 @@ static void get_replace_column(struct st_query *q)
q->last_argument= q->end;
}
#if defined(__NETWARE__) || defined(__WIN__)
/*
Substitute environment variables with text.
SYNOPSIS
subst_env_var()
arg String that should be substitute
DESCRIPTION
This function takes a string as an input and replaces the
environment variables, that starts with '$' character, with it value.
NOTES
Return string must be freed with my_free()
RETURN
String with environment variables replaced.
*/
static char *subst_env_var(const char *str)
{
char *result;
char *pos;
result= pos= my_malloc(MAX_QUERY, MYF(MY_FAE));
while (*str)
{
/*
need this only when we want to provide the functionality of
escaping through \ 'backslash'
if ((result == pos && *str=='$') ||
(result != pos && *str=='$' && str[-1] !='\\'))
*/
if (*str == '$')
{
char env_var[256], *env_pos= env_var, *subst;
/* Search for end of environment variable */
for (str++;
*str && !isspace(*str) && *str != '\\' && *str != '/' &&
*str != '$';
str++)
*env_pos++= *str;
*env_pos= 0;
if (!(subst= getenv(env_var)))
{
my_free(result, MYF(0));
die("MYSQLTEST.NLM: Environment variable %s is not defined",
env_var);
}
/* get the string to be substitued for env_var */
pos= strmov(pos, subst);
/* Process delimiter in *str again */
}
else
*pos++= *str++;
}
*pos= 0;
return result;
}
/*
popen replacement for Netware
SYNPOSIS
my_popen()
name Command to execute (with possible env variables)
mode Mode for popen.
NOTES
Environment variable expansion does not take place for popen function
on NetWare, so we use this function to wrap around popen to do this.
For the moment we ignore 'mode' and always use 'r0'
RETURN
# >= 0 File handle
-1 Error
*/
#undef popen /* Remove wrapper */
#ifdef __WIN__
#define popen _popen /* redefine for windows */
#endif
FILE *my_popen(const char *cmd, const char *mode __attribute__((unused)))
{
char *subst_cmd;
FILE *res_file;
subst_cmd= subst_env_var(cmd);
res_file= popen(subst_cmd, "r0");
my_free(subst_cmd, MYF(0));
return res_file;
}
#endif /* __NETWARE__ or __WIN__*/
......@@ -1109,7 +1109,7 @@ read_history(const char *filename)
if (h == NULL || e == NULL)
rl_initialize();
return (history(h, &ev, H_LOAD, filename));
return (history(h, &ev, H_LOAD, filename) == -1);
}
......@@ -1123,7 +1123,7 @@ write_history(const char *filename)
if (h == NULL || e == NULL)
rl_initialize();
return (history(h, &ev, H_SAVE, filename));
return (history(h, &ev, H_SAVE, filename) == -1);
}
......
......@@ -211,7 +211,7 @@ typedef uint rf_SetTimer;
#define my_sigset(A,B) signal((A),(B))
#define finite(A) _finite(A)
#define sleep(A) Sleep((A)*1000)
#define popen(A) popen(A,B) _popen((A),(B))
#define popen(A,B) _popen((A),(B))
#define pclose(A) _pclose(A)
#ifndef __BORLANDC__
......
......@@ -1364,8 +1364,12 @@ mysql_stat(MYSQL *mysql)
int STDCALL
mysql_ping(MYSQL *mysql)
{
int res;
DBUG_ENTER("mysql_ping");
DBUG_RETURN(simple_command(mysql,COM_PING,0,0,0));
res= simple_command(mysql,COM_PING,0,0,0);
if (res == CR_SERVER_LOST && mysql->reconnect)
res= simple_command(mysql,COM_PING,0,0,0);
DBUG_RETURN(res);
}
......
......@@ -162,6 +162,7 @@ our $path_slave_load_tmpdir; # What is this?!
our $path_mysqltest_log;
our $path_my_basedir;
our $opt_vardir; # A path but set directly on cmd line
our $opt_vardir_trace; # unix formatted opt_vardir for trace files
our $opt_tmpdir; # A path but set directly on cmd line
our $opt_restart_cleanup; # Source a file with SQL drop statements
......@@ -692,7 +693,7 @@ sub command_line_setup () {
{
$opt_vardir= "$glob_mysql_test_dir/var";
}
$opt_vardir_trace= $opt_vardir;
# We make the path absolute, as the server will do a chdir() before usage
unless ( $opt_vardir =~ m,^/, or
($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
......@@ -981,7 +982,8 @@ sub executable_setup () {
if ( $glob_win32 )
{
$path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
"$glob_basedir/bin");
"$glob_basedir/client_debug",
"$glob_basedir/bin",);
$exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-max",
"$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld",
......@@ -1031,6 +1033,7 @@ sub executable_setup () {
}
$exe_mysql_client_test=
mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
"$path_client_bindir/mysql_client_test",
"/usr/bin/false");
}
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
......@@ -1143,9 +1146,7 @@ sub environment_setup () {
$ENV{'LC_COLLATE'}= "C";
$ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server;
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
$ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir;
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
$ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'};
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'};
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'};
$ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'};
......@@ -1169,16 +1170,6 @@ sub environment_setup () {
$ENV{'IM_MYSQLD2_PORT'}= $instance_manager->{instances}->[1]->{port};
$ENV{'IM_MYSQLD2_PATH_PID'}=$instance_manager->{instances}->[1]->{path_pid};
if ( $glob_cygwin_perl )
{
foreach my $key ('MYSQL_TEST_WINDIR','MASTER_MYSOCK')
{
$ENV{$key}= `cygpath -w $ENV{$key}`;
$ENV{$key} =~ s,\\,\\\\,g;
chomp($ENV{$key});
}
}
$ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set
# We are nice and report a bit about our settings
......@@ -2490,12 +2481,12 @@ sub mysqld_arguments ($$$$$$) {
if ( $type eq 'master' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace",
$prefix, $opt_vardir, $sidx);
$prefix, $opt_vardir_trace, $sidx);
}
if ( $type eq 'slave' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace",
$prefix, $opt_vardir, $sidx);
$prefix, $opt_vardir_trace, $sidx);
}
}
......@@ -2876,7 +2867,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlcheck .=
" --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqldump.trace";
}
my $cmdline_mysqldump= "$exe_mysqldump --no-defaults -uroot " .
......@@ -2889,7 +2880,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqldump .=
" --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqldump.trace";
}
my $cmdline_mysqlslap;
......@@ -2903,7 +2894,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlslap .=
" --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqldump.trace";
}
}
......@@ -2913,7 +2904,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlimport .=
" --debug=d:t:A,$opt_vardir/log/mysqlimport.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqlimport.trace";
}
my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " .
......@@ -2922,7 +2913,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlshow .=
" --debug=d:t:A,$opt_vardir/log/mysqlshow.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqlshow.trace";
}
my $cmdline_mysqlbinlog=
......@@ -2933,7 +2924,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlbinlog .=
" --debug=d:t:A,$opt_vardir/log/mysqlbinlog.trace";
" --debug=d:t:A,$opt_vardir_trace/log/mysqlbinlog.trace";
}
my $cmdline_mysql=
......@@ -3075,7 +3066,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir);
mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir_trace);
}
if ( $opt_ssl_supported )
......
......@@ -1464,7 +1464,10 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -1797,7 +1800,9 @@ DROP TABLE IF EXISTS `v1`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`a` AS `a` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -1853,7 +1858,10 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -1959,13 +1967,19 @@ DROP TABLE IF EXISTS `v3`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7))*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7)) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v3`.`a` AS `a` from (`v3` join `v1`) where ((`v1`.`a` = `v3`.`a`) and (`v3`.`b` = 3)) limit 1*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `v3`.`a` AS `a` from (`v3` join `v1`) where ((`v1`.`a` = `v3`.`a`) and (`v3`.`b` = 3)) limit 1 */;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -2399,10 +2413,10 @@ drop table t1;
set global time_zone=default;
set time_zone=default;
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t1 test` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t2 test` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -2534,13 +2548,19 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1` */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......@@ -2650,3 +2670,204 @@ DELIMITER ;
DROP TRIGGER tr1;
DROP TABLE t1;
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
create definer = CURRENT_USER view v1 as select * from t1;
create SQL SECURITY INVOKER view v2 as select * from t1;
create view v3 as select * from t1 with local check option;
create algorithm=merge view v4 as select * from t1 with cascaded check option;
create algorithm =temptable view v5 as select * from t1;
drop table t1;
drop view v1, v2, v3, v4, v5;
show tables;
Tables_in_test
t1
v1
v2
v3
v4
v5
select * from v3 order by a;
a
234
289
298
456
789
drop table t1;
drop view v1, v2, v3, v4, v5;
create table t1 (a text , b text);
create table t2 (a text , b text);
insert t1 values ("Duck, Duck", "goose");
insert t1 values ("Duck, Duck", "pidgeon");
insert t2 values ("We the people", "in order to perform");
insert t2 values ("a more perfect", "union");
select * from t1;
a b
Duck, Duck goose
Duck, Duck pidgeon
select * from t2;
a b
We the people in order to perform
a more perfect union
test.t1: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
test.t2: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
select * from t1;
a b
Duck, Duck goose
Duck, Duck pidgeon
Duck, Duck goose
Duck, Duck pidgeon
select * from t2;
a b
We the people in order to perform
a more perfect union
We the people in order to perform
a more perfect union
create table words(a varchar(255));
create table words2(b varchar(255));
select * from t1;
a b
Duck, Duck goose
Duck, Duck pidgeon
Duck, Duck goose
Duck, Duck pidgeon
Duck, Duck goose
Duck, Duck pidgeon
select * from t2;
a b
We the people in order to perform
a more perfect union
We the people in order to perform
a more perfect union
We the people in order to perform
a more perfect union
select * from words;
a
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
Aberdeen
Abernathy
aberrant
aberration
select * from words2;
b
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
Aberdeen
Abernathy
aberrant
aberration
drop table words;
mysql-import: Error: 1146, Table 'test.words' doesn't exist, when using table: words
drop table t1;
drop table t2;
drop table words2;
......@@ -323,7 +323,10 @@ test
test2
test3
test4
Counter is greater than 0, (counter=10)
Counter is not 0, (counter=0)
1
Testing while with not
mysqltest: In included file "./include/mysqltest_while.inc": At line 64: Nesting too deeply
mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while
......
......@@ -64,13 +64,10 @@ a
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
Qcache_queries_in_cache 3
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
Qcache_inserts 4
drop table t1, t2;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
......
......@@ -539,7 +539,7 @@ drop procedure if exists into_outfile|
create procedure into_outfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
select * into outfile "/tmp/spout" from test.t1;
select * into outfile "../tmp/spout" from test.t1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_outfile("ofile", 1)|
......@@ -549,7 +549,7 @@ drop procedure if exists into_dumpfile|
create procedure into_dumpfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
select * into dumpfile "/tmp/spdump" from test.t1 limit 1;
select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_dumpfile("dfile", 1)|
......
......@@ -6,3 +6,11 @@ ERROR HY000: MySQL server has gone away
select 3;
3
3
select 1;
1
1
select 2;
ERROR HY000: MySQL server has gone away
select 3;
3
3
......@@ -9,13 +9,13 @@ create table t1 (
`a>b` text
);
insert into t1 values (1, 2, 'a&b a<b a>b');
--exec $MYSQL --xml test -e 'select * from t1'
--exec $MYSQL --xml test -e "select * from t1"
--exec $MYSQL_DUMP --xml --skip-create test
--exec $MYSQL --xml test -e 'select count(*) from t1'
--exec $MYSQL --xml test -e 'select 1 < 2 from dual'
--exec $MYSQL --xml test -e 'select 1 > 2 from dual'
--exec $MYSQL --xml test -e 'select 1 & 3 from dual'
--exec $MYSQL --xml test -e 'select null from dual'
--exec $MYSQL --xml test -e "select count(*) from t1"
--exec $MYSQL --xml test -e "select 1 < 2 from dual"
--exec $MYSQL --xml test -e "select 1 > 2 from dual"
--exec $MYSQL --xml test -e "select 1 & 3 from dual"
--exec $MYSQL --xml test -e "select null from dual"
drop table t1;
......@@ -36,4 +36,3 @@ rpl_sp : Bug#16456
rpl_until : Unstable test case, bug#15886
sp-goto : GOTO is currently is disabled - will be fixed in the future
rpl_ndb_log : results are not deterministic
mysqldump : Bug#17443 mysqlimport --use-threads=5 gives crashes
......@@ -9,7 +9,6 @@
# var/log/mysql_client_test.trace
--disable_result_log
--exec echo $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
# End of 4.1 tests
......
......@@ -647,7 +647,7 @@ select '------ Testing with illegal table names ------' as test_sequence ;
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\t1" 2>&1
--error 6
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\\\t1" 2>&1
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\\\\\t1" 2>&1
--error 6
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "t\1" 2>&1
......@@ -840,11 +840,11 @@ DROP TABLE t1, t2;
# Bugs #9136, #12917: problems with --defaults-extra-file option
#
--exec echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf
--exec echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf
--system echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf
--system echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf
--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1
--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1
--exec rm $MYSQLTEST_VARDIR/tmp/tmp.cnf
--system rm $MYSQLTEST_VARDIR/tmp/tmp.cnf
#
# Test of fix to BUG 12597
......@@ -960,15 +960,16 @@ set time_zone=default;
#
--disable_warnings
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
--enable_warnings
CREATE TABLE `t1 test` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t2 test` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--enable_warnings
DELIMITER //;
CREATE TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
......@@ -983,11 +984,10 @@ SELECT * FROM `t2 test`;
# quoted
--exec $MYSQL_DUMP --skip-comments --compatible=ansi --triggers test
--disable_warnings
DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
--enable_warnings
#
# BUG# 12838 mysqldump -x with views exits with error
#
......@@ -1049,8 +1049,37 @@ SET SQL_MODE = @old_sql_mode;
DROP TRIGGER tr1;
DROP TABLE t1;
--disable_parsing
#
#
# Bug 14871 Invalid view dump output
#
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
create definer = CURRENT_USER view v1 as select * from t1;
create SQL SECURITY INVOKER view v2 as select * from t1;
create view v3 as select * from t1 with local check option;
create algorithm=merge view v4 as select * from t1 with cascaded check option;
create algorithm =temptable view v5 as select * from t1;
# dump tables and views
--exec $MYSQL_DUMP test > var/tmp/bug14871.sql
# drop the db, tables and views
drop table t1;
drop view v1, v2, v3, v4, v5;
# Reload dump
--exec $MYSQL test < var/tmp/bug14871.sql
# check that all tables and views could be created
show tables;
select * from v3 order by a;
drop table t1;
drop view v1, v2, v3, v4, v5;
# Added for use-thread option
#
create table t1 (a text , b text);
......@@ -1070,7 +1099,22 @@ select * from t2;
--exec $MYSQL_IMPORT --silent --use-threads=5 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
select * from t1;
select * from t2;
# Now we test with multiple threads, but less threads than files.
create table words(a varchar(255));
create table words2(b varchar(255));
--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat
select * from t1;
select * from t2;
select * from words;
select * from words2;
# Drop table "words" and run with threads, should fail
drop table words;
--replace_regex /.*mysqlimport/mysql-import/
--error 1
--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat 2>&1
drop table t1;
drop table t2;
--enable_parsing
drop table words2;
......@@ -431,7 +431,7 @@ echo ;
# Illegal use of echo
--error 1
--exec echo "echo $;" | $MYSQL_TEST 2>&1
--exec echo "echo \$;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
......@@ -518,19 +518,19 @@ echo $novar1;
--exec echo "let ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $=hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $1 hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $m hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $ hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let =hi;" | $MYSQL_TEST 2>&1
......@@ -690,7 +690,7 @@ echo $i;
--error 1
--exec echo "inc i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
--exec echo "let \\\$i=100; inc \\\$i 1000; echo \\\$i;" | $MYSQL_TEST 2>&1
inc $i; inc $i; inc $i; --echo $i
echo $i;
......@@ -718,7 +718,7 @@ echo $d;
--error 1
--exec echo "dec i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
--exec echo "let \\\$i=100; dec \\\$i 1000; echo \\\$i;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
......@@ -754,6 +754,30 @@ echo test3stop
--delimiter ;
echo test4;
# ----------------------------------------------------------------------------
# Test if
# ----------------------------------------------------------------------------
let $counter=10;
if ($counter)
{
echo Counter is greater than 0, (counter=10);
}
if (!$counter)
{
echo Counter is not 0, (counter=10);
}
let $counter=0;
if ($counter)
{
echo Counter is greater than 0, (counter=0);
}
if (!$counter)
{
echo Counter is not 0, (counter=0);
}
# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------
......@@ -767,17 +791,22 @@ while ($i)
# One liner
#let $i=1;while ($i){echo $i;dec $i;}
let $i=0;
while (!$i)
{
echo Testing while with not;
inc $i;
}
# Exceed max nesting level
--error 1
--exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "while \$i;" | $MYSQL_TEST 2>&1
--exec echo "while \\\$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "while (\$i;" | $MYSQL_TEST 2>&1
--exec echo "while (\\\$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1
--exec echo "let \\\$i=1; while (\\\$i) dec \\\$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "};" | $MYSQL_TEST 2>&1
--error 1
......@@ -889,22 +918,22 @@ select "a" as col1, "c" as col2;
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect
--exec echo "let \$i=100;" > $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "let \\\$i=100;" > $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "while (\\\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " dec \\\$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql; echo OK;" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect, exceed max number of connections
--exec echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "let \\\$i=200;" > $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "while (\\\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo " dec \\\$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql
--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
......@@ -1022,7 +1051,7 @@ select "this will be executed";
#
# Test that a test file that does not generate any output fails.
#
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
--exec echo "let \\\$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1
......
......@@ -24,10 +24,6 @@ set GLOBAL ndb_cache_check_time=1;
reset query cache;
flush status;
# Sleep so that the query cache check thread has time to start
sleep 15;
# Create test tables in NDB and load them into cache
# on server1
connection server1;
......@@ -53,19 +49,34 @@ show status like "Qcache_inserts";
show status like "Qcache_hits";
update t1 set a=3 where a=2;
# Sleep so that the query cache check thread has time to run
sleep 5;
# Connect to server1 and check that cache is invalidated
# and correct data is returned
connection server1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
# Loop and wait for max 10 seconds until query cache thread
# has invalidated the cache and the column a in t1 is equal to 3
let $retries=20;
while (`select a != 3 from t1`)
{
dec $retries;
if (!$retries)
{
The query_cache thread failed to invalidate query_cache in 10 seconds;
}
sleep 0.5;
}
# Select from t1 one last time for the result file
# Column a should be 3
select * from t1;
# There should now be three queries in the cache
show status like "Qcache_queries_in_cache";
# And inserts should be four
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop table t1, t2;
......
......@@ -4,7 +4,7 @@
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null
......
......@@ -171,19 +171,20 @@ DROP TABLE t1;
#
# BUG: 14354 Partitions: data directory clause fails
#
--exec rm -rf $MYSQL_TEST_DIR/bug14354
--exec mkdir $MYSQL_TEST_DIR/bug14354
--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354
disable_query_log;
eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm
DATA DIRECTORY="$MYSQL_TEST_DIR/bug14354"
INDEX DIRECTORY="$MYSQL_TEST_DIR/bug14354");
PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm
DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"
INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354");
enable_query_log;
INSERT INTO t1 VALUES (15);
--exec test -f $MYSQL_TEST_DIR/bug14354/t1#P#p1.MYD
--exec test -f $MYSQL_TEST_DIR/bug14354/t1#P#p1.MYI
--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYD
--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYI
DROP TABLE t1;
--exec rm -rf $MYSQL_TEST_DIR/bug14354
--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
#
# Bug# 16534 - Trying to add multiple partitions crashes server
......
......@@ -18,7 +18,7 @@ show slave status;
change master to master_host='127.0.0.1';
# The following needs to be cleaned up when change master is fixed
--replace_result $MASTER_MYPORT MASTER_PORT $MYSQL_TCP_PORT MASTER_PORT
--replace_result $MYSQL_TCP_PORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
--replace_result $MASTER_MYPORT MASTER_PORT
......
......@@ -702,13 +702,13 @@ drop procedure if exists into_outfile|
create procedure into_outfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
select * into outfile "/tmp/spout" from test.t1;
select * into outfile "../tmp/spout" from test.t1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
system rm -f /tmp/spout|
--system rm -f $MYSQLTEST_VARDIR/tmp/spout
call into_outfile("ofile", 1)|
system rm -f /tmp/spout|
--system rm -f $MYSQLTEST_VARDIR/tmp/spout
delete from t1|
drop procedure into_outfile|
......@@ -718,13 +718,13 @@ drop procedure if exists into_dumpfile|
create procedure into_dumpfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
select * into dumpfile "/tmp/spdump" from test.t1 limit 1;
select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
system rm -f /tmp/spdump|
--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
call into_dumpfile("dfile", 1)|
system rm -f /tmp/spdump|
--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
delete from t1|
drop procedure into_dumpfile|
......
......@@ -81,7 +81,8 @@ engine=MyISAM;
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N');
-- exec $MYSQL_FIX_SYSTEM_TABLES --database=test
# Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system
-- system $MYSQL_FIX_SYSTEM_TABLES --database=test > /dev/null
-- enable_query_log
-- enable_result_log
......
......@@ -6,9 +6,25 @@
#
--disable_reconnect
select 1;
# wait_timeout is 2, so we should get disconnected now
--sleep 5
# wait_timeout is 1, so we should get disconnected now
--sleep 2
# When the connection is closed in this way, the error code should
# be consistent see bug#2845 for an explanation
--error 2006
select 2;
--enable_reconnect
select 3;
# Do the same test as above on a TCP connection
connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,);
--disable_reconnect
select 1;
# wait_timeout is 1, so we should get disconnected now
--sleep 2
# When the connection is closed in this way, the error code should
# be consistent see bug#2845 for an explanation
--error 2006
select 2;
--enable_reconnect
select 3;
disconnect con1;
......@@ -194,30 +194,93 @@ my_bool net_realloc(NET *net, ulong length)
DBUG_RETURN(0);
}
/* Remove unwanted characters from connection */
/*
Check if there is any data to be read from the socket
SYNOPSIS
net_data_is_ready()
sd socket descriptor
DESCRIPTION
Check if there is any data to be read from the socket.
RETURN VALUES
0 No data to read
1 Data or EOF to read
*/
static my_bool net_data_is_ready(my_socket sd)
{
fd_set sfds;
struct timeval tv;
int res;
FD_ZERO(&sfds);
FD_SET(sd, &sfds);
tv.tv_sec= tv.tv_usec= 0;
if ((res= select(sd+1, &sfds, NULL, NULL, &tv)) < 0)
return FALSE;
else
return test(res ? FD_ISSET(sd, &sfds) : 0);
}
/*
Remove unwanted characters from connection
and check if disconnected
SYNOPSIS
net_clear()
net NET handler
DESCRIPTION
Read from socket until there is nothing more to read. Discard
what is read.
If there is anything when to read 'net_clear' is called this
normally indicates an error in the protocol.
When connection is properly closed (for TCP it means with
a FIN packet), then select() considers a socket "ready to read",
in the sense that there's EOF to read, but read() returns 0.
*/
void net_clear(NET *net)
{
int count;
DBUG_ENTER("net_clear");
#if !defined(EXTRA_DEBUG) && !defined(EMBEDDED_LIBRARY)
#if !defined(EMBEDDED_LIBRARY)
while(net_data_is_ready(net->vio->sd))
{
int count; /* One may get 'unused' warn */
my_bool old_mode;
if (!vio_blocking(net->vio, FALSE, &old_mode))
/* The socket is ready */
if ((count= vio_read(net->vio, (char*) (net->buff),
(uint32) net->max_packet)) > 0)
{
while ((count = vio_read(net->vio, (char*) (net->buff),
(uint32) net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s",
count, vio_description(net->vio)));
vio_blocking(net->vio, TRUE, &old_mode);
DBUG_PRINT("info",("skipped %d bytes from file: %s",
count, vio_description(net->vio)));
#ifdef EXTRA_DEBUG
fprintf(stderr,"skipped %d bytes from file: %s\n",
count, vio_description(net->vio));
#endif
}
else
{
DBUG_PRINT("info",("socket ready but only EOF to read - disconnected"));
net->error= 2;
break;
}
}
#endif /* EXTRA_DEBUG */
#endif
net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */
net->write_pos=net->buff;
DBUG_VOID_RETURN;
}
/* Flush write_buffer if not empty. */
my_bool net_flush(NET *net)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment