Commit 08dae447 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-14228 MariaDB crashes with function

parent 6d4b0958
......@@ -210,7 +210,7 @@ SELECT a=1;
END;
$$
CALL p1();
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
DROP PROCEDURE p1;
CREATE PROCEDURE p1()
BEGIN
......@@ -219,7 +219,7 @@ SELECT 1=a;
END;
$$
CALL p1();
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
DROP PROCEDURE p1;
#
# Passing the entire ROW to a stored function
......
......@@ -8291,3 +8291,60 @@ rec=(10)
c
rec=(20)
DROP PROCEDURE p1;
#
# MDEV-14228 MariaDB crashes with function
#
CREATE TABLE t1 (c VARCHAR(16), KEY(c));
INSERT INTO t1 VALUES ('foo');
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v VARCHAR(16);
FOR v IN (SELECT DISTINCT c FROM t1)
DO
IF (v = 'bar') THEN
SELECT 1 INTO @a;
END IF;
END FOR;
RETURN 'qux';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v ROW TYPE OF t1;
IF v = 'bar' THEN
RETURN 'eq';
END IF;
RETURN 'ne';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v ROW(a INT);
IF v = 'bar' THEN
RETURN 'eq';
END IF;
RETURN 'ne';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT v IN ('a','b');
END $$
ERROR HY000: Illegal parameter data types row and varchar for operation 'in'
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT 'a' IN (v,'b');
END $$
ERROR HY000: Illegal parameter data types varchar and row for operation 'in'
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT 'a' IN ('b',v);
END $$
ERROR HY000: Illegal parameter data types varchar and row for operation 'in'
......@@ -384,10 +384,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2865,13 +2865,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -388,10 +388,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2868,13 +2868,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -391,10 +391,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2871,13 +2871,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -387,10 +387,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2867,13 +2867,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -390,10 +390,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2871,13 +2871,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -387,10 +387,10 @@ Warnings:
Note 1003 /* select#1 */ select 'joce' AS `pseudo`,(/* select#2 */ select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types varchar and row for operation '='
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
pseudo
joce
......@@ -2867,13 +2867,13 @@ drop table t1, t2;
create table t1 (a int, b int);
insert into t1 values (1,2);
select 1 = (select * from t1);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (select * from t1) = 1;
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (1,2) = (select a from t1);
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
select (select a from t1) = (1,2);
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
......
......@@ -232,7 +232,7 @@ SELECT a=1;
END;
$$
CALL p1();
ERROR 21000: Operand should contain 2 column(s)
ERROR HY000: Illegal parameter data types row and int for operation '='
DROP PROCEDURE p1;
CREATE PROCEDURE p1()
AS
......@@ -242,7 +242,7 @@ SELECT 1=a;
END;
$$
CALL p1();
ERROR 21000: Operand should contain 1 column(s)
ERROR HY000: Illegal parameter data types int and row for operation '='
DROP PROCEDURE p1;
#
# Passing the entire ROW to a stored function
......
......@@ -2432,3 +2432,66 @@ a b
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-14228 MariaDB crashes with function
#
CREATE TABLE t1 (c VARCHAR(16), KEY(c));
INSERT INTO t1 VALUES ('foo');
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v VARCHAR2(16);
BEGIN
FOR v IN (SELECT DISTINCT c FROM t1)
LOOP
IF (v = 'bar') THEN
SELECT 1 INTO @a;
END IF;
END LOOP;
RETURN 'qux';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v t1%ROWTYPE;
BEGIN
IF v = 'bar' THEN
NULL;
END IF;
RETURN 'qux';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v ROW(a INT);
BEGIN
IF v = 'bar' THEN
NULL;
END IF;
RETURN 'qux';
END $$
SELECT f1();
ERROR HY000: Illegal parameter data types row and varchar for operation '='
DROP FUNCTION f1;
DROP TABLE t1;
DECLARE
v ROW(a INT);
BEGIN
SELECT v IN ('a','b');
END $$
ERROR HY000: Illegal parameter data types row and varchar for operation 'in'
DECLARE
v ROW(a INT);
BEGIN
SELECT 'a' IN (v,'b');
END $$
ERROR HY000: Illegal parameter data types varchar and row for operation 'in'
DECLARE
v ROW(a INT);
BEGIN
SELECT 'a' IN ('b',v);
END $$
ERROR HY000: Illegal parameter data types varchar and row for operation 'in'
......@@ -295,7 +295,7 @@ BEGIN
END;
$$
DELIMITER ;$$
--error ER_OPERAND_COLUMNS
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1();
DROP PROCEDURE p1;
......@@ -309,7 +309,7 @@ BEGIN
END;
$$
DELIMITER ;$$
--error ER_OPERAND_COLUMNS
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1();
DROP PROCEDURE p1;
......
......@@ -2260,3 +2260,90 @@ CALL p1();
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # MDEV-14228 MariaDB crashes with function
--echo #
CREATE TABLE t1 (c VARCHAR(16), KEY(c));
INSERT INTO t1 VALUES ('foo');
DELIMITER $$;
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v VARCHAR2(16);
BEGIN
FOR v IN (SELECT DISTINCT c FROM t1)
LOOP
IF (v = 'bar') THEN
SELECT 1 INTO @a;
END IF;
END LOOP;
RETURN 'qux';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DELIMITER $$;
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v t1%ROWTYPE;
BEGIN
IF v = 'bar' THEN
NULL;
END IF;
RETURN 'qux';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DELIMITER $$;
CREATE FUNCTION f1() RETURN VARCHAR(16)
IS
v ROW(a INT);
BEGIN
IF v = 'bar' THEN
NULL;
END IF;
RETURN 'qux';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DROP TABLE t1;
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
DECLARE
v ROW(a INT);
BEGIN
SELECT v IN ('a','b');
END $$
DELIMITER ;$$
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
DECLARE
v ROW(a INT);
BEGIN
SELECT 'a' IN (v,'b');
END $$
DELIMITER ;$$
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
DECLARE
v ROW(a INT);
BEGIN
SELECT 'a' IN ('b',v);
END $$
DELIMITER ;$$
......@@ -274,7 +274,7 @@ BEGIN
END;
$$
DELIMITER ;$$
--error ER_OPERAND_COLUMNS
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1();
DROP PROCEDURE p1;
......@@ -287,7 +287,7 @@ BEGIN
END;
$$
DELIMITER ;$$
--error ER_OPERAND_COLUMNS
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CALL p1();
DROP PROCEDURE p1;
......
......@@ -9771,3 +9771,83 @@ $$
DELIMITER ;$$
CALL p1();
DROP PROCEDURE p1;
--echo #
--echo # MDEV-14228 MariaDB crashes with function
--echo #
CREATE TABLE t1 (c VARCHAR(16), KEY(c));
INSERT INTO t1 VALUES ('foo');
DELIMITER $$;
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v VARCHAR(16);
FOR v IN (SELECT DISTINCT c FROM t1)
DO
IF (v = 'bar') THEN
SELECT 1 INTO @a;
END IF;
END FOR;
RETURN 'qux';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DELIMITER $$;
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v ROW TYPE OF t1;
IF v = 'bar' THEN
RETURN 'eq';
END IF;
RETURN 'ne';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DELIMITER $$;
CREATE FUNCTION f1() RETURNS VARCHAR(16)
BEGIN
DECLARE v ROW(a INT);
IF v = 'bar' THEN
RETURN 'eq';
END IF;
RETURN 'ne';
END $$
DELIMITER ;$$
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT f1();
DROP FUNCTION f1;
DROP TABLE t1;
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT v IN ('a','b');
END $$
DELIMITER ;$$
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT 'a' IN (v,'b');
END $$
DELIMITER ;$$
DELIMITER $$;
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
BEGIN NOT ATOMIC
DECLARE v ROW(a INT);
SELECT 'a' IN ('b',v);
END $$
DELIMITER ;$$
......@@ -188,10 +188,10 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
pseudo='joce');
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
......@@ -1834,13 +1834,13 @@ drop table t1, t2;
#
create table t1 (a int, b int);
insert into t1 values (1,2);
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
select 1 = (select * from t1);
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
select (select * from t1) = 1;
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
select (1,2) = (select a from t1);
-- error ER_OPERAND_COLUMNS
-- error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
select (select a from t1) = (1,2);
-- error ER_OPERAND_COLUMNS
select (1,2,3) = (select * from t1);
......
......@@ -1148,6 +1148,16 @@ bool Item::check_type_can_return_text(const char *opname) const
bool Item::check_type_scalar(const char *opname) const
{
/*
fixed==true usually means than the Item has an initialized
and reliable data type handler and attributes.
Item_outer_ref is an exception. It copies the data type and the attributes
from the referenced Item in the constructor, but then sets "fixed" to false,
and re-fixes itself again in fix_inner_refs().
This hack in Item_outer_ref should probably be refactored eventually.
Discuss with Sanja.
*/
DBUG_ASSERT(fixed || type() == REF_ITEM);
const Type_handler *handler= type_handler();
if (handler->is_scalar_type())
return false;
......
......@@ -153,12 +153,19 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
bool Item_func::check_argument_types_like_args0() const
{
uint cols;
if (arg_count == 0)
if (arg_count < 2)
return false;
cols= args[0]->cols();
uint cols= args[0]->cols();
bool is_scalar= args[0]->type_handler()->is_scalar_type();
for (uint i= 1; i < arg_count; i++)
{
if (is_scalar != args[i]->type_handler()->is_scalar_type())
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
args[0]->type_handler()->name().ptr(),
args[i]->type_handler()->name().ptr(), func_name());
return true;
}
if (args[i]->check_cols(cols))
return true;
}
......
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