summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-12-01 12:15:48 +0200
committerunknown <bell@sanja.is.com.ua>2005-12-01 12:15:48 +0200
commit3e4d4a365662bb12a50bdda4e0efd348189f2068 (patch)
treed8ad4630eda7ed269411d8a99090a93dd775f24c /sql/sql_view.cc
parenta6e90ad94221c4d2e92f034b60173b030760f2cc (diff)
downloadmariadb-git-3e4d4a365662bb12a50bdda4e0efd348189f2068.tar.gz
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.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc35
1 files changed, 22 insertions, 13 deletions
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 */