List:Internals« Previous MessageNext Message »
From:Marko Mäkelä Date:September 19 2007 6:35pm
Subject:Re: New online alter table interface [Re: Adding new funtions to
handler interface]
View as plain text  
Martin,

On Wed, Sep 19, 2007 at 04:32:22PM +0200, Martin Skold wrote:
> Hi!
>
> The new on-line alter table interface is now in mysql-5.2 source tree, see 
> below.
> Note also that there is a syntax extension to ALTER TABLE:
> ALTER [ONLINE | OFFLINE] TABLE ...
> where ALTER ONLINE will fail if the storage engine doesn't support this
> operation on-line, and ALTER OFFLINE will always copy the table.

Online index creation usually means that the data in the table may be
updated while the index is being created.  InnoDB does not support that,
but it also does not need to copy the table.  It locks the table in
share mode when creating indexes.  (The table will be locked in exclusive
mode when creating a PRIMARY KEY.)

In the code excerpt that you attached, I could not find anything that
would temporarily disable an index.  In online index creation, one would
probably want to disable the use of the index until it has been
fully created.

Also, InnoDB will have to disable a newly created index from old
transactions, because it does not copy the history (delete-marked
records and such) when creating an index.  We asked for a virtual
method in class handler, but it wasn't implemented in 5.1:

        /** Check if an index can be used by this transaction.
        * @param keynr  key number to check
        * @return       true if available, false if the index
        *               does not contain old records that exist
        *               in the read view of this transaction */
        virtual bool is_index_available(uint keynr) { return true; }

Can you please implement this or a similar method in 5.2 and make the
query optimizer use it?

Best regards,

	Marko Mäkelä
	Innobase Oy/Oracle Corp.
Thread
Adding new funtions to handler interfaceJan Lindström6 Mar
  • Re: Adding new funtions to handler interfaceMartin Skold6 Mar
    • Re: Adding new funtions to handler interfaceJan Lindström8 Mar
    • New online alter table interface [Re: Adding new funtions to handlerinterface]Martin Skold19 Sep
      • Re: New online alter table interface [Re: Adding new funtions tohandler interface]Marko Mäkelä19 Sep
        • RE: New online alter table interface [Re: Adding new funtions tohandler interface]Rick James19 Sep
        • Re: New online alter table interface [Re: Adding new funtions tohandler interface]Martin Skold20 Sep