summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.home>2007-02-04 16:49:24 +0300
committerunknown <kroki/tomash@moonlight.home>2007-02-04 16:49:24 +0300
commit86b715a79f06d0a276e1e6f72fca3cb384890bfe (patch)
treecde821247e6309cba43e298d83772b32c6021274
parentf65038bd67576e1b53fe99db092431f7fbdc2c41 (diff)
downloadmariadb-git-86b715a79f06d0a276e1e6f72fca3cb384890bfe.tar.gz
BUG#25897: Some queries are no longer possible after a CREATE VIEW
fails The bug was introduced with the push of the fix for bug#20953: after the error on view creation we never reset the error state, so some valid statements would give the same error after that. The solution is to properly reset the error state. mysql-test/r/view.result: Add result for bug#25897: Some queries are no longer possible after a CREATE VIEW fails. mysql-test/t/view.test: Add test case for bug#25897: Some queries are no longer possible after a CREATE VIEW fails. sql/sql_lex.cc: Add st_parsing_options::reset() method, call it from lex_start(). sql/sql_lex.h: Add st_parsing_options::reset() method, call it from constructor.
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/t/view.test18
-rw-r--r--sql/sql_lex.cc11
-rw-r--r--sql/sql_lex.h6
4 files changed, 41 insertions, 4 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index f8584275a5a..649b2827b1b 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3023,4 +3023,14 @@ SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
DROP VIEW v1;
+DROP VIEW IF EXISTS v1;
+SELECT * FROM (SELECT 1) AS t;
+1
+1
+CREATE VIEW v1 AS SELECT * FROM (SELECT 1) AS t;
+ERROR HY000: View's SELECT contains a subquery in the FROM clause
+# Previously the following would fail.
+SELECT * FROM (SELECT 1) AS t;
+1
+1
End of 5.0 tests.
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index a34a1ba117d..a5454b302f1 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2975,4 +2975,22 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
+
+#
+# BUG#25897: Some queries are no longer possible after a CREATE VIEW
+# fails
+#
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+let $query = SELECT * FROM (SELECT 1) AS t;
+
+eval $query;
+--error ER_VIEW_SELECT_DERIVED
+eval CREATE VIEW v1 AS $query;
+--echo # Previously the following would fail.
+eval $query;
+
+
--echo End of 5.0 tests.
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index f14856e23fa..d60bfc9ab4c 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -99,6 +99,16 @@ void lex_free(void)
}
+void
+st_parsing_options::reset()
+{
+ allows_variable= TRUE;
+ allows_select_into= TRUE;
+ allows_select_procedure= TRUE;
+ allows_derived= TRUE;
+}
+
+
/*
This is called before every query that is to be parsed.
Because of this, it's critical to not do too much things here.
@@ -149,6 +159,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex->safe_to_cache_query= 1;
lex->time_zone_tables_used= 0;
lex->leaf_tables_insert= 0;
+ lex->parsing_options.reset();
lex->empty_field_list_on_rset= 0;
lex->select_lex.select_number= 1;
lex->next_state=MY_LEX_START;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 5731e009cb4..eaa907b6ed3 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -866,10 +866,8 @@ struct st_parsing_options
bool allows_select_procedure;
bool allows_derived;
- st_parsing_options()
- : allows_variable(TRUE), allows_select_into(TRUE),
- allows_select_procedure(TRUE), allows_derived(TRUE)
- {}
+ st_parsing_options() { reset(); }
+ void reset();
};