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
c01d4e1e
Commit
c01d4e1e
authored
Jul 04, 2001
by
sasha@mysql.sashanet.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SHOW NEW MASTER FOR SLAVE WITH ...
parent
a973b855
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
367 additions
and
3 deletions
+367
-3
include/mysqld_error.h
include/mysqld_error.h
+2
-1
mysql-test/fix-result
mysql-test/fix-result
+22
-0
mysql-test/r/rpl_log.result
mysql-test/r/rpl_log.result
+10
-0
mysql-test/t/rpl_log.test
mysql-test/t/rpl_log.test
+10
-0
sql/lex.h
sql/lex.h
+3
-0
sql/share/czech/errmsg.txt
sql/share/czech/errmsg.txt
+1
-0
sql/share/danish/errmsg.txt
sql/share/danish/errmsg.txt
+1
-0
sql/share/dutch/errmsg.txt
sql/share/dutch/errmsg.txt
+1
-0
sql/share/english/errmsg.txt
sql/share/english/errmsg.txt
+1
-0
sql/share/estonian/errmsg.txt
sql/share/estonian/errmsg.txt
+1
-0
sql/share/french/errmsg.txt
sql/share/french/errmsg.txt
+1
-0
sql/share/german/errmsg.txt
sql/share/german/errmsg.txt
+1
-0
sql/share/greek/errmsg.txt
sql/share/greek/errmsg.txt
+1
-0
sql/share/hungarian/errmsg.txt
sql/share/hungarian/errmsg.txt
+1
-0
sql/share/italian/errmsg.txt
sql/share/italian/errmsg.txt
+1
-0
sql/share/japanese/errmsg.txt
sql/share/japanese/errmsg.txt
+1
-0
sql/share/korean/errmsg.txt
sql/share/korean/errmsg.txt
+1
-0
sql/share/norwegian-ny/errmsg.txt
sql/share/norwegian-ny/errmsg.txt
+1
-0
sql/share/norwegian/errmsg.txt
sql/share/norwegian/errmsg.txt
+1
-0
sql/share/polish/errmsg.txt
sql/share/polish/errmsg.txt
+1
-0
sql/share/portuguese/errmsg.txt
sql/share/portuguese/errmsg.txt
+1
-0
sql/share/romanian/errmsg.txt
sql/share/romanian/errmsg.txt
+1
-0
sql/share/russian/errmsg.txt
sql/share/russian/errmsg.txt
+1
-0
sql/share/slovak/errmsg.txt
sql/share/slovak/errmsg.txt
+1
-0
sql/share/spanish/errmsg.txt
sql/share/spanish/errmsg.txt
+1
-0
sql/share/swedish/errmsg.txt
sql/share/swedish/errmsg.txt
+1
-0
sql/sql_lex.h
sql/sql_lex.h
+3
-1
sql/sql_parse.cc
sql/sql_parse.cc
+7
-0
sql/sql_repl.cc
sql/sql_repl.cc
+271
-1
sql/sql_repl.h
sql/sql_repl.h
+4
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+14
-0
No files found.
include/mysqld_error.h
View file @
c01d4e1e
...
...
@@ -213,4 +213,5 @@
#define ER_CONNECT_TO_MASTER 1210
#define ER_QUERY_ON_MASTER 1211
#define ER_SHOW_BINLOG_EVENTS 1212
#define ER_ERROR_MESSAGES 213
#define ER_SHOW_NEW_MASTER 1213
#define ER_ERROR_MESSAGES 214
mysql-test/fix-result
0 → 100755
View file @
c01d4e1e
#! /bin/sh
# Sasha's hack to fix results generated with mysql-test-run --record
# to be version and test port independent. In some cases, further minor
# manual edititing may be required, but most of the time it should not
# happen
#It is assumed we are running the script in mysql-test directory
VERSION
=
4.0.0-debug-log
TEST_CASE
=
$1
if
[
-z
"
$TEST_CASE
"
]
;
then
echo
"usage:
$0
test_case_name"
exit
1
fi
../extra/replace
$VERSION
'$VERSION'
9306
'$MASTER_MYPORT'
9307
\
'$SLAVE_MYPORT'
\\
\\\\
--
r/
$TEST_CASE
.result
mysql-test/r/rpl_log.result
View file @
c01d4e1e
...
...
@@ -55,3 +55,13 @@ slave-bin.002 190 Query 1 3 use test; insert into t1 values (1)
slave-bin.002 250 Query 1 4 use test; drop table t1
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Last_log_seq
127.0.0.1 root $MASTER_MYPORT 1 master-bin.002 245 Yes 0 0 4
Log_name Log_pos
slave-bin.001 132
Log_name Log_pos
slave-bin.001 225
Log_name Log_pos
slave-bin.001 439
Log_name Log_pos
slave-bin.002 132
Log_name Log_pos
slave-bin.002 250
mysql-test/t/rpl_log.test
View file @
c01d4e1e
...
...
@@ -36,3 +36,13 @@ show master logs;
show
binlog
events
in
'slave-bin.001'
from
4
;
show
binlog
events
in
'slave-bin.002'
from
4
;
show
slave
status
;
show
new
master
for
slave
with
master_log_file
=
'master-bin.001'
and
master_log_pos
=
4
and
master_log_seq
=
1
and
master_server_id
=
1
;
show
new
master
for
slave
with
master_log_file
=
'master-bin.001'
and
master_log_pos
=
79
and
master_log_seq
=
2
and
master_server_id
=
1
;
show
new
master
for
slave
with
master_log_file
=
'master-bin.001'
and
master_log_pos
=
311
and
master_log_seq
=
6
and
master_server_id
=
1
;
show
new
master
for
slave
with
master_log_file
=
'master-bin.002'
and
master_log_pos
=
4
and
master_log_seq
=
1
and
master_server_id
=
1
;
show
new
master
for
slave
with
master_log_file
=
'master-bin.002'
and
master_log_pos
=
137
and
master_log_seq
=
3
and
master_server_id
=
1
;
sql/lex.h
View file @
c01d4e1e
...
...
@@ -215,8 +215,10 @@ static SYMBOL symbols[] = {
{
"MASTER_HOST"
,
SYM
(
MASTER_HOST_SYM
),
0
,
0
},
{
"MASTER_LOG_FILE"
,
SYM
(
MASTER_LOG_FILE_SYM
),
0
,
0
},
{
"MASTER_LOG_POS"
,
SYM
(
MASTER_LOG_POS_SYM
),
0
,
0
},
{
"MASTER_LOG_SEQ"
,
SYM
(
MASTER_LOG_SEQ_SYM
),
0
,
0
},
{
"MASTER_PASSWORD"
,
SYM
(
MASTER_PASSWORD_SYM
),
0
,
0
},
{
"MASTER_PORT"
,
SYM
(
MASTER_PORT_SYM
),
0
,
0
},
{
"MASTER_SERVER_ID"
,
SYM
(
MASTER_SERVER_ID_SYM
),
0
,
0
},
{
"MASTER_USER"
,
SYM
(
MASTER_USER_SYM
),
0
,
0
},
{
"MAX_ROWS"
,
SYM
(
MAX_ROWS
),
0
,
0
},
{
"MATCH"
,
SYM
(
MATCH
),
0
,
0
},
...
...
@@ -237,6 +239,7 @@ static SYMBOL symbols[] = {
{
"NATURAL"
,
SYM
(
NATURAL
),
0
,
0
},
{
"NATIONAL"
,
SYM
(
NATIONAL_SYM
),
0
,
0
},
{
"NEXT"
,
SYM
(
NEXT_SYM
),
0
,
0
},
{
"NEW"
,
SYM
(
NEW_SYM
),
0
,
0
},
{
"NCHAR"
,
SYM
(
NCHAR_SYM
),
0
,
0
},
{
"NO"
,
SYM
(
NO_SYM
),
0
,
0
},
{
"NOT"
,
SYM
(
NOT
),
0
,
0
},
...
...
sql/share/czech/errmsg.txt
View file @
c01d4e1e
...
...
@@ -223,3 +223,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/danish/errmsg.txt
View file @
c01d4e1e
...
...
@@ -217,3 +217,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/dutch/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/english/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/estonian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -218,3 +218,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/french/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/german/errmsg.txt
View file @
c01d4e1e
...
...
@@ -217,3 +217,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/greek/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/hungarian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -216,3 +216,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/italian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/japanese/errmsg.txt
View file @
c01d4e1e
...
...
@@ -216,3 +216,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/korean/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/norwegian-ny/errmsg.txt
View file @
c01d4e1e
...
...
@@ -216,3 +216,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/norwegian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -216,3 +216,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/polish/errmsg.txt
View file @
c01d4e1e
...
...
@@ -218,3 +218,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/portuguese/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/romanian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -218,3 +218,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/russian/errmsg.txt
View file @
c01d4e1e
...
...
@@ -217,3 +217,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/slovak/errmsg.txt
View file @
c01d4e1e
...
...
@@ -222,3 +222,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/spanish/errmsg.txt
View file @
c01d4e1e
...
...
@@ -215,3 +215,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/share/swedish/errmsg.txt
View file @
c01d4e1e
...
...
@@ -214,3 +214,4 @@
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error in SHOW BINLOG EVENTS: %-.128s",
"Error in SHOW NEW MASTER: %-.128s",
sql/sql_lex.h
View file @
c01d4e1e
...
...
@@ -56,7 +56,7 @@ enum enum_sql_command {
SQLCOM_SHOW_OPEN_TABLES
,
SQLCOM_LOAD_MASTER_DATA
,
SQLCOM_HA_OPEN
,
SQLCOM_HA_CLOSE
,
SQLCOM_HA_READ
,
SQLCOM_SHOW_SLAVE_HOSTS
,
SQLCOM_MULTI_DELETE
,
SQLCOM_UNION_SELECT
,
SQLCOM_SHOW_BINLOG_EVENTS
SQLCOM_SHOW_BINLOG_EVENTS
,
SQLCOM_SHOW_NEW_MASTER
};
enum
lex_states
{
STATE_START
,
STATE_CHAR
,
STATE_IDENT
,
...
...
@@ -93,7 +93,9 @@ typedef struct st_lex_master_info
{
char
*
host
,
*
user
,
*
password
,
*
log_file_name
;
uint
port
,
connect_retry
;
ulong
last_log_seq
;
ulonglong
pos
;
ulong
server_id
;
}
LEX_MASTER_INFO
;
...
...
sql/sql_parse.cc
View file @
c01d4e1e
...
...
@@ -1173,6 +1173,13 @@ mysql_execute_command(void)
res
=
purge_master_logs
(
thd
,
lex
->
to_log
);
break
;
}
case
SQLCOM_SHOW_NEW_MASTER
:
{
if
(
check_access
(
thd
,
FILE_ACL
,
any_db
))
goto
error
;
res
=
show_new_master
(
thd
);
break
;
}
case
SQLCOM_SHOW_SLAVE_HOSTS
:
{
if
(
check_access
(
thd
,
FILE_ACL
,
any_db
))
...
...
sql/sql_repl.cc
View file @
c01d4e1e
...
...
@@ -26,6 +26,7 @@
#include <my_dir.h>
#define SLAVE_LIST_CHUNK 128
#define SLAVE_ERRMSG_SIZE (FN_REFLEN+64)
extern
const
char
*
any_db
;
extern
pthread_handler_decl
(
handle_slave
,
arg
);
...
...
@@ -38,6 +39,10 @@ bool opt_sporadic_binlog_dump_fail = 0;
static
int
binlog_dump_count
=
0
;
#endif
static
Slave_log_event
*
find_slave_event
(
IO_CACHE
*
log
,
const
char
*
log_file_name
,
char
*
errmsg
);
static
uint32
*
slave_list_key
(
SLAVE_INFO
*
si
,
uint
*
len
,
my_bool
not_used
__attribute__
((
unused
)))
{
...
...
@@ -863,6 +868,272 @@ void reset_master()
}
int
cmp_master_pos
(
const
char
*
log_file_name1
,
ulonglong
log_pos1
,
const
char
*
log_file_name2
,
ulonglong
log_pos2
)
{
int
res
;
if
((
res
=
strcmp
(
log_file_name1
,
log_file_name2
)))
return
res
;
if
(
log_pos1
>
log_pos2
)
return
1
;
else
if
(
log_pos1
==
log_pos2
)
return
0
;
return
-
1
;
}
static
inline
int
cmp_master_pos
(
Slave_log_event
*
sev
,
LEX_MASTER_INFO
*
mi
)
{
return
cmp_master_pos
(
sev
->
master_log
,
sev
->
master_pos
,
mi
->
log_file_name
,
mi
->
pos
);
}
static
int
find_target_pos
(
LEX_MASTER_INFO
*
mi
,
IO_CACHE
*
log
,
char
*
errmsg
)
{
uint32
log_seq
=
mi
->
last_log_seq
;
uint32
target_server_id
=
mi
->
server_id
;
for
(;;)
{
Log_event
*
ev
;
if
(
!
(
ev
=
Log_event
::
read_log_event
(
log
,
0
)))
{
if
(
log
->
error
>
0
)
strmov
(
errmsg
,
"Binary log truncated in the middle of event"
);
else
if
(
log
->
error
<
0
)
strmov
(
errmsg
,
"I/O error reading binary log"
);
else
strmov
(
errmsg
,
"Could not find target event in the binary log"
);
return
1
;
}
if
(
ev
->
log_seq
==
log_seq
&&
ev
->
server_id
==
target_server_id
)
{
delete
ev
;
mi
->
pos
=
my_b_tell
(
log
);
return
0
;
}
delete
ev
;
}
}
static
void
copy_base_name
(
char
*
dest
,
char
*
src
)
{
char
*
p
;
p
=
strrchr
(
src
,
FN_LIBCHAR
);
if
(
p
)
p
++
;
else
p
=
src
;
strmov
(
dest
,
p
);
}
int
translate_master
(
THD
*
thd
,
LEX_MASTER_INFO
*
mi
,
char
*
errmsg
)
{
LOG_INFO
linfo
;
char
search_file_name
[
FN_REFLEN
],
last_log_name
[
FN_REFLEN
];
IO_CACHE
log
,
last_log
;
File
file
=
-
1
,
last_file
=
-
1
;
pthread_mutex_t
*
log_lock
;
const
char
*
errmsg_p
;
Slave_log_event
*
sev
=
0
;
my_off_t
last_pos
=
0
;
int
error
=
1
;
int
cmp_res
;
LINT_INIT
(
cmp_res
);
if
(
!
mysql_bin_log
.
is_open
())
{
strmov
(
errmsg
,
"Binary log is not open"
);
return
1
;
}
if
(
!
server_id_supplied
)
{
strmov
(
errmsg
,
"Misconfigured master - server id was not set"
);
return
1
;
}
linfo
.
index_file_offset
=
0
;
thd
->
current_linfo
=
&
linfo
;
search_file_name
[
0
]
=
0
;
if
(
mysql_bin_log
.
find_first_log
(
&
linfo
,
search_file_name
))
{
strmov
(
errmsg
,
"Could not find first log"
);
return
1
;
}
bzero
((
char
*
)
&
log
,
sizeof
(
log
));
log_lock
=
mysql_bin_log
.
get_log_lock
();
pthread_mutex_lock
(
log_lock
);
for
(;;)
{
if
((
file
=
open_binlog
(
&
log
,
linfo
.
log_file_name
,
&
errmsg_p
))
<
0
)
{
pthread_mutex_unlock
(
log_lock
);
strmov
(
errmsg
,
errmsg_p
);
goto
err
;
}
if
(
!
(
sev
=
find_slave_event
(
&
log
,
linfo
.
log_file_name
,
errmsg
)))
{
pthread_mutex_unlock
(
log_lock
);
goto
err
;
}
cmp_res
=
cmp_master_pos
(
sev
,
mi
);
delete
sev
;
if
(
!
cmp_res
)
{
pthread_mutex_unlock
(
log_lock
);
copy_base_name
(
mi
->
log_file_name
,
linfo
.
log_file_name
);
mi
->
pos
=
my_b_tell
(
&
log
);
goto
mi_inited
;
}
if
(
!
last_pos
&&
cmp_res
>
0
)
{
pthread_mutex_unlock
(
log_lock
);
strmov
(
errmsg
,
"Slave event in first log points past the \
target position"
);
goto
err
;
}
if
(
last_pos
&&
cmp_res
>
0
)
{
end_io_cache
(
&
log
);
(
void
)
my_close
(
file
,
MYF
(
MY_WME
));
if
(
init_io_cache
(
&
log
,
(
file
=
last_file
),
IO_SIZE
,
READ_CACHE
,
0
,
0
,
MYF
(
MY_WME
)))
{
errmsg
[
0
]
=
0
;
goto
err
;
}
goto
found_log
;
}
strmov
(
last_log_name
,
linfo
.
log_file_name
);
last_pos
=
my_b_tell
(
&
log
);
switch
(
mysql_bin_log
.
find_next_log
(
&
linfo
))
{
case
LOG_INFO_EOF
:
if
(
last_file
>=
0
)
(
void
)
my_close
(
last_file
,
MYF
(
MY_WME
));
last_file
=
-
1
;
goto
found_log
;
case
0
:
break
;
default:
pthread_mutex_unlock
(
log_lock
);
strmov
(
errmsg
,
"Error reading log index"
);
goto
err
;
}
end_io_cache
(
&
log
);
if
(
last_file
>=
0
)
(
void
)
my_close
(
last_file
,
MYF
(
MY_WME
));
last_file
=
file
;
}
found_log:
my_b_seek
(
&
log
,
last_pos
);
if
(
find_target_pos
(
mi
,
&
log
,
errmsg
))
{
pthread_mutex_unlock
(
log_lock
);
goto
err
;
}
pthread_mutex_unlock
(
log_lock
);
copy_base_name
(
mi
->
log_file_name
,
last_log_name
);
mi_inited:
error
=
0
;
err:
end_io_cache
(
&
log
);
pthread_mutex_lock
(
&
LOCK_thread_count
);
thd
->
current_linfo
=
0
;
pthread_mutex_unlock
(
&
LOCK_thread_count
);
if
(
file
>=
0
)
(
void
)
my_close
(
file
,
MYF
(
MY_WME
));
if
(
last_file
>=
0
&&
last_file
!=
file
)
(
void
)
my_close
(
last_file
,
MYF
(
MY_WME
));
return
error
;
}
// caller must delete result when done
static
Slave_log_event
*
find_slave_event
(
IO_CACHE
*
log
,
const
char
*
log_file_name
,
char
*
errmsg
)
{
Log_event
*
ev
;
if
(
!
(
ev
=
Log_event
::
read_log_event
(
log
,
0
)))
{
my_vsnprintf
(
errmsg
,
SLAVE_ERRMSG_SIZE
,
"Error reading start event in log '%s'"
,
(
char
*
)
log_file_name
);
return
0
;
}
delete
ev
;
if
(
!
(
ev
=
Log_event
::
read_log_event
(
log
,
0
)))
{
my_vsnprintf
(
errmsg
,
SLAVE_ERRMSG_SIZE
,
"Error reading slave event in log '%s'"
,
(
char
*
)
log_file_name
);
return
0
;
}
if
(
ev
->
get_type_code
()
!=
SLAVE_EVENT
)
{
my_vsnprintf
(
errmsg
,
SLAVE_ERRMSG_SIZE
,
"Second event in log '%s' is not slave event"
,
(
char
*
)
log_file_name
);
delete
ev
;
return
0
;
}
return
(
Slave_log_event
*
)
ev
;
}
int
show_new_master
(
THD
*
thd
)
{
DBUG_ENTER
(
"show_new_master"
);
List
<
Item
>
field_list
;
char
errmsg
[
SLAVE_ERRMSG_SIZE
];
LEX_MASTER_INFO
*
lex_mi
=
&
thd
->
lex
.
mi
;
if
(
translate_master
(
thd
,
lex_mi
,
errmsg
))
{
if
(
errmsg
[
0
])
net_printf
(
&
thd
->
net
,
ER_SHOW_NEW_MASTER
,
errmsg
);
else
send_error
(
&
thd
->
net
,
0
);
DBUG_RETURN
(
1
);
}
else
{
String
*
packet
=
&
thd
->
packet
;
field_list
.
push_back
(
new
Item_empty_string
(
"Log_name"
,
20
));
field_list
.
push_back
(
new
Item_empty_string
(
"Log_pos"
,
20
));
if
(
send_fields
(
thd
,
field_list
,
1
))
DBUG_RETURN
(
-
1
);
packet
->
length
(
0
);
net_store_data
(
packet
,
lex_mi
->
log_file_name
);
net_store_data
(
packet
,
(
longlong
)
lex_mi
->
pos
);
if
(
my_net_write
(
&
thd
->
net
,
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
send_eof
(
&
thd
->
net
);
DBUG_RETURN
(
0
);
}
}
int
show_binlog_events
(
THD
*
thd
)
{
...
...
@@ -913,7 +1184,6 @@ int show_binlog_events(THD* thd)
}
pthread_mutex_lock
(
mysql_bin_log
.
get_log_lock
());
my_b_seek
(
&
log
,
pos
);
for
(
event_count
=
0
;
...
...
sql/sql_repl.h
View file @
c01d4e1e
...
...
@@ -33,8 +33,12 @@ int stop_slave(THD* thd = 0, bool net_report = 1);
int
load_master_data
(
THD
*
thd
);
int
connect_to_master
(
THD
*
thd
,
MYSQL
*
mysql
,
MASTER_INFO
*
mi
);
int
change_master
(
THD
*
thd
);
int
show_new_master
(
THD
*
thd
);
int
show_slave_hosts
(
THD
*
thd
);
int
show_binlog_events
(
THD
*
thd
);
int
translate_master
(
THD
*
thd
,
LEX_MASTER_INFO
*
mi
,
char
*
errmsg
);
int
cmp_master_pos
(
const
char
*
log_file_name1
,
ulonglong
log_pos1
,
const
char
*
log_file_name2
,
ulonglong
log_pos2
);
void
reset_slave
();
void
reset_master
();
void
init_slave_list
();
...
...
sql/sql_yacc.yy
View file @
c01d4e1e
...
...
@@ -223,9 +223,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token MASTER_USER_SYM
%token MASTER_LOG_FILE_SYM
%token MASTER_LOG_POS_SYM
%token MASTER_LOG_SEQ_SYM
%token MASTER_PASSWORD_SYM
%token MASTER_PORT_SYM
%token MASTER_CONNECT_RETRY_SYM
%token MASTER_SERVER_ID_SYM
%token MATCH
%token MAX_ROWS
%token MEDIUM_SYM
...
...
@@ -234,6 +236,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token MYISAM_SYM
%token NATIONAL_SYM
%token NATURAL
%token NEW_SYM
%token NCHAR_SYM
%token NOT
%token NO_SYM
...
...
@@ -2402,6 +2405,17 @@ show_param:
if (!add_table_to_list($4,NULL,0))
YYABORT;
}
| NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ
TEXT_STRING AND MASTER_LOG_POS_SYM EQ ULONGLONG_NUM AND
MASTER_LOG_SEQ_SYM EQ ULONG_NUM AND MASTER_SERVER_ID_SYM EQ
ULONG_NUM
{
Lex->sql_command = SQLCOM_SHOW_NEW_MASTER;
Lex->mi.log_file_name = $8.str;
Lex->mi.pos = $12;
Lex->mi.last_log_seq = $16;
Lex->mi.server_id = $20;
}
| MASTER_SYM LOGS_SYM
{
Lex->sql_command = SQLCOM_SHOW_BINLOGS;
...
...
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