Commit f90caa58 authored by bar@mysql.com's avatar bar@mysql.com

- VARCHAR(n) with binary character set is now displayed as VARBINARY(N).

- CREATE TABLE t1 SELECT BINARY 'literal'
  now creates a VARBINARY() column, not a BINARY().
parent f96a9a7a
...@@ -91,11 +91,11 @@ ab a ab a a ...@@ -91,11 +91,11 @@ ab a ab a a
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` varchar(2) NOT NULL default '', `c1` varbinary(2) NOT NULL default '',
`c2` varchar(2) NOT NULL default '', `c2` varbinary(2) NOT NULL default '',
`c3` varchar(2) NOT NULL default '', `c3` varbinary(2) NOT NULL default '',
`c4` varchar(2) NOT NULL default '', `c4` varbinary(2) NOT NULL default '',
`c5` varchar(2) NOT NULL default '' `c5` varbinary(2) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select select
......
...@@ -124,7 +124,7 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); ...@@ -124,7 +124,7 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")` binary(10) default NULL `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` varbinary(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1; select * from t1;
date_format("2004-01-19 10:10:10", "%Y-%m-%d") date_format("2004-01-19 10:10:10", "%Y-%m-%d")
......
...@@ -611,7 +611,7 @@ t1 CREATE TABLE `t1` ( ...@@ -611,7 +611,7 @@ t1 CREATE TABLE `t1` (
`substring(_latin2'ab',1)` varchar(2) character set latin2 NOT NULL default '', `substring(_latin2'ab',1)` varchar(2) character set latin2 NOT NULL default '',
`insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) character set latin2 NOT NULL default '', `insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) character set latin2 NOT NULL default '',
`replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) character set latin2 NOT NULL default '', `replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) character set latin2 NOT NULL default '',
`encode('abcd','ab')` binary(4) NOT NULL default '' `encode('abcd','ab')` varbinary(4) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select SUBSTR('abcdefg',3,2); select SUBSTR('abcdefg',3,2);
......
...@@ -1775,7 +1775,7 @@ t5 CREATE TABLE `t5` ( ...@@ -1775,7 +1775,7 @@ t5 CREATE TABLE `t5` (
`param03` double default NULL, `param03` double default NULL,
`const04` varchar(3) NOT NULL default '', `const04` varchar(3) NOT NULL default '',
`param04` longtext, `param04` longtext,
`const05` binary(3) NOT NULL default '', `const05` varbinary(3) NOT NULL default '',
`param05` longblob, `param05` longblob,
`const06` varchar(10) NOT NULL default '', `const06` varchar(10) NOT NULL default '',
`param06` longtext, `param06` longtext,
......
...@@ -1758,7 +1758,7 @@ t5 CREATE TABLE `t5` ( ...@@ -1758,7 +1758,7 @@ t5 CREATE TABLE `t5` (
`param03` double default NULL, `param03` double default NULL,
`const04` varchar(3) NOT NULL default '', `const04` varchar(3) NOT NULL default '',
`param04` longtext, `param04` longtext,
`const05` binary(3) NOT NULL default '', `const05` varbinary(3) NOT NULL default '',
`param05` longblob, `param05` longblob,
`const06` varchar(10) NOT NULL default '', `const06` varchar(10) NOT NULL default '',
`param06` longtext, `param06` longtext,
......
...@@ -1759,7 +1759,7 @@ t5 CREATE TABLE `t5` ( ...@@ -1759,7 +1759,7 @@ t5 CREATE TABLE `t5` (
`param03` double default NULL, `param03` double default NULL,
`const04` varchar(3) NOT NULL default '', `const04` varchar(3) NOT NULL default '',
`param04` longtext, `param04` longtext,
`const05` binary(3) NOT NULL default '', `const05` varbinary(3) NOT NULL default '',
`param05` longblob, `param05` longblob,
`const06` varchar(10) NOT NULL default '', `const06` varchar(10) NOT NULL default '',
`param06` longtext, `param06` longtext,
......
...@@ -1758,7 +1758,7 @@ t5 CREATE TABLE `t5` ( ...@@ -1758,7 +1758,7 @@ t5 CREATE TABLE `t5` (
`param03` double default NULL, `param03` double default NULL,
`const04` varchar(3) NOT NULL default '', `const04` varchar(3) NOT NULL default '',
`param04` longtext, `param04` longtext,
`const05` binary(3) NOT NULL default '', `const05` varbinary(3) NOT NULL default '',
`param05` longblob, `param05` longblob,
`const06` varchar(10) NOT NULL default '', `const06` varchar(10) NOT NULL default '',
`param06` longtext, `param06` longtext,
......
...@@ -272,7 +272,7 @@ auto bigint(17) unsigned NULL PRI 0 select,insert,update,references ...@@ -272,7 +272,7 @@ auto bigint(17) unsigned NULL PRI 0 select,insert,update,references
t1 bigint(1) NULL 0 select,insert,update,references t1 bigint(1) NULL 0 select,insert,update,references
t2 varchar(1) latin1_swedish_ci select,insert,update,references t2 varchar(1) latin1_swedish_ci select,insert,update,references
t3 varchar(256) latin1_swedish_ci select,insert,update,references t3 varchar(256) latin1_swedish_ci select,insert,update,references
t4 varchar(256) NULL select,insert,update,references t4 varbinary(256) NULL select,insert,update,references
t5 longtext latin1_swedish_ci select,insert,update,references t5 longtext latin1_swedish_ci select,insert,update,references
t6 longblob NULL select,insert,update,references t6 longblob NULL select,insert,update,references
t7 char(0) latin1_swedish_ci select,insert,update,references t7 char(0) latin1_swedish_ci select,insert,update,references
......
...@@ -655,7 +655,7 @@ f ...@@ -655,7 +655,7 @@ f
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`f` binary(24) default NULL `f` varbinary(24) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 SELECT y from t2 UNION select da from t2; create table t1 SELECT y from t2 UNION select da from t2;
...@@ -666,7 +666,7 @@ y ...@@ -666,7 +666,7 @@ y
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`y` binary(10) default NULL `y` varbinary(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 SELECT y from t2 UNION select dt from t2; create table t1 SELECT y from t2 UNION select dt from t2;
...@@ -677,7 +677,7 @@ y ...@@ -677,7 +677,7 @@ y
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`y` binary(19) default NULL `y` varbinary(19) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 SELECT da from t2 UNION select dt from t2; create table t1 SELECT da from t2 UNION select dt from t2;
...@@ -699,7 +699,7 @@ testc ...@@ -699,7 +699,7 @@ testc
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`dt` binary(19) default NULL `dt` varbinary(19) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 SELECT dt from t2 UNION select sv from t2; create table t1 SELECT dt from t2 UNION select sv from t2;
...@@ -710,7 +710,7 @@ testv ...@@ -710,7 +710,7 @@ testv
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`dt` binary(19) default NULL `dt` varbinary(19) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 SELECT sc from t2 UNION select sv from t2; create table t1 SELECT sc from t2 UNION select sv from t2;
......
...@@ -4778,11 +4778,18 @@ void Field_varstring::sort_string(char *to,uint length) ...@@ -4778,11 +4778,18 @@ void Field_varstring::sort_string(char *to,uint length)
void Field_varstring::sql_type(String &res) const void Field_varstring::sql_type(String &res) const
{ {
THD *thd= table->in_use;
CHARSET_INFO *cs=res.charset(); CHARSET_INFO *cs=res.charset();
ulong length= cs->cset->snprintf(cs,(char*) res.ptr(), ulong length;
res.alloced_length(),"varchar(%u)",
field_length / charset()->mbmaxlen); length= cs->cset->snprintf(cs,(char*) res.ptr(),
res.alloced_length(), "%s(%d)",
(has_charset() ? "varchar" : "varbinary"),
(int) field_length / charset()->mbmaxlen);
res.length(length); res.length(length);
if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) &&
has_charset() && (charset()->state & MY_CS_BINSORT))
res.append(" binary");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment