Commit cd89ed9a authored by unknown's avatar unknown
Browse files

1. Item now uses my_charset_bin by default,

not default_charset_into. It fixes the
problem that in some cases numbers where
treated as CHAR(N), not as BINARY(N), e.g.
wrong 'charsetnr' when sent to the client side.
2. IFNULL didn't aggregate argument charsets
and collations, so IFNULL(1,'a') produced
a CHAR(N). Now produces a BINARY(N).
3. SELECT PROCEDURE ANALIZE now returns
BINARY columns, which is much better than it worked
previously: CHAR with the default character set.
But in the future it's worth to fix the fields
'Field_name' and 'Optimal_fieldtype' to use UTF8,
and 'Min_value' and 'Max_value' to inherit their charsets
from the original items. But it is not important,
and BINARY(N) is OK for now.
4. Tests were fixed accordingly. No new tests were
made, as the old onces cover everything.


mysql-test/r/analyse.result:
  SELECT PROCEDURE ANALIZE now returns
  BINARY columns, which is much better than it worked
  previously: CHAR with the default character set.
  But in the future it's worth to fix the fields
  'Field_name' and 'Optimal_fieldtype' to use UTF8,
  and 'Min_value' and 'Max_value' to inherit their charsets
  from the original items. But it is not important,
  and BINARY(N) is OK for now.
mysql-test/r/case.result:
  Test fix according to the changes
mysql-test/r/metadata.result:
  Test fix according to the changes
mysql-test/r/ps_1general.result:
  Test fix according to the changes
mysql-test/r/ps_2myisam.result:
  Test fix according to the changes
mysql-test/r/ps_3innodb.result:
  Test fix according to the changes
mysql-test/r/ps_4heap.result:
  Test fix according to the changes
mysql-test/r/ps_5merge.result:
  Test fix according to the changes
mysql-test/r/ps_6bdb.result:
  Test fix according to the changes
mysql-test/r/ps_7ndb.result:
  Test fix according to the changes
mysql-test/r/union.result:
  Test fix according to the changes
sql/item.cc:
  Item is now BINARY by default
sql/item_cmpfunc.cc:
  IFNULL now collects arguments collations/charsets
  like other functions do.
