mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-12619 UNION creates excessive integer column types for integer literals
This commit is contained in:
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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;
|
||||
|
@ -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 #
|
||||
|
15
sql/item.h
15
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user