maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #08685
Re: [Commits] 6ff2c0a: MDEV-5309 - RENAME TABLE does not check for existence of the table's engine
Hi, Sergey!
On Feb 09, svoj@xxxxxxxxxxx wrote:
> revision-id: 6ff2c0a05155f985484e23bd8611eb95f045907f
> parent(s): f13939061d468a47985dee0268652a6fe2db7862
> committer: Sergey Vojtovich
> branch nick: 10.1
> timestamp: 2015-02-09 16:12:00 +0400
> message:
>
> MDEV-5309 - RENAME TABLE does not check for existence of the table's engine
>
> When RENAME TABLE is executed, it apparently does not check whether the engine
> is available (unlike ALTER TABLE .. RENAME, which does). It means that if the
> engine in question was not loaded on some reason, the table might become
> unusable, since the engine won't know about the change.
>
> With this patch RENAME TABLE fails if storage engine is not available.
....
> diff --git a/sql/sql_table.cc b/sql/sql_table.cc
> index e9a1ae9..f1096da 100644
> --- a/sql/sql_table.cc
> +++ b/sql/sql_table.cc
> @@ -5172,18 +5172,19 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
> error= my_errno;
> (void) file->ha_create_partitioning_metadata(to, from, CHF_RENAME_FLAG);
> }
> - else if (!file || !(error=file->ha_rename_table(from_base, to_base)))
> + else if (!file)
> {
> + error= ER_UNKNOWN_STORAGE_ENGINE;
> + }
> + else if (!(error= file->ha_rename_table(from_base, to_base)))
> + {
> if (!(flags & NO_FRM_RENAME) && rename_file_ext(from,to,reg_ext))
> {
> error= my_errno;
> - if (file)
> - {
> if (error == ENOENT)
> error= 0; // this is ok if file->ha_rename_table() succeeded
> else
> file->ha_rename_table(to_base, from_base); // Restore old file name
> - }
> }
> }
> delete file;
May be you'd rather fix it in the caller? Let's state that the first
argument of mysql_rename_table() can never be NULL.
While mysql_rename_table() is called in many places, the only place
where it can actually get a NULL hton is sql_rename.cc, if
ha_table_exists() returns hton=NULL.
I'd add the check here and simplified mysql_rename_table().
Regards,
Sergei