mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge sanja.is.com.ua:/home/bell/mysql/bk/work-top3-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-simple_in-4.1
This commit is contained in:
@ -281,3 +281,42 @@ ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set koi8r);
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>');
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) binary;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a varchar(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a text character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
drop table t1;
|
||||
|
@ -71,3 +71,24 @@ orange
|
||||
yellow
|
||||
green
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`COALESCE(1)` int(1) NOT NULL default '0',
|
||||
`COALESCE(1.0)` double(3,1) NOT NULL default '0.0',
|
||||
`COALESCE('a')` char(1) NOT NULL default '',
|
||||
`COALESCE(1,1.0)` double(3,1) NOT NULL default '0.0',
|
||||
`COALESCE(1,'1')` char(1) NOT NULL default '',
|
||||
`COALESCE(1.1,'1')` char(3) NOT NULL default '',
|
||||
`COALESCE('a' COLLATE latin1_bin,'b')` char(1) character set latin1 collate latin1_bin NOT NULL default ''
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
|
@ -111,3 +111,35 @@ id
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a char(1) character set latin1 collate latin1_general_ci,
|
||||
b char(1) character set latin1 collate latin1_swedish_ci,
|
||||
c char(1) character set latin1 collate latin1_danish_ci
|
||||
);
|
||||
insert into t1 values ('A','B','C');
|
||||
insert into t1 values ('a','c','c');
|
||||
select * from t1 where a in (b);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation ' IN '
|
||||
select * from t1 where a in (b,c);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
||||
select * from t1 where 'a' in (a,b,c);
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
select * from t1 where 'a' in (a);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where a in ('a');
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
||||
a b c
|
||||
a c c
|
||||
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
a b c
|
||||
a c c
|
||||
drop table t1;
|
||||
|
@ -297,9 +297,9 @@ select FIELD('b','A' COLLATE latin1_bin,'B');
|
||||
FIELD('b','A' COLLATE latin1_bin,'B')
|
||||
0
|
||||
select FIELD(_latin2'b','A','B');
|
||||
ERROR HY000: Illegal mix of collations for operation 'field'
|
||||
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
|
||||
select FIELD('b',_latin2'A','B');
|
||||
ERROR HY000: Illegal mix of collations for operation 'field'
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
|
||||
select FIELD('b',_latin2'A','B',1);
|
||||
FIELD('b',_latin2'A','B',1)
|
||||
1
|
||||
@ -363,15 +363,15 @@ select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
|
||||
_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin)
|
||||
0
|
||||
select _latin2'B' in (_latin1'a',_latin1'b');
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
|
||||
select _latin1'B' in (_latin2'a',_latin1'b');
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
|
||||
select _latin1'B' in (_latin1'a',_latin2'b');
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN '
|
||||
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
|
||||
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN '
|
||||
select collation(bin(130)), coercibility(bin(130));
|
||||
collation(bin(130)) coercibility(bin(130))
|
||||
latin1_swedish_ci 3
|
||||
@ -532,3 +532,24 @@ t1 CREATE TABLE `t1` (
|
||||
`replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default ''
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
drop table t1;
|
||||
select SUBSTR('abcdefg',3,2);
|
||||
SUBSTR('abcdefg',3,2)
|
||||
cd
|
||||
select SUBSTRING('abcdefg',3,2);
|
||||
SUBSTRING('abcdefg',3,2)
|
||||
cd
|
||||
select SUBSTR('abcdefg',-3,2) FROM DUAL;
|
||||
SUBSTR('abcdefg',-3,2)
|
||||
ef
|
||||
select SUBSTR('abcdefg',-1,5) FROM DUAL;
|
||||
SUBSTR('abcdefg',-1,5)
|
||||
g
|
||||
select SUBSTR('abcdefg',0,0) FROM DUAL;
|
||||
SUBSTR('abcdefg',0,0)
|
||||
|
||||
select SUBSTR('abcdefg',-1,-1) FROM DUAL;
|
||||
SUBSTR('abcdefg',-1,-1)
|
||||
|
||||
select SUBSTR('abcdefg',1,-1) FROM DUAL;
|
||||
SUBSTR('abcdefg',1,-1)
|
||||
|
||||
|
@ -10,22 +10,22 @@ select * from t1;
|
||||
f1
|
||||
5
|
||||
delete from t1;
|
||||
Access denied for user: 'ssl_user1@localhost' to database 'test'
|
||||
ERROR 42000: Access denied for user: 'ssl_user1@localhost' to database 'test'
|
||||
select * from t1;
|
||||
f1
|
||||
5
|
||||
delete from t1;
|
||||
Access denied for user: 'ssl_user2@localhost' to database 'test'
|
||||
ERROR 42000: Access denied for user: 'ssl_user2@localhost' to database 'test'
|
||||
select * from t1;
|
||||
f1
|
||||
5
|
||||
delete from t1;
|
||||
Access denied for user: 'ssl_user3@localhost' to database 'test'
|
||||
ERROR 42000: Access denied for user: 'ssl_user3@localhost' to database 'test'
|
||||
select * from t1;
|
||||
f1
|
||||
5
|
||||
delete from t1;
|
||||
Access denied for user: 'ssl_user4@localhost' to database 'test'
|
||||
ERROR 42000: Access denied for user: 'ssl_user4@localhost' to database 'test'
|
||||
delete from mysql.user where user='ssl_user%';
|
||||
delete from mysql.db where user='ssl_user%';
|
||||
flush privileges;
|
||||
|
@ -144,3 +144,30 @@ ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test that data get converted when character set is changed
|
||||
# Test that data doesn't get converted when src or dst is BINARY/BLOB
|
||||
#
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set koi8r);
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>');
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) binary;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a varchar(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a text character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
|
||||
drop table t1;
|
||||
|
@ -41,3 +41,25 @@ create table t1 (row int not null, col int not null, val varchar(255) not null);
|
||||
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
|
||||
select max(case col when 1 then val else null end) as color from t1 group by row;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# COALESCE is a CASE abbrevation:
|
||||
#
|
||||
# COALESCE(v1,v2) == CASE WHEN v1 IS NOT NULL THEN v1 ELSE v2 END
|
||||
#
|
||||
# COALESCE(V1, V2, . . . ,Vn ) =
|
||||
# CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2, . . . ,Vn) END
|
||||
#
|
||||
# Check COALESCE argument types aggregation
|
||||
|
||||
SET NAMES latin1;
|
||||
--error 1265
|
||||
CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
|
||||
--error 1265
|
||||
CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
|
||||
CREATE TABLE t1 SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -54,3 +54,22 @@ insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
select * from t1 where id in (2,5,9);
|
||||
drop table t1;
|
||||
|
||||
create table t1 (
|
||||
a char(1) character set latin1 collate latin1_general_ci,
|
||||
b char(1) character set latin1 collate latin1_swedish_ci,
|
||||
c char(1) character set latin1 collate latin1_danish_ci
|
||||
);
|
||||
insert into t1 values ('A','B','C');
|
||||
insert into t1 values ('a','c','c');
|
||||
--error 1265
|
||||
select * from t1 where a in (b);
|
||||
--error 1268
|
||||
select * from t1 where a in (b,c);
|
||||
--error 1269
|
||||
select * from t1 where 'a' in (a,b,c);
|
||||
select * from t1 where 'a' in (a);
|
||||
select * from t1 where a in ('a');
|
||||
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
||||
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
||||
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
drop table t1;
|
||||
|
@ -167,9 +167,9 @@ select FIELD('b','A','B');
|
||||
select FIELD('B','A','B');
|
||||
select FIELD('b' COLLATE latin1_bin,'A','B');
|
||||
select FIELD('b','A' COLLATE latin1_bin,'B');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select FIELD(_latin2'b','A','B');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select FIELD('b',_latin2'A','B');
|
||||
select FIELD('b',_latin2'A','B',1);
|
||||
|
||||
@ -217,15 +217,15 @@ select _latin1'B' in (_latin1'a',_latin1'b');
|
||||
select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
|
||||
select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
|
||||
select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
|
||||
--error 1269
|
||||
--error 1268
|
||||
select _latin2'B' in (_latin1'a',_latin1'b');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select _latin1'B' in (_latin2'a',_latin1'b');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select _latin1'B' in (_latin1'a',_latin2'b');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
|
||||
--error 1269
|
||||
--error 1268
|
||||
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
|
||||
|
||||
select collation(bin(130)), coercibility(bin(130));
|
||||
@ -294,3 +294,14 @@ select
|
||||
;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# test for SUBSTR
|
||||
#
|
||||
select SUBSTR('abcdefg',3,2);
|
||||
select SUBSTRING('abcdefg',3,2);
|
||||
select SUBSTR('abcdefg',-3,2) FROM DUAL;
|
||||
select SUBSTR('abcdefg',-1,5) FROM DUAL;
|
||||
select SUBSTR('abcdefg',0,0) FROM DUAL;
|
||||
select SUBSTR('abcdefg',-1,-1) FROM DUAL;
|
||||
select SUBSTR('abcdefg',1,-1) FROM DUAL;
|
||||
|
@ -2,7 +2,9 @@
|
||||
# Use mysql-test-run with --with-openssl option.
|
||||
-- source include/have_openssl_1.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(f1 int);
|
||||
insert into t1 values (5);
|
||||
|
||||
|
Reference in New Issue
Block a user