diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2003-01-28 18:55:52 +0200 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2003-01-28 18:55:52 +0200 |
commit | 7b137f15bd28727a62a6215cf21a92878948760e (patch) | |
tree | d27edf299c75a16858a77c7a707b5af28fc814a7 | |
parent | d2b66206219ba5b4eabbef46588b642443745669 (diff) | |
download | mariadb-git-7b137f15bd28727a62a6215cf21a92878948760e.tar.gz |
A feature of doing automatick result buffering when INSERT is
done from the select containing a table to be inserted to.
-rw-r--r-- | mysql-test/r/insert.result | 13 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 3 | ||||
-rw-r--r-- | mysql-test/t/insert.test | 31 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 3 |
5 files changed, 47 insertions, 4 deletions
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index ebd34dd7668..3be04584749 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -64,3 +64,16 @@ use test_$1; create table t1 (c int); insert into test_$1.t1 set test_$1.t1.c = '1'; drop database test_$1; +use test; +drop table if exists t1,t2,t3; +create table t1(id1 int not null auto_increment primary key, t char(12)); +create table t2(id2 int not null, t char(12)); +create table t3(id3 int not null, t char(12), index(id3)); +select count(*) from t2; +count(*) +500 +insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3; +select count(*) from t2; +count(*) +25500 +drop table if exists t1,t2,t3; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 04bf0575db3..ca3323adb6c 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -576,7 +576,6 @@ x 3 3 INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; -You can't specify target table 't1' for update in FROM clause INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); select * from t1; x @@ -584,6 +583,8 @@ x 2 3 3 +11 +11 0 drop table t1, t2, t3; CREATE TABLE t1 (x int not null, y int, primary key (x)); diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index bfa8aac7a1f..34302cdbc60 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -65,3 +65,34 @@ use test_$1; create table t1 (c int); insert into test_$1.t1 set test_$1.t1.c = '1'; drop database test_$1; +use test; +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings +create table t1(id1 int not null auto_increment primary key, t char(12)); +create table t2(id2 int not null, t char(12)); +create table t3(id3 int not null, t char(12), index(id3)); +disable_query_log; +let $1 = 100; +while ($1) + { + let $2 = 5; + eval insert into t1(t) values ('$1'); + while ($2) + { + eval insert into t2(id2,t) values ($1,'$2'); + let $3 = 10; + while ($3) + { + eval insert into t3(id3,t) values ($1,'$2'); + dec $3; + } + dec $2; + } + dec $1; + } +enable_query_log; +select count(*) from t2; +insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3; +select count(*) from t2; +drop table if exists t1,t2,t3; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1dcbd9a282d..9b7e5f0f290 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -332,7 +332,6 @@ INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; --- error 1093 INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); -- sleep 1 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b82846706a8..d1515025723 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2198,8 +2198,7 @@ mysql_execute_command(THD *thd) if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) { - net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); - return -1; + lex->select_lex.options |= OPTION_BUFFER_RESULT; } /* Skip first table, which is the table we are inserting in */ |