List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:February 17 2012 3:57pm
Subject:bzr push into mysql-5.1-telco-7.1 branch (frazer.clement:4451 to 4452)
View as plain text  
 4452 Frazer Clement	2012-02-17
      Test commit2 for Blob reorg

    added:
      mysql-test/suite/ndb/include/ndb_desc_partition.inc
    modified:
      mysql-test/suite/ndb/r/ndb_add_partition.result
      mysql-test/suite/ndb/t/ndb_add_partition.test
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
 4451 Frazer Clement	2012-01-31 [merge]
      Merge 7.0->7.1

    modified:
      sql/ndb_conflict.cc
      sql/ndb_conflict.h
=== added file 'mysql-test/suite/ndb/include/ndb_desc_partition.inc'
--- a/mysql-test/suite/ndb/include/ndb_desc_partition.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/include/ndb_desc_partition.inc	2012-02-17 15:53:48 +0000
@@ -0,0 +1,72 @@
+#
+# ndb_desc_partition.inc
+#
+# Helper include to describe partitioning of table test.t3 and its
+# two blob part tables for columns 1 + 2
+# Could be made generic for any table/database + blob columns
+#
+--disable_query_log
+--disable_result_log
+--exec $NDB_SHOW_TABLES > $MYSQLTEST_VARDIR/tmp/ndb_show_tables.txt
+# Needed for embedded
+--chmod 0777 $MYSQLTEST_VARDIR/tmp/ndb_show_tables.txt
+
+create table outputrows (txt varchar(1000));
+
+--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_show_tables.txt' into table outputrows columns terminated by '\n';
+
+eval select @table_id:= trim(left(txt, INSTR(txt, ' '))) from outputrows where txt like '%UserTable%test%t3';
+
+drop table outputrows;
+--remove_file $MYSQLTEST_VARDIR/tmp/ndb_show_tables.txt
+
+
+--eval select @blob_1_table:= concat('NDB\\\\\$BLOB_', @table_id, '_1');
+--eval select @blob_2_table:= concat('NDB\\\\\$BLOB_', @table_id, '_2');
+
+let $blob_1_table= query_get_value('select @blob_1_table as v',v,1);
+let $blob_2_table= query_get_value('select @blob_2_table as v',v,1);
+
+#--echo $blob_1_table
+#--echo $blob_2_table
+
+--exec $NDB_DESC -dtest t3 -p > $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+create table outputrows (txt varchar(1000));
+--chmod 0777 $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_desc.txt' into table outputrows columns terminated by '\n';
+--enable_result_log
+select txt as T3_FragmentCount from outputrows where txt like 'FragmentCount%';
+--disable_result_log
+drop table outputrows;
+--remove_file $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+--exec $NDB_DESC -dtest $blob_1_table -p > $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+create table outputrows (txt varchar(1000));
+--chmod 0777 $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_desc.txt' into table outputrows columns terminated by '\n';
+--enable_result_log
+select txt as BLOB1_FragmentCount from outputrows where txt like 'FragmentCount%';
+--disable_result_log
+drop table outputrows;
+--remove_file $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+--exec $NDB_DESC -dtest $blob_2_table -p > $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+create table outputrows (txt varchar(1000));
+--chmod 0777 $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_desc.txt' into table outputrows columns terminated by '\n';
+--enable_result_log
+select txt as BLOB2_FragmentCount from outputrows where txt like 'FragmentCount%';
+--disable_result_log
+drop table outputrows;
+--remove_file $MYSQLTEST_VARDIR/tmp/ndb_desc.txt
+
+
+#--exec $NDB_DESC -dtest t3 -p
+#--exec $NDB_DESC -dtest $blob_1_table -p
+#--exec $NDB_DESC -dtest $blob_2_table -p
+
+--enable_result_log
+--enable_query_log
\ No newline at end of file

=== modified file 'mysql-test/suite/ndb/r/ndb_add_partition.result'
--- a/mysql-test/suite/ndb/r/ndb_add_partition.result	2011-05-12 11:31:21 +0000
+++ b/mysql-test/suite/ndb/r/ndb_add_partition.result	2012-02-17 15:53:48 +0000
@@ -24,6 +24,12 @@ ENGINE = NDB
 STORAGE DISK
 TABLESPACE ts1
 partition by key(a);
+CREATE TABLE t3 (a int unsigned not null,
+b text not null,
+c text not null,
+primary key(a))
+ENGINE=NDB
+partition by key(a);
 INSERT INTO t1 VALUES
 (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
 (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
@@ -45,13 +51,23 @@ INSERT INTO t1 VALUES
 (86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90),
 (91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95),
 (96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100);
+T3_FragmentCount
+FragmentCount: 2
+BLOB1_FragmentCount
+FragmentCount: 2
+BLOB2_FragmentCount
+FragmentCount: 2
 insert into t2 select * from t1;
+insert into t3 select a, repeat(a, 20000), repeat(a, 20000) from t1;
 select count(*) from t1;
 count(*)
 100
 select count(*) from t2;
 count(*)
 100
+select count(*) from t3;
+count(*)
+100
 select * from t1 where a < 20;
 a	b	c
 1	1	1
@@ -142,22 +158,75 @@ a	b	c
 select * from t2 where b = 50;
 a	b	c
 50	50	50
+select a, length(b), length(c) from t3 where a < 20;
+a	length(b)	length(c)
+1	20000	20000
+10	40000	40000
+11	40000	40000
+12	40000	40000
+13	40000	40000
+14	40000	40000
+15	40000	40000
+16	40000	40000
+17	40000	40000
+18	40000	40000
+19	40000	40000
+2	20000	20000
+3	20000	20000
+4	20000	20000
+5	20000	20000
+6	20000	20000
+7	20000	20000
+8	20000	20000
+9	20000	20000
+select a, length(b), length(c) from t3 where a = 20;
+a	length(b)	length(c)
+20	40000	40000
+select a, length(b), length(c) from t3 where a = 30;
+a	length(b)	length(c)
+30	40000	40000
+select a, length(b), length(c) from t3 where a = 40;
+a	length(b)	length(c)
+40	40000	40000
+select a, length(b), length(c) from t3 where a = 50;
+a	length(b)	length(c)
+50	40000	40000
 alter online table t1 reorganize partition;
 alter online table t2 reorganize partition;
+alter online table t3 reorganize partition;
+T3_FragmentCount
+FragmentCount: 2
+BLOB1_FragmentCount
+FragmentCount: 2
+BLOB2_FragmentCount
+FragmentCount: 2
 partitions added to t1
 t1_added
 0
 partitions added to t2
 t2_added
 0
+partitions added to t3
+t3_added
+0
 alter online table t1 add partition partitions 1;
 alter online table t2 add partition partitions 4;
+alter online table t3 add partition partitions 4;
+T3_FragmentCount
+FragmentCount: 6
+BLOB1_FragmentCount
+FragmentCount: 6
+BLOB2_FragmentCount
+FragmentCount: 6
 partitions added to t1
 t1_added
 1
 partitions added to t2
 t2_added
 4
+partitions added to t3
+t3_added
+4
 alter online table t1 reorganize partition;
 ERROR HY000: REORGANIZE PARTITION without parameters can only be used on auto-partitioned tables using HASH PARTITIONs
 select count(*) from t1;
@@ -166,6 +235,9 @@ count(*)
 select count(*) from t2;
 count(*)
 100
+select count(*) from t3;
+count(*)
+100
 select * from t1 where a < 20;
 a	b	c
 1	1	1
@@ -256,14 +328,57 @@ a	b	c
 select * from t2 where b = 50;
 a	b	c
 50	50	50
+select a, length(b), length(c) from t3 where a < 20;
+a	length(b)	length(c)
+1	20000	20000
+10	40000	40000
+11	40000	40000
+12	40000	40000
+13	40000	40000
+14	40000	40000
+15	40000	40000
+16	40000	40000
+17	40000	40000
+18	40000	40000
+19	40000	40000
+2	20000	20000
+3	20000	20000
+4	20000	20000
+5	20000	20000
+6	20000	20000
+7	20000	20000
+8	20000	20000
+9	20000	20000
+select a, length(b), length(c) from t3 where a = 20;
+a	length(b)	length(c)
+20	40000	40000
+select a, length(b), length(c) from t3 where a = 30;
+a	length(b)	length(c)
+30	40000	40000
+select a, length(b), length(c) from t3 where a = 40;
+a	length(b)	length(c)
+40	40000	40000
+select a, length(b), length(c) from t3 where a = 50;
+a	length(b)	length(c)
+50	40000	40000
 alter online table t1 add partition partitions 2;
 alter online table t2 add partition partitions 1;
+alter online table t3 add partition partitions 1;
+T3_FragmentCount
+FragmentCount: 7
+BLOB1_FragmentCount
+FragmentCount: 7
+BLOB2_FragmentCount
+FragmentCount: 7
 partitions added to t1
 t1_added
 3
 partitions added to t2
 t2_added
 5
+partitions added to t3
+t3_added
+5
 select count(*) from t1;
 count(*)
 100
@@ -360,7 +475,40 @@ a	b	c
 select * from t2 where b = 50;
 a	b	c
 50	50	50
-drop table t1,t2;
+select a, length(b), length(c) from t3 where a < 20;
+a	length(b)	length(c)
+1	20000	20000
+10	40000	40000
+11	40000	40000
+12	40000	40000
+13	40000	40000
+14	40000	40000
+15	40000	40000
+16	40000	40000
+17	40000	40000
+18	40000	40000
+19	40000	40000
+2	20000	20000
+3	20000	20000
+4	20000	20000
+5	20000	20000
+6	20000	20000
+7	20000	20000
+8	20000	20000
+9	20000	20000
+select a, length(b), length(c) from t3 where a = 20;
+a	length(b)	length(c)
+20	40000	40000
+select a, length(b), length(c) from t3 where a = 30;
+a	length(b)	length(c)
+30	40000	40000
+select a, length(b), length(c) from t3 where a = 40;
+a	length(b)	length(c)
+40	40000	40000
+select a, length(b), length(c) from t3 where a = 50;
+a	length(b)	length(c)
+50	40000	40000
+drop table t1,t2,t3;
 alter tablespace ts1 drop datafile 'datafile.dat' engine = ndb;
 drop tablespace ts1 engine = ndb;
 drop logfile group lg1 engine = ndb;

=== modified file 'mysql-test/suite/ndb/t/ndb_add_partition.test'
--- a/mysql-test/suite/ndb/t/ndb_add_partition.test	2011-05-12 11:31:21 +0000
+++ b/mysql-test/suite/ndb/t/ndb_add_partition.test	2012-02-17 15:53:48 +0000
@@ -33,10 +33,19 @@ STORAGE DISK
 TABLESPACE ts1
 partition by key(a);
 
+CREATE TABLE t3 (a int unsigned not null,
+                 b text not null,
+                 c text not null,
+                 primary key(a))
+ENGINE=NDB
+partition by key(a);
+
 let $t1_part_count_start = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't1', Value, 1);
 
 let $t2_part_count_start = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't2', Value, 1);
 
