summaryrefslogtreecommitdiff
path: root/sql/opt_range.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/opt_range.h')
-rw-r--r--sql/opt_range.h55
1 files changed, 43 insertions, 12 deletions
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 247dd260817..cda8ad51c3f 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -38,25 +38,34 @@ typedef struct st_key_part {
Field *field;
} KEY_PART;
+
class QUICK_RANGE :public Sql_alloc {
public:
char *min_key,*max_key;
uint16 min_length,max_length,flag;
+#ifdef HAVE_purify
+ uint16 dummy; /* Avoid warnings on 'flag' */
+#endif
QUICK_RANGE(); /* Full range */
QUICK_RANGE(const char *min_key_arg,uint min_length_arg,
const char *max_key_arg,uint max_length_arg,
uint flag_arg)
: min_key((char*) sql_memdup(min_key_arg,min_length_arg+1)),
max_key((char*) sql_memdup(max_key_arg,max_length_arg+1)),
- min_length(min_length_arg),
- max_length(max_length_arg),
- flag(flag_arg)
- {}
+ min_length((uint16) min_length_arg),
+ max_length((uint16) max_length_arg),
+ flag((uint16) flag_arg)
+ {
+#ifdef HAVE_purify
+ dummy=0;
+#endif
+ }
};
+
class QUICK_SELECT {
public:
- bool next;
+ bool next,dont_free;
int error;
uint index,max_used_key_length;
TABLE *head;
@@ -71,15 +80,35 @@ public:
ha_rows records;
double read_time;
- QUICK_SELECT(TABLE *table,uint index_arg,bool no_alloc=0);
+ QUICK_SELECT(THD *thd, TABLE *table,uint index_arg,bool no_alloc=0);
virtual ~QUICK_SELECT();
void reset(void) { next=0; it.rewind(); }
- virtual int init();
+ int init() { return error=file->index_init(index); }
virtual int get_next();
+ virtual bool reverse_sorted() { return 0; }
int cmp_next(QUICK_RANGE *range);
bool unique_key_range();
};
+
+class QUICK_SELECT_DESC: public QUICK_SELECT
+{
+public:
+ QUICK_SELECT_DESC(QUICK_SELECT *q, uint used_key_parts);
+ int get_next();
+ bool reverse_sorted() { return 1; }
+private:
+ int cmp_prev(QUICK_RANGE *range);
+ bool range_reads_after_key(QUICK_RANGE *range);
+#ifdef NOT_USED
+ bool test_if_null_range(QUICK_RANGE *range, uint used_key_parts);
+#endif
+ void reset(void) { next=0; rev_it.rewind(); }
+ List<QUICK_RANGE> rev_ranges;
+ List_iterator<QUICK_RANGE> rev_it;
+};
+
+
class SQL_SELECT :public Sql_alloc {
public:
QUICK_SELECT *quick; // If quick-select used
@@ -95,13 +124,15 @@ class SQL_SELECT :public Sql_alloc {
SQL_SELECT();
~SQL_SELECT();
- bool check_quick(bool force_quick_range=0, ha_rows limit = HA_POS_ERROR)
- { return test_quick_select(~0L,0,limit, force_quick_range) < 0; }
+ bool check_quick(THD *thd, bool force_quick_range= 0,
+ ha_rows limit= HA_POS_ERROR)
+ { return test_quick_select(thd, ~0L,0,limit, force_quick_range) < 0; }
inline bool skipp_record() { return cond ? cond->val_int() == 0 : 0; }
- int test_quick_select(key_map keys,table_map prev_tables,ha_rows limit,
- bool force_quick_range=0);
+ int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
+ ha_rows limit, bool force_quick_range=0);
};
-QUICK_SELECT *get_quick_select_for_ref(TABLE *table, struct st_table_ref *ref);
+QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
+ struct st_table_ref *ref);
#endif