diff options
-rw-r--r-- | mysql-test/r/loaddata.result | 2 | ||||
-rw-r--r-- | mysql-test/t/loaddata.test | 2 | ||||
-rw-r--r-- | sql/sql_load.cc | 18 |
3 files changed, 20 insertions, 2 deletions
diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 2d67d24bedd..6942ec6b332 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -316,7 +316,7 @@ FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' 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 FIELDS ESCAPED BY '\\' diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index aa7be52484e..db21058daea 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -292,7 +292,7 @@ SELECT * FROM v2; DELETE FROM t1; --echo ---error ER_LOAD_DATA_INVALID_COLUMN +--error ER_NONUPDATEABLE_COLUMN LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2 FIELDS ESCAPED BY '\\' TERMINATED BY ',' 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. |