mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
This commit is contained in:
229
sql/opt_range.cc
229
sql/opt_range.cc
@ -80,9 +80,9 @@
|
||||
*/
|
||||
#define double2rows(x) ((ha_rows)(x))
|
||||
|
||||
static int sel_cmp(Field *f,char *a,char *b,uint8 a_flag,uint8 b_flag);
|
||||
static int sel_cmp(Field *f,uchar *a,uchar *b,uint8 a_flag,uint8 b_flag);
|
||||
|
||||
static char is_null_string[2]= {1,0};
|
||||
static uchar is_null_string[2]= {1,0};
|
||||
|
||||
class RANGE_OPT_PARAM;
|
||||
/*
|
||||
@ -274,7 +274,7 @@ public:
|
||||
ulong use_count;
|
||||
|
||||
Field *field;
|
||||
char *min_value,*max_value; // Pointer to range
|
||||
uchar *min_value,*max_value; // Pointer to range
|
||||
|
||||
SEL_ARG *left,*right; /* R-B tree children */
|
||||
SEL_ARG *next,*prev; /* Links for bi-directional interval list */
|
||||
@ -287,8 +287,8 @@ public:
|
||||
|
||||
SEL_ARG() {}
|
||||
SEL_ARG(SEL_ARG &);
|
||||
SEL_ARG(Field *,const char *,const char *);
|
||||
SEL_ARG(Field *field, uint8 part, char *min_value, char *max_value,
|
||||
SEL_ARG(Field *,const uchar *, const uchar *);
|
||||
SEL_ARG(Field *field, uint8 part, uchar *min_value, uchar *max_value,
|
||||
uint8 min_flag, uint8 max_flag, uint8 maybe_flag);
|
||||
SEL_ARG(enum Type type_arg)
|
||||
:min_flag(0),elements(1),use_count(1),left(0),next_key_part(0),
|
||||
@ -324,7 +324,7 @@ public:
|
||||
}
|
||||
SEL_ARG *clone_and(SEL_ARG* arg)
|
||||
{ // Get overlapping range
|
||||
char *new_min,*new_max;
|
||||
uchar *new_min,*new_max;
|
||||
uint8 flag_min,flag_max;
|
||||
if (cmp_min_to_min(arg) >= 0)
|
||||
{
|
||||
@ -398,7 +398,7 @@ public:
|
||||
min_flag=arg->max_flag & NEAR_MAX ? 0 : NEAR_MIN;
|
||||
}
|
||||
/* returns a number of keypart values (0 or 1) appended to the key buffer */
|
||||
int store_min(uint length,char **min_key,uint min_key_flag)
|
||||
int store_min(uint length, uchar **min_key,uint min_key_flag)
|
||||
{
|
||||
if ((min_flag & GEOM_FLAG) ||
|
||||
(!(min_flag & NO_MIN_RANGE) &&
|
||||
@ -417,7 +417,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
/* returns a number of keypart values (0 or 1) appended to the key buffer */
|
||||
int store_max(uint length,char **max_key, uint max_key_flag)
|
||||
int store_max(uint length, uchar **max_key, uint max_key_flag)
|
||||
{
|
||||
if (!(max_flag & NO_MAX_RANGE) &&
|
||||
!(max_key_flag & (NO_MAX_RANGE | NEAR_MAX)))
|
||||
@ -436,7 +436,7 @@ public:
|
||||
}
|
||||
|
||||
/* returns a number of keypart values appended to the key buffer */
|
||||
int store_min_key(KEY_PART *key,char **range_key, uint *range_key_flag)
|
||||
int store_min_key(KEY_PART *key, uchar **range_key, uint *range_key_flag)
|
||||
{
|
||||
SEL_ARG *key_tree= first();
|
||||
uint res= key_tree->store_min(key[key_tree->part].store_length,
|
||||
@ -452,7 +452,7 @@ public:
|
||||
}
|
||||
|
||||
/* returns a number of keypart values appended to the key buffer */
|
||||
int store_max_key(KEY_PART *key,char **range_key, uint *range_key_flag)
|
||||
int store_max_key(KEY_PART *key, uchar **range_key, uint *range_key_flag)
|
||||
{
|
||||
SEL_ARG *key_tree= last();
|
||||
uint res=key_tree->store_max(key[key_tree->part].store_length,
|
||||
@ -534,8 +534,8 @@ public:
|
||||
*/
|
||||
if (min_flag || max_flag)
|
||||
return FALSE;
|
||||
byte *min_val= (byte *)min_value;
|
||||
byte *max_val= (byte *)max_value;
|
||||
uchar *min_val= min_value;
|
||||
uchar *max_val= max_value;
|
||||
|
||||
if (maybe_null)
|
||||
{
|
||||
@ -641,8 +641,7 @@ public:
|
||||
longlong baseflag;
|
||||
uint max_key_part, range_count;
|
||||
|
||||
|
||||
char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH],
|
||||
uchar min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH],
|
||||
max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
|
||||
bool quick; // Don't calulate possible keys
|
||||
|
||||
@ -683,8 +682,8 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts);
|
||||
static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree,
|
||||
bool update_tbl_stats);
|
||||
static ha_rows check_quick_keys(PARAM *param,uint index,SEL_ARG *key_tree,
|
||||
char *min_key, uint min_key_flag, int,
|
||||
char *max_key, uint max_key_flag, int);
|
||||
uchar *min_key, uint min_key_flag, int,
|
||||
uchar *max_key, uint max_key_flag, int);
|
||||
|
||||
QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index,
|
||||
SEL_ARG *key_tree,
|
||||
@ -726,12 +725,12 @@ static SEL_ARG *key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2,
|
||||
uint clone_flag);
|
||||
static bool get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_ARG *root1);
|
||||
bool get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
SEL_ARG *key_tree,char *min_key,uint min_key_flag,
|
||||
char *max_key,uint max_key_flag);
|
||||
SEL_ARG *key_tree, uchar *min_key,uint min_key_flag,
|
||||
uchar *max_key,uint max_key_flag);
|
||||
static bool eq_tree(SEL_ARG* a,SEL_ARG *b);
|
||||
|
||||
static SEL_ARG null_element(SEL_ARG::IMPOSSIBLE);
|
||||
static bool null_part_in_key(KEY_PART *key_part, const char *key,
|
||||
static bool null_part_in_key(KEY_PART *key_part, const uchar *key,
|
||||
uint length);
|
||||
bool sel_trees_can_be_ored(SEL_TREE *tree1, SEL_TREE *tree2, RANGE_OPT_PARAM* param);
|
||||
|
||||
@ -986,7 +985,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
|
||||
select->file= *head->sort.io_cache;
|
||||
select->records=(ha_rows) (select->file.end_of_file/
|
||||
head->file->ref_length);
|
||||
my_free((gptr) (head->sort.io_cache),MYF(0));
|
||||
my_free(head->sort.io_cache, MYF(0));
|
||||
head->sort.io_cache=0;
|
||||
}
|
||||
DBUG_RETURN(select);
|
||||
@ -1192,8 +1191,8 @@ QUICK_ROR_INTERSECT_SELECT::QUICK_ROR_INTERSECT_SELECT(THD *thd_param,
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0);
|
||||
else
|
||||
bzero(&alloc, sizeof(MEM_ROOT));
|
||||
last_rowid= (byte*)alloc_root(parent_alloc? parent_alloc : &alloc,
|
||||
head->file->ref_length);
|
||||
last_rowid= (uchar*) alloc_root(parent_alloc? parent_alloc : &alloc,
|
||||
head->file->ref_length);
|
||||
}
|
||||
|
||||
|
||||
@ -1450,7 +1449,7 @@ int QUICK_ROR_UNION_SELECT::init()
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (!(cur_rowid= (byte*)alloc_root(&alloc, 2*head->file->ref_length)))
|
||||
if (!(cur_rowid= (uchar*) alloc_root(&alloc, 2*head->file->ref_length)))
|
||||
DBUG_RETURN(1);
|
||||
prev_rowid= cur_rowid + head->file->ref_length;
|
||||
DBUG_RETURN(0);
|
||||
@ -1468,7 +1467,7 @@ int QUICK_ROR_UNION_SELECT::init()
|
||||
val2 Second merged select
|
||||
*/
|
||||
|
||||
int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, byte *val1, byte *val2)
|
||||
int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, uchar *val1, uchar *val2)
|
||||
{
|
||||
QUICK_ROR_UNION_SELECT *self= (QUICK_ROR_UNION_SELECT*)arg;
|
||||
return self->head->file->cmp_ref(((QUICK_SELECT_I*)val1)->last_rowid,
|
||||
@ -1519,7 +1518,7 @@ int QUICK_ROR_UNION_SELECT::reset()
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
quick->save_last_pos();
|
||||
queue_insert(&queue, (byte*)quick);
|
||||
queue_insert(&queue, (uchar*)quick);
|
||||
}
|
||||
|
||||
if (head->file->ha_rnd_init(1))
|
||||
@ -1580,16 +1579,18 @@ inline void SEL_ARG::make_root()
|
||||
use_count=0; elements=1;
|
||||
}
|
||||
|
||||
SEL_ARG::SEL_ARG(Field *f,const char *min_value_arg,const char *max_value_arg)
|
||||
SEL_ARG::SEL_ARG(Field *f,const uchar *min_value_arg,
|
||||
const uchar *max_value_arg)
|
||||
:min_flag(0), max_flag(0), maybe_flag(0), maybe_null(f->real_maybe_null()),
|
||||
elements(1), use_count(1), field(f), min_value((char*) min_value_arg),
|
||||
max_value((char*) max_value_arg), next(0),prev(0),
|
||||
elements(1), use_count(1), field(f), min_value((uchar*) min_value_arg),
|
||||
max_value((uchar*) max_value_arg), next(0),prev(0),
|
||||
next_key_part(0),color(BLACK),type(KEY_RANGE)
|
||||
{
|
||||
left=right= &null_element;
|
||||
}
|
||||
|
||||
SEL_ARG::SEL_ARG(Field *field_,uint8 part_,char *min_value_,char *max_value_,
|
||||
SEL_ARG::SEL_ARG(Field *field_,uint8 part_,
|
||||
uchar *min_value_, uchar *max_value_,
|
||||
uint8 min_flag_,uint8 max_flag_,uint8 maybe_flag_)
|
||||
:min_flag(min_flag_),max_flag(max_flag_),maybe_flag(maybe_flag_),
|
||||
part(part_),maybe_null(field_->real_maybe_null()), elements(1),use_count(1),
|
||||
@ -1667,7 +1668,8 @@ SEL_ARG *SEL_ARG::last()
|
||||
Returns -2 or 2 if the ranges where 'joined' like < 2 and >= 2
|
||||
*/
|
||||
|
||||
static int sel_cmp(Field *field, char *a,char *b,uint8 a_flag,uint8 b_flag)
|
||||
static int sel_cmp(Field *field, uchar *a, uchar *b, uint8 a_flag,
|
||||
uint8 b_flag)
|
||||
{
|
||||
int cmp;
|
||||
/* First check if there was a compare to a min or max element */
|
||||
@ -1691,7 +1693,7 @@ static int sel_cmp(Field *field, char *a,char *b,uint8 a_flag,uint8 b_flag)
|
||||
goto end; // NULL where equal
|
||||
a++; b++; // Skip NULL marker
|
||||
}
|
||||
cmp=field->key_cmp((byte*) a,(byte*) b);
|
||||
cmp=field->key_cmp(a , b);
|
||||
if (cmp) return cmp < 0 ? -1 : 1; // The values differed
|
||||
|
||||
// Check if the compared equal arguments was defined with open/closed range
|
||||
@ -1970,7 +1972,7 @@ private:
|
||||
KEY *index_info;
|
||||
uint index;
|
||||
uint key_infix_len;
|
||||
byte key_infix[MAX_KEY_LENGTH];
|
||||
uchar key_infix[MAX_KEY_LENGTH];
|
||||
SEL_TREE *range_tree; /* Represents all range predicates in the query. */
|
||||
SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
|
||||
uint param_idx; /* Index of used key in param->key. */
|
||||
@ -1983,7 +1985,7 @@ public:
|
||||
uint group_prefix_len_arg, uint used_key_parts_arg,
|
||||
uint group_key_parts_arg, KEY *index_info_arg,
|
||||
uint index_arg, uint key_infix_len_arg,
|
||||
byte *key_infix_arg,
|
||||
uchar *key_infix_arg,
|
||||
SEL_TREE *tree_arg, SEL_ARG *index_tree_arg,
|
||||
uint param_idx_arg, ha_rows quick_prefix_records_arg)
|
||||
: have_min(have_min_arg), have_max(have_max_arg),
|
||||
@ -2714,7 +2716,7 @@ end:
|
||||
format.
|
||||
*/
|
||||
|
||||
void store_key_image_to_rec(Field *field, char *ptr, uint len)
|
||||
void store_key_image_to_rec(Field *field, uchar *ptr, uint len)
|
||||
{
|
||||
/* Do the same as print_key() does */
|
||||
my_bitmap_map *old_map;
|
||||
@ -3416,7 +3418,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part)
|
||||
DBUG_LOCK_FILE;
|
||||
if (!(arg->min_flag & NO_MIN_RANGE))
|
||||
{
|
||||
store_key_image_to_rec(part->field, (char*)(arg->min_value), part->length);
|
||||
store_key_image_to_rec(part->field, arg->min_value, part->length);
|
||||
dbug_print_field(part->field);
|
||||
if (arg->min_flag & NEAR_MIN)
|
||||
fputs(" < ", DBUG_FILE);
|
||||
@ -3432,7 +3434,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part)
|
||||
fputs(" < ", DBUG_FILE);
|
||||
else
|
||||
fputs(" <= ", DBUG_FILE);
|
||||
store_key_image_to_rec(part->field, (char*)(arg->max_value), part->length);
|
||||
store_key_image_to_rec(part->field, arg->max_value, part->length);
|
||||
dbug_print_field(part->field);
|
||||
}
|
||||
fputs("\n", DBUG_FILE);
|
||||
@ -4169,8 +4171,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info,
|
||||
{
|
||||
double selectivity_mult= 1.0;
|
||||
KEY_PART_INFO *key_part= info->param->table->key_info[scan->keynr].key_part;
|
||||
byte key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */
|
||||
char *key_ptr= (char*) key_val;
|
||||
uchar key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */
|
||||
uchar *key_ptr= key_val;
|
||||
SEL_ARG *sel_arg, *tuple_arg= NULL;
|
||||
key_part_map keypart_map= 0;
|
||||
bool cur_covered;
|
||||
@ -4178,9 +4180,9 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info,
|
||||
key_part->fieldnr-1));
|
||||
key_range min_range;
|
||||
key_range max_range;
|
||||
min_range.key= (byte*) key_val;
|
||||
min_range.key= key_val;
|
||||
min_range.flag= HA_READ_KEY_EXACT;
|
||||
max_range.key= (byte*) key_val;
|
||||
max_range.key= key_val;
|
||||
max_range.flag= HA_READ_AFTER_KEY;
|
||||
ha_rows prev_records= info->param->table->file->stats.records;
|
||||
DBUG_ENTER("ror_scan_selectivity");
|
||||
@ -4209,7 +4211,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info,
|
||||
&key_ptr, 0);
|
||||
keypart_map= (keypart_map << 1) | 1;
|
||||
}
|
||||
min_range.length= max_range.length= ((char*) key_ptr - (char*) key_val);
|
||||
min_range.length= max_range.length= (size_t) (key_ptr - key_val);
|
||||
min_range.keypart_map= max_range.keypart_map= keypart_map;
|
||||
records= (info->param->table->file->
|
||||
records_in_range(scan->keynr, &min_range, &max_range));
|
||||
@ -5549,7 +5551,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
|
||||
bool optimize_range;
|
||||
SEL_ARG *tree= 0;
|
||||
MEM_ROOT *alloc= param->mem_root;
|
||||
char *str;
|
||||
uchar *str;
|
||||
ulong orig_sql_mode;
|
||||
int err;
|
||||
DBUG_ENTER("get_mm_leaf");
|
||||
@ -5611,9 +5613,10 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
|
||||
if (type == Item_func::LIKE_FUNC)
|
||||
{
|
||||
bool like_error;
|
||||
char buff1[MAX_FIELD_WIDTH],*min_str,*max_str;
|
||||
char buff1[MAX_FIELD_WIDTH];
|
||||
uchar *min_str,*max_str;
|
||||
String tmp(buff1,sizeof(buff1),value->collation.collation),*res;
|
||||
uint length,offset,min_length,max_length;
|
||||
size_t length, offset, min_length, max_length;
|
||||
uint field_length= field->pack_length()+maybe_null;
|
||||
|
||||
if (!optimize_range)
|
||||
@ -5660,7 +5663,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
|
||||
field_length= length;
|
||||
}
|
||||
length+=offset;
|
||||
if (!(min_str= (char*) alloc_root(alloc, length*2)))
|
||||
if (!(min_str= (uchar*) alloc_root(alloc, length*2)))
|
||||
goto end;
|
||||
|
||||
max_str=min_str+length;
|
||||
@ -5673,7 +5676,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
|
||||
((Item_func_like*)(param->cond))->escape,
|
||||
wild_one, wild_many,
|
||||
field_length,
|
||||
min_str+offset, max_str+offset,
|
||||
(char*) min_str+offset, (char*) max_str+offset,
|
||||
&min_length, &max_length);
|
||||
if (like_error) // Can't optimize with LIKE
|
||||
goto end;
|
||||
@ -5735,12 +5738,13 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
|
||||
goto end;
|
||||
}
|
||||
field->table->in_use->variables.sql_mode= orig_sql_mode;
|
||||
str= (char*) alloc_root(alloc, key_part->store_length+1);
|
||||
str= (uchar*) alloc_root(alloc, key_part->store_length+1);
|
||||
if (!str)
|
||||
goto end;
|
||||
if (maybe_null)
|
||||
*str= (char) field->is_real_null(); // Set to 1 if null
|
||||
field->get_key_image(str+maybe_null, key_part->length, key_part->image_type);
|
||||
*str= (uchar) field->is_real_null(); // Set to 1 if null
|
||||
field->get_key_image(str+maybe_null, key_part->length,
|
||||
key_part->image_type);
|
||||
if (!(tree= new (alloc) SEL_ARG(field, str, str)))
|
||||
goto end; // out of memory
|
||||
|
||||
@ -7244,13 +7248,13 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree, bool update_tbl_stats)
|
||||
|
||||
static ha_rows
|
||||
check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree,
|
||||
char *min_key, uint min_key_flag, int min_keypart,
|
||||
char *max_key, uint max_key_flag, int max_keypart)
|
||||
uchar *min_key, uint min_key_flag, int min_keypart,
|
||||
uchar *max_key, uint max_key_flag, int max_keypart)
|
||||
{
|
||||
ha_rows records=0, tmp;
|
||||
uint tmp_min_flag, tmp_max_flag, keynr, min_key_length, max_key_length;
|
||||
uint tmp_min_keypart= min_keypart, tmp_max_keypart= max_keypart;
|
||||
char *tmp_min_key, *tmp_max_key;
|
||||
uchar *tmp_min_key, *tmp_max_key;
|
||||
uint8 save_first_null_comp= param->first_null_comp;
|
||||
|
||||
param->max_key_part=max(param->max_key_part,key_tree->part);
|
||||
@ -7370,7 +7374,7 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree,
|
||||
if (tmp_min_flag & GEOM_FLAG)
|
||||
{
|
||||
key_range min_range;
|
||||
min_range.key= (byte*) param->min_key;
|
||||
min_range.key= param->min_key;
|
||||
min_range.length= min_key_length;
|
||||
min_range.keypart_map= make_keypart_map(tmp_min_keypart);
|
||||
/* In this case tmp_min_flag contains the handler-read-function */
|
||||
@ -7383,12 +7387,12 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree,
|
||||
{
|
||||
key_range min_range, max_range;
|
||||
|
||||
min_range.key= (byte*) param->min_key;
|
||||
min_range.key= param->min_key;
|
||||
min_range.length= min_key_length;
|
||||
min_range.flag= (tmp_min_flag & NEAR_MIN ? HA_READ_AFTER_KEY :
|
||||
HA_READ_KEY_EXACT);
|
||||
min_range.keypart_map= make_keypart_map(tmp_min_keypart);
|
||||
max_range.key= (byte*) param->max_key;
|
||||
max_range.key= param->max_key;
|
||||
max_range.length= max_key_length;
|
||||
max_range.flag= (tmp_max_flag & NEAR_MAX ?
|
||||
HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY);
|
||||
@ -7557,8 +7561,8 @@ get_quick_select(PARAM *param,uint idx,SEL_ARG *key_tree,
|
||||
*/
|
||||
bool
|
||||
get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
SEL_ARG *key_tree,char *min_key,uint min_key_flag,
|
||||
char *max_key, uint max_key_flag)
|
||||
SEL_ARG *key_tree, uchar *min_key,uint min_key_flag,
|
||||
uchar *max_key, uint max_key_flag)
|
||||
{
|
||||
QUICK_RANGE *range;
|
||||
uint flag;
|
||||
@ -7571,7 +7575,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
min_key,min_key_flag, max_key, max_key_flag))
|
||||
return 1;
|
||||
}
|
||||
char *tmp_min_key=min_key,*tmp_max_key=max_key;
|
||||
uchar *tmp_min_key=min_key,*tmp_max_key=max_key;
|
||||
min_part+= key_tree->store_min(key[key_tree->part].store_length,
|
||||
&tmp_min_key,min_key_flag);
|
||||
max_part+= key_tree->store_max(key[key_tree->part].store_length,
|
||||
@ -7595,10 +7599,10 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
uint tmp_min_flag=key_tree->min_flag,tmp_max_flag=key_tree->max_flag;
|
||||
if (!tmp_min_flag)
|
||||
min_part+= key_tree->next_key_part->store_min_key(key, &tmp_min_key,
|
||||
&tmp_min_flag);
|
||||
&tmp_min_flag);
|
||||
if (!tmp_max_flag)
|
||||
max_part+= key_tree->next_key_part->store_max_key(key, &tmp_max_key,
|
||||
&tmp_max_flag);
|
||||
&tmp_max_flag);
|
||||
flag=tmp_min_flag | tmp_max_flag;
|
||||
}
|
||||
}
|
||||
@ -7646,10 +7650,10 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
}
|
||||
|
||||
/* Get range for retrieving rows in QUICK_SELECT::get_next */
|
||||
if (!(range= new QUICK_RANGE((const char *) param->min_key,
|
||||
if (!(range= new QUICK_RANGE(param->min_key,
|
||||
(uint) (tmp_min_key - param->min_key),
|
||||
min_part >=0 ? make_keypart_map(min_part) : 0,
|
||||
(const char *) param->max_key,
|
||||
param->max_key,
|
||||
(uint) (tmp_max_key - param->max_key),
|
||||
max_part >=0 ? make_keypart_map(max_part) : 0,
|
||||
flag)))
|
||||
@ -7658,7 +7662,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
set_if_bigger(quick->max_used_key_length, range->min_length);
|
||||
set_if_bigger(quick->max_used_key_length, range->max_length);
|
||||
set_if_bigger(quick->used_key_parts, (uint) key_tree->part+1);
|
||||
if (insert_dynamic(&quick->ranges, (gptr)&range))
|
||||
if (insert_dynamic(&quick->ranges, (uchar*) &range))
|
||||
return 1;
|
||||
|
||||
end:
|
||||
@ -7691,9 +7695,9 @@ bool QUICK_RANGE_SELECT::unique_key_range()
|
||||
|
||||
/* Returns TRUE if any part of the key is NULL */
|
||||
|
||||
static bool null_part_in_key(KEY_PART *key_part, const char *key, uint length)
|
||||
static bool null_part_in_key(KEY_PART *key_part, const uchar *key, uint length)
|
||||
{
|
||||
for (const char *end=key+length ;
|
||||
for (const uchar *end=key+length ;
|
||||
key < end;
|
||||
key+= key_part++->store_length)
|
||||
{
|
||||
@ -7796,7 +7800,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
!(range= new(alloc) QUICK_RANGE()))
|
||||
goto err; // out of memory
|
||||
|
||||
range->min_key= range->max_key= (char*) ref->key_buff;
|
||||
range->min_key= range->max_key= ref->key_buff;
|
||||
range->min_length= range->max_length= ref->key_length;
|
||||
range->min_keypart_map= range->max_keypart_map=
|
||||
make_prev_keypart_map(ref->key_parts);
|
||||
@ -7817,7 +7821,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
key_part->null_bit= key_info->key_part[part].null_bit;
|
||||
key_part->flag= (uint8) key_info->key_part[part].key_part_flag;
|
||||
}
|
||||
if (insert_dynamic(&quick->ranges,(gptr)&range))
|
||||
if (insert_dynamic(&quick->ranges,(uchar*)&range))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
@ -7832,13 +7836,13 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
|
||||
*ref->null_ref_key= 1; // Set null byte then create a range
|
||||
if (!(null_range= new (alloc)
|
||||
QUICK_RANGE((char*)ref->key_buff, ref->key_length,
|
||||
QUICK_RANGE(ref->key_buff, ref->key_length,
|
||||
make_prev_keypart_map(ref->key_parts),
|
||||
(char*)ref->key_buff, ref->key_length,
|
||||
ref->key_buff, ref->key_length,
|
||||
make_prev_keypart_map(ref->key_parts), EQ_RANGE)))
|
||||
goto err;
|
||||
*ref->null_ref_key= 0; // Clear null byte
|
||||
if (insert_dynamic(&quick->ranges,(gptr)&null_range))
|
||||
if (insert_dynamic(&quick->ranges,(uchar*)&null_range))
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -8093,7 +8097,7 @@ int QUICK_ROR_UNION_SELECT::get_next()
|
||||
{
|
||||
int error, dup_row;
|
||||
QUICK_SELECT_I *quick;
|
||||
byte *tmp;
|
||||
uchar *tmp;
|
||||
DBUG_ENTER("QUICK_ROR_UNION_SELECT::get_next");
|
||||
|
||||
do
|
||||
@ -8143,7 +8147,7 @@ int QUICK_ROR_UNION_SELECT::get_next()
|
||||
int QUICK_RANGE_SELECT::reset()
|
||||
{
|
||||
uint mrange_bufsiz;
|
||||
byte *mrange_buff;
|
||||
uchar *mrange_buff;
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::reset");
|
||||
next=0;
|
||||
last_range= NULL;
|
||||
@ -8186,8 +8190,9 @@ int QUICK_RANGE_SELECT::reset()
|
||||
|
||||
while (mrange_bufsiz &&
|
||||
! my_multi_malloc(MYF(MY_WME),
|
||||
&multi_range_buff, sizeof(*multi_range_buff),
|
||||
&mrange_buff, mrange_bufsiz,
|
||||
&multi_range_buff,
|
||||
(uint) sizeof(*multi_range_buff),
|
||||
&mrange_buff, (uint) mrange_bufsiz,
|
||||
NullS))
|
||||
{
|
||||
/* Try to shrink the buffers until both are 0. */
|
||||
@ -8282,13 +8287,13 @@ int QUICK_RANGE_SELECT::get_next()
|
||||
end_key= &mrange_slot->end_key;
|
||||
last_range= *(cur_range++);
|
||||
|
||||
start_key->key= (const byte*) last_range->min_key;
|
||||
start_key->key= (const uchar*) last_range->min_key;
|
||||
start_key->length= last_range->min_length;
|
||||
start_key->flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
|
||||
(last_range->flag & EQ_RANGE) ?
|
||||
HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
|
||||
start_key->keypart_map= last_range->min_keypart_map;
|
||||
end_key->key= (const byte*) last_range->max_key;
|
||||
end_key->key= (const uchar*) last_range->max_key;
|
||||
end_key->length= last_range->max_length;
|
||||
/*
|
||||
We use HA_READ_AFTER_KEY here because if we are reading on a key
|
||||
@ -8348,7 +8353,7 @@ end:
|
||||
|
||||
int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length,
|
||||
key_part_map keypart_map,
|
||||
byte *cur_prefix)
|
||||
uchar *cur_prefix)
|
||||
{
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::get_next_prefix");
|
||||
|
||||
@ -8374,13 +8379,13 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length,
|
||||
}
|
||||
last_range= *(cur_range++);
|
||||
|
||||
start_key.key= (const byte*) last_range->min_key;
|
||||
start_key.key= (const uchar*) last_range->min_key;
|
||||
start_key.length= min(last_range->min_length, prefix_length);
|
||||
start_key.keypart_map= last_range->min_keypart_map & keypart_map;
|
||||
start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
|
||||
(last_range->flag & EQ_RANGE) ?
|
||||
HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
|
||||
end_key.key= (const byte*) last_range->max_key;
|
||||
end_key.key= (const uchar*) last_range->max_key;
|
||||
end_key.length= min(last_range->max_length, prefix_length);
|
||||
end_key.keypart_map= last_range->max_keypart_map & keypart_map;
|
||||
/*
|
||||
@ -8416,7 +8421,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
|
||||
if (last_range)
|
||||
{
|
||||
// Already read through key
|
||||
result= file->index_next_same(record, (byte*) last_range->min_key,
|
||||
result= file->index_next_same(record, last_range->min_key,
|
||||
last_range->min_length);
|
||||
if (result != HA_ERR_END_OF_FILE)
|
||||
DBUG_RETURN(result);
|
||||
@ -8431,7 +8436,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
|
||||
}
|
||||
last_range= *(cur_range++);
|
||||
|
||||
result= file->index_read(record, (byte*) last_range->min_key,
|
||||
result= file->index_read(record, last_range->min_key,
|
||||
last_range->min_keypart_map,
|
||||
(ha_rkey_function)(last_range->flag ^ GEOM_FLAG));
|
||||
if (result != HA_ERR_KEY_NOT_FOUND && result != HA_ERR_END_OF_FILE)
|
||||
@ -8536,7 +8541,7 @@ int QUICK_SELECT_DESC::get_next()
|
||||
if (last_range)
|
||||
{ // Already read through key
|
||||
result = ((last_range->flag & EQ_RANGE)
|
||||
? file->index_next_same(record, (byte*) last_range->min_key,
|
||||
? file->index_next_same(record, last_range->min_key,
|
||||
last_range->min_length) :
|
||||
file->index_prev(record));
|
||||
if (!result)
|
||||
@ -8564,14 +8569,14 @@ int QUICK_SELECT_DESC::get_next()
|
||||
|
||||
if (last_range->flag & EQ_RANGE)
|
||||
{
|
||||
result = file->index_read(record, (byte*) last_range->max_key,
|
||||
result = file->index_read(record, last_range->max_key,
|
||||
last_range->max_keypart_map, HA_READ_KEY_EXACT);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(last_range->flag & NEAR_MAX ||
|
||||
range_reads_after_key(last_range));
|
||||
result=file->index_read(record, (byte*) last_range->max_key,
|
||||
result=file->index_read(record, last_range->max_key,
|
||||
last_range->max_keypart_map,
|
||||
((last_range->flag & NEAR_MAX) ?
|
||||
HA_READ_BEFORE_KEY :
|
||||
@ -8608,7 +8613,7 @@ int QUICK_RANGE_SELECT::cmp_next(QUICK_RANGE *range_arg)
|
||||
KEY_PART *key_part=key_parts;
|
||||
uint store_length;
|
||||
|
||||
for (char *key=range_arg->max_key, *end=key+range_arg->max_length;
|
||||
for (uchar *key=range_arg->max_key, *end=key+range_arg->max_length;
|
||||
key < end;
|
||||
key+= store_length, key_part++)
|
||||
{
|
||||
@ -8627,7 +8632,7 @@ int QUICK_RANGE_SELECT::cmp_next(QUICK_RANGE *range_arg)
|
||||
key++; // Skip null byte
|
||||
store_length--;
|
||||
}
|
||||
if ((cmp=key_part->field->key_cmp((byte*) key, key_part->length)) < 0)
|
||||
if ((cmp=key_part->field->key_cmp(key, key_part->length)) < 0)
|
||||
return 0;
|
||||
if (cmp > 0)
|
||||
return 1;
|
||||
@ -8646,7 +8651,7 @@ int QUICK_RANGE_SELECT::cmp_prev(QUICK_RANGE *range_arg)
|
||||
if (range_arg->flag & NO_MIN_RANGE)
|
||||
return 0; /* key can't be to small */
|
||||
|
||||
cmp= key_cmp(key_part_info, (byte*) range_arg->min_key,
|
||||
cmp= key_cmp(key_part_info, range_arg->min_key,
|
||||
range_arg->min_length);
|
||||
if (cmp > 0 || cmp == 0 && !(range_arg->flag & NEAR_MIN))
|
||||
return 0;
|
||||
@ -8896,7 +8901,7 @@ static bool get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
|
||||
KEY_PART_INFO *first_non_group_part,
|
||||
KEY_PART_INFO *min_max_arg_part,
|
||||
KEY_PART_INFO *last_part, THD *thd,
|
||||
byte *key_infix, uint *key_infix_len,
|
||||
uchar *key_infix, uint *key_infix_len,
|
||||
KEY_PART_INFO **first_non_infix_part);
|
||||
static bool
|
||||
check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
|
||||
@ -9053,7 +9058,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
||||
uint index= 0; /* The id of the chosen index. */
|
||||
uint group_key_parts= 0; // Number of index key parts in the group prefix.
|
||||
uint used_key_parts= 0; /* Number of index key parts used for access. */
|
||||
byte key_infix[MAX_KEY_LENGTH]; /* Constants from equality predicates.*/
|
||||
uchar key_infix[MAX_KEY_LENGTH]; /* Constants from equality predicates.*/
|
||||
uint key_infix_len= 0; /* Length of key_infix. */
|
||||
TRP_GROUP_MIN_MAX *read_plan= NULL; /* The eventually constructed TRP. */
|
||||
uint key_part_nr;
|
||||
@ -9337,7 +9342,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
||||
|
||||
/* Check if cur_part is referenced in the WHERE clause. */
|
||||
if (join->conds->walk(&Item::find_item_in_field_list_processor, 0,
|
||||
(byte*) key_part_range))
|
||||
(uchar*) key_part_range))
|
||||
goto next_index;
|
||||
}
|
||||
}
|
||||
@ -9607,7 +9612,7 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
|
||||
KEY_PART_INFO *first_non_group_part,
|
||||
KEY_PART_INFO *min_max_arg_part,
|
||||
KEY_PART_INFO *last_part, THD *thd,
|
||||
byte *key_infix, uint *key_infix_len,
|
||||
uchar *key_infix, uint *key_infix_len,
|
||||
KEY_PART_INFO **first_non_infix_part)
|
||||
{
|
||||
SEL_ARG *cur_range;
|
||||
@ -9616,7 +9621,7 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
|
||||
KEY_PART_INFO *end_part= min_max_arg_part ? min_max_arg_part : last_part;
|
||||
|
||||
*key_infix_len= 0;
|
||||
byte *key_ptr= key_infix;
|
||||
uchar *key_ptr= key_infix;
|
||||
for (cur_part= first_non_group_part; cur_part != end_part; cur_part++)
|
||||
{
|
||||
/*
|
||||
@ -10006,7 +10011,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg,
|
||||
uint used_key_parts_arg, KEY *index_info_arg,
|
||||
uint use_index, double read_cost_arg,
|
||||
ha_rows records_arg, uint key_infix_len_arg,
|
||||
byte *key_infix_arg, MEM_ROOT *parent_alloc)
|
||||
uchar *key_infix_arg, MEM_ROOT *parent_alloc)
|
||||
:join(join_arg), index_info(index_info_arg),
|
||||
group_prefix_len(group_prefix_len_arg), have_min(have_min_arg),
|
||||
have_max(have_max_arg), seen_first_key(FALSE),
|
||||
@ -10064,13 +10069,13 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
|
||||
if (group_prefix) /* Already initialized. */
|
||||
return 0;
|
||||
|
||||
if (!(last_prefix= (byte*) alloc_root(&alloc, group_prefix_len)))
|
||||
if (!(last_prefix= (uchar*) alloc_root(&alloc, group_prefix_len)))
|
||||
return 1;
|
||||
/*
|
||||
We may use group_prefix to store keys with all select fields, so allocate
|
||||
enough space for it.
|
||||
*/
|
||||
if (!(group_prefix= (byte*) alloc_root(&alloc,
|
||||
if (!(group_prefix= (uchar*) alloc_root(&alloc,
|
||||
real_prefix_len + min_max_arg_len)))
|
||||
return 1;
|
||||
|
||||
@ -10080,7 +10085,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
|
||||
The memory location pointed to by key_infix will be deleted soon, so
|
||||
allocate a new buffer and copy the key_infix into it.
|
||||
*/
|
||||
byte *tmp_key_infix= (byte*) alloc_root(&alloc, key_infix_len);
|
||||
uchar *tmp_key_infix= (uchar*) alloc_root(&alloc, key_infix_len);
|
||||
if (!tmp_key_infix)
|
||||
return 1;
|
||||
memcpy(tmp_key_infix, this->key_infix, key_infix_len);
|
||||
@ -10195,7 +10200,7 @@ bool QUICK_GROUP_MIN_MAX_SELECT::add_range(SEL_ARG *sel_range)
|
||||
range_flag);
|
||||
if (!range)
|
||||
return TRUE;
|
||||
if (insert_dynamic(&min_max_ranges, (gptr)&range))
|
||||
if (insert_dynamic(&min_max_ranges, (uchar*)&range))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@ -10230,7 +10235,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::adjust_prefix_ranges ()
|
||||
{
|
||||
QUICK_RANGE *range;
|
||||
|
||||
get_dynamic(arr, (gptr)&range, inx);
|
||||
get_dynamic(arr, (uchar*)&range, inx);
|
||||
range->flag &= ~(NEAR_MIN | NEAR_MAX);
|
||||
}
|
||||
}
|
||||
@ -10266,7 +10271,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat()
|
||||
QUICK_RANGE *cur_range;
|
||||
if (have_min)
|
||||
{ /* Check if the right-most range has a lower boundary. */
|
||||
get_dynamic(&min_max_ranges, (gptr)&cur_range,
|
||||
get_dynamic(&min_max_ranges, (uchar*)&cur_range,
|
||||
min_max_ranges.elements - 1);
|
||||
if (!(cur_range->flag & NO_MIN_RANGE))
|
||||
{
|
||||
@ -10277,7 +10282,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat()
|
||||
}
|
||||
if (have_max)
|
||||
{ /* Check if the left-most range has an upper boundary. */
|
||||
get_dynamic(&min_max_ranges, (gptr)&cur_range, 0);
|
||||
get_dynamic(&min_max_ranges, (uchar*)&cur_range, 0);
|
||||
if (!(cur_range->flag & NO_MAX_RANGE))
|
||||
{
|
||||
max_used_key_length+= min_max_arg_len;
|
||||
@ -10603,7 +10608,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_prefix()
|
||||
|
||||
if (quick_prefix_select)
|
||||
{
|
||||
byte *cur_prefix= seen_first_key ? group_prefix : NULL;
|
||||
uchar *cur_prefix= seen_first_key ? group_prefix : NULL;
|
||||
if ((result= quick_prefix_select->get_next_prefix(group_prefix_len,
|
||||
make_prev_keypart_map(group_key_parts), cur_prefix)))
|
||||
DBUG_RETURN(result);
|
||||
@ -10673,14 +10678,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
|
||||
|
||||
for (uint range_idx= 0; range_idx < min_max_ranges.elements; range_idx++)
|
||||
{ /* Search from the left-most range to the right. */
|
||||
get_dynamic(&min_max_ranges, (gptr)&cur_range, range_idx);
|
||||
get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx);
|
||||
|
||||
/*
|
||||
If the current value for the min/max argument is bigger than the right
|
||||
boundary of cur_range, there is no need to check this range.
|
||||
*/
|
||||
if (range_idx != 0 && !(cur_range->flag & NO_MAX_RANGE) &&
|
||||
(key_cmp(min_max_arg_part, (const byte*) cur_range->max_key,
|
||||
(key_cmp(min_max_arg_part, (const uchar*) cur_range->max_key,
|
||||
min_max_arg_len) == 1))
|
||||
continue;
|
||||
|
||||
@ -10741,7 +10746,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
|
||||
if ( !(cur_range->flag & NO_MAX_RANGE) )
|
||||
{
|
||||
/* Compose the MAX key for the range. */
|
||||
byte *max_key= (byte*) my_alloca(real_prefix_len + min_max_arg_len);
|
||||
uchar *max_key= (uchar*) my_alloca(real_prefix_len + min_max_arg_len);
|
||||
memcpy(max_key, group_prefix, real_prefix_len);
|
||||
memcpy(max_key + real_prefix_len, cur_range->max_key,
|
||||
cur_range->max_length);
|
||||
@ -10805,7 +10810,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
|
||||
|
||||
for (uint range_idx= min_max_ranges.elements; range_idx > 0; range_idx--)
|
||||
{ /* Search from the right-most range to the left. */
|
||||
get_dynamic(&min_max_ranges, (gptr)&cur_range, range_idx - 1);
|
||||
get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx - 1);
|
||||
|
||||
/*
|
||||
If the current value for the min/max argument is smaller than the left
|
||||
@ -10813,7 +10818,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
|
||||
*/
|
||||
if (range_idx != min_max_ranges.elements &&
|
||||
!(cur_range->flag & NO_MIN_RANGE) &&
|
||||
(key_cmp(min_max_arg_part, (const byte*) cur_range->min_key,
|
||||
(key_cmp(min_max_arg_part, (const uchar*) cur_range->min_key,
|
||||
min_max_arg_len) == -1))
|
||||
continue;
|
||||
|
||||
@ -10859,7 +10864,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
|
||||
if ( !(cur_range->flag & NO_MIN_RANGE) )
|
||||
{
|
||||
/* Compose the MIN key for the range. */
|
||||
byte *min_key= (byte*) my_alloca(real_prefix_len + min_max_arg_len);
|
||||
uchar *min_key= (uchar*) my_alloca(real_prefix_len + min_max_arg_len);
|
||||
memcpy(min_key, group_prefix, real_prefix_len);
|
||||
memcpy(min_key + real_prefix_len, cur_range->min_key,
|
||||
cur_range->min_length);
|
||||
@ -11030,10 +11035,10 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
|
||||
*****************************************************************************/
|
||||
|
||||
static void
|
||||
print_key(KEY_PART *key_part,const char *key,uint used_length)
|
||||
print_key(KEY_PART *key_part, const uchar *key, uint used_length)
|
||||
{
|
||||
char buff[1024];
|
||||
const char *key_end= key+used_length;
|
||||
const uchar *key_end= key+used_length;
|
||||
String tmp(buff,sizeof(buff),&my_charset_bin);
|
||||
uint store_length;
|
||||
TABLE *table= key_part->field->table;
|
||||
@ -11056,7 +11061,7 @@ print_key(KEY_PART *key_part,const char *key,uint used_length)
|
||||
key++; // Skip null byte
|
||||
store_length--;
|
||||
}
|
||||
field->set_key_image((char*) key, key_part->length);
|
||||
field->set_key_image(key, key_part->length);
|
||||
if (field->type() == MYSQL_TYPE_BIT)
|
||||
(void) field->val_int_as_str(&tmp, 1);
|
||||
else
|
||||
@ -11111,7 +11116,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose)
|
||||
range= *pr;
|
||||
if (!(range->flag & NO_MIN_RANGE))
|
||||
{
|
||||
print_key(key_parts,range->min_key,range->min_length);
|
||||
print_key(key_parts, range->min_key, range->min_length);
|
||||
if (range->flag & NEAR_MIN)
|
||||
fputs(" < ",DBUG_FILE);
|
||||
else
|
||||
@ -11125,7 +11130,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose)
|
||||
fputs(" < ",DBUG_FILE);
|
||||
else
|
||||
fputs(" <= ",DBUG_FILE);
|
||||
print_key(key_parts,range->max_key,range->max_length);
|
||||
print_key(key_parts, range->max_key, range->max_length);
|
||||
}
|
||||
fputs("\n",DBUG_FILE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user