summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/sql/table.cc b/sql/table.cc
index bfe5395c3db..e372de57177 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1497,8 +1497,10 @@ void st_table_list::set_ancestor()
SYNOPSIS
st_table_list::setup_ancestor()
- thd - thread handler
- conds - condition of this JOIN
+ thd - thread handler
+ conds - condition of this JOIN
+ check_opt_type - WHITH CHECK OPTION type (VIEW_CHECK_NONE,
+ VIEW_CHECK_LOCAL, VIEW_CHECK_CASCADED)
DESCRIPTION
It is:
@@ -1513,7 +1515,8 @@ void st_table_list::set_ancestor()
1 - error
*/
-bool st_table_list::setup_ancestor(THD *thd, Item **conds)
+bool st_table_list::setup_ancestor(THD *thd, Item **conds,
+ uint8 check_opt_type)
{
Item **transl;
SELECT_LEX *select= &view->select_lex;
@@ -1527,7 +1530,10 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
DBUG_ENTER("st_table_list::setup_ancestor");
if (ancestor->ancestor &&
- ancestor->setup_ancestor(thd, conds))
+ ancestor->setup_ancestor(thd, conds,
+ (check_opt_type == VIEW_CHECK_CASCADED ?
+ VIEW_CHECK_CASCADED :
+ VIEW_CHECK_NONE)))
DBUG_RETURN(1);
if (field_translation)
@@ -1586,23 +1592,26 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
field_translation= transl;
/* TODO: sort this list? Use hash for big number of fields */
- if (where)
+ if (where ||
+ (check_opt_type == VIEW_CHECK_CASCADED &&
+ ancestor->check_option))
{
Item_arena *arena= thd->current_arena, backup;
TABLE_LIST *tbl= this;
if (arena->is_conventional())
arena= 0; // For easier test
- if (!where->fixed && where->fix_fields(thd, ancestor, &where))
+ if (where && !where->fixed && where->fix_fields(thd, ancestor, &where))
goto err;
if (arena)
thd->set_n_backup_item_arena(arena, &backup);
- if (effective_with_check)
+ if (check_opt_type)
{
- check_option= where->copy_andor_structure(thd);
- if (effective_with_check == VIEW_CHECK_CASCADED)
+ if (where)
+ check_option= where->copy_andor_structure(thd);
+ if (check_opt_type == VIEW_CHECK_CASCADED)
{
check_option= and_conds(check_option, ancestor->check_option);
}
@@ -1612,7 +1621,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
check that it is not VIEW in which we insert with INSERT SELECT
(in this case we can't add view WHERE condition to main SELECT_LEX)
*/
- if (!no_where_clause)
+ if (where && !no_where_clause)
{
/* Go up to join tree and try to find left join */
for (; tbl; tbl= tbl->embedding)