+let $t3_part_count_start = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't3', Value, 1);
+
 INSERT INTO t1 VALUES
 (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
 (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
@@ -59,9 +68,15 @@ INSERT INTO t1 VALUES
 (91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95),
 (96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100);
 
+--source suite/ndb/include/ndb_desc_partition.inc
+
+
 insert into t2 select * from t1;
+
+insert into t3 select a, repeat(a, 20000), repeat(a, 20000) from t1;
 select count(*) from t1;
 select count(*) from t2;
+select count(*) from t3;
 --sorted_result
 select * from t1 where a < 20;
 --sorted_result
@@ -92,32 +107,57 @@ select * from t2 where b = 30;
 select * from t2 where b = 40;
 select * from t2 where b = 50;
 
+--sorted_result
+select a, length(b), length(c) from t3 where a < 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 30;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 40;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 50;
+
 alter online table t1 reorganize partition;
 alter online table t2 reorganize partition;
+alter online table t3 reorganize partition;
 
 let $t1_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't1', Value, 1);
 
 let $t2_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't2', Value, 1);
 
+let $t3_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't3', Value, 1);
+
+--source suite/ndb/include/ndb_desc_partition.inc
+
 --disable_query_log
 --echo partitions added to t1
 eval select $t1_part_count_now - $t1_part_count_start as t1_added;
 --echo partitions added to t2
 eval select $t2_part_count_now - $t2_part_count_start as t2_added;
+--echo partitions added to t3
+eval select $t3_part_count_now - $t2_part_count_start as t3_added;
 --enable_query_log
 
 alter online table t1 add partition partitions 1;
 alter online table t2 add partition partitions 4;
+alter online table t3 add partition partitions 4;
 
 let $t1_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't1', Value, 1);
 
 let $t2_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't2', Value, 1);
 
+let $t3_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't3', Value, 1);
+
+--source suite/ndb/include/ndb_desc_partition.inc
+
 --disable_query_log
 --echo partitions added to t1
 eval select $t1_part_count_now - $t1_part_count_start as t1_added;
 --echo partitions added to t2
 eval select $t2_part_count_now - $t2_part_count_start as t2_added;
+--echo partitions added to t3
+eval select $t3_part_count_now - $t3_part_count_start as t3_added;
 --enable_query_log
 
 # reorganize partition not support if not default partitioning
@@ -127,6 +167,8 @@ alter online table t1 reorganize partiti
 
 select count(*) from t1;
 select count(*) from t2;
+select count(*) from t3;
+
 --sorted_result
 select * from t1 where a < 20;
 --sorted_result
@@ -157,18 +199,36 @@ select * from t2 where b = 30;
 select * from t2 where b = 40;
 select * from t2 where b = 50;
 
+--sorted_result
+select a, length(b), length(c) from t3 where a < 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 30;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 40;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 50;
+
 alter online table t1 add partition partitions 2;
 alter online table t2 add partition partitions 1;
+alter online table t3 add partition partitions 1;
 
 let $t1_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't1', Value, 1);
 
 let $t2_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't2', Value, 1);
 
+let $t3_part_count_now = query_get_value(select count(*) as Value from information_schema.partitions where table_schema = 'test' and table_name = 't3', Value, 1);
+
+--source suite/ndb/include/ndb_desc_partition.inc
+
 --disable_query_log
 --echo partitions added to t1
 eval select $t1_part_count_now - $t1_part_count_start as t1_added;
 --echo partitions added to t2
 eval select $t2_part_count_now - $t2_part_count_start as t2_added;
+--echo partitions added to t3
+eval select $t3_part_count_now - $t3_part_count_start as t3_added;
 --enable_query_log
 
 select count(*) from t1;
@@ -203,7 +263,18 @@ select * from t2 where b = 30;
 select * from t2 where b = 40;
 select * from t2 where b = 50;
 
