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
ba26a1aa
Commit
ba26a1aa
authored
Oct 06, 2003
by
bell@laptop.sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error messages
fix derived inside subqueries
parent
179acaa3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
17 deletions
+18
-17
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+14
-14
mysql-test/t/derived.test
mysql-test/t/derived.test
+2
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-1
No files found.
mysql-test/r/subselect.result
View file @
ba26a1aa
...
@@ -295,7 +295,7 @@ Warnings:
...
@@ -295,7 +295,7 @@ Warnings:
Note 1275 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1
Note 1275 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1
Note 1275 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1
Note 1275 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
create table t7( uq int primary key, name char(25));
create table t7( uq int primary key, name char(25));
insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
...
@@ -354,7 +354,7 @@ SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
...
@@ -354,7 +354,7 @@ SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
pseudo
joce
joce
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
CREATE TABLE `t1` (
CREATE TABLE `t1` (
`topic` mediumint(8) unsigned NOT NULL default '0',
`topic` mediumint(8) unsigned NOT NULL default '0',
...
@@ -384,7 +384,7 @@ SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
...
@@ -384,7 +384,7 @@ SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
1
1
1
1
SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL topic 3 NULL 2 Using index
1 PRIMARY t1 index NULL topic 3 NULL 2 Using index
...
@@ -471,9 +471,9 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`)
...
@@ -471,9 +471,9 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`)
) TYPE=MyISAM ROW_FORMAT=FIXED;
) TYPE=MyISAM ROW_FORMAT=FIXED;
INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
drop table t1;
drop table t1;
create table t1 (a int);
create table t1 (a int);
insert into t1 values (1),(2),(3);
insert into t1 values (1),(2),(3);
...
@@ -486,7 +486,7 @@ drop table t1;
...
@@ -486,7 +486,7 @@ drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES ();
INSERT INTO t1 VALUES ();
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
drop table t1;
drop table t1;
CREATE TABLE `t1` (
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL default '0',
`numeropost` mediumint(8) unsigned NOT NULL default '0',
...
@@ -504,7 +504,7 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT
...
@@ -504,7 +504,7 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT
numreponse (SELECT numeropost FROM t1 HAVING numreponse=1)
numreponse (SELECT numeropost FROM t1 HAVING numreponse=1)
INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
...
@@ -531,7 +531,7 @@ a b
...
@@ -531,7 +531,7 @@ a b
update t1 set b= (select b from t1);
update t1 set b= (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
ERROR HY000: You can't specify target table 't1' for update in FROM clause
update t1 set b= (select b from t2);
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
update t1 set b= (select b from t2 where t1.a = t2.a);
update t1 set b= (select b from t2 where t1.a = t2.a);
select * from t1;
select * from t1;
a b
a b
...
@@ -554,7 +554,7 @@ a b
...
@@ -554,7 +554,7 @@ a b
delete from t1 where b = (select b from t1);
delete from t1 where b = (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete from t1 where b = (select b from t2);
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
delete from t1 where b = (select b from t2 where t1.a = t2.a);
delete from t1 where b = (select b from t2 where t1.a = t2.a);
select * from t1;
select * from t1;
a b
a b
...
@@ -580,7 +580,7 @@ a b
...
@@ -580,7 +580,7 @@ a b
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
ERROR HY000: You can't specify target table 't12' for update in FROM clause
ERROR HY000: You can't specify target table 't12' for update in FROM clause
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
select * from t11;
select * from t11;
a b
a b
...
@@ -599,7 +599,7 @@ insert into t3 values (1),(2);
...
@@ -599,7 +599,7 @@ insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
ERROR HY000: You can't specify target table 't1' for update in FROM clause
ERROR HY000: You can't specify target table 't1' for update in FROM clause
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1;
select * from t1;
x
x
...
@@ -641,7 +641,7 @@ x y
...
@@ -641,7 +641,7 @@ x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
ERROR HY000: You can't specify target table 't1' for update in FROM clause
ERROR HY000: You can't specify target table 't1' for update in FROM clause
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
select * from t1;
select * from t1;
x y
x y
...
@@ -712,7 +712,7 @@ id
...
@@ -712,7 +712,7 @@ id
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1);
INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1);
UPDATE t2 SET id=(SELECT * FROM t1);
ERROR 21000: Subquery returns more than 1 r
ecord
ERROR 21000: Subquery returns more than 1 r
ow
drop table t2, t1;
drop table t2, t1;
create table t1 (a int);
create table t1 (a int);
insert into t1 values (1),(2),(3);
insert into t1 values (1),(2),(3);
...
@@ -1186,7 +1186,7 @@ insert into t1 values (1,0), (2,0), (3,0);
...
@@ -1186,7 +1186,7 @@ insert into t1 values (1,0), (2,0), (3,0);
insert into t2 values (1,1), (2,1), (3,1), (2,2);
insert into t2 values (1,1), (2,1), (3,1), (2,2);
update ignore t1 set b=(select b from t2 where t1.a=t2.a);
update ignore t1 set b=(select b from t2 where t1.a=t2.a);
Warnings:
Warnings:
Error 1241 Subquery returns more than 1 r
ecord
Error 1241 Subquery returns more than 1 r
ow
select * from t1;
select * from t1;
a b
a b
1 1
1 1
...
...
mysql-test/t/derived.test
View file @
ba26a1aa
...
@@ -117,8 +117,8 @@ create table t1 (a int);
...
@@ -117,8 +117,8 @@ create table t1 (a int);
insert
into
t1
values
(
1
),(
2
),(
3
);
insert
into
t1
values
(
1
),(
2
),(
3
);
--
error
1149
--
error
1149
update
(
select
*
from
t1
)
as
t1
set
a
=
5
;
update
(
select
*
from
t1
)
as
t1
set
a
=
5
;
--
error
1
149
--
error
1
064
delete
from
(
select
*
from
t1
);
delete
from
(
select
*
from
t1
);
--
error
1
149
--
error
1
064
insert
into
(
select
*
from
t1
)
values
(
5
);
insert
into
(
select
*
from
t1
)
values
(
5
);
drop
table
t1
;
drop
table
t1
;
sql/sql_yacc.yy
View file @
ba26a1aa
...
@@ -3060,7 +3060,8 @@ join_table:
...
@@ -3060,7 +3060,8 @@ join_table:
| '(' SELECT_SYM select_derived ')' opt_table_alias
| '(' SELECT_SYM select_derived ')' opt_table_alias
{
{
LEX *lex=Lex;
LEX *lex=Lex;
if (lex->sql_command == SQLCOM_UPDATE)
if (lex->sql_command == SQLCOM_UPDATE &&
&lex->select_lex == lex->current_select->outer_select())
{
{
send_error(lex->thd, ER_SYNTAX_ERROR);
send_error(lex->thd, ER_SYNTAX_ERROR);
YYABORT;
YYABORT;
...
...
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