List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:March 4 2009 7:00am
Subject:bzr commit into mysql-6.0 branch (bar:2701) WL#2649
View as plain text  
#At file:///home/bar/mysql-bzr/mysql-6.0.w2649/

 2701 Alexander Barkov	2009-03-04
      WL#2649 Number-to-string conversions
added:
  mysql-test/include/ctype_numconv.inc
  mysql-test/r/ctype_binary.result
  mysql-test/t/ctype_binary.test
modified:
  mysql-test/r/bigint.result
  mysql-test/r/case.result
  mysql-test/r/ctype_latin1.result
  mysql-test/r/ctype_ucs.result
  mysql-test/r/explain.result
  mysql-test/r/metadata.result
  mysql-test/r/ps_1general.result
  mysql-test/r/ps_2myisam.result
  mysql-test/r/ps_3innodb.result
  mysql-test/r/ps_4heap.result
  mysql-test/r/ps_5merge.result
  mysql-test/r/show_check.result
  mysql-test/r/union.result
  mysql-test/suite/ndb/r/ps_7ndb.result
  mysql-test/t/ctype_latin1.test
  mysql-test/t/ctype_ucs.test
  sql/item.cc
  sql/item.h
  sql/item_cmpfunc.cc
  sql/item_cmpfunc.h
  sql/item_func.cc
  sql/item_func.h
  sql/item_geofunc.cc
  sql/item_geofunc.h
  sql/item_strfunc.cc
  sql/item_strfunc.h
  sql/item_timefunc.cc
  sql/item_timefunc.h
  sql/mysql_priv.h
  sql/sql_select.cc
  sql/time.cc

=== added file 'mysql-test/include/ctype_numconv.inc'
--- a/mysql-test/include/ctype_numconv.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_numconv.inc	2009-03-04 06:59:35 +0000
@@ -0,0 +1,834 @@
+#
+# Basic constants
+#
+select hex(concat(1));
+create table t1 as select concat(1) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1.1));
+create table t1 as select concat(1.1) as c1;
+show create table t1;
+drop table t1;
+
+
+#
+# Arithmetic operators
+#
+
+select hex(concat('a', 1+2)), charset(concat(1+2));
+create table t1 as select concat(1+2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1-2));
+create table t1 as select concat(1-2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1*2));
+create table t1 as select concat(1*2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1/2));
+create table t1 as select concat(1/2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1 div 2));
+create table t1 as select concat(1 div 2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1 % 2));
+create table t1 as select concat(1 % 2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(-1));
+create table t1 as select concat(-1) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(-(1+2)));
+create table t1 as select concat(-(1+2)) as c1;
+show create table t1;
+drop table t1;
+
+
+#
+# Bit functions
+#
+
+select hex(concat(1|2));
+create table t1 as select concat(1|2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(1&2));
+create table t1 as select concat(1&2) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(bit_count(12)));
+create table t1 as select concat(bit_count(12)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(2<<1));
+create table t1 as select concat(2<<1) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(2>>1));
+create table t1 as select concat(2>>1) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(~0));
+create table t1 as select concat(~0) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(3^2));
+create table t1 as select concat(3^2) as c1;
+show create table t1;
+drop table t1;
+
+
+
+#
+# Math functions
+#
+
+select hex(concat(abs(-2)));
+create table t1 as select concat(abs(-2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(exp(2)));
+create table t1 as select concat(exp(2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(log(2)));
+create table t1 as select concat(log(2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(log2(2)));
+create table t1 as select concat(log2(2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(log10(2)));
+create table t1 as select concat(log10(2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(sqrt(2)));
+create table t1 as select concat(sqrt(2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(pow(2,2)));
+create table t1 as select concat(pow(2,2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(acos(0.5)));
+create table t1 as select concat(acos(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(asin(0.5)));
+create table t1 as select concat(asin(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(atan(0.5)));
+create table t1 as select concat(atan(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(cos(0.5)));
+create table t1 as select concat(cos(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(sin(0.5)));
+create table t1 as select concat(sin(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(tan(0.5)));
+create table t1 as select concat(tan(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(degrees(0)));
+create table t1 as select concat(degrees(0)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(radians(0)));
+create table t1 as select concat(radians(0)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(ceiling(0.5)));
+create table t1 as select concat(ceiling(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(floor(0.5)));
+create table t1 as select concat(floor(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(round(0.5)));
+create table t1 as select concat(round(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(sign(0.5)));
+create table t1 as select concat(sign(0.5)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(least(1,2)));
+create table t1 as select concat(least(1,2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(greatest(1,2)));
+create table t1 as select concat(greatest(1,2)) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(rand()) as c1;
+show create table t1;
+drop table t1;
+
+
+#
+# String functions
+#
+
+select hex(concat(length('a')));
+create table t1 as select concat(length('a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(char_length('a')));
+create table t1 as select concat(char_length('a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(bit_length('a')));
+create table t1 as select concat(bit_length('a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(coercibility('a')));
+create table t1 as select concat(coercibility('a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(locate('a','a')));
+create table t1 as select concat(locate('a','a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(field('c','a','b','c')));
+create table t1 as select concat(field('c','a','b','c')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(ascii(61)));
+create table t1 as select concat(ascii(61)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(ord(61)));
+create table t1 as select concat(ord(61)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(find_in_set('b','a,b,c,d')));
+create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1;
+show create table t1;
+drop table t1;
+
+
+#
+# String hash functions
+#
+
+select md5('a'), hex(md5('a'));
+create table t1 as select md5('a') as c1;
+show create table t1;
+drop table t1;
+
+select old_password('a'), hex(old_password('a'));
+create table t1 as select old_password('a') as c1;
+show create table t1;
+drop table t1;
+
+select password('a'), hex(password('a'));
+create table t1 as select password('a') as c1;
+show create table t1;
+drop table t1;
+
+select sha('a'), hex(sha('a'));
+create table t1 as select sha('a') as c1;
+show create table t1;
+drop table t1;
+
+select sha1('a'), hex(sha1('a'));
+create table t1 as select sha1('a') as c1;
+show create table t1;
+drop table t1;
+
+select sha2('a',224), hex(sha2('a',224));
+create table t1 as select sha2('a',224) as c1;
+show create table t1;
+drop table t1;
+
+
+
+#
+# CAST
+#
+
+select hex(concat(cast('-1' as signed)));
+create table t1 as select concat(cast('-1' as signed)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(cast('1' as unsigned)));
+create table t1 as select concat(cast('1' as unsigned)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(cast(1/2 as decimal(5,5))));
+create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(cast('2001-01-02 03:04:05' as date));
+create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1;
+show create table t1;
+select * from t1;
+drop table t1;
+
+select hex(cast('2001-01-02 03:04:05' as time));
+create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1;
+show create table t1;
+select * from t1;
+drop table t1;
+
+select hex(cast('2001-01-02' as datetime));
+create table t1 as select concat(cast('2001-01-02' as datetime)) as c1;
+show create table t1;
+select * from t1;
+drop table t1;
+
+
+#
+# Miscelaneous functions
+#
+
+create table t1 as select concat(last_insert_id()) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(benchmark(0,0)));
+create table t1 as select concat(benchmark(0,0)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(sleep(0)));
+create table t1 as select concat(sleep(0)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(get_lock('a',0)));
+select hex(concat(release_lock('a')));
+create table t1 as select concat(get_lock('a',0)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(is_free_lock('xxxx')));
+create table t1 as select concat(is_free_lock('xxxx')) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(is_used_lock('a')) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(release_lock('a')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(crc32('')));
+create table t1 as select concat(crc32('')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(uncompressed_length('')));
+create table t1 as select concat(uncompressed_length('')) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(connection_id()) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(inet_aton('127.1.1.1')));
+create table t1 as select concat(inet_aton('127.1.1.1')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(inet_ntoa(2130772225)));
+create table t1 as select concat(inet_ntoa(2130772225)) as c1;
+select * from t1;
+show create table t1;
+drop table t1;
+
+select hex(concat(row_count()));
+create table t1 as select concat(row_count()) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(found_rows()));
+create table t1 as select concat(found_rows()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(uuid_short()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(uuid()) as c1;
+show create table t1;
+drop table t1;
+
+#
+# Make sure we can mix uuid() to a latin1 object
+# with DERIVATION_IMPLICIT (and higher):
+# (DERIVATION_COERCIBLE + MY_REPERTOIRE_ASCII allow to do so)
+#
+select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
+select charset(concat(uuid(), cast('a' as char character set latin1)));
+create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1;
+show create table t1;
+drop table t1;
+
+
+#
+# User and system variable functions
+#
+
+# User variables: INT
+select hex(concat(@a1:=1));
+create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+set @a2=1;
+select hex(concat(@a2));
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+# User variables: REAL
+select hex(concat(@a1:=sqrt(1)));
+create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+set @a2=sqrt(1);
+select hex(concat(@a2));
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+# User variables: DECIMAL
+select hex(concat(@a1:=1.1));
+create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+set @a2=1.1;
+select hex(concat(@a2));
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+
+select hex(concat(@@ft_max_word_len));
+create table t1 as select concat(@@ft_max_word_len) as c1;
+select hex(c1) from t1;
+show create table t1;
+drop table t1;
+
+
+
+#
+# Comparison functions
+#
+
+select hex(concat('a'='a' IS TRUE));
+create table t1 as select concat('a'='a' IS TRUE) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a'='a' IS NOT TRUE));
+create table t1 as select concat('a'='a' IS NOT TRUE) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(NOT 'a'='a'));
+create table t1 as select concat(NOT 'a'='a') as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' IS NULL));
+create table t1 as select concat('a' IS NULL) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' IS NOT NULL));
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' rlike 'a'));
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(strcmp('a','b')));
+create table t1 as select concat(strcmp('a','b')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' like 'a'));
+create table t1 as select concat('a' like 'b') as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' between 'b' and 'c'));
+create table t1 as select concat('a' between 'b' and 'c') as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat('a' in ('a','b')));
+create table t1 as select concat('a' in ('a','b')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(interval(23, 1, 15, 17, 30, 44, 200)));
+create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 (a varchar(10), fulltext key(a));
+insert into t1 values ('a');
+select hex(concat(match (a) against ('a'))) from t1;
+create table t2 as select concat(match (a) against ('a')) as a from t1;
+show create table t2;
+drop table t1, t2;
+
+
+
+#
+# GIS functions
+#
+
+select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))));
+create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))));
+create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))));
+create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))));
+create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(IsSimple(GeomFromText('POINT(1 1)'))));
+create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))));
+create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))));
+create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1;
+drop table t1;
+
+select hex(concat(x(GeomFromText('Point(1 2)'))));
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(y(GeomFromText('Point(1 2)'))));
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))));
+create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))));
+create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(GeometryType(GeomFromText('Point(1 2)'))));
+create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(AsText(GeomFromText('Point(1 2)'))));
+create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+drop table t1;
+
+
+
+#
+# Date/Time functions
+#
+
+select hex(concat(period_add(200902, 2)));
+create table t1 as select concat(period_add(200902, 2)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(period_diff(200902, 200802)));
+create table t1 as select concat(period_add(200902, 200802)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(to_days(20090224)));
+create table t1 as select concat(to_days(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(dayofmonth(20090224)));
+create table t1 as select concat(dayofmonth(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(dayofyear(20090224)));
+create table t1 as select concat(dayofyear(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(hour('10:11:12')));
+create table t1 as select concat(hour('10:11:12')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(minute('10:11:12')));
+create table t1 as select concat(minute('10:11:12')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(second('10:11:12')));
+create table t1 as select concat(second('10:11:12')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(quarter(20090224)));
+create table t1 as select concat(quarter(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(week(20090224)));
+create table t1 as select concat(week(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(yearweek(20090224)));
+create table t1 as select concat(yearweek(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(year(20090224)));
+create table t1 as select concat(year(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(weekday(20090224)));
+create table t1 as select concat(weekday(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(dayofweek(20090224)));
+create table t1 as select concat(dayofweek(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(unix_timestamp(20090224)));
+create table t1 as select concat(unix_timestamp(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(time_to_sec('10:11:12')));
+create table t1 as select concat(time_to_sec('10:11:12')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(extract(year from 20090702)));
+create table t1 as select concat(extract(year from 20090702)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(microsecond('12:00:00.123456')));
+create table t1 as select concat(microsecond('12:00:00.123456')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(month(20090224)));
+create table t1 as select concat(month(20090224)) as c1;
+show create table t1;
+drop table t1;
+
+
+create table t1 as select concat(last_day('2003-02-05')) as c1;
+show create table t1;
+select c1, hex(c1) from t1;
+drop table t1;
+
+create table t1 as select concat(from_days(730669)) as c1;
+show create table t1;
+select c1, hex(c1) from t1;
+drop table t1;
+
+create table t1 as select concat(curdate()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(utc_date()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(curtime()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select repeat('a',20) as c1 limit 0;
+set timestamp=1216359724;
+insert into t1 values (current_date);
+insert into t1 values (current_time);
+select c1, hex(c1) from t1;
+drop table t1;
+
+create table t1 as select concat(utc_time()) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(sec_to_time(2378)));
+create table t1 as select concat(sec_to_time(2378)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')));
+create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(maketime(10,11,12)));
+create table t1 as select concat(maketime(10,11,12)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(get_format(DATE,'USA'));
+create table t1 as select get_format(DATE,'USA') as c1;
+show create table t1;
+drop table t1;
+
+select hex(left(concat(from_unixtime(1111885200)),4));
+create table t1 as select concat(from_unixtime(1111885200)) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')));
+create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
+create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1;
+show create table t1;
+select * from t1;
+drop table t1;
+
+select hex(concat(makedate(2009,1)));
+create table t1 as select concat(makedate(2009,1)) as c1;
+show create table t1;
+select * from t1;
+drop table t1;
+
+create table t1 as select concat(now()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(utc_timestamp()) as c1;
+show create table t1;
+drop table t1;
+
+create table t1 as select concat(sysdate()) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(addtime('00:00:00','11:22:33')));
+create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1;
+show create table t1;
+drop table t1;
+
+select hex(concat(subtime('23:59:59','11:22:33')));
+create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1;
+show create table t1;
+drop table t1;
+

=== modified file 'mysql-test/r/bigint.result'
--- a/mysql-test/r/bigint.result	2008-05-13 23:42:43 +0000
+++ b/mysql-test/r/bigint.result	2009-03-04 06:59:35 +0000
@@ -370,22 +370,22 @@ Warnings:
 Warning	1292	Truncated incorrect DECIMAL value: ''
 select -9223372036854775808;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					-9223372036854775808	8	20	20	N	32897	0	63
+def					-9223372036854775808	8	20	20	N	32769	0	8
 -9223372036854775808
 -9223372036854775808
 select -(9223372036854775808);
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					-(9223372036854775808)	8	20	20	N	32897	0	63
+def					-(9223372036854775808)	8	20	20	N	32769	0	8
 -(9223372036854775808)
 -9223372036854775808
 select -((9223372036854775808));
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					-((9223372036854775808))	8	20	20	N	32897	0	63
+def					-((9223372036854775808))	8	20	20	N	32769	0	8
 -((9223372036854775808))
 -9223372036854775808
 select -(-(9223372036854775808));
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					-(-(9223372036854775808))	246	21	19	N	129	0	63
+def					-(-(9223372036854775808))	246	21	19	N	1	0	8
 -(-(9223372036854775808))
 9223372036854775808
 select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;

=== modified file 'mysql-test/r/case.result'
--- a/mysql-test/r/case.result	2008-02-12 19:09:16 +0000
+++ b/mysql-test/r/case.result	2009-03-04 06:59:35 +0000
@@ -101,10 +101,10 @@ Table	Create Table
 t1	CREATE TABLE `t1` (
   `c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
   `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
-  `c3` varbinary(1) NOT NULL DEFAULT '',
-  `c4` varbinary(1) NOT NULL DEFAULT '',
-  `c5` varbinary(4) NOT NULL DEFAULT '',
-  `c6` varbinary(4) NOT NULL DEFAULT '',
+  `c3` varchar(1) NOT NULL DEFAULT '',
+  `c4` varchar(1) NOT NULL DEFAULT '',
+  `c5` varchar(4) NOT NULL DEFAULT '',
+  `c6` varchar(4) NOT NULL DEFAULT '',
   `c7` decimal(2,1) NOT NULL DEFAULT '0.0',
   `c8` decimal(2,1) NOT NULL DEFAULT '0.0',
   `c9` decimal(2,1) DEFAULT NULL,
@@ -155,8 +155,8 @@ t1	CREATE TABLE `t1` (
   `COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
   `COALESCE('a')` varchar(1) NOT NULL DEFAULT '',
   `COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
-  `COALESCE(1,'1')` varbinary(1) NOT NULL DEFAULT '',
-  `COALESCE(1.1,'1')` varbinary(4) NOT NULL DEFAULT '',
+  `COALESCE(1,'1')` varchar(1) NOT NULL DEFAULT '',
+  `COALESCE(1.1,'1')` varchar(4) NOT NULL DEFAULT '',
   `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ''
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;

=== added file 'mysql-test/r/ctype_binary.result'
--- a/mysql-test/r/ctype_binary.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_binary.result	2009-03-04 06:59:35 +0000
@@ -0,0 +1,1520 @@
+set names binary;
+Start of 6.1 tests
+select hex(concat(1));
+hex(concat(1))
+31
+create table t1 as select concat(1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1.1));
+hex(concat(1.1))
+312E31
+create table t1 as select concat(1.1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a', 1+2)), charset(concat(1+2));
+hex(concat('a', 1+2))	charset(concat(1+2))
+6133	binary
+create table t1 as select concat(1+2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1-2));
+hex(concat(1-2))
+2D31
+create table t1 as select concat(1-2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1*2));
+hex(concat(1*2))
+32
+create table t1 as select concat(1*2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1/2));
+hex(concat(1/2))
+302E35303030
+create table t1 as select concat(1/2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(7) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 div 2));
+hex(concat(1 div 2))
+30
+create table t1 as select concat(1 div 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 % 2));
+hex(concat(1 % 2))
+31
+create table t1 as select concat(1 % 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-1));
+hex(concat(-1))
+2D31
+create table t1 as select concat(-1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-(1+2)));
+hex(concat(-(1+2)))
+2D33
+create table t1 as select concat(-(1+2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1|2));
+hex(concat(1|2))
+33
+create table t1 as select concat(1|2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1&2));
+hex(concat(1&2))
+30
+create table t1 as select concat(1&2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_count(12)));
+hex(concat(bit_count(12)))
+32
+create table t1 as select concat(bit_count(12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2<<1));
+hex(concat(2<<1))
+34
+create table t1 as select concat(2<<1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2>>1));
+hex(concat(2>>1))
+31
+create table t1 as select concat(2>>1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(~0));
+hex(concat(~0))
+3138343436373434303733373039353531363135
+create table t1 as select concat(~0) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(3^2));
+hex(concat(3^2))
+31
+create table t1 as select concat(3^2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(abs(-2)));
+hex(concat(abs(-2)))
+32
+create table t1 as select concat(abs(-2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(exp(2)));
+hex(concat(exp(2)))
+372E3338393035363039383933303635
+create table t1 as select concat(exp(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log(2)));
+hex(concat(log(2)))
+302E36393331343731383035353939343533
+create table t1 as select concat(log(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log2(2)));
+hex(concat(log2(2)))
+31
+create table t1 as select concat(log2(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log10(2)));
+hex(concat(log10(2)))
+302E33303130323939393536363339383132
+create table t1 as select concat(log10(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sqrt(2)));
+hex(concat(sqrt(2)))
+312E34313432313335363233373330393531
+create table t1 as select concat(sqrt(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(pow(2,2)));
+hex(concat(pow(2,2)))
+34
+create table t1 as select concat(pow(2,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(acos(0.5)));
+hex(concat(acos(0.5)))
+312E30343731393735353131393635393736
+create table t1 as select concat(acos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(asin(0.5)));
+hex(concat(asin(0.5)))
+302E35323335393837373535393832393839
+create table t1 as select concat(asin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(atan(0.5)));
+hex(concat(atan(0.5)))
+302E34363336343736303930303038303631
+create table t1 as select concat(atan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cos(0.5)));
+hex(concat(cos(0.5)))
+302E38373735383235363138393033373238
+create table t1 as select concat(cos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sin(0.5)));
+hex(concat(sin(0.5)))
+302E343739343235353338363034323033
+create table t1 as select concat(sin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(tan(0.5)));
+hex(concat(tan(0.5)))
+302E35343633303234383938343337393035
+create table t1 as select concat(tan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(degrees(0)));
+hex(concat(degrees(0)))
+30
+create table t1 as select concat(degrees(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(radians(0)));
+hex(concat(radians(0)))
+30
+create table t1 as select concat(radians(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ceiling(0.5)));
+hex(concat(ceiling(0.5)))
+31
+create table t1 as select concat(ceiling(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(floor(0.5)));
+hex(concat(floor(0.5)))
+30
+create table t1 as select concat(floor(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(round(0.5)));
+hex(concat(round(0.5)))
+31
+create table t1 as select concat(round(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sign(0.5)));
+hex(concat(sign(0.5)))
+31
+create table t1 as select concat(sign(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(least(1,2)));
+hex(concat(least(1,2)))
+31
+create table t1 as select concat(least(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(greatest(1,2)));
+hex(concat(greatest(1,2)))
+32
+create table t1 as select concat(greatest(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(rand()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(length('a')));
+hex(concat(length('a')))
+31
+create table t1 as select concat(length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(char_length('a')));
+hex(concat(char_length('a')))
+31
+create table t1 as select concat(char_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_length('a')));
+hex(concat(bit_length('a')))
+38
+create table t1 as select concat(bit_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(coercibility('a')));
+hex(concat(coercibility('a')))
+34
+create table t1 as select concat(coercibility('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(locate('a','a')));
+hex(concat(locate('a','a')))
+31
+create table t1 as select concat(locate('a','a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(11) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(field('c','a','b','c')));
+hex(concat(field('c','a','b','c')))
+33
+create table t1 as select concat(field('c','a','b','c')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ascii(61)));
+hex(concat(ascii(61)))
+3534
+create table t1 as select concat(ascii(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ord(61)));
+hex(concat(ord(61)))
+3534
+create table t1 as select concat(ord(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(find_in_set('b','a,b,c,d')));
+hex(concat(find_in_set('b','a,b,c,d')))
+32
+create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select md5('a'), hex(md5('a'));
+md5('a')	hex(md5('a'))
+0cc175b9c0f1b6a831c399e269772661	3063633137356239633066316236613833316333393965323639373732363631
+create table t1 as select md5('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(32) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select old_password('a'), hex(old_password('a'));
+old_password('a')	hex(old_password('a'))
+60671c896665c3fa	36303637316338393636363563336661
+create table t1 as select old_password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(16) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select password('a'), hex(password('a'));
+password('a')	hex(password('a'))
+*667F407DE7C6AD07358FA38DAED7828A72014B4E	2A36363746343037444537433641443037333538464133384441454437383238413732303134423445
+create table t1 as select password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(41) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha('a'), hex(sha('a'));
+sha('a')	hex(sha('a'))
+86f7e437faa5a7fce15d1ddcb9eaeaea377667b8	38366637653433376661613561376663653135643164646362396561656165613337373636376238
+create table t1 as select sha('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(40) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha1('a'), hex(sha1('a'));
+sha1('a')	hex(sha1('a'))
+86f7e437faa5a7fce15d1ddcb9eaeaea377667b8	38366637653433376661613561376663653135643164646362396561656165613337373636376238
+create table t1 as select sha1('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(40) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha2('a',224), hex(sha2('a',224));
+sha2('a',224)	hex(sha2('a',224))
+abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5	6162643337353334633764396132656662393436356465393331636437303535666664623838373935363361653938303738643664366435
+create table t1 as select sha2('a',224) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(56) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('-1' as signed)));
+hex(concat(cast('-1' as signed)))
+2D31
+create table t1 as select concat(cast('-1' as signed)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('1' as unsigned)));
+hex(concat(cast('1' as unsigned)))
+31
+create table t1 as select concat(cast('1' as unsigned)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast(1/2 as decimal(5,5))));
+hex(concat(cast(1/2 as decimal(5,5))))
+302E3530303030
+create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(7) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as date));
+hex(cast('2001-01-02 03:04:05' as date))
+323030312D30312D3032
+create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as time));
+hex(cast('2001-01-02 03:04:05' as time))
+30333A30343A3035
+create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+03:04:05
+drop table t1;
+select hex(cast('2001-01-02' as datetime));
+hex(cast('2001-01-02' as datetime))
+323030312D30312D30322030303A30303A3030
+create table t1 as select concat(cast('2001-01-02' as datetime)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02 00:00:00
+drop table t1;
+create table t1 as select concat(last_insert_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(benchmark(0,0)));
+hex(concat(benchmark(0,0)))
+30
+create table t1 as select concat(benchmark(0,0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sleep(0)));
+hex(concat(sleep(0)))
+30
+create table t1 as select concat(sleep(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(get_lock('a',0)));
+hex(concat(get_lock('a',0)))
+31
+select hex(concat(release_lock('a')));
+hex(concat(release_lock('a')))
+31
+create table t1 as select concat(get_lock('a',0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(is_free_lock('xxxx')));
+hex(concat(is_free_lock('xxxx')))
+31
+create table t1 as select concat(is_free_lock('xxxx')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(is_used_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(release_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(crc32('')));
+hex(concat(crc32('')))
+30
+create table t1 as select concat(crc32('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(uncompressed_length('')));
+hex(concat(uncompressed_length('')))
+30
+create table t1 as select concat(uncompressed_length('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(connection_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_aton('127.1.1.1')));
+hex(concat(inet_aton('127.1.1.1')))
+32313330373732323235
+create table t1 as select concat(inet_aton('127.1.1.1')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_ntoa(2130772225)));
+hex(concat(inet_ntoa(2130772225)))
+3132372E312E312E31
+create table t1 as select concat(inet_ntoa(2130772225)) as c1;
+select * from t1;
+c1
+127.1.1.1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(31) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(row_count()));
+hex(concat(row_count()))
+2D31
+create table t1 as select concat(row_count()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(found_rows()));
+hex(concat(found_rows()))
+30
+create table t1 as select concat(found_rows()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid_short()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
+coercibility(uuid())	coercibility(cast('a' as char character set latin1))
+4	2
+select charset(concat(uuid(), cast('a' as char character set latin1)));
+charset(concat(uuid(), cast('a' as char character set latin1)))
+latin1
+create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(37) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1));
+hex(concat(@a1:=1))
+31
+create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2;
+select hex(c1) from t1;
+hex(c1)
+32
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT '',
+  `c2` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1;
+select hex(concat(@a2));
+hex(concat(@a2))
+31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(20) DEFAULT NULL,
+  `c2` bigint(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=sqrt(1)));
+hex(concat(@a1:=sqrt(1)))
+31
+create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=sqrt(1);
+select hex(concat(@a2));
+hex(concat(@a2))
+31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1.1));
+hex(concat(@a1:=1.1))
+312E31
+create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2;
+select hex(c1) from t1;
+hex(c1)
+312E31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) NOT NULL DEFAULT '',
+  `c2` decimal(2,1) NOT NULL DEFAULT '0.0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1.1;
+select hex(concat(@a2));
+hex(concat(@a2))
+312E31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+312E31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(83) DEFAULT NULL,
+  `c2` decimal(65,30) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@@ft_max_word_len));
+hex(concat(@@ft_max_word_len))
+3834
+create table t1 as select concat(@@ft_max_word_len) as c1;
+select hex(c1) from t1;
+hex(c1)
+3834
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS TRUE));
+hex(concat('a'='a' IS TRUE))
+31
+create table t1 as select concat('a'='a' IS TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS NOT TRUE));
+hex(concat('a'='a' IS NOT TRUE))
+30
+create table t1 as select concat('a'='a' IS NOT TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NOT 'a'='a'));
+hex(concat(NOT 'a'='a'))
+30
+create table t1 as select concat(NOT 'a'='a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NULL));
+hex(concat('a' IS NULL))
+30
+create table t1 as select concat('a' IS NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NOT NULL));
+hex(concat('a' IS NOT NULL))
+31
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' rlike 'a'));
+hex(concat('a' rlike 'a'))
+31
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(strcmp('a','b')));
+hex(concat(strcmp('a','b')))
+2D31
+create table t1 as select concat(strcmp('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' like 'a'));
+hex(concat('a' like 'a'))
+31
+create table t1 as select concat('a' like 'b') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' between 'b' and 'c'));
+hex(concat('a' between 'b' and 'c'))
+30
+create table t1 as select concat('a' between 'b' and 'c') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' in ('a','b')));
+hex(concat('a' in ('a','b')))
+31
+create table t1 as select concat('a' in ('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(interval(23, 1, 15, 17, 30, 44, 200)));
+hex(concat(interval(23, 1, 15, 17, 30, 44, 200)))
+33
+create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a varchar(10), fulltext key(a));
+insert into t1 values ('a');
+select hex(concat(match (a) against ('a'))) from t1;
+hex(concat(match (a) against ('a')))
+30
+create table t2 as select concat(match (a) against ('a')) as a from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
+select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))))
+31
+create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+32
+create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))))
+32
+create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+30
+create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))));
+hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))))
+31
+create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))));
+hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))))
+30
+create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsSimple(GeomFromText('POINT(1 1)'))));
+hex(concat(IsSimple(GeomFromText('POINT(1 1)'))))
+30
+create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))));
+hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))))
+30
+create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))));
+hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))))
+31
+create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1;
+drop table t1;
+select hex(concat(x(GeomFromText('Point(1 2)'))));
+hex(concat(x(GeomFromText('Point(1 2)'))))
+31
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(y(GeomFromText('Point(1 2)'))));
+hex(concat(y(GeomFromText('Point(1 2)'))))
+32
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))));
+hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))))
+31
+create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))));
+hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))))
+31
+create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GeometryType(GeomFromText('Point(1 2)'))));
+hex(concat(GeometryType(GeomFromText('Point(1 2)'))))
+504F494E54
+create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(AsText(GeomFromText('Point(1 2)'))));
+hex(concat(AsText(GeomFromText('Point(1 2)'))))
+504F494E542831203229
+create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` longblob
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_add(200902, 2)));
+hex(concat(period_add(200902, 2)))
+323030393034
+create table t1 as select concat(period_add(200902, 2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(6) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_diff(200902, 200802)));
+hex(concat(period_diff(200902, 200802)))
+3132
+create table t1 as select concat(period_add(200902, 200802)) as c1;
+Warnings:
+Warning	1265	Data truncated for column 'c1' at row 1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(6) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(to_days(20090224)));
+hex(concat(to_days(20090224)))
+373333383237
+create table t1 as select concat(to_days(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofmonth(20090224)));
+hex(concat(dayofmonth(20090224)))
+3234
+create table t1 as select concat(dayofmonth(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofyear(20090224)));
+hex(concat(dayofyear(20090224)))
+3535
+create table t1 as select concat(dayofyear(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(3) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(hour('10:11:12')));
+hex(concat(hour('10:11:12')))
+3130
+create table t1 as select concat(hour('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(minute('10:11:12')));
+hex(concat(minute('10:11:12')))
+3131
+create table t1 as select concat(minute('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(second('10:11:12')));
+hex(concat(second('10:11:12')))
+3132
+create table t1 as select concat(second('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(quarter(20090224)));
+hex(concat(quarter(20090224)))
+31
+create table t1 as select concat(quarter(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(week(20090224)));
+hex(concat(week(20090224)))
+38
+create table t1 as select concat(week(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(yearweek(20090224)));
+hex(concat(yearweek(20090224)))
+323030393038
+create table t1 as select concat(yearweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(year(20090224)));
+hex(concat(year(20090224)))
+32303039
+create table t1 as select concat(year(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(weekday(20090224)));
+hex(concat(weekday(20090224)))
+31
+create table t1 as select concat(weekday(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofweek(20090224)));
+hex(concat(dayofweek(20090224)))
+33
+create table t1 as select concat(dayofweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(unix_timestamp(20090224)));
+hex(concat(unix_timestamp(20090224)))
+31323335343232383030
+create table t1 as select concat(unix_timestamp(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(time_to_sec('10:11:12')));
+hex(concat(time_to_sec('10:11:12')))
+3336363732
+create table t1 as select concat(time_to_sec('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(extract(year from 20090702)));
+hex(concat(extract(year from 20090702)))
+32303039
+create table t1 as select concat(extract(year from 20090702)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(microsecond('12:00:00.123456')));
+hex(concat(microsecond('12:00:00.123456')))
+313233343536
+create table t1 as select concat(microsecond('12:00:00.123456')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(month(20090224)));
+hex(concat(month(20090224)))
+32
+create table t1 as select concat(month(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(last_day('2003-02-05')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2003-02-28	323030332D30322D3238
+drop table t1;
+create table t1 as select concat(from_days(730669)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2000-07-03	323030302D30372D3033
+drop table t1;
+create table t1 as select concat(curdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_date()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(curtime()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(8) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select repeat('a',20) as c1 limit 0;
+set timestamp=1216359724;
+insert into t1 values (current_date);
+insert into t1 values (current_time);
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2008-07-18	323030382D30372D3138
+08:42:04	30383A34323A3034
+drop table t1;
+create table t1 as select concat(utc_time()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(8) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sec_to_time(2378)));
+hex(concat(sec_to_time(2378)))
+30303A33393A3338
+create table t1 as select concat(sec_to_time(2378)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')));
+hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')))
+32343A30303A3030
+create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(maketime(10,11,12)));
+hex(concat(maketime(10,11,12)))
+31303A31313A3132
+create table t1 as select concat(maketime(10,11,12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(get_format(DATE,'USA'));
+hex(get_format(DATE,'USA'))
+256D2E25642E2559
+create table t1 as select get_format(DATE,'USA') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(17) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(left(concat(from_unixtime(1111885200)),4));
+hex(left(concat(from_unixtime(1111885200)),4))
+32303035
+create table t1 as select concat(from_unixtime(1111885200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')));
+hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')))
+323030332D31322D33312032303A30303A3030
+create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
+hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)))
+323030342D30312D30322031323A30303A3030
+create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2004-01-02 12:00:00
+drop table t1;
+select hex(concat(makedate(2009,1)));
+hex(concat(makedate(2009,1)))
+323030392D30312D3031
+create table t1 as select concat(makedate(2009,1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2009-01-01
+drop table t1;
+create table t1 as select concat(now()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_timestamp()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(sysdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(addtime('00:00:00','11:22:33')));
+hex(concat(addtime('00:00:00','11:22:33')))
+31313A32323A3333
+create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(subtime('23:59:59','11:22:33')));
+hex(concat(subtime('23:59:59','11:22:33')))
+31323A33373A3236
+create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varbinary(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+End of 6.1 tests

=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	2008-07-23 09:43:50 +0000
+++ b/mysql-test/r/ctype_latin1.result	2009-03-04 06:59:35 +0000
@@ -1123,3 +1123,1523 @@ select hex(weight_string('abc' as char(5
 hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
 FFFF9C9D9E
 set names latin1;
+End of 6.0 tests
+Start of 6.1 tests
+select hex(concat(1));
+hex(concat(1))
+31
+create table t1 as select concat(1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1.1));
+hex(concat(1.1))
+312E31
+create table t1 as select concat(1.1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a', 1+2)), charset(concat(1+2));
+hex(concat('a', 1+2))	charset(concat(1+2))
+6133	latin1
+create table t1 as select concat(1+2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1-2));
+hex(concat(1-2))
+2D31
+create table t1 as select concat(1-2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1*2));
+hex(concat(1*2))
+32
+create table t1 as select concat(1*2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1/2));
+hex(concat(1/2))
+302E35303030
+create table t1 as select concat(1/2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(7) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 div 2));
+hex(concat(1 div 2))
+30
+create table t1 as select concat(1 div 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 % 2));
+hex(concat(1 % 2))
+31
+create table t1 as select concat(1 % 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-1));
+hex(concat(-1))
+2D31
+create table t1 as select concat(-1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-(1+2)));
+hex(concat(-(1+2)))
+2D33
+create table t1 as select concat(-(1+2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1|2));
+hex(concat(1|2))
+33
+create table t1 as select concat(1|2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1&2));
+hex(concat(1&2))
+30
+create table t1 as select concat(1&2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_count(12)));
+hex(concat(bit_count(12)))
+32
+create table t1 as select concat(bit_count(12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2<<1));
+hex(concat(2<<1))
+34
+create table t1 as select concat(2<<1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2>>1));
+hex(concat(2>>1))
+31
+create table t1 as select concat(2>>1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(~0));
+hex(concat(~0))
+3138343436373434303733373039353531363135
+create table t1 as select concat(~0) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(3^2));
+hex(concat(3^2))
+31
+create table t1 as select concat(3^2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(abs(-2)));
+hex(concat(abs(-2)))
+32
+create table t1 as select concat(abs(-2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(exp(2)));
+hex(concat(exp(2)))
+372E3338393035363039383933303635
+create table t1 as select concat(exp(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log(2)));
+hex(concat(log(2)))
+302E36393331343731383035353939343533
+create table t1 as select concat(log(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log2(2)));
+hex(concat(log2(2)))
+31
+create table t1 as select concat(log2(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log10(2)));
+hex(concat(log10(2)))
+302E33303130323939393536363339383132
+create table t1 as select concat(log10(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sqrt(2)));
+hex(concat(sqrt(2)))
+312E34313432313335363233373330393531
+create table t1 as select concat(sqrt(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(pow(2,2)));
+hex(concat(pow(2,2)))
+34
+create table t1 as select concat(pow(2,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(acos(0.5)));
+hex(concat(acos(0.5)))
+312E30343731393735353131393635393736
+create table t1 as select concat(acos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(asin(0.5)));
+hex(concat(asin(0.5)))
+302E35323335393837373535393832393839
+create table t1 as select concat(asin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(atan(0.5)));
+hex(concat(atan(0.5)))
+302E34363336343736303930303038303631
+create table t1 as select concat(atan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cos(0.5)));
+hex(concat(cos(0.5)))
+302E38373735383235363138393033373238
+create table t1 as select concat(cos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sin(0.5)));
+hex(concat(sin(0.5)))
+302E343739343235353338363034323033
+create table t1 as select concat(sin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(tan(0.5)));
+hex(concat(tan(0.5)))
+302E35343633303234383938343337393035
+create table t1 as select concat(tan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(degrees(0)));
+hex(concat(degrees(0)))
+30
+create table t1 as select concat(degrees(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(radians(0)));
+hex(concat(radians(0)))
+30
+create table t1 as select concat(radians(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ceiling(0.5)));
+hex(concat(ceiling(0.5)))
+31
+create table t1 as select concat(ceiling(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(floor(0.5)));
+hex(concat(floor(0.5)))
+30
+create table t1 as select concat(floor(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(round(0.5)));
+hex(concat(round(0.5)))
+31
+create table t1 as select concat(round(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sign(0.5)));
+hex(concat(sign(0.5)))
+31
+create table t1 as select concat(sign(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(least(1,2)));
+hex(concat(least(1,2)))
+31
+create table t1 as select concat(least(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(greatest(1,2)));
+hex(concat(greatest(1,2)))
+32
+create table t1 as select concat(greatest(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(rand()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(length('a')));
+hex(concat(length('a')))
+31
+create table t1 as select concat(length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(char_length('a')));
+hex(concat(char_length('a')))
+31
+create table t1 as select concat(char_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_length('a')));
+hex(concat(bit_length('a')))
+38
+create table t1 as select concat(bit_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(coercibility('a')));
+hex(concat(coercibility('a')))
+34
+create table t1 as select concat(coercibility('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(locate('a','a')));
+hex(concat(locate('a','a')))
+31
+create table t1 as select concat(locate('a','a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(11) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(field('c','a','b','c')));
+hex(concat(field('c','a','b','c')))
+33
+create table t1 as select concat(field('c','a','b','c')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ascii(61)));
+hex(concat(ascii(61)))
+3534
+create table t1 as select concat(ascii(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ord(61)));
+hex(concat(ord(61)))
+3534
+create table t1 as select concat(ord(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(find_in_set('b','a,b,c,d')));
+hex(concat(find_in_set('b','a,b,c,d')))
+32
+create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select md5('a'), hex(md5('a'));
+md5('a')	hex(md5('a'))
+0cc175b9c0f1b6a831c399e269772661	3063633137356239633066316236613833316333393965323639373732363631
+create table t1 as select md5('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(32) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select old_password('a'), hex(old_password('a'));
+old_password('a')	hex(old_password('a'))
+60671c896665c3fa	36303637316338393636363563336661
+create table t1 as select old_password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(16) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select password('a'), hex(password('a'));
+password('a')	hex(password('a'))
+*667F407DE7C6AD07358FA38DAED7828A72014B4E	2A36363746343037444537433641443037333538464133384441454437383238413732303134423445
+create table t1 as select password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(41) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha('a'), hex(sha('a'));
+sha('a')	hex(sha('a'))
+86f7e437faa5a7fce15d1ddcb9eaeaea377667b8	38366637653433376661613561376663653135643164646362396561656165613337373636376238
+create table t1 as select sha('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(40) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha1('a'), hex(sha1('a'));
+sha1('a')	hex(sha1('a'))
+86f7e437faa5a7fce15d1ddcb9eaeaea377667b8	38366637653433376661613561376663653135643164646362396561656165613337373636376238
+create table t1 as select sha1('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(40) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha2('a',224), hex(sha2('a',224));
+sha2('a',224)	hex(sha2('a',224))
+abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5	6162643337353334633764396132656662393436356465393331636437303535666664623838373935363361653938303738643664366435
+create table t1 as select sha2('a',224) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(56) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('-1' as signed)));
+hex(concat(cast('-1' as signed)))
+2D31
+create table t1 as select concat(cast('-1' as signed)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('1' as unsigned)));
+hex(concat(cast('1' as unsigned)))
+31
+create table t1 as select concat(cast('1' as unsigned)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast(1/2 as decimal(5,5))));
+hex(concat(cast(1/2 as decimal(5,5))))
+302E3530303030
+create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(7) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as date));
+hex(cast('2001-01-02 03:04:05' as date))
+323030312D30312D3032
+create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as time));
+hex(cast('2001-01-02 03:04:05' as time))
+30333A30343A3035
+create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+03:04:05
+drop table t1;
+select hex(cast('2001-01-02' as datetime));
+hex(cast('2001-01-02' as datetime))
+323030312D30312D30322030303A30303A3030
+create table t1 as select concat(cast('2001-01-02' as datetime)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02 00:00:00
+drop table t1;
+create table t1 as select concat(last_insert_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(benchmark(0,0)));
+hex(concat(benchmark(0,0)))
+30
+create table t1 as select concat(benchmark(0,0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sleep(0)));
+hex(concat(sleep(0)))
+30
+create table t1 as select concat(sleep(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(get_lock('a',0)));
+hex(concat(get_lock('a',0)))
+31
+select hex(concat(release_lock('a')));
+hex(concat(release_lock('a')))
+31
+create table t1 as select concat(get_lock('a',0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(is_free_lock('xxxx')));
+hex(concat(is_free_lock('xxxx')))
+31
+create table t1 as select concat(is_free_lock('xxxx')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(is_used_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(release_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(crc32('')));
+hex(concat(crc32('')))
+30
+create table t1 as select concat(crc32('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(uncompressed_length('')));
+hex(concat(uncompressed_length('')))
+30
+create table t1 as select concat(uncompressed_length('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(connection_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_aton('127.1.1.1')));
+hex(concat(inet_aton('127.1.1.1')))
+32313330373732323235
+create table t1 as select concat(inet_aton('127.1.1.1')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_ntoa(2130772225)));
+hex(concat(inet_ntoa(2130772225)))
+3132372E312E312E31
+create table t1 as select concat(inet_ntoa(2130772225)) as c1;
+select * from t1;
+c1
+127.1.1.1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(31) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(row_count()));
+hex(concat(row_count()))
+2D31
+create table t1 as select concat(row_count()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(found_rows()));
+hex(concat(found_rows()))
+30
+create table t1 as select concat(found_rows()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid_short()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
+coercibility(uuid())	coercibility(cast('a' as char character set latin1))
+4	2
+select charset(concat(uuid(), cast('a' as char character set latin1)));
+charset(concat(uuid(), cast('a' as char character set latin1)))
+latin1
+create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(37) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1));
+hex(concat(@a1:=1))
+31
+create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2;
+select hex(c1) from t1;
+hex(c1)
+32
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT '',
+  `c2` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1;
+select hex(concat(@a2));
+hex(concat(@a2))
+31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(20) DEFAULT NULL,
+  `c2` bigint(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=sqrt(1)));
+hex(concat(@a1:=sqrt(1)))
+31
+create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=sqrt(1);
+select hex(concat(@a2));
+hex(concat(@a2))
+31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1.1));
+hex(concat(@a1:=1.1))
+312E31
+create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2;
+select hex(c1) from t1;
+hex(c1)
+312E31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) NOT NULL DEFAULT '',
+  `c2` decimal(2,1) NOT NULL DEFAULT '0.0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1.1;
+select hex(concat(@a2));
+hex(concat(@a2))
+312E31
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+312E31
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(83) DEFAULT NULL,
+  `c2` decimal(65,30) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@@ft_max_word_len));
+hex(concat(@@ft_max_word_len))
+3834
+create table t1 as select concat(@@ft_max_word_len) as c1;
+select hex(c1) from t1;
+hex(c1)
+3834
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS TRUE));
+hex(concat('a'='a' IS TRUE))
+31
+create table t1 as select concat('a'='a' IS TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS NOT TRUE));
+hex(concat('a'='a' IS NOT TRUE))
+30
+create table t1 as select concat('a'='a' IS NOT TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NOT 'a'='a'));
+hex(concat(NOT 'a'='a'))
+30
+create table t1 as select concat(NOT 'a'='a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NULL));
+hex(concat('a' IS NULL))
+30
+create table t1 as select concat('a' IS NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NOT NULL));
+hex(concat('a' IS NOT NULL))
+31
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' rlike 'a'));
+hex(concat('a' rlike 'a'))
+31
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(strcmp('a','b')));
+hex(concat(strcmp('a','b')))
+2D31
+create table t1 as select concat(strcmp('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' like 'a'));
+hex(concat('a' like 'a'))
+31
+create table t1 as select concat('a' like 'b') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' between 'b' and 'c'));
+hex(concat('a' between 'b' and 'c'))
+30
+create table t1 as select concat('a' between 'b' and 'c') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' in ('a','b')));
+hex(concat('a' in ('a','b')))
+31
+create table t1 as select concat('a' in ('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(interval(23, 1, 15, 17, 30, 44, 200)));
+hex(concat(interval(23, 1, 15, 17, 30, 44, 200)))
+33
+create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a varchar(10), fulltext key(a));
+insert into t1 values ('a');
+select hex(concat(match (a) against ('a'))) from t1;
+hex(concat(match (a) against ('a')))
+30
+create table t2 as select concat(match (a) against ('a')) as a from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
+select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))))
+31
+create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+32
+create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))))
+32
+create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+30
+create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))));
+hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))))
+31
+create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))));
+hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))))
+30
+create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsSimple(GeomFromText('POINT(1 1)'))));
+hex(concat(IsSimple(GeomFromText('POINT(1 1)'))))
+30
+create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))));
+hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))))
+30
+create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))));
+hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))))
+31
+create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1;
+drop table t1;
+select hex(concat(x(GeomFromText('Point(1 2)'))));
+hex(concat(x(GeomFromText('Point(1 2)'))))
+31
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(y(GeomFromText('Point(1 2)'))));
+hex(concat(y(GeomFromText('Point(1 2)'))))
+32
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))));
+hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))))
+31
+create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))));
+hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))))
+31
+create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GeometryType(GeomFromText('Point(1 2)'))));
+hex(concat(GeometryType(GeomFromText('Point(1 2)'))))
+504F494E54
+create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(AsText(GeomFromText('Point(1 2)'))));
+hex(concat(AsText(GeomFromText('Point(1 2)'))))
+504F494E542831203229
+create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` longtext
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_add(200902, 2)));
+hex(concat(period_add(200902, 2)))
+323030393034
+create table t1 as select concat(period_add(200902, 2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_diff(200902, 200802)));
+hex(concat(period_diff(200902, 200802)))
+3132
+create table t1 as select concat(period_add(200902, 200802)) as c1;
+Warnings:
+Warning	1265	Data truncated for column 'c1' at row 1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(to_days(20090224)));
+hex(concat(to_days(20090224)))
+373333383237
+create table t1 as select concat(to_days(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofmonth(20090224)));
+hex(concat(dayofmonth(20090224)))
+3234
+create table t1 as select concat(dayofmonth(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofyear(20090224)));
+hex(concat(dayofyear(20090224)))
+3535
+create table t1 as select concat(dayofyear(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(hour('10:11:12')));
+hex(concat(hour('10:11:12')))
+3130
+create table t1 as select concat(hour('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(minute('10:11:12')));
+hex(concat(minute('10:11:12')))
+3131
+create table t1 as select concat(minute('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(second('10:11:12')));
+hex(concat(second('10:11:12')))
+3132
+create table t1 as select concat(second('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(quarter(20090224)));
+hex(concat(quarter(20090224)))
+31
+create table t1 as select concat(quarter(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(week(20090224)));
+hex(concat(week(20090224)))
+38
+create table t1 as select concat(week(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(yearweek(20090224)));
+hex(concat(yearweek(20090224)))
+323030393038
+create table t1 as select concat(yearweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(year(20090224)));
+hex(concat(year(20090224)))
+32303039
+create table t1 as select concat(year(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(weekday(20090224)));
+hex(concat(weekday(20090224)))
+31
+create table t1 as select concat(weekday(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofweek(20090224)));
+hex(concat(dayofweek(20090224)))
+33
+create table t1 as select concat(dayofweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(unix_timestamp(20090224)));
+hex(concat(unix_timestamp(20090224)))
+31323335343232383030
+create table t1 as select concat(unix_timestamp(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(time_to_sec('10:11:12')));
+hex(concat(time_to_sec('10:11:12')))
+3336363732
+create table t1 as select concat(time_to_sec('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(extract(year from 20090702)));
+hex(concat(extract(year from 20090702)))
+32303039
+create table t1 as select concat(extract(year from 20090702)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(microsecond('12:00:00.123456')));
+hex(concat(microsecond('12:00:00.123456')))
+313233343536
+create table t1 as select concat(microsecond('12:00:00.123456')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(month(20090224)));
+hex(concat(month(20090224)))
+32
+create table t1 as select concat(month(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(last_day('2003-02-05')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2003-02-28	323030332D30322D3238
+drop table t1;
+create table t1 as select concat(from_days(730669)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2000-07-03	323030302D30372D3033
+drop table t1;
+create table t1 as select concat(curdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_date()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(curtime()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(8) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select repeat('a',20) as c1 limit 0;
+set timestamp=1216359724;
+insert into t1 values (current_date);
+insert into t1 values (current_time);
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2008-07-18	323030382D30372D3138
+08:42:04	30383A34323A3034
+drop table t1;
+create table t1 as select concat(utc_time()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(8) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sec_to_time(2378)));
+hex(concat(sec_to_time(2378)))
+30303A33393A3338
+create table t1 as select concat(sec_to_time(2378)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')));
+hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')))
+32343A30303A3030
+create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(maketime(10,11,12)));
+hex(concat(maketime(10,11,12)))
+31303A31313A3132
+create table t1 as select concat(maketime(10,11,12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(get_format(DATE,'USA'));
+hex(get_format(DATE,'USA'))
+256D2E25642E2559
+create table t1 as select get_format(DATE,'USA') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(17) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(left(concat(from_unixtime(1111885200)),4));
+hex(left(concat(from_unixtime(1111885200)),4))
+32303035
+create table t1 as select concat(from_unixtime(1111885200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')));
+hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')))
+323030332D31322D33312032303A30303A3030
+create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
+hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)))
+323030342D30312D30322031323A30303A3030
+create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2004-01-02 12:00:00
+drop table t1;
+select hex(concat(makedate(2009,1)));
+hex(concat(makedate(2009,1)))
+323030392D30312D3031
+create table t1 as select concat(makedate(2009,1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2009-01-01
+drop table t1;
+create table t1 as select concat(now()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_timestamp()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(sysdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(addtime('00:00:00','11:22:33')));
+hex(concat(addtime('00:00:00','11:22:33')))
+31313A32323A3333
+create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(subtime('23:59:59','11:22:33')));
+hex(concat(subtime('23:59:59','11:22:33')))
+31323A33373A3236
+create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+End of 6.1 tests

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2009-01-06 10:38:47 +0000
+++ b/mysql-test/r/ctype_ucs.result	2009-03-04 06:59:35 +0000
@@ -1603,4 +1603,1524 @@ s1	hex(s1)
 2008-07-18 08:42:04	0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034
 DROP TABLE t1;
 SET timestamp=0;
+End of 6.0 tests
+Start of 6.1 tests
+select hex(concat(1));
+hex(concat(1))
+0031
+create table t1 as select concat(1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1.1));
+hex(concat(1.1))
+0031002E0031
+create table t1 as select concat(1.1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a', 1+2)), charset(concat(1+2));
+hex(concat('a', 1+2))	charset(concat(1+2))
+00610033	ucs2
+create table t1 as select concat(1+2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1-2));
+hex(concat(1-2))
+002D0031
+create table t1 as select concat(1-2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1*2));
+hex(concat(1*2))
+0032
+create table t1 as select concat(1*2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1/2));
+hex(concat(1/2))
+0030002E0035003000300030
+create table t1 as select concat(1/2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 div 2));
+hex(concat(1 div 2))
+0030
+create table t1 as select concat(1 div 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1 % 2));
+hex(concat(1 % 2))
+0031
+create table t1 as select concat(1 % 2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-1));
+hex(concat(-1))
+002D0031
+create table t1 as select concat(-1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(-(1+2)));
+hex(concat(-(1+2)))
+002D0033
+create table t1 as select concat(-(1+2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1|2));
+hex(concat(1|2))
+0033
+create table t1 as select concat(1|2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(1&2));
+hex(concat(1&2))
+0030
+create table t1 as select concat(1&2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_count(12)));
+hex(concat(bit_count(12)))
+0032
+create table t1 as select concat(bit_count(12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2<<1));
+hex(concat(2<<1))
+0034
+create table t1 as select concat(2<<1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(2>>1));
+hex(concat(2>>1))
+0031
+create table t1 as select concat(2>>1) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(~0));
+hex(concat(~0))
+00310038003400340036003700340034003000370033003700300039003500350031003600310035
+create table t1 as select concat(~0) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(3^2));
+hex(concat(3^2))
+0031
+create table t1 as select concat(3^2) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(abs(-2)));
+hex(concat(abs(-2)))
+0032
+create table t1 as select concat(abs(-2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(exp(2)));
+hex(concat(exp(2)))
+0037002E00330038003900300035003600300039003800390033003000360035
+create table t1 as select concat(exp(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log(2)));
+hex(concat(log(2)))
+0030002E0036003900330031003400370031003800300035003500390039003400350033
+create table t1 as select concat(log(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log2(2)));
+hex(concat(log2(2)))
+0031
+create table t1 as select concat(log2(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(log10(2)));
+hex(concat(log10(2)))
+0030002E0033003000310030003200390039003900350036003600330039003800310032
+create table t1 as select concat(log10(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sqrt(2)));
+hex(concat(sqrt(2)))
+0031002E0034003100340032003100330035003600320033003700330030003900350031
+create table t1 as select concat(sqrt(2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(pow(2,2)));
+hex(concat(pow(2,2)))
+0034
+create table t1 as select concat(pow(2,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(acos(0.5)));
+hex(concat(acos(0.5)))
+0031002E0030003400370031003900370035003500310031003900360035003900370036
+create table t1 as select concat(acos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(asin(0.5)));
+hex(concat(asin(0.5)))
+0030002E0035003200330035003900380037003700350035003900380032003900380039
+create table t1 as select concat(asin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(atan(0.5)));
+hex(concat(atan(0.5)))
+0030002E0034003600330036003400370036003000390030003000300038003000360031
+create table t1 as select concat(atan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cos(0.5)));
+hex(concat(cos(0.5)))
+0030002E0038003700370035003800320035003600310038003900300033003700320038
+create table t1 as select concat(cos(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sin(0.5)));
+hex(concat(sin(0.5)))
+0030002E003400370039003400320035003500330038003600300034003200300033
+create table t1 as select concat(sin(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(tan(0.5)));
+hex(concat(tan(0.5)))
+0030002E0035003400360033003000320034003800390038003400330037003900300035
+create table t1 as select concat(tan(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(degrees(0)));
+hex(concat(degrees(0)))
+0030
+create table t1 as select concat(degrees(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(radians(0)));
+hex(concat(radians(0)))
+0030
+create table t1 as select concat(radians(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ceiling(0.5)));
+hex(concat(ceiling(0.5)))
+0031
+create table t1 as select concat(ceiling(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(floor(0.5)));
+hex(concat(floor(0.5)))
+0030
+create table t1 as select concat(floor(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(round(0.5)));
+hex(concat(round(0.5)))
+0031
+create table t1 as select concat(round(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sign(0.5)));
+hex(concat(sign(0.5)))
+0031
+create table t1 as select concat(sign(0.5)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(least(1,2)));
+hex(concat(least(1,2)))
+0031
+create table t1 as select concat(least(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(greatest(1,2)));
+hex(concat(greatest(1,2)))
+0032
+create table t1 as select concat(greatest(1,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(rand()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(length('a')));
+hex(concat(length('a')))
+0032
+create table t1 as select concat(length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(char_length('a')));
+hex(concat(char_length('a')))
+0031
+create table t1 as select concat(char_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(bit_length('a')));
+hex(concat(bit_length('a')))
+00310036
+create table t1 as select concat(bit_length('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(coercibility('a')));
+hex(concat(coercibility('a')))
+0034
+create table t1 as select concat(coercibility('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(locate('a','a')));
+hex(concat(locate('a','a')))
+0031
+create table t1 as select concat(locate('a','a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(11) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(field('c','a','b','c')));
+hex(concat(field('c','a','b','c')))
+0033
+create table t1 as select concat(field('c','a','b','c')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ascii(61)));
+hex(concat(ascii(61)))
+0030
+create table t1 as select concat(ascii(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(ord(61)));
+hex(concat(ord(61)))
+00350034
+create table t1 as select concat(ord(61)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(find_in_set('b','a,b,c,d')));
+hex(concat(find_in_set('b','a,b,c,d')))
+0032
+create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select md5('a'), hex(md5('a'));
+md5('a')	hex(md5('a'))
+760f753576f2955b0074758acb4d5fa6	00370036003000660037003500330035003700360066003200390035003500620030003000370034003700350038006100630062003400640035006600610036
+create table t1 as select md5('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(32) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select old_password('a'), hex(old_password('a'));
+old_password('a')	hex(old_password('a'))
+5030573512345671	0035003000330030003500370033003500310032003300340035003600370031
+create table t1 as select old_password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(16) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select password('a'), hex(password('a'));
+password('a')	hex(password('a'))
+*BE1BDEC0AA74B4DCB079943E70528096CCA985F8	002A0042004500310042004400450043003000410041003700340042003400440043004200300037003900390034003300450037003000350032003800300039003600430043004100390038003500460038
+create table t1 as select password('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(41) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha('a'), hex(sha('a'));
+sha('a')	hex(sha('a'))
+3106600e0327ca77371f2526df794ed84322585c	0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063
+create table t1 as select sha('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(40) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha1('a'), hex(sha1('a'));
+sha1('a')	hex(sha1('a'))
+3106600e0327ca77371f2526df794ed84322585c	0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063
+create table t1 as select sha1('a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(40) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select sha2('a',224), hex(sha2('a',224));
+sha2('a',224)	hex(sha2('a',224))
+d95baf2bf68a013f316b01dc606dce2c7c2b5647e7c436fb41e4a886	00640039003500620061006600320062006600360038006100300031003300660033003100360062003000310064006300360030003600640063006500320063003700630032006200350036003400370065003700630034003300360066006200340031006500340061003800380036
+create table t1 as select sha2('a',224) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(56) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('-1' as signed)));
+hex(concat(cast('-1' as signed)))
+002D0031
+create table t1 as select concat(cast('-1' as signed)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast('1' as unsigned)));
+hex(concat(cast('1' as unsigned)))
+0031
+create table t1 as select concat(cast('1' as unsigned)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(cast(1/2 as decimal(5,5))));
+hex(concat(cast(1/2 as decimal(5,5))))
+0030002E00350030003000300030
+create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as date));
+hex(cast('2001-01-02 03:04:05' as date))
+0032003000300031002D00300031002D00300032
+create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02
+drop table t1;
+select hex(cast('2001-01-02 03:04:05' as time));
+hex(cast('2001-01-02 03:04:05' as time))
+00300033003A00300034003A00300035
+create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+03:04:05
+drop table t1;
+select hex(cast('2001-01-02' as datetime));
+hex(cast('2001-01-02' as datetime))
+0032003000300031002D00300031002D00300032002000300030003A00300030003A00300030
+create table t1 as select concat(cast('2001-01-02' as datetime)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2001-01-02 00:00:00
+drop table t1;
+create table t1 as select concat(last_insert_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(benchmark(0,0)));
+hex(concat(benchmark(0,0)))
+0030
+create table t1 as select concat(benchmark(0,0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sleep(0)));
+hex(concat(sleep(0)))
+0030
+create table t1 as select concat(sleep(0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(get_lock('a',0)));
+hex(concat(get_lock('a',0)))
+0031
+select hex(concat(release_lock('a')));
+hex(concat(release_lock('a')))
+0031
+create table t1 as select concat(get_lock('a',0)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(is_free_lock('xxxx')));
+hex(concat(is_free_lock('xxxx')))
+0031
+create table t1 as select concat(is_free_lock('xxxx')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(is_used_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(release_lock('a')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(crc32('')));
+hex(concat(crc32('')))
+0030
+create table t1 as select concat(crc32('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(uncompressed_length('')));
+hex(concat(uncompressed_length('')))
+0030
+create table t1 as select concat(uncompressed_length('')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(connection_id()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_aton('127.1.1.1')));
+hex(concat(inet_aton('127.1.1.1')))
+0032003100330030003700370032003200320035
+create table t1 as select concat(inet_aton('127.1.1.1')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(inet_ntoa(2130772225)));
+hex(concat(inet_ntoa(2130772225)))
+003100320037002E0031002E0031002E0031
+create table t1 as select concat(inet_ntoa(2130772225)) as c1;
+select * from t1;
+c1
+127.1.1.1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(31) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(row_count()));
+hex(concat(row_count()))
+002D0031
+create table t1 as select concat(row_count()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(found_rows()));
+hex(concat(found_rows()))
+0030
+create table t1 as select concat(found_rows()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid_short()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(uuid()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
+coercibility(uuid())	coercibility(cast('a' as char character set latin1))
+4	2
+select charset(concat(uuid(), cast('a' as char character set latin1)));
+charset(concat(uuid(), cast('a' as char character set latin1)))
+latin1
+create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(37) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1));
+hex(concat(@a1:=1))
+0031
+create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2;
+select hex(c1) from t1;
+hex(c1)
+0032
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '',
+  `c2` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1;
+select hex(concat(@a2));
+hex(concat(@a2))
+0031
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+0031
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(20) CHARACTER SET ucs2 DEFAULT NULL,
+  `c2` bigint(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=sqrt(1)));
+hex(concat(@a1:=sqrt(1)))
+0031
+create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2;
+select hex(c1) from t1;
+hex(c1)
+0031
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=sqrt(1);
+select hex(concat(@a2));
+hex(concat(@a2))
+0031
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+0031
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL,
+  `c2` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@a1:=1.1));
+hex(concat(@a1:=1.1))
+0031002E0031
+create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2;
+select hex(c1) from t1;
+hex(c1)
+0031002E0031
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '',
+  `c2` decimal(2,1) NOT NULL DEFAULT '0.0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+set @a2=1.1;
+select hex(concat(@a2));
+hex(concat(@a2))
+0031002E0031
+create table t1 as select concat(@a2) as c1, @a2 as c2;
+select hex(c1) from t1;
+hex(c1)
+0031002E0031
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(83) CHARACTER SET ucs2 DEFAULT NULL,
+  `c2` decimal(65,30) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(@@ft_max_word_len));
+hex(concat(@@ft_max_word_len))
+00380034
+create table t1 as select concat(@@ft_max_word_len) as c1;
+select hex(c1) from t1;
+hex(c1)
+00380034
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS TRUE));
+hex(concat('a'='a' IS TRUE))
+0031
+create table t1 as select concat('a'='a' IS TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a'='a' IS NOT TRUE));
+hex(concat('a'='a' IS NOT TRUE))
+0030
+create table t1 as select concat('a'='a' IS NOT TRUE) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NOT 'a'='a'));
+hex(concat(NOT 'a'='a'))
+0030
+create table t1 as select concat(NOT 'a'='a') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NULL));
+hex(concat('a' IS NULL))
+0030
+create table t1 as select concat('a' IS NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' IS NOT NULL));
+hex(concat('a' IS NOT NULL))
+0031
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' rlike 'a'));
+hex(concat('a' rlike 'a'))
+0031
+create table t1 as select concat('a' IS NOT NULL) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(strcmp('a','b')));
+hex(concat(strcmp('a','b')))
+002D0031
+create table t1 as select concat(strcmp('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' like 'a'));
+hex(concat('a' like 'a'))
+0031
+create table t1 as select concat('a' like 'b') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' between 'b' and 'c'));
+hex(concat('a' between 'b' and 'c'))
+0030
+create table t1 as select concat('a' between 'b' and 'c') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat('a' in ('a','b')));
+hex(concat('a' in ('a','b')))
+0031
+create table t1 as select concat('a' in ('a','b')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(interval(23, 1, 15, 17, 30, 44, 200)));
+hex(concat(interval(23, 1, 15, 17, 30, 44, 200)))
+0033
+create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a varchar(10), fulltext key(a));
+insert into t1 values ('a');
+select hex(concat(match (a) against ('a'))) from t1;
+hex(concat(match (a) against ('a')))
+0030
+create table t2 as select concat(match (a) against ('a')) as a from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
+select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))))
+0031
+create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+0032
+create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))));
+hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))))
+0032
+create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
+hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))))
+0030
+create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))));
+hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))))
+0031
+create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))));
+hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))))
+0030
+create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsSimple(GeomFromText('POINT(1 1)'))));
+hex(concat(IsSimple(GeomFromText('POINT(1 1)'))))
+0030
+create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))));
+hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))))
+0030
+create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))));
+hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))))
+0031
+create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1;
+drop table t1;
+select hex(concat(x(GeomFromText('Point(1 2)'))));
+hex(concat(x(GeomFromText('Point(1 2)'))))
+0031
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(y(GeomFromText('Point(1 2)'))));
+hex(concat(y(GeomFromText('Point(1 2)'))))
+0032
+create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))));
+hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))))
+0031
+create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))));
+hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))))
+0031
+create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(GeometryType(GeomFromText('Point(1 2)'))));
+hex(concat(GeometryType(GeomFromText('Point(1 2)'))))
+0050004F0049004E0054
+create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(20) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(AsText(GeomFromText('Point(1 2)'))));
+hex(concat(AsText(GeomFromText('Point(1 2)'))))
+0050004F0049004E005400280031002000320029
+create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` longtext CHARACTER SET ucs2
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_add(200902, 2)));
+hex(concat(period_add(200902, 2)))
+003200300030003900300034
+create table t1 as select concat(period_add(200902, 2)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(period_diff(200902, 200802)));
+hex(concat(period_diff(200902, 200802)))
+00310032
+create table t1 as select concat(period_add(200902, 200802)) as c1;
+Warnings:
+Warning	1265	Data truncated for column 'c1' at row 1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(to_days(20090224)));
+hex(concat(to_days(20090224)))
+003700330033003800320037
+create table t1 as select concat(to_days(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofmonth(20090224)));
+hex(concat(dayofmonth(20090224)))
+00320034
+create table t1 as select concat(dayofmonth(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofyear(20090224)));
+hex(concat(dayofyear(20090224)))
+00350035
+create table t1 as select concat(dayofyear(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(hour('10:11:12')));
+hex(concat(hour('10:11:12')))
+00310030
+create table t1 as select concat(hour('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(minute('10:11:12')));
+hex(concat(minute('10:11:12')))
+00310031
+create table t1 as select concat(minute('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(second('10:11:12')));
+hex(concat(second('10:11:12')))
+00310032
+create table t1 as select concat(second('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(quarter(20090224)));
+hex(concat(quarter(20090224)))
+0031
+create table t1 as select concat(quarter(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(week(20090224)));
+hex(concat(week(20090224)))
+0038
+create table t1 as select concat(week(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(yearweek(20090224)));
+hex(concat(yearweek(20090224)))
+003200300030003900300038
+create table t1 as select concat(yearweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(6) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(year(20090224)));
+hex(concat(year(20090224)))
+0032003000300039
+create table t1 as select concat(year(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(weekday(20090224)));
+hex(concat(weekday(20090224)))
+0031
+create table t1 as select concat(weekday(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(dayofweek(20090224)));
+hex(concat(dayofweek(20090224)))
+0033
+create table t1 as select concat(dayofweek(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(unix_timestamp(20090224)));
+hex(concat(unix_timestamp(20090224)))
+0031003200330035003400320032003800300030
+create table t1 as select concat(unix_timestamp(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(time_to_sec('10:11:12')));
+hex(concat(time_to_sec('10:11:12')))
+00330036003600370032
+create table t1 as select concat(time_to_sec('10:11:12')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(extract(year from 20090702)));
+hex(concat(extract(year from 20090702)))
+0032003000300039
+create table t1 as select concat(extract(year from 20090702)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(microsecond('12:00:00.123456')));
+hex(concat(microsecond('12:00:00.123456')))
+003100320033003400350036
+create table t1 as select concat(microsecond('12:00:00.123456')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(month(20090224)));
+hex(concat(month(20090224)))
+0032
+create table t1 as select concat(month(20090224)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(last_day('2003-02-05')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2003-02-28	0032003000300033002D00300032002D00320038
+drop table t1;
+create table t1 as select concat(from_days(730669)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2000-07-03	0032003000300030002D00300037002D00300033
+drop table t1;
+create table t1 as select concat(curdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_date()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(curtime()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(8) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select repeat('a',20) as c1 limit 0;
+set timestamp=1216359724;
+insert into t1 values (current_date);
+insert into t1 values (current_time);
+select c1, hex(c1) from t1;
+c1	hex(c1)
+2008-07-18	0032003000300038002D00300037002D00310038
+08:42:04	00300038003A00340032003A00300034
+drop table t1;
+create table t1 as select concat(utc_time()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(8) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(sec_to_time(2378)));
+hex(concat(sec_to_time(2378)))
+00300030003A00330039003A00330038
+create table t1 as select concat(sec_to_time(2378)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')));
+hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')))
+00320034003A00300030003A00300030
+create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(maketime(10,11,12)));
+hex(concat(maketime(10,11,12)))
+00310030003A00310031003A00310032
+create table t1 as select concat(maketime(10,11,12)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(get_format(DATE,'USA'));
+hex(get_format(DATE,'USA'))
+0025006D002E00250064002E00250059
+create table t1 as select get_format(DATE,'USA') as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(17) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(left(concat(from_unixtime(1111885200)),4));
+hex(left(concat(from_unixtime(1111885200)),4))
+0032003000300035
+create table t1 as select concat(from_unixtime(1111885200)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')));
+hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')))
+0032003000300033002D00310032002D00330031002000320030003A00300030003A00300030
+create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
+hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)))
+0032003000300034002D00300031002D00300032002000310032003A00300030003A00300030
+create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2004-01-02 12:00:00
+drop table t1;
+select hex(concat(makedate(2009,1)));
+hex(concat(makedate(2009,1)))
+0032003000300039002D00300031002D00300031
+create table t1 as select concat(makedate(2009,1)) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+c1
+2009-01-01
+drop table t1;
+create table t1 as select concat(now()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(utc_timestamp()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 as select concat(sysdate()) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(addtime('00:00:00','11:22:33')));
+hex(concat(addtime('00:00:00','11:22:33')))
+00310031003A00320032003A00330033
+create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select hex(concat(subtime('23:59:59','11:22:33')));
+hex(concat(subtime('23:59:59','11:22:33')))
+00310032003A00330037003A00320036
+create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+End of 6.1 tests
 SET NAMES latin1;

=== modified file 'mysql-test/r/explain.result'
--- a/mysql-test/r/explain.result	2008-12-10 09:02:11 +0000
+++ b/mysql-test/r/explain.result	2009-03-04 06:59:35 +0000
@@ -158,7 +158,7 @@ DROP TABLE t1,t2;
 End of 5.0 tests.
 explain select 1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	0	Y	0	31	8
 def					type	253	10	0	Y	0	31	8
@@ -166,7 +166,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	0	Y	32928	0	63
+def					rows	8	10	0	Y	32800	0	8
 def					Extra	253	255	14	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used

=== modified file 'mysql-test/r/metadata.result'
--- a/mysql-test/r/metadata.result	2008-10-10 11:44:10 +0000
+++ b/mysql-test/r/metadata.result	2009-03-04 06:59:35 +0000
@@ -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	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					1	8	1	1	N	32897	0	63
-def					1.0	246	4	3	N	129	1	63
-def					-1	8	2	2	N	32897	0	63
+def					1	8	1	1	N	32769	0	8
+def					1.0	246	4	3	N	1	1	8
+def					-1	8	2	2	N	32769	0	8
 def					hello	253	5	5	N	1	31	8
 def					NULL	6	0	0	Y	32896	0	63
 1	1.0	-1	hello	NULL
@@ -126,7 +126,7 @@ renamed
 1
 select * from v3 where renamed=1 group by renamed;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def		v3	v3	renamed	renamed	8	12	0	Y	32896	0	63
+def		v3	v3	renamed	renamed	8	12	0	Y	32768	0	8
 renamed
 drop table t1;
 drop view v1,v2,v3;

=== modified file 'mysql-test/r/ps_1general.result'
--- a/mysql-test/r/ps_1general.result	2008-12-13 19:55:44 +0000
+++ b/mysql-test/r/ps_1general.result	2009-03-04 06:59:35 +0000
@@ -441,7 +441,7 @@ prepare stmt1 from ' KILL 0 ';
 prepare stmt1 from ' explain select a from t1 order by b ';
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -449,7 +449,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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
@@ -457,7 +457,7 @@ 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	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	5	Y	0	31	8
@@ -465,7 +465,7 @@ def					possible_keys	253	4096	7	Y	0	31	
 def					key	253	64	7	Y	0	31	8
 def					key_len	253	320	1	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 def					Extra	253	255	48	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 index condition; Using MRR; Using filesort

=== modified file 'mysql-test/r/ps_2myisam.result'
--- a/mysql-test/r/ps_2myisam.result	2009-02-05 10:05:23 +0000
+++ b/mysql-test/r/ps_2myisam.result	2009-03-04 06:59:35 +0000
@@ -1152,7 +1152,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -1160,7 +1160,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -1788,11 +1788,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -1818,11 +1818,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -1917,25 +1917,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1964,7 +1964,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2014,25 +2014,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2054,7 +2054,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2102,25 +2102,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2146,7 +2146,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2192,25 +2192,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2230,7 +2230,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63

=== modified file 'mysql-test/r/ps_3innodb.result'
--- a/mysql-test/r/ps_3innodb.result	2009-02-05 10:05:23 +0000
+++ b/mysql-test/r/ps_3innodb.result	2009-03-04 06:59:35 +0000
@@ -1152,7 +1152,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -1160,7 +1160,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -1771,11 +1771,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -1801,11 +1801,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -1900,25 +1900,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1947,7 +1947,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -1997,25 +1997,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2037,7 +2037,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2085,25 +2085,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2129,7 +2129,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2175,25 +2175,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2213,7 +2213,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63

=== modified file 'mysql-test/r/ps_4heap.result'
--- a/mysql-test/r/ps_4heap.result	2009-02-05 10:05:23 +0000
+++ b/mysql-test/r/ps_4heap.result	2009-03-04 06:59:35 +0000
@@ -1153,7 +1153,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -1161,7 +1161,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -1772,11 +1772,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -1802,11 +1802,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -1901,25 +1901,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1948,7 +1948,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -1998,25 +1998,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2038,7 +2038,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2086,25 +2086,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2130,7 +2130,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2176,25 +2176,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2214,7 +2214,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63

=== modified file 'mysql-test/r/ps_5merge.result'
--- a/mysql-test/r/ps_5merge.result	2009-02-05 10:05:23 +0000
+++ b/mysql-test/r/ps_5merge.result	2009-03-04 06:59:35 +0000
@@ -1195,7 +1195,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -1203,7 +1203,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -1708,11 +1708,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -1738,11 +1738,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -1837,25 +1837,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1884,7 +1884,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -1934,25 +1934,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1974,7 +1974,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2022,25 +2022,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2066,7 +2066,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2112,25 +2112,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2150,7 +2150,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -4217,7 +4217,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -4225,7 +4225,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -4730,11 +4730,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -4760,11 +4760,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -4859,25 +4859,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -4906,7 +4906,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -4956,25 +4956,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -4996,7 +4996,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -5044,25 +5044,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -5088,7 +5088,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -5134,25 +5134,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -5172,7 +5172,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2009-01-26 16:03:39 +0000
+++ b/mysql-test/r/show_check.result	2009-03-04 06:59:35 +0000
@@ -853,7 +853,7 @@ Catalog	Database	Table	Table_alias	Colum
 def	information_schema	CHARACTER_SETS	CHARACTER_SETS	CHARACTER_SET_NAME	Charset	253	128	4	N	1	0	45
 def	information_schema	CHARACTER_SETS	CHARACTER_SETS	DESCRIPTION	Description	253	240	13	N	1	0	45
 def	information_schema	CHARACTER_SETS	CHARACTER_SETS	DEFAULT_COLLATE_NAME	Default collation	253	128	15	N	1	0	45
-def	information_schema	CHARACTER_SETS	CHARACTER_SETS	MAXLEN	Maxlen	8	3	1	N	32769	0	63
+def	information_schema	CHARACTER_SETS	CHARACTER_SETS	MAXLEN	Maxlen	8	12	1	N	32769	0	63
 Charset	Description	Default collation	Maxlen
 utf8	UTF-8 Unicode	utf8_general_ci	4
 ----------------------------------------------------------------
@@ -861,10 +861,10 @@ SHOW COLLATION LIKE 'latin1_bin';
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
 def	information_schema	COLLATIONS	COLLATIONS	COLLATION_NAME	Collation	253	128	10	N	1	0	45
 def	information_schema	COLLATIONS	COLLATIONS	CHARACTER_SET_NAME	Charset	253	128	6	N	1	0	45
-def	information_schema	COLLATIONS	COLLATIONS	ID	Id	8	11	2	N	32769	0	63
+def	information_schema	COLLATIONS	COLLATIONS	ID	Id	8	44	2	N	32769	0	63
 def	information_schema	COLLATIONS	COLLATIONS	IS_DEFAULT	Default	253	12	0	N	1	0	45
 def	information_schema	COLLATIONS	COLLATIONS	IS_COMPILED	Compiled	253	12	3	N	1	0	45
-def	information_schema	COLLATIONS	COLLATIONS	SORTLEN	Sortlen	8	3	1	N	32769	0	63
+def	information_schema	COLLATIONS	COLLATIONS	SORTLEN	Sortlen	8	12	1	N	32769	0	63
 Collation	Charset	Id	Default	Compiled	Sortlen
 latin1_bin	latin1	47		Yes	1
 ----------------------------------------------------------------
@@ -894,13 +894,13 @@ t1	CREATE TABLE `t1` (
 SHOW INDEX FROM t1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
 def	information_schema	STATISTICS	STATISTICS	TABLE_NAME	Table	253	256	2	N	1	0	45
-def	information_schema	STATISTICS	STATISTICS	NON_UNIQUE	Non_unique	8	1	1	N	32769	0	63
+def	information_schema	STATISTICS	STATISTICS	NON_UNIQUE	Non_unique	8	4	1	N	32769	0	63
 def	information_schema	STATISTICS	STATISTICS	INDEX_NAME	Key_name	253	256	7	N	1	0	45
-def	information_schema	STATISTICS	STATISTICS	SEQ_IN_INDEX	Seq_in_index	8	2	1	N	32769	0	63
+def	information_schema	STATISTICS	STATISTICS	SEQ_IN_INDEX	Seq_in_index	8	8	1	N	32769	0	63
 def	information_schema	STATISTICS	STATISTICS	COLUMN_NAME	Column_name	253	256	1	N	1	0	45
 def	information_schema	STATISTICS	STATISTICS	COLLATION	Collation	253	4	1	Y	0	0	45
-def	information_schema	STATISTICS	STATISTICS	CARDINALITY	Cardinality	8	21	1	Y	32768	0	63
-def	information_schema	STATISTICS	STATISTICS	SUB_PART	Sub_part	8	3	0	Y	32768	0	63
+def	information_schema	STATISTICS	STATISTICS	CARDINALITY	Cardinality	8	84	1	Y	32768	0	63
+def	information_schema	STATISTICS	STATISTICS	SUB_PART	Sub_part	8	12	0	Y	32768	0	63
 def	information_schema	STATISTICS	STATISTICS	PACKED	Packed	253	40	0	Y	0	0	45
 def	information_schema	STATISTICS	STATISTICS	NULLABLE	Null	253	12	0	N	1	0	45
 def	information_schema	STATISTICS	STATISTICS	INDEX_TYPE	Index_type	253	64	5	N	1	0	45

=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result	2008-12-09 14:22:54 +0000
+++ b/mysql-test/r/union.result	2009-03-04 06:59:35 +0000
@@ -554,7 +554,7 @@ aa
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `a` varbinary(2) NOT NULL DEFAULT ''
+  `a` varchar(2) NOT NULL DEFAULT ''
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 create table t1 SELECT 12 as a UNION select 12.2 as a;

=== modified file 'mysql-test/suite/ndb/r/ps_7ndb.result'
--- a/mysql-test/suite/ndb/r/ps_7ndb.result	2009-02-05 10:05:23 +0000
+++ b/mysql-test/suite/ndb/r/ps_7ndb.result	2009-03-04 06:59:35 +0000
@@ -1152,7 +1152,7 @@ test_sequence
 prepare stmt1 from ' explain select * from t9 ' ;
 execute stmt1;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					id	8	3	1	N	32929	0	63
+def					id	8	3	1	N	32801	0	8
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
@@ -1160,7 +1160,7 @@ def					possible_keys	253	4096	0	Y	0	31	
 def					key	253	64	0	Y	0	31	8
 def					key_len	253	320	0	Y	0	31	8
 def					ref	253	1024	0	Y	0	31	8
-def					rows	8	10	1	Y	32928	0	63
+def					rows	8	10	1	Y	32800	0	8
 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	
@@ -1771,11 +1771,11 @@ t5	CREATE TABLE `t5` (
   `const06` varchar(10) NOT NULL DEFAULT '',
   `param06` longtext,
   `const07` date DEFAULT NULL,
-  `param07` longblob,
+  `param07` longtext,
   `const08` varchar(19) NOT NULL DEFAULT '',
   `param08` longtext,
   `const09` datetime DEFAULT NULL,
-  `param09` longblob,
+  `param09` longtext,
   `const10` int(10) NOT NULL DEFAULT '0',
   `param10` bigint(20) DEFAULT NULL,
   `const11` int(4) DEFAULT NULL,
@@ -1801,11 +1801,11 @@ def	test	t5	t5	param05	param05	252	42949
 def	test	t5	t5	const06	const06	253	10	10	N	1	0	8
 def	test	t5	t5	param06	param06	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const07	const07	10	10	10	Y	128	0	63
-def	test	t5	t5	param07	param07	252	4294967295	10	Y	144	0	63
+def	test	t5	t5	param07	param07	252	4294967295	10	Y	16	0	8
 def	test	t5	t5	const08	const08	253	19	19	N	1	0	8
 def	test	t5	t5	param08	param08	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const09	const09	12	19	19	Y	128	0	63
-def	test	t5	t5	param09	param09	252	4294967295	19	Y	144	0	63
+def	test	t5	t5	param09	param09	252	4294967295	19	Y	16	0	8
 def	test	t5	t5	const10	const10	3	10	9	N	32769	0	63
 def	test	t5	t5	param10	param10	8	20	9	Y	32768	0	63
 def	test	t5	t5	const11	const11	3	4	4	Y	32768	0	63
@@ -1900,25 +1900,25 @@ from t9 where c1= 1 ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -1947,7 +1947,7 @@ from t9 where c1= 0 ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -1997,25 +1997,25 @@ execute stmt1 using @my_key ;
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2037,7 +2037,7 @@ execute stmt1 using @my_key ;
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2085,25 +2085,25 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 1 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2129,7 +2129,7 @@ into @arg01, @arg02, @arg03, @arg04, @ar
 from t9 where c1= 0 ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63
@@ -2175,25 +2175,25 @@ set @my_key= 1 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
-def					@arg02	8	20	1	Y	32896	0	63
-def					@arg03	8	20	1	Y	32896	0	63
-def					@arg04	8	20	1	Y	32896	0	63
-def					@arg05	8	20	1	Y	32896	0	63
-def					@arg06	8	20	1	Y	32896	0	63
-def					@arg07	5	23	1	Y	32896	31	63
-def					@arg08	5	23	1	Y	32896	31	63
-def					@arg09	5	23	1	Y	32896	31	63
-def					@arg10	5	23	1	Y	32896	31	63
-def					@arg11	246	83	6	Y	128	30	63
-def					@arg12	246	83	6	Y	128	30	63
+def					@arg01	8	20	1	Y	32768	0	8
+def					@arg02	8	20	1	Y	32768	0	8
+def					@arg03	8	20	1	Y	32768	0	8
+def					@arg04	8	20	1	Y	32768	0	8
+def					@arg05	8	20	1	Y	32768	0	8
+def					@arg06	8	20	1	Y	32768	0	8
+def					@arg07	5	23	1	Y	32768	31	8
+def					@arg08	5	23	1	Y	32768	31	8
+def					@arg09	5	23	1	Y	32768	31	8
+def					@arg10	5	23	1	Y	32768	31	8
+def					@arg11	246	83	6	Y	0	30	8
+def					@arg12	246	83	6	Y	0	30	8
 def					@arg13	251	16777216	10	Y	128	31	63
 def					@arg14	251	16777216	19	Y	128	31	63
 def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
-def					@arg17	8	20	4	Y	32928	0	63
-def					@arg18	8	20	1	Y	32896	0	63
-def					@arg19	8	20	1	Y	32896	0	63
+def					@arg16	251	16777216	8	Y	0	31	8
+def					@arg17	8	20	4	Y	32800	0	8
+def					@arg18	8	20	1	Y	32768	0	8
+def					@arg19	8	20	1	Y	32768	0	8
 def					@arg20	251	16777216	1	Y	0	31	8
 def					@arg21	251	16777216	10	Y	0	31	8
 def					@arg22	251	16777216	30	Y	0	31	8
@@ -2213,7 +2213,7 @@ set @my_key= 0 ;
 execute stmt1 using @my_key ;
 execute full_info ;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
-def					@arg01	8	20	1	Y	32896	0	63
+def					@arg01	8	20	1	Y	32768	0	8
 def					@arg02	8	20	0	Y	32896	0	63
 def					@arg03	8	20	0	Y	32896	0	63
 def					@arg04	8	20	0	Y	32896	0	63

=== added file 'mysql-test/t/ctype_binary.test'
--- a/mysql-test/t/ctype_binary.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_binary.test	2009-03-04 06:59:35 +0000
@@ -0,0 +1,6 @@
+
+set names binary;
+
+--echo Start of 6.1 tests
+--source include/ctype_numconv.inc
+--echo End of 6.1 tests

=== modified file 'mysql-test/t/ctype_latin1.test'
--- a/mysql-test/t/ctype_latin1.test	2008-07-23 09:43:50 +0000
+++ b/mysql-test/t/ctype_latin1.test	2009-03-04 06:59:35 +0000
@@ -151,3 +151,9 @@ set @@collation_connection=binary;
 --source include/weight_string_l1.inc
 
 set names latin1;
+
+--echo End of 6.0 tests
+
+--echo Start of 6.1 tests
+--source include/ctype_numconv.inc
+--echo End of 6.1 tests

=== modified file 'mysql-test/t/ctype_ucs.test'
--- a/mysql-test/t/ctype_ucs.test	2009-01-06 10:38:47 +0000
+++ b/mysql-test/t/ctype_ucs.test	2009-03-04 06:59:35 +0000
@@ -707,5 +707,10 @@ select hex(char(0x01020304 using ucs2));
 #
 SET collation_connection=ucs2_general_ci;
 --source include/ctype_datetime.inc
-SET NAMES latin1;
+--echo End of 6.0 tests
+
+--echo Start of 6.1 tests
+--source include/ctype_numconv.inc
+--echo End of 6.1 tests
 
+SET NAMES latin1;

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-02-05 07:49:32 +0000
+++ b/sql/item.cc	2009-03-04 06:59:35 +0000
@@ -201,6 +201,27 @@ bool Item::val_bool()
 }
 
 
+String *Item::val_ascii(String *str)
+{
+  DBUG_ASSERT(fixed == 1);
+
+  if (!(collation.collation->state & MY_CS_NONASCII))
+    return val_str(str);
+  
+  uint errors;
+  String *res= val_str(&str_value);
+  if (!res)
+    return 0;
+  
+  if ((null_value= str->copy(res->ptr(), res->length(),
+                             collation.collation, &my_charset_latin1,
+                             &errors)))
+    return 0;
+  
+  return str;
+}
+
+
 String *Item::val_string_from_real(String *str)
 {
   double nr= val_real();
@@ -437,11 +458,11 @@ uint Item::decimal_precision() const
 
   if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
   {
-    uint prec= 
-      my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
+    uint prec= my_decimal_length_to_precision(max_char_length(), decimals,
+                                              unsigned_flag);
     return min(prec, DECIMAL_MAX_PRECISION);
   }
-  return min(max_length, DECIMAL_MAX_PRECISION);
+  return min(max_char_length(), DECIMAL_MAX_PRECISION);
 }
 
 
@@ -912,8 +933,8 @@ bool Item::get_date(MYSQL_TIME *ltime,ui
   if (result_type() == STRING_RESULT)
   {
     char buff[40];
-    String tmp(buff,sizeof(buff), &my_charset_bin),*res;
-    if (!(res=val_str(&tmp)) ||
+    String tmp(buff, sizeof(buff), &my_charset_latin1), *res;
+    if (!(res= val_ascii(&tmp)) ||
         str_to_datetime_with_warn(res->ptr(), res->length(),
                                   ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
       goto err;
@@ -948,8 +969,8 @@ err:
 bool Item::get_time(MYSQL_TIME *ltime)
 {
   char buff[40];
-  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
-  if (!(res=val_str(&tmp)) ||
+  String tmp(buff, sizeof(buff), &my_charset_latin1), *res;
+  if (!(res= val_ascii(&tmp)) ||
       str_to_time_with_warn(res->ptr(), res->length(), ltime))
   {
     bzero((char*) ltime,sizeof(*ltime));
@@ -2192,7 +2213,7 @@ Item_int::Item_int(const char *str_arg, 
   char *end_ptr= (char*) str_arg + length;
   int error;
   value= my_strtoll10(str_arg, &end_ptr, &error);
-  max_length= (uint) (end_ptr - str_arg);
+  set_char_length_and_dec((uint) (end_ptr - str_arg));
   name= (char*) str_arg;
   fixed= 1;
 }
@@ -2208,7 +2229,7 @@ String *Item_int::val_str(String *str)
 {
   // following assert is redundant, because fixed=1 assigned in constructor
   DBUG_ASSERT(fixed == 1);
-  str->set(value, &my_charset_bin);
+  str->set(value, collation.collation);
   return str;
 }
 
@@ -2238,7 +2259,7 @@ String *Item_uint::val_str(String *str)
 {
   // following assert is redundant, because fixed=1 assigned in constructor
   DBUG_ASSERT(fixed == 1);
-  str->set((ulonglong) value, &my_charset_bin);
+  str->set((ulonglong) value, collation.collation);
   return str;
 }
 
@@ -2258,8 +2279,8 @@ Item_decimal::Item_decimal(const char *s
   name= (char*) str_arg;
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(decimal_value.intg + decimals,
+                                                 decimals, unsigned_flag));
 }
 
 Item_decimal::Item_decimal(longlong val, bool unsig)
@@ -2267,8 +2288,8 @@ Item_decimal::Item_decimal(longlong val,
   int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(decimal_value.intg + decimals,
+                                                 decimals, unsigned_flag));
 }
 
 
@@ -2277,8 +2298,8 @@ Item_decimal::Item_decimal(double val, i
   double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(decimal_value.intg + decimals,
+                                                 decimals, unsigned_flag));
 }
 
 
@@ -2287,8 +2308,7 @@ Item_decimal::Item_decimal(const char *s
 {
   my_decimal2decimal(val_arg, &decimal_value);
   name= (char*) str;
-  decimals= (uint8) decimal_par;
-  max_length= length;
+  set_char_length_and_dec(length, decimal_par);
   fixed= 1;
 }
 
@@ -2298,8 +2318,8 @@ Item_decimal::Item_decimal(my_decimal *v
   my_decimal2decimal(value_par, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(decimal_value.intg + decimals,
+                                                 decimals, unsigned_flag));
 }
 
 
@@ -2309,8 +2329,8 @@ Item_decimal::Item_decimal(const uchar *
                     &decimal_value, precision, scale);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(precision, decimals,
+                                                 unsigned_flag));
 }
 
 
@@ -2330,8 +2350,7 @@ double Item_decimal::val_real()
 
 String *Item_decimal::val_str(String *result)
 {
-  result->set_charset(&my_charset_bin);
-  my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, result);
+  str_set_decimal(&decimal_value, result, collation.collation);
   return result;
 }
 

=== modified file 'sql/item.h'
--- a/sql/item.h	2009-02-02 15:58:48 +0000
+++ b/sql/item.h	2009-03-04 06:59:35 +0000
@@ -687,6 +687,7 @@ public:
       If value is not null null_value flag will be reset to FALSE.
   */
   virtual String *val_str(String *str)=0;
+  virtual String *val_ascii(String *str);
   /*
     Return decimal representation of item with fixed point.
 
@@ -1051,6 +1052,19 @@ public:
     { return Field::GEOM_GEOMETRY; };
   String *check_well_formed_result(String *str, bool send_error= 0);
   bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); 
+  uint32 max_char_length() const
+  { return max_length / collation.collation->mbmaxlen; }
+  void set_char_length(uint32 max_char_length_arg)
+  {
+    /* Does not touch "decimals" */
+    collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
+    max_length= max_char_length_arg * collation.collation->mbmaxlen;
+  }
+  void set_char_length_and_dec(uint32 char_length_arg, uint32 decimals_arg= 0)
+  {
+    set_char_length(char_length_arg);
+    decimals= decimals_arg;
+  }
 };
 
 
@@ -1788,15 +1802,15 @@ public:
   longlong value;
   Item_int(int32 i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
     :value((longlong) i)
-    { max_length=length; fixed= 1; }
+    { set_char_length_and_dec(length); fixed= 1; }
   Item_int(longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
     :value(i)
-    { max_length=length; fixed= 1; }
+    { set_char_length_and_dec(length); fixed= 1; }
   Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
     :value((longlong)i)
-    { max_length=length; fixed= 1; unsigned_flag= 1; }
+    { set_char_length_and_dec(length); fixed= 1; unsigned_flag= 1; }
   Item_int(const char *str_arg,longlong i,uint length) :value(i)
-    { max_length=length; name=(char*) str_arg; fixed= 1; }
+    { set_char_length_and_dec(length); name=(char*) str_arg; fixed= 1; }
   Item_int(const char *str_arg, uint length=64);
   enum Type type() const { return INT_ITEM; }
   enum Item_result result_type () const { return INT_RESULT; }
@@ -1811,7 +1825,7 @@ public:
   virtual void print(String *str, enum_query_type query_type);
   Item_num *neg() { value= -value; return this; }
   uint decimal_precision() const
-  { return (uint)(max_length - test(value < 0)); }
+  { return (uint)(max_char_length() - test(value < 0)); }
   bool eq(const Item *, bool binary_cmp) const;
   bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
 };
@@ -1830,7 +1844,7 @@ public:
   int save_in_field(Field *field, bool no_conversions);
   virtual void print(String *str, enum_query_type query_type);
   Item_num *neg ();
-  uint decimal_precision() const { return max_length; }
+  uint decimal_precision() const { return max_char_length(); }
   bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
 };
 

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2009-01-30 14:13:39 +0000
+++ b/sql/item_cmpfunc.cc	2009-03-04 06:59:35 +0000
@@ -446,7 +446,7 @@ static bool convert_constant_item(THD *t
 
 void Item_bool_func2::fix_length_and_dec()
 {
-  max_length= 1;				     // Function returns 0 or 1
+  set_char_length_and_dec(1); // Function returns 0 or 1
   THD *thd;
 
   /*
@@ -1421,8 +1421,7 @@ void Item_func_truth::fix_length_and_dec
 {
   maybe_null= 0;
   null_value= 0;
-  decimals= 0;
-  max_length= 1;
+  set_char_length_and_dec(1);
 }
 
 
@@ -1846,7 +1845,7 @@ void Item_func_interval::fix_length_and_
     }
   }
   maybe_null= 0;
-  max_length= 2;
+  set_char_length_and_dec(2);
   used_tables_cache|= row->used_tables();
   not_null_tables_cache= row->not_null_tables();
   with_sum_func= with_sum_func || row->with_sum_func;
@@ -1997,13 +1996,14 @@ bool Item_func_between::fix_fields(THD *
 
 void Item_func_between::fix_length_and_dec()
 {
-  max_length= 1;
   int i;
   bool datetime_found= FALSE;
   int time_items_found= 0;
   compare_as_dates= TRUE;
   THD *thd= current_thd;
 
+  set_char_length_and_dec(1);
+
   /*
     As some compare functions are generated after sql_yacc,
     we have to check for out of memory conditions here
@@ -3788,7 +3788,7 @@ void Item_func_in::fix_length_and_dec()
       }
     }
   }
-  max_length= 1;
+  set_char_length_and_dec(1);
 }
 
 
@@ -4644,8 +4644,7 @@ Item_func_regex::fix_fields(THD *thd, It
        args[1]->fix_fields(thd, args + 1)) || args[1]->check_cols(1))
     return TRUE;				/* purecov: inspected */
   with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
-  max_length= 1;
-  decimals= 0;
+  set_char_length_and_dec(1);
 
   if (agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1))
     return TRUE;

=== modified file 'sql/item_cmpfunc.h'
--- a/sql/item_cmpfunc.h	2009-01-26 16:03:39 +0000
+++ b/sql/item_cmpfunc.h	2009-03-04 06:59:35 +0000
@@ -107,7 +107,7 @@ public:
   Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
   Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
   bool is_bool_func() { return 1; }
-  void fix_length_and_dec() { decimals=0; max_length=1; }
+  void fix_length_and_dec() { set_char_length_and_dec(1); }
   uint decimal_precision() const { return 1; }
 };
 
@@ -631,6 +631,11 @@ public:
   {
     Item_func::print(str, query_type);
   }
+  void fix_length_and_dec()
+  {
+    Item_bool_func2::fix_length_and_dec();
+    set_char_length(2);  // returns "1" or "0" or "-1"
+  }
 };
 
 
@@ -1283,10 +1288,7 @@ public:
   longlong val_int();
   enum Functype functype() const { return ISNULL_FUNC; }
   void fix_length_and_dec()
-  {
-    decimals=0; max_length=1; maybe_null=0;
-    update_used_tables();
-  }
+  { set_char_length_and_dec(1); maybe_null=0; update_used_tables(); }
   const char *func_name() const { return "isnull"; }
   /* Optimize case of not_null_column IS NULL */
   virtual void update_used_tables()
@@ -1349,9 +1351,7 @@ public:
   longlong val_int();
   enum Functype functype() const { return ISNOTNULL_FUNC; }
   void fix_length_and_dec()
-  {
-    decimals=0; max_length=1; maybe_null=0;
-  }
+  { set_char_length_and_dec(1); maybe_null=0; }
   const char *func_name() const { return "isnotnull"; }
   optimize_type select_optimize() const { return OPTIMIZE_NULL; }
   table_map not_null_tables() const

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2009-02-05 12:49:39 +0000
+++ b/sql/item_func.cc	2009-03-04 06:59:35 +0000
@@ -465,13 +465,15 @@ Field *Item_func::tmp_table_field(TABLE 
 
   switch (result_type()) {
   case INT_RESULT:
-    if (max_length > MY_INT32_NUM_DECIMAL_DIGITS)
-      field= new Field_longlong(max_length, maybe_null, name, unsigned_flag);
+    if (max_char_length() > MY_INT32_NUM_DECIMAL_DIGITS)
+      field= new Field_longlong(max_char_length(), maybe_null, name,
+                                unsigned_flag);
     else
-      field= new Field_long(max_length, maybe_null, name, unsigned_flag);
+      field= new Field_long(max_char_length(), maybe_null, name,
+                            unsigned_flag);
     break;
   case REAL_RESULT:
-    field= new Field_double(max_length, maybe_null, name, decimals);
+    field= new Field_double(max_char_length(), maybe_null, name, decimals);
     break;
   case STRING_RESULT:
     return make_string_field(table);
@@ -508,7 +510,7 @@ String *Item_real_func::val_str(String *
   double nr= val_real();
   if (null_value)
     return 0; /* purecov: inspected */
-  str->set_real(nr,decimals, &my_charset_bin);
+  str->set_real(nr, decimals, collation.collation);
   return str;
 }
 
@@ -531,19 +533,22 @@ void Item_func::fix_num_length_and_dec()
   for (uint i=0 ; i < arg_count ; i++)
   {
     set_if_bigger(decimals,args[i]->decimals);
-    set_if_bigger(fl_length, args[i]->max_length);
+    set_if_bigger(fl_length, args[i]->max_char_length());
   }
-  max_length=float_length(decimals);
+  max_length= float_length(decimals);
   if (fl_length > max_length)
   {
     decimals= NOT_FIXED_DEC;
     max_length= float_length(NOT_FIXED_DEC);
   }
+  set_char_length(max_length);
 }
 
 
 void Item_func_numhybrid::fix_num_length_and_dec()
-{}
+{
+  collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
+}
 
 
 /**
@@ -563,8 +568,8 @@ void Item_func::count_decimal_length()
     set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
   }
   int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(precision, decimals,
+                                                 unsigned_flag));
 }
 
 
@@ -578,9 +583,10 @@ void Item_func::count_only_length()
   unsigned_flag= 0;
   for (uint i=0 ; i < arg_count ; i++)
   {
-    set_if_bigger(max_length, args[i]->max_length);
+    set_if_bigger(max_length, args[i]->max_char_length());
     set_if_bigger(unsigned_flag, args[i]->unsigned_flag);
   }
+  set_char_length(max_length);
 }
 
 
@@ -599,9 +605,9 @@ void Item_func::count_real_length()
     if (decimals != NOT_FIXED_DEC)
     {
       set_if_bigger(decimals, args[i]->decimals);
-      set_if_bigger(length, (args[i]->max_length - args[i]->decimals));
+      set_if_bigger(length, (args[i]->max_char_length() - args[i]->decimals));
     }
-    set_if_bigger(max_length, args[i]->max_length);
+    set_if_bigger(max_length, args[i]->max_char_length());
   }
   if (decimals != NOT_FIXED_DEC)
   {
@@ -612,6 +618,7 @@ void Item_func::count_real_length()
     else
       max_length= length;
   }
+  max_length*= collation.collation->mbmaxlen;
 }
 
 
@@ -647,15 +654,14 @@ String *Item_int_func::val_str(String *s
   longlong nr=val_int();
   if (null_value)
     return 0;
-  str->set_int(nr, unsigned_flag, &my_charset_bin);
+  str->set_int(nr, unsigned_flag, collation.collation);
   return str;
 }
 
 
 void Item_func_connection_id::fix_length_and_dec()
 {
-  Item_int_func::fix_length_and_dec();
-  max_length= 10;
+  set_char_length_and_dec(10);
 }
 
 
@@ -686,7 +692,7 @@ void Item_num_op::find_num_type(void)
       r0 == STRING_RESULT || r1 ==STRING_RESULT)
   {
     count_real_length();
-    max_length= float_length(decimals);
+    max_length= float_length(decimals) * collation.collation->mbmaxlen;
     hybrid_type= REAL_RESULT;
   }
   else if (r0 == DECIMAL_RESULT || r1 == DECIMAL_RESULT)
@@ -727,7 +733,7 @@ void Item_func_num1::find_num_type()
   case STRING_RESULT:
   case REAL_RESULT:
     hybrid_type= REAL_RESULT;
-    max_length= float_length(decimals);
+    max_length= float_length(decimals) * collation.collation->mbmaxlen;
     break;
   case DECIMAL_RESULT:
     break;
@@ -745,8 +751,7 @@ void Item_func_num1::find_num_type()
 
 void Item_func_num1::fix_num_length_and_dec()
 {
-  decimals= args[0]->decimals;
-  max_length= args[0]->max_length;
+  set_char_length_and_dec(args[0]->max_char_length(), args[0]->decimals);
 }
 
 
@@ -757,6 +762,30 @@ void Item_func_numhybrid::fix_length_and
 }
 
 
+/*
+  Would be greate to make it a method of the String class,
+  but this would need to include
+  my_decimal.h from sql_string.h and sql_string.cc, which is not desirable.
+*/
+bool
+str_set_decimal(my_decimal *val, String *str, CHARSET_INFO *cs)
+{
+  if (!(cs->state & MY_CS_NONASCII))
+  {
+    my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str);
+    return FALSE;
+  }
+  else
+  {
+    uint errors;
+    char buf[DECIMAL_MAX_STR_LENGTH];
+    String tmp(buf, sizeof(buf), &my_charset_latin1);
+    my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, &tmp);
+    return str->copy(tmp.ptr(), tmp.length(), &my_charset_latin1, cs, &errors);
+  }
+}
+
+
 String *Item_func_numhybrid::val_str(String *str)
 {
   DBUG_ASSERT(fixed == 1);
@@ -767,7 +796,7 @@ String *Item_func_numhybrid::val_str(Str
     if (!(val= decimal_op(&decimal_value)))
       return 0;                                 // null is set
     my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, FALSE, val);
-    my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str);
+    str_set_decimal(val, str, collation.collation);
     break;
   }
   case INT_RESULT:
@@ -775,7 +804,7 @@ String *Item_func_numhybrid::val_str(Str
     longlong nr= int_op();
     if (null_value)
       return 0; /* purecov: inspected */
-    str->set_int(nr, unsigned_flag, &my_charset_bin);
+    str->set_int(nr, unsigned_flag, collation.collation);
     break;
   }
   case REAL_RESULT:
@@ -783,7 +812,7 @@ String *Item_func_numhybrid::val_str(Str
     double nr= real_op();
     if (null_value)
       return 0; /* purecov: inspected */
-    str->set_real(nr,decimals,&my_charset_bin);
+    str->set_real(nr, decimals, collation.collation);
     break;
   }
   case STRING_RESULT:
@@ -820,7 +849,8 @@ double Item_func_numhybrid::val_real()
     char *end_not_used;
     int err_not_used;
     String *res= str_op(&str_value);
-    return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
+    return (res ? my_strntod(collation.collation,
+                             (char*) res->ptr(), res->length(),
 			     &end_not_used, &err_not_used) : 0.0);
   }
   default:
@@ -855,7 +885,7 @@ longlong Item_func_numhybrid::val_int()
       return 0;
 
     char *end= (char*) res->ptr() + res->length();
-    CHARSET_INFO *cs= str_value.charset();
+    CHARSET_INFO *cs= collation.collation;
     return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
   }
   default:
@@ -918,6 +948,7 @@ longlong Item_func_signed::val_int_from_
   uint32 length;
   String tmp(buff,sizeof(buff), &my_charset_bin), *res;
   longlong value;
+  CHARSET_INFO *cs;
 
   /*
     For a string result, we must first get the string and then convert it
@@ -933,9 +964,10 @@ longlong Item_func_signed::val_int_from_
   null_value= 0;
   start= (char *)res->ptr();
   length= res->length();
+  cs= res->charset();
 
   end= start + length;
-  value= my_strtoll10(start, &end, error);
+  value= cs->cset->strtoll10(cs, start, &end, error);
   if (*error > 0 || end != start+ length)
   {
     char err_buff[128];
@@ -1019,7 +1051,7 @@ String *Item_decimal_typecast::val_str(S
   my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
   if (null_value)
     return NULL;
-  my_decimal2string(E_DEC_FATAL_ERROR, tmp, 0, 0, 0, str);
+  str_set_decimal(tmp, str, collation.collation);
   return str;
 }
 
@@ -1064,7 +1096,7 @@ my_decimal *Item_decimal_typecast::val_d
       goto err;
     }
   }
-  precision= my_decimal_length_to_precision(max_length,
+  precision= my_decimal_length_to_precision(max_char_length(),
                                             decimals, unsigned_flag);
   if (precision - decimals < (uint) my_decimal_intg(dec))
   {
@@ -1088,7 +1120,7 @@ void Item_decimal_typecast::print(String
   char len_buf[20*3 + 1];
   char *end;
 
-  uint precision= my_decimal_length_to_precision(max_length, decimals,
+  uint precision= my_decimal_length_to_precision(max_char_length(), decimals,
                                                  unsigned_flag);
   str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str, query_type);
@@ -1167,8 +1199,8 @@ void Item_func_additive_op::result_preci
     unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
   else
     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(precision, decimals,
+                                                 unsigned_flag));
 }
 
 
@@ -1273,7 +1305,8 @@ void Item_func_mul::result_precision()
   decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
   uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
   uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(precision, decimals,
+                                                 unsigned_flag));
 }
 
 
@@ -1329,8 +1362,8 @@ void Item_func_div::result_precision()
   else
     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
   decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  set_char_length(my_decimal_precision_to_length(precision, decimals,
+                                                 unsigned_flag));
 }
 
 
@@ -1344,9 +1377,10 @@ void Item_func_div::fix_length_and_dec()
   {
     decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
     set_if_smaller(decimals, NOT_FIXED_DEC);
-    max_length=args[0]->max_length - args[0]->decimals + decimals;
+    max_length= args[0]->max_char_length() - args[0]->decimals + decimals;
     uint tmp=float_length(decimals);
     set_if_smaller(max_length,tmp);
+    max_length*= collation.collation->mbmaxlen;
     break;
   }
   case INT_RESULT:
@@ -1420,9 +1454,9 @@ void Item_func_int_div::fix_length_and_d
 {
   Item_result argtype= args[0]->result_type();
   /* use precision ony for the data type it is applicable for and valid */
-  max_length=args[0]->max_length -
-    (argtype == DECIMAL_RESULT || argtype == INT_RESULT ?
-     args[0]->decimals : 0);
+  set_char_length(args[0]->max_char_length() -
+                  (argtype == DECIMAL_RESULT || argtype == INT_RESULT ?
+                   args[0]->decimals : 0));
   maybe_null=1;
   unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
 }
@@ -1497,7 +1531,7 @@ my_decimal *Item_func_mod::decimal_op(my
 void Item_func_mod::result_precision()
 {
   decimals= max(args[0]->decimals, args[1]->decimals);
-  max_length= max(args[0]->max_length, args[1]->max_length);
+  set_char_length(max(args[0]->max_char_length(), args[1]->max_char_length()));
 }
 
 
@@ -1540,9 +1574,8 @@ my_decimal *Item_func_neg::decimal_op(my
 
 void Item_func_neg::fix_num_length_and_dec()
 {
-  decimals= args[0]->decimals;
   /* 1 add because sign can appear */
-  max_length= args[0]->max_length + 1;
+  set_char_length_and_dec(args[0]->max_char_length() + 1, args[0]->decimals);
 }
 
 
@@ -1835,20 +1868,20 @@ longlong Item_func_bit_neg::val_int()
 
 void Item_func_integer::fix_length_and_dec()
 {
-  max_length=args[0]->max_length - args[0]->decimals+1;
+  max_length= args[0]->max_char_length() - args[0]->decimals + 1;
   uint tmp=float_length(decimals);
   set_if_smaller(max_length,tmp);
-  decimals=0;
+  set_char_length_and_dec(max_length);
 }
 
 void Item_func_int_val::fix_num_length_and_dec()
 {
-  max_length= args[0]->max_length - (args[0]->decimals ?
-                                     args[0]->decimals + 1 :
-                                     0) + 2;
+  max_length= args[0]->max_char_length() - (args[0]->decimals ?
+                                            args[0]->decimals + 1 :
+                                            0) + 2;
   uint tmp= float_length(decimals);
   set_if_smaller(max_length,tmp);
-  decimals= 0;
+  set_char_length_and_dec(max_length);
 }
 
 
@@ -1861,7 +1894,7 @@ void Item_func_int_val::find_num_type()
   case STRING_RESULT:
   case REAL_RESULT:
     hybrid_type= REAL_RESULT;
-    max_length= float_length(decimals);
+    max_length= float_length(decimals) * collation.collation->mbmaxlen;
     break;
   case INT_RESULT:
   case DECIMAL_RESULT:
@@ -1993,10 +2026,11 @@ void Item_func_round::fix_length_and_dec
   longlong val1;
   bool     val1_unsigned;
   
+  collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
   unsigned_flag= args[0]->unsigned_flag;
   if (!args[1]->const_item())
   {
-    max_length= args[0]->max_length;
+    max_length= args[0]->max_char_length();
     decimals= args[0]->decimals;
     if (args[0]->result_type() == DECIMAL_RESULT)
     {
@@ -2005,6 +2039,7 @@ void Item_func_round::fix_length_and_dec
     }
     else
       hybrid_type= REAL_RESULT;
+    max_length*= collation.collation->mbmaxlen;
     return;
   }
 
@@ -2017,8 +2052,8 @@ void Item_func_round::fix_length_and_dec
 
   if (args[0]->decimals == NOT_FIXED_DEC)
   {
-    max_length= args[0]->max_length;
-    decimals= min(decimals_to_set, NOT_FIXED_DEC);
+    set_char_length_and_dec(args[0]->max_char_length(),
+                            min(decimals_to_set, NOT_FIXED_DEC));
     hybrid_type= REAL_RESULT;
     return;
   }
@@ -2034,7 +2069,7 @@ void Item_func_round::fix_length_and_dec
     if ((!decimals_to_set && truncate) || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS))
     {
       int length_can_increase= test(!truncate && (val1 < 0) && !val1_unsigned);
-      max_length= args[0]->max_length + length_can_increase;
+      max_length= args[0]->max_char_length() + length_can_increase;
       /* Here we can keep INT_RESULT */
       hybrid_type= INT_RESULT;
       decimals= 0;
@@ -2058,6 +2093,7 @@ void Item_func_round::fix_length_and_dec
   default:
     DBUG_ASSERT(0); /* This result type isn't handled */
   }
+  max_length*= collation.collation->mbmaxlen;
 }
 
 double my_double_round(double value, longlong dec, bool dec_unsigned,
@@ -2259,10 +2295,11 @@ void Item_func_min_max::fix_length_and_d
   max_length=0;
   maybe_null=0;
   cmp_type=args[0]->result_type();
+  collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
 
   for (uint i=0 ; i < arg_count ; i++)
   {
-    set_if_bigger(max_length, args[i]->max_length);
+    set_if_bigger(max_length, args[i]->max_char_length());
     set_if_bigger(decimals, args[i]->decimals);
     set_if_bigger(max_int_part, args[i]->decimal_int_part());
     if (args[i]->maybe_null)
@@ -2287,6 +2324,7 @@ void Item_func_min_max::fix_length_and_d
   else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
     max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals,
                                             unsigned_flag);
+  max_length*= collation.collation->mbmaxlen;
   cached_field_type= agg_field_type(args, arg_count);
 }
 
@@ -2357,7 +2395,7 @@ String *Item_func_min_max::val_str(Strin
     longlong nr=val_int();
     if (null_value)
       return 0;
-    str->set_int(nr, unsigned_flag, &my_charset_bin);
+    str->set_int(nr, unsigned_flag, collation.collation);
     return str;
   }
   case DECIMAL_RESULT:
@@ -2373,7 +2411,7 @@ String *Item_func_min_max::val_str(Strin
     double nr= val_real();
     if (null_value)
       return 0; /* purecov: inspected */
-    str->set_real(nr,decimals,&my_charset_bin);
+    str->set_real(nr,decimals, collation.collation);
     return str;
   }
   case STRING_RESULT:
@@ -2545,7 +2583,7 @@ longlong Item_func_coercibility::val_int
 
 void Item_func_locate::fix_length_and_dec()
 {
-  max_length= MY_INT32_NUM_DECIMAL_DIGITS;
+  set_char_length_and_dec(MY_INT32_NUM_DECIMAL_DIGITS);
   agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1);
 }
 
@@ -2665,7 +2703,8 @@ longlong Item_func_field::val_int()
 
 void Item_func_field::fix_length_and_dec()
 {
-  maybe_null=0; max_length=3;
+  maybe_null=0;
+  set_char_length_and_dec(3);
   cmp_type= args[0]->result_type();
   for (uint i=1; i < arg_count ; i++)
     cmp_type= item_cmp_type(cmp_type, args[i]->result_type());
@@ -2719,8 +2758,7 @@ longlong Item_func_ord::val_int()
 
 void Item_func_find_in_set::fix_length_and_dec()
 {
-  decimals=0;
-  max_length=3;					// 1-999
+  set_char_length_and_dec(3);  // 1-999
   if (args[0]->const_item() && args[1]->type() == FIELD_ITEM)
   {
     Field *field= ((Item_field*) args[1])->field;
@@ -3987,9 +4025,9 @@ void
 Item_func_set_user_var::fix_length_and_dec()
 {
   maybe_null=args[0]->maybe_null;
+  collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
   max_length=args[0]->max_length;
   decimals=args[0]->decimals;
-  collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
 }
 
 
@@ -4190,16 +4228,16 @@ String *user_var_entry::val_str(my_bool 
 
   switch (type) {
   case REAL_RESULT:
-    str->set_real(*(double*) value, decimals, &my_charset_bin);
+    str->set_real(*(double*) value, decimals, collation.collation);
     break;
   case INT_RESULT:
     if (!unsigned_flag)
-      str->set(*(longlong*) value, &my_charset_bin);
+      str->set(*(longlong*) value, collation.collation);
     else
-      str->set(*(ulonglong*) value, &my_charset_bin);
+      str->set(*(ulonglong*) value, collation.collation);
     break;
   case DECIMAL_RESULT:
-    my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str);
+    str_set_decimal((my_decimal *) value, str, collation.collation);
     break;
   case STRING_RESULT:
     if (str->copy(value, length, collation.collation))
@@ -4330,13 +4368,13 @@ Item_func_set_user_var::update()
   case REAL_RESULT:
   {
     res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
-		     REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
+                     REAL_RESULT, default_charset(), DERIVATION_IMPLICIT, 0);
     break;
   }
   case INT_RESULT:
   {
     res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
-                     INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
+                     INT_RESULT, default_charset(), DERIVATION_IMPLICIT,
                      unsigned_flag);
     break;
   }
@@ -4360,7 +4398,7 @@ Item_func_set_user_var::update()
     else
       res= update_hash((void*) save_result.vdec,
                        sizeof(my_decimal), DECIMAL_RESULT,
-                       &my_charset_bin, DERIVATION_IMPLICIT, 0);
+                       default_charset(), DERIVATION_IMPLICIT, 0);
     break;
   }
   case ROW_RESULT:
@@ -4793,17 +4831,17 @@ void Item_func_get_user_var::fix_length_
     collation.set(var_entry->collation);
     switch(m_cached_result_type) {
     case REAL_RESULT:
-      max_length= DBL_DIG + 8;
+      max_length= (DBL_DIG + 8) * collation.collation->mbmaxlen;
       break;
     case INT_RESULT:
-      max_length= MAX_BIGINT_WIDTH;
+      max_length= MAX_BIGINT_WIDTH * collation.collation->mbmaxlen;
       decimals=0;
       break;
     case STRING_RESULT:
       max_length= MAX_BLOB_WIDTH;
       break;
     case DECIMAL_RESULT:
-      max_length= DECIMAL_MAX_STR_LENGTH;
+      max_length= DECIMAL_MAX_STR_LENGTH * collation.collation->mbmaxlen;
       decimals= DECIMAL_MAX_SCALE;
       break;
     case ROW_RESULT:                            // Keep compiler happy
@@ -4977,13 +5015,11 @@ void Item_func_get_system_var::fix_lengt
     case SHOW_INT:
     case SHOW_HA_ROWS:
       unsigned_flag= TRUE;
-      max_length= MY_INT64_NUM_DECIMAL_DIGITS;
-      decimals=0;
+      set_char_length_and_dec(MY_INT64_NUM_DECIMAL_DIGITS);
       break;
     case SHOW_LONGLONG:
       unsigned_flag= FALSE;
-      max_length= MY_INT64_NUM_DECIMAL_DIGITS;
-      decimals=0;
+      set_char_length_and_dec(MY_INT64_NUM_DECIMAL_DIGITS);
       break;
     case SHOW_CHAR:
     case SHOW_CHAR_PTR:
@@ -4994,13 +5030,11 @@ void Item_func_get_system_var::fix_lengt
     case SHOW_BOOL:
     case SHOW_MY_BOOL:
       unsigned_flag= FALSE;
-      max_length= 1;
-      decimals=0;
+      set_char_length_and_dec(1);
       break;
     case SHOW_DOUBLE:
       unsigned_flag= FALSE;
-      decimals= 6;
-      max_length= DBL_DIG + 6;
+      set_char_length_and_dec(DBL_DIG + 6, 6);
       break;
     default:
       my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name);
@@ -5356,8 +5390,8 @@ longlong Item_func_inet_aton::val_int()
   char buff[36];
   int dot_count= 0;
 
-  String *s,tmp(buff,sizeof(buff),&my_charset_bin);
-  if (!(s = args[0]->val_str(&tmp)))		// If null value
+  String *s, tmp(buff, sizeof(buff), &my_charset_latin1);
+  if (!(s = args[0]->val_ascii(&tmp)))          // If null value
     goto err;
   null_value=0;
 

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2009-01-23 19:37:08 +0000
+++ b/sql/item_func.h	2009-03-04 06:59:35 +0000
@@ -215,7 +215,10 @@ public:
     { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
   enum Item_result result_type () const { return REAL_RESULT; }
   void fix_length_and_dec()
-  { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
+  {
+    decimals= NOT_FIXED_DEC;
+    set_char_length(float_length(NOT_FIXED_DEC));
+  }
 };
 
 
@@ -324,7 +327,7 @@ public:
   double val_real();
   String *val_str(String*str);
   enum Item_result result_type () const { return INT_RESULT; }
-  void fix_length_and_dec() {}
+  void fix_length_and_dec() { set_char_length_and_dec(21); }
 };
 
 
@@ -349,7 +352,7 @@ public:
   longlong val_int();
   longlong val_int_from_str(int *error);
   void fix_length_and_dec()
-  { max_length=args[0]->max_length; unsigned_flag=0; }
+  { set_char_length_and_dec(args[0]->max_char_length()); unsigned_flag=0; }
   virtual void print(String *str, enum_query_type query_type);
   uint decimal_precision() const { return args[0]->decimal_precision(); }
 };
@@ -362,7 +365,8 @@ public:
   const char *func_name() const { return "cast_as_unsigned"; }
   void fix_length_and_dec()
   {
-    max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
+    set_char_length_and_dec(min(args[0]->max_char_length(),
+                                DECIMAL_MAX_PRECISION + 2));
     unsigned_flag=1;
   }
   longlong val_int();
@@ -385,7 +389,7 @@ public:
   my_decimal *val_decimal(my_decimal*);
   enum Item_result result_type () const { return DECIMAL_RESULT; }
   enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
-  void fix_length_and_dec() {};
+  void fix_length_and_dec() { set_char_length(max_length); };
   const char *func_name() const { return "decimal_typecast"; }
   virtual void print(String *str, enum_query_type query_type);
 };
@@ -517,10 +521,7 @@ class Item_dec_func :public Item_real_fu
   Item_dec_func(Item *a) :Item_real_func(a) {}
   Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {}
   void fix_length_and_dec()
-  {
-    decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
-    maybe_null=1;
-  }
+  { Item_real_func::fix_length_and_dec(); maybe_null= 1; }
 };
 
 class Item_func_exp :public Item_dec_func
@@ -714,6 +715,7 @@ public:
   Item_func_sign(Item *a) :Item_int_func(a) {}
   const char *func_name() const { return "sign"; }
   longlong val_int();
+  void fix_length_and_dec() { set_char_length_and_dec(2); }
 };
 
 
@@ -726,8 +728,6 @@ public:
     :Item_real_func(a),name(name_arg),mul(mul_arg),add(add_arg) {}
   double val_real();
   const char *func_name() const { return name; }
-  void fix_length_and_dec()
-  { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
 };
 
 
@@ -811,7 +811,7 @@ public:
   Item_func_length(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "length"; }
-  void fix_length_and_dec() { max_length=10; }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
 };
 
 class Item_func_bit_length :public Item_func_length
@@ -830,7 +830,7 @@ public:
   Item_func_char_length(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "char_length"; }
-  void fix_length_and_dec() { max_length=10; }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
 };
 
 class Item_func_coercibility :public Item_int_func
@@ -839,7 +839,7 @@ public:
   Item_func_coercibility(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "coercibility"; }
-  void fix_length_and_dec() { max_length=10; maybe_null= 0; }
+  void fix_length_and_dec() { set_char_length_and_dec(10); maybe_null= 0; }
   table_map not_null_tables() const { return 0; }
 };
 
@@ -877,7 +877,7 @@ public:
   Item_func_ascii(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "ascii"; }
-  void fix_length_and_dec() { max_length=3; }
+  void fix_length_and_dec() { set_char_length_and_dec(3); }
 };
 
 class Item_func_ord :public Item_int_func
@@ -909,7 +909,8 @@ class Item_func_bit: public Item_int_fun
 public:
   Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
   Item_func_bit(Item *a) :Item_int_func(a) {}
-  void fix_length_and_dec() { unsigned_flag= 1; }
+  void fix_length_and_dec()
+  { Item_int_func::fix_length_and_dec(); unsigned_flag= 1; }
 
   virtual inline void print(String *str, enum_query_type query_type)
   {
@@ -939,7 +940,7 @@ public:
   Item_func_bit_count(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "bit_count"; }
-  void fix_length_and_dec() { max_length=2; }
+  void fix_length_and_dec() { set_char_length_and_dec(2); }
 };
 
 class Item_func_shift_left :public Item_func_bit
@@ -980,10 +981,7 @@ public:
   longlong val_int();
   const char *func_name() const { return "last_insert_id"; }
   void fix_length_and_dec()
-  {
-    if (arg_count)
-      max_length= args[0]->max_length;
-  }
+  { set_char_length_and_dec(arg_count ? args[0]->max_char_length() : 21); }
   bool fix_fields(THD *thd, Item **ref);
 };
 
@@ -996,7 +994,7 @@ public:
   {}
   longlong val_int();
   const char *func_name() const { return "benchmark"; }
-  void fix_length_and_dec() { max_length=1; maybe_null=0; }
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 0; }
   virtual void print(String *str, enum_query_type query_type);
 };
 
@@ -1261,7 +1259,7 @@ class Item_func_get_lock :public Item_in
   Item_func_get_lock(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "get_lock"; }
-  void fix_length_and_dec() { max_length=1; maybe_null=1;}
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 1; }
 };
 
 class Item_func_release_lock :public Item_int_func