-drop table t1,t2;
+--sorted_result
+select a, length(b), length(c) from t3 where a < 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 20;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 30;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 40;
+--sorted_result
+select a, length(b), length(c) from t3 where a = 50;
+
+drop table t1,t2,t3;
 alter tablespace ts1 drop datafile 'datafile.dat' engine = ndb;
 drop tablespace ts1 engine = ndb;
 drop logfile group lg1 engine = ndb;

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2011-11-10 14:23:53 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2012-02-17 15:53:48 +0000
@@ -3224,7 +3224,9 @@ int NdbDictionaryImpl::alterTableGlobal(
     if (ret != 0)
       m_error.code = 723;
 
-    if (ret == 0 && AlterTableReq::getNameFlag(changeMask) != 0)
+    if (ret == 0 &&
+        ((AlterTableReq::getNameFlag(changeMask) != 0) ||
+         (AlterTableReq::getAddFragFlag(changeMask) != 0)))
     {
       char db0[MAX_TAB_NAME_SIZE];
       char db1[MAX_TAB_NAME_SIZE];
@@ -3252,9 +3254,12 @@ int NdbDictionaryImpl::alterTableGlobal(
       }
 
       bool schema_change = strcmp(db0, db1) != 0;
-      if (db_change || schema_change)
+
+      bool frag_change = (impl.m_fragmentCount != old_impl.m_fragmentCount);
+      
+      if (db_change || schema_change || frag_change)
       {
-        if (renameBlobTables(old_impl, impl) != 0)
+        if (alterBlobTables(old_impl, impl) != 0)
         {
           DBUG_RETURN(-1);
         }
@@ -3266,8 +3271,8 @@ int NdbDictionaryImpl::alterTableGlobal(
 }
 
 int
-NdbDictionaryImpl::renameBlobTables(const NdbTableImpl & old_tab,
-                                    const NdbTableImpl & new_tab)
+NdbDictionaryImpl::alterBlobTables(const NdbTableImpl & old_tab,
+                                   const NdbTableImpl & new_tab)
 {
   if (old_tab.m_noOfBlobs == 0)
     return 0;
@@ -3277,6 +3282,9 @@ NdbDictionaryImpl::renameBlobTables(cons
   new_tab.getDbName(db, sizeof(db));
   new_tab.getSchemaName(schema, sizeof(schema));
 
+  Uint32 oldFragCount= old_tab.m_fragmentCount;
+  Uint32 newFragCount= new_tab.m_fragmentCount;
+
   for (unsigned i = 0; i < old_tab.m_columns.size(); i++)
   {
     NdbColumnImpl & c = *old_tab.m_columns[i];
@@ -3292,13 +3300,43 @@ NdbDictionaryImpl::renameBlobTables(cons
     NdbDictionary::Table new_bt(bt);
     new_bt.m_impl.setDbSchema(db, schema);
 
+    if (oldFragCount != newFragCount)
+    {
+      if (bt.getFragmentType() == NdbDictionary::Object::HashMapPartition)
+      {
+        if (_bt->m_fragmentCount != oldFragCount)
+        {
+#ifdef VM_TRACE
+          ndbout_c("Blob parts table %s doesn't have same fragcount"
+                   "as old main table %s (BT : %u), (OT : %u)",
+                   bt.getName(),
+                   old_tab.m_facade->getName(),
+                   _bt->m_fragmentCount, 
+                   oldFragCount);
+#endif
+        }
+        /* We can only repartition HashMap partitioned parts tables */
+        new_bt.m_impl.m_fragmentCount = newFragCount;
+        new_bt.m_impl.m_hash_map_id = new_tab.m_hash_map_id;
+        new_bt.m_impl.m_hash_map_version = new_tab.m_hash_map_version;
+      }
+#ifdef VM_TRACE
+      else
+      {
+        ndbout_c("Blob parts table %s (%s) is not hashmap partitioned, type (%d)",
+                 bt.getName(),
+                 old_tab.m_facade->getName(),
+                 bt.getFragmentType());
+      }
+#endif
+    }
+    
     Uint32 changeMask = 0;
     int ret = m_receiver.alterTable(m_ndb, bt.m_impl, new_bt.m_impl,changeMask);
     if (ret != 0)
     {
       return ret;
     }
-    assert(AlterTableReq::getNameFlag(changeMask) != 0);
   }
   return 0;
 }

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2011-07-04 16:30:34 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2012-02-17 15:53:48 +0000
@@ -843,7 +843,7 @@ public:
   int dropTable(const char * name);
   int dropTable(NdbTableImpl &);
   int dropBlobTables(NdbTableImpl &);
-  int renameBlobTables(const NdbTableImpl &old_impl, const NdbTableImpl &impl);
+  int alterBlobTables(const NdbTableImpl &old_impl, const NdbTableImpl &impl);
   int invalidateObject(NdbTableImpl &);
   int removeCachedObject(NdbTableImpl &);
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.1 branch (frazer.clement:4451 to 4452) Frazer Clement20 Feb