#At file:///home/kgeorge/mysql/work/fix-6.0-bugteam/ based on revid:joro@stripped
2944 Georgi Kodinov 2009-01-06
- merged bug #31399 to 6.0-main (has BKA)
- updated a 6.0 specific test suite file to reflect 5.x test additions.
modified:
mysql-test/r/select_jcl6.result
sql/sql_join_cache.cc
sql/sql_select.cc
sql/sql_select.h
=== modified file 'mysql-test/r/select_jcl6.result'
--- a/mysql-test/r/select_jcl6.result 2008-11-05 00:53:38 +0000
+++ b/mysql-test/r/select_jcl6.result 2009-01-06 14:19:37 +0000
@@ -4344,6 +4344,39 @@ Handler_read_prev 0
Handler_read_rnd 10
Handler_read_rnd_next 7
DROP TABLE t1, t2;
+CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
+f2 int(11) NOT NULL default '0',
+f3 bigint(20) NOT NULL default '0',
+f4 varchar(255) NOT NULL default '',
+PRIMARY KEY (f1),
+KEY key1 (f4),
+KEY key2 (f2));
+CREATE TABLE t2 (f1 int(11) NOT NULL default '0',
+f2 enum('A1','A2','A3') NOT NULL default 'A1',
+f3 int(11) NOT NULL default '0',
+PRIMARY KEY (f1),
+KEY key1 (f3));
+CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0',
+f2 datetime NOT NULL default '1980-01-01 00:00:00',
+PRIMARY KEY (f1));
+insert into t1 values (1, 1, 1, 'abc');
+insert into t1 values (2, 1, 2, 'def');
+insert into t1 values (3, 1, 2, 'def');
+insert into t2 values (1, 'A1', 1);
+insert into t3 values (1, '1980-01-01');
+SELECT a.f3, cr.f4, count(*) count
+FROM t2 a
+STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1
+LEFT JOIN
+(t1 cr2
+JOIN t3 ae2 ON cr2.f3 = ae2.f1
+) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND
+cr.f4 = cr2.f4
+GROUP BY a.f3, cr.f4;
+f3 f4 count
+1 abc 1
+1 def 2
+drop table t1, t2, t3;
End of 5.0 tests
create table t1(a INT, KEY (a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
@@ -4362,6 +4395,32 @@ a
4
5
DROP TABLE t1;
+CREATE TABLE A (date_key date);
+CREATE TABLE C (
+pk int,
+int_nokey int,
+int_key int,
+date_key date NOT NULL,
+date_nokey date,
+varchar_key varchar(1)
+);
+INSERT INTO C VALUES
+(1,1,1,'0000-00-00',NULL,NULL),
+(1,1,1,'0000-00-00',NULL,NULL);
+SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
+1
+SELECT COUNT(DISTINCT 1) FROM C
+WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
+COUNT(DISTINCT 1)
+SELECT date_nokey FROM C
+WHERE int_key IN (SELECT 1 FROM A)
+HAVING date_nokey = '10:41:7'
+ORDER BY date_key;
+date_nokey
+Warnings:
+Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
+DROP TABLE A,C;
+End of 5.1 tests
set join_cache_level=default;
show variables like 'join_cache_level';
Variable_name Value
=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc 2008-12-22 19:03:25 +0000
+++ b/sql/sql_join_cache.cc 2009-01-06 14:19:37 +0000
@@ -270,8 +270,7 @@ void JOIN_CACHE::create_flag_fields()
TABLE *table= tab->table;
/* Create a field for the null bitmap from table if needed */
- /* TODO: Figure out whether we really need the second conjunct here */
- if (test(tab->used_null_fields) && table->s->null_fields)
+ if (test(tab->used_null_fields) || tab->have_bit_fields)
length+= add_flag_field_to_join_cache(table->null_flags,
table->s->null_bytes,
©);
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2009-01-06 10:38:47 +0000
+++ b/sql/sql_select.cc 2009-01-06 14:19:37 +0000
@@ -7548,9 +7548,11 @@ void calc_used_field_length(THD *thd, JO
{
uint null_fields,blobs,fields,rec_length;
Field **f_ptr,*field;
+ bool bit_fields;
MY_BITMAP *read_set= join_tab->table->read_set;;
null_fields= blobs= fields= rec_length=0;
+ bit_fields= FALSE;
for (f_ptr=join_tab->table->field ; (field= *f_ptr) ; f_ptr++)
{
if (bitmap_is_set(read_set, field->field_index))
@@ -7562,6 +7564,9 @@ void calc_used_field_length(THD *thd, JO
blobs++;
if (!(flags & NOT_NULL_FLAG))
null_fields++;
+ if (field->type() == MYSQL_TYPE_BIT &&
+ ((Field_bit*)field)->bit_len)
+ bit_fields= TRUE;
}
}
if (null_fields)
@@ -7578,6 +7583,7 @@ void calc_used_field_length(THD *thd, JO
join_tab->used_fieldlength=rec_length;
join_tab->used_blobs=blobs;
join_tab->used_null_fields= null_fields;
+ join_tab->have_bit_fields= bit_fields;
}
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2009-01-06 10:38:47 +0000
+++ b/sql/sql_select.h 2009-01-06 14:19:37 +0000
@@ -205,6 +205,7 @@ typedef struct st_join_table
uint used_fields,used_fieldlength,used_blobs;
uint used_null_fields;
uint used_rowid_fields;
+ bool have_bit_fields;
enum join_type type;
bool cached_eq_ref_table,eq_ref_table,not_used_in_distinct;
/* TRUE <=> index-based access method must return records in order */
| Thread |
|---|
| • bzr commit into mysql-6.0-bugteam branch (joro:2944) Bug#31399 | Georgi Kodinov | 6 Jan |