diff options
author | unknown <monty@mysql.com> | 2005-07-28 16:10:14 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-07-28 16:10:14 +0300 |
commit | 79f75d8fad96e7b1da588eb850a25f9e9697ac2e (patch) | |
tree | af22629d2c36ae4196e6f23584c4cecc393b874e /mysql-test | |
parent | 520ebda4f22a4471ddedddf1a63561787f31c409 (diff) | |
download | mariadb-git-79f75d8fad96e7b1da588eb850a25f9e9697ac2e.tar.gz |
Cleanups during review of new code
Ensure mysql_close() is called if mysql_set_character_set() fails
libmysql/libmysql.c:
Indentation cleanup
mysql-test/r/select.result:
Fix bad merge & align code with 4.1
mysql-test/r/type_newdecimal.result:
Added test of extreme case
mysql-test/t/select.test:
Fix bad merge & align code with 4.1
mysql-test/t/type_newdecimal.test:
Added test of extreme case
mysys/charset.c:
Removed not used variable
mysys/default.c:
Simplify code
sql-common/client.c:
Ensure mysql_close() is called if mysql_set_character_set() fails
sql/log.cc:
strmov(strmov()) -> strxmov()
sql/sp.cc:
Indentation fixes
sql/sql_acl.cc:
Indentation fixes
sql/sql_base.cc:
Added commments
Moved variable to inner block
sql/sql_show.cc:
Simple optimization (removed loop variable)
sql/sql_trigger.cc:
strmov(strmov()) -> strxmov()
strings/decimal.c:
Indentation fixes
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/select.result | 231 | ||||
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 7 | ||||
-rw-r--r-- | mysql-test/t/select.test | 206 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 4 |
4 files changed, 192 insertions, 256 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 14c45270b04..a0f6bb7084f 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2492,6 +2492,99 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid id name gid uid ident level 1 fs NULL NULL 0 READ drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +explain select * from t2 where a > -1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +0 +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +DROP TABLE t1; CREATE TABLE t1 ( city char(30) ); INSERT INTO t1 VALUES ('London'); INSERT INTO t1 VALUES ('Paris'); @@ -2579,25 +2672,6 @@ K2C4 K4N4 F2I4 WART 0100 1 WART 0200 1 WART 0300 3 -select found_rows(); -found_rows() -3 -select count(*) from t1; -count(*) -15 -select found_rows(); -found_rows() -1 -select count(*) from t1 limit 2,3; -count(*) -select found_rows(); -found_rows() -0 -select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; -count(*) -select found_rows(); -found_rows() -1 DROP TABLE t1; CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); @@ -2612,51 +2686,6 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ref a a 23 test.t1.a 2 DROP TABLE t1, t2; -CREATE TABLE t1 ( city char(30) ); -INSERT INTO t1 VALUES ('London'); -INSERT INTO t1 VALUES ('Paris'); -SELECT * FROM t1 WHERE city='London'; -city -London -SELECT * FROM t1 WHERE city='london'; -city -London -EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -SELECT * FROM t1 WHERE city='London' AND city='london'; -city -London -EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -city -London -DROP TABLE t1; -create table t1 (a int(11) unsigned, b int(11) unsigned); -insert into t1 values (1,0), (1,1), (1,2); -select a-b from t1 order by 1; -a-b -0 -1 -18446744073709551615 -select a-b , (a-b < 0) from t1 order by 1; -a-b (a-b < 0) -0 0 -1 0 -18446744073709551615 0 -select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; -d (a-b >= 0) b -1 1 0 -0 1 1 -18446744073709551615 1 2 -select cast((a - b) as unsigned) from t1 order by 1; -cast((a - b) as unsigned) -0 -1 -18446744073709551615 -drop table t1; create table t1 (a int, b int); create table t2 like t1; select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; @@ -2730,77 +2759,3 @@ DROP TABLE t1,t2; select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 16 16 2 2 -CREATE TABLE t1 ( -acct_id int(11) NOT NULL default '0', -profile_id smallint(6) default NULL, -UNIQUE KEY t1$acct_id (acct_id), -KEY t1$profile_id (profile_id) -); -INSERT INTO t1 VALUES (132,17),(133,18); -CREATE TABLE t2 ( -profile_id smallint(6) default NULL, -queue_id int(11) default NULL, -seq int(11) default NULL, -KEY t2$queue_id (queue_id) -); -INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); -CREATE TABLE t3 ( -id int(11) NOT NULL default '0', -qtype int(11) default NULL, -seq int(11) default NULL, -warn_lvl int(11) default NULL, -crit_lvl int(11) default NULL, -rr1 tinyint(4) NOT NULL default '0', -rr2 int(11) default NULL, -default_queue tinyint(4) NOT NULL default '0', -KEY t3$qtype (qtype), -KEY t3$id (id) -); -INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), -(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); -SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q -WHERE -(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND -(pq.queue_id = q.id) AND (q.rr1 <> 1); -COUNT(*) -4 -drop table t1,t2,t3; -create table t1 (f1 int); -insert into t1 values (1),(NULL); -create table t2 (f2 int, f3 int, f4 int); -create index idx1 on t2 (f4); -insert into t2 values (1,2,3),(2,4,6); -select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) -from t2 C where A.f4 = C.f4) or A.f3 IS NULL; -f2 -1 -NULL -drop table t1,t2; -create table t2 (a tinyint unsigned); -create index t2i on t2(a); -insert into t2 values (0), (254), (255); -explain select * from t2 where a > -1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index -select * from t2 where a > -1; -a -0 -254 -255 -drop table t2; -CREATE TABLE t1 (a int, b int, c int); -INSERT INTO t1 -SELECT 50, 3, 3 FROM DUAL -WHERE NOT EXISTS -(SELECT * FROM t1 WHERE a = 50 AND b = 3); -SELECT * FROM t1; -a b c -50 3 3 -INSERT INTO t1 -SELECT 50, 3, 3 FROM DUAL -WHERE NOT EXISTS -(SELECT * FROM t1 WHERE a = 50 AND b = 3); -SELECT * FROM t1; -a b c -50 3 3 -DROP TABLE t1; diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index c1039189a43..1dd1142aea8 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -946,6 +946,13 @@ t1 CREATE TABLE `t1` ( `sl` decimal(5,5) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 (sl decimal(65, 30)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sl` decimal(65,30) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; create table t1 ( f1 decimal unsigned not null default 17.49, f2 decimal unsigned not null default 17.68, diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index ef26712af06..8004d308dfa 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2080,6 +2080,94 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid drop table t1,t2,t3; +# Test for BUG#11700 +CREATE TABLE t1 ( + acct_id int(11) NOT NULL default '0', + profile_id smallint(6) default NULL, + UNIQUE KEY t1$acct_id (acct_id), + KEY t1$profile_id (profile_id) +); +INSERT INTO t1 VALUES (132,17),(133,18); + +CREATE TABLE t2 ( + profile_id smallint(6) default NULL, + queue_id int(11) default NULL, + seq int(11) default NULL, + KEY t2$queue_id (queue_id) +); +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); + +CREATE TABLE t3 ( + id int(11) NOT NULL default '0', + qtype int(11) default NULL, + seq int(11) default NULL, + warn_lvl int(11) default NULL, + crit_lvl int(11) default NULL, + rr1 tinyint(4) NOT NULL default '0', + rr2 int(11) default NULL, + default_queue tinyint(4) NOT NULL default '0', + KEY t3$qtype (qtype), + KEY t3$id (id) +); + +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), + (36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); + +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE + (pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND + (pq.queue_id = q.id) AND (q.rr1 <> 1); + +drop table t1,t2,t3; + +# +# Bug #11482 Wrongly applied optimization was erroneously rejecting valid +# rows +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +drop table t1,t2; + +# +# Bug #11521 Negative integer keys incorrectly substituted for 0 during +# range analysis. + +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +explain select * from t2 where a > -1; +select * from t2 where a > -1; +drop table t2; + +# +# Bug #11745: SELECT ... FROM DUAL with WHERE condition +# + +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 + SELECT 50, 3, 3 FROM DUAL + WHERE NOT EXISTS + (SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +INSERT INTO t1 + SELECT 50, 3, 3 FROM DUAL + WHERE NOT EXISTS + (SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +SELECT * FROM t1; +select count(*) from t1; +select found_rows(); +select count(*) from t1 limit 2,3; +select found_rows(); +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +select found_rows(); + +DROP TABLE t1; + # # Test case for bug 7098: substitution of a constant for a string field # @@ -2154,15 +2242,6 @@ SELECT K2C4, K4N4, F2I4 FROM t1 (F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); SELECT K2C4, K4N4, F2I4 FROM t1 WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); - -select found_rows(); -select count(*) from t1; -select found_rows(); -select count(*) from t1 limit 2,3; -select found_rows(); -select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; -select found_rows(); - DROP TABLE t1; # @@ -2180,36 +2259,6 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; DROP TABLE t1, t2; - -# -# Test case for bug 7098: substitution of a constant for a string field -# - -CREATE TABLE t1 ( city char(30) ); -INSERT INTO t1 VALUES ('London'); -INSERT INTO t1 VALUES ('Paris'); - -SELECT * FROM t1 WHERE city='London'; -SELECT * FROM t1 WHERE city='london'; -EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; -SELECT * FROM t1 WHERE city='London' AND city='london'; -EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; - -DROP TABLE t1; - -# -# Bug#7425 inconsistent sort order on unsigned columns result of substraction -# - -create table t1 (a int(11) unsigned, b int(11) unsigned); -insert into t1 values (1,0), (1,1), (1,2); -select a-b from t1 order by 1; -select a-b , (a-b < 0) from t1 order by 1; -select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; -select cast((a - b) as unsigned) from t1 order by 1; -drop table t1; - # # Bug#8670 # @@ -2297,82 +2346,3 @@ DROP TABLE t1,t2; # select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; -# Test for BUG#11700 -CREATE TABLE t1 ( - acct_id int(11) NOT NULL default '0', - profile_id smallint(6) default NULL, - UNIQUE KEY t1$acct_id (acct_id), - KEY t1$profile_id (profile_id) -); -INSERT INTO t1 VALUES (132,17),(133,18); - -CREATE TABLE t2 ( - profile_id smallint(6) default NULL, - queue_id int(11) default NULL, - seq int(11) default NULL, - KEY t2$queue_id (queue_id) -); -INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); - -CREATE TABLE t3 ( - id int(11) NOT NULL default '0', - qtype int(11) default NULL, - seq int(11) default NULL, - warn_lvl int(11) default NULL, - crit_lvl int(11) default NULL, - rr1 tinyint(4) NOT NULL default '0', - rr2 int(11) default NULL, - default_queue tinyint(4) NOT NULL default '0', - KEY t3$qtype (qtype), - KEY t3$id (id) -); - -INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), - (36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); - -SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q -WHERE - (pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND - (pq.queue_id = q.id) AND (q.rr1 <> 1); - -drop table t1,t2,t3; - -# -# Bug #11482 Wrongly applied optimization was erroneously rejecting valid -# rows -create table t1 (f1 int); -insert into t1 values (1),(NULL); -create table t2 (f2 int, f3 int, f4 int); -create index idx1 on t2 (f4); -insert into t2 values (1,2,3),(2,4,6); -select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) -from t2 C where A.f4 = C.f4) or A.f3 IS NULL; -drop table t1,t2; -# -# Bug #11521 Negative integer keys incorrectly substituted for 0 during -# range analysis. - -create table t2 (a tinyint unsigned); -create index t2i on t2(a); -insert into t2 values (0), (254), (255); -explain select * from t2 where a > -1; -select * from t2 where a > -1; -drop table t2; - -# -# Bug #11745: SELECT ... FROM DUAL with WHERE condition -# - -CREATE TABLE t1 (a int, b int, c int); -INSERT INTO t1 - SELECT 50, 3, 3 FROM DUAL - WHERE NOT EXISTS - (SELECT * FROM t1 WHERE a = 50 AND b = 3); -SELECT * FROM t1; -INSERT INTO t1 - SELECT 50, 3, 3 FROM DUAL - WHERE NOT EXISTS - (SELECT * FROM t1 WHERE a = 50 AND b = 3); -SELECT * FROM t1; - -DROP TABLE t1; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index f295311fe4e..e2f247edcd3 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -986,6 +986,10 @@ create table t1 (sl decimal(0,30)); create table t1 (sl decimal(5, 5)); show create table t1; drop table t1; +# Test limits +create table t1 (sl decimal(65, 30)); +show create table t1; +drop table t1; # # Bug 11557 (DEFAULT values rounded improperly |