Commit c286021a authored by unknown's avatar unknown

ORDER BY works with FULLTEXT keys

parent 47d38f68
...@@ -45,7 +45,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ ...@@ -45,7 +45,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
sql_map.h sql_string.h unireg.h \ sql_map.h sql_string.h unireg.h \
field.h handler.h ha_isammrg.h ha_isam.h ha_myisammrg.h\ field.h handler.h ha_isammrg.h ha_isam.h ha_myisammrg.h\
ha_heap.h ha_myisam.h ha_berkeley.h\ ha_heap.h ha_myisam.h ha_berkeley.h\
opt_range.h \ opt_range.h opt_ft.h \
sql_select.h structs.h table.h sql_udf.h hash_filo.h\ sql_select.h structs.h table.h sql_udf.h hash_filo.h\
lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \ lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \
log_event.h mini_client.h sql_repl.h log_event.h mini_client.h sql_repl.h
...@@ -62,7 +62,7 @@ mysqld_SOURCES = sql_lex.cc \ ...@@ -62,7 +62,7 @@ mysqld_SOURCES = sql_lex.cc \
sql_update.cc sql_delete.cc \ sql_update.cc sql_delete.cc \
procedure.cc item_uniq.cc sql_test.cc \ procedure.cc item_uniq.cc sql_test.cc \
log.cc init.cc derror.cc sql_acl.cc unireg.cc \ log.cc init.cc derror.cc sql_acl.cc unireg.cc \
time.cc opt_range.cc opt_sum.cc \ time.cc opt_range.cc opt_sum.cc opt_ft.cc \
records.cc filesort.cc handler.cc \ records.cc filesort.cc handler.cc \
ha_isam.cc ha_isammrg.cc ha_heap.cc \ ha_isam.cc ha_isammrg.cc ha_heap.cc \
ha_myisam.cc ha_myisammrg.cc ha_berkeley.cc \ ha_myisam.cc ha_myisammrg.cc ha_berkeley.cc \
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -115,10 +115,10 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, ...@@ -115,10 +115,10 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
param.ref_length= table[0]->file->ref_length; param.ref_length= table[0]->file->ref_length;
param.sort_length=sortlength(sortorder,s_length)+ param.ref_length; param.sort_length=sortlength(sortorder,s_length)+ param.ref_length;
param.max_rows= max_rows; param.max_rows= max_rows;
if (select && select->quick) if (select && select->quick)
{ {
statistic_increment(filesort_range_count, &LOCK_status); statistic_increment(filesort_range_count, &LOCK_status);
} }
else else
{ {
...@@ -336,6 +336,10 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -336,6 +336,10 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
file->extra(HA_EXTRA_CACHE); /* Quicker reads */ file->extra(HA_EXTRA_CACHE); /* Quicker reads */
} }
if (quick_select)
error=select->quick->init();
if (!error)
for (;;) for (;;)
{ {
if (quick_select) if (quick_select)
...@@ -369,7 +373,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -369,7 +373,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
record+=sort_form->db_record_offset; record+=sort_form->db_record_offset;
} }
else else
file->position(sort_form->record[0]); file->position(sort_form->record[0]);
} }
if (error && error != HA_ERR_RECORD_DELETED) if (error && error != HA_ERR_RECORD_DELETED)
break; break;
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
Fix that MAYBE_KEY are stored in the tree so that we can detect use Fix that MAYBE_KEY are stored in the tree so that we can detect use
of full hash keys for queries like: of full hash keys for queries like:
select s.id, kws.keyword_id from sites as s,kws where s.id=kws.site_id and kws.keyword_id in (204,205); select s.id, kws.keyword_id from sites as s,kws where s.id=kws.site_id and kws.keyword_id in (204,205);
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -73,12 +73,12 @@ class QUICK_SELECT { ...@@ -73,12 +73,12 @@ class QUICK_SELECT {
QUICK_SELECT(TABLE *table,uint index_arg,bool no_alloc=0); QUICK_SELECT(TABLE *table,uint index_arg,bool no_alloc=0);
~QUICK_SELECT(); ~QUICK_SELECT();
void reset(void) { next=0; it.rewind(); } void reset(void) { next=0; it.rewind(); }
int get_next(); virtual int init() { return 0; }
virtual int get_next();
int cmp_next(QUICK_RANGE *range); int cmp_next(QUICK_RANGE *range);
bool unique_key_range(); bool unique_key_range();
}; };
class SQL_SELECT :public Sql_alloc { class SQL_SELECT :public Sql_alloc {
public: public:
QUICK_SELECT *quick; // If quick-select used QUICK_SELECT *quick; // If quick-select used
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_select.h" #include "sql_select.h"
#include "opt_ft.h"
#include <m_ctype.h> #include <m_ctype.h>
#include <hash.h> #include <hash.h>
#include <ft_global.h> #include <ft_global.h>
...@@ -4357,7 +4358,7 @@ join_ft_read_first(JOIN_TAB *tab) ...@@ -4357,7 +4358,7 @@ join_ft_read_first(JOIN_TAB *tab)
#if 0 #if 0
if (cp_buffer_from_ref(&tab->ref)) // as ft-key doesn't use store_key's if (cp_buffer_from_ref(&tab->ref)) // as ft-key doesn't use store_key's
return -1; return -1; // see also FT_SELECT::init()
#endif #endif
if ((error=table->file->ft_init(tab->ref.key, if ((error=table->file->ft_init(tab->ref.key,
tab->ref.key_buff, tab->ref.key_buff,
...@@ -5052,13 +5053,13 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit) ...@@ -5052,13 +5053,13 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
} }
} }
else else
if (tab->type != JT_FT) /* Beware! SerG */ // if (tab->type != JT_FT) /* Beware! SerG */
{ {
/* /*
We have a ref on a const; Change this to a range that filesort We have a ref on a const; Change this to a range that filesort
can use. can use.
*/ */
if (!(select->quick=get_quick_select_for_ref(table, &tab->ref))) if (!(select->quick=get_ft_or_quick_select_for_ref(table, tab)))
goto err; goto err;
} }
} }
......
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