1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_OPTIMIZER_SEL_IMERGE_H
21
#define DRIZZLED_OPTIMIZER_SEL_IMERGE_H
23
#include "drizzled/memory/sql_alloc.h"
36
SEL_IMERGE is a list of possible ways to do index merge, i.e. it is
37
a condition in the following form:
38
(t_1||t_2||...||t_N) && (next)
40
where all t_i are optimizer::SEL_TREEs, next is another SEL_IMERGE and no pair
41
(t_i,t_j) contains SEL_ARGS for the same index.
43
optimizer::SEL_TREE contained in SEL_IMERGE always has merges=NULL.
45
This class relies on memory manager to do the cleanup.
47
class SEL_IMERGE : public memory::SqlAlloc
49
enum { PREALLOCED_TREES= 10};
51
SEL_TREE *trees_prealloced[PREALLOCED_TREES];
52
SEL_TREE **trees; /* trees used to do index_merge */
53
SEL_TREE **trees_next; /* last of these trees */
54
SEL_TREE **trees_end; /* end of allocated space */
56
SEL_ARG ***best_keys; /* best keys to read in optimizer::SEL_TREEs */
61
Add optimizer::SEL_TREE to this index_merge without any checks,
64
This function implements the following:
65
(x_1||...||x_N) || t = (x_1||...||x_N||t), where x_i, t are optimizer::SEL_TREEs
71
int or_sel_tree(RangeParameter *param, SEL_TREE *tree);
74
Perform OR operation on this SEL_IMERGE and supplied optimizer::SEL_TREE new_tree,
75
combining new_tree with one of the trees in this SEL_IMERGE if they both
76
have SEL_ARGs for the same key.
79
or_sel_tree_with_checks()
80
param Parameter from SqlSelect::test_quick_select
81
new_tree optimizer::SEL_TREE with type KEY or KEY_SMALLER.
84
This does the following:
85
(t_1||...||t_k)||new_tree =
87
= (t_1||...||t_k||new_tree)
89
= (t_1||....||(t_j|| new_tree)||...||t_k),
91
where t_i, y are optimizer::SEL_TREEs.
92
new_tree is combined with the first t_j it has a SEL_ARG on common
93
key with. As a consequence of this, choice of keys to do index_merge
94
read may depend on the order of conditions in WHERE part of the query.
98
1 One of the trees was combined with new_tree to optimizer::SEL_TREE::ALWAYS,
99
and (*this) should be discarded.
100
-1 An error occurred.
102
int or_sel_tree_with_checks(optimizer::RangeParameter *param, optimizer::SEL_TREE *new_tree);
105
Perform OR operation on this index_merge and supplied index_merge list.
109
1 - One of conditions in result is always true and this SEL_IMERGE
111
-1 - An error occurred
113
int or_sel_imerge_with_checks(optimizer::RangeParameter *param, SEL_IMERGE* imerge);
118
} /* namespace optimizer */
120
} /* namespace drizzled */
122
#endif /* DRIZZLED_OPTIMIZER_SEL_IMERGE_H */