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

more changes

parent 074712ab
...@@ -964,7 +964,7 @@ uint Variable_size_keys_descriptor::make_packed_record(bool exclude_nulls) ...@@ -964,7 +964,7 @@ uint Variable_size_keys_descriptor::make_packed_record(bool exclude_nulls)
*/ */
bool bool
Descriptor::setup(THD *thd, Item_sum *item, Variable_size_keys_descriptor::setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count) uint non_const_args, uint arg_count)
{ {
SORT_FIELD *sort,*pos; SORT_FIELD *sort,*pos;
...@@ -1010,7 +1010,7 @@ Descriptor::setup(THD *thd, Item_sum *item, ...@@ -1010,7 +1010,7 @@ Descriptor::setup(THD *thd, Item_sum *item,
FALSE setup successful FALSE setup successful
*/ */
bool Descriptor::setup(THD *thd, Field *field) bool Variable_size_keys_descriptor::setup(THD *thd, Field *field)
{ {
SORT_FIELD *sort,*pos; SORT_FIELD *sort,*pos;
if (sortorder) if (sortorder)
...@@ -1026,7 +1026,6 @@ bool Descriptor::setup(THD *thd, Field *field) ...@@ -1026,7 +1026,6 @@ bool Descriptor::setup(THD *thd, Field *field)
return true; return true;
sort=pos= sortorder; sort=pos= sortorder;
pos->setup(field, false); // Nulls are always excluded pos->setup(field, false); // Nulls are always excluded
return false; return false;
} }
...@@ -1053,18 +1052,44 @@ int Variable_size_keys_descriptor::compare_keys(uchar *a_ptr, ...@@ -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_simple::Variable_size_keys_simple(uint length)
: Variable_size_keys_descriptor(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;
} }
int Variable_size_keys_simple::compare_keys(uchar *a, uchar *b) bool
Fixed_size_keys_descriptor::setup(THD *thd, Field *field)
{ {
return sort_keys->compare_keys_for_single_arg(a + size_of_length_field, return false;
b + size_of_length_field); }
int Fixed_size_keys_descriptor::compare_keys(uchar *a, uchar *b)
{
return 0;
} }
......
...@@ -59,8 +59,8 @@ class Descriptor : public Sql_alloc ...@@ -59,8 +59,8 @@ class Descriptor : public Sql_alloc
// Fill structures like sort_keys, sortorder // Fill structures like sort_keys, sortorder
virtual bool setup(THD *thd, Item_sum *item, virtual bool setup(THD *thd, Item_sum *item,
uint non_const_args, uint arg_count); uint non_const_args, uint arg_count) { return false; }
virtual bool setup(THD *thd, Field *field); virtual bool setup(THD *thd, Field *field) { return false; }
virtual Sort_keys *get_keys() { return sort_keys; } virtual Sort_keys *get_keys() { return sort_keys; }
SORT_FIELD *get_sortorder() { return sortorder; } SORT_FIELD *get_sortorder() { return sortorder; }
...@@ -79,16 +79,19 @@ class Fixed_size_keys_descriptor : public Descriptor ...@@ -79,16 +79,19 @@ class Fixed_size_keys_descriptor : public Descriptor
Fixed_size_keys_descriptor(uint length); Fixed_size_keys_descriptor(uint length);
~Fixed_size_keys_descriptor() {} ~Fixed_size_keys_descriptor() {}
uint get_length_of_key(uchar *ptr) override { return max_length; } 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: public:
Fixed_size_keys_simple_descriptor(uint length); Fixed_size_keys_simple(uint length);
~Fixed_size_keys_simple_descriptor() {} ~Fixed_size_keys_simple() {}
int compare_keys(uchar *a, uchar *b) override { return 0; } int compare_keys(uchar *a, uchar *b) override;
}; };
...@@ -110,17 +113,18 @@ class Variable_size_keys_descriptor : public Descriptor ...@@ -110,17 +113,18 @@ class Variable_size_keys_descriptor : public Descriptor
Variable_size_keys_descriptor(uint length); Variable_size_keys_descriptor(uint length);
~Variable_size_keys_descriptor(); ~Variable_size_keys_descriptor();
uchar *get_packed_rec_ptr() { return packed_rec_ptr; }
Sort_keys *get_keys() { return sort_keys; } Sort_keys *get_keys() { return sort_keys; }
SORT_FIELD *get_sortorder() { return sortorder; } SORT_FIELD *get_sortorder() { return sortorder; }
bool setup(THD *thd, Item_sum *item, uint non_const_args, uint arg_count);
uint make_packed_record(bool exclude_nulls); bool setup(THD *thd, Field *field);
uint get_length_of_key(uchar *ptr) override uint get_length_of_key(uchar *ptr) override
{ {
return read_packed_length(ptr); return read_packed_length(ptr);
} }
int compare_keys(uchar *a, uchar *b) override; 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 // returns the length of the key along with the length bytes for the key
static uint read_packed_length(uchar *p) static uint read_packed_length(uchar *p)
{ {
...@@ -132,6 +136,8 @@ class Variable_size_keys_descriptor : public Descriptor ...@@ -132,6 +136,8 @@ class Variable_size_keys_descriptor : public Descriptor
} }
static const uint size_of_length_field= 4; 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