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.
This commit is contained in:
parent
d8a7b4d37b
commit
30a59a8d78
@ -316,7 +316,7 @@ FIELDS ESCAPED BY '\\'
|
|||||||
TERMINATED BY ','
|
TERMINATED BY ','
|
||||||
ENCLOSED BY '"'
|
ENCLOSED BY '"'
|
||||||
LINES TERMINATED BY '\n' (c0, c2);
|
LINES TERMINATED BY '\n' (c0, c2);
|
||||||
ERROR HY000: Invalid column reference (v2.c0) in LOAD DATA
|
ERROR HY000: Column 'c0' is not updatable
|
||||||
|
|
||||||
LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v3
|
LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v3
|
||||||
FIELDS ESCAPED BY '\\'
|
FIELDS ESCAPED BY '\\'
|
||||||
|
@ -292,7 +292,7 @@ SELECT * FROM v2;
|
|||||||
DELETE FROM t1;
|
DELETE FROM t1;
|
||||||
|
|
||||||
--echo
|
--echo
|
||||||
--error ER_LOAD_DATA_INVALID_COLUMN
|
--error ER_NONUPDATEABLE_COLUMN
|
||||||
LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2
|
LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2
|
||||||
FIELDS ESCAPED BY '\\'
|
FIELDS ESCAPED BY '\\'
|
||||||
TERMINATED BY ','
|
TERMINATED BY ','
|
||||||
|
@ -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) ||
|
setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) ||
|
||||||
check_that_all_fields_are_given_values(thd, table, table_list))
|
check_that_all_fields_are_given_values(thd, table, table_list))
|
||||||
DBUG_RETURN(TRUE);
|
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
|
Check whenever TIMESTAMP field with auto-set feature specified
|
||||||
explicitly.
|
explicitly.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user