diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-06 13:28:06 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-06 13:28:06 +0300 |
commit | a72f90bc43a809e6678e1343a1ee760878061be3 (patch) | |
tree | 16fe2efa0a3d5e40e00972a1dc3bc4e13f71170c /sql/sql_select.cc | |
parent | ba678eef7de4a8c5fbea07928b87fef84765f22b (diff) | |
parent | b38ef2b5f7bc231b63b770c28688ee9f0109c88b (diff) | |
download | mariadb-git-a72f90bc43a809e6678e1343a1ee760878061be3.tar.gz |
Merge next-mr -> next-4284.
mysql-test/t/disabled.def:
Restore disabled ssl tests: SSL certificates were updated.
Disable sp_sync.test, the test case can't work in next-4284.
mysql-test/t/partition_innodb.test:
Disable parsing of the test case for Bug#47343,
the test can not work in next-4284.
mysql-test/t/ps_ddl.test:
Update results (CREATE TABLE IF NOT EXISTS takes
into account existence of the temporary table).
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c412cf5124f..3ee973557db 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -522,7 +522,7 @@ JOIN::prepare(Item ***rref_pointer_array, thd->lex->allow_sum_func= save_allow_sum_func; } - if (!thd->lex->view_prepare_mode) + if (!thd->lex->view_prepare_mode && !(select_options & SELECT_DESCRIBE)) { Item_subselect *subselect; /* Is it subselect? */ @@ -542,13 +542,26 @@ JOIN::prepare(Item ***rref_pointer_array, if (order) { + bool real_order= FALSE; ORDER *ord; for (ord= order; ord; ord= ord->next) { Item *item= *ord->item; + /* + Disregard sort order if there's only "{VAR}CHAR(0) NOT NULL" fields + there. Such fields don't contain any data to sort. + */ + if (!real_order && + (item->type() != Item::FIELD_ITEM || + ((Item_field *) item)->field->maybe_null() || + ((Item_field *) item)->field->sort_length())) + real_order= TRUE; + if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) item->split_sum_func(thd, ref_pointer_array, all_fields); } + if (!real_order) + order= NULL; } if (having && having->with_sum_func) @@ -945,6 +958,7 @@ JOIN::optimize() DBUG_PRINT("info",("Select tables optimized away")); zero_result_cause= "Select tables optimized away"; tables_list= 0; // All tables resolved + const_tables= tables; /* Extract all table-independent conditions and replace the WHERE clause with them. All other conditions were computed by opt_sum_query @@ -3659,20 +3673,20 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array, cond_func=(Item_func_match *)cond; else if (func->arg_count == 2) { - Item_func *arg0=(Item_func *)(func->arguments()[0]), - *arg1=(Item_func *)(func->arguments()[1]); - if (arg1->const_item() && - arg0->type() == Item::FUNC_ITEM && - arg0->functype() == Item_func::FT_FUNC && + Item *arg0=(Item *)(func->arguments()[0]), + *arg1=(Item *)(func->arguments()[1]); + if (arg1->const_item() && arg1->cols() == 1 && + arg0->type() == Item::FUNC_ITEM && + ((Item_func *) arg0)->functype() == Item_func::FT_FUNC && ((functype == Item_func::GE_FUNC && arg1->val_real() > 0) || (functype == Item_func::GT_FUNC && arg1->val_real() >=0))) - cond_func=(Item_func_match *) arg0; + cond_func= (Item_func_match *) arg0; else if (arg0->const_item() && - arg1->type() == Item::FUNC_ITEM && - arg1->functype() == Item_func::FT_FUNC && + arg1->type() == Item::FUNC_ITEM && + ((Item_func *) arg1)->functype() == Item_func::FT_FUNC && ((functype == Item_func::LE_FUNC && arg0->val_real() > 0) || (functype == Item_func::LT_FUNC && arg0->val_real() >=0))) - cond_func=(Item_func_match *) arg1; + cond_func= (Item_func_match *) arg1; } } else if (cond->type() == Item::COND_ITEM) @@ -7170,6 +7184,7 @@ static void update_depend_map(JOIN *join, ORDER *order) table_map depend_map; order->item[0]->update_used_tables(); order->depend_map=depend_map=order->item[0]->used_tables(); + order->used= 0; // Not item_sum(), RAND() and no reference to table outside of sub select if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT)) && !order->item[0]->with_sum_func) |