summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-05-20 12:36:30 +0200
committerSergei Golubchik <sergii@pisem.net>2013-05-20 12:36:30 +0200
commitd7a6c801ac6890fd8a218484db5293afdcc2808a (patch)
treed399d63510cafdb2bb11ac083ae285aaebbb9096 /sql
parentdb7085dfae07e8cf4e98e41bd0dc111fb1b4896b (diff)
parent639a766096733861ce5f4ed4863d9db37090a4f4 (diff)
downloadmariadb-git-d7a6c801ac6890fd8a218484db5293afdcc2808a.tar.gz
5.3 merge.
change maria.distinct to use a function that doesn't require ssl-enabled builds
Diffstat (limited to 'sql')
-rw-r--r--sql/item.h6
-rw-r--r--sql/item_sum.cc21
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sql_lex.h3
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc3
7 files changed, 35 insertions, 7 deletions
diff --git a/sql/item.h b/sql/item.h
index 891a1500eb1..2b0456bd30c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -384,6 +384,12 @@ struct Name_resolution_context: Sql_alloc
{
(*error_processor)(thd, error_processor_data);
}
+ st_select_lex *outer_select()
+ {
+ return (outer_context ?
+ outer_context->select_lex :
+ NULL);
+ }
};
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1fed1efc637..4f4d8588a3a 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -65,7 +65,15 @@ ulonglong Item_sum::ram_limitation(THD *thd)
bool Item_sum::init_sum_func_check(THD *thd)
{
- if (!thd->lex->allow_sum_func)
+ SELECT_LEX *curr_sel= thd->lex->current_select;
+ if (!curr_sel->name_visibility_map)
+ {
+ for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select())
+ {
+ curr_sel->name_visibility_map|= (1 << sl-> nest_level);
+ }
+ }
+ if (!(thd->lex->allow_sum_func & curr_sel->name_visibility_map))
{
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
MYF(0));
@@ -136,8 +144,11 @@ bool Item_sum::init_sum_func_check(THD *thd)
bool Item_sum::check_sum_func(THD *thd, Item **ref)
{
+ SELECT_LEX *curr_sel= thd->lex->current_select;
+ nesting_map allow_sum_func= (thd->lex->allow_sum_func &
+ curr_sel->name_visibility_map);
bool invalid= FALSE;
- nesting_map allow_sum_func= thd->lex->allow_sum_func;
+ DBUG_ASSERT(curr_sel->name_visibility_map); // should be set already
/*
The value of max_arg_level is updated if an argument of the set function
contains a column reference resolved against a subquery whose level is
@@ -172,7 +183,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
if (!invalid && aggr_level < 0)
{
aggr_level= nest_level;
- aggr_sel= thd->lex->current_select;
+ aggr_sel= curr_sel;
}
/*
By this moment we either found a subquery where the set function is
@@ -309,9 +320,9 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref)
{
SELECT_LEX *sl;
nesting_map allow_sum_func= thd->lex->allow_sum_func;
- for (sl= thd->lex->current_select->master_unit()->outer_select() ;
+ for (sl= thd->lex->current_select->context.outer_select() ;
sl && sl->nest_level > max_arg_level;
- sl= sl->master_unit()->outer_select() )
+ sl= sl->context.outer_select())
{
if (aggr_level < 0 &&
(allow_sum_func & ((nesting_map)1 << sl->nest_level)))
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index a7b840beb03..1af275f9c7f 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -8301,6 +8301,12 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2);
mysql_mutex_lock(&acl_cache->lock);
+ if (!acl_users.elements)
+ {
+ mysql_mutex_unlock(&acl_cache->lock);
+ login_failed_error(mpvio->thd);
+ DBUG_RETURN(1);
+ }
uint i= nr1 % acl_users.elements;
ACL_USER *acl_user_tmp= dynamic_element(&acl_users, i, ACL_USER*);
mpvio->acl_user= acl_user_tmp->copy(mpvio->thd->mem_root);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index fdf53f7b521..14105de9e59 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1917,6 +1917,7 @@ void st_select_lex::init_select()
merged_into= 0;
m_non_agg_field_used= false;
m_agg_func_used= false;
+ name_visibility_map= 0;
}
/*
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 2f3214646de..2af1ddbf39c 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -887,6 +887,9 @@ public:
*/
List<String> *prev_join_using;
+ /* namp of nesting SELECT visibility (for aggregate functions check) */
+ nesting_map name_visibility_map;
+
void init_query();
void init_select();
st_select_lex_unit* master_unit();
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 4d1ae0b79b2..dfaab2a2f92 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -879,7 +879,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array,
if (param->state == Item_param::NO_VALUE)
DBUG_RETURN(1);
- if (param->limit_clause_param && param->item_type != Item::INT_ITEM)
+ if (param->limit_clause_param)
{
param->set_int(param->val_int(), MY_INT64_NUM_DECIMAL_DIGITS);
param->item_type= Item::INT_ITEM;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d3bfc959176..39512034cba 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -19541,7 +19541,8 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
if (!found)
break; // End of file
/* Restart search on saved row */
- error=file->restart_rnd_next(record);
+ if ((error= file->restart_rnd_next(record)))
+ goto err;
}
file->extra(HA_EXTRA_NO_CACHE);