summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2000-12-14 17:48:54 -0700
committerunknown <sasha@mysql.sashanet.com>2000-12-14 17:48:54 -0700
commit230acc45197b7b7eda5dcf33dbad7ed879116e59 (patch)
tree3f086dd0852277b199931b8f30f05151b4826769
parent7affa830608a7323aaf69d0c73d6107cf72db4b3 (diff)
parent93166332704c583cfd4d4898f8c99650dfd6193a (diff)
downloadmariadb-git-230acc45197b7b7eda5dcf33dbad7ed879116e59.tar.gz
I fixed the bug too and had to merge conflicts
myisammrg/myrg_open.c: merged
-rw-r--r--client/mysqltest.c50
-rw-r--r--myisammrg/myrg_open.c8
-rw-r--r--mysql-test/r/rpl000016.result3
-rw-r--r--mysql-test/t/rpl000016-slave-master-info.opt1
-rw-r--r--mysql-test/t/rpl000016.test19
-rw-r--r--sql/sql_repl.cc16
6 files changed, 77 insertions, 20 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 69f97f92717..fd1e4df18ba 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -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((vp = var_get(p,p_end,0)))
+ if(*p == '$')
{
- memcpy(v, vp, sizeof(VAR));
+ 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);
+ {
+ 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) {
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index 93eb436392e..f0a2b4348f6 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -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,11 +111,10 @@ int handle_locking;
my_errno=HA_ERR_RECORD_FILE_FULL;
goto err;
}
- if (files)
- 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;
diff --git a/mysql-test/r/rpl000016.result b/mysql-test/r/rpl000016.result
new file mode 100644
index 00000000000..d5716a82c24
--- /dev/null
+++ b/mysql-test/r/rpl000016.result
@@ -0,0 +1,3 @@
+s
+Could not break slave
+Tried hard
diff --git a/mysql-test/t/rpl000016-slave-master-info.opt b/mysql-test/t/rpl000016-slave-master-info.opt
new file mode 100644
index 00000000000..80190bf6d29
--- /dev/null
+++ b/mysql-test/t/rpl000016-slave-master-info.opt
@@ -0,0 +1 @@
+--server-id=2
diff --git a/mysql-test/t/rpl000016.test b/mysql-test/t/rpl000016.test
new file mode 100644
index 00000000000..6a89797af8a
--- /dev/null
+++ b/mysql-test/t/rpl000016.test
@@ -0,0 +1,19 @@
+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;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 521fe757ce5..e27a77422ad 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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,9 +553,8 @@ 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
- pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
+ while(slave_running)
+ pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
}
else
err = "Slave is not running";
@@ -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)