diff options
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/func_gconcat.result | 30 | ||||
-rw-r--r-- | mysql-test/r/func_str.result | 3 | ||||
-rw-r--r-- | mysql-test/t/func_gconcat.test | 35 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 6 | ||||
-rw-r--r-- | mysql-test/t/grant_cache.test | 3 |
5 files changed, 76 insertions, 1 deletions
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 0c8054c1f03..1ddbc18d965 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -321,3 +321,33 @@ HAVING LEFT(names, 1) ='J'; names John###Anna###Bill DROP TABLE t1; +CREATE TABLE t1 ( a int, b TEXT ); +INSERT INTO t1 VALUES (1,'First Row'), (2,'Second Row'); +SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a; +GROUP_CONCAT(b ORDER BY b) +First Row +Second Row +DROP TABLE t1; +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), +CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +a_id b_list +1 1,2,3 +2 4,5 +3 NULL +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID)); +INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ'); +CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC)); +INSERT INTO t2 VALUES (1,'A'),(1,'B'),(3,'F'); +SELECT t1.A_ID, GROUP_CONCAT(t2.B_DESC) AS B_DESC FROM t1 LEFT JOIN t2 ON t1.A_ID=t2.A_ID GROUP BY t1.A_ID ORDER BY t1.A_DESC; +A_ID B_DESC +1 A,B +2 NULL +3 F +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index e07ee4f0add..345832387bd 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -673,3 +673,6 @@ c1 c2 2147483647 4294967295 -2147483648 0 drop table t1; +select left(1234, 3) + 0; +left(1234, 3) + 0 +123 diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 62343fa2af8..d27e5d7d77f 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -201,3 +201,38 @@ SELECT GROUP_CONCAT(a SEPARATOR '||') AS names FROM t1 SELECT GROUP_CONCAT(a SEPARATOR '###') AS names FROM t1 HAVING LEFT(names, 1) ='J'; DROP TABLE t1; + +# +# check blobs +# + +CREATE TABLE t1 ( a int, b TEXT ); +INSERT INTO t1 VALUES (1,'First Row'), (2,'Second Row'); +SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a; +DROP TABLE t1; + +# +# check null values #1 +# + +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), + CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +DROP TABLE t2; +DROP TABLE t1; + +# +# check null values #2 +# + +CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID)); +INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ'); +CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC)); +INSERT INTO t2 VALUES (1,'A'),(1,'B'),(3,'F'); +SELECT t1.A_ID, GROUP_CONCAT(t2.B_DESC) AS B_DESC FROM t1 LEFT JOIN t2 ON t1.A_ID=t2.A_ID GROUP BY t1.A_ID ORDER BY t1.A_DESC; +DROP TABLE t1; +DROP TABLE t2; + diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 61d0326f7dd..e7852df40b3 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -402,3 +402,9 @@ insert into t1 values ('-21474836461','-21474836461'); show warnings; select * from t1; drop table t1; + +# +# Bug #4878: LEFT() in integer/float context +# + +select left(1234, 3) + 0; diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test index a82cd732802..e5bde977bb7 100644 --- a/mysql-test/t/grant_cache.test +++ b/mysql-test/t/grant_cache.test @@ -67,7 +67,8 @@ show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; show status like "Qcache_not_cached"; -connect (unkuser,localhost,,,,$MASTER_MYPORT,master.sock); +# Don't use '' as user because it will pick Unix login +connect (unkuser,localhost,unkuser,,,$MASTER_MYPORT,master.sock); connection unkuser; show grants for current_user(); |