summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-06-06 14:09:06 +0400
committerAlexander Barkov <bar@mariadb.com>2018-06-06 14:09:06 +0400
commitc20cd68e60465f43266fe2bc2b2190e7c1cc4983 (patch)
tree16beb4138d72ba2fac7c33fab3cf94b3591fc3cf /storage
parent395212446acec1191d570d15eb03219c2cb11791 (diff)
downloadmariadb-git-c20cd68e60465f43266fe2bc2b2190e7c1cc4983.tar.gz
MDEV-14630 Replace {STRING|INT|REAL|DECIMAL|DATE}_ITEM to CONST_ITEM
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/ha_connect.cc67
-rw-r--r--storage/mroonga/lib/mrn_condition_converter.cpp18
-rw-r--r--storage/sphinx/ha_sphinx.cc8
-rw-r--r--storage/spider/spd_db_conn.cc77
4 files changed, 99 insertions, 71 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 36aae798637..4abc4ad1d17 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -2726,37 +2726,44 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
if (!i && (ismul))
return NULL;
- switch (args[i]->real_type()) {
- case COND::STRING_ITEM:
- res= pval->val_str(&tmp);
- pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
- pp->Type= (pp->Value) ? TYPE_STRING : TYPE_ERROR;
- break;
- case COND::INT_ITEM:
- pp->Type= TYPE_INT;
- pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
- *((int*)pp->Value)= (int)pval->val_int();
- break;
- case COND::DATE_ITEM:
- pp->Type= TYPE_DATE;
- pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
- *((int*)pp->Value)= (int)pval->val_int_from_date();
- break;
- case COND::REAL_ITEM:
- pp->Type= TYPE_DOUBLE;
- pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
- *((double*)pp->Value)= pval->val_real();
- break;
- case COND::DECIMAL_ITEM:
- pp->Type= TYPE_DOUBLE;
- pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
- *((double*)pp->Value)= pval->val_real_from_decimal();
- break;
+ switch (args[i]->real_type()) {
+ case COND::CONST_ITEM:
+ switch (args[i]->cmp_type()) {
+ case STRING_RESULT:
+ res= pval->val_str(&tmp);
+ pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
+ pp->Type= (pp->Value) ? TYPE_STRING : TYPE_ERROR;
+ break;
+ case INT_RESULT:
+ pp->Type= TYPE_INT;
+ pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
+ *((int*)pp->Value)= (int)pval->val_int();
+ break;
+ case TIME_RESULT:
+ pp->Type= TYPE_DATE;
+ pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
+ *((int*)pp->Value)= (int)pval->val_int_from_date();
+ break;
+ case REAL_RESULT:
+ pp->Type= TYPE_DOUBLE;
+ pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
+ *((double*)pp->Value)= pval->val_real();
+ break;
+ case DECIMAL_RESULT:
+ pp->Type= TYPE_DOUBLE;
+ pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
+ *((double*)pp->Value)= pval->val_real_from_decimal();
+ break;
+ case ROW_RESULT:
+ DBUG_ASSERT(0);
+ return NULL;
+ }
+ break;
case COND::CACHE_ITEM: // Possible ???
case COND::NULL_ITEM: // TODO: handle this
default:
return NULL;
- } // endswitch type
+ } // endswitch type
if (trace(1))
htrc("Value type=%hd\n", pp->Type);
@@ -3008,12 +3015,8 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
Item::Type type= args[i]->real_type();
switch (type) {
- case COND::STRING_ITEM:
- case COND::INT_ITEM:
- case COND::REAL_ITEM:
+ case COND::CONST_ITEM:
case COND::NULL_ITEM:
- case COND::DECIMAL_ITEM:
- case COND::DATE_ITEM:
case COND::CACHE_ITEM:
break;
default:
diff --git a/storage/mroonga/lib/mrn_condition_converter.cpp b/storage/mroonga/lib/mrn_condition_converter.cpp
index 579292a7f89..9b9854a8a02 100644
--- a/storage/mroonga/lib/mrn_condition_converter.cpp
+++ b/storage/mroonga/lib/mrn_condition_converter.cpp
@@ -179,17 +179,17 @@ namespace mrn {
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
- if (value_item->type() == Item::STRING_ITEM &&
+ if (value_item->is_of_type(Item::CONST_ITEM, STRING_RESULT) &&
func_type == Item_func::EQ_FUNC) {
convertable = have_index(field_item, GRN_OP_EQUAL);
}
break;
case INT_TYPE:
if (field_type == MYSQL_TYPE_ENUM) {
- convertable = (value_item->type() == Item::STRING_ITEM ||
- value_item->type() == Item::INT_ITEM);
+ convertable = value_item->is_of_type(Item::CONST_ITEM, STRING_RESULT) ||
+ value_item->is_of_type(Item::CONST_ITEM, INT_RESULT);
} else {
- convertable = value_item->type() == Item::INT_ITEM;
+ convertable = value_item->is_of_type(Item::CONST_ITEM, INT_RESULT);
}
break;
case TIME_TYPE:
@@ -215,14 +215,14 @@ namespace mrn {
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
- if (min_item->type() == Item::STRING_ITEM &&
- max_item->type() == Item::STRING_ITEM) {
+ if (min_item->is_of_type(Item::CONST_ITEM, STRING_RESULT) &&
+ max_item->is_of_type(Item::CONST_ITEM, STRING_RESULT)) {
convertable = have_index(field_item, GRN_OP_LESS);
}
break;
case INT_TYPE:
- if (min_item->type() == Item::INT_ITEM &&
- max_item->type() == Item::INT_ITEM) {
+ if (min_item->is_of_type(Item::CONST_ITEM, INT_RESULT) &&
+ max_item->is_of_type(Item::CONST_ITEM, INT_RESULT)) {
convertable = have_index(field_item, GRN_OP_LESS);
}
break;
@@ -587,7 +587,7 @@ namespace mrn {
case INT_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
if (field_type == MYSQL_TYPE_ENUM) {
- if (const_item->type() == Item::STRING_ITEM) {
+ if (const_item->is_of_type(Item::CONST_ITEM, STRING_RESULT)) {
String *string;
string = const_item->val_str(NULL);
Field_enum *enum_field = static_cast<Field_enum *>(field_item->field);
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 580b3fe539f..f611d66496e 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -2746,7 +2746,9 @@ const Item * ha_sphinx::cond_push ( const Item *cond )
if ( !m_pShare->m_bSphinxQL )
{
// on non-QL tables, intercept query=value condition for SELECT
- if (!( args[0]->type()==Item::FIELD_ITEM && args[1]->type()==Item::STRING_ITEM ))
+ if (!( args[0]->type()==Item::FIELD_ITEM &&
+ args[1]->is_of_type(Item::CONST_ITEM,
+ STRING_RESULT)))
break;
Item_field * pField = (Item_field *) args[0];
@@ -2762,7 +2764,9 @@ const Item * ha_sphinx::cond_push ( const Item *cond )
} else
{
- if (!( args[0]->type()==Item::FIELD_ITEM && args[1]->type()==Item::INT_ITEM ))
+ if (!( args[0]->type()==Item::FIELD_ITEM &&
+ args[1]->is_of_type(Item::CONST_ITEM,
+ INT_RESULT)))
break;
// on QL tables, intercept id=value condition for DELETE
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 83de99e0d2f..ebfea1be138 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -8449,6 +8449,35 @@ int spider_db_flush_logs(
DBUG_RETURN(0);
}
+int spider_db_print_item_type_default(
+ Item *item,
+ ha_spider *spider,
+ spider_string *str
+) {
+ DBUG_ENTER("spider_db_print_item_type_default");
+ THD *thd = spider->trx->thd;
+ SPIDER_SHARE *share = spider->share;
+ if (spider_param_skip_default_condition(thd,
+ share->skip_default_condition))
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+ if (str)
+ {
+ if (spider->share->access_charset->cset == system_charset_info->cset)
+ {
+#if MYSQL_VERSION_ID < 50500
+ item->print(str->get_str(), QT_IS);
+#else
+ item->print(str->get_str(), QT_TO_SYSTEM_CHARSET);
+#endif
+ } else {
+ item->print(str->get_str(), QT_ORDINARY);
+ }
+ str->mem_calc();
+ }
+ DBUG_RETURN(0);
+}
+
+
int spider_db_print_item_type(
Item *item,
ha_spider *spider,
@@ -8483,14 +8512,25 @@ int spider_db_print_item_type(
case Item::ROW_ITEM:
DBUG_RETURN(spider_db_open_item_row((Item_row *) item, spider, str,
alias, alias_length, dbton_id, use_fields, fields));
- case Item::STRING_ITEM:
- DBUG_RETURN(spider_db_open_item_string(item, spider, str,
- alias, alias_length, dbton_id, use_fields, fields));
- case Item::INT_ITEM:
- case Item::REAL_ITEM:
- case Item::DECIMAL_ITEM:
- DBUG_RETURN(spider_db_open_item_int(item, spider, str,
- alias, alias_length, dbton_id, use_fields, fields));
+ case Item::CONST_ITEM:
+ {
+ switch (item->cmp_type()) {
+ case ROW_RESULT:
+ DBUG_ASSERT(0);
+ // fall through
+ case TIME_RESULT:
+ DBUG_RETURN(spider_db_print_item_type_default(item, spider, str));
+ case STRING_RESULT:
+ DBUG_RETURN(spider_db_open_item_string(item, spider, str,
+ alias, alias_length, dbton_id, use_fields, fields));
+ case INT_RESULT:
+ case REAL_RESULT:
+ case DECIMAL_RESULT:
+ DBUG_RETURN(spider_db_open_item_int(item, spider, str,
+ alias, alias_length, dbton_id, use_fields, fields));
+ }
+ DBUG_ASSERT(0);
+ }
case Item::CACHE_ITEM:
DBUG_RETURN(spider_db_open_item_cache((Item_cache *)item, spider, str,
alias, alias_length, dbton_id, use_fields, fields));
@@ -8504,26 +8544,7 @@ int spider_db_print_item_type(
#endif
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
default:
- THD *thd = spider->trx->thd;
- SPIDER_SHARE *share = spider->share;
- if (spider_param_skip_default_condition(thd,
- share->skip_default_condition))
- DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
- if (str)
- {
- if (spider->share->access_charset->cset == system_charset_info->cset)
- {
-#if MYSQL_VERSION_ID < 50500
- item->print(str->get_str(), QT_IS);
-#else
- item->print(str->get_str(), QT_TO_SYSTEM_CHARSET);
-#endif
- } else {
- item->print(str->get_str(), QT_ORDINARY);
- }
- str->mem_calc();
- }
- break;
+ DBUG_RETURN(spider_db_print_item_type_default(item, spider, str));
}
DBUG_RETURN(0);
}