From 8ab58393c5c9732c032faac3f0d04a4536e5562b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Apr 2004 01:14:32 +0300 Subject: after review PS fixes sql/item_cmpfunc.cc: merged in one if sql/mysql_priv.h: removed unused paremeter of check_one_table_access declaration of new function for SP share code sql/set_var.cc: function descriotion added unneeded parantses removed sql/sql_acl.cc: new parameter to limit number of checked tables for check_grant sql/sql_acl.h: new parameter to limit number of checked tables for check_grant sql/sql_delete.cc: preparation moved in separate function sql/sql_insert.cc: preparation moved in separate function sql/sql_lex.cc: comment style fixed unneeded assignment removed sql/sql_parse.cc: new parameter to limit number of checked tables for check_grant table list manipulation removed (because of above) new precheck function sql/sql_prepare.cc: function rewrited to shere code with sql_prepare.cc flow control fixed sql/sql_show.cc: new parameter to limit number of checked tables for check_grant sql/sql_update.cc: preparation moved in separate function sql/table.h: flag renamed --- sql/sql_insert.cc | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'sql/sql_insert.cc') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cc2ba29dbd8..8185c716228 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -207,19 +207,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, goto abort; } - if (check_insert_fields(thd,table,fields,*values,1) || - setup_tables(insert_table_list) || - setup_fields(thd, 0, insert_table_list, *values, 0, 0, 0) || - (duplic == DUP_UPDATE && - (setup_fields(thd, 0, insert_table_list, update_fields, 0, 0, 0) || - setup_fields(thd, 0, insert_table_list, update_values, 0, 0, 0)))) - goto abort; - if (find_real_table_in_list(table_list->next, - table_list->db, table_list->real_name)) - { - my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); + if (mysql_prepare_insert(thd, table_list, insert_table_list, table, + fields, values, update_fields, + update_values, duplic)) goto abort; - } value_count= values->elements; while ((values= its++)) @@ -438,6 +429,43 @@ abort: } +/* + Prepare items in INSERT statement + + SYNOPSIS + mysql_prepare_update() + thd - thread handler + table_list - global table list + insert_table_list - local table list of INSERT SELECT_LEX + + RETURN VALUE + 0 - OK + -1 - error (message is not sent to user) +*/ +int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, + TABLE_LIST *insert_table_list, TABLE *table, + List &fields, List_item *values, + List &update_fields, List &update_values, + enum_duplicates duplic) +{ + DBUG_ENTER("mysql_prepare_insert"); + if (check_insert_fields(thd, table, fields, *values, 1) || + setup_tables(insert_table_list) || + setup_fields(thd, 0, insert_table_list, *values, 0, 0, 0) || + (duplic == DUP_UPDATE && + (setup_fields(thd, 0, insert_table_list, update_fields, 0, 0, 0) || + setup_fields(thd, 0, insert_table_list, update_values, 0, 0, 0)))) + DBUG_RETURN(-1); + if (find_real_table_in_list(table_list->next, + table_list->db, table_list->real_name)) + { + my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); + DBUG_RETURN(-1); + } + DBUG_RETURN(0); +} + + /* Check if there is more uniq keys after field */ static int last_uniq_key(TABLE *table,uint keynr) -- cgit v1.2.1