Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
925e508a
Commit
925e508a
authored
Jun 19, 2010
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#121: DS-MRR support for clustered primary keys
- First code (will need code cleanup)
parent
7715f237
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
318 additions
and
93 deletions
+318
-93
sql/handler.h
sql/handler.h
+3
-2
sql/multi_range_read.cc
sql/multi_range_read.cc
+262
-65
sql/multi_range_read.h
sql/multi_range_read.h
+17
-3
sql/opt_range.cc
sql/opt_range.cc
+2
-0
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+2
-1
sql/sql_select.cc
sql/sql_select.cc
+2
-1
storage/maria/ha_maria.cc
storage/maria/ha_maria.cc
+6
-5
storage/maria/ha_maria.h
storage/maria/ha_maria.h
+4
-2
storage/myisam/ha_myisam.cc
storage/myisam/ha_myisam.cc
+5
-5
storage/myisam/ha_myisam.h
storage/myisam/ha_myisam.h
+4
-2
storage/xtradb/handler/ha_innodb.cc
storage/xtradb/handler/ha_innodb.cc
+7
-5
storage/xtradb/handler/ha_innodb.h
storage/xtradb/handler/ha_innodb.h
+4
-2
No files found.
sql/handler.h
View file @
925e508a
...
...
@@ -1752,9 +1752,10 @@ public:
uint
n_ranges
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
virtual
ha_rows
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
virtual
int
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
virtual
int
multi_range_read_next
(
char
**
range_info
);
virtual
int
read_range_first
(
const
key_range
*
start_key
,
...
...
sql/multi_range_read.cc
View file @
925e508a
This diff is collapsed.
Click to expand it.
sql/multi_range_read.h
View file @
925e508a
...
...
@@ -43,6 +43,17 @@ private:
bool
is_mrr_assoc
;
bool
use_default_impl
;
/* TRUE <=> shortcut all calls to default MRR impl */
bool
doing_cpk_scan
;
uint
cpk_tuple_length
;
uint
cpk_n_parts
;
bool
cpk_is_unique_scan
;
char
*
cpk_saved_range_info
;
bool
cpk_have_range
;
bool
check_cpk_scan
(
uint
keyno
,
uint
mrr_flags
);
static
int
key_tuple_cmp
(
void
*
arg
,
uchar
*
key1
,
uchar
*
key2
);
public:
void
init
(
handler
*
h_arg
,
TABLE
*
table_arg
)
{
...
...
@@ -50,13 +61,16 @@ public:
table
=
table_arg
;
}
int
dsmrr_init
(
handler
*
h
,
RANGE_SEQ_IF
*
seq_funcs
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
void
dsmrr_close
();
int
dsmrr_fill_buffer
();
int
dsmrr_fill_buffer_cpk
();
int
dsmrr_next
(
char
**
range_info
);
int
dsmrr_next_cpk
(
char
**
range_info
);
ha_rows
dsmrr_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
ha_rows
dsmrr_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
ha_rows
dsmrr_info_const
(
uint
keyno
,
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
*
bufsz
,
...
...
sql/opt_range.cc
View file @
925e508a
...
...
@@ -8006,6 +8006,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
quick
->
mrr_buf_size
=
thd
->
variables
.
mrr_buff_size
;
if
(
table
->
file
->
multi_range_read_info
(
quick
->
index
,
1
,
(
uint
)
records
,
uint
(
-
1
),
&
quick
->
mrr_buf_size
,
&
quick
->
mrr_flags
,
&
cost
))
goto
err
;
...
...
@@ -8367,6 +8368,7 @@ int QUICK_RANGE_SELECT::reset()
RANGE_SEQ_IF
seq_funcs
=
{
quick_range_seq_init
,
quick_range_seq_next
,
0
,
0
};
error
=
file
->
multi_range_read_init
(
&
seq_funcs
,
(
void
*
)
this
,
ranges
.
elements
,
uint
(
-
1
),
mrr_flags
,
mrr_buf_desc
?
mrr_buf_desc
:
&
empty_buf
);
DBUG_RETURN
(
error
);
...
...
sql/sql_join_cache.cc
View file @
925e508a
...
...
@@ -2377,7 +2377,8 @@ JOIN_CACHE_BKA::init_join_matching_records(RANGE_SEQ_IF *seq_funcs, uint ranges)
if
(
!
file
->
inited
)
file
->
ha_index_init
(
join_tab
->
ref
.
key
,
1
);
if
((
error
=
file
->
multi_range_read_init
(
seq_funcs
,
(
void
*
)
this
,
ranges
,
mrr_mode
,
&
mrr_buff
)))
join_tab
->
ref
.
key_parts
,
mrr_mode
,
&
mrr_buff
)))
rc
=
error
<
0
?
NESTED_LOOP_NO_MORE_ROWS
:
NESTED_LOOP_ERROR
;
return
rc
;
...
...
sql/sql_select.cc
View file @
925e508a
...
...
@@ -7318,10 +7318,11 @@ uint check_join_cache_usage(JOIN_TAB *tab,
case
JT_EQ_REF
:
if
(
cache_level
<=
4
)
return
0
;
flags
=
HA_MRR_NO_NULL_ENDPOINTS
;
flags
=
HA_MRR_NO_NULL_ENDPOINTS
|
HA_MRR_SINGLE_POINT
;
if
(
tab
->
table
->
covering_keys
.
is_set
(
tab
->
ref
.
key
))
flags
|=
HA_MRR_INDEX_ONLY
;
rows
=
tab
->
table
->
file
->
multi_range_read_info
(
tab
->
ref
.
key
,
10
,
20
,
tab
->
ref
.
key_parts
,
&
bufsz
,
&
flags
,
&
cost
);
if
((
rows
!=
HA_POS_ERROR
)
&&
!
(
flags
&
HA_MRR_USE_DEFAULT_IMPL
)
&&
(
!
(
flags
&
HA_MRR_NO_ASSOCIATION
)
||
cache_level
>
6
)
&&
...
...
storage/maria/ha_maria.cc
View file @
925e508a
...
...
@@ -3501,10 +3501,11 @@ static SHOW_VAR status_variables[]= {
***************************************************************************/
int
ha_maria
::
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
)
{
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
mode
,
buf
);
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
key_parts
,
mode
,
buf
);
}
int
ha_maria
::
multi_range_read_next
(
char
**
range_info
)
...
...
@@ -3528,11 +3529,11 @@ ha_rows ha_maria::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
}
ha_rows
ha_maria
::
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
)
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
)
{
ds_mrr
.
init
(
this
,
table
);
return
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
bufsz
,
flags
,
cost
);
return
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
key_parts
,
bufsz
,
flags
,
cost
);
}
/* MyISAM MRR implementation ends */
...
...
storage/maria/ha_maria.h
View file @
925e508a
...
...
@@ -174,14 +174,16 @@ public:
* Multi Range Read interface
*/
int
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
int
multi_range_read_next
(
char
**
range_info
);
ha_rows
multi_range_read_info_const
(
uint
keyno
,
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
ha_rows
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
/* Index condition pushdown implementation */
Item
*
idx_cond_push
(
uint
keyno
,
Item
*
idx_cond
);
...
...
storage/myisam/ha_myisam.cc
View file @
925e508a
...
...
@@ -2217,10 +2217,10 @@ static int myisam_init(void *p)
***************************************************************************/
int
ha_myisam
::
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
)
{
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
mode
,
buf
);
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
key_parts
,
mode
,
buf
);
}
int
ha_myisam
::
multi_range_read_next
(
char
**
range_info
)
...
...
@@ -2244,11 +2244,11 @@ ha_rows ha_myisam::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
}
ha_rows
ha_myisam
::
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
)
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
)
{
ds_mrr
.
init
(
this
,
table
);
return
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
bufsz
,
flags
,
cost
);
return
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
key_parts
,
bufsz
,
flags
,
cost
);
}
/* MyISAM MRR implementation ends */
...
...
storage/myisam/ha_myisam.h
View file @
925e508a
...
...
@@ -162,14 +162,16 @@ public:
* Multi Range Read interface
*/
int
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
int
multi_range_read_next
(
char
**
range_info
);
ha_rows
multi_range_read_info_const
(
uint
keyno
,
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
ha_rows
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
/* Index condition pushdown implementation */
Item
*
idx_cond_push
(
uint
keyno
,
Item
*
idx_cond
);
...
...
storage/xtradb/handler/ha_innodb.cc
View file @
925e508a
...
...
@@ -11025,9 +11025,10 @@ test_innobase_convert_name()
*/
int
ha_innobase
::
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
HANDLER_BUFFER
*
buf
)
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
)
{
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
mode
,
buf
);
return
ds_mrr
.
dsmrr_init
(
this
,
seq
,
seq_init_param
,
n_ranges
,
key_parts
,
mode
,
buf
);
}
int
ha_innobase
::
multi_range_read_next
(
char
**
range_info
)
...
...
@@ -11052,12 +11053,13 @@ ha_rows ha_innobase::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
return
res
;
}
ha_rows
ha_innobase
::
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
ha_rows
ha_innobase
::
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
key
_part
s
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
)
{
ds_mrr
.
init
(
this
,
table
);
ha_rows
res
=
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
bufsz
,
flags
,
cost
);
ha_rows
res
=
ds_mrr
.
dsmrr_info
(
keyno
,
n_ranges
,
keys
,
key_parts
,
bufsz
,
flags
,
cost
);
return
res
;
}
...
...
storage/xtradb/handler/ha_innodb.h
View file @
925e508a
...
...
@@ -210,14 +210,16 @@ public:
* Multi Range Read interface
*/
int
multi_range_read_init
(
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
uint
n_ranges
,
uint
key_parts
,
uint
mode
,
HANDLER_BUFFER
*
buf
);
int
multi_range_read_next
(
char
**
range_info
);
ha_rows
multi_range_read_info_const
(
uint
keyno
,
RANGE_SEQ_IF
*
seq
,
void
*
seq_init_param
,
uint
n_ranges
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
ha_rows
multi_range_read_info
(
uint
keyno
,
uint
n_ranges
,
uint
keys
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
uint
key_parts
,
uint
*
bufsz
,
uint
*
flags
,
COST_VECT
*
cost
);
DsMrr_impl
ds_mrr
;
Item
*
idx_cond_push
(
uint
keyno
,
Item
*
idx_cond
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment