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
7966258a
Commit
7966258a
authored
Jun 04, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-19345 Cleanup inconsistency in setting HA_(BLOB|VAR_LENGTH|BIT)_PART flags
parent
bf5a144e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
43 deletions
+21
-43
sql/field.h
sql/field.h
+7
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-13
sql/table.cc
sql/table.cc
+12
-30
No files found.
sql/field.h
View file @
7966258a
...
...
@@ -1025,6 +1025,8 @@ class Field: public Value_source
virtual
bool
binary
()
const
{
return
1
;
}
virtual
bool
zero_pack
()
const
{
return
1
;
}
virtual
enum
ha_base_keytype
key_type
()
const
{
return
HA_KEYTYPE_BINARY
;
}
virtual
uint16
key_part_flag
()
const
{
return
0
;
}
virtual
uint16
key_part_length_bytes
()
const
{
return
0
;
}
virtual
uint32
key_length
()
const
{
return
pack_length
();
}
virtual
const
Type_handler
*
type_handler
()
const
=
0
;
virtual
enum_field_types
type
()
const
...
...
@@ -3653,6 +3655,8 @@ class Field_varstring :public Field_longstr {
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_varchar
;
}
enum
ha_base_keytype
key_type
()
const
;
uint16
key_part_flag
()
const
{
return
HA_VAR_LENGTH_PART
;
}
uint16
key_part_length_bytes
()
const
{
return
HA_KEY_BLOB_LENGTH
;
}
uint
row_pack_length
()
const
{
return
field_length
;
}
bool
zero_pack
()
const
{
return
0
;
}
int
reset
(
void
)
{
bzero
(
ptr
,
field_length
+
length_bytes
);
return
0
;
}
...
...
@@ -3868,6 +3872,8 @@ class Field_blob :public Field_longstr {
}
enum
ha_base_keytype
key_type
()
const
{
return
binary
()
?
HA_KEYTYPE_VARBINARY2
:
HA_KEYTYPE_VARTEXT2
;
}
uint16
key_part_flag
()
const
{
return
HA_BLOB_PART
;
}
uint16
key_part_length_bytes
()
const
{
return
HA_KEY_BLOB_LENGTH
;
}
Type_std_attributes
type_std_attributes
()
const
{
return
Type_std_attributes
(
Field_blob
::
max_display_length
(),
decimals
(),
...
...
@@ -4354,6 +4360,7 @@ class Field_bit :public Field {
enum
utype
unireg_check_arg
,
const
LEX_CSTRING
*
field_name_arg
);
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_bit
;
}
enum
ha_base_keytype
key_type
()
const
{
return
HA_KEYTYPE_BIT
;
}
uint16
key_part_flag
()
const
{
return
HA_BIT_PART
;
}
uint32
key_length
()
const
{
return
(
uint32
)
(
field_length
+
7
)
/
8
;
}
uint32
max_data_length
()
const
{
return
(
field_length
+
7
)
/
8
;
}
uint32
max_display_length
()
const
{
return
field_length
;
}
...
...
sql/sql_select.cc
View file @
7966258a
...
...
@@ -18628,19 +18628,8 @@ bool Create_tmp_table::finalize(THD *thd,
m_key_part_info->store_length+= HA_KEY_NULL_LENGTH;
m_key_part_info->key_part_flag |= HA_NULL_PART;
}
if
((
*
reg_field
)
->
type
()
==
MYSQL_TYPE_BLOB
||
(
*
reg_field
)
->
real_type
()
==
MYSQL_TYPE_VARCHAR
||
(
*
reg_field
)
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
{
if
((
*
reg_field
)
->
type
()
==
MYSQL_TYPE_BLOB
||
(
*
reg_field
)
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
m_key_part_info
->
key_part_flag
|=
HA_BLOB_PART
;
else
m_key_part_info
->
key_part_flag
|=
HA_VAR_LENGTH_PART
;
m_key_part_info
->
store_length
+=
HA_KEY_BLOB_LENGTH
;
}
m_key_part_info->key_part_flag|= (*reg_field)->key_part_flag();
m_key_part_info->store_length+= (*reg_field)->key_part_length_bytes();
keyinfo->key_length+= m_key_part_info->store_length;
m_key_part_info->type= (uint8) (*reg_field)->key_type();
...
...
sql/table.cc
View file @
7966258a
...
...
@@ -2552,7 +2552,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
KEY_PART_INFO
*
new_key_part
=
(
keyinfo
-
1
)
->
key_part
+
(
keyinfo
-
1
)
->
ext_key_parts
;
uint
add_keyparts_for_this_key
=
add_first_key_parts
;
uint
len
gth_bytes
=
0
,
len
_null_byte
=
0
,
ext_key_length
=
0
;
uint
len_null_byte
=
0
,
ext_key_length
=
0
;
Field
*
field
;
if
((
keyinfo
-
1
)
->
algorithm
==
HA_KEY_ALG_LONG_HASH
)
...
...
@@ -2564,19 +2564,15 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
*/
for
(
i
=
0
;
i
<
keyinfo
->
user_defined_key_parts
;
i
++
)
{
uint
length_bytes
=
0
;
uint
fieldnr
=
keyinfo
->
key_part
[
i
].
fieldnr
;
field
=
share
->
field
[
fieldnr
-
1
];
if
(
field
->
null_ptr
)
len_null_byte
=
HA_KEY_NULL_LENGTH
;
if
((
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
real_type
()
==
MYSQL_TYPE_VARCHAR
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
&&
keyinfo
->
algorithm
!=
HA_KEY_ALG_LONG_HASH
)
{
length_bytes
=
HA_KEY_BLOB_LENGTH
;
}
if
(
keyinfo
->
algorithm
!=
HA_KEY_ALG_LONG_HASH
)
length_bytes
=
field
->
key_part_length_bytes
();
ext_key_length
+=
keyinfo
->
key_part
[
i
].
length
+
len_null_byte
+
length_bytes
;
...
...
@@ -2665,20 +2661,11 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
keyinfo
->
flags
|=
HA_NULL_PART_KEY
;
keyinfo
->
key_length
+=
HA_KEY_NULL_LENGTH
;
}
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
real_type
()
==
MYSQL_TYPE_VARCHAR
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
{
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
key_part
->
key_part_flag
|=
HA_BLOB_PART
;
else
key_part
->
key_part_flag
|=
HA_VAR_LENGTH_PART
;
key_part
->
store_length
+=
HA_KEY_BLOB_LENGTH
;
keyinfo
->
key_length
+=
HA_KEY_BLOB_LENGTH
;
}
if
(
field
->
type
()
==
MYSQL_TYPE_BIT
)
key_part
->
key_part_flag
|=
HA_BIT_PART
;
key_part
->
key_part_flag
|=
field
->
key_part_flag
();
uint16
key_part_length_bytes
=
field
->
key_part_length_bytes
();
key_part
->
store_length
+=
key_part_length_bytes
;
keyinfo
->
key_length
+=
key_part_length_bytes
;
if
(
i
==
0
&&
key
!=
primary_key
)
field
->
flags
|=
(((
keyinfo
->
flags
&
HA_NOSAME
||
...
...
@@ -7481,14 +7468,9 @@ void TABLE::create_key_part_by_field(KEY_PART_INFO *key_part_info,
{
key_part_info
->
store_length
+=
HA_KEY_NULL_LENGTH
;
}
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
||
field
->
real_type
()
==
MYSQL_TYPE_VARCHAR
)
{
key_part_info
->
store_length
+=
HA_KEY_BLOB_LENGTH
;
key_part_info
->
key_part_flag
|=
field
->
type
()
==
MYSQL_TYPE_BLOB
?
HA_BLOB_PART
:
HA_VAR_LENGTH_PART
;
}
key_part_info
->
key_part_flag
|=
field
->
key_part_flag
();
key_part_info
->
store_length
+=
field
->
key_part_length_bytes
();
key_part_info
->
type
=
(
uint8
)
field
->
key_type
();
key_part_info
->
key_type
=
...
...
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