Below is the list of changes that have just been committed into a local
5.1 repository of patg. When patg 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.2019 05/12/31 15:28:53 patg@stripped +4 -0
partition_select.test:
WL# 2682 New test
partition_select.result:
WL# 2682 New test results
opt_range.cc:
WL# 2682
Temp hack to make partition selection work until the bitmap_set_all, which
currently overwrites a selected partiton bitmap, is fixed
ha_partition.cc:
WL# 2682
1. Formatting
2. Tables with indexes now do partition selection
3. Tried to make the hash_delete in ::close work better. Solved the server
bombing on shutdown, but now get warnings for unfreed memory on shutdown.
4. Temporary fixes until opt_range.cc prune_partitions doesn't overwrite a
selected partition
partition_select.test, partition_select.result:
new file
mysql-test/t/partition_select.test
1.1 05/12/31 15:28:06 patg@stripped +53 -0
WL# 2682 New test
mysql-test/r/partition_select.result
1.1 05/12/31 15:28:06 patg@stripped +132 -0
WL# 2682 New test results
sql/opt_range.cc
1.192 05/12/31 15:28:06 patg@stripped +8 -4
WL# 2682
Temp hack to make partition selection work until the bitmap_set_all, which
currently overwrites a selected partiton bitmap, is fixed
sql/ha_partition.cc
1.25 05/12/31 15:28:06 patg@stripped +95 -54
WL# 2682
1. Formatting
2. Tables with indexes now do partition selection
3. Tried to make the hash_delete in ::close work better. Solved the server
bombing on shutdown, but now get warnings for unfreed memory on shutdown.
4. Temporary fixes until opt_range.cc prune_partitions doesn't overwrite a
selected partition
mysql-test/t/partition_select.test
1.0 05/12/31 15:28:06 patg@stripped +0 -0
BitKeeper file /home/patg/mysql-build/mysql-5.1-wl2682/mysql-test/t/partition_select.test
mysql-test/r/partition_select.result
1.0 05/12/31 15:28:06 patg@stripped +0 -0
BitKeeper file /home/patg/mysql-build/mysql-5.1-wl2682/mysql-test/r/partition_select.result
# 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: patg
# Host: govinda.site
# Root: /home/patg/mysql-build/mysql-5.1-wl2682
--- 1.191/sql/opt_range.cc 2005-12-25 22:46:16 -08:00
+++ 1.192/sql/opt_range.cc 2005-12-31 15:28:06 -08:00
@@ -2280,13 +2280,13 @@
if (!part_info)
DBUG_RETURN(FALSE); /* not a partitioned table */
-
+
if (!pprune_cond)
{
mark_all_partitions_as_used(part_info);
DBUG_RETURN(FALSE);
}
-
+
PART_PRUNE_PARAM prune_param;
MEM_ROOT alloc;
RANGE_OPT_PARAM *range_par= &prune_param.range_param;
@@ -2303,7 +2303,7 @@
free_root(&alloc,MYF(0)); // Return memory & allocator
DBUG_RETURN(FALSE);
}
-
+
range_par->thd= thd;
range_par->table= table;
/* range_par->cond doesn't need initialization */
@@ -2806,7 +2806,11 @@
static void mark_all_partitions_as_used(partition_info *part_info)
{
- bitmap_set_all(&part_info->used_partitions);
+ DBUG_ENTER("mark_all_partitions_as_used");
+ DBUG_PRINT("info", ("used_partitions %lx", part_info->used_partitions));
+ // REMOVE AFTER PSERGEY FIX!!!!
+ //bitmap_set_all(&part_info->used_partitions);
+ DBUG_VOID_RETURN;
}
--- 1.24/sql/ha_partition.cc 2005-12-31 08:45:00 -08:00
+++ 1.25/sql/ha_partition.cc 2005-12-31 15:28:06 -08:00
@@ -899,19 +899,19 @@
partition_element *el;
while ((el= part_it++) != NULL)
{
- el->index= index++;
+ el->index= index++;
if (my_hash_insert(&(m_part_info->partition_names), (byte*)el))
- return 1;
+ return 1;
if (!is_sub_partitioned(m_part_info))
continue;
List_iterator_fast <partition_element> sub_part_it(el->subpartitions);
- partition_element *subel;
- while ((subel= sub_part_it++) != NULL)
- {
- subel->index= index++;
+ partition_element *subel;
+ while ((subel= sub_part_it++) != NULL)
+ {
+ subel->index= index++;
if (my_hash_insert(&(m_part_info->partition_names), (byte*)subel))
- return 1;
- }
+ return 1;
+ }
}
return 0;
}
@@ -1051,7 +1051,10 @@
do
{
partition_element *part_elem= part_it++;
- VOID(hash_delete(&(m_part_info->partition_names), (byte*)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));
DBUG_RETURN(0);
@@ -1089,16 +1092,25 @@
{
uint error;
DBUG_ENTER("ha_partition::external_lock");
-
+
/* if this query specifies a partition, then set the bitmap accordingly */
if (table->partition_name != NULL)
- if (error= set_specific_partition(table->partition_name))
+ {
+ if ((error= set_specific_partition(table->partition_name)))
+ {
DBUG_RETURN(error);
-
+ }
+ }
+ /* REMOVE when psergey pushes his fix */
+ else
+ {
+ bitmap_set_all(&(m_part_info->used_partitions));
+ }
+
handler **file= m_file;
do
{
- if (error= (*file)->external_lock(thd, lock_type))
+ if ((error= (*file)->external_lock(thd, lock_type)))
{
if (F_UNLCK != lock_type)
goto err_handler;
@@ -1200,13 +1212,23 @@
/* if this query specifies a partition, then set the bitmap accordingly */
if (table->partition_name != NULL)
- if (error= set_specific_partition(table->partition_name))
+ {
+ if ((error= set_specific_partition(table->partition_name)))
+ {
DBUG_RETURN(error);
+ }
+ }
+ /* REMOVE when psergey pushes his fix */
+ else
+ {
+ bitmap_set_all(&(m_part_info->used_partitions));
+ }
+
handler **file= m_file;
do
{
- if (error= (*file)->start_stmt(thd, lock_type))
+ if ((error= (*file)->start_stmt(thd, lock_type)))
break;
} while (*(++file));
DBUG_RETURN(error);
@@ -1644,7 +1666,7 @@
/* End current partition */
late_extra_no_cache(current_partition_index);
DBUG_PRINT("info", ("rnd_end on partition %d", current_partition_index));
- if (result= file->ha_rnd_end())
+ if ((result= file->ha_rnd_end()))
break;
/* Shift to next partition */
@@ -1780,7 +1802,7 @@
{
/* TODO RONM: Change to index_init() when code is stable */
if (_bitmap_is_set(&(m_part_info->used_partitions), i))
- if (error= m_file[i]->ha_index_init(inx, sorted))
+ if ((error= m_file[i]->ha_index_init(inx, sorted)))
{
DBUG_ASSERT(0); // Should never happen
break;
@@ -1810,7 +1832,7 @@
int tmp;
/* TODO RONM: Change to index_init() when code is stable */
if (_bitmap_is_set(&(m_part_info->used_partitions), i))
- if (tmp= m_file[i]->ha_index_end())
+ if ((tmp= m_file[i]->ha_index_end()))
error= tmp;
}
DBUG_RETURN(error);
@@ -2227,43 +2249,62 @@
m_top_entry= NO_CURRENT_PART_ID;
queue_remove_all(&queue);
- for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
+
+ /* now we see what the index of our first important partition is */
+ current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
+ if (MY_BIT_NONE == current_partition_index)
{
- int error;
- byte *rec_buf_ptr= rec_buf(i);
- handler *file= m_file[i];
+ /*
+ The set of partitions to scan is empty. We return success and return
+ end of file on first rnd_next.
+ */
+ DBUG_RETURN(0);
+ }
- switch (m_index_scan_type) {
- case partition_index_read:
- error= file->index_read(rec_buf_ptr,
- m_start_key.key,
- m_start_key.length,
- m_start_key.flag);
- reverse_order= FALSE;
- break;
- case partition_index_first:
- error= file->index_first(rec_buf_ptr);
- reverse_order= FALSE;
- break;
- case partition_index_last:
- error= file->index_last(rec_buf_ptr);
- reverse_order= TRUE;
- break;
- default:
- DBUG_ASSERT(FALSE);
- DBUG_RETURN(HA_ERR_END_OF_FILE);
- }
- if (!error)
- {
- found= TRUE;
- /*
- Initialise queue without order first, simply insert
- */
- queue_element(&queue, j++)= (byte*)queue_buf(i);
- }
- else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
+ //for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
+ DBUG_PRINT("info", ("current_partition_index %d", current_partition_index));
+ for (i= current_partition_index; i <= m_part_spec.end_part; i++)
+ {
+ DBUG_PRINT("info", ("i %d", i));
+ if (_bitmap_is_set(&(m_part_info->used_partitions), i))
{
- DBUG_RETURN(error);
+ byte *rec_buf_ptr= rec_buf(i);
+ int error;
+ handler *file= m_file[i];
+ DBUG_PRINT("info", ("i %d is set", i));
+
+ switch (m_index_scan_type) {
+ case partition_index_read:
+ error= file->index_read(rec_buf_ptr,
+ m_start_key.key,
+ m_start_key.length,
+ m_start_key.flag);
+ reverse_order= FALSE;
+ break;
+ case partition_index_first:
+ error= file->index_first(rec_buf_ptr);
+ reverse_order= FALSE;
+ break;
+ case partition_index_last:
+ error= file->index_last(rec_buf_ptr);
+ reverse_order= TRUE;
+ break;
+ default:
+ DBUG_ASSERT(FALSE);
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
+ if (!error)
+ {
+ found= TRUE;
+ /*
+ Initialise queue without order first, simply insert
+ */
+ queue_element(&queue, j++)= (byte*)queue_buf(i);
+ }
+ else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
+ {
+ DBUG_RETURN(error);
+ }
}
}
if (found)
@@ -3423,10 +3464,10 @@
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
/*
- this doesn't seem to free share->partition_names,
+ this doesn't seem to free m_part_info->partition_names,
need to know how to make sure this happens
*/
- my_free((gptr) &share->partition_names, MYF(0));
+ my_free((gptr) &(m_part_info->partition_names), MYF(0));
my_free((gptr) share, MYF(0));
}
pthread_mutex_unlock(&partition_mutex);
--- New file ---
+++ mysql-test/r/partition_select.result 05/12/31 15:28:06
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (6) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (11) ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN (16) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (21) ENGINE = MyISAM);
INSERT INTO `t1` VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20);
SELECT * FROM t1;
id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
SELECT * FROM t1 PARTITION (p0);
id
1
2
3
4
5
SELECT * FROM t1 PARTITION (p1);
id
6
7
8
9
10
11
SELECT * FROM t1 PARTITION (p2);
id
12
13
14
15
16
SELECT * FROM t1 PARTITION (p3);
id
17
18
19
20
SELECT * FROM t1 PARTITION (p3) WHERE id = 2;
id
2
SELECT * FROM t1 PARTITION (foo);
ERROR HY000: partition 'foo' doesn't exist
CREATE TABLE `t2` (
`id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (6) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (11) ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN (16) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (21) ENGINE = MyISAM);
INSERT INTO `t2` VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20);
SELECT * FROM t2;
id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
SELECT * FROM t2 PARTITION (p0);
id
1
2
3
4
5
SELECT * FROM t2 PARTITION (p1);
id
6
7
8
9
10
11
SELECT * FROM t2 PARTITION (p2);
id
12
13
14
15
16
SELECT * FROM t2 PARTITION (p3);
id
17
18
19
20
SELECT * FROM t2 PARTITION (p3) WHERE id = 2;
id
2
SELECT * FROM t2 PARTITION (foo);
ERROR HY000: partition 'foo' doesn't exist
--- New file ---
+++ mysql-test/t/partition_select.test 05/12/31 15:28:06
#
# WL# 2682
# Partition select tests.
#
-- source include/have_partition.inc
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (6) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (11) ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN (16) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (21) ENGINE = MyISAM);
INSERT INTO `t1` VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20);
SELECT * FROM t1;
SELECT * FROM t1 PARTITION (p0);
SELECT * FROM t1 PARTITION (p1);
SELECT * FROM t1 PARTITION (p2);
SELECT * FROM t1 PARTITION (p3);
SELECT * FROM t1 PARTITION (p3) WHERE id = 2;
--error 1501
SELECT * FROM t1 PARTITION (foo);
# now try indexes
CREATE TABLE `t2` (
`id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (6) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (11) ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN (16) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (21) ENGINE = MyISAM);
INSERT INTO `t2` VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20);
SELECT * FROM t2;
SELECT * FROM t2 PARTITION (p0);
SELECT * FROM t2 PARTITION (p1);
SELECT * FROM t2 PARTITION (p2);
SELECT * FROM t2 PARTITION (p3);
SELECT * FROM t2 PARTITION (p3) WHERE id = 2;
--error 1501
SELECT * FROM t2 PARTITION (foo);
| Thread |
|---|
| • bk commit into 5.1 tree (patg:1.2019) | Patrick Galbraith | 1 Jan |