1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-39683 Numeric aggregates should end up with an error for xmltype.

Appropriate xxx_fix_length_and_dec() added to the Type_handler_xmltype.
This commit is contained in:
Alexey (Holyfoot) Botchkov
2026-07-06 20:28:24 +03:00
parent 48f28e51b0
commit 2883bccc7d
4 changed files with 211 additions and 0 deletions

View File

@@ -380,4 +380,41 @@ CAST('a' AS xmltype)
NULL
Warnings:
Warning 1292 Truncated incorrect xmltype value: 'a'
#
# MDEV-39683 Numeric aggregates should end up with an error for xmltype.
#
CREATE TABLE t (x XMLTYPE);
INSERT INTO t VALUES ('<a/>');
INSERT INTO t VALUES ('<a/>'),('<b>1</b>'),('<n>4.5</n>'),('<c/>');
SELECT round(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'round'
SELECT floor(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'floor'
SELECT abs(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'abs'
SELECT -x FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation '-'
SELECT sum(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'sum'
SELECT avg(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'avg'
SELECT variance(x) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'variance('
SELECT cast(x as signed) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'cast_as_signed'
SELECT cast(x as unsigned) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'cast_as_unsigned'
SELECT cast(x as float) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'float_typecast'
SELECT cast(x as double) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'double_typecast'
SELECT cast(x as decimal) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'decimal_typecast'
SELECT cast(x as time) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'cast_as_time'
SELECT cast(x as date) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'cast_as_date'
SELECT cast(x as datetime) FROM t;
ERROR HY000: Illegal parameter data type xmltype for operation 'cast_as_datetime'
DROP TABLE t;
# End of 12.3 tests

View File

@@ -308,4 +308,46 @@ DROP TABLE t1, t2;
SELECT CAST('a' AS xmltype);
--echo #
--echo # MDEV-39683 Numeric aggregates should end up with an error for xmltype.
--echo #
CREATE TABLE t (x XMLTYPE);
INSERT INTO t VALUES ('<a/>');
INSERT INTO t VALUES ('<a/>'),('<b>1</b>'),('<n>4.5</n>'),('<c/>');
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT round(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT floor(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT abs(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT -x FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT sum(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT avg(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT variance(x) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as signed) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as unsigned) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as float) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as double) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as decimal) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as time) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as date) FROM t;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT cast(x as datetime) FROM t;
DROP TABLE t;
--echo # End of 12.3 tests

View File

@@ -170,6 +170,115 @@ const Type_handler *Type_handler_xmltype::
}
bool Type_handler_xmltype::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_func_int_val_fix_length_and_dec(Item_func_int_val *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_func_abs_fix_length_and_dec(Item_func_abs *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_func_neg_fix_length_and_dec(Item_func_neg *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_sum_sum_fix_length_and_dec(Item_sum_sum *item) const
{
LEX_CSTRING name= {STRING_WITH_LEN("sum") };
return Item_func_or_sum_illegal_param(name);
}
bool Type_handler_xmltype::
Item_sum_avg_fix_length_and_dec(Item_sum_avg *item) const
{
LEX_CSTRING name= {STRING_WITH_LEN("avg") };
return Item_func_or_sum_illegal_param(name);
}
bool Type_handler_xmltype::
Item_sum_variance_fix_length_and_dec(Item_sum_variance *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_func_signed_fix_length_and_dec(Item_func_signed *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_double_typecast_fix_length_and_dec(Item_double_typecast *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_float_typecast_fix_length_and_dec(Item_float_typecast *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_time_typecast_fix_length_and_dec(Item_time_typecast *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_date_typecast_fix_length_and_dec(Item_date_typecast *item) const
{
return Item_func_or_sum_illegal_param(item);
}
bool Type_handler_xmltype::
Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *item)
const
{
return Item_func_or_sum_illegal_param(item);
}
/*****************************************************************/
void Field_xmltype::sql_type(String &res) const

View File

@@ -77,6 +77,29 @@ public:
bool can_return_date() const override { return false; }
bool can_return_time() const override { return false; }
bool Item_func_round_fix_length_and_dec(Item_func_round *) const override;
bool Item_func_int_val_fix_length_and_dec(Item_func_int_val *) const override;
bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override;
bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const override;
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const override;
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const override;
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const override;
bool Item_func_signed_fix_length_and_dec(Item_func_signed *) const override;
bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const
override;
bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *) const
override;
bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const
override;
bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const
override;
bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *) const
override;
bool Item_date_typecast_fix_length_and_dec(Item_date_typecast *) const
override;
bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *) const
override;
};
extern Type_handler_xmltype type_handler_xmltype;