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
19e1bc76
Commit
19e1bc76
authored
May 15, 2008
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge riska.(none):/home/sven/bkroot/5.1-bugteam
into riska.(none):/home/sven/bk/b36433-rpl_insert_id/5.1-bugteam
parents
6a6ec902
c25bd6fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
90 deletions
+104
-90
mysql-test/extra/rpl_tests/rpl_insert_id.test
mysql-test/extra/rpl_tests/rpl_insert_id.test
+62
-51
mysql-test/suite/rpl/r/rpl_insert_id.result
mysql-test/suite/rpl/r/rpl_insert_id.result
+42
-39
No files found.
mysql-test/extra/rpl_tests/rpl_insert_id.test
View file @
19e1bc76
...
...
@@ -18,6 +18,13 @@ use test;
drop
table
if
exists
t1
,
t2
,
t3
;
--
enable_warnings
# If concurrent inserts are on, it is not guaranteed that the rows
# inserted by INSERT are immediately accessible by SELECT in another
# thread. This would cause problems near the line 'connection master1'
# below. So we turn off concurrent inserts.
SET
@
old_concurrent_insert
=
@@
global
.
concurrent_insert
;
SET
@@
global
.
concurrent_insert
=
0
;
--
echo
#
--
echo
# See if queries that use both auto_increment and LAST_INSERT_ID()
--
echo
# are replicated well
...
...
@@ -29,8 +36,8 @@ drop table if exists t1, t2, t3;
#should work for both SBR and RBR
connection
master
;
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
;
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
))
;
eval
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
engine
=
$engine_type
;
eval
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
))
engine
=
$engine_type
;
insert
into
t1
values
(
1
),(
2
),(
3
);
insert
into
t1
values
(
null
);
insert
into
t2
values
(
null
,
last_insert_id
());
...
...
@@ -68,8 +75,8 @@ connection master;
drop
table
t2
;
drop
table
t1
;
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
;
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
))
;
eval
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
engine
=
$engine_type
;
eval
create
table
t2
(
b
int
auto_increment
,
c
int
,
key
(
b
))
engine
=
$engine_type
;
insert
into
t1
values
(
10
);
insert
into
t1
values
(
null
),(
null
),(
null
);
insert
into
t2
values
(
5
,
0
);
...
...
@@ -94,7 +101,7 @@ sync_with_master;
connection
master
;
SET
TIMESTAMP
=
1000000000
;
CREATE
TABLE
t1
(
a
INT
UNIQUE
)
;
eval
CREATE
TABLE
t1
(
a
INT
UNIQUE
)
engine
=
$engine_type
;
SET
FOREIGN_KEY_CHECKS
=
0
;
# Duplicate Key Errors
--
error
1022
,
ER_DUP_ENTRY
...
...
@@ -109,8 +116,8 @@ sync_slave_with_master;
--
echo
#
connection
master
;
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
;
create
table
t2
(
a
int
)
;
eval
create
table
t1
(
a
int
auto_increment
,
key
(
a
))
engine
=
$engine_type
;
eval
create
table
t2
(
a
int
)
engine
=
$engine_type
;
insert
into
t1
(
a
)
values
(
null
);
insert
into
t2
(
a
)
select
a
from
t1
where
a
is
null
;
insert
into
t2
(
a
)
select
a
from
t1
where
a
is
null
;
...
...
@@ -139,11 +146,11 @@ drop function if exists bug15728_insert;
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
create
table
t1
(
eval
create
table
t1
(
id
int
not
null
auto_increment
,
last_id
int
,
primary
key
(
id
)
);
)
engine
=
$engine_type
;
create
function
bug15728
()
returns
int
(
11
)
return
last_insert_id
();
...
...
@@ -152,11 +159,11 @@ insert into t1 (last_id) values (last_insert_id());
insert
into
t1
(
last_id
)
values
(
bug15728
());
# Check that nested call replicates too.
create
table
t2
(
eval
create
table
t2
(
id
int
not
null
auto_increment
,
last_id
int
,
primary
key
(
id
)
);
)
engine
=
$engine_type
;
delimiter
|
;
create
function
bug15728_insert
()
returns
int
(
11
)
modifies
sql
data
begin
...
...
@@ -215,8 +222,8 @@ drop procedure foo;
# test of BUG#20188 REPLACE or ON DUPLICATE KEY UPDATE in
# auto_increment breaks binlog
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
;
eval
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
engine
=
$engine_type
;
# First, test that we do not call restore_auto_increment() too early
# in write_record():
...
...
@@ -257,8 +264,8 @@ select * from t1 order by n;
# and now test for the bug:
connection
master
;
drop
table
t1
;
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
;
eval
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
engine
=
$engine_type
;
insert
into
t1
values
(
null
,
100
);
select
*
from
t1
order
by
n
;
sync_slave_with_master
;
...
...
@@ -282,29 +289,29 @@ sync_slave_with_master;
connection
master
;
# testcase with INSERT VALUES
CREATE
TABLE
t1
(
a
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
,
UNIQUE
(
b
))
;
eval
CREATE
TABLE
t1
(
a
INT
NOT
NULL
PRIMARY
KEY
AUTO_INCREMENT
,
b
INT
,
UNIQUE
(
b
))
ENGINE
=
$engine_type
;
INSERT
INTO
t1
(
b
)
VALUES
(
1
),(
1
),(
2
)
ON
DUPLICATE
KEY
UPDATE
t1
.
b
=
10
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t1
ORDER
BY
a
;
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t1
ORDER
BY
a
;
connection
master
;
drop
table
t1
;
# tescase with INSERT SELECT
CREATE
TABLE
t1
(
eval
CREATE
TABLE
t1
(
id
bigint
(
20
)
unsigned
NOT
NULL
auto_increment
,
field_1
int
(
10
)
unsigned
NOT
NULL
,
field_2
varchar
(
255
)
NOT
NULL
,
field_3
varchar
(
255
)
NOT
NULL
,
PRIMARY
KEY
(
id
),
UNIQUE
KEY
field_1
(
field_1
,
field_2
)
);
CREATE
TABLE
t2
(
)
ENGINE
=
$engine_type
;
eval
CREATE
TABLE
t2
(
field_a
int
(
10
)
unsigned
NOT
NULL
,
field_b
varchar
(
255
)
NOT
NULL
,
field_c
varchar
(
255
)
NOT
NULL
);
)
ENGINE
=
$engine_type
;
INSERT
INTO
t2
(
field_a
,
field_b
,
field_c
)
VALUES
(
1
,
'a'
,
'1a'
);
INSERT
INTO
t2
(
field_a
,
field_b
,
field_c
)
VALUES
(
2
,
'b'
,
'2b'
);
INSERT
INTO
t2
(
field_a
,
field_b
,
field_c
)
VALUES
(
3
,
'c'
,
'3c'
);
...
...
@@ -324,9 +331,9 @@ SELECT t2.field_a, t2.field_b, t2.field_c
FROM
t2
ON
DUPLICATE
KEY
UPDATE
t1
.
field_3
=
t2
.
field_c
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t1
ORDER
BY
id
;
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t1
ORDER
BY
id
;
connection
master
;
drop
table
t1
,
t2
;
...
...
@@ -348,17 +355,17 @@ DROP TABLE IF EXISTS t1, t2;
# Reset result of LAST_INSERT_ID().
SELECT
LAST_INSERT_ID
(
0
);
CREATE
TABLE
t1
(
eval
CREATE
TABLE
t1
(
id
INT
NOT
NULL
DEFAULT
0
,
last_id
INT
,
PRIMARY
KEY
(
id
)
);
)
ENGINE
=
$engine_type
;
CREATE
TABLE
t2
(
eval
CREATE
TABLE
t2
(
id
INT
NOT
NULL
AUTO_INCREMENT
,
last_id
INT
,
PRIMARY
KEY
(
id
)
);
)
ENGINE
=
$engine_type
;
delimiter
|
;
CREATE
PROCEDURE
p1
()
...
...
@@ -369,12 +376,12 @@ END|
delimiter
;
|
CALL
p1
();
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
SELECT
*
FROM
t1
ORDER
BY
id
;
SELECT
*
FROM
t2
ORDER
BY
id
;
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
SELECT
*
FROM
t1
ORDER
BY
id
;
SELECT
*
FROM
t2
ORDER
BY
id
;
connection
master
;
...
...
@@ -394,11 +401,11 @@ DROP FUNCTION IF EXISTS f3;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
eval
CREATE
TABLE
t1
(
i
INT
NOT
NULL
AUTO_INCREMENT
PRIMARY
KEY
,
j
INT
DEFAULT
0
);
CREATE
TABLE
t2
(
i
INT
)
;
)
ENGINE
=
$engine_type
;
eval
CREATE
TABLE
t2
(
i
INT
)
ENGINE
=
$engine_type
;
delimiter
|
;
CREATE
PROCEDURE
p1
()
...
...
@@ -443,14 +450,16 @@ UPDATE t1 SET j= -1 WHERE i IS NULL;
# Test statement-based replication of function calls.
INSERT
INTO
t1
(
i
)
VALUES
(
NULL
);
# Here, we rely on having set @@concurrent_insert= 0 (see comment at
# the top of this file).
connection
master1
;
INSERT
INTO
t1
(
i
)
VALUES
(
NULL
);
connection
master
;
SELECT
f3
();
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
SELECT
*
FROM
t1
ORDER
BY
i
;
SELECT
*
FROM
t2
ORDER
BY
i
;
sync_slave_with_master
;
SELECT
*
FROM
t1
;
...
...
@@ -472,11 +481,11 @@ sync_slave_with_master;
# Tests in this file are tightly bound together. Recreate t2.
connection
master
;
create
table
t2
(
eval
create
table
t2
(
id
int
not
null
auto_increment
,
last_id
int
,
primary
key
(
id
)
);
)
engine
=
$engine_type
;
# Test for BUG#20341 "stored function inserting into one
...
...
@@ -484,7 +493,8 @@ create table t2 (
connection
master
;
truncate
table
t2
;
create
table
t1
(
id
tinyint
primary
key
);
# no auto_increment
# no auto_increment
eval
create
table
t1
(
id
tinyint
primary
key
)
engine
=
$engine_type
;
delimiter
|
;
create
function
insid
()
returns
int
...
...
@@ -504,20 +514,20 @@ insert into t2 (id) values(5),(6),(7);
delete
from
t2
where
id
>=
5
;
set
sql_log_bin
=
1
;
insert
into
t1
select
insid
();
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t1
order
by
id
;
select
*
from
t2
order
by
id
;
sync_slave_with_master
;
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t1
order
by
id
;
select
*
from
t2
order
by
id
;
connection
master
;
drop
table
t1
;
drop
function
insid
;
truncate
table
t2
;
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
;
eval
create
table
t1
(
n
int
primary
key
auto_increment
not
null
,
b
int
,
unique
(
b
))
engine
=
$engine_type
;
delimiter
|
;
create
procedure
foo
()
begin
...
...
@@ -528,14 +538,15 @@ begin
end
|
delimiter
;
|
call
foo
();
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t1
order
by
n
;
select
*
from
t2
order
by
id
;
sync_slave_with_master
;
select
*
from
t1
;
select
*
from
t2
;
select
*
from
t1
order
by
n
;
select
*
from
t2
order
by
id
;
connection
master
;
drop
table
t1
,
t2
;
drop
procedure
foo
;
SET
@@
global
.
concurrent_insert
=
@
old_concurrent_insert
;
sync_slave_with_master
;
mysql-test/suite/rpl/r/rpl_insert_id.result
View file @
19e1bc76
...
...
@@ -15,8 +15,8 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
create table t1(a int auto_increment, key(a))
engine=innodb
;
create table t2(b int auto_increment, c int, key(b))
engine=innodb
;
insert into t1 values (1),(2),(3);
insert into t1 values (null);
insert into t2 values (null,last_insert_id());
...
...
@@ -54,8 +54,8 @@ b c
#
drop table t2;
drop table t1;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
create table t1(a int auto_increment, key(a))
engine=innodb
;
create table t2(b int auto_increment, c int, key(b))
engine=innodb
;
insert into t1 values (10);
insert into t1 values (null),(null),(null);
insert into t2 values (5,0);
...
...
@@ -87,7 +87,7 @@ drop table t2;
# FOREIGN_KEY_CHECKS
#
SET TIMESTAMP=1000000000;
CREATE TABLE t1 ( a INT UNIQUE );
CREATE TABLE t1 ( a INT UNIQUE )
engine=innodb
;
SET FOREIGN_KEY_CHECKS=0;
INSERT INTO t1 VALUES (1),(1);
Got one of the listed errors
...
...
@@ -95,8 +95,8 @@ drop table t1;
#
# Bug#14553: NULL in WHERE resets LAST_INSERT_ID
#
create table t1(a int auto_increment, key(a));
create table t2(a int);
create table t1(a int auto_increment, key(a))
engine=innodb
;
create table t2(a int)
engine=innodb
;
insert into t1 (a) values (null);
insert into t2 (a) select a from t1 where a is null;
insert into t2 (a) select a from t1 where a is null;
...
...
@@ -123,7 +123,7 @@ create table t1 (
id int not null auto_increment,
last_id int,
primary key (id)
);
)
engine=innodb
;
create function bug15728() returns int(11)
return last_insert_id();
insert into t1 (last_id) values (0);
...
...
@@ -133,7 +133,7 @@ create table t2 (
id int not null auto_increment,
last_id int,
primary key (id)
);
)
engine=innodb
;
create function bug15728_insert() returns int(11) modifies sql data
begin
insert into t2 (last_id) values (bug15728());
...
...
@@ -199,7 +199,7 @@ drop function bug15728_insert;
drop table t1,t2;
drop procedure foo;
create table t1 (n int primary key auto_increment not null,
b int, unique(b));
b int, unique(b))
engine=innodb
;
set sql_log_bin=0;
insert into t1 values(null,100);
replace into t1 values(null,50),(null,100),(null,150);
...
...
@@ -243,7 +243,7 @@ n b
1001 600
drop table t1;
create table t1 (n int primary key auto_increment not null,
b int, unique(b));
b int, unique(b))
engine=innodb
;
insert into t1 values(null,100);
select * from t1 order by n;
n b
...
...
@@ -264,13 +264,13 @@ n b
3 350
drop table t1;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT,
UNIQUE(b));
UNIQUE(b))
ENGINE=innodb
;
INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10;
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY a
;
a b
1 10
2 2
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY a
;
a b
1 10
2 2
...
...
@@ -282,12 +282,12 @@ field_2 varchar(255) NOT NULL,
field_3 varchar(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY field_1 (field_1, field_2)
);
)
ENGINE=innodb
;
CREATE TABLE t2 (
field_a int(10) unsigned NOT NULL,
field_b varchar(255) NOT NULL,
field_c varchar(255) NOT NULL
);
)
ENGINE=innodb
;
INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c');
...
...
@@ -304,7 +304,7 @@ SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c;
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY id
;
id field_1 field_2 field_3
1 1 a 1a
2 2 b 2b
...
...
@@ -312,7 +312,7 @@ id field_1 field_2 field_3
4 4 d 4d
5 5 e 5e
6 6 f 6f
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY id
;
id field_1 field_2 field_3
1 1 a 1a
2 2 b 2b
...
...
@@ -330,28 +330,28 @@ CREATE TABLE t1 (
id INT NOT NULL DEFAULT 0,
last_id INT,
PRIMARY KEY (id)
);
)
ENGINE=innodb
;
CREATE TABLE t2 (
id INT NOT NULL AUTO_INCREMENT,
last_id INT,
PRIMARY KEY (id)
);
)
ENGINE=innodb
;
CREATE PROCEDURE p1()
BEGIN
INSERT INTO t2 (last_id) VALUES (LAST_INSERT_ID());
INSERT INTO t1 (last_id) VALUES (LAST_INSERT_ID());
END|
CALL p1();
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY id
;
id last_id
0 1
SELECT * FROM t2;
SELECT * FROM t2
ORDER BY id
;
id last_id
1 0
SELECT * FROM t1;
SELECT * FROM t1
ORDER BY id
;
id last_id
0 1
SELECT * FROM t2;
SELECT * FROM t2
ORDER BY id
;
id last_id
1 0
DROP PROCEDURE p1;
...
...
@@ -364,8 +364,8 @@ DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
i INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
j INT DEFAULT 0
);
CREATE TABLE t2 (i INT);
)
ENGINE=innodb
;
CREATE TABLE t2 (i INT)
ENGINE=innodb
;
CREATE PROCEDURE p1()
BEGIN
INSERT INTO t1 (i) VALUES (NULL);
...
...
@@ -401,11 +401,14 @@ INSERT INTO t1 VALUES (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID(5)),
INSERT INTO t1 VALUES (NULL, 0), (NULL, LAST_INSERT_ID());
UPDATE t1 SET j= -1 WHERE i IS NULL;
INSERT INTO t1 (i) VALUES (NULL);
SET @old_concurrent_insert= @@global.concurrent_insert;
SET @@global.concurrent_insert= 0;
INSERT INTO t1 (i) VALUES (NULL);
SELECT f3();
f3()
0
SELECT * FROM t1;
SET @@global.concurrent_insert= @old_concurrent_insert;
SELECT * FROM t1 ORDER BY i;
i j
1 -1
2 0
...
...
@@ -427,7 +430,7 @@ i j
18 14
19 0
20 0
SELECT * FROM t2;
SELECT * FROM t2
ORDER BY i
;
i
2
3
...
...
@@ -475,9 +478,9 @@ create table t2 (
id int not null auto_increment,
last_id int,
primary key (id)
);
)
engine=innodb
;
truncate table t2;
create table t1 (id tinyint primary key);
create table t1 (id tinyint primary key)
engine=innodb
;
create function insid() returns int
begin
insert into t2 (last_id) values (0);
...
...
@@ -495,17 +498,17 @@ insert into t2 (id) values(5),(6),(7);
delete from t2 where id>=5;
set sql_log_bin=1;
insert into t1 select insid();
select * from t1;
select * from t1
order by id
;
id
0
select * from t2;
select * from t2
order by id
;
id last_id
4 0
8 0
select * from t1;
select * from t1
order by id
;
id
0
select * from t2;
select * from t2
order by id
;
id last_id
4 0
8 0
...
...
@@ -513,7 +516,7 @@ drop table t1;
drop function insid;
truncate table t2;
create table t1 (n int primary key auto_increment not null,
b int, unique(b));
b int, unique(b))
engine=innodb
;
create procedure foo()
begin
insert into t1 values(null,10);
...
...
@@ -522,16 +525,16 @@ insert ignore into t1 values(null,10);
insert into t2 values(null,3);
end|
call foo();
select * from t1;
select * from t1
order by n
;
n b
1 10
select * from t2;
select * from t2
order by id
;
id last_id
1 3
select * from t1;
select * from t1
order by n
;
n b
1 10
select * from t2;
select * from t2
order by id
;
id last_id
1 3
drop table t1, t2;
...
...
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