@@ -1271,7 +1269,7 @@ public:
   Item_func_release_lock(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "release_lock"; }
-  void fix_length_and_dec() { max_length=1; maybe_null=1;}
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 1; }
 };
 
 /* replication functions */
@@ -1284,7 +1282,7 @@ public:
   Item_master_pos_wait(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
   longlong val_int();
   const char *func_name() const { return "master_pos_wait"; }
-  void fix_length_and_dec() { max_length=21; maybe_null=1;}
+  void fix_length_and_dec() { set_char_length_and_dec(21); maybe_null= 1; }
 };
 
 
@@ -1484,7 +1482,7 @@ public:
   longlong val_int();
   const char *func_name() const { return "inet_aton"; }
   void fix_length_and_dec()
-    { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
+  { set_char_length_and_dec(21); maybe_null= 1; unsigned_flag= 1; }
 };
 
 
@@ -1546,7 +1544,7 @@ public:
   Item_func_is_free_lock(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "is_free_lock"; }
-  void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
+  void fix_length_and_dec() { set_char_length_and_dec(1);  maybe_null= 1; }
 };
 
 class Item_func_is_used_lock :public Item_int_func
@@ -1556,7 +1554,7 @@ public:
   Item_func_is_used_lock(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "is_used_lock"; }
-  void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
+  void fix_length_and_dec() { set_char_length_and_dec(10); maybe_null= 1; }
 };
 
 /* For type casts */
