mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
correct assignment of default limit (BUG#2600)
This commit is contained in:
@ -1625,3 +1625,14 @@ PIPPO
|
|||||||
1
|
1
|
||||||
NULL
|
NULL
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
|
create table t1 (a int);
|
||||||
|
insert into t1 values (1), (2), (3);
|
||||||
|
SET SQL_SELECT_LIMIT=1;
|
||||||
|
select sum(a) from (select * from t1) as a;
|
||||||
|
sum(a)
|
||||||
|
6
|
||||||
|
select 2 in (select * from t1);
|
||||||
|
2 in (select * from t1)
|
||||||
|
1
|
||||||
|
SET SQL_SELECT_LIMIT=default;
|
||||||
|
drop table t1;
|
||||||
|
@ -1075,3 +1075,14 @@ s.id_cns = cns.id ORDER BY s.anno_dep DESC LIMIT 1) AS PIPPO FROM
|
|||||||
t2 AS cns;
|
t2 AS cns;
|
||||||
|
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# GLOBAL LIMIT
|
||||||
|
#
|
||||||
|
create table t1 (a int);
|
||||||
|
insert into t1 values (1), (2), (3);
|
||||||
|
SET SQL_SELECT_LIMIT=1;
|
||||||
|
select sum(a) from (select * from t1) as a;
|
||||||
|
select 2 in (select * from t1);
|
||||||
|
SET SQL_SELECT_LIMIT=default;
|
||||||
|
drop table t1;
|
||||||
|
@ -1540,8 +1540,9 @@ void st_select_lex::print_limit(THD *thd, String *str)
|
|||||||
if (!thd)
|
if (!thd)
|
||||||
thd= current_thd;
|
thd= current_thd;
|
||||||
|
|
||||||
if (select_limit != thd->variables.select_limit ||
|
if ((select_limit != thd->variables.select_limit &&
|
||||||
select_limit != HA_POS_ERROR ||
|
this == &thd->lex->select_lex) ||
|
||||||
|
(select_limit != HA_POS_ERROR && this != &thd->lex->select_lex) ||
|
||||||
offset_limit != 0L)
|
offset_limit != 0L)
|
||||||
{
|
{
|
||||||
str->append(" limit ", 7);
|
str->append(" limit ", 7);
|
||||||
|
@ -3758,7 +3758,9 @@ mysql_init_select(LEX *lex)
|
|||||||
{
|
{
|
||||||
SELECT_LEX *select_lex= lex->current_select;
|
SELECT_LEX *select_lex= lex->current_select;
|
||||||
select_lex->init_select();
|
select_lex->init_select();
|
||||||
select_lex->select_limit= lex->thd->variables.select_limit;
|
select_lex->select_limit= (&lex->select_lex == select_lex) ?
|
||||||
|
lex->thd->variables.select_limit : /* Primry UNION */
|
||||||
|
HA_POS_ERROR; /* subquery */
|
||||||
if (select_lex == &lex->select_lex)
|
if (select_lex == &lex->select_lex)
|
||||||
{
|
{
|
||||||
lex->exchange= 0;
|
lex->exchange= 0;
|
||||||
@ -3810,7 +3812,9 @@ mysql_new_select(LEX *lex, bool move_down)
|
|||||||
fake->select_number= INT_MAX;
|
fake->select_number= INT_MAX;
|
||||||
fake->make_empty_select();
|
fake->make_empty_select();
|
||||||
fake->linkage= GLOBAL_OPTIONS_TYPE;
|
fake->linkage= GLOBAL_OPTIONS_TYPE;
|
||||||
fake->select_limit= lex->thd->variables.select_limit;
|
fake->select_limit= (&lex->unit == unit) ?
|
||||||
|
lex->thd->variables.select_limit : /* Primry UNION */
|
||||||
|
HA_POS_ERROR; /* subquery */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3476,9 +3476,12 @@ order_dir:
|
|||||||
opt_limit_clause_init:
|
opt_limit_clause_init:
|
||||||
/* empty */
|
/* empty */
|
||||||
{
|
{
|
||||||
SELECT_LEX *sel= Select;
|
LEX *lex= Lex;
|
||||||
|
SELECT_LEX *sel= lex->current_select;
|
||||||
sel->offset_limit= 0L;
|
sel->offset_limit= 0L;
|
||||||
sel->select_limit= Lex->thd->variables.select_limit;
|
sel->select_limit= (&lex->select_lex == sel) ?
|
||||||
|
Lex->thd->variables.select_limit : /* primary SELECT */
|
||||||
|
HA_POS_ERROR; /* subquery */
|
||||||
}
|
}
|
||||||
| limit_clause {}
|
| limit_clause {}
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user