diff options
author | bar@mysql.com <> | 2005-01-18 17:41:06 +0400 |
---|---|---|
committer | bar@mysql.com <> | 2005-01-18 17:41:06 +0400 |
commit | 8cfe729678d82a62962c889ac2b2a100a96b7e1d (patch) | |
tree | 1fc336cf33000766e9f51485a6c2eaf5ea519a32 | |
parent | 9fa2bb096c632a93737b7c2c11116cfa52c6f6ca (diff) | |
download | mariadb-git-8cfe729678d82a62962c889ac2b2a100a96b7e1d.tar.gz |
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.
-rw-r--r-- | mysql-test/r/analyse.result | 36 | ||||
-rw-r--r-- | mysql-test/r/case.result | 12 | ||||
-rw-r--r-- | mysql-test/r/metadata.result | 6 | ||||
-rw-r--r-- | mysql-test/r/ps_1general.result | 12 | ||||
-rw-r--r-- | mysql-test/r/ps_2myisam.result | 6 | ||||
-rw-r--r-- | mysql-test/r/ps_3innodb.result | 6 | ||||
-rw-r--r-- | mysql-test/r/ps_4heap.result | 6 | ||||
-rw-r--r-- | mysql-test/r/ps_5merge.result | 12 | ||||
-rw-r--r-- | mysql-test/r/ps_6bdb.result | 6 | ||||
-rw-r--r-- | mysql-test/r/ps_7ndb.result | 6 | ||||
-rw-r--r-- | mysql-test/r/union.result | 2 | ||||
-rw-r--r-- | sql/item.cc | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 3 |
13 files changed, 59 insertions, 56 deletions
diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index 8013bc516bb..09c606b5a04 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -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 diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 1aa838140fd..541560afd36 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -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; diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 3c7cf60db7a..54b3f1e0466 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -1,9 +1,9 @@ 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 diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index ee3eca850f4..2356989eaf6 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -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 diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 3412f2fe00c..a27b8b996cd 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -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 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 99f45117c36..eb17d25e80c 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -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 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 1ec5c280523..b53ad7e2409 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1146,15 +1146,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 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 1f36d246da0..13227eb533b 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1188,15 +1188,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 @@ -4198,15 +4198,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 diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 1e7ef526d37..8630ba2db9b 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -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 3 diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 13b6894e9b5..43ff9607c55 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -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 diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 49a2907f571..1eb978b1bd6 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -554,7 +554,7 @@ aa show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` char(20) NOT NULL default '' + `a` binary(20) NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT 12 as a UNION select 12.2 as a; diff --git a/sql/item.cc b/sql/item.cc index 92a15694e89..640cc17411f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -45,7 +45,7 @@ Item::Item(): { marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; - collation.set(default_charset(), DERIVATION_COERCIBLE); + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); name= 0; decimals= 0; max_length= 0; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3d79c16b5d0..6ec98f2dcd4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1094,6 +1094,9 @@ Item_func_nullif::fix_length_and_dec() max_length=args[0]->max_length; decimals=args[0]->decimals; agg_result_type(&cached_result_type, args, 2); + if (cached_result_type == STRING_RESULT && + agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV)) + return; } } |