List:Internals« Previous MessageNext Message »
From:Zardosht Kasheff Date:September 20 2010 2:44pm
Subject:Re: question on mysql_alter_table
View as plain text  
The MySQL Cluster code base has changed the handler interface and
mysql_alter_table_ to support these functions I list below.

I am trying to port them, and mysql cluster's implementation of
mysql_alter_table to 5.1. However, I want to do it in a way that is
safe, so I do not risk breaking other storage engines. So, the current
mysql_alter_table will become old_mysql_alter_table, and MySQL
Cluster's implementation will be new_mysql_alter_table. I realize
there is a bunch in common between the two functions, but I do not
understand them well enough to just merge them.

Thanks
-Zardosht


  virtual int check_if_supported_alter(TABLE *altered_table,
                                       HA_CREATE_INFO *create_info,
                                       HA_ALTER_FLAGS *alter_flags,
                                       uint table_changes);
  virtual int alter_table_phase1(THD *thd,
                                 TABLE *altered_table,
                                 HA_CREATE_INFO *create_info,
                                 HA_ALTER_INFO *alter_info,
                                 HA_ALTER_FLAGS *alter_flags)
  virtual int alter_table_phase2(THD *thd,
                                 TABLE *altered_table,
                                 HA_CREATE_INFO *create_info,
                                 HA_ALTER_INFO *alter_info,
                                 HA_ALTER_FLAGS *alter_flags)
  virtual int alter_table_phase3(THD *thd, TABLE *table)
  {
    return HA_ERR_UNSUPPORTED;
  }


On Mon, Sep 20, 2010 at 10:35 AM, Konstantin Osipov <kostja@stripped> wrote:
> * Zardosht Kasheff <zardosht@stripped> [10/09/20 11:31]:
>> I am trying to make a change to mysql_alter_table, but I want the
>> change to apply only when the table being altered is created with my
>> storage engine. So, I have two different versions of mysql_alter_table
>> written, one named old_mysql_alter_table, which is the current
>> functionality, and the other is new_mysql_alter_table, which has my
>> changes.
>
> Maybe you could start by telling what exactly it is that you
> want from ALTER that requires a completely new implementation?
>
>> I would like to implement mysql_alter_table as such:
>>     if (use_new) {
>>         bool failed = new_mysql_alter_table(
>>             thd,
>>             new_db,
>>             new_name,
>>             create_info,
>>             table_list,
>>             alter_info,
>>             order_num,
>>             order,
>>             ignore
>>             );
>>     }
>>     else return old_mysql_alter_table(
>>         thd,
>>         new_db,
>>         new_name,
>>         create_info,
>>         table_list,
>>         alter_info,
>>         order_num,
>>         order,
>>         ignore
>>         );
>
>>
>> I do not know how to evaluate use_new. Ideally, I would do something
>> like the following:
>>     ulong alter_flags= 0;
>>     alter_flags= table_list->table->s->db_type() ?
>>
> table_list->table->s->db_type()->alter_table_flags(alter_info->flags)
>> : 0;
>>     bool use_new = (alter_flags & HA_FLAG_THAT_ONLY_MY_ENGINE_HAS)
> ? true:false;
>>
>> The problem is that table_list->table is not yet set, and I do not see
>> how to get easily get access to the table that is about to be altered.
>>
>> Any ideas on how I could solve this problem?
>
> You can only look at the storage engine after the table is opened.
> The table is opened in the beginning of mysql_alter_table().
> Look for open_ltable().
>
>
> --
>
Thread
question on mysql_alter_tableZardosht Kasheff20 Sep
  • Re: question on mysql_alter_tableKonstantin Osipov20 Sep
    • Re: question on mysql_alter_tableZardosht Kasheff20 Sep
  • Re: question on mysql_alter_tableZardosht Kasheff22 Sep
    • Re: question on mysql_alter_tableSergei Golubchik22 Sep
      • Re: question on mysql_alter_tableZardosht Kasheff22 Sep