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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
4ead61f8
Commit
4ead61f8
authored
May 26, 2003
by
monty@narttu.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup
parent
17dfc881
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
35 deletions
+34
-35
mysql-test/r/rpl_insert_id.result
mysql-test/r/rpl_insert_id.result
+2
-0
mysql-test/t/rpl_insert_id.test
mysql-test/t/rpl_insert_id.test
+7
-3
sql/log.cc
sql/log.cc
+25
-32
No files found.
mysql-test/r/rpl_insert_id.result
View file @
4ead61f8
...
@@ -23,10 +23,12 @@ drop table t1;
...
@@ -23,10 +23,12 @@ drop table t1;
drop table t2;
drop table t2;
create table t1(a int auto_increment, key(a));
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
create table t2(b int auto_increment, c int, key(b));
SET FOREIGN_KEY_CHECKS=0;
insert into t1 values (10);
insert into t1 values (10);
insert into t1 values (null),(null),(null);
insert into t1 values (null),(null),(null);
insert into t2 values (5,0);
insert into t2 values (5,0);
insert into t2 values (null,last_insert_id());
insert into t2 values (null,last_insert_id());
SET FOREIGN_KEY_CHECKS=1;
select * from t1;
select * from t1;
a
a
10
10
...
...
mysql-test/t/rpl_insert_id.test
View file @
4ead61f8
#see if queries that use both
# See if queries that use both auto_increment and LAST_INSERT_ID()
#auto_increment and LAST_INSERT_ID()
# are replicated well
#are replicated well
# We also check how the foreign_key_check variable is replicated
source
include
/
master
-
slave
.
inc
;
source
include
/
master
-
slave
.
inc
;
connection
master
;
connection
master
;
drop
table
if
exists
t1
;
drop
table
if
exists
t1
;
...
@@ -22,10 +24,12 @@ drop table t1;
...
@@ -22,10 +24,12 @@ drop table t1;
drop
table
t2
;
drop
table
t2
;
create
table
t1
(
a
int
auto_increment
,
key
(
a
));
create
table
t1
(
a
int
auto_increment
,
key
(
a
));
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
));
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
));
SET
FOREIGN_KEY_CHECKS
=
0
;
insert
into
t1
values
(
10
);
insert
into
t1
values
(
10
);
insert
into
t1
values
(
null
),(
null
),(
null
);
insert
into
t1
values
(
null
),(
null
),(
null
);
insert
into
t2
values
(
5
,
0
);
insert
into
t2
values
(
5
,
0
);
insert
into
t2
values
(
null
,
last_insert_id
());
insert
into
t2
values
(
null
,
last_insert_id
());
SET
FOREIGN_KEY_CHECKS
=
1
;
save_master_pos
;
save_master_pos
;
connection
slave
;
connection
slave
;
sync_with_master
;
sync_with_master
;
...
...
sql/log.cc
View file @
4ead61f8
...
@@ -1116,51 +1116,39 @@ bool MYSQL_LOG::write(Log_event* event_info)
...
@@ -1116,51 +1116,39 @@ bool MYSQL_LOG::write(Log_event* event_info)
goto
err
;
goto
err
;
}
}
/* If the user has set FOREIGN_KEY_CHECKS=0 we wrap every SQL
/*
If the user has set FOREIGN_KEY_CHECKS=0 we wrap every SQL
command in the binlog inside:
command in the binlog inside:
SET FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS=0;
<command>;
<command>;
SET FOREIGN_KEY_CHECKS=1; */
SET FOREIGN_KEY_CHECKS=1;
*/
if
(
thd
->
options
&
OPTION_NO_FOREIGN_KEY_CHECKS
)
if
(
thd
->
options
&
OPTION_NO_FOREIGN_KEY_CHECKS
)
{
{
char
buf
[
256
],
*
p
;
Query_log_event
e
(
thd
,
"SET FOREIGN_KEY_CHECKS=0"
,
24
,
0
);
p
=
strmov
(
buf
,
"SET FOREIGN_KEY_CHECKS=0"
);
Query_log_event
e
(
thd
,
buf
,
(
ulong
)
(
p
-
buf
),
0
);
e
.
set_log_pos
(
this
);
e
.
set_log_pos
(
this
);
if
(
e
.
write
(
file
))
if
(
e
.
write
(
file
))
goto
err
;
goto
err
;
}
}
}
}
/*
/* Write the SQL command */
2. Write the SQL command
*/
event_info
->
set_log_pos
(
this
);
event_info
->
set_log_pos
(
this
);
if
(
event_info
->
write
(
file
)
||
if
(
event_info
->
write
(
file
))
file
==
&
log_file
&&
flush_io_cache
(
file
))
goto
err
;
goto
err
;
/*
/* Write log events to reset the 'run environment' of the SQL command */
3. Write log events to reset the 'run environment' of the SQL command
*/
if
(
thd
&&
thd
->
options
&
OPTION_NO_FOREIGN_KEY_CHECKS
)
if
(
thd
&&
thd
->
options
&
OPTION_NO_FOREIGN_KEY_CHECKS
)
{
{
char
buf
[
256
],
*
p
;
Query_log_event
e
(
thd
,
"SET FOREIGN_KEY_CHECKS=1"
,
24
,
0
);
p
=
strmov
(
buf
,
"SET FOREIGN_KEY_CHECKS=1"
);
Query_log_event
e
(
thd
,
buf
,
(
ulong
)
(
p
-
buf
),
0
);
e
.
set_log_pos
(
this
);
e
.
set_log_pos
(
this
);
if
(
e
.
write
(
file
))
if
(
e
.
write
(
file
)
||
file
==
&
log_file
&&
flush_io_cache
(
file
))
goto
err
;
goto
err
;
}
}
error
=
0
;
/*
/*
Tell for transactional table handlers up to which position in the
Tell for transactional table handlers up to which position in the
binlog file we wrote. The table handler can store this info, and
binlog file we wrote. The table handler can store this info, and
...
@@ -1180,6 +1168,9 @@ bool MYSQL_LOG::write(Log_event* event_info)
...
@@ -1180,6 +1168,9 @@ bool MYSQL_LOG::write(Log_event* event_info)
if
(
file
==
&
log_file
)
// we are writing to the real log (disk)
if
(
file
==
&
log_file
)
// we are writing to the real log (disk)
{
{
if
(
flush_io_cache
(
file
))
goto
err
;
if
(
opt_using_transactions
&&
!
my_b_tell
(
&
thd
->
transaction
.
trans_log
))
if
(
opt_using_transactions
&&
!
my_b_tell
(
&
thd
->
transaction
.
trans_log
))
{
{
/*
/*
...
@@ -1189,8 +1180,8 @@ bool MYSQL_LOG::write(Log_event* event_info)
...
@@ -1189,8 +1180,8 @@ bool MYSQL_LOG::write(Log_event* event_info)
handler if the log event type is appropriate.
handler if the log event type is appropriate.
*/
*/
if
(
event_info
->
get_type_code
()
==
QUERY_EVENT
if
(
event_info
->
get_type_code
()
==
QUERY_EVENT
||
||
event_info
->
get_type_code
()
==
EXEC_LOAD_EVENT
)
event_info
->
get_type_code
()
==
EXEC_LOAD_EVENT
)
{
{
error
=
ha_report_binlog_offset_and_commit
(
thd
,
log_file_name
,
error
=
ha_report_binlog_offset_and_commit
(
thd
,
log_file_name
,
file
->
pos_in_file
);
file
->
pos_in_file
);
...
@@ -1200,6 +1191,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
...
@@ -1200,6 +1191,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
/* we wrote to the real log, check automatic rotation */
/* we wrote to the real log, check automatic rotation */
should_rotate
=
(
my_b_tell
(
file
)
>=
(
my_off_t
)
max_binlog_size
);
should_rotate
=
(
my_b_tell
(
file
)
>=
(
my_off_t
)
max_binlog_size
);
}
}
error
=
0
;
err:
err:
if
(
error
)
if
(
error
)
...
@@ -1222,13 +1214,14 @@ err:
...
@@ -1222,13 +1214,14 @@ err:
pthread_mutex_unlock
(
&
LOCK_log
);
pthread_mutex_unlock
(
&
LOCK_log
);
/* Flush the transactional handler log file now that we have released
/*
Flush the transactional handler log file now that we have released
LOCK_log; the flush is placed here to eliminate the bottleneck on the
LOCK_log; the flush is placed here to eliminate the bottleneck on the
group commit */
group commit
*/
if
(
called_handler_commit
)
{
if
(
called_handler_commit
)
ha_commit_complete
(
thd
);
ha_commit_complete
(
thd
);
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
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