Commit b9c2ae50 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-29356 Assertion `0' failed in Type_handler_row::Item_save_in_field on INSERT

parent 590ce857
...@@ -1026,11 +1026,11 @@ BEGIN ...@@ -1026,11 +1026,11 @@ BEGIN
SELECT arg; SELECT arg;
END| END|
CALL p1((1, 2)); CALL p1((1, 2));
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'tinyint' in assignment of `arg`
CALL p1((SELECT * FROM t1 LIMIT 1)); CALL p1((SELECT * FROM t1 LIMIT 1));
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'tinyint' in assignment of `arg`
CALL p1((SELECT col1, col2 FROM t1 LIMIT 1)); CALL p1((SELECT col1, col2 FROM t1 LIMIT 1));
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'tinyint' in assignment of `arg`
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -1221,13 +1221,13 @@ BEGIN ...@@ -1221,13 +1221,13 @@ BEGIN
END| END|
delimiter ;| delimiter ;|
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1((1, 2)); CALL p1((1, 2));
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1((SELECT * FROM t1 LIMIT 1)); CALL p1((SELECT * FROM t1 LIMIT 1));
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1((SELECT col1, col2 FROM t1 LIMIT 1)); CALL p1((SELECT col1, col2 FROM t1 LIMIT 1));
# #
......
...@@ -49,3 +49,26 @@ ERROR HY000: Illegal parameter data types row and int for operation 'MOD' ...@@ -49,3 +49,26 @@ ERROR HY000: Illegal parameter data types row and int for operation 'MOD'
# #
# End of 10.5 tests # End of 10.5 tests
# #
#
# Start of 10.7 tests
#
#
# MDEV-29356 Assertion `0' failed in Type_handler_row::Item_save_in_field on INSERT
#
SET sql_mode='';
CREATE TABLE t1 (c1 INT,c2 INT);
CREATE TRIGGER t BEFORE INSERT ON t1 FOR EACH ROW SET NEW.c1=(SELECT * FROM t1);
INSERT INTO t1 VALUES (0,0);
ERROR HY000: Cannot cast 'row' as 'int' in assignment of `test`.`t1`.`c1`
DROP TABLE t1;
SET sql_mode=DEFAULT;
SET sql_mode='';
CREATE TABLE t1 (c1 INT,c2 INT) ENGINE=MyISAM;
CREATE TRIGGER t BEFORE INSERT ON t1 FOR EACH ROW SET NEW.c1=ROW(1,1);
INSERT INTO t1 VALUES (0,0);
ERROR HY000: Cannot cast 'row' as 'int' in assignment of `test`.`t1`.`c1`
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 10.7 tests
#
...@@ -60,3 +60,31 @@ SELECT ROW(1,1) % 1; ...@@ -60,3 +60,31 @@ SELECT ROW(1,1) % 1;
--echo # --echo #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #
--echo #
--echo # Start of 10.7 tests
--echo #
--echo #
--echo # MDEV-29356 Assertion `0' failed in Type_handler_row::Item_save_in_field on INSERT
--echo #
SET sql_mode='';
CREATE TABLE t1 (c1 INT,c2 INT);
CREATE TRIGGER t BEFORE INSERT ON t1 FOR EACH ROW SET NEW.c1=(SELECT * FROM t1);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
INSERT INTO t1 VALUES (0,0);
DROP TABLE t1;
SET sql_mode=DEFAULT;
SET sql_mode='';
CREATE TABLE t1 (c1 INT,c2 INT) ENGINE=MyISAM;
CREATE TRIGGER t BEFORE INSERT ON t1 FOR EACH ROW SET NEW.c1=ROW(1,1);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
INSERT INTO t1 VALUES (0,0);
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.7 tests
--echo #
...@@ -24,7 +24,7 @@ RETURN a; ...@@ -24,7 +24,7 @@ RETURN a;
END; END;
$$ $$
SELECT f1(ROW(10,20)); SELECT f1(ROW(10,20));
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'int' in assignment of `f1(ROW(10,20))`
DROP FUNCTION f1; DROP FUNCTION f1;
# #
# ROW as an SP parameter # ROW as an SP parameter
...@@ -261,7 +261,7 @@ SELECT f1(a); ...@@ -261,7 +261,7 @@ SELECT f1(a);
END; END;
$$ $$
CALL p1(); CALL p1();
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'int' in assignment of `a`
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
CREATE FUNCTION f1(a INT) RETURN INT CREATE FUNCTION f1(a INT) RETURN INT
...@@ -278,7 +278,7 @@ SELECT f1(a); ...@@ -278,7 +278,7 @@ SELECT f1(a);
END; END;
$$ $$
CALL p1(); CALL p1();
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'int' in assignment of `a`
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
# #
...@@ -332,7 +332,7 @@ RETURN rec; ...@@ -332,7 +332,7 @@ RETURN rec;
END; END;
$$ $$
SELECT f1(10); SELECT f1(10);
ERROR 21000: Operand should contain 1 column(s) ERROR HY000: Cannot cast 'row' as 'int' in assignment of `f1(10)`
DROP FUNCTION f1; DROP FUNCTION f1;
# #
# Using the entire ROW in SELECT..CREATE # Using the entire ROW in SELECT..CREATE
......
...@@ -35,7 +35,7 @@ BEGIN ...@@ -35,7 +35,7 @@ BEGIN
END; END;
$$ $$
DELIMITER ;$$ DELIMITER ;$$
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1(ROW(10,20)); SELECT f1(ROW(10,20));
DROP FUNCTION f1; DROP FUNCTION f1;
...@@ -334,7 +334,7 @@ BEGIN ...@@ -334,7 +334,7 @@ BEGIN
END; END;
$$ $$
DELIMITER ;$$ DELIMITER ;$$
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1(); CALL p1();
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
...@@ -355,7 +355,7 @@ BEGIN ...@@ -355,7 +355,7 @@ BEGIN
END; END;
$$ $$
DELIMITER ;$$ DELIMITER ;$$
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1(); CALL p1();
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP FUNCTION f1; DROP FUNCTION f1;
...@@ -427,7 +427,7 @@ BEGIN ...@@ -427,7 +427,7 @@ BEGIN
END; END;
$$ $$
DELIMITER ;$$ DELIMITER ;$$
--error ER_OPERAND_COLUMNS --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1(10); SELECT f1(10);
DROP FUNCTION f1; DROP FUNCTION f1;
......
...@@ -983,7 +983,8 @@ bool Field::check_assignability_from(const Type_handler *from, ...@@ -983,7 +983,8 @@ bool Field::check_assignability_from(const Type_handler *from,
type_handler_for_item_field()); type_handler_for_item_field());
if (th.aggregate_for_result(from->type_handler_for_item_field())) if (th.aggregate_for_result(from->type_handler_for_item_field()))
{ {
bool error= !ignore && get_thd()->is_strict_mode(); bool error= (!ignore && get_thd()->is_strict_mode()) ||
(type_handler()->is_scalar_type() != from->is_scalar_type());
/* /*
Display fully qualified column name for table columns. Display fully qualified column name for table columns.
Display non-qualified names for other things, Display non-qualified names for other things,
...@@ -1474,15 +1475,6 @@ bool Field::sp_prepare_and_store_item(THD *thd, Item **value) ...@@ -1474,15 +1475,6 @@ bool Field::sp_prepare_and_store_item(THD *thd, Item **value)
if (!(expr_item= thd->sp_fix_func_item_for_assignment(this, value))) if (!(expr_item= thd->sp_fix_func_item_for_assignment(this, value)))
goto error; goto error;
/*
expr_item is now fixed, it's safe to call cmp_type()
*/
if (expr_item->cmp_type() == ROW_RESULT)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
goto error;
}
/* Save the value in the field. Convert the value if needed. */ /* Save the value in the field. Convert the value if needed. */
expr_item->save_in_field(this, 0); expr_item->save_in_field(this, 0);
......
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