diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2016-03-16 19:49:17 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2016-03-18 19:22:13 +0100 |
commit | 4fdac6c07e1b896cbf6060d61b47669a48a1ebc9 (patch) | |
tree | 7026f13b8872fed211e43f9767937eba868ff836 /sql/sql_lex.cc | |
parent | b25373beb52af6de43a70a0883918a0d2fd60c53 (diff) | |
download | mariadb-git-4fdac6c07e1b896cbf6060d61b47669a48a1ebc9.tar.gz |
MDEV-9701: CREATE VIEW with GROUP BY or ORDER BY and constant produces invalid definition
Fixed printing integer constant in the ORDER clause (MySQL solution)
Removed workaround for double resolving counter in the ORDER.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fd841094e68..31fc5f9712c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2689,30 +2689,22 @@ void st_select_lex::print_order(String *str, { if (order->counter_used) { - if (!(query_type & QT_VIEW_INTERNAL)) + char buffer[20]; + size_t length= my_snprintf(buffer, 20, "%d", order->counter); + str->append(buffer, (uint) length); + } + else + { + /* replace numeric reference with equivalent for ORDER constant */ + if (order->item[0]->type() == Item::INT_ITEM && + order->item[0]->basic_const_item()) { - char buffer[20]; - size_t length= my_snprintf(buffer, 20, "%d", order->counter); - str->append(buffer, (uint) length); + /* make it expression instead of integer constant */ + str->append(STRING_WITH_LEN("''")); } else - { - /* replace numeric reference with expression */ - if (order->item[0]->type() == Item::INT_ITEM && - order->item[0]->basic_const_item()) - { - char buffer[20]; - size_t length= my_snprintf(buffer, 20, "%d", order->counter); - str->append(buffer, (uint) length); - /* make it expression instead of integer constant */ - str->append(STRING_WITH_LEN("+0")); - } - else - (*order->item)->print(str, query_type); - } + (*order->item)->print(str, query_type); } - else - (*order->item)->print(str, query_type); if (!order->asc) str->append(STRING_WITH_LEN(" desc")); if (order->next) |