summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se>2006-05-10 12:53:40 -0400
committerunknown <mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se>2006-05-10 12:53:40 -0400
commit4e3f4e970f6476d3b6b79077e26ddcb5a24ef80a (patch)
tree15485e03be56b9839d6e8ab9f610939e568fad1b /sql
parent3065eeb3f8cff732e1a462b58996105881c7ca88 (diff)
downloadmariadb-git-4e3f4e970f6476d3b6b79077e26ddcb5a24ef80a.tar.gz
BUG#19010: Fix issues with that ALTER TABLE from auto-partitioned NDB table doesn't work unless primary key exists on table.
mysql-test/r/ndb_bitfield.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/r/ndb_dd_basic.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/r/ndb_dd_disk2memory.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/r/ndb_gis.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/r/ndb_partition_key.result: New test cases for auto-partitioning change that was made to fix bug mysql-test/r/rpl_ndb_UUID.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/r/rpl_ndb_dd_advance.result: Test cases changes now that auto-partitioning is remembered in frm file mysql-test/t/ndb_partition_key.test: New test cases for auto-partitioning change that was made to fix bug sql/partition_info.h: New boolean to keep track of auto partitioned or not sql/sql_partition.cc: Ensure that auto-partitiong flag is reset when partitions are dropped, added, reorganised or coalesced. Ensure that auto-partitioned tables are altered into non-partitioned table when ALTER TABLE t1 engine=X is performed. sql/sql_show.cc: Only print partition info for non-auto-partitioned tables sql/sql_table.cc: Set auto partition flag when auto partitions are generated in create table sql/table.cc: Fix reading of frm file where new auto-partition flag is introduced. sql/table.h: New flag for auto partition on share object sql/unireg.cc: Fix code for writing frm to also write autopartition flag at end of partition info, fix some length issues at the same time that was in this part that caused no problems since partition info always was the last info in the file.
Diffstat (limited to 'sql')
-rw-r--r--sql/partition_info.h2
-rw-r--r--sql/sql_partition.cc25
-rw-r--r--sql/sql_show.cc1
-rw-r--r--sql/sql_table.cc1
-rw-r--r--sql/table.cc11
-rw-r--r--sql/table.h1
-rw-r--r--sql/unireg.cc18
7 files changed, 52 insertions, 7 deletions
diff --git a/sql/partition_info.h b/sql/partition_info.h
index 3a1e6be4050..af43f7b7933 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -184,6 +184,7 @@ public:
bool list_of_subpart_fields;
bool linear_hash_ind;
bool fixed;
+ bool is_auto_partitioned;
bool from_openfrm;
bool has_null_value;
uint has_null_part_id;
@@ -219,6 +220,7 @@ public:
list_of_part_fields(FALSE), list_of_subpart_fields(FALSE),
linear_hash_ind(FALSE),
fixed(FALSE),
+ is_auto_partitioned(FALSE),
from_openfrm(FALSE),
has_null_value(FALSE),
has_null_part_id(0)
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 0442ad724d2..cc580578c7e 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4075,6 +4075,7 @@ that are reorganised.
tab_part_info->use_default_partitions= FALSE;
}
tab_part_info->use_default_no_partitions= FALSE;
+ tab_part_info->is_auto_partitioned= FALSE;
}
}
else if (alter_info->flags == ALTER_DROP_PARTITION)
@@ -4090,6 +4091,8 @@ that are reorganised.
uint no_parts_dropped= alter_info->partition_names.elements;
uint no_parts_found= 0;
List_iterator<partition_element> part_it(tab_part_info->partitions);
+
+ tab_part_info->is_auto_partitioned= FALSE;
if (!(tab_part_info->part_type == RANGE_PARTITION ||
tab_part_info->part_type == LIST_PARTITION))
{
@@ -4274,7 +4277,10 @@ state of p1.
tab_part_info->no_parts= no_parts_remain;
}
if (!(alter_info->flags & ALTER_TABLE_REORG))
+ {
tab_part_info->use_default_no_partitions= FALSE;
+ tab_part_info->is_auto_partitioned= FALSE;
+ }
}
else if (alter_info->flags == ALTER_REORGANIZE_PARTITION)
{
@@ -4293,6 +4299,8 @@ state of p1.
uint no_parts_new= thd->work_part_info->partitions.elements;
partition_info *alt_part_info= thd->work_part_info;
uint check_total_partitions;
+
+ tab_part_info->is_auto_partitioned= FALSE;
if (no_parts_reorged > tab_part_info->no_parts)
{
my_error(ER_REORG_PARTITION_NOT_EXIST, MYF(0));
@@ -4533,7 +4541,22 @@ the generated partition syntax in a correct manner.
Make sure change of engine happens to all partitions.
*/
DBUG_PRINT("info", ("partition changed"));
- set_engine_all_partitions(thd->work_part_info, create_info->db_type);
+ if (table->part_info->is_auto_partitioned)
+ {
+ /*
+ If the user originally didn't specify partitioning to be
+ used we can remove it now.
+ */
+ thd->work_part_info= NULL;
+ }
+ else
+ {
+ /*
+ Ensure that all partitions have the proper engine set-up
+ */
+ set_engine_all_partitions(thd->work_part_info,
+ create_info->db_type);
+ }
*partition_changed= TRUE;
}
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 5e54040f0ae..b23b53d117e 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1274,6 +1274,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
uint part_syntax_len;
char *part_syntax;
if (table->part_info &&
+ (!table->part_info->is_auto_partitioned) &&
((part_syntax= generate_partition_syntax(table->part_info,
&part_syntax_len,
FALSE,FALSE))))
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 412682fc3b0..4b8bf7bcf17 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3045,6 +3045,7 @@ bool mysql_create_table_internal(THD *thd,
}
file->set_auto_partitions(part_info);
part_info->default_engine_type= create_info->db_type;
+ part_info->is_auto_partitioned= TRUE;
}
if (part_info)
{
diff --git a/sql/table.cc b/sql/table.cc
index 6ba66569f5c..8227287df0f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -655,7 +655,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
my_free(buff, MYF(0));
goto err;
}
- next_chunk++;
}
#else
if (partition_info_len)
@@ -679,7 +678,15 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
*/
next_chunk+= 4;
}
+ else if (share->mysql_version >= 50110)
#endif
+ {
+ /* New auto_partitioned indicator introduced in 5.1.11 */
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ share->auto_partitioned= *next_chunk;
+#endif
+ next_chunk++;
+ }
keyinfo= share->key_info;
for (i= 0; i < keys; i++, keyinfo++)
{
@@ -1469,6 +1476,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
Fix the partition functions and ensure they are not constant
functions
*/
+ outparam->part_info->is_auto_partitioned= share->auto_partitioned;
+ DBUG_PRINT("info", ("autopartitioned = %u", share->auto_partitioned));
if (fix_partition_func(thd, share->normalized_path.str, outparam,
is_create_table))
goto err;
diff --git a/sql/table.h b/sql/table.h
index 85d49444b29..e1b496a8296 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -213,6 +213,7 @@ typedef struct st_table_share
*/
bool log_table;
#ifdef WITH_PARTITION_STORAGE_ENGINE
+ bool auto_partitioned;
const uchar *partition_info;
uint partition_info_len;
const uchar *part_state;
diff --git a/sql/unireg.cc b/sql/unireg.cc
index bbb4d970d37..58c8123c98e 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -130,8 +130,14 @@ bool mysql_create_frm(THD *thd, const char *file_name,
/* str_db_type */
create_info->extra_size= (2 + str_db_type.length +
2 + create_info->connect_string.length);
- /* Partition */
- create_info->extra_size+= 9;
+ /*
+ Partition:
+ Length of partition info = 4 byte
+ Potential NULL byte at end of partition info string = 1 byte
+ Indicator if auto-partitioned table = 1 byte
+ => Total 6 byte
+ */
+ create_info->extra_size+= 6;
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (part_info)
{
@@ -203,17 +209,19 @@ bool mysql_create_frm(THD *thd, const char *file_name,
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (part_info)
{
+ char auto_partitioned= part_info->is_auto_partitioned ? 1 : 0;
int4store(buff, part_info->part_info_len);
if (my_write(file, (const byte*)buff, 4, MYF_RW) ||
my_write(file, (const byte*)part_info->part_info_string,
- part_info->part_info_len + 1, MYF_RW))
+ part_info->part_info_len + 1, MYF_RW) ||
+ my_write(file, (const byte*)&auto_partitioned, 1, MYF_RW))
goto err;
}
else
#endif
{
- bzero(buff, 9);
- if (my_write(file, (byte*) buff, 9, MYF_RW))
+ bzero(buff, 6);
+ if (my_write(file, (byte*) buff, 6, MYF_RW))
goto err;
}
for (i= 0; i < keys; i++)