Fixed lp:970528 "Server crashes in my_strnncollsp_simple on LEFT JOIN with CSV table, TEXT field"

The main problem was a bug in CSV where it provided wrong statistics (it claimed the table was empty when it wasn't)
I also fixed wrong freeing of blob's in the CSV handler. (Any call to handler::read_first_row() on a CSV table with blobs would fail)



mysql-test/r/csv.result:
  Added new test case
mysql-test/r/partition_innodb.result:
  Updated test results after fixing bug with impossible partitions and const tables
mysql-test/t/csv.test:
  Added new test case
sql/sql_select.cc:
  Cleaned up code for handling of partitions.
  Fixed also a bug where we didn't threat a table with impossible partitions as a const table.
storage/csv/ha_tina.cc:
  Allocate blobroot onces.
This commit is contained in:
Michael Widenius 2012-04-04 00:14:07 +03:00
commit a3bee835ee
6 changed files with 66 additions and 30 deletions

View file

@ -5415,4 +5415,17 @@ foo
DROP TABLE t1;
CREATE TABLE t1 ( b TEXT NOT NULL ) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('x'),('y');
CREATE TABLE t2 ( a VARCHAR(1) NOT NULL ) ENGINE=CSV;
INSERT INTO t2 VALUES ('r'),('t');
SELECT * FROM t2 ORDER BY a;
a
r
t
SELECT * FROM t1 LEFT JOIN t2 ON ( b = a );
b a
x NULL
y NULL
drop table t1,t2;
End of 5.1 tests

View file

@ -48,13 +48,13 @@ insert INTO t1 VALUES (110);
ERROR HY000: Table has no partition for value 110
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where
@ -63,16 +63,16 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
#
# Bug#50104: Partitioned table with just 1 partion works with fk

View file

@ -1820,5 +1820,20 @@ INSERT INTO t1 VALUES(-1);
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug#970528
# Server crashes in my_strnncollsp_simple on LEFT JOIN with CSV table,
# TEXT field
#
CREATE TABLE t1 ( b TEXT NOT NULL ) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('x'),('y');
CREATE TABLE t2 ( a VARCHAR(1) NOT NULL ) ENGINE=CSV;
INSERT INTO t2 VALUES ('r'),('t');
SELECT * FROM t2 ORDER BY a;
SELECT * FROM t1 LEFT JOIN t2 ON ( b = a );
drop table t1,t2;
--echo End of 5.1 tests