Commit d38454fa authored by unknown's avatar unknown

Fixed bug when making a range join based on information from a const table.


Docs/manual.texi:
  Changelog
mysql-test/r/join.result:
  Test of join bug
mysql-test/t/join.test:
  Test of join bug
mysys/hash.c:
  Fix for SUNPRO_C
scripts/mysql_config.sh:
  Fix for MacOS X
parent 38e174cc
......@@ -46833,6 +46833,7 @@ users use this code as the rest of the code and because of this we are
not yet 100% confident in this code.
@menu
* News-3.23.48:: Changes in release 3.23.48
* News-3.23.47:: Changes in release 3.23.47
* News-3.23.46:: Changes in release 3.23.46
* News-3.23.45:: Changes in release 3.23.45
......@@ -46884,7 +46885,16 @@ not yet 100% confident in this code.
* News-3.23.0:: Changes in release 3.23.0
@end menu
@node News-3.23.47, News-3.23.46, News-3.23.x, News-3.23.x
@node News-3.23.48, News-3.23.47, News-3.23.x, News-3.23.x
@appendixsubsec Changes in release 3.23.48
@itemize @bullet
@item
Fixed bug in complicated join with @code{const} tables.
@item
Added internal safety checks for InnoDB.
@end itemize
@node News-3.23.47, News-3.23.46, News-3.23.48, News-3.23.x
@appendixsubsec Changes in release 3.23.47
@itemize @bullet
@item
......@@ -27,3 +27,7 @@ d d
0000-00-00 NULL
d
0000-00-00
COUNT(t1.Title)
1
COUNT(t1.Title)
1
......@@ -2,7 +2,8 @@
# This failed for lia Perminov
#
drop table if exists t1,t2;
drop table if exists t1,t2,t3;
create table t1 (id int primary key);
create table t2 (id int);
insert into t1 values (75);
......@@ -120,3 +121,76 @@ INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
SELECT * from t1 WHERE t1.d IS NULL;
DROP TABLE t1,t2;
#
# Problem with reference from const tables
#
CREATE TABLE t1 (
Document_ID varchar(50) NOT NULL default '',
Contractor_ID varchar(6) NOT NULL default '',
Language_ID char(3) NOT NULL default '',
Expiration_Date datetime default NULL,
Publishing_Date datetime default NULL,
Title text,
Column_ID varchar(50) NOT NULL default '',
PRIMARY KEY (Language_ID,Document_ID,Contractor_ID)
);
INSERT INTO t1 VALUES ('xep80','1','ger','2001-12-31 20:00:00','2001-11-12 10:58:00','Kartenbestellung - jetzt auch online','anle'),('','999998','',NULL,NULL,NULL,'');
CREATE TABLE t2 (
Contractor_ID char(6) NOT NULL default '',
Language_ID char(3) NOT NULL default '',
Document_ID char(50) NOT NULL default '',
CanRead char(1) default NULL,
Customer_ID int(11) NOT NULL default '0',
PRIMARY KEY (Contractor_ID,Language_ID,Document_ID,Customer_ID)
);
INSERT INTO t2 VALUES ('5','ger','xep80','1',999999),('1','ger','xep80','1',999999);
CREATE TABLE t3 (
Language_ID char(3) NOT NULL default '',
Column_ID char(50) NOT NULL default '',
Contractor_ID char(6) NOT NULL default '',
CanRead char(1) default NULL,
Active char(1) default NULL,
PRIMARY KEY (Language_ID,Column_ID,Contractor_ID)
);
INSERT INTO t3 VALUES ('ger','home','1','1','1'),('ger','Test','1','0','0'),('ger','derclu','1','0','0'),('ger','clubne','1','0','0'),('ger','philos','1','0','0'),('ger','clubko','1','0','0'),('ger','clubim','1','1','1'),('ger','progra','1','0','0'),('ger','progvo','1','0','0'),('ger','progsp','1','0','0'),('ger','progau','1','0','0'),('ger','progku','1','0','0'),('ger','progss','1','0','0'),('ger','nachl','1','0','0'),('ger','mitgli','1','0','0'),('ger','mitsu','1','0','0'),('ger','mitbus','1','0','0'),('ger','ergmar','1','1','1'),('ger','home','4','1','1'),('ger','derclu','4','1','1'),('ger','clubne','4','0','0'),('ger','philos','4','1','1'),('ger','clubko','4','1','1'),('ger','clubim','4','1','1'),('ger','progra','4','1','1'),('ger','progvo','4','1','1'),('ger','progsp','4','1','1'),('ger','progau','4','0','0'),('ger','progku','4','1','1'),('ger','progss','4','1','1'),('ger','nachl','4','1','1'),('ger','mitgli','4','0','0'),('ger','mitsu','4','0','0'),('ger','mitbus','4','0','0'),('ger','ergmar','4','1','1'),('ger','progra2','1','0','0'),('ger','archiv','4','1','1'),('ger','anmeld','4','1','1'),('ger','thema','4','1','1'),('ger','edito','4','1','1'),('ger','madis','4','1','1'),('ger','enma','4','1','1'),('ger','madis','1','1','1'),('ger','enma','1','1','1'),('ger','vorsch','4','0','0'),('ger','veranst','4','0','0'),('ger','anle','4','1','1'),('ger','redak','4','1','1'),('ger','nele','4','1','1'),('ger','aukt','4','1','1'),('ger','callcenter','4','1','1'),('ger','anle','1','0','0');
delete from t1 where Contractor_ID='999998';
insert into t1 (Contractor_ID) Values ('999998');
SELECT DISTINCT COUNT(t1.Title) FROM t1,
t2, t3 WHERE
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
t1.Document_ID = t2.Document_ID AND
t1.Language_ID = t2.Language_ID AND
t1.Contractor_ID = t2.Contractor_ID AND (
t2.Customer_ID = '4' OR
t2.Customer_ID = '999999' OR
t2.Customer_ID = '1' )AND t2.CanRead
= '1' AND t1.Column_ID=t3.Column_ID AND
t1.Language_ID=t3.Language_ID AND (
t3.Contractor_ID = '4' OR
t3.Contractor_ID = '999999' OR
t3.Contractor_ID = '1') AND
t3.CanRead='1' AND t3.Active='1';
SELECT DISTINCT COUNT(t1.Title) FROM t1,
t2, t3 WHERE
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
t1.Document_ID = t2.Document_ID AND
t1.Language_ID = t2.Language_ID AND
t1.Contractor_ID = t2.Contractor_ID AND (
t2.Customer_ID = '4' OR
t2.Customer_ID = '999999' OR
t2.Customer_ID = '1' )AND t2.CanRead
= '1' AND t1.Column_ID=t3.Column_ID AND
t1.Language_ID=t3.Language_ID AND (
t3.Contractor_ID = '4' OR
t3.Contractor_ID = '999999' OR
t3.Contractor_ID = '1') AND
t3.CanRead='1' AND t3.Active='1';
drop table t1,t2,t3;
......@@ -180,7 +180,7 @@ uint calc_hashnr_caseup(const byte *key, uint len)
#endif
#ifndef _FORTREC_
#ifndef __SUNPRO_C /* SUNPRO can't handle this */
inline
#endif
uint rec_hashnr(HASH *hash,const byte *record)
......
......@@ -58,12 +58,16 @@ fix_path ()
done
}
abs_path=`expr \( substr $0 1 1 \) = '/'`
if [ "x$abs_path" = "x1" ] ; then
me=$0
else
me=`which $0`
fi
get_full_path ()
{
case $1 in
/*) echo "$1";;
./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/./;/;' ;;
*) which $1 ;;
esac
}
me=`get_full_path $0`
basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
......@@ -81,6 +85,7 @@ ldflags='@LDFLAGS@'
client_libs='@CLIENT_LIBS@'
libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs"
libs=`echo $libs | sed -e 's; +;;'`
cflags="-I'$pkgincludedir'"
usage () {
......
......@@ -1026,14 +1026,13 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
{
ha_rows records;
if (!select)
select=make_select(s->table,const_table_map,
select=make_select(s->table,0,
0,
and_conds(conds,s->on_expr),&error);
records=get_quick_record_count(select,s->table, s->const_keys);
s->quick=select->quick;
s->needed_reg=select->needed_reg;
select->quick=0;
select->read_tables=const_table_map;
if (records != HA_POS_ERROR)
{
s->found_records=records;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment