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
d98487ac
Commit
d98487ac
authored
Nov 02, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
f66d0744
fa5520fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
10 deletions
+48
-10
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+10
-1
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+16
-2
sql/item.cc
sql/item.cc
+22
-7
No files found.
mysql-test/r/subselect.result
View file @
d98487ac
...
@@ -1349,7 +1349,7 @@ create table t2 (s1 int);
...
@@ -1349,7 +1349,7 @@ create table t2 (s1 int);
insert into t1 values (1);
insert into t1 values (1);
insert into t2 values (1);
insert into t2 values (1);
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
ERROR 42S
02: Unknown table 'x' in field list
ERROR 42S
22: Unknown column 'x.s1' in 'field list'
DROP TABLE t1, t2;
DROP TABLE t1, t2;
create table t1 (a int) type=innodb;
create table t1 (a int) type=innodb;
create table t2 (a int) type=innodb;
create table t2 (a int) type=innodb;
...
@@ -1514,3 +1514,12 @@ phone code
...
@@ -1514,3 +1514,12 @@ phone code
89356874041 NULL
89356874041 NULL
95895001874 NULL
95895001874 NULL
drop table t1, t2;
drop table t1, t2;
create table t1 (s1 int);
create table t2 (s1 int);
select * from t1 where (select count(*) from t2 where t1.s2) = 1;
ERROR 42S22: Unknown column 't1.s2' in 'where clause'
select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
ERROR 42S22: Unknown column 't1.s2' in 'group statement'
select count(*) from t2 group by t1.s2;
ERROR 42S02: Unknown table 't1' in group statement
drop table t1, t2;
mysql-test/t/subselect.test
View file @
d98487ac
...
@@ -693,7 +693,7 @@ INSERT INTO t1 VALUES (1);
...
@@ -693,7 +693,7 @@ INSERT INTO t1 VALUES (1);
UPDATE
t1
SET
i
=
i
+
(
SELECT
MAX
(
i
)
FROM
(
SELECT
1
)
t
)
WHERE
i
=
(
SELECT
MAX
(
i
));
UPDATE
t1
SET
i
=
i
+
(
SELECT
MAX
(
i
)
FROM
(
SELECT
1
)
t
)
WHERE
i
=
(
SELECT
MAX
(
i
));
--
error
1111
--
error
1111
UPDATE
t1
SET
i
=
i
+
1
WHERE
i
=
(
SELECT
MAX
(
i
));
UPDATE
t1
SET
i
=
i
+
1
WHERE
i
=
(
SELECT
MAX
(
i
));
--
error
1
109
--
error
1
054
UPDATE
t1
SET
t
.
i
=
i
+
(
SELECT
MAX
(
i
)
FROM
(
SELECT
1
)
t
);
UPDATE
t1
SET
t
.
i
=
i
+
(
SELECT
MAX
(
i
)
FROM
(
SELECT
1
)
t
);
drop
table
t1
;
drop
table
t1
;
...
@@ -887,7 +887,7 @@ create table t1 (s1 int);
...
@@ -887,7 +887,7 @@ create table t1 (s1 int);
create
table
t2
(
s1
int
);
create
table
t2
(
s1
int
);
insert
into
t1
values
(
1
);
insert
into
t1
values
(
1
);
insert
into
t2
values
(
1
);
insert
into
t2
values
(
1
);
--
error
1
109
--
error
1
054
update
t1
set
s1
=
s1
+
1
where
1
=
(
select
x
.
s1
as
A
from
t2
WHERE
t2
.
s1
>
t1
.
s1
order
by
A
);
update
t1
set
s1
=
s1
+
1
where
1
=
(
select
x
.
s1
as
A
from
t2
WHERE
t2
.
s1
>
t1
.
s1
order
by
A
);
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
...
@@ -1030,3 +1030,17 @@ CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=M
...
@@ -1030,3 +1030,17 @@ CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=M
INSERT
INTO
t2
VALUES
(
'1'
),(
'1226'
),(
'1245'
),(
'1862'
),(
'18623'
),(
'1874'
),(
'1967'
),(
'6'
);
INSERT
INTO
t2
VALUES
(
'1'
),(
'1226'
),(
'1245'
),(
'1862'
),(
'18623'
),(
'1874'
),(
'1967'
),(
'6'
);
select
c
.
number
as
phone
,(
select
p
.
code
from
t2
p
where
c
.
number
like
concat
(
p
.
code
,
'%'
)
order
by
length
(
p
.
code
)
desc
limit
1
)
as
code
from
t1
c
;
select
c
.
number
as
phone
,(
select
p
.
code
from
t2
p
where
c
.
number
like
concat
(
p
.
code
,
'%'
)
order
by
length
(
p
.
code
)
desc
limit
1
)
as
code
from
t1
c
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# unresolved field error
#
create
table
t1
(
s1
int
);
create
table
t2
(
s1
int
);
--
error
1054
select
*
from
t1
where
(
select
count
(
*
)
from
t2
where
t1
.
s2
)
=
1
;
--
error
1054
select
*
from
t1
where
(
select
count
(
*
)
from
t2
group
by
t1
.
s2
)
=
1
;
--
error
1109
select
count
(
*
)
from
t2
group
by
t1
.
s2
;
drop
table
t1
,
t2
;
sql/item.cc
View file @
d98487ac
...
@@ -796,6 +796,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -796,6 +796,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if
(
!
field
)
// If field is not checked
if
(
!
field
)
// If field is not checked
{
{
TABLE_LIST
*
where
=
0
;
TABLE_LIST
*
where
=
0
;
bool
upward_lookup
=
0
;
Field
*
tmp
=
(
Field
*
)
not_found_field
;
Field
*
tmp
=
(
Field
*
)
not_found_field
;
if
((
tmp
=
find_field_in_tables
(
thd
,
this
,
tables
,
&
where
,
0
))
==
if
((
tmp
=
find_field_in_tables
(
thd
,
this
,
tables
,
&
where
,
0
))
==
not_found_field
)
not_found_field
)
...
@@ -825,6 +826,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -825,6 +826,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
sl
;
sl
;
sl
=
(
prev_unit
=
sl
->
master_unit
())
->
outer_select
())
sl
=
(
prev_unit
=
sl
->
master_unit
())
->
outer_select
())
{
{
upward_lookup
=
1
;
table_list
=
(
last
=
sl
)
->
get_table_list
();
table_list
=
(
last
=
sl
)
->
get_table_list
();
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
INSERT_MODE
&&
table_list
)
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
INSERT_MODE
&&
table_list
)
{
{
...
@@ -869,8 +871,14 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -869,8 +871,14 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return
1
;
return
1
;
else
if
(
tmp
==
not_found_field
&&
refer
==
(
Item
**
)
not_found_item
)
else
if
(
tmp
==
not_found_field
&&
refer
==
(
Item
**
)
not_found_item
)
{
{
// call to return error code
if
(
upward_lookup
)
find_field_in_tables
(
thd
,
this
,
tables
,
&
where
,
1
);
// We can't say exactly what absend table or field
my_printf_error
(
ER_BAD_FIELD_ERROR
,
ER
(
ER_BAD_FIELD_ERROR
),
MYF
(
0
),
full_name
(),
thd
->
where
);
else
// Call to report error
find_field_in_tables
(
thd
,
this
,
tables
,
&
where
,
1
);
return
-
1
;
return
-
1
;
}
}
else
if
(
refer
!=
(
Item
**
)
not_found_item
)
else
if
(
refer
!=
(
Item
**
)
not_found_item
)
...
@@ -1381,6 +1389,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1381,6 +1389,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
if
(
!
ref
)
if
(
!
ref
)
{
{
TABLE_LIST
*
where
=
0
,
*
table_list
;
TABLE_LIST
*
where
=
0
,
*
table_list
;
bool
upward_lookup
=
0
;
SELECT_LEX_UNIT
*
prev_unit
=
thd
->
lex
.
current_select
->
master_unit
();
SELECT_LEX_UNIT
*
prev_unit
=
thd
->
lex
.
current_select
->
master_unit
();
SELECT_LEX
*
sl
=
prev_unit
->
outer_select
();
SELECT_LEX
*
sl
=
prev_unit
->
outer_select
();
/*
/*
...
@@ -1399,6 +1408,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1399,6 +1408,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
REPORT_ALL_ERRORS
)))
==
REPORT_ALL_ERRORS
)))
==
(
Item
**
)
not_found_item
)
(
Item
**
)
not_found_item
)
{
{
upward_lookup
=
1
;
Field
*
tmp
=
(
Field
*
)
not_found_field
;
Field
*
tmp
=
(
Field
*
)
not_found_field
;
/*
/*
We can't find table field in table list of current select,
We can't find table field in table list of current select,
...
@@ -1457,11 +1467,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1457,11 +1467,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
return
-
1
;
return
-
1
;
else
if
(
ref
==
(
Item
**
)
not_found_item
&&
tmp
==
not_found_field
)
else
if
(
ref
==
(
Item
**
)
not_found_item
&&
tmp
==
not_found_field
)
{
{
// Call to report error
if
(
upward_lookup
)
find_item_in_list
(
this
,
// We can't say exactly what absend (table or field)
*
(
thd
->
lex
.
current_select
->
get_item_list
()),
my_printf_error
(
ER_BAD_FIELD_ERROR
,
ER
(
ER_BAD_FIELD_ERROR
),
MYF
(
0
),
&
counter
,
full_name
(),
thd
->
where
);
REPORT_ALL_ERRORS
);
else
// Call to report error
find_item_in_list
(
this
,
*
(
thd
->
lex
.
current_select
->
get_item_list
()),
&
counter
,
REPORT_ALL_ERRORS
);
ref
=
0
;
ref
=
0
;
return
1
;
return
1
;
}
}
...
...
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