@@ -1575,7 +1573,8 @@ public:
   Item_func_row_count() :Item_int_func() {}
   longlong val_int();
   const char *func_name() const { return "row_count"; }
-  void fix_length_and_dec() { decimals= 0; maybe_null=0; }
+  void fix_length_and_dec()
+  { Item_int_func::fix_length_and_dec(); maybe_null= 0; }
 };
 
 
@@ -1695,7 +1694,8 @@ public:
   Item_func_found_rows() :Item_int_func() {}
   longlong val_int();
   const char *func_name() const { return "found_rows"; }
-  void fix_length_and_dec() { decimals= 0; maybe_null=0; }
+  void fix_length_and_dec()
+  { Item_int_func::fix_length_and_dec(); maybe_null= 0; }
 };
 
 
@@ -1707,8 +1707,7 @@ public:
   Item_func_uuid_short() :Item_int_func() {}
   const char *func_name() const { return "uuid_short"; }
   longlong val_int();
-  void fix_length_and_dec()
-  { max_length= 21; unsigned_flag=1; }
+  void fix_length_and_dec() { set_char_length_and_dec(21); unsigned_flag= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2007-12-21 20:10:05 +0000
+++ b/sql/item_geofunc.cc	2009-03-04 06:59:35 +0000
@@ -52,7 +52,7 @@ String *Item_func_geometry_from_text::va
   DBUG_ASSERT(fixed == 1);
   Geometry_buffer buffer;
   String arg_val;
-  String *wkt= args[0]->val_str(&arg_val);
+  String *wkt= args[0]->val_ascii(&arg_val);
 
   if ((null_value= args[0]->null_value))
     return 0;
@@ -98,7 +98,7 @@ String *Item_func_geometry_from_wkb::val
 }
 
 
