summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2007-01-18 16:53:49 -0700
committerunknown <malff/marcsql@weblab.(none)>2007-01-18 16:53:49 -0700
commitd4ee8cebf369b0003819f63854063ff7e6161236 (patch)
tree01d98dd220fb4becb883fcc4d6639dfc9cdd78c7 /sql/sql_yacc.yy
parentf7e41baedbaf246e68936c1fbb105b75bf28ae44 (diff)
downloadmariadb-git-d4ee8cebf369b0003819f63854063ff7e6161236.tar.gz
Bug#24562 (ALTER TABLE ... ORDER BY ... with complex expression asserts)
WL#3681 (ALTER TABLE ORDER BY) Before this fix, the ALTER TABLE statement implemented an ORDER BY option with the following characteristics : 1) The order by clause accepts a list of criteria, with optional ASC or DESC keywords 2) Each criteria can be a general expression, involving operators, native functions, stored functions, user defined functions, subselects ... With this fix : 1) has been left unchanged, since it's a de-facto existing feature, that was already present in the code base and partially covered in the test suite. Code coverage for ASC and DESC was missing and has been improved. 2) has been changed to limit the kind of criteria that are permissible: now only a column name is valid. mysql-test/r/alter_table.result: Prevent ALTER TABLE ORDER BY clauses to use general expressions. mysql-test/t/alter_table.test: Prevent ALTER TABLE ORDER BY clauses to use general expressions. sql/sql_yacc.yy: Prevent ALTER TABLE ORDER BY clauses to use general expressions.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy25
1 files changed, 24 insertions, 1 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 30283a47b21..ee57a4d611c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2021,7 +2021,7 @@ alter_list_item:
lex->alter_info.is_simple= 0;
lex->alter_info.flags|= ALTER_OPTIONS;
}
- | order_clause
+ | alter_order_clause
{
LEX *lex=Lex;
lex->alter_info.is_simple= 0;
@@ -3781,6 +3781,29 @@ olap_opt:
;
/*
+ Order by statement in ALTER TABLE
+*/
+
+alter_order_clause:
+ ORDER_SYM BY alter_order_list
+ ;
+
+alter_order_list:
+ alter_order_list ',' alter_order_item
+ | alter_order_item
+ ;
+
+alter_order_item:
+ simple_ident order_dir
+ {
+ THD *thd= YYTHD;
+ bool ascending= ($2 == 1) ? true : false;
+ if (add_order_to_list(thd, $1, ascending))
+ YYABORT;
+ }
+ ;
+
+/*
Order by statement in select
*/