diff options
author | unknown <bell@sanja.is.com.ua> | 2004-01-20 19:23:28 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-01-20 19:23:28 +0200 |
commit | c3cf3d28209702a521a736daa6f797c2407db715 (patch) | |
tree | 58e31138eff605c80015c3b969fe8ff835561ec8 /sql/sql_update.cc | |
parent | fe21bfb60aaf56796350d3622f906b87e20d5ce8 (diff) | |
parent | 7a1a5cd2d828d67120d10eb623c6c5bd83733260 (diff) | |
download | mariadb-git-c3cf3d28209702a521a736daa6f797c2407db715.tar.gz |
Merge
sql/sql_parse.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/derived.result:
SCCS merged
mysql-test/t/derived.test:
e
merge
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 9fc8d482bfa..8ee00f2bca6 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -434,13 +434,36 @@ int mysql_multi_update(THD *thd, fix_tables_pointers(thd->lex->all_selects_list); select_lex->select_limit= HA_POS_ERROR; + + table_map item_tables= 0, derived_tables= 0; + if (thd->lex->derived_tables) + { + // Assign table map values to check updatability of derived tables + uint tablenr=0; + for (TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first; + table_list; + table_list= table_list->next, tablenr++) + { + table_list->table->map= (table_map) 1 << tablenr; + } + } if (setup_fields(thd, 0, table_list, *fields, 1, 0, 0)) DBUG_RETURN(-1); + if (thd->lex->derived_tables) + { + // Find tables used in items + List_iterator_fast<Item> it(*fields); + Item *item; + while ((item= it++)) + { + item_tables|= item->used_tables(); + } + } /* Count tables and setup timestamp handling */ - for (tl= select_lex->get_table_list() ; tl ; tl=tl->next) + for (tl= select_lex->get_table_list() ; tl ; tl= tl->next) { TABLE *table= tl->table; if (table->timestamp_field) @@ -450,6 +473,18 @@ int mysql_multi_update(THD *thd, if (table->timestamp_field->query_id != thd->query_id) table->time_stamp= table->timestamp_field->offset() +1; } + if (tl->derived) + derived_tables|= table->map; + } + if (thd->lex->derived_tables && (item_tables & derived_tables)) + { + // find derived table which cause error + for (tl= select_lex->get_table_list() ; tl ; tl= tl->next) + { + if (tl->derived && (item_tables & tl->table->map)) + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), tl->alias, "UPDATE"); + } } if (!(result=new multi_update(thd, table_list, fields, values, |