parent 1457163c
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -36,16 +36,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `Field_name` char(255) NOT NULL default '',
  `Min_value` char(255) default NULL,
  `Max_value` char(255) default NULL,
  `Field_name` binary(255) NOT NULL default '',
  `Min_value` binary(255) default NULL,
  `Max_value` binary(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` char(255) NOT NULL default '',
  `Std` char(255) default NULL,
  `Optimal_fieldtype` char(64) NOT NULL default ''
  `Avg_value_or_avg_length` binary(255) NOT NULL default '',
  `Std` binary(255) default NULL,
  `Optimal_fieldtype` binary(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
@@ -55,16 +55,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `Field_name` char(255) NOT NULL default '',
  `Min_value` char(255) default NULL,
  `Max_value` char(255) default NULL,
  `Field_name` binary(255) NOT NULL default '',
  `Min_value` binary(255) default NULL,
  `Max_value` binary(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` char(255) NOT NULL default '',
  `Std` char(255) default NULL,
  `Optimal_fieldtype` char(64) NOT NULL default ''
  `Avg_value_or_avg_length` binary(255) NOT NULL default '',
  `Std` binary(255) default NULL,
  `Optimal_fieldtype` binary(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
@@ -78,16 +78,16 @@ create table t2 select * from t1 where 0=1 procedure analyse();
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `Field_name` char(255) NOT NULL default '',
  `Min_value` char(255) default NULL,
  `Max_value` char(255) default NULL,
  `Field_name` binary(255) NOT NULL default '',
  `Min_value` binary(255) default NULL,
  `Max_value` binary(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` char(255) NOT NULL default '',
  `Std` char(255) default NULL,
  `Optimal_fieldtype` char(64) NOT NULL default ''
  `Avg_value_or_avg_length` binary(255) NOT NULL default '',
  `Std` binary(255) default NULL,
  `Optimal_fieldtype` binary(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
+6 −6
Original line number Diff line number Diff line
@@ -98,10 +98,10 @@ Table Create Table
t1	CREATE TABLE `t1` (
  `c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
  `c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
  `c3` char(1) NOT NULL default '',
  `c4` char(1) NOT NULL default '',
  `c5` char(3) NOT NULL default '',
  `c6` char(3) NOT NULL default '',
  `c3` binary(1) NOT NULL default '',
  `c4` binary(1) NOT NULL default '',
  `c5` binary(3) NOT NULL default '',
  `c6` binary(3) NOT NULL default '',
  `c7` double(3,1) NOT NULL default '0.0',
  `c8` double(3,1) NOT NULL default '0.0',
  `c9` double(3,1) default NULL
@@ -149,8 +149,8 @@ t1 CREATE TABLE `t1` (
  `COALESCE(1.0)` double(3,1) NOT NULL default '0.0',
  `COALESCE('a')` char(1) NOT NULL default '',
  `COALESCE(1,1.0)` double(3,1) NOT NULL default '0.0',
  `COALESCE(1,'1')` char(1) NOT NULL default '',
  `COALESCE(1.1,'1')` char(3) NOT NULL default '',
  `COALESCE(1,'1')` binary(1) NOT NULL default '',
  `COALESCE(1.1,'1')` binary(3) NOT NULL default '',
  `COALESCE('a' COLLATE latin1_bin,'b')` char(1) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+3 −3
Original line number Diff line number Diff line
drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL;
Catalog	Database	Table	Table_alias	Column	Column_alias	Name	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def					1	8	1	1	N	32769	0	8
def					1.0	5	3	3	N	32769	1	8
def					-1	8	2	2	N	32769	0	8
def					1	8	1	1	N	32897	0	63
def					1.0	5	3	3	N	32897	1	63
def					-1	8	2	2	N	32897	0	63
def					hello	254	5	5	N	1	31	8
def					NULL	6	0	0	Y	32896	0	63
1	1.0	-1	hello	NULL
+6 −6
Original line number Diff line number Diff line
@@ -468,15 +468,15 @@ ERROR HY000: This command is not supported in the prepared statement protocol ye
prepare stmt1 from ' explain select a from t1 order by b ';
execute stmt1;
Catalog	Database	Table	Table_alias	Column	Column_alias	Name	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def					id	8	3	1	N	32801	0	8
def					id	8	3	1	N	32929	0	63
def					select_type	253	19	6	N	1	31	8
def					table	253	64	2	N	1	31	8
def					type	253	10	3	N	1	31	8
def					possible_keys	253	4096	0	Y	0	31	8
def					key	253	64	0	Y	0	31	8
def					key_len	8	3	0	Y	32800	0	8
def					key_len	8	3	0	Y	32928	0	63
def					ref	253	1024	0	Y	0	31	8
def					rows	8	10	1	N	32801	0	8
def					rows	8	10	1	N	32929	0	63
def					Extra	253	255	14	N	1	31	8
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
@@ -484,15 +484,15 @@ SET @arg00=1 ;
prepare stmt1 from ' explain select a from t1 where a > ? order by b ';
execute stmt1 using @arg00;
Catalog	Database	Table	Table_alias	Column	Column_alias	Name	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def					id	8	3	1	N	32801	0	8
def					id	8	3	1	N	32929	0	63
def					select_type	253	19	6	N	1	31	8
def					table	253	64	2	N	1	31	8
def					type	253	10	5	N	1	31	8
def					possible_keys	253	4096	7	Y	0	31	8
def					key	253	64	7	Y	0	31	8
def					key_len	8	3	1	Y	32800	0	8
def					key_len	8	3	1	Y	32928	0	63
def					ref	253	1024	0	Y	0	31	8
def					rows	8	10	1	N	32801	0	8
def					rows	8	10	1	N	32929	0	63
def					Extra	253	255	27	N	1	31	8
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	Using where; Using filesort
+3 −3
Original line number Diff line number Diff line
@@ -1145,15 +1145,15 @@ test_sequence
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
Catalog	Database	Table	Table_alias	Column	Column_alias	Name	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def					id	8	3	1	N	32801	0	8
def					id	8	3	1	N	32929	0	63
def					select_type	253	19	6	N	1	31	8
def					table	253	64	2	N	1	31	8
def					type	253	10	3	N	1	31	8
def					possible_keys	253	4096	0	Y	0	31	8
def					key	253	64	0	Y	0	31	8
def					key_len	8	3	0	Y	32800	0	8
def					key_len	8	3	0	Y	32928	0	63
def					ref	253	1024	0	Y	0	31	8
def					rows	8	10	1	N	32801	0	8
def					rows	8	10	1	N	32929	0	63
def					Extra	253	255	0	N	1	31	8
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
Loading