-String *Item_func_as_wkt::val_str(String *str)
+String *Item_func_as_wkt::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String arg_val;
@@ -122,6 +122,7 @@ String *Item_func_as_wkt::val_str(String
 
 void Item_func_as_wkt::fix_length_and_dec()
 {
+  collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
   max_length=MAX_BLOB_WIDTH;
   maybe_null= 1;
 }
@@ -145,7 +146,7 @@ String *Item_func_as_wkb::val_str(String
 }
 
 
-String *Item_func_geometry_type::val_str(String *str)
+String *Item_func_geometry_type::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String *swkb= args[0]->val_str(str);
@@ -158,8 +159,7 @@ String *Item_func_geometry_type::val_str
     return 0;
   /* String will not move */
   str->copy(geom->get_class_info()->m_name.str,
-	    geom->get_class_info()->m_name.length,
-	    default_charset());
+            geom->get_class_info()->m_name.length, &my_charset_latin1);
   return str;
 }
 

=== modified file 'sql/item_geofunc.h'
--- a/sql/item_geofunc.h	2008-02-22 10:30:33 +0000
+++ b/sql/item_geofunc.h	2009-03-04 06:59:35 +0000
@@ -54,12 +54,12 @@ public:
   String *val_str(String *);
 };
 
-class Item_func_as_wkt: public Item_str_func
+class Item_func_as_wkt: public Item_str_ascii_func
 {
 public:
-  Item_func_as_wkt(Item *a): Item_str_func(a) {}
+  Item_func_as_wkt(Item *a): Item_str_ascii_func(a) {}
   const char *func_name() const { return "astext"; }
-  String *val_str(String *);
+  String *val_ascii(String *);
   void fix_length_and_dec();
 };
 
@@ -72,17 +72,17 @@ public:
   enum_field_types field_type() const  { return MYSQL_TYPE_BLOB; }
 };
 
-class Item_func_geometry_type: public Item_str_func
+class Item_func_geometry_type: public Item_str_ascii_func
 {
 public:
-  Item_func_geometry_type(Item *a): Item_str_func(a) {}
-  String *val_str(String *);
+  Item_func_geometry_type(Item *a): Item_str_ascii_func(a) {}
+  String *val_ascii(String *);
   const char *func_name() const { return "geometrytype"; }
   void fix_length_and_dec() 
   {
-     max_length=20; // "GeometryCollection" is the most long
-     maybe_null= 1;
-  };
+    set_char_length_and_dec(20); // "GeometryCollection" is the most long
+    maybe_null= 1;
+  }
 };
 
 class Item_func_centroid: public Item_geometry_func
@@ -231,48 +231,60 @@ public:
     Item_func::print(str, query_type);
   }
 
-  void fix_length_and_dec() { maybe_null= 1; }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool is_null() { (void) val_int(); return null_value; }
 };
 
-class Item_func_isempty: public Item_bool_func
+
+class Item_geom_bool_func: public Item_bool_func
 {
 public:
-  Item_func_isempty(Item *a): Item_bool_func(a) {}
-  longlong val_int();
+  Item_geom_bool_func(Item *a): Item_bool_func(a) {}
   optimize_type select_optimize() const { return OPTIMIZE_NONE; }
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 1; }
+};
+
+
+class Item_func_isempty: public Item_geom_bool_func
+{
+public:
+  Item_func_isempty(Item *a): Item_geom_bool_func(a) {}
+  longlong val_int();
   const char *func_name() const { return "isempty"; }
-  void fix_length_and_dec() { maybe_null= 1; }
 };
 
-class Item_func_issimple: public Item_bool_func
+class Item_func_issimple: public Item_geom_bool_func
 {
 public:
-  Item_func_issimple(Item *a): Item_bool_func(a) {}
+  Item_func_issimple(Item *a): Item_geom_bool_func(a) {}
   longlong val_int();
-  optimize_type select_optimize() const { return OPTIMIZE_NONE; }
   const char *func_name() const { return "issimple"; }
-  void fix_length_and_dec() { maybe_null= 1; }
 };
 
-class Item_func_isclosed: public Item_bool_func
+class Item_func_isclosed: public Item_geom_bool_func
 {
 public:
-  Item_func_isclosed(Item *a): Item_bool_func(a) {}
+  Item_func_isclosed(Item *a): Item_geom_bool_func(a) {}
   longlong val_int();
-  optimize_type select_optimize() const { return OPTIMIZE_NONE; }
   const char *func_name() const { return "isclosed"; }
-  void fix_length_and_dec() { maybe_null= 1; }
 };
 
-class Item_func_dimension: public Item_int_func
+
+class Item_geom_int_func: public Item_int_func
+{
+public:
+  Item_geom_int_func(Item *a): Item_int_func(a) {}
+  void fix_length_and_dec() { set_char_length_and_dec(10); maybe_null= 1; }
+};
+
+
+class Item_func_dimension: public Item_geom_int_func
 {
   String value;
 public:
-  Item_func_dimension(Item *a): Item_int_func(a) {}
+  Item_func_dimension(Item *a): Item_geom_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "dimension"; }
-  void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
 };
 
 class Item_func_x: public Item_real_func
@@ -282,11 +294,8 @@ public:
   Item_func_x(Item *a): Item_real_func(a) {}
   double val_real();
   const char *func_name() const { return "x"; }
-  void fix_length_and_dec() 
-  { 
-    Item_real_func::fix_length_and_dec();
-    maybe_null= 1; 
-  }
+  void fix_length_and_dec()
+  { Item_real_func::fix_length_and_dec(); maybe_null= 1; }
 };
 
 
@@ -298,43 +307,37 @@ public:
   double val_real();
   const char *func_name() const { return "y"; }
   void fix_length_and_dec() 
-  { 
-    Item_real_func::fix_length_and_dec();
-    maybe_null= 1; 
-  }
+  { Item_real_func::fix_length_and_dec(); maybe_null= 1; }
 };
 
 
-class Item_func_numgeometries: public Item_int_func
+class Item_func_numgeometries: public Item_geom_int_func
 {
   String value;
 public:
-  Item_func_numgeometries(Item *a): Item_int_func(a) {}
+  Item_func_numgeometries(Item *a): Item_geom_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "numgeometries"; }
-  void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
 };
 
 
-class Item_func_numinteriorring: public Item_int_func
+class Item_func_numinteriorring: public Item_geom_int_func
 {
   String value;
 public:
-  Item_func_numinteriorring(Item *a): Item_int_func(a) {}
+  Item_func_numinteriorring(Item *a): Item_geom_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "numinteriorrings"; }
-  void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
 };
 
 
-class Item_func_numpoints: public Item_int_func
+class Item_func_numpoints: public Item_geom_int_func
 {
   String value;
 public:
-  Item_func_numpoints(Item *a): Item_int_func(a) {}
+  Item_func_numpoints(Item *a): Item_geom_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "numpoints"; }
-  void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
 };
 
 
@@ -346,10 +349,7 @@ public:
   double val_real();
   const char *func_name() const { return "area"; }
   void fix_length_and_dec() 
-  { 
-    Item_real_func::fix_length_and_dec();
-    maybe_null= 1; 
-  }
+  { Item_real_func::fix_length_and_dec(); maybe_null= 1; }
 };
 
 
@@ -361,21 +361,17 @@ public:
   double val_real();
   const char *func_name() const { return "glength"; }
   void fix_length_and_dec() 
-  { 
-    Item_real_func::fix_length_and_dec();
-    maybe_null= 1; 
-  }
+  { Item_real_func::fix_length_and_dec(); maybe_null= 1; }
 };
 
 
-class Item_func_srid: public Item_int_func
+class Item_func_srid: public Item_geom_int_func
 {
   String value;
 public:
-  Item_func_srid(Item *a): Item_int_func(a) {}
+  Item_func_srid(Item *a): Item_geom_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "srid"; }
-  void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
 };
 
 #define GEOM_NEW(thd, obj_constructor) new (thd->mem_root) obj_constructor

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2009-01-09 18:43:23 +0000
+++ b/sql/item_strfunc.cc	2009-03-04 06:59:35 +0000
@@ -100,7 +100,28 @@ longlong Item_str_func::val_int()
 }
 
 
-String *Item_func_md5::val_str(String *str)
+String *Item_str_ascii_func::val_str(String *str)
+{
+  DBUG_ASSERT(fixed == 1);
+
+  if (!(collation.collation->state & MY_CS_NONASCII))
+    return val_ascii(str);
+  
+  uint errors;
+  String *res= val_ascii(&ascii_buf);
+  if (!res)
+    return 0;
+  
+  if ((null_value= str->copy(res->ptr(), res->length(),
+                             &my_charset_latin1, collation.collation,
+                             &errors)))
+    return 0;
+  
+  return str;
+}
+
+
+String *Item_func_md5::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String * sptr= args[0]->val_str(str);
@@ -135,7 +156,6 @@ String *Item_func_md5::val_str(String *s
 
 void Item_func_md5::fix_length_and_dec()
 {
-  max_length=32;
   /*
     The MD5() function treats its parameter as being a case sensitive. Thus
     we set binary collation on it so different instances of MD5() will be
@@ -144,10 +164,11 @@ void Item_func_md5::fix_length_and_dec()
   args[0]->collation.set(
       get_charset_by_csname(args[0]->collation.collation->csname,
                             MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE);
+  set_char_length_and_dec(32);
 }
 
 
-String *Item_func_sha::val_str(String *str)
+String *Item_func_sha::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String * sptr= args[0]->val_str(str);
@@ -185,7 +206,6 @@ String *Item_func_sha::val_str(String *s
 
 void Item_func_sha::fix_length_and_dec()
 {
-  max_length=SHA1_HASH_SIZE*2; // size of hex representation of hash
   /*
     The SHA() function treats its parameter as being a case sensitive. Thus
     we set binary collation on it so different instances of MD5() will be
@@ -194,9 +214,10 @@ void Item_func_sha::fix_length_and_dec()
   args[0]->collation.set(
       get_charset_by_csname(args[0]->collation.collation->csname,
                             MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE);
+  set_char_length_and_dec(SHA1_HASH_SIZE * 2); // size of hex representation
 }
 
-String *Item_func_sha2::val_str(String *str)
+String *Item_func_sha2::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
 #ifdef HAVE_OPENSSL
@@ -331,6 +352,9 @@ void Item_func_sha2::fix_length_and_dec(
         MY_CS_BINSORT,
         MYF(0)),
       DERIVATION_COERCIBLE);
+
+  set_char_length_and_dec(max_length);
+  
 #else
   push_warning_printf(current_thd,
     MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -1764,7 +1788,7 @@ void Item_func_trim::print(String *str, 
 
 /* Item_func_password */
 
-String *Item_func_password::val_str(String *str)
+String *Item_func_password::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String *res= args[0]->val_str(str); 
@@ -1787,7 +1811,7 @@ char *Item_func_password::alloc(THD *thd
 
 /* Item_func_old_password */
 
-String *Item_func_old_password::val_str(String *str)
+String *Item_func_old_password::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   String *res= args[0]->val_str(str);
@@ -2183,11 +2207,9 @@ Item_func_format::Item_func_format(Item 
 
 void Item_func_format::fix_length_and_dec()
 {
-  uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen;
+  uint char_length= args[0]->max_char_length();
   uint max_sep_count= char_length/3 + (decimals ? 1 : 0) + /*sign*/1;
-  collation.set(default_charset());
-  max_length= (char_length + max_sep_count + decimals) *
-    collation.collation->mbmaxlen;
+  set_char_length(char_length + max_sep_count + decimals);
 }
 
 
@@ -2874,7 +2896,7 @@ String *Item_func_conv_charset::val_str(
 void Item_func_conv_charset::fix_length_and_dec()
 {
   collation.set(conv_charset, DERIVATION_IMPLICIT);
-  max_length = args[0]->max_length*conv_charset->mbmaxlen;
+  max_length= args[0]->max_char_length() * conv_charset->mbmaxlen;
 }
 
 void Item_func_conv_charset::print(String *str, enum_query_type query_type)
@@ -3047,6 +3069,7 @@ String *Item_func_hex::val_str(String *s
   {
     ulonglong dec;
     char ans[65],*ptr;
+    uint errors;
     /* Return hex of unsigned longlong value */
     if (args[0]->result_type() == REAL_RESULT ||
         args[0]->result_type() == DECIMAL_RESULT)
@@ -3064,7 +3087,8 @@ String *Item_func_hex::val_str(String *s
     if ((null_value= args[0]->null_value))
       return 0;
     ptr= longlong2str(dec,ans,16);
-    if (str->copy(ans,(uint32) (ptr-ans),default_charset()))
+    if (str->copy(ans,(uint32) (ptr-ans), &my_charset_latin1,
+        collation.collation, &errors))
       return &my_empty_string;			// End of memory
     return str;
   }
@@ -3290,6 +3314,7 @@ String* Item_func_inet_ntoa::val_str(Str
   if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295))))
     return 0;					// Null value
 
+  str->set_charset(collation.collation);
   str->length(0);
   int4store(buf,n);
 
@@ -3307,11 +3332,11 @@ String* Item_func_inet_ntoa::val_str(Str
     num[0]=(char) n1+'0';
     num[1]=(char) n2+'0';
     num[2]=(char) c+'0';
-    uint length=(n1 ? 4 : n2 ? 3 : 2);		// Remove pre-zero
-
-    (void) str->append(num+4-length,length);
+    uint length=(n1 ? 4 : n2 ? 3 : 2);      // Remove pre-zero
+    uint dot_length= (p <= buf) ? 1 : 0;
+    (void) str->append(num + 4 - length, length - dot_length,
+                       &my_charset_latin1);
   }
-  str->length(str->length()-1);			// Remove last '.';
   return str;
 }
 

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	2008-12-09 12:08:02 +0000
+++ b/sql/item_strfunc.h	2009-03-04 06:59:35 +0000
@@ -38,40 +38,47 @@ public:
   bool fix_fields(THD *thd, Item **ref);
 };
 
-class Item_func_md5 :public Item_str_func
+
+/*
+  Functions that return values with ASCII repertoire
+*/
+class Item_str_ascii_func :public Item_str_func
 {
-  String tmp_value;
+  String ascii_buf;
 public:
-  Item_func_md5(Item *a) :Item_str_func(a)
-  {
-    collation.set(&my_charset_bin);
-  }
+  Item_str_ascii_func() :Item_str_func() {}
+  Item_str_ascii_func(Item *a) :Item_str_func(a) {}
+  Item_str_ascii_func(Item *a,Item *b) :Item_str_func(a,b) {}
+  Item_str_ascii_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
   String *val_str(String *);
+};
+
+
+class Item_func_md5 :public Item_str_ascii_func
+{
+  String tmp_value;
+public:
+  Item_func_md5(Item *a) :Item_str_ascii_func(a) { }
+  String *val_ascii(String *);
   void fix_length_and_dec();
   const char *func_name() const { return "md5"; }
 };
 
 
-class Item_func_sha :public Item_str_func
+class Item_func_sha :public Item_str_ascii_func
 {
 public:
-  Item_func_sha(Item *a) :Item_str_func(a)
-  {
-    collation.set(&my_charset_bin);
-  }
-  String *val_str(String *);    
-  void fix_length_and_dec();      
+  Item_func_sha(Item *a) :Item_str_ascii_func(a) {}
+  String *val_ascii(String *);    
+  void fix_length_and_dec();
   const char *func_name() const { return "sha"; }	
 };
 
-class Item_func_sha2 :public Item_str_func
+class Item_func_sha2 :public Item_str_ascii_func
 {
 public:
-  Item_func_sha2(Item *a, Item *b) :Item_str_func(a, b)
-  {
-    collation.set(&my_charset_bin);
-  }
-  String *val_str(String *);    
+  Item_func_sha2(Item *a, Item *b) :Item_str_ascii_func(a, b) { }
+  String *val_ascii(String *);    
   void fix_length_and_dec();      
   const char *func_name() const { return "sha2"; }	
 };
@@ -272,13 +279,14 @@ public:
   authentication procedure works, see comments in password.c.
 */
 
-class Item_func_password :public Item_str_func
+class Item_func_password :public Item_str_ascii_func
 {
   char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; 
 public:
-  Item_func_password(Item *a) :Item_str_func(a) {}
-  String *val_str(String *str);
-  void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; }
+  Item_func_password(Item *a) :Item_str_ascii_func(a) {}
+  String *val_ascii(String *str);
+  void fix_length_and_dec()
+  { set_char_length_and_dec(SCRAMBLED_PASSWORD_CHAR_LENGTH); }
   const char *func_name() const { return "password"; }
   static char *alloc(THD *thd, const char *password);
 };
@@ -291,13 +299,14 @@ public:
   function.
 */
 
-class Item_func_old_password :public Item_str_func
+class Item_func_old_password :public Item_str_ascii_func
 {
   char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1];
 public:
-  Item_func_old_password(Item *a) :Item_str_func(a) {}
-  String *val_str(String *str);
-  void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } 
+  Item_func_old_password(Item *a) :Item_str_ascii_func(a) {}
+  String *val_ascii(String *str);
+  void fix_length_and_dec()
+  { set_char_length_and_dec(SCRAMBLED_PASSWORD_CHAR_LENGTH_323); }
   const char *func_name() const { return "old_password"; }
   static char *alloc(THD *thd, const char *password);
 };
@@ -567,12 +576,7 @@ public:
   Item_func_conv(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
   const char *func_name() const { return "conv"; }
   String *val_str(String *);
-  void fix_length_and_dec()
-  {
-    collation.set(default_charset());
-    max_length=64;
-    maybe_null= 1;
-  }
+  void fix_length_and_dec() { set_char_length(64); maybe_null= 1; }
 };
 
 
@@ -584,11 +588,7 @@ public:
   const char *func_name() const { return "hex"; }
   String *val_str(String *);
   void fix_length_and_dec()
-  {
-    collation.set(default_charset());
-    decimals=0;
-    max_length=args[0]->max_length*2*collation.collation->mbmaxlen;
-  }
+  { set_char_length_and_dec(args[0]->max_length * 2); }
 };
 
 class Item_func_unhex :public Item_str_func
@@ -669,12 +669,8 @@ public:
     }
   String* val_str(String* str);
   const char *func_name() const { return "inet_ntoa"; }
-  void fix_length_and_dec() 
-  { 
-    decimals= 0; 
-    max_length= 3 * 8 + 7; 
-    maybe_null= 1;
-  }
+  void fix_length_and_dec()
+  { set_char_length_and_dec(3 * 8 + 7); maybe_null= 1; }
 };
 
 class Item_func_quote :public Item_str_func
@@ -809,7 +805,7 @@ class Item_func_crc32 :public Item_int_f
 public:
   Item_func_crc32(Item *a) :Item_int_func(a) { unsigned_flag= 1; }
   const char *func_name() const { return "crc32"; }
-  void fix_length_and_dec() { max_length=10; }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
   longlong val_int();
 };
 
@@ -819,7 +815,7 @@ class Item_func_uncompressed_length : pu
 public:
   Item_func_uncompressed_length(Item *a):Item_int_func(a){}
   const char *func_name() const{return "uncompressed_length";}
-  void fix_length_and_dec() { max_length=10; }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
   longlong val_int();
 };
 
@@ -854,13 +850,10 @@ class Item_func_uuid: public Item_str_fu
 {
 public:
   Item_func_uuid(): Item_str_func() {}
-  void fix_length_and_dec() {
-    collation.set(system_charset_info);
-    /*
-       NOTE! uuid() should be changed to use 'ascii'
-       charset when hex(), format(), md5(), etc, and implicit
-       number-to-string conversion will use 'ascii'
-    */
+  void fix_length_and_dec()
+  {
+    collation.set(system_charset_info, DERIVATION_COERCIBLE,
+                  MY_REPERTOIRE_ASCII);
     max_length= MY_UUID_STRING_LENGTH * system_charset_info->mbmaxlen;
   }
   const char *func_name() const{ return "uuid"; }

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2009-01-07 15:09:15 +0000
+++ b/sql/item_timefunc.cc	2009-03-04 06:59:35 +0000
@@ -57,7 +57,7 @@ static bool make_datetime(date_time_form
 			  String *str)
 {
   char *buff;
-  CHARSET_INFO *cs= &my_charset_bin;
+  CHARSET_INFO *cs= &my_charset_latin1;
   uint length= MAX_DATE_STRING_REP_LENGTH;
 
   if (str->alloc(length))
@@ -1038,11 +1038,9 @@ void Item_func_monthname::fix_length_and
 {
   THD* thd= current_thd;
   CHARSET_INFO *cs= thd->variables.collation_connection;
-  uint32 repertoire= my_charset_repertoire(cs);
   locale= thd->variables.lc_time_names;  
-  collation.set(cs, DERIVATION_COERCIBLE, repertoire);
-  decimals=0;
-  max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
+  set_char_length_and_dec(locale->max_month_name_length);
+  collation.set_repertoire_from_charset(cs);
   maybe_null=1; 
 }
 
@@ -1191,11 +1189,9 @@ void Item_func_dayname::fix_length_and_d
 {
   THD* thd= current_thd;
   CHARSET_INFO *cs= thd->variables.collation_connection;
-  uint32 repertoire= my_charset_repertoire(cs);
   locale= thd->variables.lc_time_names;  
-  collation.set(cs, DERIVATION_COERCIBLE, repertoire);
-  decimals=0;
-  max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
+  set_char_length_and_dec(locale->max_day_name_length);
+  collation.set_repertoire_from_charset(cs);
   maybe_null=1; 
 }
 
@@ -1483,7 +1479,7 @@ bool get_interval_value(Item *args,inter
 }
 
 
-String *Item_date::val_str(String *str)
+String *Item_date::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -1523,10 +1519,7 @@ bool Item_func_from_days::get_date(MYSQL
 
 void Item_func_curdate::fix_length_and_dec()
 {
-  collation.set(&my_charset_bin);
-  decimals=0; 
-  max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-
+  set_char_length_and_dec(MAX_DATE_WIDTH);
   store_now_in_TIME(&ltime);
   
   /* We don't need to set second_part and neg because they already 0 */
@@ -1535,7 +1528,7 @@ void Item_func_curdate::fix_length_and_d
   value= (longlong) TIME_to_ulonglong_date(&ltime);
 }
 
-String *Item_func_curdate::val_str(String *str)
+String *Item_func_curdate::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
@@ -1583,10 +1576,10 @@ bool Item_func_curdate::get_date(MYSQL_T
 }
 
 
-String *Item_func_curtime::val_str(String *str)
+String *Item_func_curtime::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
-  str_value.set(buff, buff_length, &my_charset_bin);
+  str_value.set(buff, buff_length, &my_charset_latin1);
   return &str_value;
 }
 
@@ -1595,12 +1588,10 @@ void Item_func_curtime::fix_length_and_d
 {
   MYSQL_TIME ltime;
 
-  decimals= DATETIME_DEC;
-  collation.set(&my_charset_bin);
   store_now_in_TIME(&ltime);
   value= TIME_to_ulonglong_time(&ltime);
   buff_length= (uint) my_time_to_str(&ltime, buff);
-  max_length= buff_length;
+  set_char_length_and_dec(buff_length, DATETIME_DEC);   
 }
 
 
@@ -1632,24 +1623,21 @@ void Item_func_curtime_utc::store_now_in
 }
 
 
-String *Item_func_now::val_str(String *str)
+String *Item_func_now::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
-  str_value.set(buff,buff_length, &my_charset_bin);
+  str_value.set(buff, buff_length, &my_charset_latin1);
   return &str_value;
 }
 
 
 void Item_func_now::fix_length_and_dec()
 {
-  decimals= DATETIME_DEC;
-  collation.set(&my_charset_bin);
-
   store_now_in_TIME(&ltime);
   value= (longlong) TIME_to_ulonglong_datetime(&ltime);
 
   buff_length= (uint) my_datetime_to_str(&ltime, buff);
-  max_length= buff_length;
+  set_char_length_and_dec(buff_length, DATETIME_DEC);
 }
 
 
@@ -1708,12 +1696,12 @@ void Item_func_sysdate_local::store_now_
 }
 
 
-String *Item_func_sysdate_local::val_str(String *str)
+String *Item_func_sysdate_local::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   store_now_in_TIME(&ltime);
   buff_length= (uint) my_datetime_to_str(&ltime, buff);
-  str_value.set(buff, buff_length, &my_charset_bin);
+  str_value.set(buff, buff_length, &my_charset_latin1);
   return &str_value;
 }
 
@@ -1736,9 +1724,7 @@ double Item_func_sysdate_local::val_real
 
 void Item_func_sysdate_local::fix_length_and_dec()
 {
-  decimals= 0;
-  collation.set(&my_charset_bin);
-  max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+  set_char_length_and_dec(MAX_DATETIME_WIDTH);
 }
 
 
@@ -1760,7 +1746,7 @@ int Item_func_sysdate_local::save_in_fie
 }
 
 
-String *Item_func_sec_to_time::val_str(String *str)
+String *Item_func_sec_to_time::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -1986,15 +1972,13 @@ null_date:
 void Item_func_from_unixtime::fix_length_and_dec()
 { 
   thd= current_thd;
-  collation.set(&my_charset_bin);
-  decimals= DATETIME_DEC;
-  max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+  set_char_length_and_dec(MAX_DATETIME_WIDTH, DATETIME_DEC);
   maybe_null= 1;
   thd->time_zone_used= 1;
 }
 
 
