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
43821a83
Commit
43821a83
authored
Aug 23, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-bugs-4.1
parents
a7c81531
13f7338a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
239 additions
and
106 deletions
+239
-106
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+15
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+51
-0
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+3
-1
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+28
-0
sql/item.cc
sql/item.cc
+46
-24
sql/item_subselect.cc
sql/item_subselect.cc
+74
-62
sql/item_subselect.h
sql/item_subselect.h
+2
-0
sql/mysql_priv.h
sql/mysql_priv.h
+7
-0
sql/sql_lex.cc
sql/sql_lex.cc
+1
-1
sql/sql_lex.h
sql/sql_lex.h
+0
-6
sql/sql_yacc.yy
sql/sql_yacc.yy
+12
-12
No files found.
mysql-test/r/func_gconcat.result
View file @
43821a83
...
@@ -294,6 +294,21 @@ grp
...
@@ -294,6 +294,21 @@ grp
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1;
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1;
grp
grp
2,4,3,5
2,4,3,5
select t1.a, group_concat(c order by (select c from t2 where t2.a=t1.a limit 1)) as grp from t1 group by 1;
a grp
1 2
2 4,3
3 5
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a)) as grp from t1 group by 1;
a grp
1 2
2 4,3
3 5
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1 group by 1;
a grp
1 2
2 4,3
3 5
select a,c,(select group_concat(c order by a) from t2 where a=t1.a) as grp from t1 order by grp;
select a,c,(select group_concat(c order by a) from t2 where a=t1.a) as grp from t1 order by grp;
a c grp
a c grp
3 5 3,3
3 5 3,3
...
...
mysql-test/r/subselect.result
View file @
43821a83
...
@@ -1912,3 +1912,54 @@ a
...
@@ -1912,3 +1912,54 @@ a
1
1
2
2
drop table t1,t2;
drop table t1,t2;
CREATE TABLE `t1` ( `aid` int(11) NOT NULL default '0', `bid` int(11) NOT NULL default '0', PRIMARY KEY (`aid`,`bid`));
CREATE TABLE `t2` ( `aid` int(11) NOT NULL default '0', `bid` int(11) NOT NULL default '0', PRIMARY KEY (`aid`,`bid`));
insert into t1 values (1,1),(1,2),(2,1),(2,2);
insert into t2 values (1,2),(2,2);
select * from t1 where t1.aid not in (select aid from t2 where bid=t1.bid);
aid bid
1 1
2 1
alter table t2 drop primary key;
alter table t2 add key KEY1 (aid, bid);
select * from t1 where t1.aid not in (select aid from t2 where bid=t1.bid);
aid bid
1 1
2 1
alter table t2 drop key KEY1;
alter table t2 add primary key (bid, aid);
select * from t1 where t1.aid not in (select aid from t2 where bid=t1.bid);
aid bid
1 1
2 1
drop table t1,t2;
CREATE TABLE t1 (howmanyvalues bigint, avalue int);
INSERT INTO t1 VALUES (1, 1),(2, 1),(2, 2),(3, 1),(3, 2),(3, 3),(4, 1),(4, 2),(4, 3),(4, 4);
SELECT howmanyvalues, count(*) from t1 group by howmanyvalues;
howmanyvalues count(*)
1 1
2 2
3 3
4 4
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.howmanyvalues) as mycount from t1 a group by a.howmanyvalues;
howmanyvalues mycount
1 1
2 2
3 3
4 4
CREATE INDEX t1_howmanyvalues_idx ON t1 (howmanyvalues);
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues+1 = a.howmanyvalues+1) as mycount from t1 a group by a.howmanyvalues;
howmanyvalues mycount
1 1
2 2
3 3
4 4
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.howmanyvalues) as mycount from t1 a group by a.howmanyvalues;
howmanyvalues mycount
1 1
2 2
3 3
4 4
SELECT a.howmanyvalues, (SELECT count(*) from t1 b where b.howmanyvalues = a.avalue) as mycount from t1 a group by a.howmanyvalues;
ERROR 42S22: Unknown column 'a.avalue' in 'where clause'
drop table t1;
mysql-test/t/func_gconcat.test
View file @
43821a83
...
@@ -169,9 +169,11 @@ create table t2 (a int, c int);
...
@@ -169,9 +169,11 @@ create table t2 (a int, c int);
insert
into
t2
values
(
1
,
5
),
(
2
,
4
),
(
3
,
3
),
(
3
,
3
);
insert
into
t2
values
(
1
,
5
),
(
2
,
4
),
(
3
,
3
),
(
3
,
3
);
select
group_concat
(
c
)
from
t1
;
select
group_concat
(
c
)
from
t1
;
select
group_concat
(
c
order
by
(
select
c
from
t2
where
t2
.
a
=
t1
.
a
limit
1
))
as
grp
from
t1
;
select
group_concat
(
c
order
by
(
select
c
from
t2
where
t2
.
a
=
t1
.
a
limit
1
))
as
grp
from
t1
;
select
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
))
as
grp
from
t1
;
select
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
))
as
grp
from
t1
;
select
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
)
desc
)
as
grp
from
t1
;
select
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
)
desc
)
as
grp
from
t1
;
select
t1
.
a
,
group_concat
(
c
order
by
(
select
c
from
t2
where
t2
.
a
=
t1
.
a
limit
1
))
as
grp
from
t1
group
by
1
;
select
t1
.
a
,
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
))
as
grp
from
t1
group
by
1
;
select
t1
.
a
,
group_concat
(
c
order
by
(
select
mid
(
group_concat
(
c
order
by
a
),
1
,
5
)
from
t2
where
t2
.
a
=
t1
.
a
)
desc
)
as
grp
from
t1
group
by
1
;
# The following returns random results as we are sorting on blob addresses
# The following returns random results as we are sorting on blob addresses
# select group_concat(c order by (select group_concat(c order by a) from t2 where t2.a=t1.a)) as grp from t1;
# select group_concat(c order by (select group_concat(c order by a) from t2 where t2.a=t1.a)) as grp from t1;
...
...
mysql-test/t/subselect.test
View file @
43821a83
...
@@ -1234,4 +1234,32 @@ select a,b from t1 where match(b) against ('Ball') > 0;
...
@@ -1234,4 +1234,32 @@ select a,b from t1 where match(b) against ('Ball') > 0;
select
a
from
t2
where
a
in
(
select
a
from
t1
where
match
(
b
)
against
(
'Ball'
)
>
0
);
select
a
from
t2
where
a
in
(
select
a
from
t1
where
match
(
b
)
against
(
'Ball'
)
>
0
);
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# Optimized IN with compound index
#
CREATE
TABLE
`t1`
(
`aid`
int
(
11
)
NOT
NULL
default
'0'
,
`bid`
int
(
11
)
NOT
NULL
default
'0'
,
PRIMARY
KEY
(
`aid`
,
`bid`
));
CREATE
TABLE
`t2`
(
`aid`
int
(
11
)
NOT
NULL
default
'0'
,
`bid`
int
(
11
)
NOT
NULL
default
'0'
,
PRIMARY
KEY
(
`aid`
,
`bid`
));
insert
into
t1
values
(
1
,
1
),(
1
,
2
),(
2
,
1
),(
2
,
2
);
insert
into
t2
values
(
1
,
2
),(
2
,
2
);
select
*
from
t1
where
t1
.
aid
not
in
(
select
aid
from
t2
where
bid
=
t1
.
bid
);
alter
table
t2
drop
primary
key
;
alter
table
t2
add
key
KEY1
(
aid
,
bid
);
select
*
from
t1
where
t1
.
aid
not
in
(
select
aid
from
t2
where
bid
=
t1
.
bid
);
alter
table
t2
drop
key
KEY1
;
alter
table
t2
add
primary
key
(
bid
,
aid
);
select
*
from
t1
where
t1
.
aid
not
in
(
select
aid
from
t2
where
bid
=
t1
.
bid
);
drop
table
t1
,
t2
;
#
# resolving fields of grouped outer SELECT
#
CREATE
TABLE
t1
(
howmanyvalues
bigint
,
avalue
int
);
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
1
),(
2
,
2
),(
3
,
1
),(
3
,
2
),(
3
,
3
),(
4
,
1
),(
4
,
2
),(
4
,
3
),(
4
,
4
);
SELECT
howmanyvalues
,
count
(
*
)
from
t1
group
by
howmanyvalues
;
SELECT
a
.
howmanyvalues
,
(
SELECT
count
(
*
)
from
t1
b
where
b
.
howmanyvalues
=
a
.
howmanyvalues
)
as
mycount
from
t1
a
group
by
a
.
howmanyvalues
;
CREATE
INDEX
t1_howmanyvalues_idx
ON
t1
(
howmanyvalues
);
SELECT
a
.
howmanyvalues
,
(
SELECT
count
(
*
)
from
t1
b
where
b
.
howmanyvalues
+
1
=
a
.
howmanyvalues
+
1
)
as
mycount
from
t1
a
group
by
a
.
howmanyvalues
;
SELECT
a
.
howmanyvalues
,
(
SELECT
count
(
*
)
from
t1
b
where
b
.
howmanyvalues
=
a
.
howmanyvalues
)
as
mycount
from
t1
a
group
by
a
.
howmanyvalues
;
--
error
1054
SELECT
a
.
howmanyvalues
,
(
SELECT
count
(
*
)
from
t1
b
where
b
.
howmanyvalues
=
a
.
avalue
)
as
mycount
from
t1
a
group
by
a
.
howmanyvalues
;
drop
table
t1
;
sql/item.cc
View file @
43821a83
...
@@ -60,10 +60,10 @@ Item::Item():
...
@@ -60,10 +60,10 @@ Item::Item():
*/
*/
if
(
thd
->
lex
->
current_select
)
if
(
thd
->
lex
->
current_select
)
{
{
SELECT_LEX_NODE
::
enum_parsing_place
place
=
enum_parsing_place
place
=
thd
->
lex
->
current_select
->
parsing_place
;
thd
->
lex
->
current_select
->
parsing_place
;
if
(
place
==
SELECT_L
EX_NODE
::
SELECT_L
IST
||
if
(
place
==
SELECT_LIST
||
place
==
SELECT_LEX_NODE
::
IN_HAVING
)
place
==
IN_HAVING
)
thd
->
lex
->
current_select
->
select_n_having_items
++
;
thd
->
lex
->
current_select
->
select_n_having_items
++
;
}
}
}
}
...
@@ -1233,21 +1233,34 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -1233,21 +1233,34 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
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
)
{
{
// it is primary INSERT st_select_lex => skip first table resolving
/*
it is primary INSERT st_select_lex => skip first table
resolving
*/
table_list
=
table_list
->
next
;
table_list
=
table_list
->
next
;
}
}
Item_subselect
*
prev_subselect_item
=
prev_unit
->
item
;
Item_subselect
*
prev_subselect_item
=
prev_unit
->
item
;
if
((
tmp
=
find_field_in_tables
(
thd
,
this
,
enum_parsing_place
place
=
table_list
,
&
where
,
prev_subselect_item
->
parsing_place
;
0
))
!=
not_found_field
)
/*
{
check table fields only if subquery used somewhere out of HAVING
if
(
!
tmp
)
or SELECT list or outer SELECT do not use groupping (i.e. tables
return
-
1
;
are accessable)
prev_subselect_item
->
used_tables_cache
|=
tmp
->
table
->
map
;
*/
prev_subselect_item
->
const_item_cache
=
0
;
if
(((
place
!=
IN_HAVING
&&
break
;
place
!=
SELECT_LIST
)
||
}
(
sl
->
with_sum_func
==
0
&&
sl
->
group_list
.
elements
==
0
))
&&
(
tmp
=
find_field_in_tables
(
thd
,
this
,
table_list
,
&
where
,
0
))
!=
not_found_field
)
{
if
(
!
tmp
)
return
-
1
;
prev_subselect_item
->
used_tables_cache
|=
tmp
->
table
->
map
;
prev_subselect_item
->
const_item_cache
=
0
;
break
;
}
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
SELECT_MODE
&&
if
(
sl
->
resolve_mode
==
SELECT_LEX
::
SELECT_MODE
&&
(
refer
=
find_item_in_list
(
this
,
sl
->
item_list
,
&
counter
,
(
refer
=
find_item_in_list
(
this
,
sl
->
item_list
,
&
counter
,
REPORT_EXCEPT_NOT_FOUND
))
!=
REPORT_EXCEPT_NOT_FOUND
))
!=
...
@@ -1906,16 +1919,25 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1906,16 +1919,25 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
// it is primary INSERT st_select_lex => skip first table resolving
// it is primary INSERT st_select_lex => skip first table resolving
table_list
=
table_list
->
next
;
table_list
=
table_list
->
next
;
}
}
if
((
tmp
=
find_field_in_tables
(
thd
,
this
,
enum_parsing_place
place
=
table_list
,
&
where
,
prev_subselect_item
->
parsing_place
;
0
))
!=
not_found_field
)
/*
{
check table fields only if subquery used somewhere out of HAVING
prev_subselect_item
->
used_tables_cache
|=
tmp
->
table
->
map
;
or SELECT list or outer SELECT do not use groupping (i.e. tables
prev_subselect_item
->
const_item_cache
=
0
;
are accessable)
break
;
*/
}
if
(((
place
!=
IN_HAVING
&&
place
!=
SELECT_LIST
)
||
// Reference is not found => depend from outer (or just error)
(
sl
->
with_sum_func
==
0
&&
sl
->
group_list
.
elements
==
0
))
&&
(
tmp
=
find_field_in_tables
(
thd
,
this
,
table_list
,
&
where
,
0
))
!=
not_found_field
)
{
prev_subselect_item
->
used_tables_cache
|=
tmp
->
table
->
map
;
prev_subselect_item
->
const_item_cache
=
0
;
break
;
}
// Reference is not found => depend from outer (or just error)
prev_subselect_item
->
used_tables_cache
|=
OUTER_REF_TABLE_BIT
;
prev_subselect_item
->
used_tables_cache
|=
OUTER_REF_TABLE_BIT
;
prev_subselect_item
->
const_item_cache
=
0
;
prev_subselect_item
->
const_item_cache
=
0
;
...
...
sql/item_subselect.cc
View file @
43821a83
...
@@ -63,12 +63,21 @@ void Item_subselect::init(st_select_lex *select_lex,
...
@@ -63,12 +63,21 @@ void Item_subselect::init(st_select_lex *select_lex,
=> we do not copy old_engine here
=> we do not copy old_engine here
*/
*/
engine
=
unit
->
item
->
engine
;
engine
=
unit
->
item
->
engine
;
parsing_place
=
unit
->
item
->
parsing_place
;
unit
->
item
->
engine
=
0
;
unit
->
item
->
engine
=
0
;
unit
->
item
=
this
;
unit
->
item
=
this
;
engine
->
change_item
(
this
,
result
);
engine
->
change_item
(
this
,
result
);
}
}
else
else
{
{
SELECT_LEX
*
outer_select
=
unit
->
outer_select
();
/*
do not take into account expression inside aggregate functions because
they can access original table fields
*/
parsing_place
=
(
outer_select
->
in_sum_expr
?
NO_MATTER
:
outer_select
->
parsing_place
);
if
(
select_lex
->
next_select
())
if
(
select_lex
->
next_select
())
engine
=
new
subselect_union_engine
(
unit
,
result
,
this
);
engine
=
new
subselect_union_engine
(
unit
,
result
,
this
);
else
else
...
@@ -76,7 +85,7 @@ void Item_subselect::init(st_select_lex *select_lex,
...
@@ -76,7 +85,7 @@ void Item_subselect::init(st_select_lex *select_lex,
}
}
{
{
SELECT_LEX
*
upper
=
unit
->
outer_select
();
SELECT_LEX
*
upper
=
unit
->
outer_select
();
if
(
upper
->
parsing_place
==
SELECT_LEX_NODE
::
IN_HAVING
)
if
(
upper
->
parsing_place
==
IN_HAVING
)
upper
->
subquery_in_having
=
1
;
upper
->
subquery_in_having
=
1
;
}
}
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
@@ -1245,29 +1254,31 @@ int subselect_uniquesubquery_engine::exec()
...
@@ -1245,29 +1254,31 @@ int subselect_uniquesubquery_engine::exec()
DBUG_ENTER
(
"subselect_uniquesubquery_engine::exec"
);
DBUG_ENTER
(
"subselect_uniquesubquery_engine::exec"
);
int
error
;
int
error
;
TABLE
*
table
=
tab
->
table
;
TABLE
*
table
=
tab
->
table
;
if
((
tab
->
ref
.
key_err
=
(
*
tab
->
ref
.
key_copy
)
->
copy
())
)
for
(
store_key
**
copy
=
tab
->
ref
.
key_copy
;
*
copy
;
copy
++
)
{
{
table
->
status
=
STATUS_NOT_FOUND
;
if
(
tab
->
ref
.
key_err
=
(
*
copy
)
->
copy
())
error
=
-
1
;
{
table
->
status
=
STATUS_NOT_FOUND
;
DBUG_RETURN
(
1
);
}
}
}
if
(
!
table
->
file
->
inited
)
table
->
file
->
ha_index_init
(
tab
->
ref
.
key
);
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
tab
->
ref
.
key_buff
,
tab
->
ref
.
key_length
,
HA_READ_KEY_EXACT
);
if
(
error
&&
error
!=
HA_ERR_KEY_NOT_FOUND
)
error
=
report_error
(
table
,
error
);
else
else
{
{
if
(
!
table
->
file
->
inited
)
error
=
0
;
table
->
file
->
ha_index_init
(
tab
->
ref
.
key
);
table
->
null_row
=
0
;
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
((
Item_in_subselect
*
)
item
)
->
value
=
(
!
table
->
status
&&
tab
->
ref
.
key_buff
,
(
!
cond
||
cond
->
val_int
())
?
1
:
tab
->
ref
.
key_length
,
HA_READ_KEY_EXACT
);
0
);
if
(
error
&&
error
!=
HA_ERR_KEY_NOT_FOUND
)
error
=
report_error
(
table
,
error
);
else
{
error
=
0
;
table
->
null_row
=
0
;
((
Item_in_subselect
*
)
item
)
->
value
=
(
!
table
->
status
&&
(
!
cond
||
cond
->
val_int
())
?
1
:
0
);
}
}
}
DBUG_RETURN
(
error
!=
0
);
DBUG_RETURN
(
error
!=
0
);
}
}
...
@@ -1295,55 +1306,56 @@ int subselect_indexsubquery_engine::exec()
...
@@ -1295,55 +1306,56 @@ int subselect_indexsubquery_engine::exec()
((
Item_in_subselect
*
)
item
)
->
was_null
=
0
;
((
Item_in_subselect
*
)
item
)
->
was_null
=
0
;
}
}
if
((
*
tab
->
ref
.
key_copy
)
&&
(
tab
->
ref
.
key_err
=
(
*
tab
->
ref
.
key_copy
)
->
copy
())
)
for
(
store_key
**
copy
=
tab
->
ref
.
key_copy
;
*
copy
;
copy
++
)
{
{
table
->
status
=
STATUS_NOT_FOUND
;
if
(
tab
->
ref
.
key_err
=
(
*
copy
)
->
copy
())
error
=
-
1
;
{
table
->
status
=
STATUS_NOT_FOUND
;
DBUG_RETURN
(
1
);
}
}
}
if
(
!
table
->
file
->
inited
)
table
->
file
->
ha_index_init
(
tab
->
ref
.
key
);
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
tab
->
ref
.
key_buff
,
tab
->
ref
.
key_length
,
HA_READ_KEY_EXACT
);
if
(
error
&&
error
!=
HA_ERR_KEY_NOT_FOUND
)
error
=
report_error
(
table
,
error
);
else
else
{
{
if
(
!
table
->
file
->
inited
)
for
(;;)
table
->
file
->
ha_index_init
(
tab
->
ref
.
key
);
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
tab
->
ref
.
key_buff
,
tab
->
ref
.
key_length
,
HA_READ_KEY_EXACT
);
if
(
error
&&
error
!=
HA_ERR_KEY_NOT_FOUND
)
error
=
report_error
(
table
,
error
);
else
{
{
for
(;;)
error
=
0
;
table
->
null_row
=
0
;
if
(
!
table
->
status
)
{
{
error
=
0
;
if
(
!
cond
||
cond
->
val_int
())
table
->
null_row
=
0
;
{
if
(
!
table
->
status
)
if
(
null_finding
)
{
((
Item_in_subselect
*
)
item
)
->
was_null
=
1
;
if
(
!
cond
||
cond
->
val_int
())
else
{
((
Item_in_subselect
*
)
item
)
->
value
=
1
;
if
(
null_finding
)
break
;
((
Item_in_subselect
*
)
item
)
->
was_null
=
1
;
}
else
error
=
table
->
file
->
index_next_same
(
table
->
record
[
0
],
((
Item_in_subselect
*
)
item
)
->
value
=
1
;
tab
->
ref
.
key_buff
,
break
;
tab
->
ref
.
key_length
);
}
if
(
error
&&
error
!=
HA_ERR_END_OF_FILE
)
error
=
table
->
file
->
index_next_same
(
table
->
record
[
0
],
{
tab
->
ref
.
key_buff
,
error
=
report_error
(
table
,
error
);
tab
->
ref
.
key_length
);
break
;
if
(
error
&&
error
!=
HA_ERR_END_OF_FILE
)
}
{
}
error
=
report_error
(
table
,
error
);
else
break
;
{
}
if
(
!
check_null
||
null_finding
)
}
break
;
/* We don't need to check nulls */
else
*
tab
->
ref
.
null_ref_key
=
1
;
{
null_finding
=
1
;
if
(
!
check_null
||
null_finding
)
/* Check if there exists a row with a null value in the index */
break
;
/* We don't need to check nulls */
if
((
error
=
(
safe_index_read
(
tab
)
==
1
)))
*
tab
->
ref
.
null_ref_key
=
1
;
break
;
null_finding
=
1
;
/* Check if there exists a row with a null value in the index */
if
((
error
=
(
safe_index_read
(
tab
)
==
1
)))
break
;
}
}
}
}
}
}
}
...
...
sql/item_subselect.h
View file @
43821a83
...
@@ -48,6 +48,8 @@ protected:
...
@@ -48,6 +48,8 @@ protected:
table_map
used_tables_cache
;
table_map
used_tables_cache
;
/* allowed number of columns (1 for single value subqueries) */
/* allowed number of columns (1 for single value subqueries) */
uint
max_columns
;
uint
max_columns
;
/* where subquery is placed */
enum_parsing_place
parsing_place
;
/* work with 'substitution' */
/* work with 'substitution' */
bool
have_to_be_excluded
;
bool
have_to_be_excluded
;
/* cache of constant state */
/* cache of constant state */
...
...
sql/mysql_priv.h
View file @
43821a83
...
@@ -293,6 +293,13 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
...
@@ -293,6 +293,13 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
*/
*/
#define MAX_DATE_REP_LENGTH 30
#define MAX_DATE_REP_LENGTH 30
enum
enum_parsing_place
{
NO_MATTER
,
IN_HAVING
,
SELECT_LIST
};
struct
st_table
;
struct
st_table
;
class
THD
;
class
THD
;
class
Item_arena
;
class
Item_arena
;
...
...
sql/sql_lex.cc
View file @
43821a83
...
@@ -1017,7 +1017,7 @@ void st_select_lex::init_query()
...
@@ -1017,7 +1017,7 @@ void st_select_lex::init_query()
select_n_having_items
=
0
;
select_n_having_items
=
0
;
prep_where
=
0
;
prep_where
=
0
;
subquery_in_having
=
explicit_limit
=
0
;
subquery_in_having
=
explicit_limit
=
0
;
parsing_place
=
SELECT_LEX_NODE
::
NO_MATTER
;
parsing_place
=
NO_MATTER
;
}
}
void
st_select_lex
::
init_select
()
void
st_select_lex
::
init_select
()
...
...
sql/sql_lex.h
View file @
43821a83
...
@@ -220,12 +220,6 @@ protected:
...
@@ -220,12 +220,6 @@ protected:
*
master
,
*
slave
,
/* vertical links */
*
master
,
*
slave
,
/* vertical links */
*
link_next
,
**
link_prev
;
/* list of whole SELECT_LEX */
*
link_next
,
**
link_prev
;
/* list of whole SELECT_LEX */
public:
public:
enum
enum_parsing_place
{
NO_MATTER
,
IN_HAVING
,
SELECT_LIST
};
ulong
options
;
ulong
options
;
/*
/*
...
...
sql/sql_yacc.yy
View file @
43821a83
...
@@ -1113,11 +1113,11 @@ create_select:
...
@@ -1113,11 +1113,11 @@ create_select:
lex->sql_command= SQLCOM_REPLACE_SELECT;
lex->sql_command= SQLCOM_REPLACE_SELECT;
lex->current_select->table_list.save_and_clear(&lex->save_list);
lex->current_select->table_list.save_and_clear(&lex->save_list);
mysql_init_select(lex);
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_L
EX_NODE::SELECT_L
IST;
lex->current_select->parsing_place= SELECT_LIST;
}
}
select_options select_item_list
select_options select_item_list
{
{
Select->parsing_place=
SELECT_LEX_NODE::
NO_MATTER;
Select->parsing_place= NO_MATTER;
}
}
opt_select_from
opt_select_from
{ Lex->current_select->table_list.push_front(&Lex->save_list); }
{ Lex->current_select->table_list.push_front(&Lex->save_list); }
...
@@ -2376,11 +2376,11 @@ select_part2:
...
@@ -2376,11 +2376,11 @@ select_part2:
lex->lock_option= TL_READ;
lex->lock_option= TL_READ;
if (sel->linkage != UNION_TYPE)
if (sel->linkage != UNION_TYPE)
mysql_init_select(lex);
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_L
EX_NODE::SELECT_L
IST;
lex->current_select->parsing_place= SELECT_LIST;
}
}
select_options select_item_list
select_options select_item_list
{
{
Select->parsing_place=
SELECT_LEX_NODE::
NO_MATTER;
Select->parsing_place= NO_MATTER;
}
}
select_into select_lock_type;
select_into select_lock_type;
...
@@ -3444,11 +3444,11 @@ select_derived:
...
@@ -3444,11 +3444,11 @@ select_derived:
YYABORT;
YYABORT;
mysql_init_select(lex);
mysql_init_select(lex);
lex->current_select->linkage= DERIVED_TABLE_TYPE;
lex->current_select->linkage= DERIVED_TABLE_TYPE;
lex->current_select->parsing_place= SELECT_L
EX_NODE::SELECT_L
IST;
lex->current_select->parsing_place= SELECT_LIST;
}
}
select_options select_item_list
select_options select_item_list
{
{
Select->parsing_place=
SELECT_LEX_NODE::
NO_MATTER;
Select->parsing_place= NO_MATTER;
}
}
opt_select_from union_opt
opt_select_from union_opt
;
;
...
@@ -3578,13 +3578,13 @@ having_clause:
...
@@ -3578,13 +3578,13 @@ having_clause:
/* empty */
/* empty */
| HAVING
| HAVING
{
{
Select->parsing_place=
SELECT_LEX_NODE::
IN_HAVING;
Select->parsing_place= IN_HAVING;
}
}
expr
expr
{
{
SELECT_LEX *sel= Select;
SELECT_LEX *sel= Select;
sel->having= $3;
sel->having= $3;
sel->parsing_place=
SELECT_LEX_NODE::
NO_MATTER;
sel->parsing_place= NO_MATTER;
if ($3)
if ($3)
$3->top_level_item();
$3->top_level_item();
}
}
...
@@ -4819,7 +4819,7 @@ simple_ident:
...
@@ -4819,7 +4819,7 @@ simple_ident:
ident
ident
{
{
SELECT_LEX *sel=Select;
SELECT_LEX *sel=Select;
$$= (sel->parsing_place !=
SELECT_LEX_NODE::
IN_HAVING ||
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,NullS,$1.str) :
(Item*) new Item_field(NullS,NullS,$1.str) :
(Item*) new Item_ref(0,0, NullS,NullS,$1.str);
(Item*) new Item_ref(0,0, NullS,NullS,$1.str);
...
@@ -4835,7 +4835,7 @@ simple_ident:
...
@@ -4835,7 +4835,7 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $1.str, thd->where);
MYF(0), $1.str, thd->where);
}
}
$$= (sel->parsing_place !=
SELECT_LEX_NODE::
IN_HAVING ||
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,$1.str,$3.str) :
(Item*) new Item_field(NullS,$1.str,$3.str) :
(Item*) new Item_ref(0,0,NullS,$1.str,$3.str);
(Item*) new Item_ref(0,0,NullS,$1.str,$3.str);
...
@@ -4851,7 +4851,7 @@ simple_ident:
...
@@ -4851,7 +4851,7 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $2.str, thd->where);
MYF(0), $2.str, thd->where);
}
}
$$= (sel->parsing_place !=
SELECT_LEX_NODE::
IN_HAVING ||
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,$2.str,$4.str) :
(Item*) new Item_field(NullS,$2.str,$4.str) :
(Item*) new Item_ref(0,0,NullS,$2.str,$4.str);
(Item*) new Item_ref(0,0,NullS,$2.str,$4.str);
...
@@ -4867,7 +4867,7 @@ simple_ident:
...
@@ -4867,7 +4867,7 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $3.str, thd->where);
MYF(0), $3.str, thd->where);
}
}
$$= (sel->parsing_place !=
SELECT_LEX_NODE::
IN_HAVING ||
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field((YYTHD->client_capabilities &
(Item*) new Item_field((YYTHD->client_capabilities &
CLIENT_NO_SCHEMA ? NullS : $1.str),
CLIENT_NO_SCHEMA ? NullS : $1.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