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
e8a1b21d
Commit
e8a1b21d
authored
Sep 20, 2006
by
marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge changes from MySQL AB to the innodb_mysql test.
parent
3916e2ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
11 deletions
+48
-11
mysql-test/innodb_mysql.result
mysql-test/innodb_mysql.result
+30
-8
mysql-test/innodb_mysql.test
mysql-test/innodb_mysql.test
+18
-3
No files found.
mysql-test/innodb_mysql.result
View file @
e8a1b21d
...
@@ -124,7 +124,7 @@ min(7)
...
@@ -124,7 +124,7 @@ min(7)
NULL
NULL
select min(7) from DUAL;
select min(7) from DUAL;
min(7)
min(7)
NULL
7
explain select min(7) from t2m join t1m;
explain select min(7) from t2m join t1m;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
...
@@ -139,7 +139,7 @@ max(7)
...
@@ -139,7 +139,7 @@ max(7)
NULL
NULL
select max(7) from DUAL;
select max(7) from DUAL;
max(7)
max(7)
NULL
7
explain select max(7) from t2m join t1m;
explain select max(7) from t2m join t1m;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
...
@@ -178,7 +178,7 @@ min(7)
...
@@ -178,7 +178,7 @@ min(7)
NULL
NULL
select min(7) from DUAL;
select min(7) from DUAL;
min(7)
min(7)
NULL
7
explain select min(7) from t2i join t1i;
explain select min(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
...
@@ -194,7 +194,7 @@ max(7)
...
@@ -194,7 +194,7 @@ max(7)
NULL
NULL
select max(7) from DUAL;
select max(7) from DUAL;
max(7)
max(7)
NULL
7
explain select max(7) from t2i join t1i;
explain select max(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
...
@@ -432,22 +432,44 @@ ifnull( c,
...
@@ -432,22 +432,44 @@ ifnull( c,
0 ) + 1;
0 ) + 1;
select last_insert_id();
select last_insert_id();
last_insert_id()
last_insert_id()
1
2
select last_insert_id(0);
last_insert_id(0)
0
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
0
select * from t2;
select * from t2;
k a c
k a c
1 6
1
1 6
2
2 7 NULL
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
select last_insert_id();
last_insert_id()
last_insert_id()
1
0
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
select last_insert_id();
last_insert_id()
last_insert_id()
11
11
select * from t2;
select * from t2;
k a c
k a c
1 6 1
1 6 2
2 7 NULL
10 8 1
11 15 1
12 20 1
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1, k=last_insert_id(k);
select last_insert_id();
last_insert_id()
1
select * from t2;
k a c
1 6 3
2 7 NULL
2 7 NULL
10 8 1
10 8 1
11 15 1
11 15 1
...
...
mysql-test/innodb_mysql.test
View file @
e8a1b21d
...
@@ -369,8 +369,8 @@ insert into t1 values('aaa');
...
@@ -369,8 +369,8 @@ insert into t1 values('aaa');
drop
table
t1
;
drop
table
t1
;
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
# UPDATE":
now LAST_INSERT_ID() will return the id of the updated
# UPDATE":
if the row is updated, it's like a regular UPDATE:
#
row
.
#
LAST_INSERT_ID() is not affected
.
CREATE
TABLE
`t2`
(
CREATE
TABLE
`t2`
(
`k`
int
(
11
)
NOT
NULL
auto_increment
,
`k`
int
(
11
)
NOT
NULL
auto_increment
,
`a`
int
(
11
)
default
NULL
,
`a`
int
(
11
)
default
NULL
,
...
@@ -390,6 +390,12 @@ insert into t2 ( a ) values ( 6 ) on duplicate key update c =
...
@@ -390,6 +390,12 @@ insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull
(
c
,
ifnull
(
c
,
0
)
+
1
;
0
)
+
1
;
select
last_insert_id
();
select
last_insert_id
();
# test again when last_insert_id() is 0 initially
select
last_insert_id
(
0
);
insert
into
t2
(
a
)
values
(
6
)
on
duplicate
key
update
c
=
ifnull
(
c
,
0
)
+
1
;
select
last_insert_id
();
select
*
from
t2
;
select
*
from
t2
;
# Test of LAST_INSERT_ID() when autogenerated will fail:
# Test of LAST_INSERT_ID() when autogenerated will fail:
...
@@ -402,5 +408,14 @@ insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
...
@@ -402,5 +408,14 @@ insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select
last_insert_id
();
select
last_insert_id
();
select
*
from
t2
;
select
*
from
t2
;
drop
table
t2
;
# Test of the workaround which enables people to know the id of the
# updated row in INSERT ON DUPLICATE KEY UPDATE, by using
# LAST_INSERT_ID(autoinc_col) in the UPDATE clause.
insert
into
t2
(
a
)
values
(
6
)
on
duplicate
key
update
c
=
ifnull
(
c
,
0
)
+
1
,
k
=
last_insert_id
(
k
);
select
last_insert_id
();
select
*
from
t2
;
drop
table
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