#At file:///home/jonas/src/telco-6.2/
2816 Jonas Oreland 2009-02-12
ndb - bug#42549
Fix alter (online) table wrt storage disk
modified:
mysql-test/suite/ndb/r/ndb_alter_table_online.result
mysql-test/suite/ndb/r/ndb_dd_alter.result
mysql-test/suite/ndb/t/ndb_alter_table_online.test
sql/ha_ndbcluster.cc
sql/sql_table.cc
per-file messages:
mysql-test/suite/ndb/r/ndb_alter_table_online.result
new testcases
mysql-test/suite/ndb/r/ndb_dd_alter.result
fix result set,
these columns are now added as disk-columns, as table has STORAGE DISK
and they are not explicitly given memory storage
mysql-test/suite/ndb/t/ndb_alter_table_online.test
new testcases
sql/ha_ndbcluster.cc
bug#42549
- filter away HA_COLUMN_STORAGE & HA_COLUMN_FORMAT, that are set "weirdly" by
SQL-layer
- "copy" auto-converting keys to memory storage from createTable, so that checks gets
correct
sql/sql_table.cc
bug#42549
copy storage media/tablespace in correct place so that it gets passed down to
storage-engine.
previously it was copied to a temporary create_info struct, that got tossed before
calling
storage engine
=== modified file 'mysql-test/suite/ndb/r/ndb_alter_table_online.result'
--- a/mysql-test/suite/ndb/r/ndb_alter_table_online.result 2008-12-11 10:20:34 +0000
+++ b/mysql-test/suite/ndb/r/ndb_alter_table_online.result 2009-02-12 14:22:34 +0000
@@ -657,6 +657,15 @@ ERROR 42000: This version of MySQL doesn
ALTER ONLINE TABLE t1 ADD COLUMN h VARBINARY(20) COLUMN_FORMAT DYNAMIC;
ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 ADD COLUMN
h VARBINARY(20) COLUMN_FORMAT DYNAMIC'
DROP TABLE t1;
+create table t1 (a int primary key, b int) storage disk tablespace ts1 engine = ndb;
+alter online table t1 add column c0 int null column_format DYNAMIC;
+ERROR 42000: This version of MySQL doesn't yet support 'alter online table t1 add column
c0 int null column_format DYNAMIC'
+alter online table t1 add column c1 int null column_format DYNAMIC storage memory;
+drop table t1;
+create table t1 (a int primary key, b int storage disk) tablespace ts1 engine = ndb;
+alter online table t1 add column c0 int null column_format DYNAMIC;
+alter online table t1 add column c1 int null column_format DYNAMIC storage memory;
+drop table t1;
ALTER TABLESPACE ts1
DROP DATAFILE 'datafile.dat'
ENGINE = NDB;
=== modified file 'mysql-test/suite/ndb/r/ndb_dd_alter.result'
--- a/mysql-test/suite/ndb/r/ndb_dd_alter.result 2007-11-19 12:56:54 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dd_alter.result 2009-02-12 14:22:34 +0000
@@ -316,9 +316,6 @@ SELECT * FROM information_schema.partiti
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts
ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
-Warnings:
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name =
'p0';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts
@@ -345,12 +342,6 @@ a1 a2 a3
19 20.2345 20000019
20 21.2345 20000020
ALTER TABLE test.t1 ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME;
-Warnings:
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
-Warning 1478 Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN
SELECT a1,a2,a3,hex(a4), a5,a6,a7,a8 FROM test.t1 ORDER BY a1;
a1 a2 a3 hex(a4) a5 a6 a7 a8
1 2.2345 20000001 0 1 23457 2006-01-01 07:04:00
=== modified file 'mysql-test/suite/ndb/t/ndb_alter_table_online.test'
--- a/mysql-test/suite/ndb/t/ndb_alter_table_online.test 2008-12-11 10:20:34 +0000
+++ b/mysql-test/suite/ndb/t/ndb_alter_table_online.test 2009-02-12 14:22:34 +0000
@@ -685,6 +685,20 @@ ALTER ONLINE TABLE t1 ADD COLUMN h BINAR
ALTER ONLINE TABLE t1 ADD COLUMN h VARBINARY(20) COLUMN_FORMAT DYNAMIC;
DROP TABLE t1;
+#
+# bug#42549
+#
+create table t1 (a int primary key, b int) storage disk tablespace ts1 engine = ndb;
+--error ER_NOT_SUPPORTED_YET
+alter online table t1 add column c0 int null column_format DYNAMIC;
+alter online table t1 add column c1 int null column_format DYNAMIC storage memory;
+drop table t1;
+
+create table t1 (a int primary key, b int storage disk) tablespace ts1 engine = ndb;
+alter online table t1 add column c0 int null column_format DYNAMIC;
+alter online table t1 add column c1 int null column_format DYNAMIC storage memory;
+drop table t1;
+
ALTER TABLESPACE ts1
DROP DATAFILE 'datafile.dat'
ENGINE = NDB;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-02-10 16:23:13 +0000
+++ b/sql/ha_ndbcluster.cc 2009-02-12 14:22:34 +0000
@@ -10507,6 +10507,16 @@ int ha_ndbcluster::check_if_supported_al
/*
Check that we are only adding columns
*/
+ /*
+ HA_COLUMN_STORAGE & HA_COLUMN_FORMAT
+ are set if they are specified in an later cmd
+ even if they're no change. This is probably a bug
+ conclusion: add them to add_column-mask, so that we silently "accept" them
+ In case of someone trying to change a column, the HA_CHANGE_COLUMN would be set
+ which we don't support, so we will still return HA_ALTER_NOT_SUPPORTED in those
cases
+ */
+ add_column.set_bit(HA_COLUMN_STORAGE);
+ add_column.set_bit(HA_COLUMN_FORMAT);
if ((*alter_flags & ~add_column).is_set())
{
DBUG_PRINT("info", ("Only add column exclusively can be performed on-line"));
@@ -10581,6 +10591,22 @@ int ha_ndbcluster::check_if_supported_al
const NDBCOL *col= tab->getColumn(i);
create_ndb_column(0, new_col, field, create_info);
+
+ /**
+ * This is a "copy" of code in ::create()
+ * that "auto-converts" columns with keys into memory
+ * (unless storage disk is explicitly added)
+ * This is needed to check if getStorageType() == getStorageType() further down
+ */
+ if (field->flags & (PRI_KEY_FLAG | UNIQUE_KEY_FLAG | MULTIPLE_KEY_FLAG))
+ {
+ if (field->field_storage_type() == HA_SM_DISK)
+ {
+ DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
+ }
+ new_col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
+ }
+
if (col->getStorageType() != new_col.getStorageType())
{
DBUG_PRINT("info", ("Column storage media is changed"));
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2009-01-15 07:32:40 +0000
+++ b/sql/sql_table.cc 2009-02-12 14:22:34 +0000
@@ -5816,21 +5816,6 @@ int create_temporary_table(THD *thd,
else
create_info->data_file_name=create_info->index_file_name=0;
- if (new_db_type == old_db_type)
- {
- /*
- Table has not changed storage engine.
- If STORAGE and TABLESPACE have not been changed than copy them
- from the original table
- */
- if (!create_info->tablespace &&
- table->s->tablespace &&
- create_info->default_storage_media == HA_SM_DEFAULT)
- create_info->tablespace= table->s->tablespace;
- if (create_info->default_storage_media == HA_SM_DEFAULT)
- create_info->default_storage_media= table->s->default_storage_media;
- }
-
/*
Create a table with a temporary name.
With create_info->frm_only == 1 this creates a .frm file only.
@@ -6446,6 +6431,22 @@ mysql_prepare_alter_table(THD *thd, TABL
if (table->s->tmp_table)
create_info->options|=HA_LEX_CREATE_TMP_TABLE;
+ if (create_info->db_type == table->s->db_type())
+ {
+ /*
+ Table has not changed storage engine.
+ If STORAGE and TABLESPACE have not been changed than copy them
+ from the original table
+ */
+ if (!create_info->tablespace &&
+ table->s->tablespace &&
+ create_info->default_storage_media == HA_SM_DEFAULT)
+ create_info->tablespace= table->s->tablespace;
+
+ if (create_info->default_storage_media == HA_SM_DEFAULT)
+ create_info->default_storage_media= table->s->default_storage_media;
+ }
+
rc= FALSE;
alter_info->create_list.swap(new_create_list);
alter_info->key_list.swap(new_key_list);
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (jonas:2816) Bug#42549 | Jonas Oreland | 12 Feb 2009 |