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
42e1296e
Commit
42e1296e
authored
Jul 16, 2003
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mi_keycache.c:
new file Many files: Added CACHE INDEX command
parent
5a458484
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
190 additions
and
12 deletions
+190
-12
include/myisam.h
include/myisam.h
+2
-0
myisam/mi_keycache.c
myisam/mi_keycache.c
+47
-0
sql/ha_myisam.cc
sql/ha_myisam.cc
+58
-0
sql/ha_myisam.h
sql/ha_myisam.h
+1
-0
sql/handler.cc
sql/handler.cc
+5
-0
sql/handler.h
sql/handler.h
+1
-0
sql/mysql_priv.h
sql/mysql_priv.h
+1
-0
sql/sql_lex.cc
sql/sql_lex.cc
+2
-1
sql/sql_lex.h
sql/sql_lex.h
+6
-3
sql/sql_parse.cc
sql/sql_parse.cc
+11
-2
sql/sql_table.cc
sql/sql_table.cc
+21
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+35
-6
No files found.
include/myisam.h
View file @
42e1296e
...
...
@@ -410,6 +410,8 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,
int
mi_init_bulk_insert
(
MI_INFO
*
info
,
ulong
cache_size
,
ha_rows
rows
);
void
mi_flush_bulk_insert
(
MI_INFO
*
info
,
uint
inx
);
void
mi_end_bulk_insert
(
MI_INFO
*
info
);
int
mi_assign_to_keycache
(
MI_INFO
*
info
,
ulonglong
key_map
,
char
*
keycache_name
);
int
mi_preload
(
MI_INFO
*
info
,
ulonglong
key_map
,
my_bool
ignore_leaves
);
#ifdef __cplusplus
...
...
myisam/mi_keycache.c
0 → 100644
View file @
42e1296e
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Key cache assignments
*/
#include "myisamdef.h"
/*
Assign pages of the index file for a table to a key cache
SYNOPSIS
mi_assign_to_keycache()
info open table
map map of indexes to assign to the key cache
keycache_name name of of the key cache to assign index to
RETURN VALUE
0 if a success. error code - otherwise.
NOTES.
At present pages for all indexes must be assigned to the same key cache.
In future only pages for indexes specified in the key_map parameter
of the table will be assigned to the specified key cache.
*/
int
mi_assign_to_keycache
(
MI_INFO
*
info
,
ulonglong
key_map
,
char
*
keycache_name
)
{
return
0
;
}
sql/ha_myisam.cc
View file @
42e1296e
...
...
@@ -688,6 +688,64 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize)
}
/*
Assign table indexes to a key cache.
*/
int
ha_myisam
::
assign_to_keycache
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
)
{
int
error
;
const
char
*
errmsg
;
ulonglong
map
=
~
(
ulonglong
)
0
;
TABLE_LIST
*
table_list
=
table
->
pos_in_table_list
;
char
*
keycache_name
=
table_list
->
option
;
DBUG_ENTER
(
"ha_myisam::assign_to_keycache"
);
/* Check validity of the index references */
if
(
table_list
->
use_index
)
{
key_map
kmap
=
get_key_map_from_key_list
(
table
,
table_list
->
use_index
);
if
(
kmap
==
~
(
key_map
)
0
)
{
errmsg
=
thd
->
net
.
last_error
;
error
=
HA_ADMIN_FAILED
;
goto
err
;
}
if
(
kmap
)
map
=
kmap
;
}
if
((
error
=
mi_assign_to_keycache
(
file
,
map
,
keycache_name
)))
{
switch
(
error
)
{
default:
char
buf
[
ERRMSGSIZE
+
20
];
my_snprintf
(
buf
,
ERRMSGSIZE
,
"Failed to read from index file (errno: %d)"
,
my_errno
);
errmsg
=
buf
;
}
error
=
HA_ADMIN_FAILED
;
goto
err
;
}
DBUG_RETURN
(
HA_ADMIN_OK
);
err:
{
MI_CHECK
param
;
myisamchk_init
(
&
param
);
param
.
thd
=
thd
;
param
.
op_name
=
(
char
*
)
"assign_to_keycache"
;
param
.
db_name
=
table
->
table_cache_key
;
param
.
table_name
=
table
->
table_name
;
param
.
testflag
=
0
;
mi_check_print_error
(
&
param
,
errmsg
);
DBUG_RETURN
(
error
);
}
}
/*
Preload pages of the index file for a table into the key cache.
*/
...
...
sql/ha_myisam.h
View file @
42e1296e
...
...
@@ -127,6 +127,7 @@ class ha_myisam: public handler
int
optimize
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
int
restore
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
int
backup
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
int
assign_to_keycache
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
int
preload_keys
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
#ifdef HAVE_REPLICATION
int
dump
(
THD
*
thd
,
int
fd
);
...
...
sql/handler.cc
View file @
42e1296e
...
...
@@ -620,6 +620,11 @@ int handler::analyze(THD* thd, HA_CHECK_OPT* check_opt)
return
HA_ADMIN_NOT_IMPLEMENTED
;
}
int
handler
::
assign_to_keycache
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
)
{
return
HA_ADMIN_NOT_IMPLEMENTED
;
}
int
handler
::
preload_keys
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
)
{
return
HA_ADMIN_NOT_IMPLEMENTED
;
...
...
sql/handler.h
View file @
42e1296e
...
...
@@ -305,6 +305,7 @@ public:
virtual
int
optimize
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
virtual
int
analyze
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
virtual
int
backup
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
virtual
int
assign_to_keycache
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
virtual
int
preload_keys
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
/*
restore assumes .frm file must exist, and that generate_table() has been
...
...
sql/mysql_priv.h
View file @
42e1296e
...
...
@@ -403,6 +403,7 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* table_list,
HA_CHECK_OPT
*
check_opt
);
int
mysql_optimize_table
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
HA_CHECK_OPT
*
check_opt
);
int
mysql_assign_to_keycache
(
THD
*
thd
,
TABLE_LIST
*
table_list
);
int
mysql_preload_keys
(
THD
*
thd
,
TABLE_LIST
*
table_list
);
bool
check_simple_select
();
...
...
sql/sql_lex.cc
View file @
42e1296e
...
...
@@ -1205,7 +1205,8 @@ TABLE_LIST *st_select_lex_node::add_table_to_list(THD *thd, Table_ident *table,
ulong
table_join_options
,
thr_lock_type
flags
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
List
<
String
>
*
ignore_index
,
LEX_STRING
*
option
)
{
return
0
;
}
...
...
sql/sql_lex.h
View file @
42e1296e
...
...
@@ -59,7 +59,8 @@ enum enum_sql_command {
SQLCOM_CHANGE_DB
,
SQLCOM_CREATE_DB
,
SQLCOM_DROP_DB
,
SQLCOM_ALTER_DB
,
SQLCOM_REPAIR
,
SQLCOM_REPLACE
,
SQLCOM_REPLACE_SELECT
,
SQLCOM_CREATE_FUNCTION
,
SQLCOM_DROP_FUNCTION
,
SQLCOM_REVOKE
,
SQLCOM_OPTIMIZE
,
SQLCOM_CHECK
,
SQLCOM_PRELOAD_KEYS
,
SQLCOM_REVOKE
,
SQLCOM_OPTIMIZE
,
SQLCOM_CHECK
,
SQLCOM_ASSIGN_TO_KEYCACHE
,
SQLCOM_PRELOAD_KEYS
,
SQLCOM_FLUSH
,
SQLCOM_KILL
,
SQLCOM_ANALYZE
,
SQLCOM_ROLLBACK
,
SQLCOM_COMMIT
,
SQLCOM_SLAVE_START
,
SQLCOM_SLAVE_STOP
,
SQLCOM_BEGIN
,
SQLCOM_LOAD_MASTER_TABLE
,
SQLCOM_CHANGE_MASTER
,
...
...
@@ -252,7 +253,8 @@ public:
ulong
table_options
,
thr_lock_type
flags
=
TL_UNLOCK
,
List
<
String
>
*
use_index
=
0
,
List
<
String
>
*
ignore_index
=
0
);
List
<
String
>
*
ignore_index
=
0
,
LEX_STRING
*
option
=
0
);
virtual
void
set_lock_for_tables
(
thr_lock_type
lock_type
)
{}
void
mark_as_dependent
(
st_select_lex
*
last
);
...
...
@@ -409,7 +411,8 @@ public:
ulong
table_options
,
thr_lock_type
flags
=
TL_UNLOCK
,
List
<
String
>
*
use_index
=
0
,
List
<
String
>
*
ignore_index
=
0
);
List
<
String
>
*
ignore_index
=
0
,
LEX_STRING
*
option
=
0
);
void
set_lock_for_tables
(
thr_lock_type
lock_type
);
inline
void
init_order
()
{
...
...
sql/sql_parse.cc
View file @
42e1296e
...
...
@@ -1881,6 +1881,14 @@ mysql_execute_command(THD *thd)
res
=
mysql_restore_table
(
thd
,
tables
);
break
;
}
case
SQLCOM_ASSIGN_TO_KEYCACHE
:
{
if
(
check_db_used
(
thd
,
tables
)
||
check_access
(
thd
,
INDEX_ACL
,
tables
->
db
,
&
tables
->
grant
.
privilege
))
goto
error
;
res
=
mysql_assign_to_keycache
(
thd
,
tables
);
break
;
}
case
SQLCOM_PRELOAD_KEYS
:
{
if
(
check_db_used
(
thd
,
tables
)
||
...
...
@@ -4063,7 +4071,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
ulong
table_options
,
thr_lock_type
lock_type
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
List
<
String
>
*
ignore_index
,
LEX_STRING
*
option
)
{
register
TABLE_LIST
*
ptr
;
char
*
alias_str
;
...
...
@@ -4124,7 +4133,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
if
(
ignore_index
)
ptr
->
ignore_index
=
(
List
<
String
>
*
)
thd
->
memdup
((
gptr
)
ignore_index
,
sizeof
(
*
ignore_index
));
ptr
->
option
=
option
?
option
->
str
:
0
;
/* check that used name is unique */
if
(
lock_type
!=
TL_IGNORE
)
{
...
...
sql/sql_table.cc
View file @
42e1296e
...
...
@@ -1560,6 +1560,27 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
}
/*
Assigned specified indexes for a table into key cache
SYNOPSIS
mysql_assign_to_keycache()
thd Thread object
tables Table list (one table only)
RETURN VALUES
0 ok
-1 error
*/
int
mysql_assign_to_keycache
(
THD
*
thd
,
TABLE_LIST
*
tables
)
{
DBUG_ENTER
(
"mysql_assign_to_keycache"
);
DBUG_RETURN
(
mysql_admin_table
(
thd
,
tables
,
0
,
"assign_to_keycache"
,
TL_WRITE
,
0
,
0
,
0
,
&
handler
::
assign_to_keycache
));
}
/*
Preload specified indexes for a table into key cache
...
...
sql/sql_yacc.yy
View file @
42e1296e
...
...
@@ -657,11 +657,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <NONE>
query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename
show describe load alter optimize preload flush
show describe load alter optimize
keycache
preload flush
reset purge begin commit rollback slave master_def master_defs
repair restore backup analyze check start
field_list field_list_item field_spec kill column_def key_def
preload_list preload_keys
keycache_list assign_to_keycache
preload_list preload_keys
select_item_list select_item values_list no_braces
opt_limit_clause delete_limit_clause fields opt_values values
procedure_list procedure_list2 procedure_item
...
...
@@ -730,6 +730,7 @@ verb_clause:
| lock
| kill
| optimize
| keycache
| preload
| purge
| rename
...
...
@@ -1843,6 +1844,34 @@ table_to_table:
YYABORT;
};
keycache:
CACHE_SYM INDEX
{
LEX *lex=Lex;
lex->sql_command=SQLCOM_ASSIGN_TO_KEYCACHE;
}
keycache_list
{}
;
keycache_list:
assign_to_keycache
| keycache_list ',' assign_to_keycache;
assign_to_keycache:
table_ident cache_keys_spec ident
{
LEX *lex=Lex;
SELECT_LEX *sel= &lex->select_lex;
if (!sel->add_table_to_list(lex->thd, $1, NULL, 0,
TL_WRITE,
sel->get_use_index(),
(List<String> *)0,
&($3)))
YYABORT;
}
;
preload:
LOAD INDEX INTO CACHE_SYM
{
...
...
@@ -1858,7 +1887,7 @@ preload_list:
| preload_list ',' preload_keys;
preload_keys:
table_ident
preload
_keys_spec opt_ignore_leaves
table_ident
cache
_keys_spec opt_ignore_leaves
{
LEX *lex=Lex;
SELECT_LEX *sel= &lex->select_lex;
...
...
@@ -1870,9 +1899,9 @@ preload_keys:
}
;
preload
_keys_spec:
cache
_keys_spec:
keys_or_index { Select->select_lex()->interval_list.empty(); }
preload
_key_list_or_empty
cache
_key_list_or_empty
{
LEX *lex=Lex;
SELECT_LEX *sel= &lex->select_lex;
...
...
@@ -1881,7 +1910,7 @@ preload_keys_spec:
}
;
preload
_key_list_or_empty:
cache
_key_list_or_empty:
/* empty */
| '(' key_usage_list2 ')' {}
;
...
...
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