Hi Monty,

On Tue, Jun 21, 2016 at 9:30 AM, Michael Widenius <monty@mariadb.org> wrote:

Hi!

>>>>> "Nirbhay" == Nirbhay Choubey <nirbhay@mariadb.com> writes:

<cut>

Nirbhay> ALTER TABLE implementation takes a shortcut for operations not affecting
Nirbhay> .frm files,
Nirbhay> which includes simple RENAMEs. But this is skipped for temp tables and thus
Nirbhay> copying
Nirbhay> always takes place for temp tables.

Nirbhay> The following commit (from 2002) added this exception for temp tables:
Nirbhay> https://github.com/MariaDB/server/commit/a7798dfd0a6472bf65fffc2ade543605e177ff9c

The above old patch is not really working for the current code.

Nirbhay> I have created a patch to also include temp tables to this shortcut :
Nirbhay> https://gist.github.com/nirbhayc/442a0c269ce48b283543cac434aaf44e

This solves the problem of doing a simple rename, but not for things
like:

alter table t1 add column c int, rename to t2;

Which will still produce crashes.

When it comes to last_version, is still vote for that we should be using
THD::rename_temporary_table when renaming temporary tables instead of
doing any handler calls.

Right.
 

Maybe we could move THD::rename_temporary_tables to ha_rename_table to
get all temporary tables handled in one place ?

handler::ha_rename_table() is currently being used only for non-temporary tables at
places which do not support temporary tables like partitions, DDL logs, RENAME
TABLE, etc. So, moving rename_temporary_table to ha_rename_table seem overkill
and possibly inappropriate.

Here's the latest version of patch :
http://lists.askmonty.org/pipermail/commits/2016-June/009477.html

Best,
Nirbhay


Regards,
Monty