summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2006-04-24 13:32:07 +0300
committerunknown <bell@sanja.is.com.ua>2006-04-24 13:32:07 +0300
commit4cfc649d2564ffda3de451e4f9073b6d1266f596 (patch)
treeb4b53f9873d5ee576a5ea0a905753163cd7fc022 /sql/sql_view.cc
parentc7a5f503420c56522ccc63fdcac80177e00dabb1 (diff)
parent8dc06e0f064194489ab5cb56b11537a822ad844c (diff)
downloadmariadb-git-4cfc649d2564ffda3de451e4f9073b6d1266f596.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-merge-5.1 configure.in: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/view.test: Auto merged sql/item_func.cc: Auto merged sql/sql_view.cc: Auto merged sql/share/errmsg.txt: merge
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 18217094ff7..707a885df99 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -773,6 +773,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");
@@ -800,6 +801,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).
@@ -898,7 +917,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;