Below is the list of changes that have just been committed into a local
5.1 repository of psergey. When psergey 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
1.2018 06/01/10 18:31:33 sergefp@stripped +5 -0
Manually merged
sql/ha_partition.cc
1.28 06/01/10 18:31:29 sergefp@stripped +0 -0
Manually merged
mysql-test/t/partition_select.test
1.3 06/01/10 18:31:29 sergefp@stripped +0 -1
Manually merged
mysql-test/r/partition_select.result
1.3 06/01/10 18:31:29 sergefp@stripped +0 -0
Manually merged
sql/opt_range.cc
1.194 06/01/10 18:19:47 sergefp@stripped +0 -0
Auto merged
sql/handler.h
1.177 06/01/10 18:19:47 sergefp@stripped +0 -0
Auto merged
# 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: sergefp
# Host: newbox.mylan
# Root: /home/psergey/mysql-5.1-wl2682/RESYNC
--- 1.176/sql/handler.h 2006-01-06 02:09:33 +03:00
+++ 1.177/sql/handler.h 2006-01-10 18:19:47 +03:00
@@ -1545,7 +1545,7 @@
inline bool ha_storage_engine_is_enabled(const handlerton *db_type)
{
- return (db_type && db_type->create) ?
+ return (db_type && db_type->create) ?
(db_type->state == SHOW_OPTION_YES) : FALSE;
}
@@ -1556,7 +1556,6 @@
TYPELIB *ha_known_exts(void);
int ha_panic(enum ha_panic_function flag);
-int ha_update_statistics();
void ha_close_connection(THD* thd);
bool ha_flush_logs(handlerton *db_type);
void ha_drop_database(char* path);
--- 1.193/sql/opt_range.cc 2006-01-06 02:09:33 +03:00
+++ 1.194/sql/opt_range.cc 2006-01-10 18:19:47 +03:00
@@ -6985,6 +6985,7 @@
/*
Create quick select from ref/ref_or_null scan.
+
SYNOPSIS
get_quick_select_for_ref()
thd Thread handle
@@ -7004,15 +7005,18 @@
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
TABLE_REF *ref, ha_rows records)
{
- MEM_ROOT *old_root= thd->mem_root;
- /* The following call may change thd->mem_root */
- QUICK_RANGE_SELECT *quick= new QUICK_RANGE_SELECT(thd, table, ref->key, 0);
- /* save mem_root set by QUICK_RANGE_SELECT constructor */
- MEM_ROOT *alloc= thd->mem_root;
+ MEM_ROOT *old_root, *alloc;
+ QUICK_RANGE_SELECT *quick;
KEY *key_info = &table->key_info[ref->key];
KEY_PART *key_part;
QUICK_RANGE *range;
uint part;
+
+ old_root= thd->mem_root;
+ /* The following call may change thd->mem_root */
+ quick= new QUICK_RANGE_SELECT(thd, table, ref->key, 0);
+ /* save mem_root set by QUICK_RANGE_SELECT constructor */
+ alloc= thd->mem_root;
/*
return back default mem_root (thd->mem_root) changed by
QUICK_RANGE_SELECT constructor
--- 1.27/sql/ha_partition.cc 2006-01-06 02:09:33 +03:00
+++ 1.28/sql/ha_partition.cc 2006-01-10 18:31:29 +03:00
@@ -899,10 +899,13 @@
partition_element *el;
while ((el= part_it++) != NULL)
{
- el->index= index++;
+ bool has_sub_parts= is_sub_partitioned(m_part_info);
+
+ if (! has_sub_parts)
+ el->index= index++;
if (my_hash_insert(&(m_part_info->partition_names), (byte*)el))
return 1;
- if (!is_sub_partitioned(m_part_info))
+ if (!has_sub_parts)
continue;
List_iterator_fast <partition_element> sub_part_it(el->subpartitions);
partition_element *subel;
@@ -1041,22 +1044,18 @@
int ha_partition::close(void)
{
+ int i;
handler **file;
+ partition_element *part_elem;
List_iterator_fast <partition_element> part_it(m_part_info->partitions);
DBUG_ENTER("ha_partition::close");
delete_queue(&queue);
bitmap_free(&(m_part_info->used_partitions));
file= m_file;
- do
- {
- partition_element *part_elem= part_it++;
- /* this line causes the server to bomb on shutdown*/
- //VOID(hash_delete(&(m_part_info->partition_names), (byte*)part_it++));
- /* this line doesn't seem to free the hash!!! */
- VOID(hash_delete(&(m_part_info->partition_names), (byte*)part_elem));
- (*file)->close();
- } while (*(++file));
+ do { (*file)->close(); } while (*(++file));
+ hash_free(&(m_part_info->partition_names));
+
DBUG_RETURN(0);
}
@@ -1195,12 +1194,19 @@
DBUG_PRINT("info", ("selected partition %s is in table", partition_name));
bitmap_clear_all(&m_part_info->used_partitions);
- while (el != NULL)
+
+ if (is_sub_partitioned(m_part_info) && (el->subpartitions.elements > 0))
{
- bitmap_set_bit(&(m_part_info->used_partitions), el->index);
- el= (partition_element*)hash_next(&(m_part_info->partition_names), (const byte*)partition_name,
- strlen(partition_name));
+ List_iterator<partition_element> sub_part_it(el->subpartitions);
+ partition_element *sub_el;
+ while ((sub_el= sub_part_it++) != NULL)
+ {
+ bitmap_set_bit(&(m_part_info->used_partitions), sub_el->index);
+ }
}
+ else
+ bitmap_set_bit(&(m_part_info->used_partitions), el->index);
+
DBUG_RETURN(0);
}
@@ -1558,7 +1564,7 @@
DBUG_PRINT("info", ("rnd_init on partition %d", current_partition_index));
- for (i= current_partition_index; i < m_part_info->no_parts; i++)
+ for (i= current_partition_index; i < m_tot_parts; i++)
{
if (_bitmap_is_set(&(m_part_info->used_partitions), i))
if ((error= m_file[i]->ha_rnd_init(scan)))
@@ -3136,17 +3142,16 @@
ha_rows ha_partition::estimate_rows_upper_bound()
{
- handler **file;
ha_rows rows, tot_rows= 0;
+ handler **file;
DBUG_ENTER("ha_partition::estimate_rows_upper_bound");
+ file= m_file;
do
{
- int i= file - m_file;
- if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+ if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
{
rows= (*file)->estimate_rows_upper_bound();
-
if (rows == HA_POS_ERROR)
DBUG_RETURN(HA_POS_ERROR);
tot_rows+= rows;
@@ -3475,7 +3480,6 @@
this doesn't seem to free m_part_info->partition_names,
need to know how to make sure this happens
*/
- my_free((gptr) &(m_part_info->partition_names), MYF(0));
my_free((gptr) share, MYF(0));
}
pthread_mutex_unlock(&partition_mutex);
--- 1.2/mysql-test/r/partition_select.result 2006-01-06 02:09:33 +03:00
+++ 1.3/mysql-test/r/partition_select.result 2006-01-10 18:31:29 +03:00
@@ -124,10 +124,200 @@
18
19
20
+SELECT * FROM t2 PARTITION (p3) ORDER BY id;
+id
+17
+18
+19
+20
SELECT * FROM t2 PARTITION (p3) WHERE id = 2;
id
SELECT * FROM t2 PARTITION (foo);
ERROR HY000: partition 'foo' doesn't exist
+DROP TABLE IF EXISTS `t3`;
+Warnings:
+Note 1051 Unknown table 't3'
+CREATE TABLE `t3` (
+`id` int(32) default NULL,
+`name` varchar(32) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST (id) (
+PARTITION p0 VALUES IN (1,3,5,7),
+PARTITION p1 VALUES IN (0,2,4,6,8),
+PARTITION p2 VALUES IN (9,10,11,12,13)
+);
+INSERT INTO `t3` VALUES (1,'first'), (3,'third'),(5,'fifth'),(7,'seventh'),(0,'zilch'),(2,'second'),(4,'fourth'),(6,'sixth'),(8,'eighth'),(9,'ninth'),(10,'tenth'),(11,'eleventh'),(12,'twelfth'),(13,'thirteenth');
+SELECT * FROM `t3`;
+id name
+1 first
+3 third
+5 fifth
+7 seventh
+0 zilch
+2 second
+4 fourth
+6 sixth
+8 eighth
+9 ninth
+10 tenth
+11 eleventh
+12 twelfth
+13 thirteenth
+SELECT * FROM `t3` PARTITION (p0);
+id name
+1 first
+3 third
+5 fifth
+7 seventh
+SELECT * FROM `t3` PARTITION (p1);
+id name
+0 zilch
+2 second
+4 fourth
+6 sixth
+8 eighth
+SELECT * FROM `t3` PARTITION (p2);
+id name
+9 ninth
+10 tenth
+11 eleventh
+12 twelfth
+13 thirteenth
+SELECT * FROM `t3` PARTITION (p2) ORDER BY id;
+id name
+9 ninth
+10 tenth
+11 eleventh
+12 twelfth
+13 thirteenth
+DROP TABLE IF EXISTS `t4`;
+Warnings:
+Note 1051 Unknown table 't4'
+CREATE TABLE `t4` (
+`id` int(32) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ;
+INSERT INTO `t4` SELECT * FROM `t2`;
+INSERT INTO `t4` SELECT * FROM `t2` ORDER BY id;
+CREATE TABLE `t5` (
+id int(32),
+name varchar(64),
+purchased date)
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s2,
+SUBPARTITION s3
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s4,
+SUBPARTITION s5
+)
+);
+INSERT INTO `t5` VALUES (1, 'aaaaaaa', '2006-01-05 00:00:00');
+INSERT INTO `t5` VALUES (2, 'bbbbbbb', '2005-08-05 00:00:00');
+INSERT INTO `t5` VALUES (3, 'ccccccc', '1985-08-07 00:00:00');
+INSERT INTO `t5` VALUES (4, 'ddddddd', '2000-01-01 00:00:00');
+INSERT INTO `t5` VALUES (5, 'eeeeeee', '1999-12-01 00:00:00');
+INSERT INTO `t5` VALUES (6, 'fffffff', '2003-11-12 00:00:00');
+INSERT INTO `t5` VALUES (7, 'ggggggg', '1990-01-05 00:00:00');
+INSERT INTO `t5` VALUES (8, 'hhhhhhh', '1978-01-05 00:00:00');
+INSERT INTO `t5` VALUES (9, 'iiiiiii', '1979-01-05 00:00:00');
+INSERT INTO `t5` VALUES (10, 'jjjjjjj', '1992-01-05 00:00:00');
+INSERT INTO `t5` VALUES (11, 'kkkkkkk', '1993-01-05 00:00:00');
+INSERT INTO `t5` VALUES (12, 'mmmmmmm', '1994-01-05 00:00:00');
+INSERT INTO `t5` VALUES (13, 'nnnnnnn', '1989-01-05 00:00:00');
+INSERT INTO `t5` VALUES (14, 'ooooooo', '1983-12-05 00:00:00');
+INSERT INTO `t5` VALUES (15, 'ppppppp', '1986-06-05 00:00:00');
+INSERT INTO `t5` VALUES (16, 'qqqqqqq', '1974-04-11 00:00:00');
+INSERT INTO `t5` VALUES (17, 'qqqqqqq', '1960-03-15 00:00:00');
+INSERT INTO `t5` VALUES (18, 'sssssss', '1950-09-23 00:00:00');
+INSERT INTO `t5` VALUES (19, 'ttttttt', '1999-08-02 00:00:00');
+INSERT INTO `t5` VALUES (20, 'uuuuuuu', '1994-05-28 00:00:00');
+SELECT * FROM `t5`;
+id name purchased
+8 hhhhhhh 1978-01-05
+13 nnnnnnn 1989-01-05
+14 ooooooo 1983-12-05
+18 sssssss 1950-09-23
+3 ccccccc 1985-08-07
+9 iiiiiii 1979-01-05
+15 ppppppp 1986-06-05
+16 qqqqqqq 1974-04-11
+17 qqqqqqq 1960-03-15
+5 eeeeeee 1999-12-01
+12 mmmmmmm 1994-01-05
+4 ddddddd 2000-01-01
+7 ggggggg 1990-01-05
+10 jjjjjjj 1992-01-05
+11 kkkkkkk 1993-01-05
+19 ttttttt 1999-08-02
+20 uuuuuuu 1994-05-28
+2 bbbbbbb 2005-08-05
+6 fffffff 2003-11-12
+1 aaaaaaa 2006-01-05
+SELECT * FROM `t5` PARTITION(p0) ORDER BY id;
+id name purchased
+3 ccccccc 1985-08-07
+8 hhhhhhh 1978-01-05
+9 iiiiiii 1979-01-05
+13 nnnnnnn 1989-01-05
+14 ooooooo 1983-12-05
+15 ppppppp 1986-06-05
+16 qqqqqqq 1974-04-11
+17 qqqqqqq 1960-03-15
+18 sssssss 1950-09-23
+SELECT * FROM `t5` PARTITION(s0) ORDER BY id;
+id name purchased
+8 hhhhhhh 1978-01-05
+13 nnnnnnn 1989-01-05
+14 ooooooo 1983-12-05
+18 sssssss 1950-09-23
+SELECT * FROM `t5` PARTITION(s1) ORDER BY id;
+id name purchased
+3 ccccccc 1985-08-07
+9 iiiiiii 1979-01-05
+15 ppppppp 1986-06-05
+16 qqqqqqq 1974-04-11
+17 qqqqqqq 1960-03-15
+SELECT * FROM `t5` PARTITION(p1) ORDER BY id;
+id name purchased
+4 ddddddd 2000-01-01
+5 eeeeeee 1999-12-01
+7 ggggggg 1990-01-05
+10 jjjjjjj 1992-01-05
+11 kkkkkkk 1993-01-05
+12 mmmmmmm 1994-01-05
+19 ttttttt 1999-08-02
+20 uuuuuuu 1994-05-28
+SELECT * FROM `t5` PARTITION(s2) ORDER BY id;
+id name purchased
+5 eeeeeee 1999-12-01
+12 mmmmmmm 1994-01-05
+SELECT * FROM `t5` PARTITION(s3) ORDER BY id;
+id name purchased
+4 ddddddd 2000-01-01
+7 ggggggg 1990-01-05
+10 jjjjjjj 1992-01-05
+11 kkkkkkk 1993-01-05
+19 ttttttt 1999-08-02
+20 uuuuuuu 1994-05-28
+SELECT * FROM `t5` PARTITION(p2) ORDER BY id;
+id name purchased
+1 aaaaaaa 2006-01-05
+2 bbbbbbb 2005-08-05
+6 fffffff 2003-11-12
+SELECT * FROM `t5` PARTITION(s4) ORDER BY id;
+id name purchased
+2 bbbbbbb 2005-08-05
+6 fffffff 2003-11-12
+SELECT * FROM `t5` PARTITION(s5) ORDER BY id;
+id name purchased
+1 aaaaaaa 2006-01-05
+drop table t1,t2,t3,t4,t5;
drop table t1,t2;
create table t1 (a int) partition by hash(a) partitions 3;
insert into t1 values(1),(2),(3);
--- 1.2/mysql-test/t/partition_select.test 2006-01-06 02:09:33 +03:00
+++ 1.3/mysql-test/t/partition_select.test 2006-01-10 18:31:29 +03:00
@@ -48,10 +48,100 @@
SELECT * FROM t2 PARTITION (p1);
SELECT * FROM t2 PARTITION (p2);
SELECT * FROM t2 PARTITION (p3);
+SELECT * FROM t2 PARTITION (p3) ORDER BY id;
SELECT * FROM t2 PARTITION (p3) WHERE id = 2;
--error 1501
SELECT * FROM t2 PARTITION (foo);
+
+DROP TABLE IF EXISTS `t3`;
+CREATE TABLE `t3` (
+ `id` int(32) default NULL,
+ `name` varchar(32) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST (id) (
+ PARTITION p0 VALUES IN (1,3,5,7),
+ PARTITION p1 VALUES IN (0,2,4,6,8),
+ PARTITION p2 VALUES IN (9,10,11,12,13)
+);
+
+INSERT INTO `t3` VALUES (1,'first'), (3,'third'),(5,'fifth'),(7,'seventh'),(0,'zilch'),(2,'second'),(4,'fourth'),(6,'sixth'),(8,'eighth'),(9,'ninth'),(10,'tenth'),(11,'eleventh'),(12,'twelfth'),(13,'thirteenth');
+
+SELECT * FROM `t3`;
+SELECT * FROM `t3` PARTITION (p0);
+SELECT * FROM `t3` PARTITION (p1);
+SELECT * FROM `t3` PARTITION (p2);
+SELECT * FROM `t3` PARTITION (p2) ORDER BY id;
+
+DROP TABLE IF EXISTS `t4`;
+CREATE TABLE `t4` (
+ `id` int(32) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ;
+
+INSERT INTO `t4` SELECT * FROM `t2`;
+INSERT INTO `t4` SELECT * FROM `t2` ORDER BY id;
+# not sure how to do this, since names could be anything
+#SELECT * FROM `t4` PARTITION (p0);
+#SELECT * FROM `t4` PARTITION (p1);
+#SELECT * FROM `t4` PARTITION (p2);
+#SELECT * FROM `t4` PARTITION (p3);
+#SELECT * FROM `t4` PARTITION (p3) ORDER BY id;
+
+CREATE TABLE `t5` (
+ id int(32),
+ name varchar(64),
+ purchased date)
+PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0,
+ SUBPARTITION s1
+ ),
+ PARTITION p1 VALUES LESS THAN (2000) (
+ SUBPARTITION s2,
+ SUBPARTITION s3
+ ),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s4,
+ SUBPARTITION s5
+ )
+ );
+
+INSERT INTO `t5` VALUES (1, 'aaaaaaa', '2006-01-05 00:00:00');
+INSERT INTO `t5` VALUES (2, 'bbbbbbb', '2005-08-05 00:00:00');
+INSERT INTO `t5` VALUES (3, 'ccccccc', '1985-08-07 00:00:00');
+INSERT INTO `t5` VALUES (4, 'ddddddd', '2000-01-01 00:00:00');
+INSERT INTO `t5` VALUES (5, 'eeeeeee', '1999-12-01 00:00:00');
+INSERT INTO `t5` VALUES (6, 'fffffff', '2003-11-12 00:00:00');
+INSERT INTO `t5` VALUES (7, 'ggggggg', '1990-01-05 00:00:00');
+INSERT INTO `t5` VALUES (8, 'hhhhhhh', '1978-01-05 00:00:00');
+INSERT INTO `t5` VALUES (9, 'iiiiiii', '1979-01-05 00:00:00');
+INSERT INTO `t5` VALUES (10, 'jjjjjjj', '1992-01-05 00:00:00');
+INSERT INTO `t5` VALUES (11, 'kkkkkkk', '1993-01-05 00:00:00');
+INSERT INTO `t5` VALUES (12, 'mmmmmmm', '1994-01-05 00:00:00');
+INSERT INTO `t5` VALUES (13, 'nnnnnnn', '1989-01-05 00:00:00');
+INSERT INTO `t5` VALUES (14, 'ooooooo', '1983-12-05 00:00:00');
+INSERT INTO `t5` VALUES (15, 'ppppppp', '1986-06-05 00:00:00');
+INSERT INTO `t5` VALUES (16, 'qqqqqqq', '1974-04-11 00:00:00');
+INSERT INTO `t5` VALUES (17, 'qqqqqqq', '1960-03-15 00:00:00');
+INSERT INTO `t5` VALUES (18, 'sssssss', '1950-09-23 00:00:00');
+INSERT INTO `t5` VALUES (19, 'ttttttt', '1999-08-02 00:00:00');
+INSERT INTO `t5` VALUES (20, 'uuuuuuu', '1994-05-28 00:00:00');
+
+SELECT * FROM `t5`;
+SELECT * FROM `t5` PARTITION(p0) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s0) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s1) ORDER BY id;
+SELECT * FROM `t5` PARTITION(p1) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s2) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s3) ORDER BY id;
+SELECT * FROM `t5` PARTITION(p2) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s4) ORDER BY id;
+SELECT * FROM `t5` PARTITION(s5) ORDER BY id;
+
+--disable_warnings
+drop table t1,t2,t3,t4,t5;
+--enable_warnings
drop table t1,t2;
# Tests for working together with partition pruning.
| Thread |
|---|
| • bk commit into 5.1 tree (sergefp:1.2018) | Sergey Petrunia | 10 Jan |