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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
1edf7e71
Commit
1edf7e71
authored
Nov 10, 2009
by
Mikael Ronstrom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review comments for LOCK_open patch
parent
5e7733bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
20 deletions
+28
-20
include/hash.h
include/hash.h
+6
-4
mysys/hash.c
mysys/hash.c
+16
-10
sql/sql_base.cc
sql/sql_base.cc
+6
-6
No files found.
include/hash.h
View file @
1edf7e71
...
...
@@ -45,7 +45,6 @@ extern "C" {
#define hash_element my_hash_element
#define hash_search my_hash_search
#define hash_first my_hash_first
#define hash_first_from_hash_value my_hash_first_from_hash_value
#define hash_next my_hash_next
#define hash_insert my_hash_insert
#define hash_delete my_hash_delete
...
...
@@ -65,6 +64,7 @@ extern "C" {
/* flags for hash_init */
#define HASH_UNIQUE 1
/* hash_insert fails on duplicate key */
typedef
uint
my_hash_value_type
;
typedef
uchar
*
(
*
my_hash_get_key
)(
const
uchar
*
,
size_t
*
,
my_bool
);
typedef
void
(
*
my_hash_free_key
)(
void
*
);
...
...
@@ -95,13 +95,15 @@ void my_hash_free(HASH *tree);
void
my_hash_reset
(
HASH
*
hash
);
uchar
*
my_hash_element
(
HASH
*
hash
,
ulong
idx
);
uchar
*
my_hash_search
(
const
HASH
*
info
,
const
uchar
*
key
,
size_t
length
);
uchar
*
my_hash_search_using_hash_value
(
const
HASH
*
info
,
uint
hash_value
,
uchar
*
my_hash_search_using_hash_value
(
const
HASH
*
info
,
my_hash_value_type
hash_value
,
const
uchar
*
key
,
size_t
length
);
uint
my_calc_hash
(
const
HASH
*
info
,
const
uchar
*
key
,
size_t
length
);
my_hash_value_type
my_calc_hash
(
const
HASH
*
info
,
const
uchar
*
key
,
size_t
length
);
uchar
*
my_hash_first
(
const
HASH
*
info
,
const
uchar
*
key
,
size_t
length
,
HASH_SEARCH_STATE
*
state
);
uchar
*
my_hash_first_from_hash_value
(
const
HASH
*
info
,
uint
hash_value
,
my_hash_value_type
hash_value
,
const
uchar
*
key
,
size_t
length
,
HASH_SEARCH_STATE
*
state
);
...
...
mysys/hash.c
View file @
1edf7e71
...
...
@@ -33,16 +33,18 @@ typedef struct st_hash_info {
uchar
*
data
;
/* data for current entry */
}
HASH_LINK
;
static
uint
my_hash_mask
(
size_t
hashnr
,
size_t
buffmax
,
size_t
maxlength
);
static
uint
my_hash_mask
(
my_hash_value_type
hashnr
,
size_t
buffmax
,
size_t
maxlength
);
static
void
movelink
(
HASH_LINK
*
array
,
uint
pos
,
uint
next_link
,
uint
newlink
);
static
int
hashcmp
(
const
HASH
*
hash
,
HASH_LINK
*
pos
,
const
uchar
*
key
,
size_t
length
);
static
uint
calc_hash
(
const
HASH
*
hash
,
const
uchar
*
key
,
size_t
length
)
static
my_hash_value_type
calc_hash
(
const
HASH
*
hash
,
const
uchar
*
key
,
size_t
length
)
{
ulong
nr1
=
1
,
nr2
=
4
;
hash
->
charset
->
coll
->
hash_sort
(
hash
->
charset
,(
uchar
*
)
key
,
length
,
&
nr1
,
&
nr2
);
return
nr1
;
return
(
my_hash_value_type
)
nr1
;
}
/**
...
...
@@ -179,7 +181,8 @@ my_hash_key(const HASH *hash, const uchar *record, size_t *length,
/* Calculate pos according to keys */
static
uint
my_hash_mask
(
size_t
hashnr
,
size_t
buffmax
,
size_t
maxlength
)
static
uint
my_hash_mask
(
my_hash_value_type
hashnr
,
size_t
buffmax
,
size_t
maxlength
)
{
if
((
hashnr
&
(
buffmax
-
1
))
<
maxlength
)
return
(
hashnr
&
(
buffmax
-
1
));
return
(
hashnr
&
((
buffmax
>>
1
)
-
1
));
...
...
@@ -200,7 +203,7 @@ static
#if !defined(__USLC__) && !defined(__sgi)
inline
#endif
unsigned
int
rec_hashnr
(
HASH
*
hash
,
const
uchar
*
record
)
my_hash_value_type
rec_hashnr
(
HASH
*
hash
,
const
uchar
*
record
)
{
size_t
length
;
uchar
*
key
=
(
uchar
*
)
my_hash_key
(
hash
,
record
,
&
length
,
0
);
...
...
@@ -215,7 +218,7 @@ uchar* my_hash_search(const HASH *hash, const uchar *key, size_t length)
}
uchar
*
my_hash_search_using_hash_value
(
const
HASH
*
hash
,
uint
hash_value
,
my_hash_value_type
hash_value
,
const
uchar
*
key
,
size_t
length
)
{
...
...
@@ -224,7 +227,8 @@ uchar* my_hash_search_using_hash_value(const HASH *hash,
key
,
length
,
&
state
);
}
uint
my_calc_hash
(
const
HASH
*
hash
,
const
uchar
*
key
,
size_t
length
)
my_hash_value_type
my_calc_hash
(
const
HASH
*
hash
,
const
uchar
*
key
,
size_t
length
)
{
return
calc_hash
(
hash
,
key
,
length
?
length
:
hash
->
key_length
);
}
...
...
@@ -244,7 +248,7 @@ uchar* my_hash_first(const HASH *hash, const uchar *key, size_t length,
}
uchar
*
my_hash_first_from_hash_value
(
const
HASH
*
hash
,
uint
hash_value
,
my_hash_value_type
hash_value
,
const
uchar
*
key
,
size_t
length
,
HASH_SEARCH_STATE
*
current_record
)
...
...
@@ -356,7 +360,8 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
my_bool
my_hash_insert
(
HASH
*
info
,
const
uchar
*
record
)
{
int
flag
;
size_t
idx
,
halfbuff
,
hash_nr
,
first_index
;
size_t
idx
,
halfbuff
,
first_index
;
my_hash_value_type
hash_nr
;
uchar
*
ptr_to_rec
,
*
ptr_to_rec2
;
HASH_LINK
*
data
,
*
empty
,
*
gpos
,
*
gpos2
,
*
pos
;
...
...
@@ -497,7 +502,8 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
my_bool
my_hash_delete
(
HASH
*
hash
,
uchar
*
record
)
{
uint
blength
,
pos2
,
pos_hashnr
,
lastpos_hashnr
,
idx
,
empty_index
;
uint
blength
,
pos2
,
idx
,
empty_index
;
my_hash_value_type
pos_hashnr
,
lastpos_hashnr
;
HASH_LINK
*
data
,
*
lastpos
,
*
gpos
,
*
pos
,
*
pos3
,
*
empty
;
DBUG_ENTER
(
"my_hash_delete"
);
if
(
!
hash
->
records
)
...
...
sql/sql_base.cc
View file @
1edf7e71
...
...
@@ -2513,7 +2513,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
char
key
[
MAX_DBKEY_LENGTH
];
uint
key_length
;
char
*
alias
=
table_list
->
alias
;
uint
hash_value
;
my_hash_value_type
hash_value
;
HASH_SEARCH_STATE
state
;
DBUG_ENTER
(
"open_table"
);
...
...
@@ -2746,11 +2746,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
an implicit "pending locks queue" - see
wait_for_locked_table_names for details.
*/
for
(
table
=
(
TABLE
*
)
hash_first_from_hash_value
(
&
open_cache
,
hash_value
,
(
uchar
*
)
key
,
key_length
,
&
state
);
for
(
table
=
(
TABLE
*
)
my_
hash_first_from_hash_value
(
&
open_cache
,
hash_value
,
(
uchar
*
)
key
,
key_length
,
&
state
);
table
&&
table
->
in_use
;
table
=
(
TABLE
*
)
hash_next
(
&
open_cache
,
(
uchar
*
)
key
,
key_length
,
&
state
))
...
...
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