| 570 | */ |
| 571 | |
| 572 | enum_ident_name_check check_table_name(const char *name, size_t length, |
| 573 | bool check_for_path_chars) |
| 574 | { |
| 575 | // name length in symbols |
| 576 | size_t name_length= 0; |
| 577 | const char *end= name+length; |
| 578 | if (!length || length > NAME_LEN) |
| 579 | return IDENT_NAME_WRONG; |
| 580 | #if defined(USE_MB) && defined(USE_MB_IDENT) |
| 581 | bool last_char_is_space= FALSE; |
| 582 | #else |
| 583 | if (name[length-1]==' ') |
| 584 | return IDENT_NAME_WRONG; |
| 585 | #endif |
| 586 | |
| 587 | while (name != end) |
| 588 | { |
| 589 | #if defined(USE_MB) && defined(USE_MB_IDENT) |
| 590 | last_char_is_space= my_isspace(system_charset_info, *name); |
| 591 | if (use_mb(system_charset_info)) |
| 592 | { |
| 593 | int len=my_ismbchar(system_charset_info, name, end); |
| 594 | if (len) |
| 595 | { |
| 596 | name += len; |
| 597 | name_length++; |
| 598 | continue; |
| 599 | } |
| 600 | } |
| 601 | #endif |
| 602 | if (check_for_path_chars && |
| 603 | (*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR)) |
| 604 | return IDENT_NAME_WRONG; |
| 605 | name++; |
| 606 | name_length++; |
| 607 | } |
| 608 | #if defined(USE_MB) && defined(USE_MB_IDENT) |
| 609 | if (last_char_is_space) |
| 610 | return IDENT_NAME_WRONG; |
| 611 | else if (name_length > NAME_CHAR_LEN) |
| 612 | return IDENT_NAME_TOO_LONG; |
| 613 | #endif |
| 614 | return IDENT_NAME_OK; |
| 615 | } |
| 616 | |
| 617 | |
| 618 | bool check_column_name(const char *name) |
no outgoing calls
no test coverage detected