From 3e4d4a365662bb12a50bdda4e0efd348189f2068 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Dec 2005 12:15:48 +0200 Subject: View creation code fixed to expect empty TABLE_LIST::table pointer (BUG#15096). mysql-test/r/view.result: BUG#15096 test suite. mysql-test/t/view.test: BUG#15096 test suite. sql/sql_view.cc: View placed in a function never get TABLE during view creation, because we have never executed that function in this process. So we should expect empty TABLE_LIST::table pointer. --- sql/sql_view.cc | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'sql/sql_view.cc') diff --git a/sql/sql_view.cc b/sql/sql_view.cc index e03d3b22b89..31c5e5fed0a 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -350,15 +350,6 @@ bool mysql_create_view(THD *thd, */ for (tbl= lex->query_tables; tbl; tbl= tbl->next_global) { - /* is this table temporary and is not view? */ - if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view && - !tbl->schema_table) - { - my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias); - res= TRUE; - goto err; - } - /* is this table view and the same view which we creates now? */ if (tbl->view && strcmp(tbl->view_db.str, view->db) == 0 && @@ -370,11 +361,29 @@ bool mysql_create_view(THD *thd, } /* - Copy the privileges of the underlying VIEWs which were filled by - fill_effective_table_privileges - (they were not copied at derived tables processing) + tbl->table can be NULL when tbl is a placeholder for a view + that is indirectly referenced via a stored function from the + view being created. We don't check these indirectly + referenced views in CREATE VIEW so they don't have table + object. */ - tbl->table->grant.privilege= tbl->grant.privilege; + if (tbl->table) + { + /* is this table temporary and is not view? */ + if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view && + !tbl->schema_table) + { + my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias); + res= TRUE; + goto err; + } + /* + Copy the privileges of the underlying VIEWs which were filled by + fill_effective_table_privileges + (they were not copied at derived tables processing) + */ + tbl->table->grant.privilege= tbl->grant.privilege; + } } /* prepare select to resolve all fields */ -- cgit v1.2.1 From 4202271065969a00c310f832cd496cb6f3c095e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Dec 2005 21:18:12 +0200 Subject: Now we shall store only position (index of first character) of SELECT from query begining, to be independet of query buffer allocation. Correct procedure used to find beginning of the current statement during parsing (BUG#14885). mysql-test/r/view.result: BUG#14885 test suite. mysql-test/t/view.test: BUG#14885 test suite. sql/sp_head.cc: The debug print statement fixed to prevent crash in case of NULL in m_next_cached_sp. sql/sql_lex.h: Now we shall store only position (index of first character) of SELECT from query beginning. sql/sql_view.cc: Position of the SELECT used to output it to .frm. sql/sql_yacc.yy: Now we shall store only position (index of first character) of SELECT from query beginning. Correct procedure used to find beginning of the current statement during parsing. --- sql/sql_view.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sql/sql_view.cc') diff --git a/sql/sql_view.cc b/sql/sql_view.cc index e03d3b22b89..3ca592dfd44 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -641,10 +641,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, /* fill structure */ view->query.str= (char*)str.ptr(); view->query.length= str.length()-1; // we do not need last \0 - view->source.str= thd->lex->create_view_select_start; + view->source.str= thd->query + thd->lex->create_view_select_start; view->source.length= (thd->query_length - - (thd->lex->create_view_select_start - - thd->lex->create_view_start)); + thd->lex->create_view_select_start); view->file_version= 1; view->calc_md5(md5); view->md5.str= md5; -- cgit v1.2.1