Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
681cdbbd
Commit
681cdbbd
authored
Aug 09, 2001
by
sasha@mysql.sashanet.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysqlbinlog->client
parent
94db78ce
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
35 deletions
+71
-35
.bzrignore
.bzrignore
+7
-0
Makefile.am
Makefile.am
+1
-0
client/Makefile.am
client/Makefile.am
+16
-1
client/mysqlbinlog.cc
client/mysqlbinlog.cc
+19
-16
libmysql/Makefile.shared
libmysql/Makefile.shared
+2
-1
libmysql/libmysql.c
libmysql/libmysql.c
+2
-2
sql/Makefile.am
sql/Makefile.am
+0
-4
sql/log_event.cc
sql/log_event.cc
+20
-11
sql/log_event.h
sql/log_event.h
+4
-0
No files found.
.bzrignore
View file @
681cdbbd
...
...
@@ -291,3 +291,10 @@ myisam/test1.MYD
myisam/test1.MYI
.gdbinit
.vimrc
client/log_event.cc
client/log_event.h
client/mf_iocache.c
client/mf_iocache.cc
client/mysqlbinlog
client/mysys_priv.h
mysql.kdevprj
Makefile.am
View file @
681cdbbd
...
...
@@ -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
:
...
...
client/Makefile.am
View file @
681cdbbd
...
...
@@ -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)
$<
...
...
sql
/mysqlbinlog.cc
→
client
/mysqlbinlog.cc
View file @
681cdbbd
...
...
@@ -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
;
...
...
@@ -108,7 +114,7 @@ static void die(const char* fmt, ...)
static
void
print_version
()
{
printf
(
"%s Ver 1.
4
for %s at %s
\n
"
,
my_progname
,
SYSTEM_TYPE
,
MACHINE_TYPE
);
printf
(
"%s Ver 1.
5
for %s at %s
\n
"
,
my_progname
,
SYSTEM_TYPE
,
MACHINE_TYPE
);
}
...
...
@@ -248,12 +254,12 @@ static int parse_args(int *argc, char*** argv)
static
MYSQL
*
safe_connect
()
{
MYSQL
*
local_mysql
=
m
c_m
ysql_init
(
NULL
);
MYSQL
*
local_mysql
=
mysql_init
(
NULL
);
if
(
!
local_mysql
)
die
(
"Failed on m
c_m
ysql_init"
);
die
(
"Failed on mysql_init"
);
if
(
!
m
c_mysq
l_connect
(
local_mysql
,
host
,
user
,
pass
,
0
,
port
,
0
,
0
))
die
(
"failed on connect: %s"
,
m
c_m
ysql_error
(
local_mysql
));
if
(
!
m
ysql_rea
l_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"
,
m
c_m
ysql_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
)
m
c_m
ysql_close
(
mysql
);
mysql_close
(
mysql
);
return
0
;
}
...
...
libmysql/Makefile.shared
View file @
681cdbbd
...
...
@@ -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)
...
...
libmysql/libmysql.c
View file @
681cdbbd
...
...
@@ -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
)
{
...
...
sql/Makefile.am
View file @
681cdbbd
...
...
@@ -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)
\"
"
\
...
...
sql/log_event.cc
View file @
681cdbbd
...
...
@@ -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
;
}
...
...
sql/log_event.h
View file @
681cdbbd
...
...
@@ -105,8 +105,12 @@ class Log_event
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment