diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-09-27 23:05:54 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-09-27 23:05:54 -0600 |
commit | 29f148bd36d934ba52836e805cd8598516650e8b (patch) | |
tree | 57e877bfc39c6dc5d9340ff9c84c6652d67724b0 /tools | |
parent | e4fbcbac1c028a0439ae63664eb5d36b960347ba (diff) | |
download | mariadb-git-29f148bd36d934ba52836e805cd8598516650e8b.tar.gz |
client/mysqlmanagerc.c
added support for quiet
increased line buffer size
client/mysqltest.c
fixed memory leak
added query logging to result file
added error message logging to result file
added enable_query_log/disable_query_log
mysql-test/mysql-test-run.sh
converted tests to use mysqlmanager
Updated test results
BitKeeper/etc/ignore:
added *.reject
client/mysqlmanagerc.c:
added support for quiet
increased line buffer size
client/mysqltest.c:
fixed memory leak
added query logging to result file
added error message logging to result file
added enable_query_log/disable_query_log
mysql-test/mysql-test-run.sh:
converted tests to use mysqlmanager
mysql-test/r/alias.result:
log queries
mysql-test/r/alter_table.result:
log queries
mysql-test/r/analyse.result:
log queries
mysql-test/r/auto_increment.result:
log queries
mysql-test/r/backup.result:
log queries
mysql-test/r/bdb-crash.result:
log queries
mysql-test/r/bench_count_distinct.result:
log queries
mysql-test/r/bigint.result:
log queries
mysql-test/r/binary.result:
log queries
mysql-test/r/bulk_replace.result:
log queries
mysql-test/r/case.result:
log queries
mysql-test/r/check.result:
log queries
mysql-test/r/comments.result:
log queries
mysql-test/r/compare.result:
log queries
mysql-test/r/count_distinct.result:
log queries
mysql-test/r/count_distinct2.result:
log queries
mysql-test/r/create.result:
log queries
mysql-test/r/ctype_latin1_de.result:
log queries
mysql-test/r/delayed.result:
log queries
mysql-test/r/dirty-close.result:
log queries
mysql-test/r/distinct.result:
log queries
mysql-test/r/drop.result:
log queries
mysql-test/r/empty_table.result:
log queries
mysql-test/r/explain.result:
log queries
mysql-test/r/flush.result:
log queries
mysql-test/r/fulltext.result:
log queries
mysql-test/r/fulltext_cache.result:
log queries
mysql-test/r/fulltext_distinct.result:
log queries
mysql-test/r/fulltext_left_join.result:
log queries
mysql-test/r/fulltext_multi.result:
log queries
mysql-test/r/fulltext_order_by.result:
log queries
mysql-test/r/fulltext_update.result:
log queries
mysql-test/r/fulltext_var.result:
log queries
mysql-test/r/func_crypt.result:
log queries
mysql-test/r/func_date_add.result:
log queries
mysql-test/r/func_equal.result:
log queries
mysql-test/r/func_group.result:
log queries
mysql-test/r/func_in.result:
log queries
mysql-test/r/func_like.result:
log queries
mysql-test/r/func_math.result:
log queries
mysql-test/r/func_misc.result:
log queries
mysql-test/r/func_op.result:
log queries
mysql-test/r/func_regexp.result:
log queries
mysql-test/r/func_set.result:
log queries
mysql-test/r/func_str.result:
log queries
mysql-test/r/func_system.result:
log queries
mysql-test/r/func_test.result:
log queries
mysql-test/r/func_time.result:
log queries
mysql-test/r/func_timestamp.result:
log queries
mysql-test/r/group_by.result:
log queries
mysql-test/r/handler.result:
log queries
mysql-test/r/having.result:
log queries
mysql-test/r/heap.result:
log queries
mysql-test/r/identity.result:
log queries
mysql-test/r/ins000001.result:
log queries
mysql-test/r/insert.result:
log queries
mysql-test/r/insert_select.result:
log queries
mysql-test/r/isam.result:
log queries
mysql-test/r/join.result:
log queries
mysql-test/r/join_crash.result:
log queries
mysql-test/r/join_outer.result:
log queries
mysql-test/r/key.result:
log queries
mysql-test/r/key_diff.result:
log queries
mysql-test/r/key_primary.result:
log queries
mysql-test/r/keywords.result:
log queries
mysql-test/r/kill.result:
log queries
mysql-test/r/limit.result:
log queries
mysql-test/r/lock.result:
log queries
mysql-test/r/merge.result:
log queries
mysql-test/r/multi_update.result:
log queries
mysql-test/r/myisam.result:
log queries
mysql-test/r/null.result:
log queries
mysql-test/r/null_key.result:
log queries
mysql-test/r/odbc.result:
log queries
mysql-test/r/openssl_1.result:
log queries
mysql-test/r/openssl_2.result:
log queries
mysql-test/r/order_by.result:
log queries
mysql-test/r/order_fill_sortbuf.result:
log queries
mysql-test/r/raid.result:
log queries
mysql-test/r/range.result:
log queries
mysql-test/r/rename.result:
log queries
mysql-test/r/replace.result:
log queries
mysql-test/r/rollback.result:
log queries
mysql-test/r/rpl000001.result:
log queries
mysql-test/r/rpl000002.result:
log queries
mysql-test/r/rpl000003.result:
log queries
mysql-test/r/rpl000004.result:
log queries
mysql-test/r/rpl000005.result:
log queries
mysql-test/r/rpl000006.result:
log queries
mysql-test/r/rpl000007.result:
log queries
mysql-test/r/rpl000008.result:
log queries
mysql-test/r/rpl000009.result:
log queries
mysql-test/r/rpl000010.result:
log queries
mysql-test/r/rpl000011.result:
log queries
mysql-test/r/rpl000012.result:
log queries
mysql-test/r/rpl000013.result:
log queries
mysql-test/r/rpl000014.result:
log queries
mysql-test/r/rpl000015.result:
log queries
mysql-test/r/rpl000016.result:
log queries
mysql-test/r/rpl000017.result:
log queries
mysql-test/r/rpl000018.result:
log queries
mysql-test/r/rpl_get_lock.result:
log queries
mysql-test/r/rpl_log.result:
log queries
mysql-test/r/rpl_magic.result:
log queries
mysql-test/r/rpl_mystery22.result:
log queries
mysql-test/r/rpl_sporadic_master.result:
log queries
mysql-test/r/sel000001.result:
log queries
mysql-test/r/sel000002.result:
log queries
mysql-test/r/sel000003.result:
log queries
mysql-test/r/sel000031.result:
log queries
mysql-test/r/sel000032.result:
log queries
mysql-test/r/sel000033.result:
log queries
mysql-test/r/sel000100.result:
log queries
mysql-test/r/select.result:
log queries
mysql-test/r/select_found.result:
log queries
mysql-test/r/select_safe.result:
log queries
mysql-test/r/show_check.result:
log queries
mysql-test/r/slave-running.result:
log queries
mysql-test/r/slave-stopped.result:
log queries
mysql-test/r/status.result:
log queries
mysql-test/r/symlink.result:
log queries
mysql-test/r/tablelock.result:
log queries
mysql-test/r/temp_table.result:
log queries
mysql-test/r/truncate.result:
log queries
mysql-test/r/type_blob.result:
log queries
mysql-test/r/type_date.result:
log queries
mysql-test/r/type_datetime.result:
log queries
mysql-test/r/type_decimal.result:
log queries
mysql-test/r/type_enum.result:
log queries
mysql-test/r/type_float.result:
log queries
mysql-test/r/type_ranges.result:
log queries
mysql-test/r/type_time.result:
log queries
mysql-test/r/type_timestamp.result:
log queries
mysql-test/r/type_uint.result:
log queries
mysql-test/r/type_year.result:
log queries
mysql-test/r/union.result:
log queries
mysql-test/r/update.result:
log queries
mysql-test/r/user_var.result:
log queries
mysql-test/r/varbinary.result:
log queries
mysql-test/r/variables.result:
log queries
mysql-test/t/bench_count_distinct.test:
log queries
mysql-test/t/check.test:
log queries
mysql-test/t/count_distinct2.test:
log queries
mysql-test/t/flush.test:
log queries
mysql-test/t/isam.test:
log queries
mysql-test/t/multi_update.test:
log queries
mysql-test/t/myisam.test:
log queries
mysql-test/t/order_fill_sortbuf.test:
log queries
mysql-test/t/rpl000016.test:
log queries
tools/managertest1.nc:
test for def_exec overwrite
tools/mysqlmanager.c:
support def_exec overwrite and queries on running server
Diffstat (limited to 'tools')
-rw-r--r-- | tools/managertest1.nc | 3 | ||||
-rw-r--r-- | tools/mysqlmanager.c | 115 |
2 files changed, 112 insertions, 6 deletions
diff --git a/tools/managertest1.nc b/tools/managertest1.nc index 19736b250e5..bf1b82ed406 100644 --- a/tools/managertest1.nc +++ b/tools/managertest1.nc @@ -4,9 +4,12 @@ set_exec_stdout server /tmp/mysqld.err set_exec_stderr server /tmp/mysqld.err start_exec server 3 show_exec +query server show variables like '%max_heap%'; stop_exec server 3 +def_exec server /usr/sbin/mysqld --socket=/tmp/temp.sock --skip-grant --skip-net --datadir=/tmp -O max_heap_table_size=5000 show_exec start_exec server 3 +query server show variables like '%max_heap%'; show_exec stop_exec server 3 show_exec diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index aa599beee93..869982656d1 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -173,6 +173,7 @@ static uint tokenize_args(char* arg_start,char** arg_end); static void init_arg_array(char* arg_str,char** args,uint arg_count); static int hex_val(char c); static int open_and_dup(int fd,char* path); +static void update_req_len(struct manager_exec* e); typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*); @@ -219,6 +220,7 @@ struct manager_exec MYSQL mysql; char* data_buf; int req_len; + int start_wait_timeout; int stderr_path_size,stdout_path_size,data_buf_size; int num_args; }; @@ -244,6 +246,7 @@ HANDLE_DECL(stop_exec); HANDLE_DECL(set_exec_con); HANDLE_DECL(set_exec_stdout); HANDLE_DECL(set_exec_stderr); +HANDLE_DECL(query); HANDLE_NOARG_DECL(show_exec); struct manager_cmd commands[] = @@ -262,6 +265,7 @@ struct manager_cmd commands[] = handle_set_exec_stdout,15}, {"set_exec_stderr", "Set stderr path for executable entry", handle_set_exec_stderr,15}, + {"query","Run query against MySQL server",handle_query,5}, {"show_exec","Show defined executable entries",handle_show_exec,9}, {"help", "Print this message", handle_help,4}, {0,0,0,0} @@ -460,7 +464,7 @@ HANDLE_DECL(set_exec_con) else e->con_sock[0]=0; } - else + else if(num_args > 4) { pthread_mutex_unlock(&lock_exec_hash); error="Too many arguments"; @@ -563,7 +567,7 @@ HANDLE_DECL(start_exec) if ((error=e->error)) goto err; pthread_mutex_lock(&e->lock); - t.tv_sec=time(0)+atoi(args_start+ident_len+1); + t.tv_sec=time(0)+(e->start_wait_timeout=atoi(args_start+ident_len+1)); t.tv_nsec=0; if (!e->pid) pthread_cond_timedwait(&e->cond,&e->lock,&t); @@ -642,6 +646,89 @@ err: return 1; } +HANDLE_DECL(query) +{ + const char* error=0; + struct manager_exec* e; + MYSQL_RES* res=0; + MYSQL_ROW row; + MYSQL_FIELD* fields; + int num_fields,i,ident_len; + char* ident,*query; + query=ident=args_start; + while (!isspace(*query)) + query++; + if (query == ident) + { + error="Missing server identifier"; + goto err; + } + ident_len=(int)(query-ident); + while (query<args_end && isspace(*query)) + query++; + if (query == args_end) + { + error="Missing query"; + goto err; + } + pthread_mutex_lock(&lock_exec_hash); + if (!(e=(struct manager_exec*)hash_search(&exec_hash,ident, + ident_len))) + { + pthread_mutex_unlock(&lock_exec_hash); + error="Exec definition entry does not exist"; + goto err; + } + pthread_mutex_unlock(&lock_exec_hash); + pthread_mutex_lock(&e->lock); + if (!e->pid) + { + error="Process is not running"; + pthread_mutex_unlock(&e->lock); + goto err; + } + + if (mysql_query(&e->mysql,query)) + { + error=mysql_error(&e->mysql); + pthread_mutex_unlock(&e->lock); + goto err; + } + if ((res=mysql_store_result(&e->mysql))) + { + char buf[MAX_CLIENT_MSG_LEN],*p,*buf_end; + fields=mysql_fetch_fields(res); + num_fields=mysql_num_fields(res); + p=buf; + buf_end=buf+sizeof(buf); + for (i=0;i<num_fields && p<buf_end-2;i++) + { + p=arg_strmov(p,fields[i].name,buf_end-p-2); + *p++='\t'; + } + *p=0; + client_msg_pre(thd->vio,MANAGER_OK,buf); + + while ((row=mysql_fetch_row(res))) + { + p=buf; + for (i=0;i<num_fields && p<buf_end-2;i++) + { + p=arg_strmov(p,row[i],buf_end-p-2); + *p++='\t'; + } + *p=0; + client_msg_pre(thd->vio,MANAGER_OK,buf); + } + } + pthread_mutex_unlock(&e->lock); + client_msg(thd->vio,MANAGER_OK,"End"); + return 0; +err: + client_msg(thd->vio,MANAGER_CLIENT_ERR,error); + return 1; +} + HANDLE_DECL(def_exec) { struct manager_exec* e=0,*old_e; @@ -660,9 +747,14 @@ HANDLE_DECL(def_exec) if ((old_e=(struct manager_exec*)hash_search(&exec_hash,(byte*)e->ident, e->ident_len))) { - pthread_mutex_unlock(&lock_exec_hash); - error="Exec definition already exists"; - goto err; + strnmov(e->stdout_path,old_e->stdout_path,sizeof(e->stdout_path)); + strnmov(e->stderr_path,old_e->stderr_path,sizeof(e->stderr_path)); + strnmov(e->con_user,old_e->con_user,sizeof(e->con_user)); + strnmov(e->con_host,old_e->con_host,sizeof(e->con_host)); + strnmov(e->con_sock,old_e->con_sock,sizeof(e->con_sock)); + e->con_port=old_e->con_port; + update_req_len(e); + hash_delete(&exec_hash,(byte*)old_e); } hash_insert(&exec_hash,(byte*)e); pthread_mutex_unlock(&lock_exec_hash); @@ -712,7 +804,12 @@ static struct manager_exec* manager_exec_by_pid(pid_t pid) static void manager_exec_connect(struct manager_exec* e) { int i; - for (i=0;i<manager_connect_retries;i++) + int connect_retries; + + if (!(connect_retries=e->start_wait_timeout)) + connect_retries=manager_connect_retries; + + for (i=0;i<connect_retries;i++) { if (mysql_real_connect(&e->mysql,e->con_host,e->con_user,e->con_pass,0, e->con_port,e->con_sock,0)) @@ -1426,6 +1523,12 @@ static uint tokenize_args(char* arg_start,char** arg_end) return arg_count; } +static void update_req_len(struct manager_exec* e) +{ + e->req_len=e->data_buf_size+ + (e->stdout_path_size=strlen(e->stdout_path)+1)+ + (e->stderr_path_size=strlen(e->stderr_path)+1); + } static struct manager_exec* manager_exec_new(char* arg_start,char* arg_end) { |