client/mysqltest.c

    added system command
myisammrg/myrg_open.c
    fixed coredump when opening an empty union table
sql/sql_repl.cc
    fixed warnings, remove confusing comment, fixed coredump in
    change master to when master.info was corrupted

added new replication test case
parent 254a8007
......@@ -113,7 +113,7 @@ struct query
enum {Q_CONNECTION, Q_QUERY, Q_CONNECT,
Q_SLEEP, Q_INC, Q_DEC,Q_SOURCE,
Q_DISCONNECT,Q_LET, Q_ECHO, Q_WHILE, Q_END_BLOCK,
Q_UNKNOWN} type;
Q_SYSTEM, Q_UNKNOWN} type;
};
#define DS_CHUNK 16384
......@@ -330,11 +330,21 @@ int do_source(struct query* q)
int eval_expr(VAR* v, char* p, char* p_end)
{
VAR* vp;
if(*p == '$')
{
if((vp = var_get(p,p_end,0)))
{
memcpy(v, vp, sizeof(VAR));
return 0;
}
}
else
{
v->str_val = p;
v->str_val_len = p_end ? p_end - p : strlen(p);
return 0;
}
if(p_end)
*p_end = 0;
die("Invalid expr: %s", p);
......@@ -365,6 +375,25 @@ int do_dec(struct query* q)
return 0;
}
int do_system(struct query* q)
{
char* p;
VAR v;
p = (char*)q->q + q->first_word_len;
while(*p && isspace(*p)) p++;
eval_expr(&v, p, 0); /* NULL terminated */
if(v.str_val_len > 1)
{
char expr_buf[512];
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;
if(system(expr_buf) && q->abort_on_error)
die("system command '%s' failed", expr_buf);
}
return 0;
}
int do_echo(struct query* q)
{
......@@ -1006,7 +1035,6 @@ void reject_dump(const char* record_file, char* buf, int size)
{
char reject_file[MAX_RECORD_FILE+16];
char* p;
FILE* freject;
p = reject_file;
p = safe_str_append(p, record_file, sizeof(reject_file));
......@@ -1021,7 +1049,6 @@ int run_query(MYSQL* mysql, struct query* q)
MYSQL_FIELD* fields;
MYSQL_ROW row;
int num_fields,i, error = 0;
struct stat info;
unsigned long* lengths;
char* val;
int len;
......@@ -1181,6 +1208,8 @@ void get_query_type(struct query* q)
case 6:
if(check_first_word(q, "source", 6))
q->type = Q_SOURCE;
else if(check_first_word(q, "system", 6))
q->type = Q_SYSTEM;
break;
case 7:
if(check_first_word(q, "connect", 7))
......@@ -1254,6 +1283,7 @@ int main(int argc, char** argv)
case Q_INC: do_inc(q); break;
case Q_DEC: do_dec(q); break;
case Q_ECHO: do_echo(q); break;
case Q_SYSTEM: do_system(q); break;
case Q_LET: do_let(q); break;
case Q_QUERY: error |= run_query(&cur_con->mysql, q); break;
default: processed = 0; break;
......@@ -1277,10 +1307,12 @@ int main(int argc, char** argv)
close_cons();
if(result_file)
{
if(!record && ds_res.len)
error |= check_result(&ds_res, result_file);
else
str_to_file(result_file, ds_res.str, ds_res.len);
}
dyn_string_end(&ds_res);
if (!silent) {
......
......@@ -45,6 +45,7 @@ int handle_locking;
DBUG_ENTER("myrg_open");
LINT_INIT(last_isam);
LINT_INIT(m_info);
isam=0;
errpos=files=0;
bzero((gptr) &info,sizeof(info));
......@@ -84,7 +85,7 @@ int handle_locking;
MYF(MY_WME))))
goto err;
*m_info=info;
m_info->open_tables=(MYRG_TABLE *) (m_info+1);
m_info->open_tables=(files) ? (MYRG_TABLE *) (m_info+1) : 0;
m_info->tables=files;
errpos=2;
......@@ -110,9 +111,10 @@ int handle_locking;
my_errno=HA_ERR_RECORD_FILE_FULL;
goto err;
}
m_info->keys=m_info->open_tables->table->s->base.keys;
m_info->keys=(files) ? m_info->open_tables->table->s->base.keys : 0;
bzero((char*) &m_info->by_key,sizeof(m_info->by_key));
/* this works ok if the table list is empty */
m_info->end_table=m_info->open_tables+files;
m_info->last_used_table=m_info->open_tables;
......
s
Could not break slave
Tried hard
connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;
!slave start;
system chmod 600 var/slave-data/master.info;
!slave start;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
reset slave;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
slave start;
connection master;
drop table if exists foo;
create table foo(s text);
insert into foo values('Could not break slave'),('Tried hard');
connection slave;
sleep 0.3;
select * from foo;
......@@ -34,7 +34,8 @@ static int send_file(THD *thd)
char fname[FN_REFLEN+1];
char *buf;
const char *errmsg = 0;
int old_timeout,packet_len;
int old_timeout;
uint packet_len;
DBUG_ENTER("send_file");
// the client might be slow loading the data, give him wait_timeout to do
......@@ -63,7 +64,6 @@ static int send_file(THD *thd)
// this is needed to make replicate-ignore-db
if (!strcmp(fname,"/dev/null"))
goto end;
// TODO: work on the well-known system that does not have a /dev/null :-)
if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
{
......@@ -553,8 +553,7 @@ int stop_slave(THD* thd, bool net_report )
// do not abort the slave in the middle of a query, so we do not set
// thd->killed for the slave thread
thd->proc_info = "waiting for slave to die";
while(slave_running) // we may miss slave start broadcast, if it starts
// very quickly
while(slave_running)
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
}
else
......@@ -643,8 +642,11 @@ int change_master(THD* thd)
thd->proc_info = "changing master";
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
if(!glob_mi.inited)
init_master_info(&glob_mi);
if(init_master_info(&glob_mi))
{
send_error(&thd->net, 0, "Could not initialize master info");
return 1;
}
pthread_mutex_lock(&glob_mi.lock);
if((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
......
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