Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2010 05/10/05 21:33:34 bell@stripped +3 -0
recognification of WITH CHECK OPTION after GROUP BY clause (BUG#9801)
sql/sql_yacc.yy
1.432 05/10/05 21:33:03 bell@stripped +65 -3
recognification of WITH CHECK OPTION after GROUP BY clause
mysql-test/t/view.test
1.115 05/10/05 21:33:03 bell@stripped +22 -0
check syntax
mysql-test/r/view.result
1.123 05/10/05 21:33:03 bell@stripped +16 -0
check syntax
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bell
# Host: sanja.is.com.ua
# Root: /home/bell/mysql/bk/work-bug1-5.0
--- 1.431/sql/sql_yacc.yy 2005-09-23 10:18:52 +03:00
+++ 1.432/sql/sql_yacc.yy 2005-10-05 21:33:03 +03:00
@@ -705,7 +705,7 @@
delete_option opt_temporary all_or_any opt_distinct
opt_ignore_leaves fulltext_options spatial_type union_option
start_transaction_opts opt_chain opt_release
- union_opt select_derived_init option_type2
+ union_opt select_derived_init option_type2 optional_ident_trick
%type <ulong_num>
ulong_num raid_types merge_insert_types
@@ -1266,6 +1266,7 @@
/* first table in list is target VIEW name */
if (!lex->select_lex.add_table_to_list(thd, $7, NULL, 0))
YYABORT;
+ Lex->create_view_check= VIEW_CHECK_NONE;
}
opt_view_list AS select_view_init check_option
{}
@@ -3427,7 +3428,9 @@
lex->sql_command= SQLCOM_CREATE_VIEW;
lex->create_view_mode= VIEW_ALTER;
/* first table in list is target VIEW name */
- lex->select_lex.add_table_to_list(thd, $6, NULL, 0);
+ if (!lex->select_lex.add_table_to_list(thd, $6, NULL, 0))
+ YYABORT;
+ Lex->create_view_check= VIEW_CHECK_NONE;
}
opt_view_list AS select_view_init check_option
{}
@@ -5701,6 +5704,14 @@
| order_ident order_dir
{ if (add_group_to_list(YYTHD, $1,(bool) $2)) YYABORT; };
+/* see comment inside olap_opt */
+optional_ident_trick:
+ /*empty*/
+ { $$= 0; }
+ | ident
+ { $$= 1; }
+ ;
+
olap_opt:
/* empty */ {}
| WITH CUBE_SYM
@@ -5727,6 +5738,57 @@
}
lex->current_select->olap= ROLLUP_TYPE;
}
+ /*
+ Following made for correct recornising:
+ CREATE VIEW ... AS SELECT ... GROUP BY <something> WITH CHECK OPTION
+ yacc read only one token ahead, so after reading GROP BY and having
+ WITH read ahead it go to this rule instead of check_option.
+
+ But we have to recognise WITH CHECK OPTION here only if it is in
+ CREATE VIEW command and this is very last clause in the query.
+ To check that the clause is very last we use optional_ident_trick,
+ which detect ident after clause or force parser to read ahead one
+ token after clause, so we can check yychar on query end.
+ */
+ | WITH remember_name CHECK_SYM OPTION optional_ident_trick
+ {
+ LEX *lex= Lex;
+ if (lex->sql_command != SQLCOM_CREATE_VIEW ||
+ $5 || yychar != END_OF_INPUT)
+ {
+ /* rewind tok_start to get correct syntax error context */
+ lex->tok_start= (uchar*)$2;
+ yyerror(ER(ER_SYNTAX_ERROR));
+ YYABORT;
+ }
+ lex->create_view_check= VIEW_CHECK_CASCADED;
+ }
+ | WITH remember_name CASCADED CHECK_SYM OPTION optional_ident_trick
+ {
+ LEX *lex= Lex;
+ if (lex->sql_command != SQLCOM_CREATE_VIEW ||
+ $6 || yychar != END_OF_INPUT)
+ {
+ /* rewind tok_start to get correct syntax error context */
+ lex->tok_start= (uchar*)$2;
+ yyerror(ER(ER_SYNTAX_ERROR));
+ YYABORT;
+ }
+ lex->create_view_check= VIEW_CHECK_CASCADED;
+ }
+ | WITH remember_name LOCAL_SYM CHECK_SYM OPTION optional_ident_trick
+ {
+ LEX *lex= Lex;
+ if (lex->sql_command != SQLCOM_CREATE_VIEW ||
+ $6 || yychar != END_OF_INPUT)
+ {
+ /* rewind tok_start to get correct syntax error context */
+ lex->tok_start= (uchar*)$2;
+ yyerror(ER(ER_SYNTAX_ERROR));
+ YYABORT;
+ }
+ lex->create_view_check= VIEW_CHECK_LOCAL;
+ }
;
/*
@@ -8988,7 +9050,7 @@
check_option:
/* empty */
- { Lex->create_view_check= VIEW_CHECK_NONE; }
+ { }
| WITH CHECK_SYM OPTION
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
| WITH CASCADED CHECK_SYM OPTION
--- 1.122/mysql-test/r/view.result 2005-10-01 09:35:10 +03:00
+++ 1.123/mysql-test/r/view.result 2005-10-05 21:33:03 +03:00
@@ -2298,3 +2298,19 @@
3
DROP VIEW v1;
DROP TABLE t1;
+create table t1 (s1 int);
+create view v1 as select sum(s1) from t1 with check option;
+ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
+create view v1 as select sum(s1) from t1 group by s1 with check option;
+ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
+create view v1 as select sum(s1) from t1 group by s1 with cascaded check option;
+ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
+create view v1 as select sum(s1) from t1 group by s1 with local check option;
+ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
+create view v1 as select sum(s1) from t1 group by s1 having 1 with check option;
+ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
+create view v1 as select sum(s1) from t1 group by s1 with check option having 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'check option having 1' at
line 1
+select sum(s1) from t1 group by s1 with check option;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'check option' at line 1
+drop table t1;
--- 1.114/mysql-test/t/view.test 2005-10-01 09:35:10 +03:00
+++ 1.115/mysql-test/t/view.test 2005-10-05 21:33:03 +03:00
@@ -2167,3 +2167,25 @@
DROP VIEW v1;
DROP TABLE t1;
+
+#
+# Avoid syntax error if we have GROUP BY as last clause of SELECT in CREATE
+# VIEW and WITH CHECK OPTION clause (BUG#9801)
+#
+create table t1 (s1 int);
+-- error ER_VIEW_NONUPD_CHECK
+create view v1 as select sum(s1) from t1 with check option;
+-- error ER_VIEW_NONUPD_CHECK
+create view v1 as select sum(s1) from t1 group by s1 with check option;
+-- error ER_VIEW_NONUPD_CHECK
+create view v1 as select sum(s1) from t1 group by s1 with cascaded check option;
+-- error ER_VIEW_NONUPD_CHECK
+create view v1 as select sum(s1) from t1 group by s1 with local check option;
+-- error ER_VIEW_NONUPD_CHECK
+create view v1 as select sum(s1) from t1 group by s1 having 1 with check option;
+-- error ER_PARSE_ERROR
+create view v1 as select sum(s1) from t1 group by s1 with check option having 1;
+-- error ER_PARSE_ERROR
+select sum(s1) from t1 group by s1 with check option;
+drop table t1;
+
| Thread |
|---|
| • bk commit into 5.0 tree (bell:1.2010) BUG#9801 | sanja | 5 Oct |