Commit ba3573ca authored by Alexander Barkov's avatar Alexander Barkov

Clean-up:

- Renaming Item::is_bool_func() to is_bool_type(), to avoid assumption
  that the item is an Item_func derivant.
- Deriving Item_func_spatial_rel from Item_bool_func rather than Item_int_func
parent a71e2d23
......@@ -1732,3 +1732,11 @@ SRID
0
102
drop table t1;
# Expect an int(1) column to be created
CREATE TABLE t1 AS SELECT CONTAINS(NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CONTAINS(NULL, NULL)` int(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -1463,3 +1463,7 @@ create table t1(g GEOMETRY(9,4) REF_SYSTEM_ID=101, pt POINT(8,2), pg GEOMETRY RE
SELECT SRID from information_schema.geometry_columns WHERE G_TABLE_NAME='t1';
drop table t1;
-- echo # Expect an int(1) column to be created
CREATE TABLE t1 AS SELECT CONTAINS(NULL, NULL);
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -1123,7 +1123,7 @@ public:
*/
virtual void set_result_field(Field *field) {}
virtual bool is_result_field() { return 0; }
virtual bool is_bool_func() { return 0; }
virtual bool is_bool_type() { return false; }
virtual void save_in_result_field(bool no_conversions) {}
/*
set value of aggregate function in case of no rows for grouping were found
......
......@@ -128,7 +128,7 @@ public:
Item_bool_func(Item *a, Item *b, Item *c) :Item_int_func(a, b, c) {}
Item_bool_func(List<Item> &list) :Item_int_func(list) { }
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
bool is_bool_func() { return 1; }
bool is_bool_type() { return true; }
void fix_length_and_dec() { decimals=0; max_length=1; }
uint decimal_precision() const { return 1; }
};
......@@ -847,7 +847,6 @@ public:
longlong int_op();
String *str_op(String *str);
my_decimal *decimal_op(my_decimal *);
bool is_bool_func() { return false; }
void fix_length_and_dec();
uint decimal_precision() const { return m_args0_copy->decimal_precision(); }
const char *func_name() const { return "nullif"; }
......
......@@ -1001,14 +1001,14 @@ longlong Item_func_spatial_mbr_rel::val_int()
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b,
enum Functype sp_rel) :
Item_int_func(a,b), collector()
Item_bool_func(a,b), collector()
{
spatial_rel = sp_rel;
}
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b, Item *mask) :
Item_int_func(a,b,mask), spatial_rel(SP_RELATE_FUNC)
Item_bool_func(a,b,mask), spatial_rel(SP_RELATE_FUNC)
{}
......
......@@ -294,7 +294,7 @@ public:
};
class Item_func_spatial_rel: public Item_int_func
class Item_func_spatial_rel: public Item_bool_func
{
enum Functype spatial_rel;
Gcalc_heap collector;
......@@ -317,9 +317,7 @@ public:
Item_func::print(str, query_type);
}
void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; }
bool is_bool_func() { return 1; }
uint decimal_precision() const { return 1; }
optimize_type select_optimize() const { return OPTIMIZE_OP; }
};
......
......@@ -392,7 +392,7 @@ class Item_bool :public Item_int
public:
Item_bool(int32 i): Item_int(i) {}
const char *func_name() const { return "xpath_bool"; }
bool is_bool_func() { return 1; }
bool is_bool_type() { return true; }
};
......@@ -402,15 +402,14 @@ public:
* a node-set is true if and only if it is non-empty
* a string is true if and only if its length is non-zero
*/
class Item_xpath_cast_bool :public Item_int_func
class Item_xpath_cast_bool :public Item_bool_func
{
String *pxml;
String tmp_value;
public:
Item_xpath_cast_bool(Item *a, String *pxml_arg)
:Item_int_func(a), pxml(pxml_arg) {}
:Item_bool_func(a), pxml(pxml_arg) {}
const char *func_name() const { return "xpath_cast_bool"; }
bool is_bool_func() { return 1; }
longlong val_int()
{
if (args[0]->type() == XPATH_NODESET)
......@@ -568,7 +567,6 @@ public:
:Item_bool_func(nodeset,cmpfunc), pxml(p) {}
enum Type type() const { return XPATH_NODESET_CMP; };
const char *func_name() const { return "xpath_nodeset_to_const_comparator"; }
bool is_bool_func() { return 1; }
bool check_vcol_func_processor(uchar *int_arg)
{
return trace_unsupported_by_check_vcol_func_processor(func_name());
......@@ -823,7 +821,7 @@ String *Item_nodeset_func_elementbyindex::val_nodeset(String *nodeset)
flt->pos,
size);
int index= (int) (args[1]->val_int()) - 1;
if (index >= 0 && (flt->pos == (uint) index || args[1]->is_bool_func()))
if (index >= 0 && (flt->pos == (uint) index || args[1]->is_bool_type()))
((XPathFilter*)nodeset)->append_element(flt->num, pos++);
}
return nodeset;
......@@ -1732,7 +1730,7 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath)
xpath->item= nodeset2bool(xpath, xpath->item);
if (xpath->item->is_bool_func())
if (xpath->item->is_bool_type())
{
xpath->context= new Item_nodeset_func_predicate(prev_context,
xpath->item,
......
......@@ -8755,7 +8755,7 @@ Item *negate_expression(THD *thd, Item *expr)
/* it is NOT(NOT( ... )) */
Item *arg= ((Item_func *) expr)->arguments()[0];
enum_parsing_place place= thd->lex->current_select->parsing_place;
if (arg->is_bool_func() || place == IN_WHERE || place == IN_HAVING)
if (arg->is_bool_type() || place == IN_WHERE || place == IN_HAVING)
return arg;
/*
if it is not boolean function then we have to emulate value of
......
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