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
387b690e
Commit
387b690e
authored
Feb 22, 2019
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: cosmetic fixes
parent
72ee1805
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
58 deletions
+45
-58
sql/handler.cc
sql/handler.cc
+12
-18
sql/sql_insert.cc
sql/sql_insert.cc
+2
-4
sql/sql_table.cc
sql/sql_table.cc
+12
-13
sql/table.cc
sql/table.cc
+19
-23
No files found.
sql/handler.cc
View file @
387b690e
...
@@ -4288,8 +4288,7 @@ static bool update_frm_version(TABLE *table)
...
@@ -4288,8 +4288,7 @@ static bool update_frm_version(TABLE *table)
*/
*/
uint
handler
::
get_dup_key
(
int
error
)
uint
handler
::
get_dup_key
(
int
error
)
{
{
DBUG_ASSERT
(
table_share
->
tmp_table
!=
NO_TMP_TABLE
||
DBUG_ASSERT
(
table_share
->
tmp_table
!=
NO_TMP_TABLE
||
m_lock_type
!=
F_UNLCK
);
m_lock_type
!=
F_UNLCK
);
DBUG_ENTER
(
"handler::get_dup_key"
);
DBUG_ENTER
(
"handler::get_dup_key"
);
if
(
table
->
s
->
long_unique_table
&&
table
->
file
->
errkey
<
table
->
s
->
keys
)
if
(
table
->
s
->
long_unique_table
&&
table
->
file
->
errkey
<
table
->
s
->
keys
)
DBUG_RETURN
(
table
->
file
->
errkey
);
DBUG_RETURN
(
table
->
file
->
errkey
);
...
@@ -6488,17 +6487,18 @@ static int wsrep_after_row(THD *thd)
...
@@ -6488,17 +6487,18 @@ static int wsrep_after_row(THD *thd)
}
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
static
int
check_duplicate_long_entry_key
(
TABLE
*
table
,
handler
*
h
,
uchar
*
new_rec
,
static
int
check_duplicate_long_entry_key
(
TABLE
*
table
,
handler
*
h
,
uint
key_no
)
uchar
*
new_rec
,
uint
key_no
)
{
{
Field
*
hash_field
;
Field
*
hash_field
;
int
result
,
error
=
0
;
int
result
,
error
=
0
;
KEY
*
key_info
=
table
->
key_info
+
key_no
;
KEY
*
key_info
=
table
->
key_info
+
key_no
;
hash_field
=
key_info
->
key_part
->
field
;
hash_field
=
key_info
->
key_part
->
field
;
uchar
ptr
[
HA_HASH_KEY_LENGTH_WITH_NULL
];
DBUG_ASSERT
((
key_info
->
flags
&
HA_NULL_PART_KEY
&&
DBUG_ASSERT
((
key_info
->
flags
&
HA_NULL_PART_KEY
&&
key_info
->
key_length
==
HA_HASH_KEY_LENGTH_WITH_NULL
)
key_info
->
key_length
==
HA_HASH_KEY_LENGTH_WITH_NULL
)
||
key_info
->
key_length
==
HA_HASH_KEY_LENGTH_WITHOUT_NULL
);
||
key_info
->
key_length
==
HA_HASH_KEY_LENGTH_WITHOUT_NULL
);
uchar
ptr
[
HA_HASH_KEY_LENGTH_WITH_NULL
];
if
(
hash_field
->
is_real_null
())
if
(
hash_field
->
is_real_null
())
return
0
;
return
0
;
...
@@ -6551,20 +6551,14 @@ static int check_duplicate_long_entry_key(TABLE *table, handler *h, uchar *new_r
...
@@ -6551,20 +6551,14 @@ static int check_duplicate_long_entry_key(TABLE *table, handler *h, uchar *new_r
while
(
!
is_same
&&
!
(
result
=
table
->
file
->
ha_index_next_same
(
table
->
check_unique_buf
,
while
(
!
is_same
&&
!
(
result
=
table
->
file
->
ha_index_next_same
(
table
->
check_unique_buf
,
ptr
,
key_info
->
key_length
)));
ptr
,
key_info
->
key_length
)));
if
(
is_same
)
if
(
is_same
)
{
table
->
file
->
errkey
=
key_no
;
error
=
HA_ERR_FOUND_DUPP_KEY
;
error
=
HA_ERR_FOUND_DUPP_KEY
;
goto
exit
;
goto
exit
;
}
}
else
goto
exit
;
}
if
(
result
==
HA_ERR_LOCK_WAIT_TIMEOUT
)
if
(
result
==
HA_ERR_LOCK_WAIT_TIMEOUT
)
{
table
->
file
->
errkey
=
key_no
;
error
=
HA_ERR_LOCK_WAIT_TIMEOUT
;
error
=
HA_ERR_LOCK_WAIT_TIMEOUT
;
}
exit:
exit:
if
(
error
)
table
->
file
->
errkey
=
key_no
;
h
->
ha_index_end
();
h
->
ha_index_end
();
return
error
;
return
error
;
}
}
...
...
sql/sql_insert.cc
View file @
387b690e
...
@@ -1744,10 +1744,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
...
@@ -1744,10 +1744,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
was used. This ensures that we don't get a problem when the
was used. This ensures that we don't get a problem when the
whole range of the key has been used.
whole range of the key has been used.
*/
*/
if
(
info
->
handle_duplicates
==
DUP_REPLACE
&&
if
(
info
->
handle_duplicates
==
DUP_REPLACE
&&
table
->
next_number_field
&&
table
->
next_number_field
&&
key_nr
==
table
->
s
->
next_number_index
&&
insert_id_for_cur_row
>
0
)
key_nr
==
table
->
s
->
next_number_index
&&
(
insert_id_for_cur_row
>
0
))
goto
err
;
goto
err
;
if
(
table
->
file
->
ha_table_flags
()
&
HA_DUPLICATE_POS
)
if
(
table
->
file
->
ha_table_flags
()
&
HA_DUPLICATE_POS
)
{
{
...
...
sql/sql_table.cc
View file @
387b690e
...
@@ -4163,12 +4163,11 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -4163,12 +4163,11 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if
(
key_length
>
max_key_length
&&
key
->
type
!=
Key
::
FULLTEXT
&&
if
(
key_length
>
max_key_length
&&
key
->
type
!=
Key
::
FULLTEXT
&&
!
is_hash_field_needed
)
!
is_hash_field_needed
)
{
{
my_error
(
ER_TOO_LONG_KEY
,
MYF
(
0
),
max_key_length
);
my_error
(
ER_TOO_LONG_KEY
,
MYF
(
0
),
max_key_length
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
if
(
is_hash_field_needed
&&
if
(
is_hash_field_needed
&&
key_info
->
algorithm
!=
HA_KEY_ALG_UNDEF
&&
key_info
->
algorithm
!=
HA_KEY_ALG_UNDEF
&&
key_info
->
algorithm
!=
HA_KEY_ALG_HASH
)
key_info
->
algorithm
!=
HA_KEY_ALG_HASH
)
{
{
my_error
(
ER_TOO_LONG_KEY
,
MYF
(
0
),
max_key_length
);
my_error
(
ER_TOO_LONG_KEY
,
MYF
(
0
),
max_key_length
);
...
...
sql/table.cc
View file @
387b690e
...
@@ -712,9 +712,9 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
...
@@ -712,9 +712,9 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
static
bool
create_key_infos
(
const
uchar
*
strpos
,
const
uchar
*
frm_image_end
,
static
bool
create_key_infos
(
const
uchar
*
strpos
,
const
uchar
*
frm_image_end
,
uint
keys
,
KEY
*
keyinfo
,
uint
keys
,
KEY
*
keyinfo
,
uint
new_frm_ver
,
uint
&
ext_key_parts
,
uint
new_frm_ver
,
uint
*
ext_key_parts
,
TABLE_SHARE
*
share
,
uint
len
,
TABLE_SHARE
*
share
,
uint
len
,
KEY
*
first_keyinfo
,
char
*
&
keynames
)
KEY
*
first_keyinfo
,
char
*
*
keynames
)
{
{
uint
i
,
j
,
n_length
;
uint
i
,
j
,
n_length
;
KEY_PART_INFO
*
key_part
=
NULL
;
KEY_PART_INFO
*
key_part
=
NULL
;
...
@@ -770,8 +770,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
...
@@ -770,8 +770,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
if
(
i
==
0
)
if
(
i
==
0
)
{
{
ext_key_parts
+=
(
share
->
use_ext_keys
?
first_keyinfo
->
user_defined_key_parts
*
(
keys
-
1
)
:
0
);
(
*
ext_key_parts
)
+=
(
share
->
use_ext_keys
?
first_keyinfo
->
user_defined_key_parts
*
(
keys
-
1
)
:
0
);
n_length
=
keys
*
sizeof
(
KEY
)
+
ext_key_parts
*
sizeof
(
KEY_PART_INFO
);
n_length
=
keys
*
sizeof
(
KEY
)
+
*
ext_key_parts
*
sizeof
(
KEY_PART_INFO
);
if
(
!
(
keyinfo
=
(
KEY
*
)
alloc_root
(
&
share
->
mem_root
,
if
(
!
(
keyinfo
=
(
KEY
*
)
alloc_root
(
&
share
->
mem_root
,
n_length
+
len
)))
n_length
+
len
)))
return
1
;
return
1
;
...
@@ -780,7 +780,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
...
@@ -780,7 +780,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
key_part
=
reinterpret_cast
<
KEY_PART_INFO
*>
(
keyinfo
+
keys
);
key_part
=
reinterpret_cast
<
KEY_PART_INFO
*>
(
keyinfo
+
keys
);
if
(
!
(
rec_per_key
=
(
ulong
*
)
alloc_root
(
&
share
->
mem_root
,
if
(
!
(
rec_per_key
=
(
ulong
*
)
alloc_root
(
&
share
->
mem_root
,
sizeof
(
ulong
)
*
ext_key_parts
)))
sizeof
(
ulong
)
*
*
ext_key_parts
)))
return
1
;
return
1
;
first_key_part
=
key_part
;
first_key_part
=
key_part
;
first_key_parts
=
first_keyinfo
->
user_defined_key_parts
;
first_key_parts
=
first_keyinfo
->
user_defined_key_parts
;
...
@@ -825,8 +825,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
...
@@ -825,8 +825,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
{
{
keyinfo
->
key_length
=
HA_HASH_KEY_LENGTH_WITHOUT_NULL
;
keyinfo
->
key_length
=
HA_HASH_KEY_LENGTH_WITHOUT_NULL
;
//Storing key hash
key_part
++
;
// reserved for the hash value
key_part
++
;
}
}
/*
/*
...
@@ -865,8 +864,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
...
@@ -865,8 +864,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
share
->
ext_key_parts
++
;
share
->
ext_key_parts
++
;
share
->
ext_key_parts
+=
keyinfo
->
ext_key_parts
;
share
->
ext_key_parts
+=
keyinfo
->
ext_key_parts
;
}
}
keynames
=
(
char
*
)
key_part
;
*
keynames
=
(
char
*
)
key_part
;
strpos
+=
strnmov
(
keynames
,
(
char
*
)
strpos
,
frm_image_end
-
strpos
)
-
keynames
;
strpos
+=
strnmov
(
*
keynames
,
(
char
*
)
strpos
,
frm_image_end
-
strpos
)
-
*
keynames
;
if
(
*
strpos
++
)
// key names are \0-terminated
if
(
*
strpos
++
)
// key names are \0-terminated
return
1
;
return
1
;
...
@@ -1189,17 +1188,18 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
...
@@ -1189,17 +1188,18 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
{
{
key
=
table
->
key_info
+
key_index
;
key
=
table
->
key_info
+
key_index
;
parts
=
key
->
user_defined_key_parts
;
parts
=
key
->
user_defined_key_parts
;
if
(
key
->
algorithm
==
HA_KEY_ALG_LONG_HASH
&&
if
(
key
->
key_part
[
parts
].
fieldnr
==
field
->
field_index
+
1
)
key
->
key_part
[
key
->
user_defined_key_parts
].
fieldnr
==
field
->
field_index
+
1
)
break
;
break
;
}
}
if
(
key
->
algorithm
!=
HA_KEY_ALG_LONG_HASH
)
goto
end
;
KEY_PART_INFO
*
keypart
;
KEY_PART_INFO
*
keypart
;
for
(
uint
i
=
0
;
i
<
parts
;
i
++
)
for
(
uint
i
=
0
;
i
<
parts
;
i
++
)
{
{
keypart
=
key
->
key_part
+
i
;
keypart
=
key
->
key_part
+
i
;
if
(
!
keypart
->
length
)
if
(
!
keypart
->
length
)
{
{
list_item
=
new
(
mem_root
)
Item_field
(
thd
,
keypart
->
field
);
list_item
=
new
(
mem_root
)
Item_field
(
thd
,
keypart
->
field
);
}
}
else
else
{
{
...
@@ -1581,7 +1581,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
...
@@ -1581,7 +1581,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
DBUG_ENTER
(
"TABLE_SHARE::init_from_binary_frm_image"
);
DBUG_ENTER
(
"TABLE_SHARE::init_from_binary_frm_image"
);
keyinfo
=
&
first_keyinfo
;
keyinfo
=
&
first_keyinfo
;
share
->
ext_key_parts
=
0
;
thd
->
mem_root
=
&
share
->
mem_root
;
thd
->
mem_root
=
&
share
->
mem_root
;
if
(
write
&&
write_frm_image
(
frm_image
,
frm_length
))
if
(
write
&&
write_frm_image
(
frm_image
,
frm_length
))
...
@@ -1821,8 +1820,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
...
@@ -1821,8 +1820,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
share
->
set_use_ext_keys_flag
(
plugin_hton
(
se_plugin
)
->
flags
&
HTON_SUPPORTS_EXTENDED_KEYS
);
share
->
set_use_ext_keys_flag
(
plugin_hton
(
se_plugin
)
->
flags
&
HTON_SUPPORTS_EXTENDED_KEYS
);
if
(
create_key_infos
(
disk_buff
+
6
,
frm_image_end
,
keys
,
keyinfo
,
if
(
create_key_infos
(
disk_buff
+
6
,
frm_image_end
,
keys
,
keyinfo
,
new_frm_ver
,
ext_key_parts
,
new_frm_ver
,
&
ext_key_parts
,
share
,
len
,
&
first_keyinfo
,
keynames
))
share
,
len
,
&
first_keyinfo
,
&
keynames
))
goto
err
;
goto
err
;
if
(
next_chunk
+
5
<
buff_end
)
if
(
next_chunk
+
5
<
buff_end
)
...
@@ -1914,14 +1913,14 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
...
@@ -1914,14 +1913,14 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
else
else
{
{
if
(
create_key_infos
(
disk_buff
+
6
,
frm_image_end
,
keys
,
keyinfo
,
if
(
create_key_infos
(
disk_buff
+
6
,
frm_image_end
,
keys
,
keyinfo
,
new_frm_ver
,
ext_key_parts
,
new_frm_ver
,
&
ext_key_parts
,
share
,
len
,
&
first_keyinfo
,
keynames
))
share
,
len
,
&
first_keyinfo
,
&
keynames
))
goto
err
;
goto
err
;
}
}
share
->
key_block_size
=
uint2korr
(
frm_image
+
62
);
share
->
key_block_size
=
uint2korr
(
frm_image
+
62
);
keyinfo
=
share
->
key_info
;
keyinfo
=
share
->
key_info
;
for
(
uint
i
=
0
;
i
<
share
->
keys
;
i
++
,
keyinfo
++
)
for
(
uint
i
=
0
;
i
<
share
->
keys
;
i
++
,
keyinfo
++
)
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
hash_fields
++
;
hash_fields
++
;
if
(
share
->
db_plugin
&&
!
plugin_equals
(
share
->
db_plugin
,
se_plugin
))
if
(
share
->
db_plugin
&&
!
plugin_equals
(
share
->
db_plugin
,
se_plugin
))
...
@@ -2436,10 +2435,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
...
@@ -2436,10 +2435,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uint
offset
=
share
->
reclength
-
HA_HASH_FIELD_LENGTH
*
hash_fields
;
uint
offset
=
share
->
reclength
-
HA_HASH_FIELD_LENGTH
*
hash_fields
;
for
(
uint
i
=
0
;
i
<
share
->
keys
;
i
++
,
keyinfo
++
)
for
(
uint
i
=
0
;
i
<
share
->
keys
;
i
++
,
keyinfo
++
)
{
{
/*
/* We need set value in hash key_part */
We need set value in hash key_part
*/
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
if
(
keyinfo
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
{
{
share
->
long_unique_table
=
1
;
share
->
long_unique_table
=
1
;
...
...
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