diff --git a/storage/tianmu/core/query_compile.cpp b/storage/tianmu/core/query_compile.cpp index 859df32d7..22c95f251 100644 --- a/storage/tianmu/core/query_compile.cpp +++ b/storage/tianmu/core/query_compile.cpp @@ -1137,7 +1137,9 @@ QueryRouteTo Query::Compile(CompiledQuery *compiled_query, SELECT_LEX *selects_l List_iterator_fast li(*fields); for (Item *item = li++; item; item = li++) { if ((item->type() == Item::Type::FUNC_ITEM) && - (down_cast(item)->functype() == Item_func::Functype::FUNC_SP) && (!sl->is_distinct())) { + ((down_cast(item)->functype() == Item_func::Functype::FUNC_SP) || + (down_cast(item)->functype() == Item_func::Functype::SUSERVAR_FUNC)) && + (!sl->is_distinct())) { sl->add_active_options(SELECT_DISTINCT); sl->join->select_distinct = TRUE; use_tmp_when_no_join = true;