summaryrefslogtreecommitdiff
path: root/sql/opt_range.h
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2004-11-21 11:51:19 +0300
committerunknown <sergefp@mysql.com>2004-11-21 11:51:19 +0300
commitfebda72f628cbd3c9ca638f0022ef1c765d41c2c (patch)
tree4405a89b7616b6761af8778b22aaa0801ee5bcad /sql/opt_range.h
parent6763a1da76a07c3962492acae491c341714f8b82 (diff)
downloadmariadb-git-febda72f628cbd3c9ca638f0022ef1c765d41c2c.tar.gz
Fix for BUG#4177:
* Make index merge quick selects code allow perform several scans. * Delay additional handler objects creation till row retrieval is started. include/queues.h: Added trivial queue_remove_all macro mysql-test/r/index_merge.result: Testcase for BUG#4177 mysql-test/t/index_merge.test: Testcase for BUG#4177 sql/opt_range.cc: Fix for BUG#4177: * For any quick select, row retrieval can be performed several times. Now all index_merge quick selects code handles such cases properly. * In QUICK_INDEX_MERGE_SELECT we use one handler object for all merged scans, and it was possible that in destructor several cleanup functions were called * Additionally - Removed redundant QUICK_INDEX_MERGE_SELECT members. - Now QUICK_ROR_*_SELECTs create additional handler objects only when row retrieval is started So if join optimizer chooses other access method, we don't create/delete handlers.
Diffstat (limited to 'sql/opt_range.h')
-rw-r--r--sql/opt_range.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 19234f61ea2..74d388128c8 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -127,7 +127,8 @@ public:
reset() should be called when it is certain that row retrieval will be
necessary. This call may do heavyweight initialization like buffering first
N records etc. If reset() call fails get_next() must not be called.
-
+ Note that reset() may be called several times if this quick select
+ executes in a subselect.
RETURN
0 OK
other Error code
@@ -274,6 +275,10 @@ public:
next=0;
range= NULL;
cur_range= NULL;
+ /*
+ Note: in opt_range.cc there are places where it is assumed that this
+ function always succeeds
+ */
return 0;
}
int init();
@@ -388,21 +393,15 @@ public:
/* range quick selects this index_merge read consists of */
List<QUICK_RANGE_SELECT> quick_selects;
- /* quick select which is currently used for rows retrieval */
- List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it;
- QUICK_RANGE_SELECT* cur_quick_select;
-
/* quick select that uses clustered primary key (NULL if none) */
QUICK_RANGE_SELECT* pk_quick_select;
/* true if this select is currently doing a clustered PK scan */
bool doing_pk_scan;
- Unique *unique;
MEM_ROOT alloc;
-
THD *thd;
- int prepare_unique();
+ int read_keys_and_merge();
/* used to get rows collected in Unique */
READ_RECORD read_record;
@@ -465,6 +464,8 @@ public:
MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
THD *thd; /* current thread */
bool need_to_fetch_row; /* if true, do retrieve full table records. */
+ /* in top-level quick select, true if merged scans where initialized */
+ bool scans_inited;
};
@@ -514,6 +515,7 @@ public:
uint rowid_length; /* table rowid length */
private:
static int queue_cmp(void *arg, byte *val1, byte *val2);
+ bool scans_inited;
};