Commit a4dfa930 authored by unknown's avatar unknown

Added support for different int sizes in condition pushdown

parent e9171b2c
...@@ -5777,14 +5777,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5777,14 +5777,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating EQ filter %s", DBUG_PRINT("info", ("Generating EQ filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (field->is_big())
filter->eq(field->get_field_no(), filter->cmp(NdbScanFilter::COND_EQ,
(Uint64) value->get_int_value()); field->get_field_no(),
else (void *) &int_value,
filter->eq(field->get_field_no(), field->pack_length());
(Uint32) value->get_int_value());
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
case(Item_func::NE_FUNC): { case(Item_func::NE_FUNC): {
...@@ -5800,15 +5799,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5800,15 +5799,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating NE filter %s", DBUG_PRINT("info", ("Generating NE filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (field->is_big())
filter->ne(field->get_field_no(), filter->cmp(NdbScanFilter::COND_NE,
(Uint64) value->get_int_value()); field->get_field_no(),
else (void *) &int_value,
filter->ne(field->get_field_no(), field->pack_length());
(Uint32) value->get_int_value(),
field->pack_length());
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
case(Item_func::LT_FUNC): { case(Item_func::LT_FUNC): {
...@@ -5824,25 +5821,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5824,25 +5821,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating LT filter %s", DBUG_PRINT("info", ("Generating LT filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (a == field) if (a == field)
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_LT,
filter->lt(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->lt(field->get_field_no(),
(Uint32) value->get_int_value());
} }
else else
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_GT,
filter->gt(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->gt(field->get_field_no(),
(Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5859,25 +5853,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5859,25 +5853,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating LE filter %s", DBUG_PRINT("info", ("Generating LE filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (a == field) if (a == field)
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_LE,
filter->le(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->le(field->get_field_no(),
(Uint32) value->get_int_value());
} }
else else
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_GE,
filter->ge(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->ge(field->get_field_no(),
(Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5894,25 +5885,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5894,25 +5885,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating GE filter %s", DBUG_PRINT("info", ("Generating GE filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (a == field) if (a == field)
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_GE,
filter->ge(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->ge(field->get_field_no(),
(Uint32) value->get_int_value());
} }
else else
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_LE,
filter->le(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->le(field->get_field_no(),
(Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5929,25 +5917,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5929,25 +5917,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b : (b->type == NDB_FIELD)? b
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating GT filter %s", DBUG_PRINT("info", ("Generating GT filter"));
field->is_big() ? "64 bit" : "")); longlong int_value= value->get_int_value();
if (a == field) if (a == field)
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_GT,
filter->gt(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->gt(field->get_field_no(),
(Uint32) value->get_int_value());
} }
else else
{ {
if (field->is_big()) filter->cmp(NdbScanFilter::COND_LT,
filter->lt(field->get_field_no(), field->get_field_no(),
(Uint64) value->get_int_value()); (void *) &int_value,
else field->pack_length());
filter->lt(field->get_field_no(),
(Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
......
...@@ -103,11 +103,6 @@ class Ndb_item { ...@@ -103,11 +103,6 @@ class Ndb_item {
Ndb_item(Item_func::Functype func_type); Ndb_item(Item_func::Functype func_type);
~Ndb_item(); ~Ndb_item();
void print(String *str); void print(String *str);
bool is_big()
{
enum_field_types type= value.field_value->field->type();
return (type == MYSQL_TYPE_LONGLONG || type == MYSQL_TYPE_INT24);
};
uint32 pack_length() { return value.field_value->field->pack_length(); }; uint32 pack_length() { return value.field_value->field->pack_length(); };
// Getters and Setters // Getters and Setters
longlong get_int_value() { return value.int_value; }; longlong get_int_value() { return value.int_value; };
......
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