-String *Item_func_from_unixtime::val_str(String *str)
+String *Item_func_from_unixtime::val_ascii(String *str)
 {
   MYSQL_TIME time_tmp;
 
@@ -2046,14 +2030,12 @@ bool Item_func_from_unixtime::get_date(M
 
 void Item_func_convert_tz::fix_length_and_dec()
 {
-  collation.set(&my_charset_bin);
-  decimals= 0;
-  max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+  set_char_length_and_dec(MAX_DATETIME_WIDTH);
   maybe_null= 1;
 }
 
 
-String *Item_func_convert_tz::val_str(String *str)
+String *Item_func_convert_tz::val_ascii(String *str)
 {
   MYSQL_TIME time_tmp;
 
@@ -2092,13 +2074,13 @@ bool Item_func_convert_tz::get_date(MYSQ
 
   if (!from_tz_cached)
   {
-    from_tz= my_tz_find(thd, args[1]->val_str(&str));
+    from_tz= my_tz_find(thd, args[1]->val_ascii(&str));
     from_tz_cached= args[1]->const_item();
   }
 
   if (!to_tz_cached)
   {
-    to_tz= my_tz_find(thd, args[2]->val_str(&str));
+    to_tz= my_tz_find(thd, args[2]->val_ascii(&str));
     to_tz_cached= args[2]->const_item();
   }
 
@@ -2132,9 +2114,8 @@ void Item_date_add_interval::fix_length_
 {
   enum_field_types arg0_field_type;
 
-  collation.set(&my_charset_bin);
   maybe_null=1;
-  max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+  set_char_length(MAX_DATETIME_FULL_WIDTH);
   value.alloc(max_length);
 
   /*
@@ -2182,7 +2163,7 @@ bool Item_date_add_interval::get_date(MY
 }
 
 
-String *Item_date_add_interval::val_str(String *str)
+String *Item_date_add_interval::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -2267,8 +2248,6 @@ void Item_extract::print(String *str, en
 
 void Item_extract::fix_length_and_dec()
 {
-  value.alloc(32);				// alloc buffer
-
   maybe_null=1;					// If wrong date
   switch (int_type) {
   case INTERVAL_YEAR:		max_length=4; date_value=1; break;
@@ -2293,6 +2272,8 @@ void Item_extract::fix_length_and_dec()
   case INTERVAL_SECOND_MICROSECOND: max_length=9; date_value=0; break;
   case INTERVAL_LAST: DBUG_ASSERT(0); break; /* purecov: deadcode */
   }
+  set_char_length_and_dec(max_length);
+  value.alloc(32 * collation.collation->mbmaxlen); // alloc buffer
 }
 
 
@@ -2552,7 +2533,7 @@ void Item_char_typecast::fix_length_and_
 }
 
 
-String *Item_datetime_typecast::val_str(String *str)
+String *Item_datetime_typecast::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -2606,7 +2587,7 @@ longlong Item_time_typecast::val_int()
   return ltime.hour * 10000L + ltime.minute * 100 + ltime.second;
 }
 
-String *Item_time_typecast::val_str(String *str)
+String *Item_time_typecast::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -2637,7 +2618,7 @@ bool Item_date_typecast::get_time(MYSQL_
 }
 
 
-String *Item_date_typecast::val_str(String *str)
+String *Item_date_typecast::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -2672,7 +2653,7 @@ longlong Item_date_typecast::val_int()
     for dates between 0000-01-01 and 0099-12-31
 */
 
-String *Item_func_makedate::val_str(String *str)
+String *Item_func_makedate::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME l_time;
@@ -2748,8 +2729,7 @@ err:
 void Item_func_add_time::fix_length_and_dec()
 {
   enum_field_types arg0_field_type;
-  decimals=0;
-  max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+  set_char_length_and_dec(MAX_DATETIME_FULL_WIDTH);
   maybe_null= 1;
 
   /*
@@ -2782,7 +2762,7 @@ void Item_func_add_time::fix_length_and_
   Result: Time value or datetime value
 */
 
-String *Item_func_add_time::val_str(String *str)
+String *Item_func_add_time::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME l_time1, l_time2, l_time3;
@@ -2882,7 +2862,7 @@ void Item_func_add_time::print(String *s
   Result: Time value
 */
 
-String *Item_func_timediff::val_str(String *str)
+String *Item_func_timediff::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   longlong seconds;
@@ -2930,7 +2910,7 @@ null_date:
   Result: Time value
 */
 
-String *Item_func_maketime::val_str(String *str)
+String *Item_func_maketime::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
@@ -3160,12 +3140,12 @@ void Item_func_timestamp_diff::print(Str
 }
 
 
-String *Item_func_get_format::val_str(String *str)
+String *Item_func_get_format::val_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   const char *format_name;
   KNOWN_DATE_TIME_FORMAT *format;
-  String *val= args[0]->val_str(str);
+  String *val= args[0]->val_ascii(str);
   ulong val_len;
 
   if ((null_value= args[0]->null_value))
@@ -3184,7 +3164,7 @@ String *Item_func_get_format::val_str(St
 		      (const uchar *) format_name, val_len))
     {
       const char *format_str= get_date_time_format_str(format, type);
-      str->set(format_str, strlen(format_str), &my_charset_bin);
+      str->set(format_str, strlen(format_str), &my_charset_latin1);
       return str;
     }
   }

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2009-02-07 16:00:57 +0000
+++ b/sql/item_timefunc.h	2009-03-04 06:59:35 +0000
@@ -34,10 +34,7 @@ public:
   Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "period_add"; }
-  void fix_length_and_dec() 
-  { 
-    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(6); }
 };
 
 
@@ -47,11 +44,7 @@ public:
   Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "period_diff"; }
-  void fix_length_and_dec()
-  { 
-    decimals=0;
-    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(6); }
 };
 
 
@@ -61,12 +54,7 @@ public:
   Item_func_to_days(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "to_days"; }
-  void fix_length_and_dec() 
-  { 
-    decimals=0; 
-    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1; 
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(6); maybe_null= 1; }
   enum_monotonicity_info get_monotonicity_info() const;
   longlong val_int_endpoint(bool left_endp, bool *incl_endp);
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@@ -79,12 +67,7 @@ public:
   Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "dayofmonth"; }
-  void fix_length_and_dec() 
-  { 
-    decimals=0; 
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1; 
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -98,18 +81,12 @@ public:
   { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
   String *val_str(String *str) 
   {
-    str->set(val_int(), &my_charset_bin);
+    str->set(val_int(), collation.collation);
     return null_value ? 0 : str;
   }
   const char *func_name() const { return "month"; }
   enum Item_result result_type () const { return INT_RESULT; }
-  void fix_length_and_dec() 
-  { 
-    collation.set(&my_charset_bin);
-    decimals=0;
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1; 
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -133,12 +110,7 @@ public:
   Item_func_dayofyear(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "dayofyear"; }
-  void fix_length_and_dec() 
-  { 
-    decimals=0;
-    max_length=3*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1; 
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(3); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -149,12 +121,7 @@ public:
   Item_func_hour(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "hour"; }
-  void fix_length_and_dec()
-  {
-    decimals=0;
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -165,12 +132,7 @@ public:
   Item_func_minute(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "minute"; }
-  void fix_length_and_dec()
-  {
-    decimals=0;
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -181,12 +143,7 @@ public:
   Item_func_quarter(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "quarter"; }
-  void fix_length_and_dec()
-  { 
-     decimals=0;
-     max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
-     maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -197,12 +154,7 @@ public:
   Item_func_second(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "second"; }
-  void fix_length_and_dec() 
-  { 
-    decimals=0;
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -213,12 +165,7 @@ public:
   Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "week"; }
-  void fix_length_and_dec()
-  { 
-    decimals=0;
-    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(2); maybe_null= 1; }
 };
 
 class Item_func_yearweek :public Item_int_func
@@ -227,12 +174,7 @@ public:
   Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "yearweek"; }
-  void fix_length_and_dec()
-  { 
-    decimals=0;
-    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(6); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -245,12 +187,7 @@ public:
   const char *func_name() const { return "year"; }
   enum_monotonicity_info get_monotonicity_info() const;
   longlong val_int_endpoint(bool left_endp, bool *incl_endp);
-  void fix_length_and_dec()
-  { 
-    decimals=0;
-    max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(4); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -266,7 +203,7 @@ public:
   String *val_str(String *str)
   {
     DBUG_ASSERT(fixed == 1);
-    str->set(val_int(), &my_charset_bin);
+    str->set(val_int(), collation.collation);
     return null_value ? 0 : str;
   }
   const char *func_name() const
@@ -274,13 +211,7 @@ public:
      return (odbc_type ? "dayofweek" : "weekday");
   }
   enum Item_result result_type () const { return INT_RESULT; }
-  void fix_length_and_dec()
-  {
-    collation.set(&my_charset_bin);
-    decimals=0;
-    max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(1); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -305,11 +236,7 @@ public:
   Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "unix_timestamp"; }
-  void fix_length_and_dec()
-  {
-    decimals=0;
-    max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
 };
 
 
@@ -319,11 +246,7 @@ public:
   Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
   longlong val_int();
   const char *func_name() const { return "time_to_sec"; }
-  void fix_length_and_dec()
-  {
-    decimals=0;
-    max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(10); }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -332,23 +255,18 @@ public:
   This can't be a Item_str_func, because the val_real() functions are special
 */
 
-class Item_date :public Item_func
+class Item_date :public Item_str_ascii_func
 {
 public:
-  Item_date() :Item_func() {}
-  Item_date(Item *a) :Item_func(a) {}
+  Item_date() :Item_str_ascii_func() { }
+  Item_date(Item *a) :Item_str_ascii_func(a) { }
   enum Item_result result_type () const { return STRING_RESULT; }
   enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   longlong val_int();
   double val_real() { return val_real_from_decimal(); }
   const char *func_name() const { return "date"; }
-  void fix_length_and_dec()
-  { 
-    collation.set(&my_charset_bin);
-    decimals=0;
-    max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(MAX_DATE_WIDTH); }
   Field *tmp_table_field(TABLE *table)
   {
     return tmp_table_field_from_field_type(table, 0);
@@ -366,13 +284,13 @@ public:
 };
 
 
-class Item_date_func :public Item_str_func
+class Item_date_func :public Item_str_ascii_func
 {
 public:
-  Item_date_func() :Item_str_func() {}
-  Item_date_func(Item *a) :Item_str_func(a) {}
-  Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
-  Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
+  Item_date_func() :Item_str_ascii_func() {}
+  Item_date_func(Item *a) :Item_str_ascii_func(a) {}
+  Item_date_func(Item *a,Item *b) :Item_str_ascii_func(a,b) {}
+  Item_date_func(Item *a,Item *b, Item *c) :Item_str_ascii_func(a,b,c) {}
   enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
   Field *tmp_table_field(TABLE *table)
   {
@@ -392,19 +310,16 @@ public:
 };
 
 
-class Item_str_timefunc :public Item_str_func
+class Item_str_timefunc :public Item_str_ascii_func
 {
 public:
-  Item_str_timefunc() :Item_str_func() {}
-  Item_str_timefunc(Item *a) :Item_str_func(a) {}
-  Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
-  Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
+  Item_str_timefunc() :Item_str_ascii_func() {}
+  Item_str_timefunc(Item *a) :Item_str_ascii_func(a) {}
+  Item_str_timefunc(Item *a,Item *b) :Item_str_ascii_func(a,b) {}
+  Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_ascii_func(a, b ,c) {}
   enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
   void fix_length_and_dec()
-  {
-    decimals= DATETIME_DEC;
-    max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  { set_char_length_and_dec(MAX_TIME_WIDTH, DATETIME_DEC); }
   Field *tmp_table_field(TABLE *table)
   {
     return tmp_table_field_from_field_type(table, 0);
@@ -436,7 +351,7 @@ public:
   Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
   double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
   longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   void fix_length_and_dec();
   /* 
     Abstract method that defines which time zone is used for conversion.
@@ -477,7 +392,7 @@ class Item_func_curdate :public Item_dat
 public:
   Item_func_curdate() :Item_date() {}
   longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   void fix_length_and_dec();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
   virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
@@ -517,7 +432,7 @@ public:
   enum Item_result result_type () const { return STRING_RESULT; }
   longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
   int save_in_field(Field *to, bool no_conversions);
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   void fix_length_and_dec();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
   virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
@@ -560,7 +475,7 @@ public:
   double val_real();
   longlong val_int();
   int save_in_field(Field *to, bool no_conversions);
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   void fix_length_and_dec();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
   void update_used_tables()
@@ -604,7 +519,7 @@ class Item_func_from_unixtime :public It
  public:
   Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
   longlong val_int();
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "from_unixtime"; }
   void fix_length_and_dec();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
@@ -639,7 +554,7 @@ class Item_func_convert_tz :public Item_
   Item_func_convert_tz(Item *a, Item *b, Item *c):
     Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
   longlong val_int();
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "convert_tz"; }
   void fix_length_and_dec();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
@@ -657,13 +572,9 @@ public:
     return (double) Item_func_sec_to_time::val_int();
   }
   longlong val_int();
-  String *val_str(String *);
-  void fix_length_and_dec()
-  { 
-    Item_str_timefunc::fix_length_and_dec();
-    collation.set(&my_charset_bin);
-    maybe_null=1;
-  }
+  String *val_ascii(String *);
+  void fix_length_and_dec() 
+  { Item_str_timefunc::fix_length_and_dec(); maybe_null= 1; }
   const char *func_name() const { return "sec_to_time"; }
   bool result_as_longlong() { return TRUE; }
 };
@@ -679,7 +590,7 @@ public:
   const bool date_sub_interval; // keep it public
   Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
     :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
-  String *val_str(String *);
+  String *val_ascii(String *);
   const char *func_name() const { return "date_add_interval"; }
   void fix_length_and_dec();
   enum_field_types field_type() const { return cached_field_type; }
@@ -708,43 +619,7 @@ class Item_extract :public Item_int_func
 };
 
 
-class Item_typecast :public Item_str_func
-{
-public:
-  Item_typecast(Item *a) :Item_str_func(a) {}
-  String *val_str(String *a)
-  {
-    DBUG_ASSERT(fixed == 1);
-    String *tmp=args[0]->val_str(a);
-    null_value=args[0]->null_value;
-    if (tmp)
-      tmp->set_charset(collation.collation);
-    return tmp;
-  }
-  void fix_length_and_dec()
-  {
-    collation.set(&my_charset_bin);
-    max_length=args[0]->max_length;
-  }
-  virtual const char* cast_type() const= 0;
-  virtual void print(String *str, enum_query_type query_type);
-};
-
-
-class Item_typecast_maybe_null :public Item_typecast
-{
-public:
-  Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
-  void fix_length_and_dec()
-  {
-    collation.set(&my_charset_bin);
-    max_length=args[0]->max_length;
-    maybe_null= 1;
-  }
-};
-
-
-class Item_char_typecast :public Item_typecast
+class Item_char_typecast :public Item_str_func
 {
   int cast_length;
   CHARSET_INFO *cast_cs, *from_cs;
@@ -752,23 +627,31 @@ class Item_char_typecast :public Item_ty
   String tmp_value;
 public:
   Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
-    :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
+    :Item_str_func(a), cast_length(length_arg), cast_cs(cs_arg) {}
   enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
   bool eq(const Item *item, bool binary_cmp) const;
   const char *func_name() const { return "cast_as_char"; }
-  const char* cast_type() const { return "char"; };
   String *val_str(String *a);
   void fix_length_and_dec();
   virtual void print(String *str, enum_query_type query_type);
 };
 
 
-class Item_date_typecast :public Item_typecast_maybe_null
+class Item_typecast :public Item_str_ascii_func
+{
+public:
+  Item_typecast(Item *a) :Item_str_ascii_func(a) {}
+  virtual const char* cast_type() const= 0;
+  virtual void print(String *str, enum_query_type query_type);
+};
+
+
+class Item_date_typecast :public Item_typecast
 {
 public:
-  Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+  Item_date_typecast(Item *a) :Item_typecast(a) {}
   const char *func_name() const { return "cast_as_date"; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
   bool get_time(MYSQL_TIME *ltime);
   const char *cast_type() const { return "date"; }
@@ -777,12 +660,7 @@ public:
   {
     return tmp_table_field_from_field_type(table, 0);
   }  
-  void fix_length_and_dec()
-  {
-    collation.set(&my_charset_bin);
-    max_length= 10;
-    maybe_null= 1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(10); maybe_null= 1; }
   bool result_as_longlong() { return TRUE; }
   longlong val_int();
   double val_real() { return (double) val_int(); }
@@ -798,12 +676,12 @@ public:
 };
 
 
-class Item_time_typecast :public Item_typecast_maybe_null
+class Item_time_typecast :public Item_typecast
 {
 public:
-  Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+  Item_time_typecast(Item *a) :Item_typecast(a) {}
   const char *func_name() const { return "cast_as_time"; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   bool get_time(MYSQL_TIME *ltime);
   const char *cast_type() const { return "time"; }
   enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
@@ -823,15 +701,17 @@ public:
   {
     return save_time_in_field(field);
   }
+  void fix_length_and_dec()
+  { set_char_length_and_dec(args[0]->max_char_length()); maybe_null= 1; }
 };
 
 
-class Item_datetime_typecast :public Item_typecast_maybe_null
+class Item_datetime_typecast :public Item_typecast
 {
 public:
-  Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+  Item_datetime_typecast(Item *a) :Item_typecast(a) {}
   const char *func_name() const { return "cast_as_datetime"; }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *cast_type() const { return "datetime"; }
   enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
   Field *tmp_table_field(TABLE *table)
@@ -840,10 +720,8 @@ public:
   }
   void fix_length_and_dec()
   {
-    collation.set(&my_charset_bin);
     maybe_null= 1;
-    max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
-    decimals= DATETIME_DEC;
+    set_char_length_and_dec(MAX_DATETIME_FULL_WIDTH, DATETIME_DEC);
   }
   bool result_as_longlong() { return TRUE; }
   longlong val_int();
@@ -864,19 +742,16 @@ class Item_func_makedate :public Item_da
 {
 public:
   Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "makedate"; }
   enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
   void fix_length_and_dec()
-  { 
-    decimals=0;
-    max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  { set_char_length_and_dec(MAX_DATE_WIDTH); }
   longlong val_int();
 };
 
 
-class Item_func_add_time :public Item_str_func
+class Item_func_add_time :public Item_str_ascii_func
 {
   const bool is_date;
   int sign;
@@ -884,8 +759,8 @@ class Item_func_add_time :public Item_st
 
 public:
   Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
-    :Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
-  String *val_str(String *str);
+    :Item_str_ascii_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
+  String *val_ascii(String *str);
   enum_field_types field_type() const { return cached_field_type; }
   void fix_length_and_dec();
 
@@ -920,13 +795,10 @@ class Item_func_timediff :public Item_st
 public:
   Item_func_timediff(Item *a, Item *b)
     :Item_str_timefunc(a, b) {}
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "timediff"; }
   void fix_length_and_dec()
-  {
-    Item_str_timefunc::fix_length_and_dec();
-    maybe_null= 1;
-  }
+  { Item_str_timefunc::fix_length_and_dec(); maybe_null= 1; }
 };
 
 class Item_func_maketime :public Item_str_timefunc
@@ -937,7 +809,7 @@ public:
   {
     maybe_null= TRUE;
   }
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "maketime"; }
 };
 
@@ -947,11 +819,7 @@ public:
   Item_func_microsecond(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "microsecond"; }
-  void fix_length_and_dec() 
-  { 
-    decimals=0;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(21); maybe_null= 1; }
   bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 };
 
@@ -964,11 +832,7 @@ public:
     :Item_int_func(a,b), int_type(type_arg) {}
   const char *func_name() const { return "timestampdiff"; }
   longlong val_int();
-  void fix_length_and_dec()
-  {
-    decimals=0;
-    maybe_null=1;
-  }
+  void fix_length_and_dec() { set_char_length_and_dec(21); maybe_null= 1; }
   virtual void print(String *str, enum_query_type query_type);
 };
 
@@ -978,21 +842,17 @@ enum date_time_format
   USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT
 };
 
-class Item_func_get_format :public Item_str_func
+class Item_func_get_format :public Item_str_ascii_func
 {
 public:
   const timestamp_type type; // keep it public
   Item_func_get_format(timestamp_type type_arg, Item *a)
-    :Item_str_func(a), type(type_arg)
+    :Item_str_ascii_func(a), type(type_arg)
   {}
-  String *val_str(String *str);
+  String *val_ascii(String *str);
   const char *func_name() const { return "get_format"; }
   void fix_length_and_dec()
-  {
-    maybe_null= 1;
-    decimals=0;
-    max_length=17*MY_CHARSET_BIN_MB_MAXLEN;
-  }
+  { maybe_null= 1; set_char_length_and_dec(17); }
   virtual void print(String *str, enum_query_type query_type);
 };
 

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-02-11 12:11:20 +0000
+++ b/sql/mysql_priv.h	2009-03-04 06:59:35 +0000
@@ -788,6 +788,8 @@ typedef Comp_creator* (*chooser_compare_
 #include "item.h"
 extern my_decimal decimal_zero;
 
+bool str_set_decimal(my_decimal *val, String *str, CHARSET_INFO *cs);
+
 /* sql_parse.cc */
 void free_items(Item *item);
 void cleanup_items(Item *item);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-02-13 17:44:21 +0000
+++ b/sql/sql_select.cc	2009-03-04 06:59:35 +0000
@@ -13660,10 +13660,10 @@ static Field *create_tmp_field_from_item
       Field_long : make them Field_longlong.  
     */
     if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1))
-      new_field=new Field_longlong(item->max_length, maybe_null,
+      new_field=new Field_longlong(item->max_char_length(), maybe_null,
                                    item->name, item->unsigned_flag);
     else
-      new_field=new Field_long(item->max_length, maybe_null,
+      new_field=new Field_long(item->max_char_length(), maybe_null,
                                item->name, item->unsigned_flag);
     break;
   case STRING_RESULT:
@@ -13683,7 +13683,7 @@ static Field *create_tmp_field_from_item
       Make sure that the blob fits into a Field_varstring which has 
       2-byte lenght. 
     */
-    else if (item->max_length/item->collation.collation->mbmaxlen > 255 &&
+    else if (item->max_char_length() > 255 &&
              convert_blob_length <= Field_varstring::MAX_SIZE && 
              convert_blob_length)
       new_field= new Field_varstring(convert_blob_length, maybe_null,

=== modified file 'sql/time.cc'
--- a/sql/time.cc	2008-11-18 19:41:51 +0000
+++ b/sql/time.cc	2009-03-04 06:59:35 +0000
@@ -697,7 +697,7 @@ void make_time(const DATE_TIME_FORMAT *f
 {
   uint length= (uint) my_time_to_str(l_time, (char*) str->ptr());
   str->length(length);
-  str->set_charset(&my_charset_bin);
+  str->set_charset(&my_charset_latin1);
 }
 
 
@@ -706,7 +706,7 @@ void make_date(const DATE_TIME_FORMAT *f
 {
   uint length= (uint) my_date_to_str(l_time, (char*) str->ptr());
   str->length(length);
-  str->set_charset(&my_charset_bin);
+  str->set_charset(&my_charset_latin1);
 }
 
 
@@ -715,7 +715,7 @@ void make_datetime(const DATE_TIME_FORMA
 {
   uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr());
   str->length(length);
-  str->set_charset(&my_charset_bin);
+  str->set_charset(&my_charset_latin1);
 }
 
 

Thread
bzr commit into mysql-6.0 branch (bar:2701) WL#2649Alexander Barkov4 Mar
  • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Øystein Grøvlen24 Apr
    • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Alexander Barkov29 Apr
      • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Øystein Grøvlen5 May
        • WL#2649Alexander Barkov19 Jun
          • Re: WL#2649Øystein Grøvlen25 Jun
            • Re: WL#2649Alexander Barkov25 Jun
              • Re: WL#2649Øystein Grøvlen25 Jun
                • Re: WL#2649Peter Gulutzan29 Jun
                  • Re: WL#2649Øystein Grøvlen1 Jul
                    • Re: WL#2649Peter Gulutzan2 Jul
                      • Re: WL#2649Øystein Grøvlen3 Jul
                        • Re: WL#2649Peter Gulutzan15 Jul
                        • Re: WL#2649Alexander Barkov20 Aug
                        • Re: WL#2649Alexander Barkov20 Aug
                          • Re: WL#2649Øystein Grøvlen21 Aug
    • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Alexander Barkov5 May
      • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Alexander Barkov5 May
        • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Øystein Grøvlen6 May
      • Re: bzr commit into mysql-6.0 branch (bar:2701) WL#2649Øystein Grøvlen6 May