Skip to content

Commit 1a9a52f

Browse files
tomas-villagesqlmjamaloney
authored andcommitted
Improve custom type comparison error messages and validation (#438)
GitOrigin-RevId: 1c78d4980e7d5ff80b34c58bf0dcd7cb0e0681a7
1 parent e12a636 commit 1a9a52f

20 files changed

Lines changed: 139 additions & 44 deletions

mysql-test/suite/villagesql/implicit_cast/disallowed/r/cross_join_mixed_comparison.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ CREATE TABLE t_string (id INT, val VARCHAR(100));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_string VALUES (1, 'hello');
55
SELECT * FROM t_complex c CROSS JOIN t_string s WHERE c.val < s.val;
6-
ERROR HY000: Cannot compare values of custom and non-custom types in <
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in <
77
DROP TABLE t_complex;
88
DROP TABLE t_string;

mysql-test/suite/villagesql/implicit_cast/disallowed/r/cross_type_comparison_complex_numeric.result

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ CREATE TABLE t_numeric (id INT, val DECIMAL(10,2));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_numeric VALUES (1, 10.50);
55
SELECT * FROM t_complex c, t_numeric n WHERE c.val = n.val;
6-
ERROR HY000: Cannot compare values of custom and non-custom types in =
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
77
DROP TABLE t_complex;
88
DROP TABLE t_numeric;
9+
CREATE TABLE t_mixed (id INT, complex_col COMPLEX, decimal_col DECIMAL(10,2), int_col INT);
10+
INSERT INTO t_mixed VALUES (1, '(1.0,2.0)', 1.5, 5);
11+
SELECT * FROM t_mixed WHERE complex_col = decimal_col;
12+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
13+
SELECT * FROM t_mixed WHERE complex_col = int_col;
14+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
15+
SELECT * FROM t_mixed WHERE complex_col = 5;
16+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
17+
SELECT * FROM t_mixed WHERE complex_col = 1.5;
18+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
19+
DROP TABLE t_mixed;

mysql-test/suite/villagesql/implicit_cast/disallowed/r/cross_type_comparison_complex_string.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ CREATE TABLE t_string (id INT, val VARCHAR(100));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_string VALUES (1, 'hello');
55
SELECT * FROM t_complex c, t_string s WHERE c.val = s.val;
6-
ERROR HY000: Cannot compare values of custom and non-custom types in =
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
77
DROP TABLE t_complex;
88
DROP TABLE t_string;

mysql-test/suite/villagesql/implicit_cast/disallowed/r/exists_subquery_mixed_comparison.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ CREATE TABLE t_string (id INT, val VARCHAR(100));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_string VALUES (1, 'hello');
55
SELECT * FROM t_complex c WHERE EXISTS (SELECT 1 FROM t_string s WHERE c.val = s.val);
6-
ERROR HY000: Cannot compare values of custom and non-custom types in =
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
77
DROP TABLE t_complex;
88
DROP TABLE t_string;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE TABLE t_complex (id INT, val COMPLEX);
22
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
33
SELECT COUNT(*) FROM t_complex GROUP BY val || 'test';
4-
ERROR HY000: Cannot compare values of custom and non-custom types in <>
4+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in <>
55
DROP TABLE t_complex;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE t_complex (id INT, val COMPLEX);
2+
CREATE TABLE t_string (id INT, val VARCHAR(100));
3+
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
4+
INSERT INTO t_string VALUES (1, 'hello');
5+
SELECT * FROM t_complex c JOIN t_string s ON c.val = s.val;
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
7+
DROP TABLE t_complex;
8+
DROP TABLE t_string;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE t_complex (id INT, val COMPLEX);
2+
CREATE TABLE t_numeric (id INT, val DECIMAL(10,2));
3+
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
4+
INSERT INTO t_numeric VALUES (1, 10.50);
5+
SELECT * FROM t_complex c LEFT JOIN t_numeric n ON c.val = n.val;
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
7+
DROP TABLE t_complex;
8+
DROP TABLE t_numeric;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE t_complex (id INT, val COMPLEX);
2+
CREATE TABLE t_string (id INT, val VARCHAR(100));
3+
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
4+
INSERT INTO t_string VALUES (1, 'hello');
5+
DELETE c FROM t_complex c, t_string s WHERE c.val = s.val;
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
7+
DROP TABLE t_complex;
8+
DROP TABLE t_string;

mysql-test/suite/villagesql/implicit_cast/disallowed/r/subquery_comparison_numeric.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ CREATE TABLE t_numeric (id INT, val DECIMAL(10,2));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_numeric VALUES (1, 10.50);
55
SELECT * FROM t_complex WHERE val > (SELECT AVG(val) FROM t_numeric);
6-
ERROR HY000: Cannot compare values of custom and non-custom types in >
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in >
77
DROP TABLE t_complex;
88
DROP TABLE t_numeric;

mysql-test/suite/villagesql/implicit_cast/disallowed/r/subquery_cross_type_in.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ CREATE TABLE t_string (id INT, val VARCHAR(100));
33
INSERT INTO t_complex VALUES (1, '(1.0,2.0)');
44
INSERT INTO t_string VALUES (1, 'hello');
55
SELECT * FROM t_complex WHERE val IN (SELECT val FROM t_string);
6-
ERROR HY000: Cannot compare values of custom and non-custom types in =
6+
ERROR HY000: Unable to implicitly cast a non-custom type during compare with a custom type in =
77
DROP TABLE t_complex;
88
DROP TABLE t_string;

0 commit comments

Comments
 (0)