Commit 5876acb3 authored by Varun Gupta's avatar Varun Gupta

more changes

parent 074712ab
......@@ -964,8 +964,8 @@ uint Variable_size_keys_descriptor::make_packed_record(bool exclude_nulls)
*/
bool
Descriptor::setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count)
Variable_size_keys_descriptor::setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count)
{
SORT_FIELD *sort,*pos;
if (sortorder)
......@@ -1010,7 +1010,7 @@ Descriptor::setup(THD *thd, Item_sum *item,
FALSE setup successful
*/
bool Descriptor::setup(THD *thd, Field *field)
bool Variable_size_keys_descriptor::setup(THD *thd, Field *field)
{
SORT_FIELD *sort,*pos;
if (sortorder)
......@@ -1026,7 +1026,6 @@ bool Descriptor::setup(THD *thd, Field *field)
return true;
sort=pos= sortorder;
pos->setup(field, false); // Nulls are always excluded
return false;
}
......@@ -1053,18 +1052,44 @@ int Variable_size_keys_descriptor::compare_keys(uchar *a_ptr,
}
int Variable_size_keys_simple::compare_keys(uchar *a, uchar *b)
{
return sort_keys->compare_keys_for_single_arg(a + size_of_length_field,
b + size_of_length_field);
}
Variable_size_keys_simple::Variable_size_keys_simple(uint length)
: Variable_size_keys_descriptor(length)
{}
int Fixed_size_keys_simple::compare_keys(uchar *a, uchar *b)
{
SORT_FIELD *sort_field= sort_keys->begin();
DBUG_ASSERT(sort_field->field);
return sort_field->field->cmp(a, b);
}
bool
Fixed_size_keys_descriptor::setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count)
{
return false;
}
bool
Fixed_size_keys_descriptor::setup(THD *thd, Field *field)
{
return false;
}
int Variable_size_keys_simple::compare_keys(uchar *a, uchar *b)
int Fixed_size_keys_descriptor::compare_keys(uchar *a, uchar *b)
{
return sort_keys->compare_keys_for_single_arg(a + size_of_length_field,
b + size_of_length_field);
return 0;
}
......
......@@ -59,8 +59,8 @@ class Descriptor : public Sql_alloc
// Fill structures like sort_keys, sortorder
virtual bool setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count);
virtual bool setup(THD *thd, Field *field);
uint non_const_args, uint arg_count) { return false; }
virtual bool setup(THD *thd, Field *field) { return false; }
virtual Sort_keys *get_keys() { return sort_keys; }
SORT_FIELD *get_sortorder() { return sortorder; }
......@@ -79,16 +79,19 @@ class Fixed_size_keys_descriptor : public Descriptor
Fixed_size_keys_descriptor(uint length);
~Fixed_size_keys_descriptor() {}
uint get_length_of_key(uchar *ptr) override { return max_length; }
virtual int compare_keys(uchar *a, uchar *b) override { return 0; }
bool setup(THD *thd, Field *field);
bool setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count);
virtual int compare_keys(uchar *a, uchar *b) override;
};
class Fixed_size_keys_simple_descriptor : public Fixed_size_keys_descriptor
class Fixed_size_keys_simple : public Fixed_size_keys_descriptor
{
public:
Fixed_size_keys_simple_descriptor(uint length);
~Fixed_size_keys_simple_descriptor() {}
int compare_keys(uchar *a, uchar *b) override { return 0; }
Fixed_size_keys_simple(uint length);
~Fixed_size_keys_simple() {}
int compare_keys(uchar *a, uchar *b) override;
};
......@@ -110,17 +113,18 @@ class Variable_size_keys_descriptor : public Descriptor
Variable_size_keys_descriptor(uint length);
~Variable_size_keys_descriptor();
uchar *get_packed_rec_ptr() { return packed_rec_ptr; }
Sort_keys *get_keys() { return sort_keys; }
SORT_FIELD *get_sortorder() { return sortorder; }
uint make_packed_record(bool exclude_nulls);
bool setup(THD *thd, Item_sum *item, uint non_const_args, uint arg_count);
bool setup(THD *thd, Field *field);
uint get_length_of_key(uchar *ptr) override
{
return read_packed_length(ptr);
}
int compare_keys(uchar *a, uchar *b) override;
// All need to be moved to some new class
// returns the length of the key along with the length bytes for the key
static uint read_packed_length(uchar *p)
{
......@@ -132,6 +136,8 @@ class Variable_size_keys_descriptor : public Descriptor
}
static const uint size_of_length_field= 4;
uchar *get_packed_rec_ptr() { return packed_rec_ptr; }
uint make_packed_record(bool exclude_nulls);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment