From 0bed4d72c03184ceaafb82a0a4b7d8deea55bd61 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 24 Jun 2022 17:21:31 +0400 Subject: [PATCH] MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER Now INSERT, UPDATE, ALTER statements involving incompatible data type pairs, e.g.: UPDATE TABLE t1 SET col_inet6=col_int; INSERT INTO t1 (col_inet6) SELECT col_in FROM t2; ALTER TABLE t1 MODIFY col_inet6 INT; consistently return an error at the statement preparation time: ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' and abort the statement before starting interating rows. This error is the same with what is raised for queries like: SELECT col_inet6 FROM t1 UNION SELECT col_int FROM t2; SELECT COALESCE(col_inet6, col_int) FROM t1; Before this change the error was caught only during the execution time, when a Field_xxx::store_xxx() was called for the very firts row. The behavior was not consistent between various statements and could do different things: - abort the statement - set a column to the data type default value (e.g. '::' for INET6) - set a column to NULL A typical old error was: ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`a` at row 1 EXCEPTION: Note, there is an exception: a multi-row INSERT..VALUES, e.g.: INSERT INTO t1 (col_a,col_b) VALUES (a1,b1),(a2,b2); checks assignment compability at the preparation time for the very first row only: (col_a,col_b) vs (a1,b1) Other rows are still checked at the execution time and return the old warnings or errors in case of a failure. This is done because catching all rows at the preparation time would change behavior significantly. So it still works according to the STRICT_XXX_TABLES sql_mode flags and the table transaction ability. This is too late to change this behavior in 10.7. There is no a firm decision yet if a multi-row INSERT..VALUES behavior will change in later versions. --- mysql-test/include/gis_generic.inc | 4 +- mysql-test/include/type_mix_incompatible.inc | 137 ++++++++++++ mysql-test/main/get_diagnostics.result | 8 +- mysql-test/main/get_diagnostics.test | 4 +- mysql-test/main/gis.result | 4 +- mysql-test/main/gis.test | 4 +- mysql-test/main/type_geometry_mix_int.result | 192 +++++++++++++++++ mysql-test/main/type_geometry_mix_int.test | 19 ++ mysql-test/suite/archive/archive_gis.result | 4 +- mysql-test/suite/innodb/r/innodb_gis.result | 4 +- mysql-test/suite/innodb_gis/r/0.result | 4 +- mysql-test/suite/innodb_gis/r/1.result | 4 +- mysql-test/suite/innodb_gis/r/gis.result | 4 +- mysql-test/suite/innodb_gis/t/1.test | 4 +- mysql-test/suite/innodb_gis/t/gis.test | 4 +- .../mysql-test/type_inet/type_inet6.result | 48 ++--- .../mysql-test/type_inet/type_inet6.test | 49 +++-- .../type_inet/type_inet6_mix_decimal.result | 195 ++++++++++++++++++ .../type_inet/type_inet6_mix_decimal.test | 19 ++ .../type_inet/type_inet6_mix_double.result | 195 ++++++++++++++++++ .../type_inet/type_inet6_mix_double.test | 19 ++ .../type_inet/type_inet6_mix_int.result | 195 ++++++++++++++++++ .../type_inet/type_inet6_mix_int.test | 19 ++ .../type_inet/type_inet6_mix_time.result | 195 ++++++++++++++++++ .../type_inet/type_inet6_mix_time.test | 19 ++ .../type_inet/type_inet6_mix_uint.result | 195 ++++++++++++++++++ .../type_inet/type_inet6_mix_uint.test | 19 ++ plugin/type_mysql_json/type.cc | 12 ++ .../mysql-test/type_uuid/type_uuid.result | 42 ++-- .../mysql-test/type_uuid/type_uuid.test | 42 ++-- .../type_uuid/type_uuid_mix_decimal.result | 195 ++++++++++++++++++ .../type_uuid/type_uuid_mix_decimal.test | 19 ++ .../type_uuid/type_uuid_mix_double.result | 195 ++++++++++++++++++ .../type_uuid/type_uuid_mix_double.test | 19 ++ .../type_uuid/type_uuid_mix_int.result | 195 ++++++++++++++++++ .../type_uuid/type_uuid_mix_int.test | 19 ++ .../type_uuid/type_uuid_mix_time.result | 195 ++++++++++++++++++ .../type_uuid/type_uuid_mix_time.test | 19 ++ .../type_uuid/type_uuid_mix_uint.result | 195 ++++++++++++++++++ .../type_uuid/type_uuid_mix_uint.test | 19 ++ sql/field.cc | 26 +++ sql/field.h | 6 + sql/item.cc | 16 ++ sql/item.h | 19 ++ sql/sql_insert.cc | 42 +++- sql/sql_table.cc | 2 + sql/sql_update.cc | 6 +- sql/table.cc | 54 +++++ sql/table.h | 21 ++ 49 files changed, 2805 insertions(+), 120 deletions(-) create mode 100644 mysql-test/include/type_mix_incompatible.inc create mode 100644 mysql-test/main/type_geometry_mix_int.result create mode 100644 mysql-test/main/type_geometry_mix_int.test create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.result create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.test create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.result create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.test create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.result create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.test create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.result create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.test create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.result create mode 100644 plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.test create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.result create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.test create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.result create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.test create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.result create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.test create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.result create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.test create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.result create mode 100644 plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.test diff --git a/mysql-test/include/gis_generic.inc b/mysql-test/include/gis_generic.inc index 8209240614e..c693b86b896 100644 --- a/mysql-test/include/gis_generic.inc +++ b/mysql-test/include/gis_generic.inc @@ -180,9 +180,9 @@ insert IGNORE into t1 (a) values ('Garbage'); drop table t1; create table t1 (pk integer primary key auto_increment, fl geometry not null); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 (fl) values (1); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 (fl) values (1.11); --error 1416 insert into t1 (fl) values ("qwerty"); diff --git a/mysql-test/include/type_mix_incompatible.inc b/mysql-test/include/type_mix_incompatible.inc new file mode 100644 index 00000000000..8f0eb4fb70c --- /dev/null +++ b/mysql-test/include/type_mix_incompatible.inc @@ -0,0 +1,137 @@ +--echo # Start of type_store_assignment_incompatible.inc + +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS + WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); + +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS + WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); + +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; + +# +# Single row INSERT..VALUES +# + +CREATE TABLE t3 LIKE t2; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 VALUES + (1, + (SELECT source FROM t2 ORDER BY id LIMIT 1), + (SELECT source FROM t2 ORDER BY id LIMIT 1)); +DROP TABLE t3; + +# +# Multi-row INSERT..VALUES +# + +# INSERT .. VALUES checks assignment compatibility for the first row only. +# Here the first row is compatible, so no error happens. +# The second row is not compatible. It works according to the +# current sql_mode and the table transaction ability, so it can: +# (a) either raise a warning +# (b) or escalate a warning to an error and abort on the current row +# (c) or escalate a warning to an error and rollback +# Here we test (a) and (b). + +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE + CONCAT('CREATE VIEW v3 AS SELECT id,', + IF(@target_type='geometry','AsText(target)','target'), ' AS target,', + IF(@source_type='geometry','AsText(source)','source'), ' AS source ', + ' FROM t3'); + +--error 0,ER_CANT_CREATE_GEOMETRY_OBJECT +INSERT INTO t3 VALUES + (1, + (SELECT target FROM t2 ORDER BY id LIMIT 1), + (SELECT source FROM t2 ORDER BY id LIMIT 1)), + (2, + (SELECT source FROM t2 ORDER BY id LIMIT 1), + (SELECT source FROM t2 ORDER BY id LIMIT 1)); +SELECT * FROM v3; +TRUNCATE TABLE t3; + +SET sql_mode=STRICT_ALL_TABLES; +--error ER_TRUNCATED_WRONG_VALUE, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, WARN_DATA_TRUNCATED, ER_CANT_CREATE_GEOMETRY_OBJECT +INSERT INTO t3 VALUES + (1, + (SELECT target FROM t2 ORDER BY id LIMIT 1), + (SELECT source FROM t2 ORDER BY id LIMIT 1)), + (2, + (SELECT source FROM t2 ORDER BY id LIMIT 1), + (SELECT source FROM t2 ORDER BY id LIMIT 1)); +SELECT * FROM v3; +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; + +# +# INSERT .. SELECT +# + +CREATE TABLE t3 LIKE t2; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 SELECT id,source,source FROM t2; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; + +# +# INSERT .. VALUES .. ON DUPLICATE KEY UPDATE target=source +# + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; + +# +# INSERT .. SELECT .. ON DUPLICATE KEY UPDATE target=source +# + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; + + +# +# UPDATE +# +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +UPDATE t3 SET target=source; + + +# +# UPDATE, multi-table +# + +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; + + +# +# ALTER +# + +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +EXECUTE IMMEDIATE @alter; + + +DROP TABLE t3; +DROP TABLE t2; +--echo # End of type_store_assignment_incompatible.inc diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 47fd30f0dc7..697b3a589d7 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -1152,11 +1152,11 @@ SELECT @var62, @var63; @var62 @var63 1 NULL INSERT INTO t1 SELECT id2, val2, p2 from t2; -ERROR 22007: Incorrect double value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00$@' for column `test`.`t1`.`d1` at row 1 +ERROR HY000: Illegal parameter data types double and point for operation 'SET' GET DIAGNOSTICS CONDITION 1 @var64= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var65= ROW_NUMBER; Warnings: -Error 1366 Incorrect double value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00$@' for column `test`.`t1`.`d1` at row 1 +Error 4078 Illegal parameter data types double and point for operation 'SET' Error 1758 Invalid condition number SELECT @var64, @var65; @var64 @var65 @@ -1396,11 +1396,11 @@ SELECT @var103, @var104; @var103 @var104 1 NULL INSERT INTO t1 SELECT id2, val2, p2 from t2; -ERROR 22007: Incorrect double value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00$@' for column `test`.`t1`.`d1` at row 1 +ERROR HY000: Illegal parameter data types double and point for operation 'SET' GET DIAGNOSTICS CONDITION 1 @var105= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var106= ROW_NUMBER; Warnings: -Error 1366 Incorrect double value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00$@' for column `test`.`t1`.`d1` at row 1 +Error 4078 Illegal parameter data types double and point for operation 'SET' Error 1758 Invalid condition number SELECT @var105, @var106; @var105 @var106 diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 8576d2ed8c1..01063551b9b 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -1091,7 +1091,7 @@ GET DIAGNOSTICS CONDITION 1 @var62= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var63= ROW_NUMBER; SELECT @var62, @var63; ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 SELECT id2, val2, p2 from t2; GET DIAGNOSTICS CONDITION 1 @var64= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var65= ROW_NUMBER; @@ -1277,7 +1277,7 @@ GET DIAGNOSTICS CONDITION 1 @var103= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var104= ROW_NUMBER; SELECT @var103, @var104; ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 SELECT id2, val2, p2 from t2; GET DIAGNOSTICS CONDITION 1 @var105= ROW_NUMBER; GET DIAGNOSTICS CONDITION 2 @var106= ROW_NUMBER; diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index f941447a677..88cd55c0251 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -688,9 +688,9 @@ object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo)) drop table t1; create table t1 (fl geometry not null); insert into t1 values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index 17a93291b77..f1fed747d51 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -366,9 +366,9 @@ t1 where object_id=85984; drop table t1; create table t1 (fl geometry not null); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1.11); --error 1416 insert into t1 values ("qwerty"); diff --git a/mysql-test/main/type_geometry_mix_int.result b/mysql-test/main/type_geometry_mix_int.result new file mode 100644 index 00000000000..6511a0fcea6 --- /dev/null +++ b/mysql-test/main/type_geometry_mix_int.result @@ -0,0 +1,192 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target GEOMETRY DEFAULT POINT(1,1), source INT DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` geometry DEFAULT point(1,1), + `source` int(11) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +SELECT * FROM v3; +id target source +1 POINT(1 1) 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 POINT(1 1) 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target int(11) +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target INT DEFAULT 0, source GEOMETRY DEFAULT POINT(1,1)); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` int(11) DEFAULT 0, + `source` geometry DEFAULT point(1,1), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1366 Incorrect integer value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0?\x00\x00\x00\x00\x00\x00\xF0?' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 0 POINT(1 1) +2 0 POINT(1 1) +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 POINT(1 1) +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types int and geometry for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target geometry +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/mysql-test/main/type_geometry_mix_int.test b/mysql-test/main/type_geometry_mix_int.test new file mode 100644 index 00000000000..1c64a13e1e8 --- /dev/null +++ b/mysql-test/main/type_geometry_mix_int.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target GEOMETRY DEFAULT POINT(1,1), source INT DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target INT DEFAULT 0, source GEOMETRY DEFAULT POINT(1,1)); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/mysql-test/suite/archive/archive_gis.result b/mysql-test/suite/archive/archive_gis.result index e24cad80702..25854db1feb 100644 --- a/mysql-test/suite/archive/archive_gis.result +++ b/mysql-test/suite/archive/archive_gis.result @@ -452,9 +452,9 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1; create table t1 (pk integer primary key auto_increment, fl geometry not null); insert into t1 (fl) values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 (fl) values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 (fl) values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 (fl) values (pointfromtext('point(1,1)')); diff --git a/mysql-test/suite/innodb/r/innodb_gis.result b/mysql-test/suite/innodb/r/innodb_gis.result index 90fc5be1e73..c222e7d053a 100644 --- a/mysql-test/suite/innodb/r/innodb_gis.result +++ b/mysql-test/suite/innodb/r/innodb_gis.result @@ -452,9 +452,9 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1; create table t1 (pk integer primary key auto_increment, fl geometry not null); insert into t1 (fl) values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 (fl) values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 (fl) values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 (fl) values (pointfromtext('point(1,1)')); diff --git a/mysql-test/suite/innodb_gis/r/0.result b/mysql-test/suite/innodb_gis/r/0.result index 6dd2cd16437..3f72baadd12 100644 --- a/mysql-test/suite/innodb_gis/r/0.result +++ b/mysql-test/suite/innodb_gis/r/0.result @@ -452,9 +452,9 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1; create table t1 (pk integer primary key auto_increment, fl geometry not null); insert into t1 (fl) values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 (fl) values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 (fl) values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 (fl) values (pointfromtext('point(1,1)')); diff --git a/mysql-test/suite/innodb_gis/r/1.result b/mysql-test/suite/innodb_gis/r/1.result index f8db53a4ca9..53750015716 100644 --- a/mysql-test/suite/innodb_gis/r/1.result +++ b/mysql-test/suite/innodb_gis/r/1.result @@ -660,9 +660,9 @@ object_id ST_geometrytype(geo) ST_ISSIMPLE(GEO) ST_ASTEXT(ST_centroid(geo)) drop table t1; create table t1 (fl geometry not null); insert into t1 values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (ST_pointfromtext('point(1,1)')); diff --git a/mysql-test/suite/innodb_gis/r/gis.result b/mysql-test/suite/innodb_gis/r/gis.result index f41fcab5bbb..5f7ca9e03fe 100644 --- a/mysql-test/suite/innodb_gis/r/gis.result +++ b/mysql-test/suite/innodb_gis/r/gis.result @@ -661,9 +661,9 @@ object_id ST_geometrytype(geo) ST_ISSIMPLE(GEO) ST_ASTEXT(ST_centroid(geo)) drop table t1; create table t1 (fl geometry not null); insert into t1 values (1); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and int for operation 'SET' insert into t1 values (1.11); -ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +ERROR HY000: Illegal parameter data types geometry and decimal for operation 'SET' insert into t1 values ("qwerty"); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (ST_pointfromtext('point(1,1)')); diff --git a/mysql-test/suite/innodb_gis/t/1.test b/mysql-test/suite/innodb_gis/t/1.test index 950db360794..99651842795 100644 --- a/mysql-test/suite/innodb_gis/t/1.test +++ b/mysql-test/suite/innodb_gis/t/1.test @@ -387,9 +387,9 @@ t1 where object_id=85984; drop table t1; create table t1 (fl geometry not null); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1.11); --error 1416 insert into t1 values ("qwerty"); diff --git a/mysql-test/suite/innodb_gis/t/gis.test b/mysql-test/suite/innodb_gis/t/gis.test index 966aea7bc77..b27e1852d6e 100644 --- a/mysql-test/suite/innodb_gis/t/gis.test +++ b/mysql-test/suite/innodb_gis/t/gis.test @@ -380,9 +380,9 @@ t1 where object_id=85984; drop table t1; create table t1 (fl geometry not null); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1); ---error 1416 +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION insert into t1 values (1.11); --error 1416 insert into t1 values ("qwerty"); diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result index 9f3b8a9715e..932f3a68625 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -192,9 +192,9 @@ CREATE TABLE t1 (a INET6); INSERT INTO t1 VALUES ('x'); ERROR 22007: Incorrect inet6 value: 'x' for column `test`.`t1`.`a` at row 1 INSERT INTO t1 VALUES (1); -ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' INSERT INTO t1 VALUES (TIME'10:20:30'); -ERROR 22007: Incorrect inet6 value: '10:20:30' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' INSERT INTO t1 VALUES (0x00); ERROR 22007: Incorrect inet6 value: '\x00' for column `test`.`t1`.`a` at row 1 DROP TABLE t1; @@ -820,15 +820,15 @@ DROP TABLE t1; # CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (CAST('::' AS INET6)); -ERROR 22007: Incorrect integer value: '::' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a DOUBLE); INSERT INTO t1 VALUES (CAST('::' AS INET6)); -ERROR 22007: Incorrect double value: '::' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0)); INSERT INTO t1 VALUES (CAST('::' AS INET6)); -ERROR 22007: Incorrect decimal value: '::' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(64)); INSERT INTO t1 VALUES (CAST('::' AS INET6)); @@ -1606,7 +1606,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b INT); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1614,7 +1614,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b DOUBLE); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect double value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1622,7 +1622,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b DECIMAL(32,0)); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect decimal value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1630,7 +1630,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b YEAR); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types year and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1641,7 +1641,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b INET6); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' SELECT b FROM t1; b NULL @@ -1649,7 +1649,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DOUBLE, b INET6); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' SELECT b FROM t1; b NULL @@ -1657,7 +1657,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0), b INET6); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' SELECT b FROM t1; b NULL @@ -1665,7 +1665,7 @@ DROP TABLE t1; CREATE TABLE t1 (a YEAR, b INET6); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '2001' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and year for operation 'SET' SELECT b FROM t1; b NULL @@ -1676,7 +1676,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b TIME); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect time value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1684,7 +1684,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b DATE); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect date value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types date and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1692,7 +1692,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b DATETIME); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types datetime and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1700,7 +1700,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b TIMESTAMP NULL DEFAULT NULL); INSERT INTO t1 VALUES ('ffff::ffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types timestamp and inet6 for operation 'SET' SELECT b FROM t1; b NULL @@ -1711,7 +1711,7 @@ DROP TABLE t1; CREATE TABLE t1 (a TIME, b INET6); INSERT INTO t1 VALUES ('00:00:00', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '00:00:00' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' SELECT b FROM t1; b NULL @@ -1719,7 +1719,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DATE, b INET6); INSERT INTO t1 VALUES ('2001-01:01', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '2001-01-01' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and date for operation 'SET' SELECT b FROM t1; b NULL @@ -1727,7 +1727,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DATETIME, b INET6); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and datetime for operation 'SET' SELECT b FROM t1; b NULL @@ -1735,7 +1735,7 @@ DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP, b INET6); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types inet6 and timestamp for operation 'SET' SELECT b FROM t1; b NULL @@ -1922,7 +1922,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b INT); INSERT INTO t1 (a) VALUES ('::'); UPDATE t1 SET b=a; -ERROR 22007: Incorrect integer value: '::' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' SELECT * FROM t1; a b :: NULL @@ -1931,7 +1931,7 @@ SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30'); CREATE TABLE t1 (a INET6, b TIMESTAMP); INSERT INTO t1 (a) VALUES ('::'); UPDATE t1 SET b=a; -ERROR 22007: Incorrect datetime value: '::' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types timestamp and inet6 for operation 'SET' SELECT * FROM t1; a b :: 2001-01-01 10:20:30 @@ -1940,7 +1940,7 @@ SET timestamp=DEFAULT; CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 (a) VALUES ('::'); ALTER TABLE t1 MODIFY a DATE; -ERROR 22007: Incorrect date value: '::' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types date and inet6 for operation 'SET' DROP TABLE t1; # # MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.test b/plugin/type_inet/mysql-test/type_inet/type_inet6.test index ef8399d981f..72059bd060c 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -1,4 +1,3 @@ - --echo # --echo # Basic CREATE functionality, defaults, metadata --echo # @@ -48,9 +47,9 @@ CREATE TABLE t1 (c1 INET6 DEFAULT ''); CREATE TABLE t1 (a INET6); --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES ('x'); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (1); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (TIME'10:20:30'); --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES (0x00); @@ -447,17 +446,17 @@ DROP TABLE t1; --echo # CREATE TABLE t1 (a INT); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('::' AS INET6)); DROP TABLE t1; CREATE TABLE t1 (a DOUBLE); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('::' AS INET6)); DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0)); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('::' AS INET6)); DROP TABLE t1; @@ -1095,28 +1094,28 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b INT); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b DOUBLE); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b DECIMAL(32,0)); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b YEAR); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1128,28 +1127,28 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b INET6); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DOUBLE, b INET6); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0), b INET6); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a YEAR, b INET6); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1161,28 +1160,28 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b TIME); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b DATE); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b DATETIME); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a INET6, b TIMESTAMP NULL DEFAULT NULL); INSERT INTO t1 VALUES ('ffff::ffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1194,28 +1193,28 @@ DROP TABLE t1; CREATE TABLE t1 (a TIME, b INET6); INSERT INTO t1 VALUES ('00:00:00', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DATE, b INET6); INSERT INTO t1 VALUES ('2001-01:01', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DATETIME, b INET6); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP, b INET6); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1406,7 +1405,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INET6, b INT); INSERT INTO t1 (a) VALUES ('::'); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT * FROM t1; DROP TABLE t1; @@ -1414,7 +1413,7 @@ DROP TABLE t1; SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30'); CREATE TABLE t1 (a INET6, b TIMESTAMP); INSERT INTO t1 (a) VALUES ('::'); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT * FROM t1; DROP TABLE t1; @@ -1422,7 +1421,7 @@ SET timestamp=DEFAULT; CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 (a) VALUES ('::'); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION ALTER TABLE t1 MODIFY a DATE; DROP TABLE t1; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.result new file mode 100644 index 00000000000..c045bbe7769 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target INET6 DEFAULT '::0', source DECIMAL(38,0) DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` inet6 DEFAULT '::', + `source` decimal(38,0) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect inet6 value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 :: 0 +2 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target decimal(38,0) +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target DECIMAL(38,0) DEFAULT 0, source INET6 DEFAULT '::0'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` decimal(38,0) DEFAULT 0, + `source` inet6 DEFAULT '::', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1366 Incorrect decimal value: '::' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 0 :: +2 0 :: +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 :: +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types decimal and inet6 for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target inet6 +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types inet6 and decimal for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.test new file mode 100644 index 00000000000..9696d313790 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_decimal.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target INET6 DEFAULT '::0', source DECIMAL(38,0) DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target DECIMAL(38,0) DEFAULT 0, source INET6 DEFAULT '::0'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.result new file mode 100644 index 00000000000..cd658dbab1a --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target INET6 DEFAULT '::0', source DOUBLE DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` inet6 DEFAULT '::', + `source` double DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect inet6 value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 :: 0 +2 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target double +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target DOUBLE DEFAULT 0, source INET6 DEFAULT '::0'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` double DEFAULT 0, + `source` inet6 DEFAULT '::', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1366 Incorrect double value: '::' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 0 :: +2 0 :: +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 :: +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types double and inet6 for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target inet6 +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types inet6 and double for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.test new file mode 100644 index 00000000000..8fc0e24d177 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_double.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target INET6 DEFAULT '::0', source DOUBLE DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target DOUBLE DEFAULT 0, source INET6 DEFAULT '::0'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.result new file mode 100644 index 00000000000..67052350187 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target INET6 DEFAULT '::0', source INT DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` inet6 DEFAULT '::', + `source` int(11) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect inet6 value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 :: 0 +2 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target int(11) +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target INT DEFAULT 0, source INET6 DEFAULT '::0'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` int(11) DEFAULT 0, + `source` inet6 DEFAULT '::', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1366 Incorrect integer value: '::' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 0 :: +2 0 :: +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 :: +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types int and inet6 for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target inet6 +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.test new file mode 100644 index 00000000000..21a47e39f90 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_int.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target INET6 DEFAULT '::0', source INT DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target INT DEFAULT 0, source INET6 DEFAULT '::0'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.result new file mode 100644 index 00000000000..042a9203fd6 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target INET6 DEFAULT '::0', source TIME DEFAULT '00:00:00'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` inet6 DEFAULT '::', + `source` time DEFAULT '00:00:00', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect inet6 value: '00:00:00' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 :: 00:00:00 +2 :: 00:00:00 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 :: 00:00:00 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target time +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target TIME DEFAULT '00:00:00', source INET6 DEFAULT '::0'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` time DEFAULT '00:00:00', + `source` inet6 DEFAULT '::', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 00:00:00 :: +2 00:00:00 :: +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00:00:00 :: +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types time and inet6 for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target inet6 +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types inet6 and time for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.test new file mode 100644 index 00000000000..7ffb3133d0c --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_time.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target INET6 DEFAULT '::0', source TIME DEFAULT '00:00:00'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target TIME DEFAULT '00:00:00', source INET6 DEFAULT '::0'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.result new file mode 100644 index 00000000000..579aee6e3fd --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target INET6 DEFAULT '::0', source INT UNSIGNED DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` inet6 DEFAULT '::', + `source` int(10) unsigned DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect inet6 value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 :: 0 +2 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 :: 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target int(10) unsigned +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target INT UNSIGNED DEFAULT 0, source INET6 DEFAULT '::0'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` int(10) unsigned DEFAULT 0, + `source` inet6 DEFAULT '::', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1366 Incorrect integer value: '::' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 0 :: +2 0 :: +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 :: +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types int unsigned and inet6 for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target inet6 +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types inet6 and int unsigned for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.test new file mode 100644 index 00000000000..7506b56742f --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_mix_uint.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target INET6 DEFAULT '::0', source INT UNSIGNED DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target INT UNSIGNED DEFAULT 0, source INET6 DEFAULT '::0'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_mysql_json/type.cc b/plugin/type_mysql_json/type.cc index 7e6576e5df4..ef8c97cfc1c 100644 --- a/plugin/type_mysql_json/type.cc +++ b/plugin/type_mysql_json/type.cc @@ -40,6 +40,18 @@ public: void Column_definition_reuse_fix_attributes(THD *thd, Column_definition *def, const Field *field) const override; + const Type_handler *type_handler_base() const override + { + /* + Override this method in the same way with what Type_handler_blob_json + does, to tell the server that MySQL JSON inherits aggregation behaviour + from the LONGBLOB data type. + This makes MariaDB JSON column and a MySQL JSON column compatible for + assignment, so "ALTER TABLE table_with_mysql_json FORCE" can run without + raising ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION. + */ + return &type_handler_long_blob; + } }; Type_handler_mysql_json type_handler_mysql_json; diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result index 7ce3b878a1a..adcafc51ece 100644 --- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result @@ -195,9 +195,9 @@ CREATE TABLE t1 (a UUID); INSERT INTO t1 VALUES ('x'); ERROR 22007: Incorrect uuid value: 'x' for column `test`.`t1`.`a` at row 1 INSERT INTO t1 VALUES (1); -ERROR 22007: Incorrect uuid value: '1' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' INSERT INTO t1 VALUES (TIME'10:20:30'); -ERROR 22007: Incorrect uuid value: '10:20:30' for column `test`.`t1`.`a` at row 1 +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' INSERT INTO t1 VALUES (0x00); ERROR 22007: Incorrect uuid value: '\x00' for column `test`.`t1`.`a` at row 1 DROP TABLE t1; @@ -1931,15 +1931,15 @@ DROP TABLE t1; # CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); -ERROR 01000: Data truncated for column 'a' at row 1 +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a DOUBLE); INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); -ERROR 01000: Data truncated for column 'a' at row 1 +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0)); INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); -ERROR 01000: Data truncated for column 'a' at row 1 +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(64)); INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); @@ -2762,7 +2762,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b INT); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect integer value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2770,7 +2770,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b DOUBLE); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect double value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2778,7 +2778,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b DECIMAL(32,0)); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect decimal value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2786,7 +2786,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b YEAR); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect integer value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types year and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2797,7 +2797,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b UUID); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' SELECT b FROM t1; b NULL @@ -2805,7 +2805,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DOUBLE, b UUID); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' SELECT b FROM t1; b NULL @@ -2813,7 +2813,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0), b UUID); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '1' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' SELECT b FROM t1; b NULL @@ -2821,7 +2821,7 @@ DROP TABLE t1; CREATE TABLE t1 (a YEAR, b UUID); INSERT INTO t1 VALUES (1, NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '2001' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and year for operation 'SET' SELECT b FROM t1; b NULL @@ -2832,7 +2832,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b TIME); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect time value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2840,7 +2840,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b DATE); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect date value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types date and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2848,7 +2848,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b DATETIME); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect datetime value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types datetime and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2856,7 +2856,7 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b TIMESTAMP NULL DEFAULT NULL); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect datetime value: 'ffffffff-ffff-ffff-ffff-ffffffffffff' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types timestamp and uuid for operation 'SET' SELECT b FROM t1; b NULL @@ -2867,7 +2867,7 @@ DROP TABLE t1; CREATE TABLE t1 (a TIME, b UUID); INSERT INTO t1 VALUES ('00:00:00', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '00:00:00' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' SELECT b FROM t1; b NULL @@ -2875,7 +2875,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DATE, b UUID); INSERT INTO t1 VALUES ('2001-01:01', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '2001-01-01' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and date for operation 'SET' SELECT b FROM t1; b NULL @@ -2883,7 +2883,7 @@ DROP TABLE t1; CREATE TABLE t1 (a DATETIME, b UUID); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and datetime for operation 'SET' SELECT b FROM t1; b NULL @@ -2891,7 +2891,7 @@ DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP, b UUID); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); UPDATE t1 SET b=a; -ERROR 22007: Incorrect uuid value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1 +ERROR HY000: Illegal parameter data types uuid and timestamp for operation 'SET' SELECT b FROM t1; b NULL diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test index 4a3525a783c..91f8f82125b 100644 --- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test @@ -51,9 +51,9 @@ CREATE TABLE t1 (c1 UUID DEFAULT ''); CREATE TABLE t1 (a UUID); --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES ('x'); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (1); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (TIME'10:20:30'); --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES (0x00); @@ -542,17 +542,17 @@ DROP TABLE t1; --echo # CREATE TABLE t1 (a INT); ---error WARN_DATA_TRUNCATED +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); DROP TABLE t1; CREATE TABLE t1 (a DOUBLE); ---error WARN_DATA_TRUNCATED +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0)); ---error WARN_DATA_TRUNCATED +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION INSERT INTO t1 VALUES (CAST('00000000-0000-0000-0000-000000000000' AS UUID)); DROP TABLE t1; @@ -1250,28 +1250,28 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b INT); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b DOUBLE); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b DECIMAL(32,0)); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b YEAR); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1283,28 +1283,28 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b UUID); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DOUBLE, b UUID); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DECIMAL(32,0), b UUID); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a YEAR, b UUID); INSERT INTO t1 VALUES (1, NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1316,28 +1316,28 @@ DROP TABLE t1; CREATE TABLE t1 (a UUID, b TIME); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b DATE); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b DATETIME); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a UUID, b TIMESTAMP NULL DEFAULT NULL); INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; @@ -1349,28 +1349,28 @@ DROP TABLE t1; CREATE TABLE t1 (a TIME, b UUID); INSERT INTO t1 VALUES ('00:00:00', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DATE, b UUID); INSERT INTO t1 VALUES ('2001-01:01', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a DATETIME, b UUID); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP, b UUID); INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL); ---error ER_TRUNCATED_WRONG_VALUE +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION UPDATE t1 SET b=a; SELECT b FROM t1; DROP TABLE t1; diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.result new file mode 100644 index 00000000000..7fc9d0a9d38 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from UUID UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source DECIMAL(38,0) DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + `source` decimal(38,0) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect uuid value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +2 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target decimal(38,0) +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target DECIMAL(38,0) DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` decimal(38,0) DEFAULT 0, + `source` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +2 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types decimal and uuid for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target uuid +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types uuid and decimal for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.test new file mode 100644 index 00000000000..234e31b6565 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_decimal.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from UUID UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source DECIMAL(38,0) DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target DECIMAL(38,0) DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.result new file mode 100644 index 00000000000..87b3b1ecfb3 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source DOUBLE DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + `source` double DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect uuid value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +2 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target double +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target DOUBLE DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` double DEFAULT 0, + `source` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +2 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types double and uuid for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target uuid +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types uuid and double for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.test new file mode 100644 index 00000000000..8e8529aeed3 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_double.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source DOUBLE DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target DOUBLE DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.result new file mode 100644 index 00000000000..404581ee519 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source INT DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + `source` int(11) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect uuid value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +2 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target int(11) +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target INT DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` int(11) DEFAULT 0, + `source` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +2 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types int and uuid for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target uuid +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types uuid and int for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.test new file mode 100644 index 00000000000..79a55566258 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_int.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source INT DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target INT DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.result new file mode 100644 index 00000000000..99efe1b579c --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source TIME DEFAULT '00:00:00'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + `source` time DEFAULT '00:00:00', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect uuid value: '00:00:00' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 00:00:00 +2 00000000-0000-0000-0000-000000000000 00:00:00 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 00:00:00 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target time +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target TIME DEFAULT '00:00:00', source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` time DEFAULT '00:00:00', + `source` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 00:00:00 00000000-0000-0000-0000-000000000000 +2 00:00:00 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00:00:00 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types time and uuid for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target uuid +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types uuid and time for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.test new file mode 100644 index 00000000000..5182d0ceebd --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_time.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source TIME DEFAULT '00:00:00'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target TIME DEFAULT '00:00:00', source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.result new file mode 100644 index 00000000000..8f7236dab20 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.result @@ -0,0 +1,195 @@ +# +# Start of 10.7 tests +# +# +# MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +# +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source INT UNSIGNED DEFAULT 0); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + `source` int(10) unsigned DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1292 Incorrect uuid value: '0' for column `test`.`t3`.`target` at row 2 +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +2 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 00000000-0000-0000-0000-000000000000 0 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target int(10) unsigned +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +CREATE TABLE t1 (target INT UNSIGNED DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +# Start of type_store_assignment_incompatible.inc +SET @source_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='source' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +SET @target_type= (SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS +WHERE COLUMN_NAME='target' + AND TABLE_NAME='t1' + AND TABLE_SCHEMA='test'); +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ADD id INT NOT NULL PRIMARY KEY FIRST; +INSERT INTO t2 VALUES (1,DEFAULT,DEFAULT); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `target` int(10) unsigned DEFAULT 0, + `source` uuid DEFAULT '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 VALUES +(1, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +DROP TABLE t3; +SET sql_mode=''; +CREATE TABLE t3 LIKE t2; +ALTER TABLE t3 ENGINE=MyISAM; +EXECUTE IMMEDIATE +CONCAT('CREATE VIEW v3 AS SELECT id,', +IF(@target_type='geometry','AsText(target)','target'), ' AS target,', +IF(@source_type='geometry','AsText(source)','source'), ' AS source ', +' FROM t3'); +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Warnings: +Warning 1265 Data truncated for column 'target' at row 2 +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +2 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=STRICT_ALL_TABLES; +INSERT INTO t3 VALUES +(1, +(SELECT target FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)), +(2, +(SELECT source FROM t2 ORDER BY id LIMIT 1), +(SELECT source FROM t2 ORDER BY id LIMIT 1)); +Got one of the listed errors +SELECT * FROM v3; +id target source +1 0 00000000-0000-0000-0000-000000000000 +TRUNCATE TABLE t3; +SET sql_mode=DEFAULT; +DROP TABLE t3; +DROP VIEW v3; +CREATE TABLE t3 LIKE t2; +INSERT INTO t3 SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT id,source,source FROM t2; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +INSERT INTO t3 VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) VALUES (1,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE target=source; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +INSERT INTO t3 SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +INSERT INTO t3 (id,target,source) SELECT 1,DEFAULT(t2.target),DEFAULT(t2.source) FROM t2 ON DUPLICATE KEY UPDATE t3.target=t2.source; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +UPDATE t3 SET target=source; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +UPDATE t2, t3 SET t3.target=t2.source WHERE t2.id=t3.id; +ERROR HY000: Illegal parameter data types int unsigned and uuid for operation 'SET' +SET @alter=CONCAT('ALTER TABLE t3 MODIFY target ', @source_type); +SELECT @alter; +@alter +ALTER TABLE t3 MODIFY target uuid +EXECUTE IMMEDIATE @alter; +ERROR HY000: Illegal parameter data types uuid and int unsigned for operation 'SET' +DROP TABLE t3; +DROP TABLE t2; +# End of type_store_assignment_incompatible.inc +DROP TABLE t1; +# +# End of 10.7 tests +# diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.test new file mode 100644 index 00000000000..94de2dce2d8 --- /dev/null +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_mix_uint.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.7 tests +--echo # + +--echo # +--echo # MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER +--echo # + +CREATE TABLE t1 (target UUID DEFAULT '00000000-0000-0000-0000-000000000000', source INT UNSIGNED DEFAULT 0); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +CREATE TABLE t1 (target INT UNSIGNED DEFAULT 0, source UUID DEFAULT '00000000-0000-0000-0000-000000000000'); +--source include/type_mix_incompatible.inc +DROP TABLE t1; + +--echo # +--echo # End of 10.7 tests +--echo # diff --git a/sql/field.cc b/sql/field.cc index 348947329f7..5abf05fed2e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -964,6 +964,32 @@ Type_handler::aggregate_for_result_traditional(const Type_handler *a, } +bool Field::check_assignability_from(const Type_handler *from) const +{ + /* + Using type_handler_for_item_field() here to get the data type handler + on both sides. This is needed to make sure aggregation for Field + works the same way with how Item_field aggregates for UNION or CASE, + so these statements: + SELECT a FROM t1 UNION SELECT b FROM t1; // Item_field vs Item_field + UPDATE t1 SET a=b; // Field vs Item_field + either both return "Illegal parameter data types" or both pass + the data type compatibility test. + For MariaDB standard data types, using type_handler_for_item_field() + turns ENUM/SET into just CHAR. + */ + Type_handler_hybrid_field_type th(type_handler()-> + type_handler_for_item_field()); + if (th.aggregate_for_result(from->type_handler_for_item_field())) + { + my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0), + type_handler()->name().ptr(), from->name().ptr(), "SET"); + return true; + } + return false; +} + + /* Test if the given string contains important data: not spaces for character string, diff --git a/sql/field.h b/sql/field.h index 81e10307c89..2198066d962 100644 --- a/sql/field.h +++ b/sql/field.h @@ -905,6 +905,12 @@ public: bool is_unsigned() const { return flags & UNSIGNED_FLAG; } + bool check_assignability_from(const Type_handler *from) const; + bool check_assignability_from(const Field *from) const + { + return check_assignability_from(from->type_handler()); + } + /** Convenience definition of a copy function returned by Field::get_copy_func() diff --git a/sql/item.cc b/sql/item.cc index 1f6d585efd7..ecc9f8e6bfe 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4509,6 +4509,22 @@ bool Item_param::is_evaluable_expression() const } +bool Item_param::check_assignability_to(const Field *to) const +{ + switch (state) { + case SHORT_DATA_VALUE: + case LONG_DATA_VALUE: + case NULL_VALUE: + return to->check_assignability_from(type_handler()); + case NO_VALUE: + case IGNORE_VALUE: + case DEFAULT_VALUE: + break; + } + return false; +} + + bool Item_param::can_return_value() const { // There's no "default". See comments in Item_param::save_in_field(). diff --git a/sql/item.h b/sql/item.h index c3251259b43..117a252c025 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1838,6 +1838,16 @@ public: */ virtual bool is_evaluable_expression() const { return true; } + virtual bool check_assignability_to(const Field *to) const + { + /* + "this" must be neither DEFAULT/IGNORE, + nor Item_param bound to DEFAULT/IGNORE. + */ + DBUG_ASSERT(is_evaluable_expression()); + return to->check_assignability_from(type_handler()); + } + /** * Check whether the item is a parameter ('?') of stored routine. * Default implementation returns false. Method is overridden in the class @@ -4091,6 +4101,7 @@ class Item_param :public Item_basic_value, const String *value_query_val_str(THD *thd, String* str) const; Item *value_clone_item(THD *thd); bool is_evaluable_expression() const override; + bool check_assignability_to(const Field *field) const override; bool can_return_value() const; public: @@ -6771,6 +6782,10 @@ public: { str->append(STRING_WITH_LEN("default")); } + bool check_assignability_to(const Field *to) const override + { + return false; + } int save_in_field(Field *field_arg, bool) override { return field_arg->save_in_field_default_value(false); @@ -6804,6 +6819,10 @@ public: { str->append(STRING_WITH_LEN("ignore")); } + bool check_assignability_to(const Field *to) const override + { + return false; + } int save_in_field(Field *field_arg, bool) override { return field_arg->save_in_field_ignore_value(false); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d22a5670495..73bc914746d 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -829,6 +829,19 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, context->resolve_in_table_list_only(table_list); switch_to_nullable_trigger_fields(*values, table); + /* + Check assignability for the leftmost () in VALUES: + INSERT INTO t1 (a,b) VALUES (1,2), (3,4); + This checks if the values (1,2) can be assigned to fields (a,b). + The further values, e.g. (3,4) are not checked - they will be + checked during the execution time (when processing actual rows). + This is to preserve the "insert until the very first error"-style + behaviour for non-transactional tables. + */ + if (values->elements && + table_list->table->check_assignability_opt_fields(fields, *values)) + goto abort; + while ((values= its++)) { thd->get_stmt_da()->inc_current_row_for_warning(); @@ -1688,7 +1701,15 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, { select_lex->no_wrap_view_item= TRUE; res= check_update_fields(thd, context->table_list, update_fields, - update_values, false, &map); + update_values, false, &map) || + /* + Check that all col=expr pairs are compatible for assignment in + INSERT INTO t1 VALUES (...) + ON DUPLICATE KEY UPDATE col=expr [, col=expr]; + */ + TABLE::check_assignability_explicit_fields(update_fields, + update_values); + select_lex->no_wrap_view_item= FALSE; } @@ -3883,6 +3904,16 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) check_insert_fields(thd, table_list, *fields, values, !insert_into_view, 1, &map)); + if (!res) + { + /* + Check that all colN=exprN pairs are compatible for assignment, e.g.: + INSERT INTO t1 (col1, col2) VALUES (expr1, expr2); + INSERT INTO t1 SET col1=expr1, col2=expr2; + */ + res= table_list->table->check_assignability_opt_fields(*fields, values); + } + if (!res && fields->elements) { Abort_on_warning_instant_set aws(thd, @@ -3936,7 +3967,14 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) } res= res || setup_fields(thd, Ref_ptr_array(), *info.update_values, - MARK_COLUMNS_READ, 0, NULL, 0); + MARK_COLUMNS_READ, 0, NULL, 0) || + /* + Check that all col=expr pairs are compatible for assignment in + INSERT INTO t1 SELECT ... FROM t2 + ON DUPLICATE KEY UPDATE col=expr [, col=expr] + */ + TABLE::check_assignability_explicit_fields(*info.update_fields, + *info.update_values); if (!res) { /* diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 929335f973e..e99aefcdf1f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11088,6 +11088,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, if (!(*ptr)->vcol_info) { bitmap_set_bit(from->read_set, def->field->field_index); + if ((*ptr)->check_assignability_from(def->field)) + goto err; (copy_end++)->set(*ptr,def->field,0); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4da967bb115..d5b5ac5eef4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -523,6 +523,9 @@ int mysql_update(THD *thd, DBUG_RETURN(1); /* purecov: inspected */ } + if (table_list->table->check_assignability_explicit_fields(fields, values)) + DBUG_RETURN(true); + if (check_unique_table(thd, table_list)) DBUG_RETURN(TRUE); @@ -2082,7 +2085,8 @@ int multi_update::prepare(List ¬_used_values, */ int error= setup_fields(thd, Ref_ptr_array(), - *values, MARK_COLUMNS_READ, 0, NULL, 0); + *values, MARK_COLUMNS_READ, 0, NULL, 0) || + TABLE::check_assignability_explicit_fields(*fields, *values); ti.rewind(); while ((table_ref= ti++)) diff --git a/sql/table.cc b/sql/table.cc index f6f293290cd..98b487ba991 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9242,6 +9242,60 @@ bool TABLE::validate_default_values_of_unset_fields(THD *thd) const } +/* + Check assignment compatibility of a value list against an explicitly + specified field list, e.g. + INSERT INTO t1 (a,b) VALUES (1,2); +*/ +bool TABLE::check_assignability_explicit_fields(List fields, + List values) +{ + DBUG_ENTER("TABLE::check_assignability_explicit_fields"); + DBUG_ASSERT(fields.elements == values.elements); + + List_iterator fi(fields); + List_iterator vi(values); + Item *f, *value; + while ((f= fi++) && (value= vi++)) + { + Item_field *item_field= f->field_for_view_update(); + if (!item_field) + { + /* + A non-updatable field of a view found. + This scenario is caught later and an error is raised. + We could eventually move error reporting here. For now just continue. + */ + continue; + } + if (value->check_assignability_to(item_field->field)) + DBUG_RETURN(true); + } + DBUG_RETURN(false); +} + + +/* + Check assignment compatibility for a value list against + all visible fields of the table, e.g. + INSERT INTO t1 VALUES (1,2); +*/ +bool TABLE::check_assignability_all_visible_fields(List &values) const +{ + DBUG_ENTER("TABLE::check_assignability_all_visible_fields"); + DBUG_ASSERT(s->visible_fields == values.elements); + + List_iterator vi(values); + for (uint i= 0; i < s->fields; i++) + { + if (!field[i]->invisible && + (vi++)->check_assignability_to(field[i])) + DBUG_RETURN(true); + } + DBUG_RETURN(false); +} + + bool TABLE::insert_all_rows_into_tmp_table(THD *thd, TABLE *tmp_table, TMP_TABLE_PARAM *tmp_table_param, diff --git a/sql/table.h b/sql/table.h index 1c09f463d9e..ddb0b183cf2 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1686,6 +1686,27 @@ public: Field **field_to_fill(); bool validate_default_values_of_unset_fields(THD *thd) const; + // Check if the value list is assignable to the explicit field list + static bool check_assignability_explicit_fields(List fields, + List values); + // Check if the value list is assignable to all visible fields + bool check_assignability_all_visible_fields(List &values) const; + /* + Check if the value list is assignable to: + - The explicit field list if fields.elements > 0, e.g. + INSERT INTO t1 (a,b) VALUES (1,2); + - All visible fields, if fields.elements==0, e.g. + INSERT INTO t1 VALUES (1,2); + */ + bool check_assignability_opt_fields(List fields, + List values) const + { + DBUG_ASSERT(values.elements); + return fields.elements ? + check_assignability_explicit_fields(fields, values) : + check_assignability_all_visible_fields(values); + } + bool insert_all_rows_into_tmp_table(THD *thd, TABLE *tmp_table, TMP_TABLE_PARAM *tmp_table_param,