• Nikita Malyavin's avatar
    MDEV-22506 Malformed error message for ER_KEY_CONTAINS_PERIOD_FIELDS · e618f7e9
    Nikita Malyavin authored
    Though this is an error message task, the problem was deep in the
    `mysql_prepare_create_table` implementation. The problem is described as
    follows:
    
    1. `append_system_key_parts` was called before
    `mysql_prepare_create_table`, though key name generation was done close to
    the latest stage of the latter.
    2. We can't move `append_system_key_parts` in the end, because system keys
    should be appended before some checks done.
    3. If the checks from `append_system_key_parts` are moved to the end of
    `mysql_prepare_create_table`, then some other inappropriate errors are
    issued. like `ER_DUP_FIELDNAME`.
    
    To have key name specified in error message, name generation should be done
    before the checks, which consequenced in more changes.
    
    The final design for key initialization in `mysql_prepare_create_table`
    follows. The initialization is done in three phases:
    1. Calculate a total number of keys created with respect to keys ignored.
     Allocate KEY* buffer.
    2. Generate unique names; calculate a total number of key parts.
     Make early checks. Allocate KEY_PART_INFO* buffer.
    3. Initialize key parts, make the rest of the checks.
    e618f7e9
overlaps.result 14.5 KB