diff options
-rw-r--r-- | mysql-test/r/gis.result | 60 | ||||
-rw-r--r-- | mysql-test/r/metadata.result | 4 | ||||
-rw-r--r-- | mysql-test/r/union.result | 32 | ||||
-rw-r--r-- | mysql-test/suite/innodb_gis/r/create_spatial_index.result | 2 | ||||
-rw-r--r-- | mysql-test/t/union.test | 24 | ||||
-rw-r--r-- | sql/item.h | 15 |
6 files changed, 103 insertions, 34 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 43de7d2e7d6..fdc0e1e6368 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -4030,65 +4030,65 @@ DROP TABLE t1; # CREATE TABLE t1 (a GEOMETRY); SELECT POINT(1,1) + 1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '+' +ERROR HY000: Illegal parameter data types geometry and int for operation '+' SELECT POINT(1,1) - 1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '-' +ERROR HY000: Illegal parameter data types geometry and int for operation '-' SELECT POINT(1,1) * 1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '*' +ERROR HY000: Illegal parameter data types geometry and int for operation '*' SELECT POINT(1,1) / 1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '/' +ERROR HY000: Illegal parameter data types geometry and int for operation '/' SELECT POINT(1,1) MOD 1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '%' +ERROR HY000: Illegal parameter data types geometry and int for operation '%' SELECT 1 + POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '+' +ERROR HY000: Illegal parameter data types int and geometry for operation '+' SELECT 1 - POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '-' +ERROR HY000: Illegal parameter data types int and geometry for operation '-' SELECT 1 * POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '*' +ERROR HY000: Illegal parameter data types int and geometry for operation '*' SELECT 1 / POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '/' +ERROR HY000: Illegal parameter data types int and geometry for operation '/' SELECT 1 MOD POINT(1,1); -ERROR HY000: Illegal parameter data types bigint and geometry for operation '%' +ERROR HY000: Illegal parameter data types int and geometry for operation '%' SELECT a + 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '+' +ERROR HY000: Illegal parameter data types geometry and int for operation '+' SELECT a - 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '-' +ERROR HY000: Illegal parameter data types geometry and int for operation '-' SELECT a * 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '*' +ERROR HY000: Illegal parameter data types geometry and int for operation '*' SELECT a / 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '/' +ERROR HY000: Illegal parameter data types geometry and int for operation '/' SELECT a MOD 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '%' +ERROR HY000: Illegal parameter data types geometry and int for operation '%' SELECT 1 + a FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '+' +ERROR HY000: Illegal parameter data types int and geometry for operation '+' SELECT 1 - a FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '-' +ERROR HY000: Illegal parameter data types int and geometry for operation '-' SELECT 1 * a FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '*' +ERROR HY000: Illegal parameter data types int and geometry for operation '*' SELECT 1 / a FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '/' +ERROR HY000: Illegal parameter data types int and geometry for operation '/' SELECT 1 MOD a FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '%' +ERROR HY000: Illegal parameter data types int and geometry for operation '%' SELECT COALESCE(a) + 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '+' +ERROR HY000: Illegal parameter data types geometry and int for operation '+' SELECT COALESCE(a) - 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '-' +ERROR HY000: Illegal parameter data types geometry and int for operation '-' SELECT COALESCE(a) * 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '*' +ERROR HY000: Illegal parameter data types geometry and int for operation '*' SELECT COALESCE(a) / 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '/' +ERROR HY000: Illegal parameter data types geometry and int for operation '/' SELECT COALESCE(a) MOD 1 FROM t1; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '%' +ERROR HY000: Illegal parameter data types geometry and int for operation '%' SELECT 1 + COALESCE(a) FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '+' +ERROR HY000: Illegal parameter data types int and geometry for operation '+' SELECT 1 - COALESCE(a) FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '-' +ERROR HY000: Illegal parameter data types int and geometry for operation '-' SELECT 1 * COALESCE(a) FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '*' +ERROR HY000: Illegal parameter data types int and geometry for operation '*' SELECT 1 / COALESCE(a) FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '/' +ERROR HY000: Illegal parameter data types int and geometry for operation '/' SELECT 1 MOD COALESCE(a) FROM t1; -ERROR HY000: Illegal parameter data types bigint and geometry for operation '%' +ERROR HY000: Illegal parameter data types int and geometry for operation '%' DROP TABLE t1; # # MDEV-12514 Split Item_temporal_func::fix_length_and_dec() diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 3db3bcd450f..d31b2c5efe0 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -76,12 +76,12 @@ def aaa @arg00 @arg00 8 20 1 Y 32768 0 63 1 select 1 union select 1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def 1 1 8 20 1 N 32769 0 63 +def 1 1 3 11 1 N 32769 0 63 1 1 select * from (select 1 union select 1) aaa; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def aaa 1 1 8 20 1 N 32769 0 63 +def aaa 1 1 3 11 1 N 32769 0 63 1 1 drop table t1; diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 807a194e773..9949defebf7 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -852,7 +852,7 @@ select * from t1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `1` bigint(20) NOT NULL DEFAULT 0 + `1` int(11) NOT NULL DEFAULT 0 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 select _latin1"test" union select _latin2"testt" ; @@ -2178,3 +2178,33 @@ WHERE t1_2.b NOT IN ( SELECT 4 UNION ALL SELECT 5 ); a b a b 1 1 1 1 DROP TABLE t1; +# +# Start of 10.3 tests +# +# +# MDEV-12619 UNION creates excessive integer column types for integer literals +# +CREATE TABLE t1 AS SELECT 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `1` int(1) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `1` int(11) NOT NULL DEFAULT 0 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 AS SELECT * FROM (SELECT 1 UNION SELECT 1) AS t0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `1` int(11) NOT NULL DEFAULT 0 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# End of 10.3 tests +# diff --git a/mysql-test/suite/innodb_gis/r/create_spatial_index.result b/mysql-test/suite/innodb_gis/r/create_spatial_index.result index 572e3ac0d14..9629fa03fef 100644 --- a/mysql-test/suite/innodb_gis/r/create_spatial_index.result +++ b/mysql-test/suite/innodb_gis/r/create_spatial_index.result @@ -1238,7 +1238,7 @@ Table Op Msg_type Msg_text test.tab check status OK DROP TABLE tab; CREATE TABLE tab(c1 POINT NOT NULL,CONSTRAINT tab_const check(c1 > 0) ) ENGINE=InnoDB; -ERROR HY000: Illegal parameter data types geometry and bigint for operation '>' +ERROR HY000: Illegal parameter data types geometry and int for operation '>' CREATE TABLE tab(c1 POINT NOT NULL,CONSTRAINT tab_const check(CAST(c1 AS BINARY) > 0) ) ENGINE=InnoDB; CREATE SPATIAL INDEX idx1 ON tab(c1) ; SHOW CREATE TABLE tab; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index fa07dc22dbb..04ab71588be 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1523,3 +1523,27 @@ SELECT * FROM t1 t1_1 LEFT JOIN t1 t1_2 ON ( t1_2.b = t1_1.a ) WHERE t1_2.b NOT IN ( SELECT 4 UNION ALL SELECT 5 ); DROP TABLE t1; + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-12619 UNION creates excessive integer column types for integer literals +--echo # + +CREATE TABLE t1 AS SELECT 1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 AS SELECT * FROM (SELECT 1 UNION SELECT 1) AS t0; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/sql/item.h b/sql/item.h index 7200b69b7b5..886292d394c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3207,6 +3207,17 @@ public: enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } + const Type_handler *type_handler() const + { + // The same condition is repeated in Item::create_tmp_field() + if (max_length > MY_INT32_NUM_DECIMAL_DIGITS - 2) + return &type_handler_longlong; + return &type_handler_long; + } + Field *create_tmp_field(bool group, TABLE *table) + { return tmp_table_field_from_field_type(table); } + Field *create_field_for_create_select(TABLE *table) + { return tmp_table_field_from_field_type(table); } longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; } my_decimal *val_decimal(my_decimal *); @@ -3717,6 +3728,10 @@ public: unsigned_flag=1; } enum_field_types field_type() const { return int_field_type; } + const Type_handler *type_handler() const + { + return Type_handler::get_handler_by_field_type(int_field_type); + } }; |