← Back to team overview

maria-developers team mailing list archive

Re: Please review: MDEV-7824 [Bug #68041] Zero date can be inserted in strict no-zero mode through a default value

 

Hi, Alexander!

On Jun 25, Alexander Barkov wrote:
> Hi Sergei,
> 
> >> diff --git a/sql/field_conv.cc b/sql/field_conv.cc
> >> index e31f7c5..14f2947 100644
> >> --- a/sql/field_conv.cc
> >> +++ b/sql/field_conv.cc
> >> @@ -859,7 +859,8 @@ bool memcpy_field_possible(Field *to,Field *from)
> >>             from->charset() == to->charset() &&
> >>             (!sql_mode_for_dates(to->table->in_use) ||
> >>              (from->type()!= MYSQL_TYPE_DATE &&
> >> -            from->type()!= MYSQL_TYPE_DATETIME)) &&
> >> +            from->type()!= MYSQL_TYPE_DATETIME &&
> >> +            from->type()!= MYSQL_TYPE_TIMESTAMP)) &&
> >
> > what is this for - to apply TIME_NO_ZERO_DATE to timestamps?
> 
> Right, this is for CREATE TABLE AS SELECT, like in here:
> 
> set sql_mode=default;
> drop table if exists t1;
> create table t1 (a timestamp);
> insert into t1 values (0);
> set sql_mode='TRADITIONAL';
> drop table if exists t2;
> create table t2 as select * from t1;
> 
> The last statement should fail. It does not fail before the patch.
> 
> This is not strictly DEFAULT. But a very related thing,
> when a wrong value sneaks in going around Field_xxx::store().
> 
> Would you mind if I have this change in this patch?

better not.

it's trivial to put it in a separate commit with "git citool"
if it'd be difficult to extract it - then yes, but mention is
explicitly in the commit comment ("also fixes the case....").

> >> diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
> >> index 0846740..d79fbcc 100644
> >> --- a/sql/share/errmsg-utf8.txt
> >> +++ b/sql/share/errmsg-utf8.txt
> >> @@ -7127,3 +7127,5 @@ ER_ROLE_DROP_EXISTS
> >>           eng "Can't drop role '%-.64s'; it doesn't exist"
> >>   ER_CANNOT_CONVERT_CHARACTER
> >>           eng "Cannot convert '%s' character 0x%-.64s to '%s'"
> >> +ER_INVALID_DEFAULT_VALUE_FOR_FIELD  22007
> >> +        eng "Incorrect default value '%-.128s' for column '%.192s'"
> >
> Do you agree with a new error?

yes, okay.

Regards,
Sergei


Follow ups

References