File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed
plugin/type_inet/mysql-test/type_inet Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -1986,3 +1986,38 @@ ERROR HY000: Illegal parameter data type inet6 for operation 'extract(day)'
1986
1986
DROP TABLE t1;
1987
1987
SELECT EXTRACT(DAY FROM CAST('::' AS INET6));
1988
1988
ERROR HY000: Illegal parameter data type inet6 for operation 'extract(day)'
1989
+ #
1990
+ # MDEV-22764 Crash with a stored aggregate function returning INET6
1991
+ #
1992
+ CREATE OR REPLACE AGGREGATE FUNCTION aggregate_min_inet6(x INET6) RETURNS INET6
1993
+ BEGIN
1994
+ DECLARE res INET6 DEFAULT NULL;
1995
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
1996
+ RETURN res;
1997
+ LOOP
1998
+ FETCH GROUP NEXT ROW;
1999
+ IF (res IS NULL) OR (res > x) THEN
2000
+ SET res= x;
2001
+ END IF;
2002
+ END LOOP;
2003
+ END;
2004
+ $$
2005
+ CREATE OR REPLACE TABLE t1 (name CHAR(30), val INET6);
2006
+ INSERT INTO t1 VALUES ('a', '::05');
2007
+ INSERT INTO t1 VALUES ('a', '::03');
2008
+ INSERT INTO t1 VALUES ('b', '::01');
2009
+ INSERT INTO t1 VALUES ('b', '::02');
2010
+ INSERT INTO t1 VALUES ('b', '::05');
2011
+ SELECT name, aggregate_min_inet6(val) pc FROM t1 GROUP BY name;
2012
+ name pc
2013
+ a ::3
2014
+ b ::1
2015
+ CREATE OR REPLACE TABLE t2 (name CHAR(30), val INET6);
2016
+ INSERT INTO t2 SELECT name, aggregate_min_inet6(val) pc FROM t1 GROUP BY name;
2017
+ SELECT * FROM t2;
2018
+ name val
2019
+ a ::3
2020
+ b ::1
2021
+ DROP TABLE t2;
2022
+ DROP TABLE t1;
2023
+ DROP FUNCTION aggregate_min_inet6;
Original file line number Diff line number Diff line change @@ -1457,3 +1457,40 @@ SELECT EXTRACT(DAY FROM a) FROM t1;
1457
1457
DROP TABLE t1;
1458
1458
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
1459
1459
SELECT EXTRACT(DAY FROM CAST('::' AS INET6));
1460
+
1461
+
1462
+ --echo #
1463
+ --echo # MDEV-22764 Crash with a stored aggregate function returning INET6
1464
+ --echo #
1465
+
1466
+ DELIMITER $$;
1467
+ CREATE OR REPLACE AGGREGATE FUNCTION aggregate_min_inet6(x INET6) RETURNS INET6
1468
+ BEGIN
1469
+ DECLARE res INET6 DEFAULT NULL;
1470
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
1471
+ RETURN res;
1472
+ LOOP
1473
+ FETCH GROUP NEXT ROW;
1474
+ IF (res IS NULL) OR (res > x) THEN
1475
+ SET res= x;
1476
+ END IF;
1477
+ END LOOP;
1478
+ END;
1479
+ $$
1480
+ DELIMITER ;$$
1481
+
1482
+ CREATE OR REPLACE TABLE t1 (name CHAR(30), val INET6);
1483
+ INSERT INTO t1 VALUES ('a', '::05');
1484
+ INSERT INTO t1 VALUES ('a', '::03');
1485
+ INSERT INTO t1 VALUES ('b', '::01');
1486
+ INSERT INTO t1 VALUES ('b', '::02');
1487
+ INSERT INTO t1 VALUES ('b', '::05');
1488
+ SELECT name, aggregate_min_inet6(val) pc FROM t1 GROUP BY name;
1489
+
1490
+ CREATE OR REPLACE TABLE t2 (name CHAR(30), val INET6);
1491
+ INSERT INTO t2 SELECT name, aggregate_min_inet6(val) pc FROM t1 GROUP BY name;
1492
+ SELECT * FROM t2;
1493
+ DROP TABLE t2;
1494
+
1495
+ DROP TABLE t1;
1496
+ DROP FUNCTION aggregate_min_inet6;
Original file line number Diff line number Diff line change @@ -1407,6 +1407,11 @@ class Item_sum_sp :public Item_sum,
1407
1407
return sp_result_field->val_decimal (dec_buf);
1408
1408
}
1409
1409
1410
+ bool val_native (THD *thd, Native *to)
1411
+ {
1412
+ return null_value= execute () || sp_result_field->val_native (to);
1413
+ }
1414
+
1410
1415
String *val_str (String *str)
1411
1416
{
1412
1417
String buf;
You can’t perform that action at this time.
0 commit comments