mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Fixed compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length myisam/myisampack.c: Indentation cleanup mysql-test/r/analyse.result: Update results for new varchar handling mysql-test/r/case.result: Update results for new varchar handling mysql-test/r/cast.result: Update results for new varchar handling mysql-test/r/create.result: Update results for new varchar handling mysql-test/r/ctype_mb.result: Update results for new varchar handling mysql-test/r/ctype_ucs.result: Update results for new varchar handling mysql-test/r/ctype_utf8.result: Update results for new varchar handling mysql-test/r/func_group.result: Update results for new varchar handling mysql-test/r/func_str.result: Update results for new varchar handling mysql-test/r/func_system.result: Update results for new varchar handling mysql-test/r/heap.result: Update results for new varchar handling mysql-test/r/heap_hash.result: Update results for new varchar handling mysql-test/r/information_schema.result: Update results for new varchar handling mysql-test/r/metadata.result: Update results for new varchar handling mysql-test/r/null.result: Update results for new varchar handling mysql-test/r/ps_2myisam.result: Update results for new varchar handling mysql-test/r/ps_3innodb.result: Update results for new varchar handling mysql-test/r/ps_4heap.result: Update results for new varchar handling mysql-test/r/ps_5merge.result: Update results for new varchar handling mysql-test/r/ps_6bdb.result: Update results for new varchar handling mysql-test/r/subselect.result: Update results for new varchar handling mysql-test/r/type_ranges.result: Update results for new varchar handling mysql-test/r/union.result: Update results for new varchar handling mysql-test/t/heap.test: Update results for new varchar handling mysql-test/t/type_ranges.test: Added extra test to test generated type for string functions sql/field.cc: Update results for new varchar handling sql/field.h: Update results for new varchar handling We have to use orig_table instead of table as 'table' may point to a new field in the created table sql/field_conv.cc: Update results for new varchar handling sql/ha_heap.cc: Indentation fixes sql/ha_innodb.cc: Update results for new varchar handling sql/item.cc: Update results for new varchar handling Remove compiler warnings String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item.h: Update results for new varchar handling sql/item_func.cc: Update results for new varchar handling String results in CREATE ... SELECT are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/item_func.h: ANALYZE now return VARCHAR columns sql/procedure.h: Update results for new varchar handling sql/sql_acl.cc: After merge fixes sql/sql_select.cc: Update results for new varchar handling String results in temporary tables are now created as CHAR(0), VARCHAR(X) or TEXT() depending on item->max_length sql/sql_show.cc: After merge fixes sql/sql_table.cc: After merge fixes strings/ctype-tis620.c: After merge fixes tests/client_test.c: Fixed results, as in MySQL 5.0 strings in CREATE ... SELECT are creates VARCHAR columns
181 lines
5.8 KiB
Plaintext
181 lines
5.8 KiB
Plaintext
select CAST(1-2 AS UNSIGNED);
|
||
CAST(1-2 AS UNSIGNED)
|
||
18446744073709551615
|
||
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
|
||
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
|
||
-1
|
||
select CONVERT('-1',UNSIGNED);
|
||
CONVERT('-1',UNSIGNED)
|
||
18446744073709551615
|
||
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
|
||
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
|
||
18446744073709551611 18446744073709551611
|
||
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
|
||
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
|
||
18446744073709551610 18446744073709551612
|
||
select ~5, cast(~5 as signed);
|
||
~5 cast(~5 as signed)
|
||
18446744073709551610 -6
|
||
explain extended select ~5, cast(~5 as signed);
|
||
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
|
||
Warnings:
|
||
Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
|
||
select cast(5 as unsigned) -6.0;
|
||
cast(5 as unsigned) -6.0
|
||
-1.0
|
||
select cast(NULL as signed), cast(1/0 as signed);
|
||
cast(NULL as signed) cast(1/0 as signed)
|
||
NULL NULL
|
||
select cast(NULL as unsigned), cast(1/0 as unsigned);
|
||
cast(NULL as unsigned) cast(1/0 as unsigned)
|
||
NULL NULL
|
||
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
|
||
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
|
||
0 1
|
||
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
|
||
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
|
||
2001-01-01 2001-01-01 00:00:00
|
||
select cast("1:2:3" as TIME);
|
||
cast("1:2:3" as TIME)
|
||
01:02:03
|
||
select CONVERT("2004-01-22 21:45:33",DATE);
|
||
CONVERT("2004-01-22 21:45:33",DATE)
|
||
2004-01-22
|
||
select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
|
||
CONVERT(DATE "2004-01-22 21:45:33" USING latin1)
|
||
2004-01-22 21:45:33
|
||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
|
||
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
|
||
2004-01-22 21:45:33
|
||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
|
||
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
|
||
2004
|
||
select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
|
||
CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
|
||
2004
|
||
select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
|
||
CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
|
||
2004
|
||
set names binary;
|
||
select cast(_latin1'test' as char character set latin2);
|
||
cast(_latin1'test' as char character set latin2)
|
||
test
|
||
select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251);
|
||
cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251)
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
create table t1 select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251) as t;
|
||
show create table t1;
|
||
Table Create Table
|
||
t1 CREATE TABLE `t1` (
|
||
`t` varchar(4) character set cp1251 NOT NULL default ''
|
||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||
drop table t1;
|
||
select
|
||
cast(_latin1'ab' AS char) as c1,
|
||
cast(_latin1'a ' AS char) as c2,
|
||
cast(_latin1'abc' AS char(2)) as c3,
|
||
cast(_latin1'a ' AS char(2)) as c4,
|
||
cast(_latin1'a' AS char(2)) as c5;
|
||
c1 c2 c3 c4 c5
|
||
ab a ab a a
|
||
create table t1 select
|
||
cast(_latin1'ab' AS char) as c1,
|
||
cast(_latin1'a ' AS char) as c2,
|
||
cast(_latin1'abc' AS char(2)) as c3,
|
||
cast(_latin1'a ' AS char(2)) as c4,
|
||
cast(_latin1'a' AS char(2)) as c5;
|
||
select * from t1;
|
||
c1 c2 c3 c4 c5
|
||
ab a ab a a
|
||
show create table t1;
|
||
Table Create Table
|
||
t1 CREATE TABLE `t1` (
|
||
`c1` varchar(2) NOT NULL default '',
|
||
`c2` varchar(2) NOT NULL default '',
|
||
`c3` varchar(2) NOT NULL default '',
|
||
`c4` varchar(2) NOT NULL default '',
|
||
`c5` varchar(2) NOT NULL default ''
|
||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||
drop table t1;
|
||
select
|
||
cast(_koi8r'<27><>' AS nchar) as c1,
|
||
cast(_koi8r'<27> ' AS nchar) as c2,
|
||
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
||
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
||
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
||
c1 c2 c3 c4 c5
|
||
фг ф фг ф ф
|
||
create table t1 select
|
||
cast(_koi8r'<27><>' AS nchar) as c1,
|
||
cast(_koi8r'<27> ' AS nchar) as c2,
|
||
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
||
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
||
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
||
select * from t1;
|
||
c1 c2 c3 c4 c5
|
||
фг ф фг ф ф
|
||
show create table t1;
|
||
Table Create Table
|
||
t1 CREATE TABLE `t1` (
|
||
`c1` varchar(2) character set utf8 NOT NULL default '',
|
||
`c2` varchar(2) character set utf8 NOT NULL default '',
|
||
`c3` varchar(2) character set utf8 NOT NULL default '',
|
||
`c4` varchar(2) character set utf8 NOT NULL default '',
|
||
`c5` varchar(2) character set utf8 NOT NULL default ''
|
||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||
drop table t1;
|
||
create table t1 (a binary(10), b char(10) character set koi8r);
|
||
insert into t1 values (_binary'<27><><EFBFBD><EFBFBD>',_binary'<27><><EFBFBD><EFBFBD>');
|
||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||
a b cast(a as char character set cp1251) cast(b as binary)
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||
set names koi8r;
|
||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||
a b cast(a as char character set cp1251) cast(b as binary)
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||
set names cp1251;
|
||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||
a b cast(a as char character set cp1251) cast(b as binary)
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
||
drop table t1;
|
||
set names binary;
|
||
select cast("2001-1-1" as date) = "2001-01-01";
|
||
cast("2001-1-1" as date) = "2001-01-01"
|
||
1
|
||
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
|
||
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
||
1
|
||
select cast("1:2:3" as TIME) = "1:02:03";
|
||
cast("1:2:3" as TIME) = "1:02:03"
|
||
0
|
||
select cast(NULL as DATE);
|
||
cast(NULL as DATE)
|
||
NULL
|
||
select cast(NULL as BINARY);
|
||
cast(NULL as BINARY)
|
||
NULL
|
||
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
||
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
||
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
||
a CAST(a AS CHAR)
|
||
aac aac
|
||
aab aab
|
||
aaa aaa
|
||
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
||
a CAST(a AS CHAR(3))
|
||
aac aac
|
||
aab aab
|
||
aaa aaa
|
||
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
||
a CAST(a AS UNSIGNED)
|
||
aaa 3
|
||
aab 2
|
||
aac 1
|
||
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
||
a CAST(a AS CHAR(2))
|
||
aaa aa
|
||
aab aa
|
||
aac aa
|
||
DROP TABLE t1;
|