| 372 | */ |
| 373 | |
| 374 | static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, |
| 375 | List<Item> &update_fields, |
| 376 | List<Item> &update_values, |
| 377 | bool fields_and_values_from_different_maps, |
| 378 | table_map *map) |
| 379 | { |
| 380 | TABLE *table= insert_table_list->table; |
| 381 | my_bool UNINIT_VAR(autoinc_mark); |
| 382 | enum_sql_command sql_command_save= thd->lex->sql_command; |
| 383 | |
| 384 | table->next_number_field_updated= FALSE; |
| 385 | |
| 386 | if (table->found_next_number_field) |
| 387 | { |
| 388 | /* |
| 389 | Unmark the auto_increment field so that we can check if this is modified |
| 390 | by update_fields |
| 391 | */ |
| 392 | autoinc_mark= bitmap_test_and_clear(table->write_set, |
| 393 | table->found_next_number_field-> |
| 394 | field_index); |
| 395 | } |
| 396 | |
| 397 | thd->lex->sql_command= SQLCOM_UPDATE; |
| 398 | |
| 399 | /* Check the fields we are going to modify */ |
| 400 | if (setup_fields(thd, Ref_ptr_array(), |
| 401 | update_fields, MARK_COLUMNS_WRITE, 0, NULL, 0, |
| 402 | THD_WHERE::UPDATE_CLAUSE)) |
| 403 | { |
| 404 | thd->lex->sql_command= sql_command_save; |
| 405 | return -1; |
| 406 | } |
| 407 | |
| 408 | thd->lex->sql_command= sql_command_save; |
| 409 | |
| 410 | if (insert_table_list->is_view() && |
| 411 | insert_table_list->is_merged_derived() && |
| 412 | check_view_single_update(update_fields, |
| 413 | fields_and_values_from_different_maps ? |
| 414 | (List<Item>*) 0 : &update_values, |
| 415 | insert_table_list, map, false)) |
| 416 | return -1; |
| 417 | |
| 418 | if (table->default_field) |
| 419 | table->mark_default_fields_for_write(FALSE); |
| 420 | |
| 421 | if (table->found_next_number_field) |
| 422 | { |
| 423 | if (bitmap_is_set(table->write_set, |
| 424 | table->found_next_number_field->field_index)) |
| 425 | table->next_number_field_updated= TRUE; |
| 426 | |
| 427 | if (autoinc_mark) |
| 428 | bitmap_set_bit(table->write_set, |
| 429 | table->found_next_number_field->field_index); |
| 430 | } |
| 431 |
no test coverage detected