Commit 11f34156 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Don't use IGNORE by default in INSERT ... SELECT

parent dd43f32d
...@@ -9686,6 +9686,10 @@ version 4.0; ...@@ -9686,6 +9686,10 @@ version 4.0;
@itemize @bullet @itemize @bullet
@item @item
@code{INSERT INTO ... SELECT} had in 3.23 always @code{IGNORE} enabled.
In 4.0.1 MySQL will stop (and possible rollback) in case of an error if you
don't specify @code{IGNORE}.
@item
@file{safe_mysqld} is renamed to @file{mysqld_safe}. @file{safe_mysqld} is renamed to @file{mysqld_safe}.
@item @item
The old C API functions @code{mysql_drop_db}, @code{mysql_create_db} and The old C API functions @code{mysql_drop_db}, @code{mysql_create_db} and
...@@ -48867,6 +48871,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -48867,6 +48871,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Changed @code{INSERT INTO .. SELECT} to by default stop on errors.
@item
Ignore @code{DATA DIRECTORY} and @code{INDEX DIRECTORY} directives on windows. Ignore @code{DATA DIRECTORY} and @code{INDEX DIRECTORY} directives on windows.
@item @item
Added boolean fulltext search code. It should be considered early alpha. Added boolean fulltext search code. It should be considered early alpha.
...@@ -4,6 +4,8 @@ insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7, ...@@ -4,6 +4,8 @@ insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
insert into t2 (payoutID) SELECT payoutID+10 FROM t1; insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
Duplicate entry '16' for key 1
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
select * from t2; select * from t2;
payoutID payoutID
1 1
......
...@@ -7,7 +7,9 @@ create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLI ...@@ -7,7 +7,9 @@ create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLI
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
--error 1062
insert into t2 (payoutID) SELECT payoutID+10 FROM t1; insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
select * from t2; select * from t2;
drop table t1,t2; drop table t1,t2;
# #
......
...@@ -1626,8 +1626,7 @@ mysql_execute_command(void) ...@@ -1626,8 +1626,7 @@ mysql_execute_command(void)
if (!(res=open_and_lock_tables(thd, tables))) if (!(res=open_and_lock_tables(thd, tables)))
{ {
if ((result=new select_insert(tables->table,&lex->field_list, if ((result=new select_insert(tables->table,&lex->field_list,
lex->sql_command == SQLCOM_REPLACE_SELECT ? lex->duplicates)))
DUP_REPLACE : DUP_IGNORE)))
res=handle_select(thd,lex,result); res=handle_select(thd,lex,result);
} }
else else
......
...@@ -2188,7 +2188,13 @@ insert: ...@@ -2188,7 +2188,13 @@ insert:
INSERT { Lex->sql_command = SQLCOM_INSERT; } insert_lock_option opt_ignore insert2 insert_field_spec INSERT { Lex->sql_command = SQLCOM_INSERT; } insert_lock_option opt_ignore insert2 insert_field_spec
replace: replace:
REPLACE { Lex->sql_command = SQLCOM_REPLACE; } replace_lock_option insert2 insert_field_spec REPLACE
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_REPLACE;
lex->duplicates= DUP_REPLACE;
}
replace_lock_option insert2 insert_field_spec
insert_lock_option: insert_lock_option:
/* empty */ { Lex->lock_option= TL_WRITE_CONCURRENT_INSERT; } /* empty */ { Lex->lock_option= TL_WRITE_CONCURRENT_INSERT; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment