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
473d7d59
Commit
473d7d59
authored
Jun 22, 2005
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Fix for bug #10886 merge
parents
1b59ffb8
b625e434
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
mysql-test/r/insert_select.result
mysql-test/r/insert_select.result
+9
-0
mysql-test/t/insert_select.test
mysql-test/t/insert_select.test
+9
-0
sql/sql_insert.cc
sql/sql_insert.cc
+4
-1
No files found.
mysql-test/r/insert_select.result
View file @
473d7d59
...
@@ -625,3 +625,12 @@ select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
...
@@ -625,3 +625,12 @@ select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
ID NO SEQ
ID NO SEQ
1 1 1
1 1 1
drop table t1;
drop table t1;
create table t1 (f1 int);
create table t2 (ff1 int unique, ff2 int default 1);
insert into t1 values (1),(1),(2);
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
select * from t2;
ff1 ff2
1 2
2 1
drop table t1, t2;
mysql-test/t/insert_select.test
View file @
473d7d59
...
@@ -164,3 +164,12 @@ INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1
...
@@ -164,3 +164,12 @@ INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1
select
SQL_BUFFER_RESULT
*
from
t1
WHERE
(
SEQ
=
1
);
select
SQL_BUFFER_RESULT
*
from
t1
WHERE
(
SEQ
=
1
);
drop
table
t1
;
drop
table
t1
;
#
# Bug#10886 - Have to restore default values after update ON DUPLICATE KEY
#
create
table
t1
(
f1
int
);
create
table
t2
(
ff1
int
unique
,
ff2
int
default
1
);
insert
into
t1
values
(
1
),(
1
),(
2
);
insert
into
t2
(
ff1
)
select
f1
from
t1
on
duplicate
key
update
ff2
=
ff2
+
1
;
select
*
from
t2
;
drop
table
t1
,
t2
;
sql/sql_insert.cc
View file @
473d7d59
...
@@ -2119,9 +2119,12 @@ bool select_insert::send_data(List<Item> &values)
...
@@ -2119,9 +2119,12 @@ bool select_insert::send_data(List<Item> &values)
}
}
if
(
!
(
error
=
write_record
(
thd
,
table
,
&
info
)))
if
(
!
(
error
=
write_record
(
thd
,
table
,
&
info
)))
{
{
if
(
table
->
triggers
)
if
(
table
->
triggers
||
info
.
handle_duplicates
==
DUP_UPDATE
)
{
{
/*
/*
Restore fields of the record since it is possible that they were
changed by ON DUPLICATE KEY UPDATE clause.
If triggers exist then whey can modify some fields which were not
If triggers exist then whey can modify some fields which were not
originally touched by INSERT ... SELECT, so we have to restore
originally touched by INSERT ... SELECT, so we have to restore
their original values for the next row.
their original values for the next row.
...
...
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