| 340 | */ |
| 341 | |
| 342 | bool check_sequence_fields(LEX *lex, List<Create_field> *fields, |
| 343 | const LEX_CSTRING db, const LEX_CSTRING table_name) |
| 344 | { |
| 345 | Create_field *field; |
| 346 | List_iterator_fast<Create_field> it(*fields); |
| 347 | uint field_count; |
| 348 | uint field_no; |
| 349 | const char *reason; |
| 350 | Sequence_row_definition row_structure; |
| 351 | DBUG_ENTER("check_sequence_fields"); |
| 352 | |
| 353 | field_count= fields->elements; |
| 354 | if (!field_count) |
| 355 | { |
| 356 | reason= my_get_err_msg(ER_SEQUENCE_TABLE_HAS_WRONG_NUMBER_OF_COLUMNS); |
| 357 | goto err; |
| 358 | } |
| 359 | if (!sequence_definition::is_allowed_value_type( |
| 360 | fields->head()->type_handler()->field_type())) |
| 361 | { |
| 362 | reason= fields->head()->field_name.str; |
| 363 | goto err; |
| 364 | } |
| 365 | row_structure= sequence_structure(fields->head()->type_handler()); |
| 366 | if (field_count != array_elements(row_structure.fields)-1) |
| 367 | { |
| 368 | reason= my_get_err_msg(ER_SEQUENCE_TABLE_HAS_WRONG_NUMBER_OF_COLUMNS); |
| 369 | goto err; |
| 370 | } |
| 371 | if (lex->alter_info.key_list.elements > 0) |
| 372 | { |
| 373 | reason= my_get_err_msg(ER_SEQUENCE_TABLE_CANNOT_HAVE_ANY_KEYS); |
| 374 | goto err; |
| 375 | } |
| 376 | if (lex->alter_info.check_constraint_list.elements > 0) |
| 377 | { |
| 378 | reason= my_get_err_msg(ER_SEQUENCE_TABLE_CANNOT_HAVE_ANY_CONSTRAINTS); |
| 379 | goto err; |
| 380 | } |
| 381 | if (lex->alter_info.flags & ALTER_ORDER) |
| 382 | { |
| 383 | reason= my_get_err_msg(ER_SEQUENCE_TABLE_ORDER_BY); |
| 384 | goto err; |
| 385 | } |
| 386 | |
| 387 | for (field_no= 0; (field= it++); field_no++) |
| 388 | { |
| 389 | const Sequence_field_definition *field_def= &row_structure.fields[field_no]; |
| 390 | if (!field->field_name.streq(Lex_cstring_strlen(field_def->field_name)) || |
| 391 | field->flags != field_def->flags || |
| 392 | field->type_handler() != field_def->type_handler || |
| 393 | field->check_constraint || field->vcol_info) |
| 394 | { |
| 395 | reason= field->field_name.str; |
| 396 | goto err; |
| 397 | } |
| 398 | } |
| 399 | DBUG_RETURN(FALSE); |
no test coverage detected