Commit 0b9c9210 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

merge

parents d24f3b5e b1cb5b6f
......@@ -43,7 +43,7 @@
**********************************************************************/
#define MTEST_VERSION "1.8"
#define MTEST_VERSION "1.10"
#include <global.h>
#include <my_sys.h>
......@@ -84,7 +84,7 @@
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
static char *db = 0, *pass=0;
const char* user = 0, *host = 0, *unix_sock = 0;
static int port = 0;
static int port = 0, opt_big_test=0;
static uint start_lineno, *lineno;
static char **default_argv;
......@@ -95,9 +95,13 @@ static FILE** cur_file;
static FILE** file_stack_end;
static uint lineno_stack[MAX_INCLUDE_DEPTH];
static char TMPDIR[FN_REFLEN];
static int *block_ok_stack_end;
static int block_stack[BLOCK_STACK_DEPTH];
static int *cur_block, *block_stack_end;
static int block_stack[BLOCK_STACK_DEPTH];
static int block_ok_stack[BLOCK_STACK_DEPTH];
static uint global_expected_errno[MAX_EXPECTED_ERRORS];
DYNAMIC_ARRAY q_lines;
......@@ -121,7 +125,7 @@ typedef struct
PARSER parser;
MASTER_POS master_pos;
int block_ok = 1; /* set to 0 if the current block should not be executed */
int* block_ok; /* set to 0 if the current block should not be executed */
int false_block_depth = 0;
const char* result_file = 0; /* if set, all results are concated and
compared against this file*/
......@@ -159,6 +163,8 @@ Q_SYNC_WITH_MASTER, Q_ERROR,
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND
......@@ -167,7 +173,7 @@ Q_COMMENT_WITH_COMMAND
/* this should really be called command */
struct st_query
{
char *query, *query_buf,*first_argument;
char *query, *query_buf,*first_argument,*end;
int first_word_len;
my_bool abort_on_error, require_file;
uint expected_errno[MAX_EXPECTED_ERRORS];
......@@ -188,6 +194,8 @@ const char *command_names[] = {
"send", "reap",
"dirty_close", "replace_result",
"ping", "eval",
"rpl_probe", "enable_rpl_parse",
"disable_rpl_parse", "eval_result",
0
};
......@@ -199,7 +207,7 @@ static void die(const char* fmt, ...);
static void init_var_hash();
static byte* get_var_key(const byte* rec, uint* len,
my_bool __attribute__((unused)) t);
static VAR* var_init(const char* name, int name_len, const char* val,
static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
int val_len);
static void var_free(void* v);
......@@ -230,10 +238,21 @@ void free_pointer_array(POINTER_ARRAY *pa);
static int initialize_replace_buffer(void);
static void free_replace_buffer(void);
static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
void str_to_file(const char* fname, char* str, int size);
struct st_replace *glob_replace;
static char *out_buff;
static uint out_length;
static int eval_result = 0;
/* Disable functions that only exist in MySQL 4.0 */
#if MYSQL_VERSION_ID < 40000
static void mysql_enable_rpl_parse(MYSQL* mysql) {}
static void mysql_disable_rpl_parse(MYSQL* mysql) {}
static int mysql_rpl_parse_enabled(MYSQL* mysql) { return 1; }
static int mysql_rpl_probe(MYSQL *mysql) { return 1; }
#endif
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
{
......@@ -290,7 +309,7 @@ static void close_files()
{
do
{
if (*cur_file != stdin)
if (*cur_file != stdin && *cur_file)
my_fclose(*cur_file,MYF(0));
} while (cur_file-- != file_stack);
}
......@@ -352,7 +371,9 @@ static void abort_not_supported_test()
static void verbose_msg(const char* fmt, ...)
{
va_list args;
if (!verbose) return;
DBUG_ENTER("verbose_msg");
if (!verbose)
DBUG_VOID_RETURN;
va_start(args, fmt);
......@@ -360,6 +381,7 @@ static void verbose_msg(const char* fmt, ...)
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
DBUG_VOID_RETURN;
}
......@@ -382,24 +404,52 @@ int hex_val(int c)
int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
{
MY_STAT stat_info;
char *tmp;
char *tmp, *res_ptr;
char eval_file[FN_REFLEN];
int res;
uint res_len;
int fd;
DYNAMIC_STRING res_ds;
DBUG_ENTER("dyn_string_cmp");
if (!my_stat(fname, &stat_info, MYF(MY_WME)))
die(NullS);
if (stat_info.st_size != ds->length)
if (!eval_result && stat_info.st_size != ds->length)
DBUG_RETURN(2);
if (!(tmp = (char*) my_malloc(ds->length, MYF(MY_WME))))
if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
die(NullS);
if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
die(NullS);
if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
die(NullS);
res = (memcmp(tmp, ds->str, stat_info.st_size)) ? 1 : 0;
tmp[stat_info.st_size] = 0;
init_dynamic_string(&res_ds, "", 0, 65536);
if (eval_result)
{
do_eval(&res_ds, tmp);
res_ptr = res_ds.str;
if((res_len = res_ds.length) != ds->length)
{
res = 2;
goto err;
}
}
else
{
res_ptr = tmp;
res_len = stat_info.st_size;
}
res = (memcmp(res_ptr, ds->str, res_len)) ? 1 : 0;
err:
if(res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
res_len);
my_free((gptr) tmp, MYF(0));
my_close(fd, MYF(MY_WME));
dynstr_free(&res_ds);
DBUG_RETURN(res);
}
......@@ -446,7 +496,7 @@ VAR* var_get(const char* var_name, const char** var_name_end, int raw)
{
const char* save_var_name = var_name, *end;
end = (var_name_end) ? *var_name_end : 0;
while(isalnum(*var_name) || *var_name == '_')
while (isvar(*var_name))
{
if(end && var_name == end)
break;
......@@ -488,7 +538,7 @@ static VAR* var_obtain(char* name, int len)
VAR* v;
if((v = (VAR*)hash_search(&var_hash, name, len)))
return v;
v = var_init(name, len, "", 0);
v = var_init(0, name, len, "", 0);
hash_insert(&var_hash, (byte*)v);
return v;
}
......@@ -497,7 +547,6 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
char* var_val_end)
{
int digit;
int val_len;
VAR* v;
if (*var_name++ != '$')
{
......@@ -512,21 +561,8 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
}
else
v = var_reg + digit;
if (v->alloced_len < (val_len = (int)(var_val_end - var_val)+1))
{
v->alloced_len = (val_len < MIN_VAR_ALLOC) ? MIN_VAR_ALLOC : val_len;
if (!(v->str_val =
v->str_val ? my_realloc(v->str_val, v->alloced_len, MYF(MY_WME)) :
my_malloc(v->alloced_len, MYF(MY_WME))))
die("Out of memory");
}
val_len--;
memcpy(v->str_val, var_val, val_len);
v->str_val_len = val_len;
v->str_val[val_len] = 0;
v->int_val = atoi(v->str_val);
v->int_dirty=0;
return 0;
return eval_expr(v, var_val, (const char**)&var_val_end);
}
int open_file(const char* name)
......@@ -554,6 +590,35 @@ int do_source(struct st_query* q)
return open_file(name);
}
int var_query_set(VAR* v, const char* p, const char** p_end)
{
char* end = (char*)((p_end && *p_end) ? *p_end : p + strlen(p));
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL* mysql = &cur_con->mysql;
LINT_INIT(res);
while (end > p && *end != '`')
--end;
if (p == end)
die("Syntax error in query, missing '`'");
++p;
if (mysql_real_query(mysql, p, (int)(end - p)) ||
!(res = mysql_store_result(mysql)))
{
*end = 0;
die("Error running query '%s': %s", p, mysql_error(mysql));
}
if ((row = mysql_fetch_row(res)) && row[0])
eval_expr(v, row[0], 0);
else
eval_expr(v, "", 0);
mysql_free_result(res);
return 0;
}
int eval_expr(VAR* v, const char* p, const char** p_end)
{
......@@ -566,10 +631,27 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
return 0;
}
}
else if(*p == '`')
{
return var_query_set(v, p, p_end);
}
else
{
v->str_val = (char*)p;
v->str_val_len = (p_end && *p_end) ? (int) (*p_end - p) : (int) strlen(p);
int new_val_len = (p_end && *p_end) ?
(int) (*p_end - p) : (int) strlen(p);
if (new_val_len + 1 >= v->alloced_len)
{
v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
MIN_VAR_ALLOC : new_val_len + 1;
if (!(v->str_val =
v->str_val ? my_realloc(v->str_val, v->alloced_len,
MYF(MY_WME)) :
my_malloc(v->alloced_len, MYF(MY_WME))))
die("Out of memory");
}
v->str_val_len = new_val_len;
memcpy(v->str_val, p, new_val_len);
v->str_val[new_val_len] = 0;
v->int_val=atoi(p);
v->int_dirty=0;
return 0;
......@@ -605,6 +687,7 @@ int do_system(struct st_query* q)
{
char* p=q->first_argument;
VAR v;
var_init(&v, 0, 0, 0, 0);
eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len)
{
......@@ -624,6 +707,7 @@ int do_echo(struct st_query* q)
{
char* p=q->first_argument;
VAR v;
var_init(&v,0,0,0,0);
eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len)
{
......@@ -642,6 +726,11 @@ int do_sync_with_master(struct st_query* q)
char query_buf[FN_REFLEN+128];
int offset = 0;
char* p = q->first_argument;
int rpl_parse;
rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
if(*p)
offset = atoi(p);
......@@ -659,6 +748,9 @@ int do_sync_with_master(struct st_query* q)
die("Error on slave while syncing with master");
mysql_free_result(res);
if(rpl_parse)
mysql_enable_rpl_parse(mysql);
return 0;
}
......@@ -667,6 +759,11 @@ int do_save_master_pos()
MYSQL_RES* res;
MYSQL_ROW row;
MYSQL* mysql = &cur_con->mysql;
int rpl_parse;
rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
if(mysql_query(mysql, "show master status"))
die("At line %u: failed in show master status: %d: %s", start_lineno,
mysql_errno(mysql), mysql_error(mysql));
......@@ -679,6 +776,9 @@ int do_save_master_pos()
master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res);
if(rpl_parse)
mysql_enable_rpl_parse(mysql);
return 0;
}
......@@ -697,11 +797,29 @@ int do_let(struct st_query* q)
while(*p && isspace(*p))
p++;
var_val_start = p;
while(*p && !isspace(*p))
p++;
return var_set(var_name, var_name_end, var_val_start, p);
return var_set(var_name, var_name_end, var_val_start, q->end);
}
int do_rpl_probe(struct st_query* __attribute__((unused)) q)
{
if(mysql_rpl_probe(&cur_con->mysql))
die("Failed in mysql_rpl_probe(): %s", mysql_error(&cur_con->mysql));
return 0;
}
int do_enable_rpl_parse(struct st_query* __attribute__((unused)) q)
{
mysql_enable_rpl_parse(&cur_con->mysql);
return 0;
}
int do_disable_rpl_parse(struct st_query* __attribute__((unused)) q)
{
mysql_disable_rpl_parse(&cur_con->mysql);
return 0;
}
int do_sleep(struct st_query* q)
{
char* p=q->first_argument;
......@@ -1015,6 +1133,7 @@ int do_connect(struct st_query* q)
if (!mysql_init(&next_con->mysql))
die("Failed on mysql_init()");
if (con_sock)
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
if (!con_db[0])
con_db=db;
......@@ -1047,13 +1166,14 @@ int do_done(struct st_query* q)
q->type = Q_END_BLOCK;
if (cur_block == block_stack)
die("Stray '}' - end of block before beginning");
if (block_ok)
if (*block_ok--)
{
parser.current_line = *--cur_block;
}
else
{
if (!--false_block_depth)
block_ok = 1;
++parser.current_line;
--cur_block;
}
return 0;
}
......@@ -1063,13 +1183,17 @@ int do_while(struct st_query* q)
char* p=q->first_argument;
const char* expr_start, *expr_end;
VAR v;
var_init(&v,0,0,0,0);
if (cur_block == block_stack_end)
die("Nesting too deeply");
if (!block_ok)
if (!*block_ok)
{
++false_block_depth;
*++block_ok = 0;
*cur_block++ = parser.current_line++;
return 0;
}
expr_start = strchr(p, '(');
if (!expr_start)
die("missing '(' in while");
......@@ -1080,9 +1204,11 @@ int do_while(struct st_query* q)
*cur_block++ = parser.current_line++;
if (!v.int_val)
{
block_ok = 0;
false_block_depth = 1;
*++block_ok = 0;
false_block_depth++;
}
else
*++block_ok = 1;
return 0;
}
......@@ -1346,7 +1472,7 @@ int read_query(struct st_query** q_ptr)
q->first_word_len = (uint) (p - q->query);
while (*p && isspace(*p)) p++;
q->first_argument=p;
q->end = strend(q->query);
parser.read_lines++;
return 0;
}
......@@ -1356,6 +1482,7 @@ struct option long_options[] =
{
{"debug", optional_argument, 0, '#'},
{"database", required_argument, 0, 'D'},
{"big-test", no_argument, 0, 'B'},
{"help", no_argument, 0, '?'},
{"host", required_argument, 0, 'h'},
{"password", optional_argument, 0, 'p'},
......@@ -1366,6 +1493,7 @@ struct option long_options[] =
{"silent", no_argument, 0, 'q'},
{"sleep", required_argument, 0, 'T'},
{"socket", required_argument, 0, 'S'},
{"test-file", required_argument, 0, 'x'},
{"tmpdir", required_argument, 0, 't'},
{"user", required_argument, 0, 'u'},
{"verbose", no_argument, 0, 'v'},
......@@ -1398,6 +1526,7 @@ void usage()
-u, --user=... User for login.\n\
-p[password], --password[=...]\n\
Password to use when connecting to server.\n\
-B, --big-test Define BIG_TEST to 1\n\
-D, --database=... Database to use.\n\
-P, --port=... Port number to use for connection.\n\
-S, --socket=... Socket file to use for connection.\n\
......@@ -1405,6 +1534,7 @@ void usage()
-T, --sleep=# Sleep always this many seconds on sleep commands\n\
-r, --record Record output of test_file into result file.\n\
-R, --result-file=... Read/Store result from/in this file.\n\
-x, --test-file=... Read test from/in this file (default stdin).\n\
-v, --verbose Write more.\n\
-q, --quiet, --silent Suppress all normal output.\n\
-V, --version Output version information and exit.\n\
......@@ -1419,7 +1549,7 @@ int parse_args(int argc, char **argv)
load_defaults("my",load_default_groups,&argc,&argv);
default_argv= argv;
while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:#:?rvVq",
while((c = getopt_long(argc, argv, "h:p::u:BP:D:S:R:x:t:T:#:?rvVq",
long_options, &option_index)) != EOF)
{
switch(c) {
......@@ -1438,6 +1568,10 @@ int parse_args(int argc, char **argv)
case 'R':
result_file = optarg;
break;
case 'x':
if (!(*cur_file = my_fopen(optarg, O_RDONLY, MYF(MY_WME))))
die("Could not open %s: errno = %d", optarg, errno);
break;
case 'p':
if (optarg)
{
......@@ -1448,6 +1582,9 @@ int parse_args(int argc, char **argv)
else
tty_password=1;
break;
case 'B':
opt_big_test=1;
break;
case 'P':
port = atoi(optarg);
break;
......@@ -1522,10 +1659,12 @@ void reject_dump(const char* record_file, char* buf, int size)
str_to_file(fn_format(reject_file, record_file,"",".reject",2), buf, size);
}
/* flags control the phased/stages of query execution to be performed
/*
* flags control the phased/stages of query execution to be performed
* if QUERY_SEND bit is on, the query will be sent. If QUERY_REAP is on
* the result will be read - for regular query, both bits must be on
*/
int run_query(MYSQL* mysql, struct st_query* q, int flags)
{
MYSQL_RES* res = 0;
......@@ -1568,7 +1707,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
if(!(flags & QUERY_REAP))
return 0;
if (mysql_read_query_result(mysql))
if (mysql_read_query_result(mysql) ||
(!(res = mysql_store_result(mysql)) && mysql_field_count(mysql)))
{
if (q->require_file)
abort_not_supported_test();
......@@ -1584,17 +1724,25 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
}
if (i)
{
verbose_msg("query '%s' failed with wrong errno\
%d instead of %d...", q->query, mysql_errno(mysql), q->expected_errno[0]);
verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
q->query, mysql_errno(mysql), q->expected_errno[0]);
error=1;
goto end;
}
verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
mysql_error(mysql));
/* if we do not abort on error, failure to run the query does
/*
if we do not abort on error, failure to run the query does
not fail the whole test case
*/
goto end;
}
/*{
verbose_msg("failed in mysql_store_result for query '%s' (%d)", query,
mysql_errno(mysql));
error = 1;
goto end;
}*/
}
if (q->expected_errno[0])
......@@ -1605,23 +1753,6 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
goto end;
}
if (!(res = mysql_store_result(mysql)) && mysql_field_count(mysql))
{
if (q->require_file)
abort_not_supported_test();
if (q->abort_on_error)
die("At line %u: Failed in mysql_store_result for query '%s' (%d)",
start_lineno, query, mysql_errno(mysql));
else
{
verbose_msg("failed in mysql_store_result for query '%s' (%d)", query,
mysql_errno(mysql));
error = 1;
goto end;
}
}
if (!res) goto end;
fields = mysql_fetch_fields(res);
......@@ -1718,33 +1849,39 @@ static byte* get_var_key(const byte* var, uint* len,
return (byte*)key;
}
static VAR* var_init(const char* name, int name_len, const char* val,
static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
int val_len)
{
int val_alloc_len;
VAR* tmp_var;
if(!name_len)
if(!name_len && name)
name_len = strlen(name);
if(!val_len)
if(!val_len && val)
val_len = strlen(val) ;
val_alloc_len = val_len + 16; /* room to grow */
if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + val_alloc_len
if(!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var)
+ name_len, MYF(MY_WME))))
die("Out of memory");
tmp_var->name = (char*)tmp_var + sizeof(*tmp_var);
tmp_var->str_val = tmp_var->name + name_len;
tmp_var->name = (name) ? (char*)tmp_var + sizeof(*tmp_var) : 0;
if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
die("Out of memory");
memcpy(tmp_var->name, name, name_len);
if(val)
memcpy(tmp_var->str_val, val, val_len + 1);
tmp_var->name_len = name_len;
tmp_var->str_val_len = val_len;
tmp_var->alloced_len = val_alloc_len;
tmp_var->int_val = atoi(val);
tmp_var->int_val = (val) ? atoi(val) : 0;
tmp_var->int_dirty = 0;
return tmp_var;
}
static void var_free(void* v)
{
my_free(((VAR*)v)->str_val, MYF(MY_WME));
my_free(v, MYF(MY_WME));
}
......@@ -1756,17 +1893,19 @@ static void var_from_env(const char* name, const char* def_val)
if(!(tmp = getenv(name)))
tmp = def_val;
v = var_init(name, 0, tmp, 0);
v = var_init(0, name, 0, tmp, 0);
hash_insert(&var_hash, (byte*)v);
}
static void init_var_hash()
{
if(hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed");
var_from_env("MASTER_MYPORT", "9306");
var_from_env("SLAVE_MYPORT", "9307");
var_from_env("MYSQL_TEST_DIR", "");
var_from_env("MYSQL_TEST_DIR", "/tmp");
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
}
int main(int argc, char** argv)
......@@ -1793,7 +1932,11 @@ int main(int argc, char** argv)
INIT_Q_LINES);
memset(block_stack, 0, sizeof(block_stack));
block_stack_end = block_stack + BLOCK_STACK_DEPTH;
memset(block_ok_stack, 0, sizeof(block_stack));
block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH;
cur_block = block_stack;
block_ok = block_ok_stack;
*block_ok = 1;
init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv);
init_var_hash();
......@@ -1817,7 +1960,7 @@ int main(int argc, char** argv)
int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
get_query_type(q);
if (block_ok)
if (*block_ok)
{
processed = 1;
switch (q->type) {
......@@ -1826,6 +1969,9 @@ int main(int argc, char** argv)
case Q_DISCONNECT:
case Q_DIRTY_CLOSE:
close_connection(q); break;
case Q_RPL_PROBE: do_rpl_probe(q); break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_SOURCE: do_source(q); break;
case Q_SLEEP: do_sleep(q); break;
case Q_INC: do_inc(q); break;
......@@ -1833,6 +1979,7 @@ int main(int argc, char** argv)
case Q_ECHO: do_echo(q); break;
case Q_SYSTEM: do_system(q); break;
case Q_LET: do_let(q); break;
case Q_EVAL_RESULT: eval_result = 1; break;
case Q_EVAL:
if (q->query == q->query_buf)
q->query += q->first_word_len;
......
......@@ -287,7 +287,6 @@ inline double ulonglong2double(ulonglong value)
#define FN_ROOTDIR "\\"
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
#define FN_LOWER_CASE TRUE /* Files are represented in lower case */
#define MY_NFILE 1024
#define DO_NOT_REMOVE_THREAD_WRAPPERS
......
......@@ -11,7 +11,9 @@ Created 1/20/1994 Heikki Tuuri
#include "univ.i"
#include <time.h>
#ifndef MYSQL_SERVER
#include <ctype.h>
#endif
typedef time_t ib_time_t;
......
......@@ -73,7 +73,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
if (!(flag & READING_HEADER) || info->error == -1 ||
(uint) info->error+in_buff_length < 3)
{
if (!my_errno)
if (!my_errno || my_errno == -1)
my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1);
}
......@@ -87,7 +87,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
if (!(flag & READING_HEADER) || (int) read_length == -1 ||
read_length+in_buff_length < 3)
{
if (!my_errno)
if (!my_errno || my_errno == -1)
my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1);
}
......
......@@ -708,7 +708,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
puts("- check record links");
}
if (!(record= (byte*) my_alloca(info->s->base.pack_reclength)))
if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0))))
{
mi_check_print_error(param,"Not Enough memory");
DBUG_RETURN(-1);
......@@ -924,7 +924,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
if (block_info.rec_len < (uint) info->s->min_pack_length ||
block_info.rec_len > (uint) info->s->max_pack_length)
{
mi_check_print_error(param,"Found block with wrong recordlength: %d at %s",
mi_check_print_error(param,
"Found block with wrong recordlength: %d at %s",
block_info.rec_len, llstr(start_recpos,llbuff));
got_error=1;
break;
......@@ -934,7 +935,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
goto err;
if (_mi_pack_rec_unpack(info,record,info->rec_buff,block_info.rec_len))
{
mi_check_print_error(param,"Found wrong record at %s", llstr(start_recpos,llbuff));
mi_check_print_error(param,"Found wrong record at %s",
llstr(start_recpos,llbuff));
got_error=1;
}
if (static_row_size)
......@@ -1082,12 +1084,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
printf("Lost space: %12s Linkdata: %10s\n",
llstr(empty,llbuff),llstr(link_used,llbuff2));
}
my_afree((gptr) record);
my_free((gptr) record,MYF(0));
DBUG_RETURN (error);
err:
mi_check_print_error(param,"got error: %d when reading datafile",my_errno);
mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff));
err2:
my_afree((gptr) record);
my_free((gptr) record,MYF(0));
param->retry_without_quick=1;
DBUG_RETURN(1);
} /* chk_data_link */
......@@ -1188,7 +1190,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
del=info->state->del;
info->state->records=info->state->del=share->state.split=0;
info->state->empty=0;
if (sort_info->new_data_file_type != COMPRESSED_RECORD && !rep_quick)
if (!rep_quick)
share->state.checksum=0;
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (i=0 ; i < info->s->base.keys ; i++)
......@@ -1866,8 +1868,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
sort_param.sort_info=sort_info;
del=info->state->del;
if (sort_info->new_data_file_type != COMPRESSED_RECORD &&
! rep_quick)
if (! rep_quick)
share->state.checksum=0;
rec_per_key_part= param->rec_per_key_part;
......@@ -2414,6 +2415,7 @@ static int sort_get_next_record(SORT_INFO *sort_info)
llstr(sort_info->pos,llbuff));
continue;
}
info->checksum=mi_checksum(info,sort_info->record);
if (!sort_info->fix_datafile)
sort_info->filepos=sort_info->pos;
sort_info->max_pos=(sort_info->pos=block_info.filepos+
......@@ -2492,6 +2494,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1);
}
sort_info->filepos+=block_length;
info->s->state.checksum+=info->checksum;
break;
case COMPRESSED_RECORD:
reclength=info->packed_length;
......@@ -2504,6 +2507,7 @@ int sort_write_record(SORT_INFO *sort_info)
mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1);
}
info->s->state.checksum+=info->checksum;
sort_info->filepos+=reclength+length;
break;
}
......
......@@ -962,7 +962,7 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
b_type=_mi_pack_get_block_info(info,&block_info,info->dfile,filepos,
info->rec_buff);
if (b_type)
goto err;
goto err; /* Error code is already set */
#ifndef DBUG_OFF
if (block_info.rec_len > share->max_pack_length)
{
......
......@@ -201,7 +201,7 @@ static struct option long_options[] =
static void print_version(void)
{
printf("%s Ver 1.49 for %s at %s\n",my_progname,SYSTEM_TYPE,
printf("%s Ver 1.50 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
......@@ -953,7 +953,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name)
share->base.raid_chunks,
share->base.raid_chunksize);
}
if (share->options & HA_OPTION_CHECKSUM)
if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
printf("Checksum: %23s\n",llstr(info->s->state.checksum,llbuff));
;
if (share->options & HA_OPTION_DELAY_KEY_WRITE)
......
......@@ -693,7 +693,7 @@ drop table t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=bdb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
--error 690
--error 1062
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
select id from t1;
......@@ -704,7 +704,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
begin;
--error 690
--error 1062
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
......
......@@ -10,7 +10,8 @@ create table t1 (a int);
!$1054 select count(test.t1.b) from t1;
!$1109 select count(not_existing_database.t1) from t1;
!$1109 select count(not_existing_database.t1.a) from t1;
!$1044 select count(not_existing_database.t1.a) from not_existing_database.t1;
--error 1044,1146
select count(not_existing_database.t1.a) from not_existing_database.t1;
!$1054 select 1 from t1 order by 2;
!$1054 select 1 from t1 group by 2;
!$1054 select 1 from t1 order by t1.b;
......
......@@ -73,11 +73,15 @@ CREATE TABLE t3 (
);
--error 1210
select * from t2 having MATCH inhalt AGAINST (t1.id);
select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
--error 1210
select * from t2 having MATCH ticket AGAINST ('foobar');
select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
--error 1191
select * from t2 where MATCH ticket AGAINST ('foobar');
--error 1210
select * from t2,t3 having MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
drop table t1,t2,t3;
......@@ -414,8 +414,8 @@ drop table t1;
#
CREATE TABLE t1 (a int unsigned NOT NULL) type=innodb;
--error 1031
INSERT DELAYED INTO t1 VALUES (1);
# Can't test this in 3.23
# INSERT DELAYED INTO t1 VALUES (1);
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
DROP TABLE t1;
......@@ -437,7 +437,7 @@ drop table t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
--error 690
--error 1062
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
select id from t1;
......@@ -448,7 +448,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
begin;
--error 690
--error 1062
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
......
connect (con1,localhost,boo,,);
connection con1;
-- error 1064;
-- error 1064,1102
drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
......@@ -955,7 +955,7 @@ int ha_gemini::handleIndexEntry(const byte * record, dsmRecid_t recid,
thd = current_thd;
key_info=table->key_info+keynr;
thereIsAnull = false;
thereIsAnull = FALSE;
rc = createKeyString(record, key_info, theKey.akey.keystr,
sizeof(theKey.apad),&keyStringLen,
(short)pindexNumbers[keynr],
......@@ -1067,7 +1067,7 @@ int ha_gemini::createKeyString(const byte * record, KEY *pkeyinfo,
isNull = record[key_part->null_offset] & key_part->null_bit;
if(isNull)
*thereIsAnull = true;
*thereIsAnull = TRUE;
rc = gemFieldToIdxComponent(pos,
(unsigned long) key_part_length,
......@@ -1107,7 +1107,7 @@ int ha_gemini::update_row(const byte * old_record, byte * new_record)
}
for (uint keynr=0 ; keynr < table->keys ; keynr++)
{
if(key_cmp(keynr,old_record, new_record,false))
if(key_cmp(keynr,old_record, new_record,FALSE))
{
error = handleIndexEntry(old_record,lastRowid,KEY_DELETE,keynr);
if(error)
......@@ -2430,8 +2430,8 @@ int ha_gemini::analyze(THD* thd, HA_CHECK_OPT* check_opt)
uint saveIsolation;
dsmMask_t saveLockMode;
check_opt->quick = true;
check_opt->optimize = true; // Tells check not to get table lock
check_opt->quick = TRUE;
check_opt->optimize = TRUE; // Tells check not to get table lock
saveLockMode = lockMode;
saveIsolation = thd->gemini.tx_isolation;
thd->gemini.tx_isolation = ISO_READ_UNCOMMITTED;
......@@ -2503,7 +2503,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
error = fetch_row(thd->gemini.context,buf);
if(!error)
{
if(key_cmp(i,buf,indexBuf,false))
if(key_cmp(i,buf,indexBuf,FALSE))
{
gemini_msg((dsmContext_t *)thd->gemini.context,
......@@ -2534,7 +2534,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
}
}
key_cmp(i,indexBuf,prevBuf,true);
key_cmp(i,indexBuf,prevBuf,TRUE);
bcopy((void *)indexBuf,(void *)prevBuf,table->rec_buff_length);
if(!error)
......
......@@ -177,19 +177,19 @@
"Can't write, because of unique constraint, to table '%-.64s'",
"BLOB column '%-.64s' used in key specification without a key length",
"All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead",
"Result consisted of more than one row",
"Tulemis on rohkem kui ks kirje",
"This table type requires a primary key",
"Antud MySQL ei ole kompileeritud RAID-i toega",
"You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
"Key '%-.64s' doesn't exist in table '%-.64s'",
"Can't open table",
"The handler for the table doesn't support check/repair",
"You are not allowed to execute this command in a transaction",
"Got error %d during COMMIT",
"Got error %d during ROLLBACK",
"Got error %d during FLUSH_LOGS",
"Got error %d during CHECKPOINT",
"Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)",
"Ei suuda tabelit avada",
"See tabelitp ei toeta kske CHECK/REPAIR",
"Puudub igus selle transaktsiooniksu andmiseks",
"Sain vea %d COMMIT ksu titmisel",
"Sain vea %d ROLLBACK ksu titmisel",
"Sain vea %d FLUSH_LOGS ksu titmisel",
"Sain vea %d CHECKPOINT ksu titmisel",
"hendus %ld katkestatud andmebaas: '%-.64s' kasutaja: '%-.32s' masin: `%-.64s' (%-.64s)",
"The handler for the table does not support binary table dump",
"Binlog closed while trying to FLUSH MASTER",
"Failed rebuilding the index of dumped table '%-.64s'",
......@@ -198,9 +198,9 @@
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
"Unknown system variable '%-.64'",
"Table '%-.64s' is marked as crashed and should be repaired",
"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
"Tundmatu ssteemne muutja '%-.64'",
"Tabel '%-.64s' on mrgitud vigaseks ja tuleb parandada",
"Tabel '%-.64s' on mrgitud vigaseks ja viimane (automaatne?) parandamiskatse ebannestus",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
"This operation cannot be performed with a running slave, run SLAVE STOP first",
......
......@@ -205,11 +205,11 @@
"Kunde inte initializera replications-strukturerna. Kontrollera privilegerna för 'master.info'",
"Kunde inte starta en tråd för replikering",
"Användare '%-.64s' har redan 'max_user_connections' aktiva inloggningar",
"Du kan endast använda konstant-uttryck med SET",
"Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"DROP DATABASE not allowed while thread is holding global read lock",
"CREATE DATABASE not allowed while thread is holding global read lock",
"Man kan endast använda konstant-uttryck med SET",
"Fick inte ett lås i tid",
"Antal lås överskrider antalet reserverade lås",
"Updaterings-lås kan inte göras när man använder READ UNCOMMITTED",
"DROP DATABASE är inte tillåtet när man har ett globalt läs-lås",
"CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås",
"Felaktiga argument till %s",
"%-.32s@%-.64s is not allowed to create new users",
"%-.32s@%-.64s har inte rättigheter att skapa nya användare",
......@@ -2667,7 +2667,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
DBUG_RETURN(0);
}
#ifdef FN_LOWER_CASE
#ifdef FN_NO_CASE_SENCE
if (!alias) /* Alias is case sensitive */
if (!(alias_str=sql_strmake(alias_str,table->table.length)))
DBUG_RETURN(0);
......
......@@ -1125,7 +1125,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
strmov(new_name_buff,new_name);
fn_same(new_name_buff,table_name,3);
#ifdef FN_LOWER_CASE
#ifdef FN_NO_CASE_SENCE
if (lower_case_table_names)
casedn_str(new_name);
if ((lower_case_table_names &&
......@@ -1709,7 +1709,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
/* Turn off recovery logging since rollback of an
alter table is to delete the new table so there
is no need to log the changes to it. */
error = ha_recovery_logging(thd,false);
error = ha_recovery_logging(thd,FALSE);
if (error)
{
error = 1;
......@@ -1761,7 +1761,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (to->file->activate_all_index(thd))
error=1;
tmp_error = ha_recovery_logging(thd,true);
tmp_error = ha_recovery_logging(thd,TRUE);
/*
Ensure that the new table is saved properly to disk so that we
can do a rename
......@@ -1773,7 +1773,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (to->file->external_lock(thd,F_UNLCK))
error=1;
err:
tmp_error = ha_recovery_logging(thd,true);
tmp_error = ha_recovery_logging(thd,TRUE);
free_io_cache(from);
*copied= found_count;
*deleted=delete_count;
......
......@@ -189,7 +189,10 @@ TEST_join(JOIN *join)
void mysql_print_status(THD *thd)
{
char current_dir[FN_REFLEN];
printf("\nStatus information:\n\n");
my_getwd(current_dir, sizeof(current_dir),MYF(0));
printf("Current dir: %s\n", current_dir);
if (thd)
thd->proc_info="locks";
thr_print_locks(); // Write some debug info
......
......@@ -42,13 +42,13 @@
#include "my_sys.h" /* defines errno */
#include <errno.h>
#ifdef LONGLONG
#ifdef USE_LONGLONG
#define UTYPE_MAX (~(ulonglong) 0)
#define TYPE_MIN LONGLONG_MIN
#define TYPE_MAX LONGLONG_MAX
#define longtype longlong
#define ulongtype ulonglong
#ifdef UNSIGNED
#ifdef USE_UNSIGNED
#define function ulongtype strtoull
#else
#define function longtype strtoll
......@@ -59,7 +59,7 @@
#define TYPE_MAX LONG_MAX
#define longtype long
#define ulongtype unsigned long
#ifdef UNSIGNED
#ifdef USE_UNSIGNED
#define function ulongtype strtoul
#else
#define function longtype strtol
......@@ -170,7 +170,7 @@ function (const char *nptr,char **endptr,int base)
if (endptr != NULL)
*endptr = (char *) s;
#ifndef UNSIGNED
#ifndef USE_UNSIGNED
/* Check for a value that is within the range of
`unsigned long int', but outside the range of `long int'. */
if (negative)
......@@ -185,7 +185,7 @@ function (const char *nptr,char **endptr,int base)
if (overflow)
{
my_errno=ERANGE;
#ifdef UNSIGNED
#ifdef USE_UNSIGNED
return UTYPE_MAX;
#else
return negative ? TYPE_MIN : TYPE_MAX;
......
......@@ -19,7 +19,7 @@
#include <global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
#define LONGLONG
#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG)
#define USE_LONGLONG
#include "strto.c"
#endif
......@@ -19,6 +19,6 @@
#include <global.h>
#if !defined(MSDOS) && !defined(HAVE_STRTOUL)
#define UNSIGNED
#define USE_UNSIGNED
#include "strto.c"
#endif
......@@ -20,7 +20,7 @@
#include <global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
#define UNSIGNED
#define LONGLONG
#define USE_UNSIGNED
#define USE_LONGLONG
#include "strto.c"
#endif
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