Commit 23d5f3f9 authored by unknown's avatar unknown

Merge work:/home/bk/mysql

into mysql.sashanet.com:/home/sasha/src/bk/mysql


BitKeeper/etc/ignore:
  auto-union
BitKeeper/etc/logging_ok:
  auto-union
client/mysqlbinlog.cc:
  Auto merged
parents f6751dd8 ebb3bd0f
......@@ -141,13 +141,19 @@ bdb/test/logtrack.list
bdb/txn/txn_auto.c
binary/*
client/insert_test
client/log_event.cc
client/log_event.h
client/mf_iocache.c
client/mf_iocache.cc
client/mysql
client/mysqladmin
client/mysqlbinlog
client/mysqlcheck
client/mysqldump
client/mysqlimport
client/mysqlshow
client/mysqltest
client/mysys_priv.h
client/select_test
client/thimble
client/thread_test
......@@ -214,6 +220,7 @@ mysql-test/mysql-test-run
mysql-test/r/*.reject
mysql-test/share/mysql
mysql-test/var/*
mysql.kdevprj
mysql.proj
mysqld.S
mysqld.sym
......
......@@ -37,6 +37,7 @@ linked_include_sources:
echo timestamp > linked_include_sources
linked_client_sources: @linked_client_targets@
cd client; $(MAKE) link_sources
echo timestamp > linked_client_sources
linked_libmysql_sources:
......
......@@ -21,7 +21,8 @@ INCLUDES = -I$(srcdir)/../include \
-I..
LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow mysqldump mysqlimport mysqltest
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
mysqldump mysqlimport mysqltest mysqlbinlog
noinst_PROGRAMS = insert_test select_test thread_test
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
......@@ -36,10 +37,24 @@ insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqltest_SOURCES= mysqltest.c
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlbinlog_SOURCES = mysqlbinlog.cc
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
sql_src=log_event.h log_event.cc
mysys_src=mysys_priv.h
# Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK
link_sources:
for f in $(sql_src) ; do \
rm -f $$f; \
@LN_CP_F@ ../sql/$$f $$f; \
done; \
for f in $(mysys_src); do \
rm -f $$f; \
@LN_CP_F@ ../mysys/$$f $$f; \
done;
thread_test.o: thread_test.c
$(COMPILE) -c @MT_INCLUDES@ $(INCLUDES) $<
......
......@@ -22,13 +22,19 @@
#include <my_sys.h>
#include <getopt.h>
#include <thr_alarm.h>
#define MYSQL_SERVER // We want the C++ version of net
#include <mysql.h>
#include "log_event.h"
#include "mini_client.h"
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
extern "C"
{
int simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg,
uint length, my_bool skipp_check);
int net_safe_read(MYSQL* mysql);
}
char server_version[SERVER_VERSION_LENGTH];
uint32 server_id = 0;
......@@ -248,12 +254,12 @@ static int parse_args(int *argc, char*** argv)
static MYSQL* safe_connect()
{
MYSQL *local_mysql = mc_mysql_init(NULL);
MYSQL *local_mysql = mysql_init(NULL);
if(!local_mysql)
die("Failed on mc_mysql_init");
die("Failed on mysql_init");
if(!mc_mysql_connect(local_mysql, host, user, pass, 0, port, 0, 0))
die("failed on connect: %s", mc_mysql_error(local_mysql));
if(!mysql_real_connect(local_mysql, host, user, pass, 0, port, 0, 0))
die("failed on connect: %s", mysql_error(local_mysql));
return local_mysql;
}
......@@ -281,7 +287,7 @@ static void dump_remote_table(NET* net, const char* db, const char* table)
*p++ = table_len;
memcpy(p, table, table_len);
if(mc_simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
if(simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
die("Error sending the table dump command");
for(;;)
......@@ -314,14 +320,14 @@ static void dump_remote_log_entries(const char* logname)
len = (uint) strlen(logname);
int4store(buf + 6, 0);
memcpy(buf + 10, logname,len);
if(mc_simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1))
if(simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1))
die("Error sending the log dump command");
for(;;)
{
len = mc_net_safe_read(mysql);
len = net_safe_read(mysql);
if (len == packet_error)
die("Error reading packet from server: %s", mc_mysql_error(mysql));
die("Error reading packet from server: %s", mysql_error(mysql));
if(len == 1 && net->read_pos[0] == 254)
break; // end of data
DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n",
......@@ -391,7 +397,7 @@ static void dump_local_log_entries(const char* logname)
char llbuff[21];
my_off_t old_off = my_b_tell(file);
Log_event* ev = Log_event::read_log_event(file, 0);
Log_event* ev = Log_event::read_log_event(file);
if (!ev)
{
if (file->error)
......@@ -430,9 +436,6 @@ int main(int argc, char** argv)
if(use_remote)
{
#ifndef __WIN__
init_thr_alarm(10); // need to do this manually
#endif
mysql = safe_connect();
}
......@@ -457,7 +460,7 @@ int main(int argc, char** argv)
if (result_file != stdout)
my_fclose(result_file, MYF(0));
if (use_remote)
mc_mysql_close(mysql);
mysql_close(mysql);
return 0;
}
......
......@@ -55,7 +55,8 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
thr_mutex.lo mulalloc.lo string.lo default.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo hash.lo
charset.lo hash.lo mf_iocache.lo my_seek.lo \
my_pread.lo mf_cache.lo
# Not needed in the minimum library
mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo
mysysobjects = $(mysysobjects1) $(mysysobjects2)
......
......@@ -287,7 +287,7 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
** or packet is an error message
*****************************************************************************/
static uint
uint
net_safe_read(MYSQL *mysql)
{
NET *net= &mysql->net;
......@@ -417,7 +417,7 @@ static void free_rows(MYSQL_DATA *cur)
}
static int
int
simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
uint length, my_bool skipp_check)
{
......
......@@ -27,7 +27,6 @@ INCLUDES = @MT_INCLUDES@ \
-I$(srcdir) -I../include -I.. -I.
WRAPLIBS= @WRAPLIBS@
SUBDIRS = share
bin_PROGRAMS = mysqlbinlog
libexec_PROGRAMS = mysqld
noinst_PROGRAMS = gen_lex_hash
gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
......@@ -83,9 +82,6 @@ mysqld_SOURCES = sql_lex.cc \
md5.c stacktrace.c
gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
mysqlbinlog_SOURCES = mysqlbinlog.cc mini_client.cc net_serv.cc \
mini_client_errors.c violite.c password.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) # $(mysqld_LDADD)
DEFS = -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
......
......@@ -111,18 +111,29 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
#endif // MYSQL_CLIENT
// allocates memory - the caller is responsible for clean-up
#ifndef MYSQL_CLIENT
#define UNLOCK_MUTEX if(log_lock) pthread_mutex_unlock(log_lock);
#else
#define UNLOCK_MUTEX
#endif
// allocates memory - the caller is responsible for clean-up
#ifndef MYSQL_CLIENT
Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
#else
Log_event* Log_event::read_log_event(IO_CACHE* file)
#endif
{
time_t timestamp;
uint32 server_id;
char buf[LOG_EVENT_HEADER_LEN-4];
#ifndef MYSQL_CLIENT
if(log_lock) pthread_mutex_lock(log_lock);
#endif
if (my_b_read(file, (byte *) buf, sizeof(buf)))
{
if (log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
return NULL;
}
timestamp = uint4korr(buf);
......@@ -133,7 +144,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
case QUERY_EVENT:
{
Query_log_event* q = new Query_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
if (!q->query)
{
delete q;
......@@ -145,7 +156,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
case LOAD_EVENT:
{
Load_log_event* l = new Load_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
if (!l->table_name)
{
delete l;
......@@ -158,8 +169,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
case ROTATE_EVENT:
{
Rotate_log_event* r = new Rotate_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
if (!r->new_log_ident)
{
delete r;
......@@ -171,8 +181,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
case INTVAR_EVENT:
{
Intvar_log_event* e = new Intvar_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
if (e->type == INVALID_INT_EVENT)
{
delete e;
......@@ -184,13 +193,13 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
case START_EVENT:
{
Start_log_event* e = new Start_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
return e;
}
case STOP_EVENT:
{
Stop_log_event* e = new Stop_log_event(file, timestamp, server_id);
if(log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
return e;
}
default:
......@@ -198,7 +207,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock)
}
// default
if (log_lock) pthread_mutex_unlock(log_lock);
UNLOCK_MUTEX
return NULL;
}
......
......@@ -105,8 +105,12 @@ public:
void print_timestamp(FILE* file, time_t *ts = 0);
void print_header(FILE* file);
#ifndef MYSQL_CLIENT
// if mutex is 0, the read will proceed without mutex
static Log_event* read_log_event(IO_CACHE* file, pthread_mutex_t* log_lock);
#else // avoid having to link mysqlbinlog against libpthread
static Log_event* read_log_event(IO_CACHE* file);
#endif
static Log_event* read_log_event(const char* buf, int event_len);
#ifndef MYSQL_CLIENT
......
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