Below is the list of changes that have just been committed into a local
5.0 repository of mikron. When mikron 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.1785 05/03/09 15:48:51 mronstrom@stripped +3 -0
WL1354 Partitioning
Fixed rnd_pos and position, various fixes and bug fixes
sql/sql_yacc.yy
1.347 05/03/09 15:48:44 mronstrom@stripped +4 -2
Fixed coding style
sql/ha_partition.h
1.19 05/03/09 15:48:44 mronstrom@stripped +2 -1
Fixed bug introduced during earlier fixes.
Fixed bug due to new stuff on server level (used dummy table
object instead of table == NULL.
Use m_scan_value=2 to indicate no scan on any partition ongoing
Various fixes for full table scan module
Fixed so that rnd_pos and position is to work.
sql/ha_partition.cc
1.18 05/03/09 15:48:44 mronstrom@stripped +105 -26
Fixed bug introduced during earlier fixes.
Fixed bug due to new stuff on server level (used dummy table
object instead of table == NULL.
Use m_scan_value=2 to indicate no scan on any partition ongoing
Various fixes for full table scan module
Fixed so that rnd_pos and position is to work.
# 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: mronstrom
# Host: mikael-ronstr-ms-dator.local
# Root: /Users/mikron/wl1354_new
--- 1.346/sql/sql_yacc.yy Thu Mar 3 20:36:22 2005
+++ 1.347/sql/sql_yacc.yy Wed Mar 9 15:48:44 2005
@@ -2504,13 +2504,15 @@
partition_entry:
PARTITION_SYM
{
- if (Lex->part_info) {
+ if (Lex->part_info)
+ {
/*
We enter here when opening the frm file to translate
partition info string into part_info data structure.
*/
Lex->part_info= new partition_info();
- } else
+ }
+ else
{
yyerror(ER(ER_PARTITION_ENTRY_ERROR));
YYABORT;
--- 1.17/sql/ha_partition.cc Thu Mar 3 20:36:20 2005
+++ 1.18/sql/ha_partition.cc Wed Mar 9 15:48:44 2005
@@ -82,8 +82,8 @@
init_handler_variables();
if (table)
{
- DBUG_ASSERT(table->s->part_info);
- m_part_info= table->s->part_info;
+ if (table->s->part_info)
+ m_part_info= table->s->part_info;
}
DBUG_VOID_RETURN;
}
@@ -94,6 +94,7 @@
DBUG_ENTER("ha_partition::ha_partition(part_info)");
init_handler_variables();
m_part_info= part_info;
+ m_create_handler= TRUE;
DBUG_ASSERT(m_part_info);
DBUG_VOID_RETURN;
}
@@ -111,7 +112,7 @@
m_pkey_is_clustered= 0;
m_lock_type= F_UNLCK;
m_curr_scan_part= NO_CURRENT_PART_ID;
- m_scan_value= 0;
+ m_scan_value= 2;
m_ref_length= 0;
m_current_index= 0;
m_current_index_part= NO_CURRENT_PART_ID;
@@ -664,7 +665,7 @@
char name_buff[FN_REFLEN];
char *name_buffer_ptr= m_name_buffer_ptr;
handler *file;
- m_ref_length= 0;
+ ref_length= 0;
if (get_from_handler_file(name))
DBUG_RETURN(TRUE);
for (i= 0; i < m_tot_parts; i++)
@@ -674,11 +675,15 @@
if (error=file->open((const char*)name_buff, mode, test_if_locked))
goto err_handler;
name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
- if (file->ref_length > m_ref_length)
- m_ref_length= file->ref_length;
+ if (file->ref_length > ref_length)
+ ref_length= file->ref_length;
}
- m_ref_length+=4; //Add 4 bytes for partition id in position ref length
- ref_length= m_ref_length;
+ /*
+ Add 2 bytes for partition id in position ref length.
+ ref_length=max_in_all_partitions(ref_length) + PARTITION_BYTES_IN_POS
+ */
+ ref_length+=PARTITION_BYTES_IN_POS;
+ m_ref_length=ref_length;
/*
Release buffer read from .par file. It will not be reused again after
being opened once.
@@ -981,33 +986,73 @@
-------------------------------------------------------------------------
*/
/*
- rnd_init() is called when the system wants the storage engine to do a
- table scan.
+ rnd_init() is called when the server wants the storage engine to do a
+ table scan or when the server wants to access data through rnd_pos.
+ When preparing for a scan the scan is TRUE and when preparing for using
+ rnd_pos scan is FALSE.
See the partition in the introduction at the top of this file to see when
rnd_init() is called.
+
+ When scan is used we will scan one handler partition at a time and end
+ when done. When preparing for rnd_pos we will init all handler partitions.
+ No extra cache handling is needed when scannning is not performed.
+ Before initialising we will call rnd_end to ensure that we clean up from
+ any previous incarnation of a table scan.
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc,
sql_table.cc, and sql_update.cc.
*/
int ha_partition::rnd_init(bool scan)
{
+ int error;
+ uint i;
DBUG_ENTER("ha_partition::rnd_init");
- m_curr_scan_part= 0;
- late_extra_cache(0);
- m_scan_value= scan;
- DBUG_RETURN(m_eng_ref[0]->ha_rnd_init(scan))
+ if (scan)
+ {
+ rnd_end();
+ m_curr_scan_part= 0;
+ late_extra_cache(0);
+ error= m_eng_ref[0]->ha_rnd_init(1);
+ if (error)
+ {
+ m_scan_value=2;
+ DBUG_RETURN(error);
+ }
+ m_scan_value=1;
+ DBUG_RETURN(FALSE);
+ }
+ else
+ {
+ for (i= 0; i < m_tot_parts; i++)
+ if (error=m_eng_ref[i]->ha_rnd_init(0))
+ goto err;
+ m_scan_value= 0;
+ DBUG_RETURN(FALSE);
+ }
+err:
+ for (i--; ~i; i--)
+ m_eng_ref[i]->ha_rnd_end();
+ DBUG_RETURN(error);
}
int ha_partition::rnd_end()
{
- DBUG_ENTER("ha_partition::rnd_end");
uint i;
- if (m_curr_scan_part == m_tot_parts)
- m_curr_scan_part--;
- for (i=m_curr_scan_part; ~i; i--)
- m_eng_ref[i]->ha_rnd_end();
+ DBUG_ENTER("ha_partition::rnd_end");
+ if (m_scan_value)
+ {
+ if (m_curr_scan_part != NO_CURRENT_PART_ID && m_scan_value == 1)
+ {
+ late_extra_no_cache(m_curr_scan_part);
+ m_eng_ref[m_curr_scan_part]->ha_rnd_end();
+ }
+ }
+ else
+ for (i= 0; i < m_tot_parts; i++)
+ m_eng_ref[i]->ha_rnd_end();
m_curr_scan_part= NO_CURRENT_PART_ID;
- DBUG_RETURN(0);
+ m_scan_value= 2;
+ DBUG_RETURN(FALSE);
}
/*
@@ -1023,9 +1068,12 @@
int ha_partition::rnd_next(byte *buf)
{
DBUG_ENTER("ha_partition::rnd_next");
+ DBUG_ASSERT(m_scan_value);
uint part_id= m_curr_scan_part;
handler *file= m_eng_ref[part_id];
int error= TRUE;
+ if (m_scan_value == 2)
+ goto err_handler;
if (part_id >= m_tot_parts)
goto err_handler;
while (TRUE)
@@ -1040,15 +1088,16 @@
else
{
late_extra_no_cache(part_id);
- file->ha_rnd_end();
+ if (error=file->ha_rnd_end())
+ DBUG_RETURN(error);
if (++part_id == m_tot_parts)
break;
+ m_scan_value=2;
file= m_eng_ref[part_id];
- if (error=file->ha_rnd_init(m_scan_value))
- {
+ if (error=file->ha_rnd_init(1))
DBUG_RETURN(error);
- }
late_extra_cache(part_id);
+ m_scan_value=1;
}
}
else
@@ -1064,6 +1113,19 @@
DBUG_RETURN(error);
}
+inline
+void store_part_id_in_pos(byte *pos, uint part_id)
+{
+ DBUG_ASSERT(part_id < 65536);
+ pos[0]= part_id & 255;
+ pos[1]= (part_id >> 8) & 255;
+}
+
+inline
+uint get_part_id_from_pos(byte *pos)
+{
+ return (uint)(pos[0] + (pos[1] << 8));
+}
/*
position() is called after each call to rnd_next() if the data needs
@@ -1081,11 +1143,16 @@
*/
void ha_partition::position(const byte *record)
{
+ uint part_id= m_curr_scan_part;
DBUG_ENTER("ha_partition::position");
+ DBUG_ASSERT(part_id < m_tot_parts);
+ m_eng_ref[part_id]->position(record);
+ store_part_id_in_pos(ref, part_id);
+ memcpy((ref+PARTITION_BYTES_IN_POS), m_eng_ref[part_id],
+ (ref_length - PARTITION_BYTES_IN_POS));
DBUG_VOID_RETURN;
}
-
/*
This is like rnd_next, but you are given a position to use
to determine the row. The position will be of the type that you stored in
@@ -1096,8 +1163,20 @@
*/
int ha_partition::rnd_pos(byte * buf, byte *pos)
{
+ uint part_id;
+ handler *file;
DBUG_ENTER("ha_partition::rnd_pos");
- DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ part_id=get_part_id_from_pos(pos);
+ file= m_eng_ref[part_id];
+ if (part_id < m_tot_parts)
+ {
+ DBUG_RETURN(file->rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS)));
+ }
+ else
+ {
+ DBUG_ASSERT(FALSE);
+ DBUG_RETURN(TRUE);
+ }
}
/*
--- 1.18/sql/ha_partition.h Thu Mar 3 20:36:21 2005
+++ 1.19/sql/ha_partition.h Wed Mar 9 15:48:44 2005
@@ -29,6 +29,7 @@
THR_LOCK lock;
} PARTITION_SHARE;
+#define PARTITION_BYTES_IN_POS 2
class ha_partition: public handler
{
private:
@@ -51,7 +52,7 @@
bool m_pkey_is_clustered; //Is primary key clustered
int m_lock_type; //Remembers type of last external_lock
uint m_curr_scan_part; //Current partition scanned in full table scan
- bool m_scan_value; //Value passed in rnd_init call
+ uint m_scan_value; //Value passed in rnd_init call
uint m_ref_length; // Length of position in this handler object
uint m_current_index; // Current index used in index scan
uint m_current_index_part; // Current partition scanned in index scan
| Thread |
|---|
| • bk commit into 5.0 tree (mronstrom:1.1785) | mikael | 9 Mar |