diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2021-01-18 22:31:41 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2021-01-18 22:31:41 +0200 |
commit | 777bda4b7c23312a8931a204a81217e0ceec707d (patch) | |
tree | 6918089577a2f0b55c3c3189b9db0d6a6ce12c2f | |
parent | 7d1afaf09ab63ad724756ab131122f2f138cc0a7 (diff) | |
download | mariadb-git-777bda4b7c23312a8931a204a81217e0ceec707d.tar.gz |
Fix view
-rw-r--r-- | sql/sql_lex.cc | 32 | ||||
-rw-r--r-- | sql/sql_select.cc | 7 |
2 files changed, 28 insertions, 11 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 4b05ee32db3..8cb60c2ab92 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3737,17 +3737,37 @@ void st_select_lex::print_limit(THD *thd, return; } } - // TODO(cvicentiu) limit_params.with_ties requires different printing! if (limit_params.explicit_limit && limit_params.select_limit) { - str->append(STRING_WITH_LEN(" limit ")); - if (limit_params.offset_limit) + /* + [OFFSET n] + FETCH FIRST n ROWS WITH TIES + + For FETCH FIRST n ROWS ONLY we fall back to the "limit" specification + as it's identical. + */ + if (limit_params.with_ties) { - limit_params.offset_limit->print(str, query_type); - str->append(','); + if (limit_params.offset_limit) + { + str->append(STRING_WITH_LEN(" offset ")); + limit_params.offset_limit->print(str, query_type); + } + str->append(STRING_WITH_LEN(" fetch first ")); + limit_params.select_limit->print(str, query_type); + str->append(STRING_WITH_LEN(" rows with ties")); + } + else + { + str->append(STRING_WITH_LEN(" limit ")); + if (limit_params.offset_limit) + { + limit_params.offset_limit->print(str, query_type); + str->append(','); + } + limit_params.select_limit->print(str, query_type); } - limit_params.select_limit->print(str, query_type); } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c01e9ac576f..667e43fb66b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1362,13 +1362,10 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num, { bool real_order= FALSE; ORDER *ord; - /* WITH TIES forces the results to be sorted, even if it's not sortable? */ - // TODO(cvicentiu) -> Check this... + /* WITH TIES forces the results to be sorted, even if it's not sanely + sortable. */ if (select_lex->limit_params.with_ties) - { real_order= true; - alloc_order_fields(this, order); - } for (ord= order; ord; ord= ord->next) { |