Commit 646f1003 authored by mskold@mysql.com's avatar mskold@mysql.com

Added support for different int sizes in condition pushdown

parent d3b643d7
...@@ -5778,13 +5778,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5778,13 +5778,13 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating EQ filter %s", DBUG_PRINT("info", ("Generating EQ filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (field->isBig()) if (field->is_big())
filter->eq(field->getFieldNo(), filter->eq(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->eq(field->getFieldNo(), filter->eq(field->get_field_no(),
(Uint32) value->getIntValue()); (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): {
...@@ -5801,13 +5801,14 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5801,13 +5801,14 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating NE filter %s", DBUG_PRINT("info", ("Generating NE filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (field->isBig()) if (field->is_big())
filter->ne(field->getFieldNo(), filter->ne(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->ne(field->getFieldNo(), filter->ne(field->get_field_no(),
(Uint32) value->getIntValue()); (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,24 +5825,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5824,24 +5825,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating LT filter %s", DBUG_PRINT("info", ("Generating LT filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (a == field) if (a == field)
{ {
if (field->isBig()) if (field->is_big())
filter->lt(field->getFieldNo(), filter->lt(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->lt(field->getFieldNo(), filter->lt(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
else else
{ {
if (field->isBig()) if (field->is_big())
filter->gt(field->getFieldNo(), filter->gt(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->gt(field->getFieldNo(), filter->gt(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5859,24 +5860,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5859,24 +5860,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating LE filter %s", DBUG_PRINT("info", ("Generating LE filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (a == field) if (a == field)
{ {
if (field->isBig()) if (field->is_big())
filter->le(field->getFieldNo(), filter->le(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->le(field->getFieldNo(), filter->le(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
else else
{ {
if (field->isBig()) if (field->is_big())
filter->ge(field->getFieldNo(), filter->ge(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->ge(field->getFieldNo(), filter->ge(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5894,24 +5895,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5894,24 +5895,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating GE filter %s", DBUG_PRINT("info", ("Generating GE filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (a == field) if (a == field)
{ {
if (field->isBig()) if (field->is_big())
filter->ge(field->getFieldNo(), filter->ge(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->ge(field->getFieldNo(), filter->ge(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
else else
{ {
if (field->isBig()) if (field->is_big())
filter->le(field->getFieldNo(), filter->le(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->le(field->getFieldNo(), filter->le(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5929,24 +5930,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5929,24 +5930,24 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
DBUG_PRINT("info", ("Generating GT filter %s", DBUG_PRINT("info", ("Generating GT filter %s",
field->isBig() ? "64 bit" : "")); field->is_big() ? "64 bit" : ""));
if (a == field) if (a == field)
{ {
if (field->isBig()) if (field->is_big())
filter->gt(field->getFieldNo(), filter->gt(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->gt(field->getFieldNo(), filter->gt(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
else else
{ {
if (field->isBig()) if (field->is_big())
filter->lt(field->getFieldNo(), filter->lt(field->get_field_no(),
(Uint64) value->getIntValue()); (Uint64) value->get_int_value());
else else
filter->lt(field->getFieldNo(), filter->lt(field->get_field_no(),
(Uint32) value->getIntValue()); (Uint32) value->get_int_value());
} }
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5964,9 +5965,9 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5964,9 +5965,9 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
if (value->qualification.value_type != Item::STRING_ITEM) break; if (value->qualification.value_type != Item::STRING_ITEM) break;
String *str= value->getStringValue(); String *str= value->get_string_value();
DBUG_PRINT("info", ("Generating LIKE filter: like(%d,%s,%d)", field->getFieldNo(), str->ptr(), str->length())); DBUG_PRINT("info", ("Generating LIKE filter: like(%d,%s,%d)", field->get_field_no(), str->ptr(), str->length()));
//filter->like(field->getFieldNo(), //filter->like(field->get_field_no(),
// str->ptr(), str->length(), TRUE); // str->ptr(), str->length(), TRUE);
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
...@@ -5984,22 +5985,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond, ...@@ -5984,22 +5985,22 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: NULL; : NULL;
if (!value || !field) break; if (!value || !field) break;
if (value->qualification.value_type != Item::STRING_ITEM) break; if (value->qualification.value_type != Item::STRING_ITEM) break;
String *str= value->getStringValue(); String *str= value->get_string_value();
DBUG_PRINT("info", ("Generating NOTLIKE filter: notlike(%d,%s,%d)", field->getFieldNo(), str->ptr(), str->length())); DBUG_PRINT("info", ("Generating NOTLIKE filter: notlike(%d,%s,%d)", field->get_field_no(), str->ptr(), str->length()));
//filter->notlike(field->getFieldNo(), //filter->notlike(field->get_field_no(),
// str->ptr(), str->length()); // str->ptr(), str->length());
DBUG_RETURN(cond->next->next->next); DBUG_RETURN(cond->next->next->next);
} }
case(Item_func::ISNULL_FUNC): case(Item_func::ISNULL_FUNC):
if (a->type == NDB_FIELD) { if (a->type == NDB_FIELD) {
DBUG_PRINT("info", ("Generating ISNULL filter")); DBUG_PRINT("info", ("Generating ISNULL filter"));
filter->isnull(a->getFieldNo()); filter->isnull(a->get_field_no());
} }
DBUG_RETURN(cond->next->next); DBUG_RETURN(cond->next->next);
case(Item_func::ISNOTNULL_FUNC): { case(Item_func::ISNOTNULL_FUNC): {
if (a->type == NDB_FIELD) { if (a->type == NDB_FIELD) {
DBUG_PRINT("info", ("Generating ISNOTNULL filter")); DBUG_PRINT("info", ("Generating ISNOTNULL filter"));
filter->isnotnull(a->getFieldNo()); filter->isnotnull(a->get_field_no());
} }
DBUG_RETURN(cond->next->next); DBUG_RETURN(cond->next->next);
} }
......
...@@ -103,18 +103,19 @@ class Ndb_item { ...@@ -103,18 +103,19 @@ 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 isBig() bool is_big()
{ {
enum_field_types type= value.field_value->field->type(); enum_field_types type= value.field_value->field->type();
return (type == MYSQL_TYPE_LONGLONG || type == MYSQL_TYPE_INT24); return (type == MYSQL_TYPE_LONGLONG || type == MYSQL_TYPE_INT24);
} };
uint32 pack_length() { return value.field_value->field->pack_length(); };
// Getters and Setters // Getters and Setters
longlong getIntValue() { return value.int_value; }; longlong get_int_value() { return value.int_value; };
double getRealValue() { return value.real_value; }; double get_real_value() { return value.real_value; };
String * getStringValue() { return &value.string_value->s; }; String * get_string_value() { return &value.string_value->s; };
CHARSET_INFO * getStringCharset() { return value.string_value->c; }; CHARSET_INFO * get_string_charset() { return value.string_value->c; };
Field * getField() { return value.field_value->field; }; Field * get_field() { return value.field_value->field; };
int getFieldNo() { return value.field_value->column_no; }; int get_field_no() { return value.field_value->column_no; };
public: public:
NDB_ITEM_TYPE type; NDB_ITEM_TYPE type;
......
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