mirror of
https://github.com/MariaDB/server.git
synced 2025-01-24 07:44:22 +01:00
9ca50fe144
Fixed compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length myisam/myisampack.c: Indentation cleanup mysql-test/r/analyse.result: Update results for new varchar handling mysql-test/r/case.result: Update results for new varchar handling mysql-test/r/cast.result: Update results for new varchar handling mysql-test/r/create.result: Update results for new varchar handling mysql-test/r/ctype_mb.result: Update results for new varchar handling mysql-test/r/ctype_ucs.result: Update results for new varchar handling mysql-test/r/ctype_utf8.result: Update results for new varchar handling mysql-test/r/func_group.result: Update results for new varchar handling mysql-test/r/func_str.result: Update results for new varchar handling mysql-test/r/func_system.result: Update results for new varchar handling mysql-test/r/heap.result: Update results for new varchar handling mysql-test/r/heap_hash.result: Update results for new varchar handling mysql-test/r/information_schema.result: Update results for new varchar handling mysql-test/r/metadata.result: Update results for new varchar handling mysql-test/r/null.result: Update results for new varchar handling mysql-test/r/ps_2myisam.result: Update results for new varchar handling mysql-test/r/ps_3innodb.result: Update results for new varchar handling mysql-test/r/ps_4heap.result: Update results for new varchar handling mysql-test/r/ps_5merge.result: Update results for new varchar handling mysql-test/r/ps_6bdb.result: Update results for new varchar handling mysql-test/r/subselect.result: Update results for new varchar handling mysql-test/r/type_ranges.result: Update results for new varchar handling mysql-test/r/union.result: Update results for new varchar handling mysql-test/t/heap.test: Update results for new varchar handling mysql-test/t/type_ranges.test: Added extra test to test generated type for string functions sql/field.cc: Update results for new varchar handling sql/field.h: Update results for new varchar handling We have to use orig_table instead of table as 'table' may point to a new field in the created table sql/field_conv.cc: Update results for new varchar handling sql/ha_heap.cc: Indentation fixes sql/ha_innodb.cc: Update results for new varchar handling sql/item.cc: Update results for new varchar handling Remove compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item.h: Update results for new varchar handling sql/item_func.cc: Update results for new varchar handling String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item_func.h: ANALYZE now return VARCHAR columns sql/procedure.h: Update results for new varchar handling sql/sql_acl.cc: After merge fixes sql/sql_select.cc: Update results for new varchar handling String results in temporary tables are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/sql_show.cc: After merge fixes sql/sql_table.cc: After merge fixes strings/ctype-tis620.c: After merge fixes tests/client_test.c: Fixed results, as in MySQL 5.0 strings in CREATE ... SELECT are creates VARCHAR columns
98 lines
5.2 KiB
Text
98 lines
5.2 KiB
Text
drop table if exists t1,t2;
|
|
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
|
|
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
|
|
select count(*) from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL
|
|
select * from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
select * from t1 procedure analyse(2);
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
create table t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
drop table t1,t2;
|
|
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
|
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
|
create table t1 (a int not null);
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varchar(255) NOT NULL default '',
|
|
`Min_value` varchar(255) default NULL,
|
|
`Max_value` varchar(255) default NULL,
|
|
`Min_length` bigint(11) NOT NULL default '0',
|
|
`Max_length` bigint(11) NOT NULL default '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL default '0',
|
|
`Nulls` bigint(11) NOT NULL default '0',
|
|
`Avg_value_or_avg_length` varchar(255) NOT NULL default '',
|
|
`Std` varchar(255) default NULL,
|
|
`Optimal_fieldtype` varchar(64) NOT NULL default ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t1 where 0=1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t1 values(1);
|
|
drop table t2;
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varchar(255) NOT NULL default '',
|
|
`Min_value` varchar(255) default NULL,
|
|
`Max_value` varchar(255) default NULL,
|
|
`Min_length` bigint(11) NOT NULL default '0',
|
|
`Max_length` bigint(11) NOT NULL default '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL default '0',
|
|
`Nulls` bigint(11) NOT NULL default '0',
|
|
`Avg_value_or_avg_length` varchar(255) NOT NULL default '',
|
|
`Std` varchar(255) default NULL,
|
|
`Optimal_fieldtype` varchar(64) NOT NULL default ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.a 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
|
|
insert into t1 values(2);
|
|
drop table t2;
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varchar(255) NOT NULL default '',
|
|
`Min_value` varchar(255) default NULL,
|
|
`Max_value` varchar(255) default NULL,
|
|
`Min_length` bigint(11) NOT NULL default '0',
|
|
`Max_length` bigint(11) NOT NULL default '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL default '0',
|
|
`Nulls` bigint(11) NOT NULL default '0',
|
|
`Avg_value_or_avg_length` varchar(255) NOT NULL default '',
|
|
`Std` varchar(255) default NULL,
|
|
`Optimal_fieldtype` varchar(64) NOT NULL default ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.a 1 2 1 1 0 0 1.5000 0.5000 ENUM('1','2') NOT NULL
|
|
drop table t1,t2;
|