Skip to content

Commit

Permalink
Merge branch 'bb-10.2-ext' into 10.3-merge-10.2-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Mar 16, 2017
2 parents 6a9e2e1 + b13ce22 commit 4c6ae99
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 117 deletions.
29 changes: 29 additions & 0 deletions mysql-test/r/gis.result
Original file line number Diff line number Diff line change
Expand Up @@ -3720,5 +3720,34 @@ DROP TABLE t1;
SELECT ROUND(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'round'
#
# MDEV-12199 Split Item_func_{abs|neg|int_val}::fix_length_and_dec() into methods in Type_handler
#
CREATE TABLE t1 (a GEOMETRY);
SELECT -a FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation '-'
SELECT ABS(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'abs'
SELECT CEILING(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'ceiling'
SELECT FLOOR(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'floor'
SELECT -COALESCE(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation '-'
SELECT ABS(COALESCE(a)) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'abs'
SELECT CEILING(COALESCE(a)) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'ceiling'
SELECT FLOOR(COALESCE(a)) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'floor'
DROP TABLE t1;
SELECT -POINT(1,1);
ERROR HY000: Illegal parameter data type geometry for operation '-'
SELECT ABS(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'abs'
SELECT CEILING(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'ceiling'
SELECT FLOOR(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'floor'
#
# End of 10.3 tests
#
8 changes: 4 additions & 4 deletions mysql-test/t/except.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ EXPLAIN extended (select a,b from t1) except (select c,d from t2);
EXPLAIN extended select * from ((select a,b from t1) except (select c,d from t2)) a;
EXPLAIN format=json (select a,b from t1) except (select c,d from t2);

--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json (select a,b from t1) except (select c,d from t2);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json select * from ((select a,b from t1) except (select c,d from t2)) a;
select * from ((select a,b from t1) except (select c,d from t2)) a;

Expand Down Expand Up @@ -41,9 +41,9 @@ EXPLAIN (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4);
EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a;
EXPLAIN format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4);

--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except
(select c,d,g,h from t2,t4)) a;
select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a;
Expand Down
35 changes: 35 additions & 0 deletions mysql-test/t/gis.test
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,41 @@ DROP TABLE t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ROUND(POINT(1,1));


--echo #
--echo # MDEV-12199 Split Item_func_{abs|neg|int_val}::fix_length_and_dec() into methods in Type_handler
--echo #

CREATE TABLE t1 (a GEOMETRY);

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT -a FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ABS(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CEILING(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT FLOOR(a) FROM t1;

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT -COALESCE(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ABS(COALESCE(a)) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CEILING(COALESCE(a)) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT FLOOR(COALESCE(a)) FROM t1;
DROP TABLE t1;

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT -POINT(1,1);
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ABS(POINT(1,1));
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CEILING(POINT(1,1));
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT FLOOR(POINT(1,1));

--echo #
--echo # End of 10.3 tests
--echo #
8 changes: 4 additions & 4 deletions mysql-test/t/intersect.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ EXPLAIN (select a,b from t1) intersect (select c,d from t2) intersect (select e,
EXPLAIN extended (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3);
EXPLAIN extended select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a;
EXPLAIN format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a;
select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a;

Expand All @@ -39,9 +39,9 @@ EXPLAIN (select a,b from t1) intersect (select c,e from t2,t3);
EXPLAIN extended (select a,b from t1) intersect (select c,e from t2,t3);
EXPLAIN extended select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a;
EXPLAIN format=json (select a,b from t1) intersect (select c,e from t2,t3);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3);
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
--replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/
ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a;
select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a;

Expand Down
8 changes: 8 additions & 0 deletions sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ class Field: public Value_source
virtual bool str_needs_quotes() { return FALSE; }
virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); }
virtual const Type_handler *cast_to_int_type_handler() const
{
return Type_handler::get_handler_by_field_type(type());
}
static bool type_can_have_key_part(enum_field_types);
static enum_field_types field_type_merge(enum_field_types, enum_field_types);
virtual bool eq(Field *field)
Expand Down Expand Up @@ -3463,6 +3467,10 @@ class Field_enum :public Field_str {
Field *make_new_field(MEM_ROOT *root, TABLE *new_table, bool keep_type);
enum_field_types type() const { return MYSQL_TYPE_STRING; }
enum Item_result cmp_type () const { return INT_RESULT; }
const Type_handler *cast_to_int_type_handler() const
{
return &type_handler_longlong;
}
enum ha_base_keytype key_type() const;
Copy_func *get_copy_func(const Field *from) const
{
Expand Down
17 changes: 11 additions & 6 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ class Item: public Value_source,
{
return Type_handler::get_handler_by_field_type(field_type());
}
virtual const Type_handler *cast_to_int_type_handler() const
{
return type_handler();
}
/* result_type() of an item specifies how the value should be returned */
virtual Item_result result_type() const
{
Expand All @@ -709,7 +713,6 @@ class Item: public Value_source,
{
return type_handler()->cmp_type();
}
virtual Item_result cast_to_int_type() const { return cmp_type(); }
enum_field_types string_field_type() const
{
return Type_handler::string_type_handler(max_length)->field_type();
Expand Down Expand Up @@ -2398,9 +2401,9 @@ class Item_field :public Item_ident
{
return field->result_type();
}
Item_result cast_to_int_type() const
const Type_handler *cast_to_int_type_handler() const
{
return field->cmp_type();
return field->cast_to_int_type_handler();
}
enum_field_types field_type() const
{
Expand Down Expand Up @@ -3418,7 +3421,7 @@ class Item_hex_constant: public Item_basic_constant
bool eq(const Item *item, bool binary_cmp) const
{
return item->basic_const_item() && item->type() == type() &&
item->cast_to_int_type() == cast_to_int_type() &&
item->cast_to_int_type_handler() == cast_to_int_type_handler() &&
str_value.bin_eq(&((Item_hex_constant*)item)->str_value);
}
String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; }
Expand Down Expand Up @@ -3460,7 +3463,10 @@ class Item_hex_hybrid: public Item_hex_constant
field->set_notnull();
return field->store_hex_hybrid(str_value.ptr(), str_value.length());
}
enum Item_result cast_to_int_type() const { return INT_RESULT; }
const Type_handler *cast_to_int_type_handler() const
{
return &type_handler_longlong;
}
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_hex_hybrid>(thd, mem_root, this); }
Expand Down Expand Up @@ -3502,7 +3508,6 @@ class Item_hex_string: public Item_hex_constant
return field->store(str_value.ptr(), str_value.length(),
collation.collation);
}
enum Item_result cast_to_int_type() const { return STRING_RESULT; }
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_hex_string>(thd, mem_root, this); }
Expand Down

0 comments on commit 4c6ae99

Please sign in to comment.