maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #08537
Re: Please review: MDEV-7824 [Bug #68041] Zero date can be inserted in strict no-zero mode through a default value
Hi, Alexander!
On Mar 25, Alexander Barkov wrote:
> Hi Sergei,
>
> Please review a patch for mdev-7824.
>
> It's based on a MySQL patch for
> http://bugs.mysql.com/bug.php?id=68041
>
> and is a blocker for:
>
> MDEV-3929 Add full support for auto-initialized/updated timestamp and
> datetime
That looks good.
But I don't like it that you verify defaults for every row.
It's not very cheap. And neither defaults nor sql_mode can change in the
duration of one statement. It should be enough to test only once.
I'm not sure, though, how to do that with a minimal overhead. A couple
of bool's in TABLE, like
bool all_default_are_checked;
bool write_set_defaults_are_checked;
that are set to false at the beginning on INSERT,INSERT...SELECT,LOAD.
And used like that
bool TABLE::restore_record_and_validate_unset_fields(THD *thd, bool all)
{
restore_record(this, s->default_values);
if (all ? all_default_are_checked : write_set_defaults_are_checked)
return false;
if (all) all_default_are_checked= true;
else write_set_defaults_are_checked= true;
return validate_default_values_of_unset_fields(thd);
}
and in mysql_insert():
if (fields.elements || !value_count)
{
if (table->restore_record_and_validate_unset_fields(thd, !value_count))
Regards,
Sergei
Follow ups
References