mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
fixed subqueries name resolution with INSERT/REPLACE (found during bug 446 investigation)
mysql-test/r/subselect.result: subselect test changed mysql-test/t/subselect.test: INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); sql/item.cc: avoid resolving of INSER/REPLACE tables field in subqueries sql/sql_lex.cc: Primary (top) simple INSERT/REPLACE st_select_lex indicator sql/sql_lex.h: Primary (top) simple INSERT/REPLACE st_select_lex indicator sql/sql_yacc.yy: Primary (top) simple INSERT/REPLACE st_select_lex indicator
This commit is contained in:
@ -580,12 +580,12 @@ a b
|
||||
drop table t11, t12, t2;
|
||||
CREATE TABLE t1 (x int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
create table t3 (b int);
|
||||
insert into t2 values (1);
|
||||
insert into t3 values (1),(2);
|
||||
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t3));
|
||||
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
|
||||
Subselect returns more than 1 record
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
|
||||
select * from t1;
|
||||
@ -607,13 +607,15 @@ x
|
||||
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));
|
||||
Unknown column 'x' in 'field list'
|
||||
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
|
||||
select * from t1;
|
||||
x
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
0
|
||||
2
|
||||
drop table t1, t2, t3;
|
||||
CREATE TABLE t1 (x int not null, y int, primary key (x));
|
||||
create table t2 (a int);
|
||||
|
@ -334,13 +334,13 @@ drop table t11, t12, t2;
|
||||
#insert with subselects
|
||||
CREATE TABLE t1 (x int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
create table t3 (b int);
|
||||
insert into t2 values (1);
|
||||
insert into t3 values (1),(2);
|
||||
-- error 1093
|
||||
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
|
||||
-- error 1240
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t3));
|
||||
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
|
||||
select * from t1;
|
||||
insert into t2 values (1);
|
||||
@ -351,9 +351,15 @@ 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;
|
||||
-- error 1054
|
||||
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
|
||||
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
|
||||
-- sleep 1
|
||||
select * from t1;
|
||||
#
|
||||
#TODO: should be uncommented after bug 380 fix pushed
|
||||
#INSERT INTO t1 (x) SELECT (SELECT SUM(a)+b FROM t2) from t3;
|
||||
#select * from t1;
|
||||
drop table t1, t2, t3;
|
||||
|
||||
#replace with subselects
|
||||
|
Reference in New Issue
Block a user