-
Chaithra Gopalareddy authored
Problem: Insert with 'on duplicate key update' on a view, crashes the server. Analysis: During an insert on to a view, we do the following: For insert fields and values - 1. Resolve insert values. 2. Resolve insert fields. 3. Check if the fields and values are all from a single table of a view in case of INSERT VALUES. Do not check the same in case of INSERT SELECT, as the values can be read from different table than that of the view. For the update fields (if DUP UPDATE is used) 1. Create a name resolution context with 'table_list' only. 2. Resolve update fields in this context. 3. Check if update fields and values are from the same table as the insert fields. 4. Get the next name resolution context. Concatinate this with the previous one. 5. Resolve update values in this context as we can refer to other tables in the values clause. Note that at step 3(of update fields), we check for 'used_tables map' of update values, without resolving them first. Hence the crash. Fix: At step 3, do not pass the update values to check if its a single table view update, as update values can refer other table. Code has been re-organized to function like check_insert_fields. sql/sql_insert.cc: Do not pass update_values as they are not resolved yet.
d8c9cd70