summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-10-07 15:42:26 +0300
committerunknown <monty@narttu.mysql.fi>2003-10-07 15:42:26 +0300
commitf16887c59c7e896c6504008f6cbea337a5cb3fff (patch)
treed89c080ef636608e316f1166b1628cd1d902deec /client
parentdf02cd390d461b50ab5bdf3492aae1071db7da05 (diff)
parentbc4a57f01ace40255de2f8d7307254fd1d1d5bfa (diff)
downloadmariadb-git-f16887c59c7e896c6504008f6cbea337a5cb3fff.tar.gz
Merge with 4.0.16
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-mysqldump.result: Delete: mysql-test/r/mysqldump.result BitKeeper/deleted/.del-mysqldump.test: Delete: mysql-test/t/mysqldump.test BitKeeper/deleted/.del-compile-netware-max: Delete: netware/BUILD/compile-netware-max BitKeeper/deleted/.del-compile-netware-max-debug: Delete: netware/BUILD/compile-netware-max-debug BitKeeper/deleted/.del-compile-netware-src: Delete: netware/BUILD/compile-netware-src BitKeeper/deleted/.del-knetware.imp: Delete: netware/BUILD/knetware.imp BUILD/compile-pentium-valgrind-max: Auto merged BitKeeper/deleted/.del-mini_client.cc~8677895ec8169183: Auto merged BitKeeper/deleted/.del-mysql_fix_privilege_tables.sql: Auto merged BitKeeper/deleted/.del-openssl.imp: Delete: netware/BUILD/openssl.imp acinclude.m4: Auto merged SSL/cacert.pem: Auto merged SSL/client-cert.pem: Auto merged SSL/server-cert.pem: Auto merged client/mysqlbinlog.cc: Auto merged extra/resolveip.c: Auto merged heap/hp_test2.c: Auto merged include/my_global.h: Auto merged innobase/row/row0mysql.c: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.def: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged myisam/mi_test2.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/r/fulltext_multi.result: Auto merged mysql-test/r/fulltext_order_by.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/std_data/rpl_loaddata2.dat: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/select.test: Auto merged mysql-test/t/user_var.test: Auto merged mysys/mf_dirname.c: Auto merged scripts/make_win_src_distribution.sh: Auto merged sql/des_key_file.cc: Auto merged sql/log.cc: Auto merged sql/mysqld.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.h: Auto merged sql-bench/crash-me.sh: Auto merged sql-bench/server-cfg.sh: Auto merged sql-bench/test-insert.sh: Auto merged sql-bench/test-transactions.sh: Auto merged sql/sql_base.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged support-files/mysql.server.sh: Auto merged client/mysqltest.c: Merge with 4.0.16 Changed version number to '2.0' to avoid confusion with version numbering in 3.23 mysql-test/r/distinct.result: Updated results for merge mysql-test/r/insert.result: Updated results for merge mysql-test/r/insert_select.result: Updated results for merge mysql-test/r/join_outer.result: Updated results for merge mysql-test/r/mix_innodb_myisam_binlog.result: Updated results for merge mysql-test/r/order_by.result: Updated results for merge mysql-test/r/rpl000009.result: Updated results for merge mysql-test/r/rpl_loaddata.result: Updated results for merge mysql-test/r/rpl_log.result: Updated results for merge mysql-test/r/select_safe.result: Updated results for merge scripts/mysql_install_db.sh: Change -eq to = BitKeeper/deleted/.del-ins000001.test~2428ee5c9b1bc483: dummy
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc8
-rw-r--r--client/mysqlbinlog.cc131
-rw-r--r--client/mysqltest.c37
3 files changed, 95 insertions, 81 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index e63ee1d2d75..c93875a55fc 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -44,7 +44,7 @@
#include <locale.h>
#endif
-const char *VER= "14.1";
+const char *VER= "14.2";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
@@ -860,7 +860,9 @@ static int read_lines(bool execute_commands)
char *prompt= (char*) (glob_buffer.is_empty() ? construct_prompt() :
!in_string ? " -> " :
in_string == '\'' ?
- " '> " : " \"> ");
+ " '> " : (in_string == '`' ?
+ " `> " :
+ " \"> "));
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
@@ -2643,7 +2645,7 @@ com_status(String *buffer __attribute__((unused)),
(result=mysql_use_result(&mysql)))
{
MYSQL_ROW cur=mysql_fetch_row(result);
- tee_fprintf(stdout, "Current database:\t%s\n",cur[0]);
+ tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
tee_fprintf(stdout, "Current user:\t\t%s\n",cur[1]);
(void) mysql_fetch_row(result); // Read eof
}
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 942c55f3078..54f245ae4a2 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -20,7 +20,6 @@
#include <time.h>
#include <assert.h>
#include "log_event.h"
-#include "include/my_sys.h"
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
@@ -49,10 +48,10 @@ static bool force_opt= 0;
static const char* database;
static bool short_form = 0;
static ulonglong offset = 0;
-static const char* host = "localhost";
+static const char* host = 0;
static int port = MYSQL_PORT;
static const char* sock= MYSQL_UNIX_ADDR;
-static const char* user = "test";
+static const char* user = 0;
static const char* pass = "";
static ulonglong position = 0;
static bool use_remote = 0;
@@ -73,34 +72,7 @@ class Load_log_processor
int target_dir_name_len;
DYNAMIC_ARRAY file_names;
- const char* create_file(Create_file_log_event *ce)
- {
- const char *bname= ce->fname + ce->fname_len -1;
- while (bname>ce->fname && bname[-1]!=FN_LIBCHAR)
- bname--;
-
- uint blen= ce->fname_len - (bname-ce->fname);
- uint full_len= target_dir_name_len + blen;
- char *tmp;
- if (!(tmp= my_malloc(full_len + 9 + 1,MYF(MY_WME))) ||
- set_dynamic(&file_names,(gptr)&ce,ce->file_id))
- {
- die("Could not construct local filename %s%s",target_dir_name,bname);
- return 0;
- }
-
- char *ptr= tmp;
- memcpy(ptr,target_dir_name,target_dir_name_len);
- ptr+= target_dir_name_len;
- memcpy(ptr,bname,blen);
- ptr+= blen;
- sprintf(ptr,"-%08x",ce->file_id);
-
- ce->set_fname_outside_temp_buf(tmp,full_len);
-
- return tmp;
- }
-
+ const char *create_file(Create_file_log_event *ce);
void append_to_file(const char* fname, int flags,
gptr data, uint size)
{
@@ -112,7 +84,6 @@ class Load_log_processor
}
public:
-
Load_log_processor()
{
init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
@@ -125,26 +96,10 @@ public:
delete_dynamic(&file_names);
}
- void init_by_dir_name(const char *atarget_dir_name)
+ void init_by_dir_name(const char *dir)
{
- char *end= strmov(target_dir_name,atarget_dir_name);
- if (end[-1]!=FN_LIBCHAR)
- *end++= FN_LIBCHAR;
- target_dir_name_len= end-target_dir_name;
- }
- void init_by_file_name(const char *file_name)
- {
- int len= strlen(file_name);
- const char *end= file_name + len - 1;
- while (end>file_name && *end!=FN_LIBCHAR)
- end--;
- if (*end!=FN_LIBCHAR)
- target_dir_name_len= 0;
- else
- {
- target_dir_name_len= end - file_name + 1;
- memmove(target_dir_name,file_name,target_dir_name_len);
- }
+ target_dir_name_len= (convert_dirname(target_dir_name, dir, NullS) -
+ target_dir_name);
}
void init_by_cur_dir()
{
@@ -168,6 +123,8 @@ public:
}
Create_file_log_event *grab_event(uint file_id)
{
+ if (file_id >= file_names.elements)
+ return 0;
Create_file_log_event **ptr=
(Create_file_log_event**)file_names.buffer + file_id;
Create_file_log_event *res= *ptr;
@@ -177,11 +134,18 @@ public:
void process(Create_file_log_event *ce)
{
const char *fname= create_file(ce);
- append_to_file(fname,O_CREAT|O_EXCL|O_BINARY|O_WRONLY,ce->block,ce->block_len);
+ append_to_file(fname,O_CREAT|O_EXCL|O_BINARY|O_WRONLY,ce->block,
+ ce->block_len);
}
void process(Append_block_log_event *ae)
{
- if (ae->file_id >= file_names.elements)
+ Create_file_log_event* ce= (ae->file_id < file_names.elements) ?
+ *((Create_file_log_event**)file_names.buffer + ae->file_id) : 0;
+
+ if (ce)
+ append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY, ae->block,
+ ae->block_len);
+ else
{
/*
There is no Create_file event (a bad binlog or a big
@@ -190,14 +154,58 @@ public:
*/
fprintf(stderr,"Warning: ignoring Append_block as there is no \
Create_file event for file_id: %u\n",ae->file_id);
- return;
}
- Create_file_log_event* ce=
- *((Create_file_log_event**)file_names.buffer + ae->file_id);
- append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len);
}
};
+
+const char *Load_log_processor::create_file(Create_file_log_event *ce)
+{
+ const char *bname= ce->fname+dirname_length(ce->fname);
+ uint blen= ce->fname_len - (bname-ce->fname);
+ uint full_len= target_dir_name_len + blen + 9 + 9 + 1;
+ uint version= 0;
+ char *tmp, *ptr;
+
+ if (!(tmp= my_malloc(full_len,MYF(MY_WME))) ||
+ set_dynamic(&file_names,(gptr)&ce,ce->file_id))
+ {
+ die("Could not construct local filename %s%s",target_dir_name,bname);
+ return 0;
+ }
+
+ memcpy(tmp, target_dir_name, target_dir_name_len);
+ ptr= tmp+ target_dir_name_len;
+ memcpy(ptr,bname,blen);
+ ptr+= blen;
+ ptr+= my_sprintf(ptr,(ptr,"-%x",ce->file_id));
+
+ /*
+ Note that this code has a possible race condition if there was was
+ many simultaneous clients running which tried to create files at the same
+ time. Fortunately this should never be the case.
+
+ A better way to do this would be to use 'create_tmp_file() and avoid this
+ race condition altogether on the expense of getting more cryptic file
+ names.
+ */
+ for (;;)
+ {
+ sprintf(ptr,"-%x",version);
+ if (access(tmp,F_OK))
+ break;
+ /* If we have to try more than 1000 times, something is seriously wrong */
+ if (version++ > 1000)
+ {
+ die("Could not construct local filename %s%s",target_dir_name,bname);
+ return 0;
+ }
+ }
+ ce->set_fname_outside_temp_buf(tmp,strlen(tmp));
+ return tmp;
+}
+
+
Load_log_processor load_processor;
static struct my_option my_long_options[] =
@@ -613,10 +621,11 @@ Could not read entry at offset %s : Error in log format or read error",
}
}
/*
- We print the event, but with a leading '#': this is just to inform the
- user of the original command; the command we want to execute will be a
- derivation of this original command (we will change the filename and
- use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' below.
+ We print the event, but with a leading '#': this is just to inform
+ the user of the original command; the command we want to execute
+ will be a derivation of this original command (we will change the
+ filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT'
+ below.
*/
ce->print(result_file, short_form, last_db, true);
load_processor.process(ce);
diff --git a/client/mysqltest.c b/client/mysqltest.c
index fd8cf7ecc8b..479c368aaa1 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -42,7 +42,7 @@
**********************************************************************/
-#define MTEST_VERSION "1.30"
+#define MTEST_VERSION "2.0"
#include <my_global.h>
#include <mysql_embed.h>
@@ -78,6 +78,7 @@
#ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546
#endif
+#define MAX_SERVER_ARGS 20
/*
Sometimes in a test the client starts before
@@ -122,11 +123,19 @@ static int *block_ok_stack_end;
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], global_expected_errors;
-static CHARSET_INFO *charset_info= &my_charset_latin1;
+static int embedded_server_arg_count=0;
+static char *embedded_server_args[MAX_SERVER_ARGS];
+
+static const char *embedded_server_groups[] = {
+ "server",
+ "embedded",
+ "mysqltest_SERVER",
+ NullS
+};
+
DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h"
@@ -343,18 +352,8 @@ void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
#endif
-
-#define MAX_SERVER_ARGS 20
-
-static int embedded_server_arg_count=0;
-static char *embedded_server_args[MAX_SERVER_ARGS];
-
-static const char *embedded_server_groups[] = {
- "server",
- "embedded",
- "mysqltest_SERVER",
- NullS
-};
+static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
+ int len);
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
{
@@ -865,7 +864,7 @@ int do_exec(struct st_query* q)
FILE *res_file;
char *cmd= q->first_argument;
- while (*cmd && my_isspace(charset_info, *cmd))
+ while (*cmd && isspace(*cmd))
cmd++;
if (!*cmd)
die("Missing argument in exec\n");
@@ -881,8 +880,12 @@ int do_exec(struct st_query* q)
if (!(res_file= popen(cmd, "r")) && q->abort_on_error)
die("popen() failed\n");
while (fgets(buf, sizeof(buf), res_file))
- dynstr_append(ds, buf);
+ replace_dynstr_append_mem(ds, buf, strlen(buf));
pclose(res_file);
+
+ if (glob_replace)
+ free_replace();
+
if (record)
{
if (!q->record_file[0] && !result_file)