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
7e05d7b4
Commit
7e05d7b4
authored
Oct 07, 2002
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/work-4.1
parents
e2f911d8
31568581
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
4 deletions
+49
-4
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+14
-2
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+17
-2
sql/item_subselect.cc
sql/item_subselect.cc
+18
-0
No files found.
mysql-test/r/subselect.result
View file @
7e05d7b4
select (select 2);
select (select 2);
(select 2)
(select 2)
2
2
drop table if exists t1,t2,t3,t4,t5,attend,clinic;
drop table if exists t1,t2,t3,t4,t5,attend,clinic
,inscrit
;
create table t1 (a int);
create table t1 (a int);
create table t2 (a int, b int);
create table t2 (a int, b int);
create table t3 (a int);
create table t3 (a int);
...
@@ -147,4 +147,16 @@ W 1
...
@@ -147,4 +147,16 @@ W 1
SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
a b
a b
W a
W a
drop table t1,t2,t3,t4,t5,attend,clinic;
drop table if exists inscrit;
CREATE TABLE `inscrit` (
`pseudo` varchar(35) character set latin1 NOT NULL default '',
`email` varchar(60) character set latin1 NOT NULL default '',
PRIMARY KEY (`pseudo`),
UNIQUE KEY `email` (`email`)
) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
INSERT INTO inscrit (pseudo,email) VALUES ('joce','test');
INSERT INTO inscrit (pseudo,email) VALUES ('joce1','test1');
INSERT INTO inscrit (pseudo,email) VALUES ('2joce1','2test1');
SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo LIKE '%joce%');
Subselect returns more than 1 record
drop table if exists inscrit;
mysql-test/t/subselect.test
View file @
7e05d7b4
select
(
select
2
);
select
(
select
2
);
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
attend
,
clinic
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
attend
,
clinic
,
inscrit
;
create
table
t1
(
a
int
);
create
table
t1
(
a
int
);
create
table
t2
(
a
int
,
b
int
);
create
table
t2
(
a
int
,
b
int
);
create
table
t3
(
a
int
);
create
table
t3
(
a
int
);
...
@@ -66,4 +66,19 @@ SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
...
@@ -66,4 +66,19 @@ SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
SELECT
*
FROM
t2
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t2
);
SELECT
*
FROM
t2
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t2
);
SELECT
*
FROM
t3
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t3
);
SELECT
*
FROM
t3
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t3
);
drop
table
t1
,
t2
,
t3
,
t4
,
t5
,
attend
,
clinic
;
drop
table
if
exists
inscrit
;
CREATE
TABLE
`inscrit`
(
`pseudo`
varchar
(
35
)
character
set
latin1
NOT
NULL
default
''
,
`email`
varchar
(
60
)
character
set
latin1
NOT
NULL
default
''
,
PRIMARY
KEY
(
`pseudo`
),
UNIQUE
KEY
`email`
(
`email`
)
)
TYPE
=
MyISAM
CHARSET
=
latin1
ROW_FORMAT
=
DYNAMIC
;
INSERT
INTO
inscrit
(
pseudo
,
email
)
VALUES
(
'joce'
,
'test'
);
INSERT
INTO
inscrit
(
pseudo
,
email
)
VALUES
(
'joce1'
,
'test1'
);
INSERT
INTO
inscrit
(
pseudo
,
email
)
VALUES
(
'2joce1'
,
'2test1'
);
--
error
1240
SELECT
pseudo
FROM
inscrit
WHERE
pseudo
=
(
SELECT
pseudo
FROM
inscrit
WHERE
pseudo
LIKE
'%joce%'
);
drop
table
if
exists
inscrit
;
\ No newline at end of file
sql/item_subselect.cc
View file @
7e05d7b4
...
@@ -119,21 +119,30 @@ Item::Type Item_subselect::type() const
...
@@ -119,21 +119,30 @@ Item::Type Item_subselect::type() const
double
Item_singleval_subselect
::
val
()
double
Item_singleval_subselect
::
val
()
{
{
if
(
engine
->
exec
())
if
(
engine
->
exec
())
{
assign_null
();
return
0
;
return
0
;
}
return
real_value
;
return
real_value
;
}
}
longlong
Item_singleval_subselect
::
val_int
()
longlong
Item_singleval_subselect
::
val_int
()
{
{
if
(
engine
->
exec
())
if
(
engine
->
exec
())
{
assign_null
();
return
0
;
return
0
;
}
return
int_value
;
return
int_value
;
}
}
String
*
Item_singleval_subselect
::
val_str
(
String
*
str
)
String
*
Item_singleval_subselect
::
val_str
(
String
*
str
)
{
{
if
(
engine
->
exec
()
||
null_value
)
if
(
engine
->
exec
()
||
null_value
)
{
assign_null
();
return
0
;
return
0
;
}
return
&
str_value
;
return
&
str_value
;
}
}
...
@@ -157,21 +166,30 @@ void Item_exists_subselect::fix_length_and_dec()
...
@@ -157,21 +166,30 @@ void Item_exists_subselect::fix_length_and_dec()
double
Item_exists_subselect
::
val
()
double
Item_exists_subselect
::
val
()
{
{
if
(
engine
->
exec
())
if
(
engine
->
exec
())
{
assign_null
();
return
0
;
return
0
;
}
return
(
double
)
value
;
return
(
double
)
value
;
}
}
longlong
Item_exists_subselect
::
val_int
()
longlong
Item_exists_subselect
::
val_int
()
{
{
if
(
engine
->
exec
())
if
(
engine
->
exec
())
{
assign_null
();
return
0
;
return
0
;
}
return
value
;
return
value
;
}
}
String
*
Item_exists_subselect
::
val_str
(
String
*
str
)
String
*
Item_exists_subselect
::
val_str
(
String
*
str
)
{
{
if
(
engine
->
exec
())
if
(
engine
->
exec
())
{
assign_null
();
return
0
;
return
0
;
}
str
->
set
(
value
);
str
->
set
(
value
);
return
str
;
return
str
;
}
}
...
...
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