From: Patrick Galbraith Date: December 31 2005 12:38am Subject: bk commit into 5.1 tree (patg:1.2008) List-Archive: http://lists.mysql.com/commits/478 Message-Id: <20051231003841.7E97565866B@govinda.site> 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.2008 05/12/30 16:38:35 patg@stripped +1 -0 WL# 2682 More progress sql/ha_partition.cc 1.20 05/12/30 16:37:26 patg@stripped +52 -129 WL# 2682 Added more looping with bitmap check (replaced do {...} while's) # 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.19/sql/ha_partition.cc 2005-12-29 16:14:33 -08:00 +++ 1.20/sql/ha_partition.cc 2005-12-30 16:37:26 -08:00 @@ -88,19 +88,6 @@ } -bool is_partition_in_table(PARTITION_SHARE *share, char *name) -{ - PARTITION_NAME *partition_name; - DBUG_ENTER("is_partition_in_table"); - partition_name= (PARTITION_NAME*)hash_search(&share->partition_names, - (byte*) name, - strlen(name)); - if (partition_name && partition_name->partition_name) - DBUG_RETURN(1); - - DBUG_RETURN(0); -} - /**************************************************************************** MODULE create/delete handler object ****************************************************************************/ @@ -924,40 +911,6 @@ } } return 0; - -/* for (i= 0; i < m_part_info->no_parts; i++) - { - PARTITION_NAME *partition_name = (PARTITION_NAME*)my_malloc(sizeof(PARTITION_NAME), MYF(MY_WME)); - partition_element *part_elem= part_it++; - partition_name->partition_name= part_elem->partition_name; - partition_name->partition_name_length= strlen(part_elem->partition_name); - partition_name->partition_number=part_num_counter++; - partition_name->is_sub_partition= FALSE; - if (my_hash_insert(&share->partition_names, (byte *)partition_name)) - goto err_handler; - if (is_sub_partitioned(m_part_info)) - { - List_iterator sub_it(part_elem->subpartitions); - for (j= 0; j < m_part_info->no_subparts; j++) - { - partition_element *sub_elem= sub_it++; - if (!strcmp(sub_elem->partition_name, part_elem->partition_name)) - { - PARTITION_NAME *sub_partition_name = - (PARTITION_NAME*)my_malloc(sizeof(PARTITION_NAME), MYF(MY_WME)); - sub_partition_name->partition_name= sub_elem->partition_name; - sub_partition_name->partition_name_length= strlen(sub_elem->partition_name); - sub_partition_name->partition_number=part_num_counter++; - sub_partition_name->is_sub_partition= TRUE; - } - else - { - continue; - } - } - } - DBUG_PRINT("info", ("partition name %s", part_elem->partition_name)); - }*/ } @@ -1093,14 +1046,8 @@ file= m_file; do { - //PARTITION_NAME *partition_name; partition_element *part_elem= part_it++; - //partition_name= (PARTITION_NAME*)hash_search(&share->partition_names, - // (byte*) part_elem->partition_name, - // strlen(part_elem->partition_name)); VOID(hash_delete(&(m_part_info->partition_names), (byte*)part_it++)); -// DBUG_PRINT("info", ("partition_name->partition_name %s", partition_name->partition_name)); - // my_free((gptr) partition_name, MYF(0)); (*file)->close(); } while (*(++file)); DBUG_RETURN(0); @@ -1137,24 +1084,21 @@ int ha_partition::external_lock(THD *thd, int lock_type) { + int i= 0; uint error; handler **file; bool is_in_list; -// List_iterator_fast part_it(m_part_info->partitions); DBUG_ENTER("ha_partition::external_lock"); - /* + /* if thd->lex->part_info is non-null, then we were given a specific partition to target */ - bitmap_set_all(&(m_part_info->used_partitions)); // TODO: remove this once the pruning patch goes in if (thd->lex->part_info) { int index; bitmap_clear_all(&(m_part_info->used_partitions)); index= get_partition_index(thd->lex->part_info->selected_partition); - // uint retval=0; retval= is_partition_in_table(share, - // thd->lex->part_info->selected_partition); if (index >= 0) { DBUG_PRINT("info", ("selected partition %s is in table", @@ -1169,30 +1113,20 @@ } DBUG_PRINT("info", ("is_in_list %d", is_in_list)); - //file= m_file; - int i= 0; for (i= 0; i < (int) m_part_info->no_parts; i++) { if (_bitmap_is_set(&(m_part_info->used_partitions), i)) if ((error= m_file[i]->external_lock(thd, lock_type))) { - DBUG_PRINT("info", ("(file)->s->table_name.str", (*file)->table_share->table_name.str)); + DBUG_PRINT("info", ("(file)->s->table_name.str", + (*file)->table_share->table_name.str)); if (lock_type != F_UNLCK) goto err_handler; } } - /* do - { - if ((error= (*file)->external_lock(thd, lock_type))) - { - DBUG_PRINT("info", ("(file)->s->table_name.str", (*file)->table_share->table_name.str)); - if (lock_type != F_UNLCK) - goto err_handler; - } - } while (*(++file));*/ - m_lock_type= lock_type; // For the future (2009?) + m_lock_type= lock_type; DBUG_RETURN(0); err_handler: @@ -1202,8 +1136,6 @@ m_file[i--]->external_lock(thd, F_UNLCK); } - //while (file-- != m_file) - //(*file)->external_lock(thd, F_UNLCK); DBUG_RETURN(error); } @@ -1258,15 +1190,15 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type) { + int i= 0; int error= 0; - handler **file; DBUG_ENTER("ha_partition::start_stmt"); - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { - if ((error= (*file)->start_stmt(thd, lock_type))) - break; - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + if ((error= m_file[i]->start_stmt(thd, lock_type))) + break; + } DBUG_RETURN(error); } @@ -1473,15 +1405,15 @@ int ha_partition::delete_all_rows() { + int i= 0; int error; - handler **file; DBUG_ENTER("ha_partition::delete_all_rows"); - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { - if ((error= (*file)->delete_all_rows())) - DBUG_RETURN(error); - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + if ((error= m_file[i]->delete_all_rows())) + DBUG_RETURN(error); + } DBUG_RETURN(0); } @@ -1491,7 +1423,7 @@ void ha_partition::start_bulk_insert(ha_rows rows) { - handler **file; + int i= 0; DBUG_ENTER("ha_partition::start_bulk_insert"); if (!rows) { @@ -1499,29 +1431,28 @@ DBUG_VOID_RETURN; } rows= rows/m_tot_parts + 1; - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { - (*file)->start_bulk_insert(rows); - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + m_file[i]->start_bulk_insert(rows); + } DBUG_VOID_RETURN; } int ha_partition::end_bulk_insert() { + int i= 0; int error= 0; - handler **file; DBUG_ENTER("ha_partition::end_bulk_insert"); - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { int tmp; - /* We want to execute end_bulk_insert() on all handlers */ - if ((tmp= (*file)->end_bulk_insert())) - error= tmp; - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + if ((tmp= m_file[i]->end_bulk_insert())) + error= tmp; + } DBUG_RETURN(error); } @@ -1553,12 +1484,12 @@ int ha_partition::rnd_init(bool scan) { int error; - int i= 0; + uint i= 0; handler **file; DBUG_ENTER("ha_partition::rnd_init"); include_partition_fields_in_used_fields(); - if (scan && 0) + if (scan) { /* rnd_end() is needed for partitioning to reset internal data if scan @@ -1585,7 +1516,7 @@ if (error) m_scan_value= 2; // No scan active - DBUG_PRINT("info", ("if scan && 0 m_scan_value %d", m_scan_value)); + DBUG_PRINT("info", ("if scan m_scan_value %d", m_scan_value)); DBUG_RETURN(error); } @@ -1596,13 +1527,6 @@ goto err; } - -// file= m_file; -// do -// { -// if ((error= (*file)->ha_rnd_init(0))) -// goto err; -// } while (*(++file)); m_scan_value= 0; DBUG_PRINT("info", ("m_scan_value %d", m_scan_value)); DBUG_RETURN(0); @@ -1613,15 +1537,13 @@ if (_bitmap_is_set(&(m_part_info->used_partitions), i)) m_file[i--]->ha_rnd_end(); } -// while (file--) - // (*file)->ha_rnd_end(); DBUG_RETURN(error); } int ha_partition::rnd_end() { - handler **file; + int i= 0; DBUG_ENTER("ha_partition::rnd_end"); switch (m_scan_value) { case 2: // Error @@ -1634,8 +1556,7 @@ } break; case 0: - int i=0; - file= m_file; + uint i=0; for (i= 0; i < m_part_info->no_parts; i++) { if (_bitmap_is_set(&(m_part_info->used_partitions), i)) @@ -1819,7 +1740,7 @@ int ha_partition::index_init(uint inx, bool sorted) { int error= 0; - int i= 0; + uint i= 0; handler **file; DBUG_ENTER("ha_partition::index_init"); @@ -1852,7 +1773,7 @@ int ha_partition::index_end() { int error= 0; - int i= 0; + uint i= 0; handler **file; DBUG_ENTER("ha_partition::index_end"); @@ -3001,9 +2922,9 @@ int result= 0, tmp; handler **file; DBUG_ENTER("ha_partition::reset"); - file= m_file; if (m_part_info) bitmap_clear_all(&m_part_info->used_partitions); + file= m_file; do { if ((tmp= (*file)->reset())) @@ -3012,7 +2933,6 @@ DBUG_RETURN(result); } - int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize) { DBUG_ENTER("ha_partition::extra_opt()"); @@ -3128,33 +3048,36 @@ ha_rows ha_partition::records_in_range(uint inx, key_range *min_key, key_range *max_key) { + int i= 0; ha_rows in_range= 0; - handler **file; DBUG_ENTER("ha_partition::records_in_range"); - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { - in_range+= (*file)->records_in_range(inx, min_key, max_key); - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + in_range+= m_file[i]->records_in_range(inx, min_key, max_key); + } DBUG_RETURN(in_range); } ha_rows ha_partition::estimate_rows_upper_bound() { + int i= 0; ha_rows rows, tot_rows= 0; - handler **file; DBUG_ENTER("ha_partition::estimate_rows_upper_bound"); - file= m_file; - do + for (i= 0; i < (int) m_part_info->no_parts; i++) { - rows= (*file)->estimate_rows_upper_bound(); - if (rows == HA_POS_ERROR) - DBUG_RETURN(HA_POS_ERROR); - tot_rows+= rows; - } while (*(++file)); + if (_bitmap_is_set(&(m_part_info->used_partitions), i)) + { + rows= m_file[i]->estimate_rows_upper_bound(); + + if (rows == HA_POS_ERROR) + DBUG_RETURN(HA_POS_ERROR); + tot_rows+= rows; + } + } DBUG_RETURN(tot_rows); }