| 2909 | } |
| 2910 | |
| 2911 | static |
| 2912 | my_bool init_key_part_spec(THD *thd, Alter_info *alter_info, |
| 2913 | const handler *file, |
| 2914 | const Key &key, Key_part_spec &kp, |
| 2915 | uint max_key_length, uint max_key_part_length, |
| 2916 | bool *is_hash_field_needed) |
| 2917 | { |
| 2918 | DBUG_ENTER("init_key_part_spec"); |
| 2919 | |
| 2920 | const Lex_ident_column &field_name= kp.field_name; |
| 2921 | Create_field *column= NULL; |
| 2922 | |
| 2923 | for (Create_field &c: alter_info->create_list) |
| 2924 | if (c.field_name.streq(field_name)) |
| 2925 | column= &c; |
| 2926 | |
| 2927 | /* |
| 2928 | Either field is not present or field visibility is > INVISIBLE_USER |
| 2929 | */ |
| 2930 | if (!column || (column->invisible > INVISIBLE_USER && !kp.generated)) |
| 2931 | { |
| 2932 | my_error(ER_KEY_COLUMN_DOES_NOT_EXIST, MYF(0), field_name.str); |
| 2933 | DBUG_RETURN(TRUE); |
| 2934 | } |
| 2935 | |
| 2936 | if (!DBUG_IF("test_invisible_index") |
| 2937 | && column->invisible > INVISIBLE_USER |
| 2938 | && !(column->flags & VERS_SYSTEM_FIELD) && !key.invisible) |
| 2939 | { |
| 2940 | my_error(ER_KEY_COLUMN_DOES_NOT_EXIST, MYF(0), column->field_name.str); |
| 2941 | DBUG_RETURN(TRUE); |
| 2942 | } |
| 2943 | |
| 2944 | const Type_handler *type_handler= column->type_handler(); |
| 2945 | switch(key.type) |
| 2946 | { |
| 2947 | case Key::VECTOR: |
| 2948 | if (type_handler->Key_part_spec_init_vector(&kp, *column)) |
| 2949 | { |
| 2950 | my_error(ER_WRONG_ARGUMENTS, MYF(0), "VECTOR INDEX"); |
| 2951 | DBUG_RETURN(TRUE); |
| 2952 | } |
| 2953 | break; |
| 2954 | case Key::FULLTEXT: |
| 2955 | if (type_handler->Key_part_spec_init_ft(&kp, *column)) |
| 2956 | { |
| 2957 | my_error(ER_BAD_FT_COLUMN, MYF(0), field_name.str); |
| 2958 | DBUG_RETURN(-1); |
| 2959 | } |
| 2960 | break; |
| 2961 | |
| 2962 | case Key::SPATIAL: |
| 2963 | if (type_handler->Key_part_spec_init_spatial(&kp, *column)) |
| 2964 | DBUG_RETURN(TRUE); |
| 2965 | break; |
| 2966 | |
| 2967 | case Key::PRIMARY: |
| 2968 | if (column->vcol_info) |
no test coverage detected