Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-03-24 11:08:58+01:00, mskold@stripped +12 -0
temp checkin 2
sql/ha_ndbcluster.cc@stripped, 2007-03-24 11:08:31+01:00, mskold@stripped +108 -42
temp checkin 2
sql/ha_ndbcluster.h@stripped, 2007-03-24 11:08:31+01:00, mskold@stripped +2 -0
temp checkin 2
sql/ha_ndbcluster_binlog.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +10 -3
temp checkin 2
sql/handler.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +2 -2
temp checkin 2
sql/handler.h@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +2 -0
temp checkin 2
sql/mysql_priv.h@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +9 -3
temp checkin 2
sql/sql_base.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +8 -6
temp checkin 2
sql/sql_delete.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +2 -1
temp checkin 2
sql/sql_table.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +20 -15
temp checkin 2
sql/table.cc@stripped, 2007-03-24 11:08:32+01:00, mskold@stripped +13 -8
temp checkin 2
storage/ndb/src/ndbapi/NdbDictionary.cpp@stripped, 2007-03-24 11:08:33+01:00,
mskold@stripped +2 -2
temp checkin 2
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2007-03-24 11:08:33+01:00,
mskold@stripped +1 -1
temp checkin 2
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mskold
# Host: linux.site
# Root: /windows/Linux_space/MySQL/mysql-5.1-wl3627
--- 1.292/sql/handler.cc 2007-03-24 11:09:09 +01:00
+++ 1.293/sql/handler.cc 2007-03-24 11:09:09 +01:00
@@ -2591,7 +2591,7 @@ int ha_create_table(THD *thd, const char
init_tmp_table_share(&share, db, 0, table_name, path);
if (open_table_def(thd, &share, 0) ||
open_table_from_share(thd, &share, "", 0, (uint) READ_ALL, 0, &table,
- TRUE))
+ OTM_CREATE))
goto err;
if (update_create_info)
@@ -2668,7 +2668,7 @@ int ha_create_table_from_engine(THD* thd
{
DBUG_RETURN(3);
}
- if (open_table_from_share(thd, &share, "" ,0, 0, 0, &table, FALSE))
+ if (open_table_from_share(thd, &share, "" ,0, 0, 0, &table, OTM_OPEN))
{
free_table_share(&share);
DBUG_RETURN(3);
--- 1.254/sql/handler.h 2007-03-24 11:09:09 +01:00
+++ 1.255/sql/handler.h 2007-03-24 11:09:09 +01:00
@@ -1643,11 +1643,13 @@ public:
}
virtual int prepare_alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags)
{ DBUG_ASSERT(FALSE); }
virtual int alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags)
{ DBUG_ASSERT(FALSE); }
--- 1.470/sql/mysql_priv.h 2007-03-24 11:09:09 +01:00
+++ 1.471/sql/mysql_priv.h 2007-03-24 11:09:09 +01:00
@@ -115,7 +115,6 @@ enum Derivation
DERIVATION_EXPLICIT= 0
};
-
typedef struct my_locale_st
{
const char *name;
@@ -1204,9 +1203,16 @@ int simple_open_n_lock_tables(THD *thd,T
bool open_and_lock_tables(THD *thd,TABLE_LIST *tables);
bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen);
+
+enum open_table_mode
+{ OTM_OPEN= 0,
+ OTM_CREATE= 1,
+ OTM_ALTER= 2
+};
+
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
const char *table_name, bool link_in_list,
- bool is_alter_table);
+ open_table_mode open_mode);
bool rm_temporary_table(handlerton *base, char *path);
void free_io_cache(TABLE *entry);
void intern_close_table(TABLE *entry);
@@ -1748,7 +1754,7 @@ int open_table_def(THD *thd, TABLE_SHARE
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
uint db_stat, uint prgflag, uint ha_open_flags,
- TABLE *outparam, bool is_create_table);
+ TABLE *outparam, open_table_mode open_mode);
int readfrm(const char *name, const void** data, uint* length);
int writefrm(const char* name, const void* data, uint len);
int closefrm(TABLE *table, bool free_share);
--- 1.375/sql/sql_base.cc 2007-03-24 11:09:09 +01:00
+++ 1.376/sql/sql_base.cc 2007-03-24 11:09:09 +01:00
@@ -2681,7 +2681,7 @@ retry:
HA_TRY_READ_ONLY),
(READ_KEYINFO | COMPUTE_TYPES |
EXTRA_RECORD),
- thd->open_options, entry, FALSE)))
+ thd->open_options, entry, OTM_OPEN)))
{
if (error == 7) // Table def changed
{
@@ -2744,7 +2744,7 @@ retry:
HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
ha_open_options | HA_OPEN_FOR_REPAIR,
- entry, FALSE) || ! entry->file ||
+ entry, OTM_OPEN) || ! entry->file ||
(entry->file->is_crashed() && entry->file->check_and_repair(thd)))
{
/* Give right error message */
@@ -3494,7 +3494,8 @@ void close_tables_for_reopen(THD *thd, T
db database
table_name Table name
link_in_list 1 if table should be linked into thd->temporary_tables
- is_alter_table 1 if table is opened as part of an alter table
+ open_mode One of OTM_OPEN, OTM_CREATE or OTM_ALTER, if OTM_ALTER
+ then only the frm and the TABLE object will be created
NOTES:
Used by alter_table to open a temporary table and when creating
@@ -3507,7 +3508,7 @@ void close_tables_for_reopen(THD *thd, T
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
const char *table_name, bool link_in_list,
- bool is_alter_table)
+ open_table_mode open_mode)
{
TABLE *tmp_table;
TABLE_SHARE *share;
@@ -3517,6 +3518,7 @@ TABLE *open_temporary_table(THD *thd, co
DBUG_ENTER("open_temporary_table");
DBUG_PRINT("enter", ("table: '%s'.'%s' path: '%s'",
db, table_name, path));
+ DBUG_PRINT("info", ("open_mode %u", open_mode));
table_list.db= (char*) db;
table_list.table_name= (char*) table_name;
@@ -3538,12 +3540,12 @@ TABLE *open_temporary_table(THD *thd, co
if (open_table_def(thd, share, 0) ||
open_table_from_share(thd, share, table_name,
- (is_alter_table) ? 0 :
+ (open_mode == OTM_ALTER) ? 0 :
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
HA_GET_INDEX),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
ha_open_options,
- tmp_table, is_alter_table))
+ tmp_table, open_mode))
{
/* No need to lock share->mutex as this is not needed for tmp tables */
free_table_share(share);
--- 1.206/sql/sql_delete.cc 2007-03-24 11:09:09 +01:00
+++ 1.207/sql/sql_delete.cc 2007-03-24 11:09:09 +01:00
@@ -881,7 +881,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST
// We don't need to call invalidate() because this table is not in cache
if ((error= (int) !(open_temporary_table(thd, share->path.str,
share->db.str,
- share->table_name.str, 1, 0))))
+ share->table_name.str, 1,
+ OTM_OPEN))))
(void) rm_temporary_table(table_type, path);
free_table_share(share);
my_free((char*) table,MYF(0));
--- 1.381/sql/sql_table.cc 2007-03-24 11:09:09 +01:00
+++ 1.382/sql/sql_table.cc 2007-03-24 11:09:09 +01:00
@@ -3513,7 +3513,8 @@ bool mysql_create_table_internal(THD *th
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
/* Open table and put in temporary table list */
- if (!(open_temporary_table(thd, path, db, table_name, 1, 0)))
+ if (!(open_temporary_table(thd, path, db, table_name, 1,
+ OTM_OPEN)))
{
(void) rm_temporary_table(create_info->db_type, path);
goto unlock_and_end;
@@ -3906,7 +3907,7 @@ static int prepare_for_repair(THD *thd,
DBUG_RETURN(0); // Can't open frm file
}
- if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE))
+ if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, OTM_OPEN))
{
release_table_share(share, RELEASE_NORMAL);
pthread_mutex_unlock(&LOCK_open);
@@ -4752,7 +4753,8 @@ bool mysql_create_like_table(THD* thd, T
pthread_mutex_unlock(&LOCK_open);
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
- if (err || !open_temporary_table(thd, dst_path, db, table_name, 1, 0))
+ if (err || !open_temporary_table(thd, dst_path, db, table_name, 1,
+ OTM_OPEN))
{
(void) rm_temporary_table(create_info->db_type,
dst_path); /* purecov: inspected */
@@ -5413,22 +5415,26 @@ TABLE *create_altered_table(THD *thd,
my_snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%lx",
tmp_file_prefix, current_pid, thd->thread_id);
- //build_tmptable_filename(thd, tmp_name, sizeof(tmp_name));
+/*
+ build_tmptable_filename(thd, tmp_name, sizeof(tmp_name));
+*/
if (!(altered_create_info= copy_create_info(create_info)))
goto err;
altered_create_info->frm_only= 1;
- /*
+/*
tmp_disable_binlog(thd);
error= mysql_create_table(thd, new_db, tmp_name,
- altered_create_info,fields,keys,1,0,0);
+ altered_create_info,fields,keys,1,0,1);
reenable_binlog(thd);
- */
+*/
error= create_temporary_table(thd, new_db, tmp_name, altered_create_info,
fields, keys, db_change);
+
char path[FN_REFLEN];
build_table_filename(path, sizeof(path), new_db, tmp_name, "",
FN_IS_TMP);
- altered_table= open_temporary_table(thd, path, new_db, tmp_name,1,1);
+ altered_table= open_temporary_table(thd, path, new_db, tmp_name, 1,
+ OTM_ALTER);
DBUG_RETURN(altered_table);
err:
@@ -5454,22 +5460,21 @@ int mysql_fast_or_online_alter_table(THD
{
DBUG_ENTER(" mysql_fast_or_online_alter_table");
int error= 0;
- VOID(pthread_mutex_lock(&LOCK_open));
if ((error= table->file->prepare_alter_table(thd,
altered_table,
+ create_info,
alter_info,
alter_table_flags)))
{
- VOID(pthread_mutex_unlock(&LOCK_open));
goto err;
}
if ((error= table->file->alter_table(thd,
altered_table,
+ create_info,
alter_info,
alter_table_flags)))
{
- VOID(pthread_mutex_unlock(&LOCK_open));
goto err;
}
@@ -5477,7 +5482,7 @@ int mysql_fast_or_online_alter_table(THD
The final .frm file is already created as a temporary file
and will be renamed to the original table name.
*/
-
+ VOID(pthread_mutex_lock(&LOCK_open));
if (mysql_rename_table(NULL,
altered_table->s->db.str, altered_table->s->table_name.str,
table->s->db.str, table->s->table_name.str, FN_FROM_IS_TMP))
@@ -5579,7 +5584,7 @@ bool mysql_alter_table(THD *thd,char *ne
char tablespace[FN_LEN];
char path[FN_REFLEN];
char reg_path[FN_REFLEN+1];
- ha_rows copied,deleted;
+ ha_rows copied= 0,deleted= 0;
uint db_create_options, used_fields;
handlerton *old_db_type, *new_db_type, *save_old_db_type;
legacy_db_type table_type;
@@ -6413,7 +6418,7 @@ view_err:
build_table_filename(path, sizeof(path), new_db, tmp_name, "",
FN_IS_TMP);
/* Open our intermediate table */
- new_table=open_temporary_table(thd, path, new_db, tmp_name,0,0);
+ new_table=open_temporary_table(thd, path, new_db, tmp_name,0, OTM_OPEN);
}
if (!new_table)
goto err1;
@@ -6683,7 +6688,7 @@ end_online:
*/
char path[FN_REFLEN];
build_table_filename(path, sizeof(path), new_db, table_name, "", 0);
- table=open_temporary_table(thd, path, new_db, tmp_name,0,0);
+ table=open_temporary_table(thd, path, new_db, tmp_name, 0, OTM_OPEN);
if (table)
{
intern_close_table(table);
--- 1.270/sql/table.cc 2007-03-24 11:09:09 +01:00
+++ 1.271/sql/table.cc 2007-03-24 11:09:09 +01:00
@@ -1322,6 +1322,9 @@ static int open_binary_frm(THD *thd, TAB
prgflag READ_ALL etc..
ha_open_flags HA_OPEN_ABORT_IF_LOCKED etc..
outparam result table
+ open_mode One of OTM_OPEN|OTM_CREATE|OTM_ALTER
+ if OTM_CREATE some errors are ignore
+ if OTM_ALTER HA_OPEN is not called
RETURN VALUES
0 ok
@@ -1335,7 +1338,7 @@ static int open_binary_frm(THD *thd, TAB
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
uint db_stat, uint prgflag, uint ha_open_flags,
- TABLE *outparam, bool is_create_table)
+ TABLE *outparam, open_table_mode open_mode)
{
int error;
uint records, i, bitmap_size;
@@ -1343,11 +1346,12 @@ int open_table_from_share(THD *thd, TABL
byte *record, *bitmaps;
Field **field_ptr;
DBUG_ENTER("open_table_from_share");
- DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx, create table:%s",
+ DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx, open mode:%s",
share->db.str,
share->table_name.str,
(long) outparam,
- (is_create_table)?"yes":"no"));
+ (open_mode == OTM_OPEN)?"open":
+ ((open_mode == OTM_CREATE)?"create":"alter")));
error= 1;
bzero((char*) outparam, sizeof(*outparam));
@@ -1511,22 +1515,23 @@ int open_table_from_share(THD *thd, TABL
share->partition_info_len,
(uchar*)share->part_state,
share->part_state_len,
- outparam, is_create_table,
+ outparam, (open_mode != OTM_OPEN),
share->default_part_db_type);
outparam->part_info->is_auto_partitioned= share->auto_partitioned;
DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned));
if (!tmp)
- tmp= fix_partition_func(thd, outparam, is_create_table);
+ tmp= fix_partition_func(thd, outparam, (open_mode != OTM_OPEN));
thd->stmt_arena= backup_stmt_arena_ptr;
thd->restore_active_arena(&part_func_arena, &backup_arena);
if (!tmp)
outparam->part_info->item_free_list= part_func_arena.free_list;
if (tmp)
{
- if (is_create_table)
+ if (open_mode == OTM_CREATE)
{
/*
- During CREATE/ALTER TABLE it is ok to receive errors here.
+ During CREATE (could be part of ALTER) it is ok to receive
+ errors here.
It is not ok if it happens during the opening of an frm
file as part of a normal query.
*/
@@ -1552,7 +1557,7 @@ int open_table_from_share(THD *thd, TABL
/* The table struct is now initialized; Open the table */
error= 2;
- if (db_stat)
+ if (db_stat && open_mode != OTM_ALTER)
{
int ha_err;
if ((ha_err= (outparam->file->
--- 1.71/storage/ndb/src/ndbapi/NdbDictionary.cpp 2007-03-24 11:09:09 +01:00
+++ 1.72/storage/ndb/src/ndbapi/NdbDictionary.cpp 2007-03-24 11:09:09 +01:00
@@ -1438,14 +1438,14 @@ int
NdbDictionary::Dictionary::dropTable(const char * name){
return m_impl.dropTable(name);
}
-/*
+
bool
NdbDictionary::Dictionary::supportedAlterTable(const Table & f,
const Table & t)
{
return m_impl.supportedAlterTable(NdbTableImpl::getImpl(f), NdbTableImpl::getImpl(t));
}
-*/
+
int
NdbDictionary::Dictionary::alterTable(const Table & f, const Table & t)
{
--- 1.158/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-03-24 11:09:09 +01:00
+++ 1.159/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-03-24 11:09:09 +01:00
@@ -2315,7 +2315,7 @@ bool NdbDictInterface::supportedAlterTab
NdbTableImpl &impl)
{
Uint32 change_mask;
- return compChangeMask(old_impl, impl, change_mask);
+ return (compChangeMask(old_impl, impl, change_mask) == 0);
}
int NdbDictionaryImpl::alterTable(NdbTableImpl &old_impl,
--- 1.373/sql/ha_ndbcluster.cc 2007-03-24 11:09:09 +01:00
+++ 1.374/sql/ha_ndbcluster.cc 2007-03-24 11:09:09 +01:00
@@ -4716,6 +4716,47 @@ static int create_ndb_column(NDBCOL &col
}
else
col.setAutoIncrement(FALSE);
+
+ switch (field->field_format()) {
+ case(FIELD_FORMAT_TYPE_FIXED):
+ col.setDynamic(false);
+ break;
+ case(FIELD_FORMAT_TYPE_DYNAMIC):
+ col.setDynamic(true);
+ break;
+ case(FIELD_FORMAT_TYPE_DEFAULT):
+ default:
+ if (info->row_type==ROW_TYPE_DEFAULT)
+ switch(field->type()) {
+ case(MYSQL_TYPE_VARCHAR):
+ col.setDynamic(true);
+ break;
+ default:
+ col.setDynamic(false);
+ }
+ else
+ col.setDynamic(info->row_type==ROW_TYPE_DYNAMIC);
+ break;
+ }
+ DBUG_PRINT("info", ("Column %s is declared %s", field->field_name,
(col.getDynamic())?"dynamic":"static"));
+ if (col.getStorageType() == NdbDictionary::Column::StorageTypeDisk)
+ {
+ if (col.getDynamic())
+ {
+ DBUG_PRINT("info", ("Dynamic disk stored column %s changed to static",
field->field_name));
+ col.setDynamic(false);
+ }
+ if (field->field_format() == FIELD_FORMAT_TYPE_DYNAMIC)
+ {
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "DYNAMIC field %s declared with "
+ "STORAGE DISK is not supported, "
+ "field will become STATIC",
+ field->field_name);
+ }
+ }
+
return 0;
}
@@ -4842,46 +4883,6 @@ int ha_ndbcluster::create(const char *na
col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
break;
}
-
- switch (field->field_format()) {
- case(FIELD_FORMAT_TYPE_FIXED):
- col.setDynamic(false);
- break;
- case(FIELD_FORMAT_TYPE_DYNAMIC):
- col.setDynamic(true);
- break;
- case(FIELD_FORMAT_TYPE_DEFAULT):
- default:
- if (info->row_type==ROW_TYPE_DEFAULT)
- switch(field->type()) {
- case(MYSQL_TYPE_VARCHAR):
- col.setDynamic(true);
- break;
- default:
- col.setDynamic(false);
- }
- else
- col.setDynamic(info->row_type==ROW_TYPE_DYNAMIC);
- break;
- }
- DBUG_PRINT("info", ("Column %s is declared %s", field->field_name,
(col.getDynamic())?"dynamic":"static"));
- if (col.getStorageType() == NdbDictionary::Column::StorageTypeDisk)
- {
- if (col.getDynamic())
- {
- DBUG_PRINT("info", ("Dynamic disk stored column %s changed to static",
field->field_name));
- col.setDynamic(false);
- }
- if (field->field_format() == FIELD_FORMAT_TYPE_DYNAMIC)
- {
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "DYNAMIC field %s declared with "
- "STORAGE DISK is not supported, "
- "field will become STATIC",
- field->field_name);
- }
- }
tab.addColumn(col);
if (col.getPrimaryKey())
pk_length += (field->pack_length() + 3) / 4;
@@ -7540,7 +7541,8 @@ int handle_trailing_share(NDB_SHARE *sha
/*
Ndb share has not been released as it should
*/
- DBUG_ASSERT(FALSE);
+ //DBUG_ASSERT(FALSE);
+ DBUG_PRINT("info", ("Detected unreleased share"));
/*
This is probably an error. We can however save the situation
@@ -10593,7 +10595,8 @@ HA_ALTER_FLAGS supported_alter_operation
HA_ADD_INDEX |
HA_DROP_INDEX |
HA_ADD_UNIQUE_INDEX |
- HA_DROP_UNIQUE_INDEX;
+ HA_DROP_UNIQUE_INDEX |
+ HA_ADD_COLUMN;
}
int ha_ndbcluster::check_if_supported_alter(TABLE *altered_table,
@@ -10618,6 +10621,37 @@ int ha_ndbcluster::check_if_supported_al
DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
}
+ if (alter_flags & HA_ADD_COLUMN)
+ {
+ NDBCOL col;
+ Ndb *ndb= get_ndb();
+ NDBDICT *dict= ndb->getDictionary();
+ ndb->setDatabaseName(m_dbname);
+ const NDBTAB *old_tab= m_table;
+ NdbDictionary::Table new_tab= *old_tab;
+ Uint32 id;
+ bool disk_storage= old_tab->getTablespace(&id);
+
+ /* Find the new fields */
+ for (uint i= table->s->fields; i < altered_table->s->fields; i++)
+ {
+ Field *field= altered_table->field[i];
+ DBUG_PRINT("info", ("Found new field %s", field->field_name));
+ DBUG_PRINT("info", ("storage_type %i, field_format %i",
+ (uint) field->field_storage_type(),
+ (uint) field->field_format()));
+ if ((my_errno= create_ndb_column(col, field, create_info)))
+ DBUG_RETURN(my_errno);
+
+ new_tab.addColumn(col);
+ }
+ if (dict->supportedAlterTable(*old_tab, new_tab))
+ {
+ DBUG_PRINT("info", ("Adding column(s) supported"));
+ }
+ else
+ DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
+ }
int pk= 0;
int ai= 0;
for (i= 0; i < table->s->fields; i++)
@@ -10678,10 +10712,12 @@ int ha_ndbcluster::check_if_supported_al
int ha_ndbcluster::prepare_alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags)
{
int error= 0;
+ uint i;
DBUG_ENTER("prepare_alter_table");
DBUG_PRINT("info", ("altered_table %u, alter_info %u, alter_flags 0x%lx",
(uint) altered_table, (uint) alter_info, alter_flags));
@@ -10758,6 +10794,35 @@ int ha_ndbcluster::prepare_alter_table(T
}
}
+ if (alter_flags & HA_ADD_COLUMN)
+ {
+ NDBCOL col;
+ Ndb *ndb= get_ndb();
+ NDBDICT *dict= ndb->getDictionary();
+ ndb->setDatabaseName(m_dbname);
+ const NDBTAB *old_tab= m_table;
+ NdbDictionary::Table new_tab= *old_tab;
+ Uint32 id;
+ bool disk_storage= old_tab->getTablespace(&id);
+
+ /* Find the new fields */
+ for (i= table->s->fields; i < altered_table->s->fields; i++)
+ {
+ Field *field= altered_table->field[i];
+ DBUG_PRINT("info", ("Found new field %s", field->field_name));
+ if ((my_errno= create_ndb_column(col, field, create_info)))
+ DBUG_RETURN(my_errno);
+
+ new_tab.addColumn(col);
+ }
+ if (dict->alterTableGlobal(*old_tab, new_tab))
+ {
+ DBUG_PRINT("info", ("Adding column(s) failed"));
+ error= ndb_to_mysql_error(&dict->getNdbError());
+ goto err;
+ }
+ }
+
err:
DBUG_RETURN(error);
}
@@ -10765,6 +10830,7 @@ int ha_ndbcluster::prepare_alter_table(T
int ha_ndbcluster::alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags)
--- 1.165/sql/ha_ndbcluster.h 2007-03-24 11:09:09 +01:00
+++ 1.166/sql/ha_ndbcluster.h 2007-03-24 11:09:09 +01:00
@@ -796,11 +796,13 @@ static void set_tabname(const char *path
int prepare_alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags);
int alter_table(THD *thd,
TABLE *altered_table,
+ HA_CREATE_INFO *create_info,
HA_ALTER_INFO *alter_info,
HA_ALTER_FLAGS alter_flags);
--- 1.95/sql/ha_ndbcluster_binlog.cc 2007-03-24 11:09:09 +01:00
+++ 1.96/sql/ha_ndbcluster_binlog.cc 2007-03-24 11:09:09 +01:00
@@ -304,7 +304,7 @@ ndbcluster_binlog_open_table(THD *thd, N
DBUG_RETURN(error);
}
if ((error= open_table_from_share(thd, table_share, "", 0 /* fon't allocate buffers */,
- (uint) READ_ALL, 0, table, FALSE)))
+ (uint) READ_ALL, 0, table, OTM_OPEN)))
{
sql_print_error("Unable to open table for %s, error=%d(%d)",
share->key, error, my_errno);
@@ -1553,8 +1553,15 @@ ndb_handle_schema_change(THD *thd, Ndb *
else
{
DBUG_PRINT("info", ("NDBEVENT::TE_ALTER: name changed"));
- DBUG_ASSERT(pOp->tableNameChanged());
- is_rename_table= TRUE;
+ if (pOp->tableNameChanged())
+ is_rename_table= TRUE;
+ else
+ {
+ DBUG_PRINT("info", ("Detected other alter table, ignoring"));
+ is_online_alter_table= TRUE;
+
+ DBUG_RETURN(0);
+ }
}
}
| Thread |
|---|
| • bk commit into 5.1 tree (mskold:1.2341) | Martin Skold | 1 Apr |