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
aa99bd61
Commit
aa99bd61
authored
Aug 09, 2005
by
acurtis@xiphis.org
Browse files
Options
Browse Files
Download
Plain Diff
Merge acurtis@bk-internal.mysql.com:/home/bk/mysql-4.1
into xiphis.org:/usr/home/antony/work2/p2-bug10109.3
parents
a856f155
015447b2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
15 deletions
+58
-15
mysql-test/r/insert_update.result
mysql-test/r/insert_update.result
+6
-0
mysql-test/t/insert_update.test
mysql-test/t/insert_update.test
+14
-0
sql/sql_class.h
sql/sql_class.h
+11
-3
sql/sql_insert.cc
sql/sql_insert.cc
+25
-11
sql/sql_parse.cc
sql/sql_parse.cc
+2
-1
No files found.
mysql-test/r/insert_update.result
View file @
aa99bd61
...
...
@@ -191,3 +191,9 @@ ERROR 23000: Column 'a' in field list is ambiguous
insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
ERROR 23000: Column 't1.a' in field list is ambiguous
drop table t1;
CREATE TABLE t1 (
a BIGINT(20) NOT NULL DEFAULT 0,
PRIMARY KEY (a)
) ENGINE=MyISAM;
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
DROP TABLE t1;
mysql-test/t/insert_update.test
View file @
aa99bd61
...
...
@@ -101,4 +101,18 @@ insert into t1 select a from t1 on duplicate key update a=a+1 ;
insert
ignore
into
t1
select
a
from
t1
on
duplicate
key
update
a
=
t1
.
a
+
1
;
drop
table
t1
;
#
# Bug#10109 - INSERT .. SELECT ... ON DUPLICATE KEY UPDATE fails
# Bogus "Duplicate columns" error message
#
CREATE
TABLE
t1
(
a
BIGINT
(
20
)
NOT
NULL
DEFAULT
0
,
PRIMARY
KEY
(
a
)
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
(
a
)
SELECT
0
ON
DUPLICATE
KEY
UPDATE
a
=
a
+
VALUES
(
a
)
;
DROP
TABLE
t1
;
# End of 4.1 tests
sql/sql_class.h
View file @
aa99bd61
...
...
@@ -1236,19 +1236,27 @@ class select_insert :public select_result_interceptor {
List
<
Item
>
*
fields
;
ulonglong
last_insert_id
;
COPY_INFO
info
;
TABLE_LIST
*
insert_table_list
;
TABLE_LIST
*
dup_table_list
;
select_insert
(
TABLE
*
table_par
,
List
<
Item
>
*
fields_par
,
enum_duplicates
duplic
,
bool
ignore
)
:
table
(
table_par
),
fields
(
fields_par
),
last_insert_id
(
0
)
:
table
(
table_par
),
fields
(
fields_par
),
last_insert_id
(
0
),
insert_table_list
(
0
),
dup_table_list
(
0
)
{
bzero
((
char
*
)
&
info
,
sizeof
(
info
));
info
.
ignore
=
ignore
;
info
.
handle_duplicates
=
duplic
;
}
select_insert
(
TABLE
*
table_par
,
List
<
Item
>
*
fields_par
,
select_insert
(
TABLE
*
table_par
,
TABLE_LIST
*
insert_table_list_par
,
TABLE_LIST
*
dup_table_list_par
,
List
<
Item
>
*
fields_par
,
List
<
Item
>
*
update_fields
,
List
<
Item
>
*
update_values
,
enum_duplicates
duplic
,
bool
ignore
)
:
table
(
table_par
),
fields
(
fields_par
),
last_insert_id
(
0
)
:
table
(
table_par
),
fields
(
fields_par
),
last_insert_id
(
0
),
insert_table_list
(
insert_table_list_par
),
dup_table_list
(
dup_table_list_par
)
{
bzero
((
char
*
)
&
info
,
sizeof
(
info
));
info
.
ignore
=
ignore
;
...
...
sql/sql_insert.cc
View file @
aa99bd61
...
...
@@ -543,18 +543,22 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if
(
!
table
->
insert_values
)
DBUG_RETURN
(
-
1
);
}
if
((
values
&&
check_insert_fields
(
thd
,
table
,
fields
,
*
values
))
||
setup_tables
(
insert_table_list
)
||
(
values
&&
setup_fields
(
thd
,
0
,
insert_table_list
,
*
values
,
0
,
0
,
0
))
||
(
duplic
==
DUP_UPDATE
&&
(
check_update_fields
(
thd
,
table
,
insert_table_list
,
update_fields
)
||
setup_fields
(
thd
,
0
,
dup_table_list
,
update_values
,
1
,
0
,
0
))))
if
(
setup_tables
(
insert_table_list
))
DBUG_RETURN
(
-
1
);
if
(
values
&&
find_real_table_in_list
(
table_list
->
next
,
table_list
->
db
,
table_list
->
real_name
))
if
(
values
)
{
my_error
(
ER_UPDATE_TABLE_USED
,
MYF
(
0
),
table_list
->
real_name
);
DBUG_RETURN
(
-
1
);
if
(
check_insert_fields
(
thd
,
table
,
fields
,
*
values
)
||
setup_fields
(
thd
,
0
,
insert_table_list
,
*
values
,
0
,
0
,
0
)
||
(
duplic
==
DUP_UPDATE
&&
(
check_update_fields
(
thd
,
table
,
insert_table_list
,
update_fields
)
||
setup_fields
(
thd
,
0
,
dup_table_list
,
update_values
,
1
,
0
,
0
))))
DBUG_RETURN
(
-
1
);
if
(
find_real_table_in_list
(
table_list
->
next
,
table_list
->
db
,
table_list
->
real_name
))
{
my_error
(
ER_UPDATE_TABLE_USED
,
MYF
(
0
),
table_list
->
real_name
);
DBUG_RETURN
(
-
1
);
}
}
if
(
duplic
==
DUP_UPDATE
||
duplic
==
DUP_REPLACE
)
table
->
file
->
extra
(
HA_EXTRA_RETRIEVE_PRIMARY_KEY
);
...
...
@@ -1601,6 +1605,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
int
res
;
LEX
*
lex
=
thd
->
lex
;
SELECT_LEX
*
lex_current_select_save
=
lex
->
current_select
;
bool
lex_select_no_error
=
lex
->
select_lex
.
no_error
;
DBUG_ENTER
(
"select_insert::prepare"
);
unit
=
u
;
...
...
@@ -1608,10 +1613,19 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
Since table in which we are going to insert is added to the first
select, LEX::current_select should point to the first select while
we are fixing fields from insert list.
Since these checks may cause the query to fail, we don't want the
error messages to be converted into warnings, must force no_error=0
*/
lex
->
current_select
=
&
lex
->
select_lex
;
res
=
check_insert_fields
(
thd
,
table
,
*
fields
,
values
);
lex
->
select_lex
.
no_error
=
0
;
res
=
check_insert_fields
(
thd
,
table
,
*
fields
,
values
)
||
setup_fields
(
thd
,
0
,
insert_table_list
,
values
,
0
,
0
,
0
)
||
(
info
.
handle_duplicates
==
DUP_UPDATE
&&
(
check_update_fields
(
thd
,
table
,
insert_table_list
,
*
info
.
update_fields
)
||
setup_fields
(
thd
,
0
,
dup_table_list
,
*
info
.
update_values
,
1
,
0
,
0
)));
lex
->
current_select
=
lex_current_select_save
;
lex
->
select_lex
.
no_error
=
lex_select_no_error
;
if
(
res
)
DBUG_RETURN
(
1
);
...
...
sql/sql_parse.cc
View file @
aa99bd61
...
...
@@ -2877,7 +2877,8 @@ mysql_execute_command(THD *thd)
lex
->
field_list
,
0
,
lex
->
update_list
,
lex
->
value_list
,
lex
->
duplicates
))
&&
(
result
=
new
select_insert
(
insert_table
,
&
lex
->
field_list
,
(
result
=
new
select_insert
(
insert_table
,
first_local_table
,
&
dup_tables
,
&
lex
->
field_list
,
&
lex
->
update_list
,
&
lex
->
value_list
,
lex
->
duplicates
,
lex
->
ignore
)))
{
...
...
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