diff options
author | unknown <bell@sanja.is.com.ua> | 2006-04-13 23:12:26 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2006-04-13 23:12:26 +0300 |
commit | 8dbb580748e75c4f516e572f5846041299652bf2 (patch) | |
tree | 7c82180f348f690107af3589ae36aba1cdb889d6 /sql/sql_view.cc | |
parent | 72a803dedf6aac8531c9b79d61f86b74391ed089 (diff) | |
download | mariadb-git-8dbb580748e75c4f516e572f5846041299652bf2.tar.gz |
The check for recursive view definitions added. (BUG#14308)
mysql-test/r/view.result:
BUG#14308 test suite.
mysql-test/t/view.test:
BUG#14308 test suite.
sql/share/errmsg.txt:
New error message about a recursive view.
sql/sql_view.cc:
The check of view recursion.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 39d1ae5c9fb..cdb6c581565 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -771,6 +771,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table) SELECT_LEX *end, *view_select; LEX *old_lex, *lex; Query_arena *arena, backup; + TABLE_LIST *top_view= table->top_table(); int res; bool result; DBUG_ENTER("mysql_make_view"); @@ -798,6 +799,24 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table) DBUG_RETURN(0); } + /* check loop via view definition */ + for (TABLE_LIST *precedent= table->referencing_view; + precedent; + precedent= precedent->referencing_view) + { + if (precedent->view_name.length == table->table_name_length && + precedent->view_db.length == table->db_length && + my_strcasecmp(system_charset_info, + precedent->view_name.str, table->table_name) == 0 && + my_strcasecmp(system_charset_info, + precedent->view_db.str, table->db) == 0) + { + my_error(ER_VIEW_RECURSIVE, MYF(0), + top_view->view_db.str, top_view->view_name.str); + DBUG_RETURN(TRUE); + } + } + /* For now we assume that tables will not be changed during PS life (it will be TRUE as far as we make new table cache). @@ -896,7 +915,6 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table) } if (!res && !thd->is_fatal_error) { - TABLE_LIST *top_view= table->top_table(); TABLE_LIST *view_tables= lex->query_tables; TABLE_LIST *view_tables_tail= 0; TABLE_LIST *tbl; |