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
3616175f
Commit
3616175f
authored
Oct 05, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20760 Add Type_handler::KEY_pack_flags()
parent
c717483c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
sql/sql_table.cc
sql/sql_table.cc
+4
-10
sql/sql_type.h
sql/sql_type.h
+27
-0
No files found.
sql/sql_table.cc
View file @
3616175f
...
...
@@ -4147,16 +4147,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
/* Use packed keys for long strings on the first column */
if
(
!
((
*
db_options
)
&
HA_OPTION_NO_PACK_KEYS
)
&&
!
((
create_info
->
table_options
&
HA_OPTION_NO_PACK_KEYS
))
&&
(
key_part_length
>=
KEY_DEFAULT_PACK_LENGTH
&&
(
sql_field
->
real_field_type
()
==
MYSQL_TYPE_STRING
||
sql_field
->
real_field_type
()
==
MYSQL_TYPE_VARCHAR
||
f_is_blob
(
sql_field
->
pack_flag
)))
&&
!
is_hash_field_needed
)
{
if
((
column_nr
==
0
&&
f_is_blob
(
sql_field
->
pack_flag
))
||
sql_field
->
real_field_type
()
==
MYSQL_TYPE_VARCHAR
)
key_info
->
flags
|=
HA_BINARY_PACK_KEY
|
HA_VAR_LENGTH_KEY
;
else
key_info
->
flags
|=
HA_PACK_KEY
;
(
key_part_length
>=
KEY_DEFAULT_PACK_LENGTH
)
&&
!
is_hash_field_needed
)
{
key_info
->
flags
|=
sql_field
->
type_handler
()
->
KEY_pack_flags
(
column_nr
);
}
/* Check if the key segment is partial, set the key flag accordingly */
if
(
key_part_length
!=
sql_field
->
type_handler
()
->
...
...
sql/sql_type.h
View file @
3616175f
...
...
@@ -3362,6 +3362,7 @@ class Type_handler
virtual
const
Name
version
()
const
;
virtual
const
Name
&
default_value
()
const
=
0
;
virtual
uint32
flags
()
const
{
return
0
;
}
virtual
ulong
KEY_pack_flags
(
uint
column_nr
)
const
{
return
0
;
}
bool
is_unsigned
()
const
{
return
flags
()
&
UNSIGNED_FLAG
;
}
virtual
enum_field_types
field_type
()
const
=
0
;
virtual
enum_field_types
real_field_type
()
const
{
return
field_type
();
}
...
...
@@ -6410,6 +6411,10 @@ class Type_handler_string: public Type_handler_longstr
virtual
~
Type_handler_string
()
{}
const
Name
name
()
const
override
;
enum_field_types
field_type
()
const
override
{
return
MYSQL_TYPE_STRING
;
}
ulong
KEY_pack_flags
(
uint
column_nr
)
const
override
{
return
HA_PACK_KEY
;
}
bool
is_param_long_data_type
()
const
override
{
return
true
;
}
uint32
max_display_length_for_field
(
const
Conv_source
&
src
)
const
override
;
uint32
calc_pack_length
(
uint32
length
)
const
override
{
return
length
;
}
...
...
@@ -6481,6 +6486,12 @@ class Type_handler_varchar: public Type_handler_longstr
virtual
~
Type_handler_varchar
()
{}
const
Name
name
()
const
override
;
enum_field_types
field_type
()
const
override
{
return
MYSQL_TYPE_VARCHAR
;
}
ulong
KEY_pack_flags
(
uint
column_nr
)
const
override
{
if
(
column_nr
==
0
)
return
HA_BINARY_PACK_KEY
|
HA_VAR_LENGTH_KEY
;
return
HA_PACK_KEY
;
}
enum_field_types
type_code_for_protocol
()
const
override
{
return
MYSQL_TYPE_VAR_STRING
;
// Keep things compatible for old clients
...
...
@@ -6547,6 +6558,11 @@ class Type_handler_varchar_compressed: public Type_handler_varchar
{
return
MYSQL_TYPE_VARCHAR_COMPRESSED
;
}
ulong
KEY_pack_flags
(
uint
column_nr
)
const
override
{
DBUG_ASSERT
(
0
);
return
0
;
}
uint32
max_display_length_for_field
(
const
Conv_source
&
src
)
const
override
;
void
show_binlog_type
(
const
Conv_source
&
src
,
const
Field
&
dst
,
String
*
str
)
const
override
;
...
...
@@ -6567,6 +6583,12 @@ class Type_handler_blob_common: public Type_handler_longstr
public:
virtual
~
Type_handler_blob_common
()
{
}
virtual
uint
length_bytes
()
const
=
0
;
ulong
KEY_pack_flags
(
uint
column_nr
)
const
override
{
if
(
column_nr
==
0
)
return
HA_BINARY_PACK_KEY
|
HA_VAR_LENGTH_KEY
;
return
HA_PACK_KEY
;
}
Field
*
make_conversion_table_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
uint
metadata
,
const
Field
*
target
)
const
override
;
...
...
@@ -6713,6 +6735,11 @@ class Type_handler_blob_compressed: public Type_handler_blob
{
return
MYSQL_TYPE_BLOB_COMPRESSED
;
}
ulong
KEY_pack_flags
(
uint
column_nr
)
const
override
{
DBUG_ASSERT
(
0
);
return
0
;
}
uint32
max_display_length_for_field
(
const
Conv_source
&
src
)
const
override
;
void
show_binlog_type
(
const
Conv_source
&
src
,
const
Field
&
,
String
*
str
)
const
override
;
...
...
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