summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-09-29 17:10:17 +0300
committerunknown <bell@sanja.is.com.ua>2004-09-29 17:10:17 +0300
commit40ac8462d5be643fdc4e7397794ae6cb0e5b4f3e (patch)
treeaeac5ada3224a0f38d6477026dfc659193a88437 /sql/table.cc
parentf9ae154da46994d3333166c75466f3cd5ba6653d (diff)
parente05e18606be069b79d44ca004315293cd1ac5ed8 (diff)
downloadmariadb-git-40ac8462d5be643fdc4e7397794ae6cb0e5b4f3e.tar.gz
merge
sql/sql_class.h: Auto merged sql/sql_lex.h: Auto merged sql/sql_update.cc: Auto merged sql/sql_view.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc72
1 files changed, 67 insertions, 5 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 946dbc0766a..77ae3c8a386 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1594,6 +1594,14 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
if (arena)
thd->set_n_backup_item_arena(arena, &backup);
+ if (with_check)
+ {
+ check_option= where->copy_andor_structure(thd);
+ if (with_check == VIEW_CHECK_CASCADED)
+ {
+ check_option= and_conds(check_option, ancestor->check_option);
+ }
+ }
/* Go up to join tree and try to find left join */
for (; tbl; tbl= tbl->embedding)
{
@@ -1611,16 +1619,36 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
}
if (tbl == 0)
{
- /*
- It is conds of JOIN, but it will be stored in st_select_lex::prep_where
- for next reexecution
- */
- *conds= and_conds(*conds, where);
+ if (outer_join)
+ {
+ /*
+ Store WHERE condition to ON expression for outer join, because we
+ can't use WHERE to correctly execute jeft joins on VIEWs and this
+ expression will not be moved to WHERE condition (i.e. will be
+ clean correctly for PS/SP)
+ */
+ on_expr= and_conds(on_expr, where);
+ }
+ else
+ {
+ /*
+ It is conds of JOIN, but it will be stored in
+ st_select_lex::prep_where for next reexecution
+ */
+ *conds= and_conds(*conds, where);
+ }
}
if (arena)
thd->restore_backup_item_arena(arena, &backup);
}
+ /*
+ fix_fields do not need tables, because new are only AND operation and we
+ just need recollect statistics
+ */
+ if (check_option && !check_option->fixed &&
+ check_option->fix_fields(thd, 0, &check_option))
+ goto err;
/* full text function moving to current select */
if (view->select_lex.ftfunc_list->elements)
@@ -1654,6 +1682,40 @@ err:
}
+/*
+ check CHECK OPTION condition
+
+ SYNOPSIS
+ check_option()
+ ignore_failure ignore check option fail
+
+ RETURN
+ VIEW_CHECK_OK OK
+ VIEW_CHECK_ERROR FAILED
+ VIEW_CHECK_SKIP FAILED, but continue
+*/
+
+int st_table_list::view_check_option(THD *thd, bool ignore_failure)
+{
+ if (check_option && check_option->val_int() == 0)
+ {
+ if (ignore_failure)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED),
+ view_db.str, view_name.str);
+ return(VIEW_CHECK_SKIP);
+ }
+ else
+ {
+ my_error(ER_VIEW_CHECK_FAILED, MYF(0), view_db.str, view_name.str);
+ return(VIEW_CHECK_ERROR);
+ }
+ }
+ return(VIEW_CHECK_OK);
+}
+
+
void Field_iterator_view::set(TABLE_LIST *table)
{
ptr= table->field_translation;