diff options
author | Sreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com> | 2016-12-13 16:41:05 +0530 |
---|---|---|
committer | Sreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com> | 2016-12-13 16:41:05 +0530 |
commit | 30a59a8d78f10f738aef124fe6736851275192bd (patch) | |
tree | 4b91f396230a7ada3a65606083d299df67c49919 /sql | |
parent | d8a7b4d37b47b248cd761f6cd03a625c09f1127c (diff) | |
download | mariadb-git-30a59a8d78f10f738aef124fe6736851275192bd.tar.gz |
Bug #24595937: INCORRECT BEHAVIOR WHEN LOADING DATA TO VIEW
Issue:
------
While using the LOAD statement to insert data into an
updateable view, the check to verify whether a column
is actually updatable is missing.
Solution for 5.5 and 5.6:
-------------------------
For a view whose column-list in specified in the LOAD
command, this check is not performed. This fix adds the
check.
This is a partial backport of Bug#21097485.
Solution for 5.7 and trunk:
---------------------------
For a view whose column-list is specified in the LOAD
command, this check is already performed. This fix adds the
same check when no column-list is specified.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_load.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c084e5e3839..c28c7cdb2db 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -296,6 +296,24 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) || check_that_all_fields_are_given_values(thd, table, table_list)) DBUG_RETURN(TRUE); + + /* + Special updatability test is needed because fields_vars may contain + a mix of column references and user variables. + */ + Item *item; + List_iterator<Item> it(fields_vars); + while ((item= it++)) + { + if ((item->type() == Item::FIELD_ITEM || + item->type() == Item::REF_ITEM) && + item->filed_for_view_update() == NULL) + { + my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name); + DBUG_RETURN(true); + } + } + /* Check whenever TIMESTAMP field with auto-set feature specified explicitly. |