| 210 | */ |
| 211 | |
| 212 | static int check_insert_fields(THD *thd, TABLE_LIST *table_list, |
| 213 | List<Item> &fields, List<Item> &values, |
| 214 | bool check_unique, |
| 215 | bool fields_and_values_from_different_maps, |
| 216 | table_map *map) |
| 217 | { |
| 218 | TABLE *table= table_list->table; |
| 219 | DBUG_ENTER("check_insert_fields"); |
| 220 | |
| 221 | if (!table_list->single_table_updatable()) |
| 222 | { |
| 223 | my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT"); |
| 224 | DBUG_RETURN(-1); |
| 225 | } |
| 226 | |
| 227 | if (fields.elements == 0 && values.elements != 0) |
| 228 | { |
| 229 | if (!table) |
| 230 | { |
| 231 | my_error(ER_VIEW_NO_INSERT_FIELD_LIST, MYF(0), |
| 232 | table_list->view_db.str, table_list->view_name.str); |
| 233 | DBUG_RETURN(-1); |
| 234 | } |
| 235 | if (values.elements != table->s->visible_fields) |
| 236 | { |
| 237 | thd->get_stmt_da()->reset_current_row_for_warning(1); |
| 238 | my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L); |
| 239 | DBUG_RETURN(-1); |
| 240 | } |
| 241 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 242 | Field_iterator_table_ref field_it; |
| 243 | field_it.set(table_list); |
| 244 | if (check_grant_all_columns(thd, INSERT_ACL, &field_it)) |
| 245 | DBUG_RETURN(-1); |
| 246 | #endif |
| 247 | /* |
| 248 | No fields are provided so all fields must be provided in the values. |
| 249 | Thus we set all bits in the write set. |
| 250 | */ |
| 251 | bitmap_set_all(table->write_set); |
| 252 | } |
| 253 | else |
| 254 | { // Part field list |
| 255 | SELECT_LEX *select_lex= thd->lex->first_select_lex(); |
| 256 | Name_resolution_context *context= &select_lex->context; |
| 257 | Name_resolution_context_state ctx_state; |
| 258 | int res; |
| 259 | |
| 260 | if (fields.elements != values.elements) |
| 261 | { |
| 262 | thd->get_stmt_da()->reset_current_row_for_warning(1); |
| 263 | my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L); |
| 264 | DBUG_RETURN(-1); |
| 265 | } |
| 266 | |
| 267 | thd->dup_field= 0; |
| 268 | select_lex->no_wrap_view_item= TRUE; |
| 269 |
no test coverage detected