Commit ae5b31fe authored by Alexander Barkov's avatar Alexander Barkov

A cleanup for MDEV-12619 UNION creates excessive integer column types for integer literals

Fixing result set metadata for Item_int to match type_handler(),
i.e. MYSQL_TYPE_LONG for small numbers and MYSQL_TYPE_LONGLONG for big numbers.
parent 01b308c3
drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def 1 8 1 1 N 32897 0 63
def 1 3 1 1 N 32897 0 63
def 1.0 246 4 3 N 32897 1 63
def -1 8 2 2 N 32897 0 63
def -1 3 2 2 N 32897 0 63
def hello 253 5 5 N 1 39 8
def NULL 6 0 0 Y 32896 0 63
1 1.0 -1 hello NULL
1 1.0 -1 hello NULL
SELECT
1 AS c1,
11 AS c2,
111 AS c3,
1111 AS c4,
11111 AS c5,
111111 AS c6,
1111111 AS c7,
11111111 AS c8,
111111111 AS c9,
1111111111 AS c10,
11111111111 AS c11,
111111111111 AS c12,
1111111111111 AS c13,
11111111111111 AS c14,
111111111111111 AS c15,
1111111111111111 AS c16,
11111111111111111 AS c17,
111111111111111111 AS c18,
1111111111111111111 AS c19,
11111111111111111111 AS c20,
111111111111111111111 AS c21;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c1 3 1 1 N 32897 0 63
def c2 3 2 2 N 32897 0 63
def c3 3 3 3 N 32897 0 63
def c4 3 4 4 N 32897 0 63
def c5 3 5 5 N 32897 0 63
def c6 3 6 6 N 32897 0 63
def c7 3 7 7 N 32897 0 63
def c8 3 8 8 N 32897 0 63
def c9 3 9 9 N 32897 0 63
def c10 8 10 10 N 32897 0 63
def c11 8 11 11 N 32897 0 63
def c12 8 12 12 N 32897 0 63
def c13 8 13 13 N 32897 0 63
def c14 8 14 14 N 32897 0 63
def c15 8 15 15 N 32897 0 63
def c16 8 16 16 N 32897 0 63
def c17 8 17 17 N 32897 0 63
def c18 8 18 18 N 32897 0 63
def c19 8 19 19 N 32897 0 63
def c20 8 20 20 N 32929 0 63
def c21 246 22 21 N 32897 0 63
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111 111111111111 1111111111111 11111111111111 111111111111111 1111111111111111 11111111111111111 111111111111111111 1111111111111111111 11111111111111111111 111111111111111111111
SELECT
-1 AS c1,
-11 AS c2,
-111 AS c3,
-1111 AS c4,
-11111 AS c5,
-111111 AS c6,
-1111111 AS c7,
-11111111 AS c8,
-111111111 AS c9,
-1111111111 AS c10,
-11111111111 AS c11,
-111111111111 AS c12,
-1111111111111 AS c13,
-11111111111111 AS c14,
-111111111111111 AS c15,
-1111111111111111 AS c16,
-11111111111111111 AS c17,
-111111111111111111 AS c18,
-1111111111111111111 AS c19,
-11111111111111111111 AS c20,
-111111111111111111111 AS c21;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c1 3 2 2 N 32897 0 63
def c2 3 3 3 N 32897 0 63
def c3 3 4 4 N 32897 0 63
def c4 3 5 5 N 32897 0 63
def c5 3 6 6 N 32897 0 63
def c6 3 7 7 N 32897 0 63
def c7 3 8 8 N 32897 0 63
def c8 3 9 9 N 32897 0 63
def c9 8 10 10 N 32897 0 63
def c10 8 11 11 N 32897 0 63
def c11 8 12 12 N 32897 0 63
def c12 8 13 13 N 32897 0 63
def c13 8 14 14 N 32897 0 63
def c14 8 15 15 N 32897 0 63
def c15 8 16 16 N 32897 0 63
def c16 8 17 17 N 32897 0 63
def c17 8 18 18 N 32897 0 63
def c18 8 19 19 N 32897 0 63
def c19 8 20 20 N 32897 0 63
def c20 246 21 21 N 32897 0 63
def c21 246 22 22 N 32897 0 63
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21
-1 -11 -111 -1111 -11111 -111111 -1111111 -11111111 -111111111 -1111111111 -11111111111 -111111111111 -1111111111111 -11111111111111 -111111111111111 -1111111111111111 -11111111111111111 -111111111111111111 -1111111111111111111 -11111111111111111111 -111111111111111111111
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10));
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
......
......@@ -14,6 +14,51 @@ drop table if exists t1,t2;
#
select 1, 1.0, -1, "hello", NULL;
SELECT
1 AS c1,
11 AS c2,
111 AS c3,
1111 AS c4,
11111 AS c5,
111111 AS c6,
1111111 AS c7,
11111111 AS c8,
111111111 AS c9,
1111111111 AS c10,
11111111111 AS c11,
111111111111 AS c12,
1111111111111 AS c13,
11111111111111 AS c14,
111111111111111 AS c15,
1111111111111111 AS c16,
11111111111111111 AS c17,
111111111111111111 AS c18,
1111111111111111111 AS c19,
11111111111111111111 AS c20,
111111111111111111111 AS c21;
SELECT
-1 AS c1,
-11 AS c2,
-111 AS c3,
-1111 AS c4,
-11111 AS c5,
-111111 AS c6,
-1111111 AS c7,
-11111111 AS c8,
-111111111 AS c9,
-1111111111 AS c10,
-11111111111 AS c11,
-111111111111 AS c12,
-1111111111111 AS c13,
-11111111111111 AS c14,
-111111111111111 AS c15,
-1111111111111111 AS c16,
-11111111111111111 AS c17,
-111111111111111111 AS c18,
-1111111111111111111 AS c19,
-11111111111111111111 AS c20,
-111111111111111111111 AS c21;
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10));
select * from t1;
......
......@@ -3151,7 +3151,10 @@ class Item_int :public Item_num
Item_int(THD *thd, const char *str_arg, uint length=64);
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; }
enum_field_types field_type() const
{
return Item_int::type_handler()->field_type();
}
const Type_handler *type_handler() const
{
// The same condition is repeated in Item::create_tmp_field()
......
......@@ -2985,7 +2985,7 @@ sp_head::show_routine_code(THD *thd)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, tmp);
}
protocol->prepare_for_resend();
protocol->store((longlong)ip);
protocol->store_long(ip);
buffer.set("", 0, system_charset_info);
i->print(&buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment