Skip to content
  • Praveenkumar Hulakund's avatar
    0780e1a6
    BUG#11747847 - 34280: Create table fails if in NO_ZERO_DATE SQL mode. · 0780e1a6
    Praveenkumar Hulakund authored
    Analysis:
    -----------------
    The behavior of SQL Modes "NO_ZERO_DATE" and "NO_ZERO_IN_DATE" is as below,
    
        NO_ZERO_DATE:
        ------------
            Strict Mode: Do not permit '0000-00-00' or 0 as valid date
    
            Non-strict Mode: Date '0000-00-00' or 0 is accepted but warning is 
                             generated
        NO_ZERO_IN_DATE:
        ----------------
            Strict Mode: Do not accept the dates where year is non-zero and month
                         or day is 0 (e.g. 2012-00-00)
    
            Non-strict Mode: Date having non-zero year and month or day 0 is 
                             accepted but warning is generated.
    
    
        Strict mode: Setting SQL modes STRICT_ALL_TABLES, STRICT_TRANS_TABLES will
                     enable the strict mode.
    
    CREATE TABLE and ALTER TABLE fails in non-strict mode when NO_ZERO_DATE (NO_ZERO_IN_DATE)
    is set and the default value is zero (contains zero month or day).
    
    INSERT and UPDATE statements work properly.
    
    Fix:
    -----------------
    While inserting/updating, flag "abort_on_warning" of THD is set, if strict SQL
    MODE is set. And if NO_ZERO_DATE or NO_ZERO_IN_DATE mode is also set then for
    zero date or zero in (month/day) of date, error will be generated. But for 
    non-strict mode only warning message is generated as "abort_on_warning" is set
    to "false".
    
    "abort_on_warning" flag of THD decides whether to generate warning or error
    for invalid value in NO_ZERO_DATE or NO_ZERO_IN_DATE SQL modes. 
    
    But "abort_on_warning" was not set for the CREATE TABLE and ALTER TABLE statements.
    
    The fix is to set "abort_on_warning" also for these statements.
    
    0780e1a6
    BUG#11747847 - 34280: Create table fails if in NO_ZERO_DATE SQL mode.
    Praveenkumar Hulakund authored
    Analysis:
    -----------------
    The behavior of SQL Modes "NO_ZERO_DATE" and "NO_ZERO_IN_DATE" is as below,
    
        NO_ZERO_DATE:
        ------------
            Strict Mode: Do not permit '0000-00-00' or 0 as valid date
    
            Non-strict Mode: Date '0000-00-00' or 0 is accepted but warning is 
                             generated
        NO_ZERO_IN_DATE:
        ----------------
            Strict Mode: Do not accept the dates where year is non-zero and month
                         or day is 0 (e.g. 2012-00-00)
    
            Non-strict Mode: Date having non-zero year and month or day 0 is 
                             accepted but warning is generated.
    
    
        Strict mode: Setting SQL modes STRICT_ALL_TABLES, STRICT_TRANS_TABLES will
                     enable the strict mode.
    
    CREATE TABLE and ALTER TABLE fails in non-strict mode when NO_ZERO_DATE (NO_ZERO_IN_DATE)
    is set and the default value is zero (contains zero month or day).
    
    INSERT and UPDATE statements work properly.
    
    Fix:
    -----------------
    While inserting/updating, flag "abort_on_warning" of THD is set, if strict SQL
    MODE is set. And if NO_ZERO_DATE or NO_ZERO_IN_DATE mode is also set then for
    zero date or zero in (month/day) of date, error will be generated. But for 
    non-strict mode only warning message is generated as "abort_on_warning" is set
    to "false".
    
    "abort_on_warning" flag of THD decides whether to generate warning or error
    for invalid value in NO_ZERO_DATE or NO_ZERO_IN_DATE SQL modes. 
    
    But "abort_on_warning" was not set for the CREATE TABLE and ALTER TABLE statements.
    
    The fix is to set "abort_on_warning" also for these statements.
    
Loading