Skip to content
  • Raghav Kapoor's avatar
    42e85b37
    BUG#13995622 - MYSQL SILENTLY REFUSES TO MAKE PRIMARY KEY COLUMN NULL · 42e85b37
    Raghav Kapoor authored
    BUG#15967545 - MISSING ERROR MESSAGE / WARNING WHEN TRYING TO CREATE A PRIMARY KEY WITH NULL VALUE
    BUG#16545198 - NOT REJECTING ALTER TABLE ADD PRIMARY KEY(X), ADD COLUMN X ... DEFAULT NULL
    
    BACKGROUND:
    The crux of the problem reported in the bug report is in the
    current behaviour when we specify NULL for any column that is
    part of a PRIMARY KEY, then the column is implicitly assigned
    a NOT NULL qualifier.
    According to bug requirement, When the user explicitly asks for
    a PRIMARY KEY column to be NULL, that statement should be rejected.
    
    ANALYSIS:
    This implicit assignment of NULL to NOT NULL is done by a parser
    rule in sql_yacc.yy NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }.
    With this rule, we cannot distinguish whether NULL was
    specified explicitly or not. Further down the line we do not
    remember or know if we visited NULL keyword at any point of time.
    
    FIX:
    As a fix for this bug, a new flag EXPLICIT_NULL_FLAG is introduced
    in LEX::type/Create_field::flags bitmaps (similar to NOT_NULL_FLAG).
    The parser rule is modified accordingly. Then later in
    mysql_prepare_create_table() function, while iterating over all
    keys, this flag is used to identify fields participating in
    primary key which were explicitly requested to be nullable (by using
    NULL clause) and appropriate error is emitted.
    
    NOTE:This Patch also fixes problems mentioned in Bug#15967545.
    and Bug#16545198. Additional Test Coverage is added for the reported
    bugs.
    42e85b37
    BUG#13995622 - MYSQL SILENTLY REFUSES TO MAKE PRIMARY KEY COLUMN NULL
    Raghav Kapoor authored
    BUG#15967545 - MISSING ERROR MESSAGE / WARNING WHEN TRYING TO CREATE A PRIMARY KEY WITH NULL VALUE
    BUG#16545198 - NOT REJECTING ALTER TABLE ADD PRIMARY KEY(X), ADD COLUMN X ... DEFAULT NULL
    
    BACKGROUND:
    The crux of the problem reported in the bug report is in the
    current behaviour when we specify NULL for any column that is
    part of a PRIMARY KEY, then the column is implicitly assigned
    a NOT NULL qualifier.
    According to bug requirement, When the user explicitly asks for
    a PRIMARY KEY column to be NULL, that statement should be rejected.
    
    ANALYSIS:
    This implicit assignment of NULL to NOT NULL is done by a parser
    rule in sql_yacc.yy NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }.
    With this rule, we cannot distinguish whether NULL was
    specified explicitly or not. Further down the line we do not
    remember or know if we visited NULL keyword at any point of time.
    
    FIX:
    As a fix for this bug, a new flag EXPLICIT_NULL_FLAG is introduced
    in LEX::type/Create_field::flags bitmaps (similar to NOT_NULL_FLAG).
    The parser rule is modified accordingly. Then later in
    mysql_prepare_create_table() function, while iterating over all
    keys, this flag is used to identify fields participating in
    primary key which were explicitly requested to be nullable (by using
    NULL clause) and appropriate error is emitted.
    
    NOTE:This Patch also fixes problems mentioned in Bug#15967545.
    and Bug#16545198. Additional Test Coverage is added for the reported
    bugs.
Loading