Skip to content

Commit ba3573c

Browse files
author
Alexander Barkov
committed
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
1 parent a71e2d2 commit ba3573c

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

mysql-test/r/gis.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,3 +1732,11 @@ SRID
17321732
0
17331733
102
17341734
drop table t1;
1735+
# Expect an int(1) column to be created
1736+
CREATE TABLE t1 AS SELECT CONTAINS(NULL, NULL);
1737+
SHOW CREATE TABLE t1;
1738+
Table Create Table
1739+
t1 CREATE TABLE `t1` (
1740+
`CONTAINS(NULL, NULL)` int(1) DEFAULT NULL
1741+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1742+
DROP TABLE t1;

mysql-test/t/gis.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,3 +1463,7 @@ create table t1(g GEOMETRY(9,4) REF_SYSTEM_ID=101, pt POINT(8,2), pg GEOMETRY RE
14631463
SELECT SRID from information_schema.geometry_columns WHERE G_TABLE_NAME='t1';
14641464
drop table t1;
14651465

1466+
-- echo # Expect an int(1) column to be created
1467+
CREATE TABLE t1 AS SELECT CONTAINS(NULL, NULL);
1468+
SHOW CREATE TABLE t1;
1469+
DROP TABLE t1;

sql/item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ class Item {
11231123
*/
11241124
virtual void set_result_field(Field *field) {}
11251125
virtual bool is_result_field() { return 0; }
1126-
virtual bool is_bool_func() { return 0; }
1126+
virtual bool is_bool_type() { return false; }
11271127
virtual void save_in_result_field(bool no_conversions) {}
11281128
/*
11291129
set value of aggregate function in case of no rows for grouping were found

sql/item_cmpfunc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Item_bool_func :public Item_int_func
128128
Item_bool_func(Item *a, Item *b, Item *c) :Item_int_func(a, b, c) {}
129129
Item_bool_func(List<Item> &list) :Item_int_func(list) { }
130130
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
131-
bool is_bool_func() { return 1; }
131+
bool is_bool_type() { return true; }
132132
void fix_length_and_dec() { decimals=0; max_length=1; }
133133
uint decimal_precision() const { return 1; }
134134
};
@@ -847,7 +847,6 @@ class Item_func_nullif :public Item_func_hybrid_field_type
847847
longlong int_op();
848848
String *str_op(String *str);
849849
my_decimal *decimal_op(my_decimal *);
850-
bool is_bool_func() { return false; }
851850
void fix_length_and_dec();
852851
uint decimal_precision() const { return m_args0_copy->decimal_precision(); }
853852
const char *func_name() const { return "nullif"; }

sql/item_geofunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,14 +1001,14 @@ longlong Item_func_spatial_mbr_rel::val_int()
10011001

10021002
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b,
10031003
enum Functype sp_rel) :
1004-
Item_int_func(a,b), collector()
1004+
Item_bool_func(a,b), collector()
10051005
{
10061006
spatial_rel = sp_rel;
10071007
}
10081008

10091009

10101010
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b, Item *mask) :
1011-
Item_int_func(a,b,mask), spatial_rel(SP_RELATE_FUNC)
1011+
Item_bool_func(a,b,mask), spatial_rel(SP_RELATE_FUNC)
10121012
{}
10131013

10141014

sql/item_geofunc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Item_func_spatial_mbr_rel: public Item_bool_func2
294294
};
295295

296296

297-
class Item_func_spatial_rel: public Item_int_func
297+
class Item_func_spatial_rel: public Item_bool_func
298298
{
299299
enum Functype spatial_rel;
300300
Gcalc_heap collector;
@@ -317,9 +317,7 @@ class Item_func_spatial_rel: public Item_int_func
317317
Item_func::print(str, query_type);
318318
}
319319

320-
void fix_length_and_dec() { maybe_null= 1; }
321320
bool is_null() { (void) val_int(); return null_value; }
322-
bool is_bool_func() { return 1; }
323321
uint decimal_precision() const { return 1; }
324322
optimize_type select_optimize() const { return OPTIMIZE_OP; }
325323
};

sql/item_xmlfunc.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class Item_bool :public Item_int
392392
public:
393393
Item_bool(int32 i): Item_int(i) {}
394394
const char *func_name() const { return "xpath_bool"; }
395-
bool is_bool_func() { return 1; }
395+
bool is_bool_type() { return true; }
396396
};
397397

398398

@@ -402,15 +402,14 @@ class Item_bool :public Item_int
402402
* a node-set is true if and only if it is non-empty
403403
* a string is true if and only if its length is non-zero
404404
*/
405-
class Item_xpath_cast_bool :public Item_int_func
405+
class Item_xpath_cast_bool :public Item_bool_func
406406
{
407407
String *pxml;
408408
String tmp_value;
409409
public:
410410
Item_xpath_cast_bool(Item *a, String *pxml_arg)
411-
:Item_int_func(a), pxml(pxml_arg) {}
411+
:Item_bool_func(a), pxml(pxml_arg) {}
412412
const char *func_name() const { return "xpath_cast_bool"; }
413-
bool is_bool_func() { return 1; }
414413
longlong val_int()
415414
{
416415
if (args[0]->type() == XPATH_NODESET)
@@ -568,7 +567,6 @@ class Item_nodeset_to_const_comparator :public Item_bool_func
568567
:Item_bool_func(nodeset,cmpfunc), pxml(p) {}
569568
enum Type type() const { return XPATH_NODESET_CMP; };
570569
const char *func_name() const { return "xpath_nodeset_to_const_comparator"; }
571-
bool is_bool_func() { return 1; }
572570
bool check_vcol_func_processor(uchar *int_arg)
573571
{
574572
return trace_unsupported_by_check_vcol_func_processor(func_name());
@@ -823,7 +821,7 @@ String *Item_nodeset_func_elementbyindex::val_nodeset(String *nodeset)
823821
flt->pos,
824822
size);
825823
int index= (int) (args[1]->val_int()) - 1;
826-
if (index >= 0 && (flt->pos == (uint) index || args[1]->is_bool_func()))
824+
if (index >= 0 && (flt->pos == (uint) index || args[1]->is_bool_type()))
827825
((XPathFilter*)nodeset)->append_element(flt->num, pos++);
828826
}
829827
return nodeset;
@@ -1732,7 +1730,7 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath)
17321730

17331731
xpath->item= nodeset2bool(xpath, xpath->item);
17341732

1735-
if (xpath->item->is_bool_func())
1733+
if (xpath->item->is_bool_type())
17361734
{
17371735
xpath->context= new Item_nodeset_func_predicate(prev_context,
17381736
xpath->item,

sql/sql_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8755,7 +8755,7 @@ Item *negate_expression(THD *thd, Item *expr)
87558755
/* it is NOT(NOT( ... )) */
87568756
Item *arg= ((Item_func *) expr)->arguments()[0];
87578757
enum_parsing_place place= thd->lex->current_select->parsing_place;
8758-
if (arg->is_bool_func() || place == IN_WHERE || place == IN_HAVING)
8758+
if (arg->is_bool_type() || place == IN_WHERE || place == IN_HAVING)
87598759
return arg;
87608760
/*
87618761
if it is not boolean function then we have to emulate value of

0 commit comments

Comments
 (0)