diff options
author | unknown <igor@olga.mysql.com> | 2007-06-30 20:49:28 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-06-30 20:49:28 -0700 |
commit | 26a2b00498c5da514abe7056032ea37f7115b1e1 (patch) | |
tree | ed6bbc6971d75074b67617c9c71dbae1f71a8996 | |
parent | 2ca2b232e3fd7e82c4502f4ebd21a85e01d547a3 (diff) | |
parent | 8dcd5fca6977a8aafb0dd874b348e0078eafda94 (diff) | |
download | mariadb-git-26a2b00498c5da514abe7056032ea37f7115b1e1.tar.gz |
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.1-opt
mysql-test/r/binary.result:
Auto merged
mysql-test/r/ctype_collate.result:
Auto merged
mysql-test/r/ctype_utf8.result:
Auto merged
mysql-test/t/binary.test:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/ctype_utf8.test:
Auto merged
sql/field_conv.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item_subselect.cc:
Auto merged
sql/item_sum.cc:
Auto merged
sql/item_sum.h:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql-common/client.c:
Auto merged
sql/sql_select.h:
Auto merged
sql/table.cc:
Auto merged
storage/myisam/mi_open.c:
Auto merged
strings/ctype-simple.c:
Auto merged
mysql-test/r/create.result:
Manual merge.
mysql-test/r/subselect.result:
Manual merge.
mysql-test/r/type_enum.result:
Manual merge.
mysql-test/t/type_enum.test:
Manual merge.
mysql-test/include/mix1.inc:
Manual merge.
mysql-test/r/innodb_mysql.result:
Manual merge.
mysql-test/t/subselect.test:
Manual merge.
sql/sql_parse.cc:
Manual merge.
storage/myisam/mi_key.c:
Manual merge.
-rw-r--r-- | mysql-test/include/mix1.inc | 35 | ||||
-rw-r--r-- | mysql-test/r/binary.result | 38 | ||||
-rw-r--r-- | mysql-test/r/ctype_collate.result | 8 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 37 | ||||
-rw-r--r-- | mysql-test/r/innodb_mysql.result | 15 | ||||
-rw-r--r-- | mysql-test/t/binary.test | 38 | ||||
-rw-r--r-- | mysql-test/t/create.test | 333 | ||||
-rw-r--r-- | mysql-test/t/ctype_collate.test | 11 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 25 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 42 | ||||
-rw-r--r-- | sql/field_conv.cc | 17 | ||||
-rw-r--r-- | sql/item.cc | 12 | ||||
-rw-r--r-- | sql/item_subselect.cc | 3 | ||||
-rw-r--r-- | sql/item_sum.cc | 4 | ||||
-rw-r--r-- | sql/item_sum.h | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 9 | ||||
-rw-r--r-- | sql/sql_select.cc | 49 | ||||
-rw-r--r-- | sql/sql_select.h | 4 | ||||
-rw-r--r-- | sql/table.cc | 14 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 12 | ||||
-rw-r--r-- | storage/myisam/mi_open.c | 2 | ||||
-rw-r--r-- | strings/ctype-simple.c | 2 |
22 files changed, 681 insertions, 38 deletions
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index cc2f0e0588e..2aca2ba3698 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -672,6 +672,41 @@ SELECT * FROM t3 WHERE a = 'uk'; DROP TABLE t1,t2,t3; + +# +# Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked +# + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; + +CONNECT (c1,localhost,root,,); +CONNECT (c2,localhost,root,,); + +--echo switch to connection c1 +CONNECTION c1; +SET AUTOCOMMIT=0; +INSERT INTO t2 VALUES (1); + +--echo switch to connection c2 +CONNECTION c2; +SET AUTOCOMMIT=0; +--error ER_LOCK_WAIT_TIMEOUT +LOCK TABLES t1 READ, t2 READ; + +--echo switch to connection c1 +CONNECTION c1; +COMMIT; +INSERT INTO t1 VALUES (1); + +--echo switch to connection default +CONNECTION default; +SET AUTOCOMMIT=default; +DISCONNECT c1; +DISCONNECT c2; +DROP TABLE t1,t2; + + --echo End of 5.0 tests # diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result index ccafa43c7ab..be87c25e932 100644 --- a/mysql-test/r/binary.result +++ b/mysql-test/r/binary.result @@ -160,3 +160,41 @@ hex(col1) 62000000000000000000 62200000000000000000 drop table t1; +CREATE TABLE t1 ( +a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', +index idx(a) +); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707'); +SELECT hex(a) FROM t1 order by a; +hex(a) +1F9480179366F2BF567E1C4B964C1EF029080707 +1F9480179366F2BF567E1C4B964C1EF029082020 +1F9480179366F2BF567E1C4B964C1EF029087575 +EXPLAIN SELECT hex(a) FROM t1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL idx 20 NULL 3 Using index +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +hex(a) +1F9480179366F2BF567E1C4B964C1EF029082020 +EXPLAIN +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx idx 20 const 1 Using where; Using index +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908'); +hex(a) +DROP TABLE t1; +CREATE TABLE t1 ( +id numeric(20) NOT NULL, +lang varchar(8) NOT NULL, +msg varchar(32) NOT NULL, +PRIMARY KEY (id,lang) +); +INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz'); +INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx'); +INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy'); +SELECT * FROM t1 WHERE id=32; +id lang msg +32 en yyyyyyy +DROP TABLE t1; diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index c5d433cd080..5417c9da47e 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -595,3 +595,11 @@ EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where DROP TABLE t1; +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 8601e6890de..4778e9a6296 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1657,3 +1657,40 @@ colA colB colA colB 1 foo 1 foo 2 foo bar 2 foo bar DROP TABLE t1, t2; +SELECT 'н1234567890' UNION SELECT _binary '1'; +н1234567890 +н1234567890 +1 +SELECT 'н1234567890' UNION SELECT 1; +н1234567890 +н1234567890 +1 +SELECT '1' UNION SELECT 'н1234567890'; +1 +1 +н1234567890 +SELECT 1 UNION SELECT 'н1234567890'; +1 +1 +н1234567890 +CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; +CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); +INSERT INTO t1 (c) VALUES ('н1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); +SELECT c FROM t1 UNION SELECT b FROM t2; +c +н1234567890 +1 +SELECT c FROM t1 UNION SELECT i FROM t2; +c +н1234567890 +1 +SELECT b FROM t2 UNION SELECT c FROM t1; +b +1 +н1234567890 +SELECT i FROM t2 UNION SELECT c FROM t1; +i +1 +н1234567890 +DROP TABLE t1, t2; diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index afecf30b94f..fb8139e2ce1 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -665,6 +665,21 @@ UPDATE t3 SET a = 'us' WHERE a = 'uk'; SELECT * FROM t3 WHERE a = 'uk'; a DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +switch to connection c1 +SET AUTOCOMMIT=0; +INSERT INTO t2 VALUES (1); +switch to connection c2 +SET AUTOCOMMIT=0; +LOCK TABLES t1 READ, t2 READ; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +switch to connection c1 +COMMIT; +INSERT INTO t1 VALUES (1); +switch to connection default +SET AUTOCOMMIT=default; +DROP TABLE t1,t2; End of 5.0 tests CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(1,2); diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test index 4ab6ee9eaf1..1cc6ae07675 100644 --- a/mysql-test/t/binary.test +++ b/mysql-test/t/binary.test @@ -101,3 +101,41 @@ select hex(col1) from t1; insert into t1 values ('b'),('b '); select hex(col1) from t1; drop table t1; + +# +# Bug #29087: assertion abort for a search in a BINARY non-nullable index +# by a key with trailing spaces +# + +CREATE TABLE t1 ( + a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', + index idx(a) +); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707'); + +SELECT hex(a) FROM t1 order by a; +EXPLAIN SELECT hex(a) FROM t1 order by a; + +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +EXPLAIN +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); + +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908'); + +DROP TABLE t1; + +CREATE TABLE t1 ( + id numeric(20) NOT NULL, + lang varchar(8) NOT NULL, + msg varchar(32) NOT NULL, + PRIMARY KEY (id,lang) +); +INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz'); +INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx'); +INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy'); +SELECT * FROM t1 WHERE id=32; + +DROP TABLE t1; + diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 149982e23c5..dd3037ce88d 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -790,6 +790,339 @@ drop table t1, t2; create table t1 (upgrade int); drop table t1; + +# +# Bug #26642: create index corrupts table definition in .frm +# +# Problem with creating keys with maximum key-parts and maximum name length +# This test is made for a mysql server supporting names up to 64 bytes +# and a maximum of 16 key segements per Key +# + +create table t1 ( + c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, + c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, + + key a001_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a002_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a003_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a004_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a005_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a006_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a007_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a008_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a009_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a010_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a011_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a012_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a013_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a014_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a015_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a016_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a017_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a018_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a019_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a020_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a021_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a022_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a023_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a024_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a025_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a026_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a027_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a028_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a029_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a030_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a031_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a032_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a033_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a034_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a035_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a036_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a037_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a038_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a039_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a040_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a041_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a042_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a043_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a044_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a045_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a046_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a047_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a048_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a049_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a050_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a051_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a052_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a053_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a054_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a055_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a056_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a057_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a058_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a059_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + key a060_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a061_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a062_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a063_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + key a064_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16) +); + +# Check that the table is not corrupted +show create table t1; +flush tables; +show create table t1; + +# Repeat test using ALTER to add indexes + +drop table t1; +create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, +c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int); + +alter table t1 + + add key a001_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a002_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a003_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a004_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a005_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a006_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a007_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a008_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a009_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a010_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a011_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a012_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a013_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a014_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a015_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a016_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a017_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a018_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a019_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a020_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a021_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a022_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a023_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a024_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a025_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a026_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a027_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a028_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a029_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a030_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a031_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a032_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a033_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a034_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a035_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a036_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a037_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a038_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a039_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a040_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a041_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a042_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a043_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a044_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a045_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a046_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a047_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a048_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a049_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a050_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a051_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a052_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a053_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a054_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a055_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a056_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a057_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a058_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a059_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + + add key a060_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a061_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a062_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a063_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16), + add key a064_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16); + +show create table t1; +flush tables; +show create table t1; + +# Test the server limits; if any of these pass, all above tests need +# to be rewritten to hit the limit +# +# Ensure limit is really 64 keys +--error 1069 +alter table t1 add key + a065_long_123456789_123456789_123456789_123456789_123456789_1234 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16); + +drop table t1; + +# Ensure limit is really 16 key parts per key + +create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, +c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, +c16 int, c17 int); + +# Get error for max key parts +--error 1070 +alter table t1 add key i1 ( + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17); + +# Get error for max key-name length +--error 1059 +alter table t1 add key + a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1); + +show create table t1; + +drop table t1; + + --echo End of 5.0 tests # diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index aca240b46bc..4bbae42559a 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -207,3 +207,14 @@ EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; DROP TABLE t1; # End of 4.1 tests + +# +# Bug#29261: Sort order of the collation wasn't used when comparing trailing +# spaces. +# +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +drop table t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 03b3df44c73..204d59589e4 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1339,3 +1339,28 @@ INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB WHERE t1.colA < 3; DROP TABLE t1, t2; + +# +# Bug#29205: truncation of UTF8 values when the UNION statement +# forces collation to the binary charset +# + +SELECT 'н1234567890' UNION SELECT _binary '1'; +SELECT 'н1234567890' UNION SELECT 1; + +SELECT '1' UNION SELECT 'н1234567890'; +SELECT 1 UNION SELECT 'н1234567890'; + +CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; +CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); + +INSERT INTO t1 (c) VALUES ('н1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); + +SELECT c FROM t1 UNION SELECT b FROM t2; +SELECT c FROM t1 UNION SELECT i FROM t2; + +SELECT b FROM t2 UNION SELECT c FROM t1; +SELECT i FROM t2 UNION SELECT c FROM t1; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index e88ded56914..4c046dfd3c6 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2945,6 +2945,48 @@ SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2; DROP TABLE t1,t2; + +# +# Bug #27333: subquery grouped for aggregate of outer query / no aggregate +# of subquery +# +CREATE TABLE t1 (a INTEGER, b INTEGER); +CREATE TABLE t2 (x INTEGER); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +INSERT INTO t2 VALUES (1), (2); + +# wasn't failing, but should +--error ER_SUBQUERY_NO_1_ROW +SELECT a, COUNT(b), (SELECT COUNT(b) FROM t2) FROM t1 GROUP BY a; + +# fails as it should +--error ER_SUBQUERY_NO_1_ROW +SELECT a, COUNT(b), (SELECT COUNT(b)+0 FROM t2) FROM t1 GROUP BY a; + +SELECT (SELECT SUM(t1.a)/AVG(t2.x) FROM t2) FROM t1; +DROP TABLE t1,t2; + +# second test case from 27333 +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1, 2), (1,3), (1,4), (2,1), (2,2); + +-- returns no rows, when it should +SELECT a1.a, COUNT(*) FROM t1 a1 WHERE a1.a = 1 +AND EXISTS( SELECT a2.a FROM t1 a2 WHERE a2.a = a1.a) +GROUP BY a1.a; +DROP TABLE t1; + +#test cases from 29297 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (1),(2); +SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=0) FROM t1; +--error ER_SUBQUERY_NO_1_ROW +SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1; +SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1; +DROP TABLE t1,t2; + --echo End of 5.0 tests. # diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 63810c8b113..44aea9acee0 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -307,6 +307,15 @@ static void do_field_string(Copy_field *copy) } +static void do_field_enum(Copy_field *copy) +{ + if (copy->from_field->val_int() == 0) + ((Field_enum *) copy->to_field)->store_type((ulonglong) 0); + else + do_field_string(copy); +} + + static void do_field_varbinary_pre50(Copy_field *copy) { char buff[MAX_FIELD_WIDTH]; @@ -667,7 +676,13 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) to->real_type() == MYSQL_TYPE_SET) { if (!to->eq_def(from)) - return do_field_string; + { + if (from->real_type() == MYSQL_TYPE_ENUM && + to->real_type() == MYSQL_TYPE_ENUM) + return do_field_enum; + else + return do_field_string; + } } else if (to->charset() != from->charset()) return do_field_string; diff --git a/sql/item.cc b/sql/item.cc index 4fa6a2a8517..d7743c491eb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6687,9 +6687,15 @@ bool Item_type_holder::join_types(THD *thd, Item *item) expansion of the size of the values because of character set conversions. */ - max_length= max(old_max_chars * collation.collation->mbmaxlen, - display_length(item) / item->collation.collation->mbmaxlen * - collation.collation->mbmaxlen); + if (collation.collation != &my_charset_bin) + { + max_length= max(old_max_chars * collation.collation->mbmaxlen, + display_length(item) / + item->collation.collation->mbmaxlen * + collation.collation->mbmaxlen); + } + else + set_if_bigger(max_length, display_length(item)); break; } case REAL_RESULT: diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 000abb313a0..1d042860d73 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -985,7 +985,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, DBUG_RETURN(RES_ERROR); thd->lex->allow_sum_func= save_allow_sum_func; /* we added aggregate function => we have to change statistic */ - count_field_types(&join->tmp_table_param, join->all_fields, 0); + count_field_types(select_lex, &join->tmp_table_param, join->all_fields, + 0); subs= new Item_singlerow_subselect(select_lex); } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 10bd24dbb66..e2d4c02d986 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2480,7 +2480,7 @@ bool Item_sum_count_distinct::setup(THD *thd) } if (always_null) return FALSE; - count_field_types(tmp_table_param,list,0); + count_field_types(select_lex, tmp_table_param, list, 0); tmp_table_param->force_copy_fields= force_copy_fields; DBUG_ASSERT(table == 0); if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1, @@ -3286,7 +3286,7 @@ bool Item_func_group_concat::setup(THD *thd) setup_order(thd, args, context->table_list, list, all_fields, *order)) DBUG_RETURN(TRUE); - count_field_types(tmp_table_param,all_fields,0); + count_field_types(select_lex, tmp_table_param, all_fields, 0); tmp_table_param->force_copy_fields= force_copy_fields; DBUG_ASSERT(table == 0); /* diff --git a/sql/item_sum.h b/sql/item_sum.h index 84b425755d1..b3a382012f1 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -966,8 +966,15 @@ public: bool fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); + + if (init_sum_func_check(thd)) + return TRUE; + fixed= 1; - return udf.fix_fields(thd, this, this->arg_count, this->args); + if (udf.fix_fields(thd, this, this->arg_count, this->args)) + return TRUE; + + return check_sum_func(thd, ref); } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } virtual bool have_field_update(void) const { return 0; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a8dbebe012d..bf07bae379d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3012,6 +3012,7 @@ end_with_restore_list: break; case SQLCOM_LOCK_TABLES: unlock_locked_tables(thd); + /* we must end the trasaction first, regardless of anything */ if (end_active_trans(thd)) goto error; if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0)) @@ -3030,7 +3031,15 @@ end_with_restore_list: send_ok(thd); } else + { + /* + Need to end the current transaction, so the storage engine (InnoDB) + can free its locks if LOCK TABLES locked some tables before finding + that it can't lock a table in its list + */ + end_active_trans(thd); thd->options&= ~(ulong) (OPTION_TABLE_LOCK); + } thd->in_lock_tables=0; break; case SQLCOM_CREATE_DB: diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 504046ef43f..3cda4029161 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -606,7 +606,7 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; /* purecov: inspected */ /* Init join struct */ - count_field_types(&tmp_table_param, all_fields, 0); + count_field_types(select_lex, &tmp_table_param, all_fields, 0); ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; unit= unit_arg; @@ -1781,7 +1781,7 @@ JOIN::exec() if (make_simple_join(curr_join, curr_tmp_table)) DBUG_VOID_RETURN; calc_group_buffer(curr_join, group_list); - count_field_types(&curr_join->tmp_table_param, + count_field_types(select_lex, &curr_join->tmp_table_param, curr_join->tmp_all_fields1, curr_join->select_distinct && !curr_join->group_list); curr_join->tmp_table_param.hidden_field_count= @@ -1904,11 +1904,13 @@ JOIN::exec() if (make_simple_join(curr_join, curr_tmp_table)) DBUG_VOID_RETURN; calc_group_buffer(curr_join, curr_join->group_list); - count_field_types(&curr_join->tmp_table_param, *curr_all_fields, 0); + count_field_types(select_lex, &curr_join->tmp_table_param, + *curr_all_fields, 0); } if (procedure) - count_field_types(&curr_join->tmp_table_param, *curr_all_fields, 0); + count_field_types(select_lex, &curr_join->tmp_table_param, + *curr_all_fields, 0); if (curr_join->group || curr_join->tmp_table_param.sum_func_count || (procedure && (procedure->flags & PROC_GROUP))) @@ -13976,8 +13978,8 @@ next_item: *****************************************************************************/ void -count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, - bool reset_with_sum_func) +count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, + List<Item> &fields, bool reset_with_sum_func) { List_iterator<Item> li(fields); Item *field; @@ -13995,18 +13997,22 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, if (! field->const_item()) { Item_sum *sum_item=(Item_sum*) field->real_item(); - if (!sum_item->quick_group) - param->quick_group=0; // UDF SUM function - param->sum_func_count++; - param->func_count++; + if (!sum_item->depended_from() || + sum_item->depended_from() == select_lex) + { + if (!sum_item->quick_group) + param->quick_group=0; // UDF SUM function + param->sum_func_count++; - for (uint i=0 ; i < sum_item->arg_count ; i++) - { - if (sum_item->args[0]->real_item()->type() == Item::FIELD_ITEM) - param->field_count++; - else - param->func_count++; - } + for (uint i=0 ; i < sum_item->arg_count ; i++) + { + if (sum_item->args[0]->real_item()->type() == Item::FIELD_ITEM) + param->field_count++; + else + param->func_count++; + } + } + param->func_count++; } } else @@ -14467,7 +14473,9 @@ bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_fields, func= sum_funcs; while ((item=it++)) { - if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item()) + if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item() && + (!((Item_sum*) item)->depended_from() || + ((Item_sum *)item)->depended_from() == select_lex)) *func++= (Item_sum*) item; } if (before_group_by && rollup.state == ROLLUP::STATE_INITED) @@ -15049,7 +15057,10 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, ref_array= ref_array_start; } - if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item()) + if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item() && + (!((Item_sum*) item)->depended_from() || + ((Item_sum *)item)->depended_from() == select_lex)) + { /* This is a top level summary function that must be replaced with diff --git a/sql/sql_select.h b/sql/sql_select.h index 290a0f5d992..98f2a7829dd 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -509,8 +509,8 @@ TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ulonglong select_options, ha_rows rows_limit, char* alias); void free_tmp_table(THD *thd, TABLE *entry); -void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, - bool reset_with_sum_func); +void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, + List<Item> &fields, bool reset_with_sum_func); bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, Item **ref_pointer_array, List<Item> &new_list1, List<Item> &new_list2, diff --git a/sql/table.cc b/sql/table.cc index 45ca17afce4..68964e420da 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2221,7 +2221,19 @@ File create_frm(THD *thd, const char *name, const char *db, ha_checktype(thd,ha_legacy_type(create_info->db_type),0,0)); fileinfo[4]=1; int2store(fileinfo+6,IO_SIZE); /* Next block starts here */ - key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16; + /* + Keep in sync with pack_keys() in unireg.cc + For each key: + 8 bytes for the key header + 9 bytes for each key-part (MAX_REF_PARTS) + NAME_LEN bytes for the name + 1 byte for the NAMES_SEP_CHAR (before the name) + For all keys: + 6 bytes for the header + 1 byte for the NAMES_SEP_CHAR (after the last name) + 9 extra bytes (padding for safety? alignment?) + */ + key_length= keys * (8 + MAX_REF_PARTS * 9 + NAME_LEN + 1) + 16; length= next_io_size((ulong) (IO_SIZE+key_length+reclength+ create_info->extra_size)); int4store(fileinfo+10,length); diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 230ebac3bb0..5b3662c4f28 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -254,16 +254,16 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, if (keyseg->flag & HA_SPACE_PACK) { uchar *end=pos+length; - if (type != HA_KEYTYPE_NUM) - { - while (end > pos && end[-1] == ' ') - end--; - } - else + if (type == HA_KEYTYPE_NUM) { while (pos < end && pos[0] == ' ') pos++; } + else if (type != HA_KEYTYPE_BINARY) + { + while (end > pos && end[-1] == ' ') + end--; + } length=(uint) (end-pos); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 9ff8ecdb14d..405dca641d1 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -236,7 +236,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) key_parts+=fulltext_keys*FT_SEGS; if (share->base.max_key_length > MI_MAX_KEY_BUFF || keys > MI_MAX_KEY || - key_parts >= MI_MAX_KEY * MI_MAX_KEY_SEG) + key_parts > MI_MAX_KEY * MI_MAX_KEY_SEG) { DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); my_errno=HA_ERR_UNSUPPORTED; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 99e41611eaa..9a80b932d20 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -186,7 +186,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return (*a < ' ') ? -swap : swap; + return (map[*a] < ' ') ? -swap : swap; } } return res; |