diff options
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 121 |
1 files changed, 56 insertions, 65 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9d6e82b0356..299170d1ff4 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -54,6 +54,7 @@ #endif #include "mysql_priv.h" +#include "create_options.h" #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" @@ -1153,7 +1154,8 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, error != HA_ADMIN_ALREADY_DONE && error != HA_ADMIN_TRY_ALTER) { - print_admin_msg(thd, "error", table_share->db.str, table->alias, + print_admin_msg(thd, "error", table_share->db.str, + table->alias.c_ptr(), opt_op_name[flag], "Subpartition %s returned error", sub_elem->partition_name); @@ -1180,7 +1182,8 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, error != HA_ADMIN_ALREADY_DONE && error != HA_ADMIN_TRY_ALTER) { - print_admin_msg(thd, "error", table_share->db.str, table->alias, + print_admin_msg(thd, "error", table_share->db.str, + table->alias.c_ptr(), opt_op_name[flag], "Partition %s returned error", part_elem->partition_name); } @@ -1723,11 +1726,11 @@ int ha_partition::copy_partitions(ulonglong * const copied, uint32 new_part; late_extra_cache(reorg_part); - if ((result= file->ha_rnd_init(1))) + if ((result= file->ha_rnd_init_with_error(1))) goto error; while (TRUE) { - if ((result= file->rnd_next(m_rec0))) + if ((result= file->ha_rnd_next(m_rec0))) { if (result == HA_ERR_RECORD_DELETED) continue; //Probably MyISAM @@ -1951,6 +1954,8 @@ uint ha_partition::del_ren_cre_table(const char *from, { if ((error= set_up_table_before_create(table_arg, from_buff, create_info, i, NULL)) || + parse_engine_table_options(ha_thd(), (*file)->ht, + (*file)->table_share) || ((error= (*file)->ha_create(from_buff, table_arg, create_info)))) goto create_error; } @@ -2457,7 +2462,7 @@ bool ha_partition::read_par_file(const char *name) fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT); /* Following could be done with my_stat to read in whole file */ - if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0) + if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(MY_WME))) < 0) DBUG_RETURN(true); if (my_read(file, (uchar *) & buff[0], PAR_WORD_SIZE, MYF(MY_NABP))) goto err1; @@ -2564,7 +2569,7 @@ bool ha_partition::setup_engine_array(MEM_ROOT *mem_root) for (i= 0; i < m_tot_parts; i++) m_engine_array[i]= ha_lock_engine(NULL, engine_array[i]); - my_afree((gptr) engine_array); + my_afree(engine_array); if (create_handlers(mem_root)) { @@ -2575,7 +2580,7 @@ bool ha_partition::setup_engine_array(MEM_ROOT *mem_root) DBUG_RETURN(false); err: - my_afree((gptr) engine_array); + my_afree(engine_array); DBUG_RETURN(true); } @@ -2676,7 +2681,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) name_buffer_ptr= m_name_buffer_ptr; m_start_key.length= 0; m_rec0= table->record[0]; - m_rec_length= table_share->reclength; + m_rec_length= table_share->stored_rec_length; alloc_len= m_tot_parts * (m_rec_length + PARTITION_BYTES_IN_POS); alloc_len+= table_share->max_key_length; if (!m_ordered_rec_buffer) @@ -3941,6 +3946,7 @@ int ha_partition::rnd_next(uchar *buf) int result= HA_ERR_END_OF_FILE; uint part_id= m_part_spec.start_part; DBUG_ENTER("ha_partition::rnd_next"); + decrement_statistics(&SSV::ha_read_rnd_next_count); if (NO_CURRENT_PART_ID == part_id) { @@ -3956,7 +3962,7 @@ int ha_partition::rnd_next(uchar *buf) while (TRUE) { - result= file->rnd_next(buf); + result= file->ha_rnd_next(buf); if (!result) { m_last_part= part_id; @@ -4088,6 +4094,7 @@ int ha_partition::rnd_pos(uchar * buf, uchar *pos) uint part_id; handler *file; DBUG_ENTER("ha_partition::rnd_pos"); + decrement_statistics(&SSV::ha_read_rnd_count); part_id= uint2korr((const uchar *) pos); DBUG_ASSERT(part_id < m_tot_parts); @@ -4300,6 +4307,7 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key, enum ha_rkey_function find_flag) { DBUG_ENTER("ha_partition::index_read_map"); + decrement_statistics(&SSV::ha_read_key_count); end_range= 0; m_index_scan_type= partition_index_read; m_start_key.key= key; @@ -4428,6 +4436,7 @@ int ha_partition::common_index_read(uchar *buf, bool have_start_key) int ha_partition::index_first(uchar * buf) { DBUG_ENTER("ha_partition::index_first"); + decrement_statistics(&SSV::ha_read_first_count); end_range= 0; m_index_scan_type= partition_index_first; @@ -4459,6 +4468,7 @@ int ha_partition::index_first(uchar * buf) int ha_partition::index_last(uchar * buf) { DBUG_ENTER("ha_partition::index_last"); + decrement_statistics(&SSV::ha_read_last_count); m_index_scan_type= partition_index_last; DBUG_RETURN(common_first_last(buf)); @@ -4487,39 +4497,6 @@ int ha_partition::common_first_last(uchar *buf) /* - Read last using key - - SYNOPSIS - index_read_last_map() - buf Read row in MySQL Row Format - key Key - keypart_map Which part of key is used - - RETURN VALUE - >0 Error code - 0 Success - - DESCRIPTION - This is used in join_read_last_key to optimise away an ORDER BY. - Can only be used on indexes supporting HA_READ_ORDER -*/ - -int ha_partition::index_read_last_map(uchar *buf, const uchar *key, - key_part_map keypart_map) -{ - DBUG_ENTER("ha_partition::index_read_last"); - - m_ordered= TRUE; // Safety measure - end_range= 0; - m_index_scan_type= partition_index_read_last; - m_start_key.key= key; - m_start_key.keypart_map= keypart_map; - m_start_key.flag= HA_READ_PREFIX_LAST; - DBUG_RETURN(common_index_read(buf, TRUE)); -} - - -/* Optimization of the default implementation to take advantage of dynamic partition pruning. */ @@ -4595,6 +4572,7 @@ int ha_partition::index_read_idx_map(uchar *buf, uint index, int ha_partition::index_next(uchar * buf) { DBUG_ENTER("ha_partition::index_next"); + decrement_statistics(&SSV::ha_read_next_count); /* TODO(low priority): @@ -4631,6 +4609,7 @@ int ha_partition::index_next(uchar * buf) int ha_partition::index_next_same(uchar *buf, const uchar *key, uint keylen) { DBUG_ENTER("ha_partition::index_next_same"); + decrement_statistics(&SSV::ha_read_next_count); DBUG_ASSERT(keylen == m_start_key.length); DBUG_ASSERT(m_index_scan_type != partition_index_last); @@ -4658,6 +4637,7 @@ int ha_partition::index_next_same(uchar *buf, const uchar *key, uint keylen) int ha_partition::index_prev(uchar * buf) { DBUG_ENTER("ha_partition::index_prev"); + decrement_statistics(&SSV::ha_read_prev_count); /* TODO: read comment in index_next */ DBUG_ASSERT(m_index_scan_type != partition_index_first); @@ -4870,8 +4850,8 @@ int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) } else if (is_next_same) { - if (!(error= file->index_next_same(buf, m_start_key.key, - m_start_key.length))) + if (!(error= file->ha_index_next_same(buf, m_start_key.key, + m_start_key.length))) { m_last_part= m_part_spec.start_part; DBUG_RETURN(0); @@ -4879,7 +4859,7 @@ int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) } else { - if (!(error= file->index_next(buf))) + if (!(error= file->ha_index_next(buf))) { m_last_part= m_part_spec.start_part; DBUG_RETURN(0); // Row was in range @@ -4934,13 +4914,13 @@ int ha_partition::handle_unordered_scan_next_partition(uchar * buf) break; case partition_index_read: DBUG_PRINT("info", ("index_read on partition %d", i)); - error= file->index_read_map(buf, m_start_key.key, - m_start_key.keypart_map, - m_start_key.flag); + error= file->ha_index_read_map(buf, m_start_key.key, + m_start_key.keypart_map, + m_start_key.flag); break; case partition_index_first: DBUG_PRINT("info", ("index_first on partition %d", i)); - error= file->index_first(buf); + error= file->ha_index_first(buf); break; case partition_index_first_unordered: /* @@ -5021,23 +5001,17 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) switch (m_index_scan_type) { case partition_index_read: - error= file->index_read_map(rec_buf_ptr, - m_start_key.key, - m_start_key.keypart_map, - m_start_key.flag); + error= file->ha_index_read_map(rec_buf_ptr, + m_start_key.key, + m_start_key.keypart_map, + m_start_key.flag); break; case partition_index_first: - error= file->index_first(rec_buf_ptr); + error= file->ha_index_first(rec_buf_ptr); reverse_order= FALSE; break; case partition_index_last: - error= file->index_last(rec_buf_ptr); - reverse_order= TRUE; - break; - case partition_index_read_last: - error= file->index_read_last_map(rec_buf_ptr, - m_start_key.key, - m_start_key.keypart_map); + error= file->ha_index_last(rec_buf_ptr); reverse_order= TRUE; break; case partition_read_range: @@ -5139,10 +5113,10 @@ int ha_partition::handle_ordered_next(uchar *buf, bool is_next_same) memcpy(rec_buf(part_id), table->record[0], m_rec_length); } else if (!is_next_same) - error= file->index_next(rec_buf(part_id)); + error= file->ha_index_next(rec_buf(part_id)); else - error= file->index_next_same(rec_buf(part_id), m_start_key.key, - m_start_key.length); + error= file->ha_index_next_same(rec_buf(part_id), m_start_key.key, + m_start_key.length); if (error) { if (error == HA_ERR_END_OF_FILE) @@ -5187,7 +5161,7 @@ int ha_partition::handle_ordered_prev(uchar *buf) handler *file= m_file[part_id]; DBUG_ENTER("ha_partition::handle_ordered_prev"); - if ((error= file->index_prev(rec_buf(part_id)))) + if ((error= file->ha_index_prev(rec_buf(part_id)))) { if (error == HA_ERR_END_OF_FILE) { @@ -7148,5 +7122,22 @@ mysql_declare_plugin(partition) NULL /* config options */ } mysql_declare_plugin_end; +maria_declare_plugin(partition) +{ + MYSQL_STORAGE_ENGINE_PLUGIN, + &partition_storage_engine, + "partition", + "Mikael Ronstrom, MySQL AB", + "Partition Storage Engine Helper", + PLUGIN_LICENSE_GPL, + partition_initialize, /* Plugin Init */ + NULL, /* Plugin Deinit */ + 0x0100, /* 1.0 */ + NULL, /* status variables */ + NULL, /* system variables */ + "1.0", /* string version */ + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +} +maria_declare_plugin_end; #endif |