Commit ebde3d6d authored by unknown's avatar unknown

Merge work:/my/mysql into tik.mysql.fi:/home/my/mysql

parents a774d561 811532f5
This diff is collapsed.
......@@ -111,3 +111,34 @@ DateOfAction TransactionID
member_id nickname voornaam
1
2
gid sid uid
104620 5 15
103867 5 27
103962 5 27
104619 5 75
104505 5 117
103853 5 250
gid sid uid
104620 5 15
103867 5 27
103962 5 27
104619 5 75
104505 5 117
103853 5 250
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index
t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 where used; Using index
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 where used
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 where used; Using index
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 where used
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 where used
......@@ -168,8 +168,8 @@ drop table t1,t2,t3;
#bug reported by Wouter de Jong
drop table if exists members;
CREATE TABLE members (
drop table if exists t1;
CREATE TABLE t1 (
member_id int(11) NOT NULL auto_increment,
inschrijf_datum varchar(20) NOT NULL default '',
lastchange_datum varchar(20) NOT NULL default '',
......@@ -200,8 +200,50 @@ CREATE TABLE members (
PRIMARY KEY (member_id)
) TYPE=MyISAM PACK_KEYS=1;
insert into members (member_id) values (1),(2),(3);
select member_id, nickname, voornaam FROM members
insert into t1 (member_id) values (1),(2),(3);
select member_id, nickname, voornaam FROM t1
ORDER by lastchange_datum DESC LIMIT 2;
drop table members;
drop table t1;
#
# Test optimizing bug with EQ_REF tables, where some ORDER BY parts where
# wrongly removed.
CREATE TABLE t1 (
gid int(10) unsigned NOT NULL auto_increment,
cid smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (gid),
KEY component_id (cid)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108);
ALTER TABLE t1 add skr int(10) not null;
CREATE TABLE t2 (
gid int(10) unsigned NOT NULL default '0',
uid smallint(5) unsigned NOT NULL default '1',
sid tinyint(3) unsigned NOT NULL default '1',
PRIMARY KEY (gid),
KEY uid (uid),
KEY status_id (sid)
) TYPE=MyISAM;
INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5);
CREATE TABLE t3 (
uid smallint(6) NOT NULL auto_increment,
PRIMARY KEY (uid)
) TYPE=MyISAM;
INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250);
ALTER TABLE t3 add skr int(10) not null;
select t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
# The following ORDER BY can be optimimized
EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
# The following ORDER BY can't be optimimized
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
drop table t1,t2,t3;
......@@ -222,7 +222,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
const char *dir, const char *config_file,
const char *ext, TYPELIB *group)
{
char name[FN_REFLEN+10],buff[FN_REFLEN+1],*ptr,*end,*value,*tmp;
char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp;
FILE *fp;
uint line=0;
my_bool read_values=0,found_group=0;
......
......@@ -223,18 +223,27 @@ foreach my $rdb ( @db_desc ) {
my $db = $rdb->{src};
eval { $dbh->do( "use $db" ); };
die "Database '$db' not accessible: $@" if ( $@ );
my @dbh_tables = $dbh->func( '_ListTables' );
my @dbh_tables = $dbh->tables();
## generate regex for tables/files
my $t_regex = $rdb->{t_regex}; ## assign temporary regex
my $negated = $t_regex =~ tr/~//d; ## remove and count negation operator: we don't allow ~ in table names
$t_regex = qr/$t_regex/; ## make regex string from user regex
my $t_regex;
my $negated;
if ($rdb->{t_regex}) {
$t_regex = $rdb->{t_regex}; ## assign temporary regex
$negated = $t_regex =~ tr/~//d; ## remove and count
## negation operator: we
## don't allow ~ in table
## names
$t_regex = qr/$t_regex/; ## make regex string from
## user regex
## filter (out) tables specified in t_regex
print "Filtering tables with '$t_regex'\n" if $opt{debug};
@dbh_tables = ( $negated
? grep { $_ !~ $t_regex } @dbh_tables
: grep { $_ =~ $t_regex } @dbh_tables );
}
## get list of files to copy
my $db_dir = "$datadir/$db";
......@@ -249,10 +258,18 @@ foreach my $rdb ( @db_desc ) {
closedir( DBDIR );
## filter (out) files specified in t_regex
my @db_files = ( $negated
my @db_files;
if ($rdb->{t_regex}) {
@db_files = ($negated
? grep { $db_files{$_} !~ $t_regex } keys %db_files
: grep { $db_files{$_} =~ $t_regex } keys %db_files );
}
else {
@db_files = keys %db_files;
}
@db_files = sort @db_files;
my @index_files=();
## remove indices unless we're told to keep them
......@@ -809,3 +826,7 @@ Ask Bjoern Hansen - Cleanup code to fix a few bugs and enable -w again.
Emil S. Hansen - Added resetslave and resetmaster.
Jeremy D. Zawodny - Removed depricated DBI calls. Fixed bug which
resulted in nothing being copied when a regexp was specified but no
database name(s).
......@@ -2649,12 +2649,12 @@ static void update_depend_map(JOIN *join)
for (i=0 ; i < ref->key_parts ; i++,item++)
depend_map|=(*item)->used_tables();
ref->depend_map=depend_map;
for (JOIN_TAB *join_tab2=join->join_tab;
for (JOIN_TAB **tab=join->map2table;
depend_map ;
join_tab2++,depend_map>>=1 )
tab++,depend_map>>=1 )
{
if (depend_map & 1)
ref->depend_map|=join_tab2->ref.depend_map;
ref->depend_map|=(*tab)->ref.depend_map;
}
}
}
......@@ -2671,12 +2671,12 @@ static void update_depend_map(JOIN *join, ORDER *order)
order->depend_map=depend_map=order->item[0]->used_tables();
if (!(order->depend_map & RAND_TABLE_BIT)) // Not item_sum() or RAND()
{
for (JOIN_TAB *join_tab=join->join_tab;
for (JOIN_TAB **tab=join->map2table;
depend_map ;
join_tab++, depend_map>>=1)
tab++, depend_map>>=1)
{
if (depend_map & 1)
order->depend_map|=join_tab->ref.depend_map;
order->depend_map|=(*tab)->ref.depend_map;
}
}
}
......
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