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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
fa5520fb
Commit
fa5520fb
authored
Oct 11, 2003
by
bell@laptop.sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more resonable errors about name resolving in subqueries (BUG#1483)
parent
8313e0da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
10 deletions
+47
-10
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+10
-1
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+15
-2
sql/item.cc
sql/item.cc
+22
-7
No files found.
mysql-test/r/subselect.result
View file @
fa5520fb
...
@@ -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;
...
@@ -1439,3 +1439,12 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1439,3 +1439,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
drop table if exists t2, t3;
drop table if exists t2, t3;
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 @
fa5520fb
...
@@ -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
;
...
@@ -965,3 +965,16 @@ insert into t2 values (2,2), (2,1), (3,3), (3,1);
...
@@ -965,3 +965,16 @@ insert into t2 values (2,2), (2,1), (3,3), (3,1);
select
*
from
t3
where
a
>
all
(
select
max
(
b
)
from
t2
group
by
a
);
select
*
from
t3
where
a
>
all
(
select
max
(
b
)
from
t2
group
by
a
);
explain
select
*
from
t3
where
a
>
all
(
select
max
(
b
)
from
t2
group
by
a
);
explain
select
*
from
t3
where
a
>
all
(
select
max
(
b
)
from
t2
group
by
a
);
drop
table
if
exists
t2
,
t3
;
drop
table
if
exists
t2
,
t3
;
#
# 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
;
\ No newline at end of file
sql/item.cc
View file @
fa5520fb
...
@@ -794,6 +794,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -794,6 +794,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
)
...
@@ -821,6 +822,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -821,6 +822,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
sl
;
sl
;
sl
=
sl
->
outer_select
())
sl
=
sl
->
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
)
{
{
...
@@ -846,8 +848,14 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -846,8 +848,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
)
...
@@ -1350,6 +1358,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1350,6 +1358,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
*
sl
=
thd
->
lex
.
current_select
->
outer_select
();
SELECT_LEX
*
sl
=
thd
->
lex
.
current_select
->
outer_select
();
/*
/*
Finding only in current select will be performed for selects that have
Finding only in current select will be performed for selects that have
...
@@ -1367,6 +1376,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1367,6 +1376,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,
...
@@ -1408,11 +1418,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1408,11 +1418,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