Commit cccfa9dc authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19908 Add class Type_collection

parent 5de9dd7b
...@@ -356,22 +356,16 @@ SET SESSION debug_dbug="-d,Item_func_in"; ...@@ -356,22 +356,16 @@ SET SESSION debug_dbug="-d,Item_func_in";
# MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec() # MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec()
# #
SET debug_dbug='+d,num_op'; SET debug_dbug='+d,num_op';
CREATE TABLE t1 AS SELECT SELECT POINT(0,0)+POINT(0,0);
POINT(0,0)+POINT(0,0), ERROR HY000: Illegal parameter data types geometry and geometry for operation '+'
POINT(0,0)-POINT(0,0), SELECT POINT(0,0)-POINT(0,0);
POINT(0,0)*POINT(0,0), ERROR HY000: Illegal parameter data types geometry and geometry for operation '-'
POINT(0,0)/POINT(0,0), SELECT POINT(0,0)*POINT(0,0);
POINT(0,0) MOD POINT(0,0) LIMIT 0; ERROR HY000: Illegal parameter data types geometry and geometry for operation '*'
SHOW CREATE TABLE t1; SELECT POINT(0,0)/POINT(0,0);
Table Create Table ERROR HY000: Illegal parameter data types geometry and geometry for operation '/'
t1 CREATE TABLE `t1` ( SELECT POINT(0,0) MOD POINT(0,0);
`POINT(0,0)+POINT(0,0)` geometry DEFAULT NULL, ERROR HY000: Illegal parameter data types geometry and geometry for operation 'MOD'
`POINT(0,0)-POINT(0,0)` geometry DEFAULT NULL,
`POINT(0,0)*POINT(0,0)` geometry DEFAULT NULL,
`POINT(0,0)/POINT(0,0)` geometry DEFAULT NULL,
`POINT(0,0) MOD POINT(0,0)` geometry DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT CREATE TABLE t1 AS SELECT
POINT(0,0)+'0', POINT(0,0)+'0',
POINT(0,0)-'0', POINT(0,0)-'0',
......
...@@ -73,15 +73,21 @@ SET SESSION debug_dbug="-d,Item_func_in"; ...@@ -73,15 +73,21 @@ SET SESSION debug_dbug="-d,Item_func_in";
SET debug_dbug='+d,num_op'; SET debug_dbug='+d,num_op';
# (GEOMETRY,GEOMETRY) gives GEOMETRY for all operators # (GEOMETRY,GEOMETRY) goes through
CREATE TABLE t1 AS SELECT # Type_collection_geometry::aggregate_for_num_op() which fails.
POINT(0,0)+POINT(0,0), # Type pairs from Type_handler_data::m_type_aggregator_xxx are not even tested,
POINT(0,0)-POINT(0,0), # as both sides are from the same type collection.
POINT(0,0)*POINT(0,0),
POINT(0,0)/POINT(0,0), --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
POINT(0,0) MOD POINT(0,0) LIMIT 0; SELECT POINT(0,0)+POINT(0,0);
SHOW CREATE TABLE t1; --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
DROP TABLE t1; SELECT POINT(0,0)-POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)*POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)/POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0) MOD POINT(0,0);
# (GEOMETRY,VARCHAR) gives GEOMETRY for all operators # (GEOMETRY,VARCHAR) gives GEOMETRY for all operators
CREATE TABLE t1 AS SELECT CREATE TABLE t1 AS SELECT
......
This diff is collapsed.
...@@ -87,6 +87,7 @@ class Vers_history_point; ...@@ -87,6 +87,7 @@ class Vers_history_point;
class Virtual_column_info; class Virtual_column_info;
class Conv_source; class Conv_source;
class ST_FIELD_INFO; class ST_FIELD_INFO;
class Type_collection;
#define my_charset_numeric my_charset_latin1 #define my_charset_numeric my_charset_latin1
...@@ -3281,12 +3282,10 @@ class Type_handler ...@@ -3281,12 +3282,10 @@ class Type_handler
DBUG_ASSERT(type != TIME_RESULT); DBUG_ASSERT(type != TIME_RESULT);
return get_handler_by_cmp_type(type); return get_handler_by_cmp_type(type);
} }
virtual const Type_collection *type_collection() const;
static const static const
Type_handler *aggregate_for_result_traditional(const Type_handler *h1, Type_handler *aggregate_for_result_traditional(const Type_handler *h1,
const Type_handler *h2); const Type_handler *h2);
static const
Type_handler *aggregate_for_num_op_traditional(const Type_handler *h1,
const Type_handler *h2);
virtual const Name name() const= 0; virtual const Name name() const= 0;
virtual const Name version() const { return m_version_default; } virtual const Name version() const { return m_version_default; }
...@@ -6372,6 +6371,7 @@ class Type_handler_geometry: public Type_handler_string_result ...@@ -6372,6 +6371,7 @@ class Type_handler_geometry: public Type_handler_string_result
bool is_param_long_data_type() const { return true; } bool is_param_long_data_type() const { return true; }
uint32 max_display_length_for_field(const Conv_source &src) const; uint32 max_display_length_for_field(const Conv_source &src) const;
uint32 calc_pack_length(uint32 length) const; uint32 calc_pack_length(uint32 length) const;
const Type_collection *type_collection() const override;
const Type_handler *type_handler_for_comparison() const; const Type_handler *type_handler_for_comparison() const;
bool type_can_have_key_part() const bool type_can_have_key_part() const
{ {
...@@ -6570,6 +6570,24 @@ class Type_handler_interval_DDhhmmssff: public Type_handler_long_blob ...@@ -6570,6 +6570,24 @@ class Type_handler_interval_DDhhmmssff: public Type_handler_long_blob
}; };
class Type_collection
{
public:
virtual ~Type_collection() {}
virtual const Type_handler *aggregate_for_result(const Type_handler *h1,
const Type_handler *h2)
const= 0;
virtual const Type_handler *aggregate_for_comparison(const Type_handler *h1,
const Type_handler *h2)
const= 0;
virtual const Type_handler *aggregate_for_min_max(const Type_handler *h1,
const Type_handler *h2)
const= 0;
virtual const Type_handler *aggregate_for_num_op(const Type_handler *h1,
const Type_handler *h2)
const= 0;
};
/** /**
A handler for hybrid type functions, e.g. A handler for hybrid type functions, e.g.
......
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