Commit 3b8d8276 authored by jonas@perch.ndb.mysql.com's avatar jonas@perch.ndb.mysql.com

Merge perch.ndb.mysql.com:/home/jonas/src/51-work

into  perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new-ndb
parents f4226023 30142f3e
...@@ -596,7 +596,7 @@ f_int1 ...@@ -596,7 +596,7 @@ f_int1
NULL NULL
explain partitions select * from t1 where f_int1 is null; explain partitions select * from t1 where f_int1 is null;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part4_p2sp0 system NULL NULL NULL NULL 1 1 SIMPLE t1 part4_part4sp0 system NULL NULL NULL NULL 1
drop table t1; drop table t1;
create table t1 (a int not null, b int not null) create table t1 (a int not null, b int not null)
partition by list(a) partition by list(a)
...@@ -625,16 +625,16 @@ insert into t1 values (1,1),(1,2),(1,3),(1,4), ...@@ -625,16 +625,16 @@ insert into t1 values (1,1),(1,2),(1,3),(1,4),
(2,1),(2,2),(2,3),(2,4), (NULL,1); (2,1),(2,2),(2,3),(2,4), (NULL,1);
explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2); explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn_p3sp0,pn_p3sp1 system NULL NULL NULL NULL 1 1 SIMPLE t1 pn_pnsp0,pn_pnsp1 system NULL NULL NULL NULL 1
explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2); explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn_p3sp0,pn_p3sp1 system NULL NULL NULL NULL 1 1 SIMPLE t1 pn_pnsp0,pn_pnsp1 system NULL NULL NULL NULL 1
explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2); explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,pn_p3sp0,pn_p3sp1 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0_p0sp0,p0_p0sp1,pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2); explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,pn_p3sp0,pn_p3sp1 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0_p0sp0,p0_p0sp1,pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL 5 Using where
drop table t1; drop table t1;
create table t1 ( a int) partition by list (MOD(a, 10)) create table t1 ( a int) partition by list (MOD(a, 10))
( partition p0 values in (0), partition p1 values in (1), ( partition p0 values in (0), partition p1 values in (1),
......
...@@ -363,3 +363,27 @@ SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; ...@@ -363,3 +363,27 @@ SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31';
COUNT(*) COUNT(*)
10 10
DROP TABLE t1; DROP TABLE t1;
create table t1 (a int)
partition by range (MOD(a,3))
subpartition by hash(a)
subpartitions 2
(partition p0 values less than (1),
partition p1 values less than (2),
partition p2 values less than (3),
partition p3 values less than (4));
ALTER TABLE t1 DROP PARTITION p3;
ALTER TABLE t1 DROP PARTITION p1;
ALTER TABLE t1 DROP PARTITION p2;
drop table t1;
create table t1 (a int)
partition by range (MOD(a,3))
subpartition by hash(a)
subpartitions 2
(partition p0 values less than (1),
partition p1 values less than (2),
partition p2 values less than (3),
partition p3 values less than (4));
ALTER TABLE t1 DROP PARTITION p0;
ALTER TABLE t1 DROP PARTITION p1;
ALTER TABLE t1 DROP PARTITION p2;
drop table t1;
...@@ -388,3 +388,31 @@ SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31'; ...@@ -388,3 +388,31 @@ SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31';
SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31';
DROP TABLE t1; DROP TABLE t1;
#
# BUG 18962 Errors in DROP PARTITION
#
create table t1 (a int)
partition by range (MOD(a,3))
subpartition by hash(a)
subpartitions 2
(partition p0 values less than (1),
partition p1 values less than (2),
partition p2 values less than (3),
partition p3 values less than (4));
ALTER TABLE t1 DROP PARTITION p3;
ALTER TABLE t1 DROP PARTITION p1;
ALTER TABLE t1 DROP PARTITION p2;
drop table t1;
create table t1 (a int)
partition by range (MOD(a,3))
subpartition by hash(a)
subpartitions 2
(partition p0 values less than (1),
partition p1 values less than (2),
partition p2 values less than (3),
partition p3 values less than (4));
ALTER TABLE t1 DROP PARTITION p0;
ALTER TABLE t1 DROP PARTITION p1;
ALTER TABLE t1 DROP PARTITION p2;
drop table t1;
...@@ -88,10 +88,10 @@ partition_info *partition_info::get_clone() ...@@ -88,10 +88,10 @@ partition_info *partition_info::get_clone()
The external routine needing this code is check_partition_info The external routine needing this code is check_partition_info
*/ */
#define MAX_PART_NAME_SIZE 16 #define MAX_PART_NAME_SIZE 8
char *partition_info::create_default_partition_names(uint part_no, uint no_parts, char *partition_info::create_default_partition_names(uint part_no, uint no_parts,
uint start_no, bool is_subpart) uint start_no)
{ {
char *ptr= sql_calloc(no_parts*MAX_PART_NAME_SIZE); char *ptr= sql_calloc(no_parts*MAX_PART_NAME_SIZE);
char *move_ptr= ptr; char *move_ptr= ptr;
...@@ -102,10 +102,7 @@ char *partition_info::create_default_partition_names(uint part_no, uint no_parts ...@@ -102,10 +102,7 @@ char *partition_info::create_default_partition_names(uint part_no, uint no_parts
{ {
do do
{ {
if (is_subpart) my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i)));
my_sprintf(move_ptr, (move_ptr,"p%usp%u", part_no, (start_no + i)));
else
my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i)));
move_ptr+=MAX_PART_NAME_SIZE; move_ptr+=MAX_PART_NAME_SIZE;
} while (++i < no_parts); } while (++i < no_parts);
} }
...@@ -117,6 +114,36 @@ char *partition_info::create_default_partition_names(uint part_no, uint no_parts ...@@ -117,6 +114,36 @@ char *partition_info::create_default_partition_names(uint part_no, uint no_parts
} }
/*
Create a unique name for the subpartition as part_name'sp''subpart_no'
SYNOPSIS
create_subpartition_name()
subpart_no Number of subpartition
part_name Name of partition
RETURN VALUES
>0 A reference to the created name string
0 Memory allocation error
*/
char *partition_info::create_subpartition_name(uint subpart_no,
const char *part_name)
{
uint size_alloc= strlen(part_name) + MAX_PART_NAME_SIZE;
char *ptr= sql_calloc(size_alloc);
DBUG_ENTER("create_subpartition_name");
if (likely(ptr != NULL))
{
my_sprintf(ptr, (ptr, "%ssp%u", part_name, subpart_no));
}
else
{
mem_alloc_error(size_alloc);
}
DBUG_RETURN(ptr);
}
/* /*
Set up all the default partitions not set-up by the user in the SQL Set up all the default partitions not set-up by the user in the SQL
statement. Also perform a number of checks that the user hasn't tried statement. Also perform a number of checks that the user hasn't tried
...@@ -167,8 +194,7 @@ bool partition_info::set_up_default_partitions(handler *file, ulonglong max_rows ...@@ -167,8 +194,7 @@ bool partition_info::set_up_default_partitions(handler *file, ulonglong max_rows
goto end; goto end;
} }
if (unlikely((!(default_name= create_default_partition_names(0, no_parts, if (unlikely((!(default_name= create_default_partition_names(0, no_parts,
start_no, start_no)))))
FALSE)))))
goto end; goto end;
i= 0; i= 0;
do do
...@@ -238,18 +264,17 @@ bool partition_info::set_up_default_subpartitions(handler *file, ...@@ -238,18 +264,17 @@ bool partition_info::set_up_default_subpartitions(handler *file,
{ {
part_elem= part_it++; part_elem= part_it++;
j= 0; j= 0;
name_ptr= create_default_partition_names(i, no_subparts, (uint)0, TRUE);
if (unlikely(!name_ptr))
goto end;
do do
{ {
partition_element *subpart_elem= new partition_element(); partition_element *subpart_elem= new partition_element();
if (likely(subpart_elem != 0 && if (likely(subpart_elem != 0 &&
(!part_elem->subpartitions.push_back(subpart_elem)))) (!part_elem->subpartitions.push_back(subpart_elem))))
{ {
char *ptr= create_subpartition_name(j, part_elem->partition_name);
if (!ptr)
goto end;
subpart_elem->engine_type= default_engine_type; subpart_elem->engine_type= default_engine_type;
subpart_elem->partition_name= name_ptr; subpart_elem->partition_name= ptr;
name_ptr+= MAX_PART_NAME_SIZE;
} }
else else
{ {
......
...@@ -256,7 +256,8 @@ private: ...@@ -256,7 +256,8 @@ private:
uint start_no); uint start_no);
bool set_up_default_subpartitions(handler *file, ulonglong max_rows); bool set_up_default_subpartitions(handler *file, ulonglong max_rows);
char *create_default_partition_names(uint part_no, uint no_parts, char *create_default_partition_names(uint part_no, uint no_parts,
uint start_no, bool is_subpart); uint start_no);
char *create_subpartition_name(uint subpart_no, const char *part_name);
bool has_unique_name(partition_element *element); bool has_unique_name(partition_element *element);
}; };
......
...@@ -29,6 +29,7 @@ public: ...@@ -29,6 +29,7 @@ public:
Bank(Ndb_cluster_connection&, bool init = true, const char *dbase="BANK"); Bank(Ndb_cluster_connection&, bool init = true, const char *dbase="BANK");
int setSkipCreate(bool skip) { m_skip_create = skip; }
int createAndLoadBank(bool overWrite, bool disk= false, int num_accounts=10); int createAndLoadBank(bool overWrite, bool disk= false, int num_accounts=10);
int dropBank(); int dropBank();
...@@ -140,6 +141,7 @@ private: ...@@ -140,6 +141,7 @@ private:
Ndb m_ndb; Ndb m_ndb;
int m_maxAccount; int m_maxAccount;
bool m_initialized; bool m_initialized;
bool m_skip_create;
}; };
#endif #endif
...@@ -58,7 +58,7 @@ int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){ ...@@ -58,7 +58,7 @@ int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){
m_ndb.init(); m_ndb.init();
if (m_ndb.waitUntilReady() != 0) if (m_ndb.waitUntilReady() != 0)
return NDBT_FAILED; return NDBT_FAILED;
const NdbDictionary::Table* pSysValTab = const NdbDictionary::Table* pSysValTab =
m_ndb.getDictionary()->getTable("SYSTEM_VALUES"); m_ndb.getDictionary()->getTable("SYSTEM_VALUES");
if (pSysValTab != NULL){ if (pSysValTab != NULL){
...@@ -69,7 +69,7 @@ int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){ ...@@ -69,7 +69,7 @@ int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){
} }
} }
if (createTables(disk) != NDBT_OK) if (!m_skip_create && createTables(disk) != NDBT_OK)
return NDBT_FAILED; return NDBT_FAILED;
if (clearTables() != NDBT_OK) if (clearTables() != NDBT_OK)
......
...@@ -31,10 +31,12 @@ int main(int argc, const char** argv){ ...@@ -31,10 +31,12 @@ int main(int argc, const char** argv){
int _help = 0; int _help = 0;
char * _database = "BANK"; char * _database = "BANK";
int disk = 0; int disk = 0;
int skip_create = 0;
struct getargs args[] = { struct getargs args[] = {
{ "database", 'd', arg_string, &_database, "Database name", ""}, { "database", 'd', arg_string, &_database, "Database name", ""},
{ "disk", 0, arg_flag, &disk, "Use disk tables", "" }, { "disk", 0, arg_flag, &disk, "Use disk tables", "" },
{ "skip-create", 0, arg_flag, &skip_create, "Skip create", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" } { "usage", '?', arg_flag, &_help, "Print help", "" }
}; };
int num_args = sizeof(args) / sizeof(args[0]); int num_args = sizeof(args) / sizeof(args[0]);
...@@ -55,6 +57,7 @@ int main(int argc, const char** argv){ ...@@ -55,6 +57,7 @@ int main(int argc, const char** argv){
Bank bank(con,_database); Bank bank(con,_database);
int overWriteExisting = true; int overWriteExisting = true;
bank.setSkipCreate(skip_create);
if (bank.createAndLoadBank(overWriteExisting, disk) != NDBT_OK) if (bank.createAndLoadBank(overWriteExisting, disk) != NDBT_OK)
return NDBT_ProgramExit(NDBT_FAILED); return NDBT_ProgramExit(NDBT_FAILED);
return NDBT_ProgramExit(NDBT_OK); return NDBT_ProgramExit(NDBT_OK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment