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
4b594f07
Commit
4b594f07
authored
Dec 04, 2020
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Refactoring
parent
6d93260e
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
174 deletions
+170
-174
sql/uniques.cc
sql/uniques.cc
+60
-87
sql/uniques.h
sql/uniques.h
+110
-87
No files found.
sql/uniques.cc
View file @
4b594f07
...
@@ -888,25 +888,6 @@ Variable_size_keys_descriptor::Variable_size_keys_descriptor(uint length)
...
@@ -888,25 +888,6 @@ Variable_size_keys_descriptor::Variable_size_keys_descriptor(uint length)
}
}
Variable_size_composite_key_desc
::
Variable_size_composite_key_desc
(
uint
length
)
:
Variable_size_keys_descriptor
(
length
),
Encode_key
()
{
}
Variable_size_composite_key_desc_for_gconcat
::
Variable_size_composite_key_desc_for_gconcat
(
uint
length
)
:
Variable_size_keys_descriptor
(
length
),
Encode_key_for_group_concat
()
{
}
Variable_size_keys_simple
::
Variable_size_keys_simple
(
uint
length
)
:
Variable_size_keys_descriptor
(
length
),
Encode_key
()
{
}
/*
/*
@brief
@brief
Setup the structures that are used when Unique stores packed values
Setup the structures that are used when Unique stores packed values
...
@@ -930,18 +911,11 @@ Variable_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
...
@@ -930,18 +911,11 @@ Variable_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
uint
non_const_args
,
uint
non_const_args
,
uint
arg_count
)
uint
arg_count
)
{
{
SORT_FIELD
*
sort
,
*
pos
;
SORT_FIELD
*
pos
;
if
(
init
())
if
(
init
(
thd
,
non_const_args
))
return
true
;
return
true
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
pos
=
sortorder
;
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
)
*
non_const_args
);
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
non_const_args
);
if
(
!
sort_keys
)
return
true
;
sort
=
pos
=
sortorder
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
{
Item
*
arg
=
item
->
get_arg
(
i
);
Item
*
arg
=
item
->
get_arg
(
i
);
...
@@ -975,20 +949,11 @@ Variable_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
...
@@ -975,20 +949,11 @@ Variable_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
bool
Variable_size_keys_descriptor
::
setup_for_field
(
THD
*
thd
,
Field
*
field
)
bool
Variable_size_keys_descriptor
::
setup_for_field
(
THD
*
thd
,
Field
*
field
)
{
{
SORT_FIELD
*
sort
,
*
pos
;
SORT_FIELD
*
pos
;
if
(
init
())
if
(
init
(
thd
,
1
))
return
true
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
));
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
1
);
if
(
!
sort_keys
)
return
true
;
return
true
;
sort
=
pos
=
sortorder
;
pos
=
sortorder
;
pos
->
setup_key_part_for_variable_size_key
(
field
);
// Nulls are always excluded
pos
->
setup_key_part_for_variable_size_key
(
field
);
return
false
;
return
false
;
}
}
...
@@ -1067,7 +1032,8 @@ uchar* Variable_size_composite_key_desc::make_record(bool exclude_nulls)
...
@@ -1067,7 +1032,8 @@ uchar* Variable_size_composite_key_desc::make_record(bool exclude_nulls)
return
make_encoded_record
(
sort_keys
,
exclude_nulls
);
return
make_encoded_record
(
sort_keys
,
exclude_nulls
);
}
}
uchar
*
Variable_size_composite_key_desc_for_gconcat
::
make_record
(
bool
exclude_nulls
)
uchar
*
Variable_size_composite_key_desc_for_gconcat
::
make_record
(
bool
exclude_nulls
)
{
{
return
make_encoded_record
(
sort_keys
,
exclude_nulls
);
return
make_encoded_record
(
sort_keys
,
exclude_nulls
);
}
}
...
@@ -1079,21 +1045,51 @@ uchar* Variable_size_keys_simple::make_record(bool exclude_nulls)
...
@@ -1079,21 +1045,51 @@ uchar* Variable_size_keys_simple::make_record(bool exclude_nulls)
}
}
bool
Variable_size_composite_key_desc
::
init
()
/*
@brief
Create the sortorder and Sort keys structures for a descriptor
@param thd THD structure
@param count Number of key parts to be allocated
@retval
TRUE ERROR
FALSE structures successfully created
*/
bool
Descriptor
::
init
(
THD
*
thd
,
uint
count
)
{
if
(
sortorder
)
return
false
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
)
*
count
);
if
(
!
sortorder
)
return
true
;
// OOM
sort_keys
=
new
Sort_keys
(
sortorder
,
count
);
if
(
!
sort_keys
)
return
true
;
// OOM
return
false
;
}
bool
Variable_size_composite_key_desc
::
init
(
THD
*
thd
,
uint
count
)
{
{
return
Encode_key
::
init
(
max_length
);
return
Descriptor
::
init
(
thd
,
count
)
||
Encode_variable_size_key
::
init
(
max_length
);
}
}
bool
Variable_size_composite_key_desc_for_gconcat
::
init
()
bool
Variable_size_composite_key_desc_for_gconcat
::
init
(
THD
*
thd
,
uint
count
)
{
{
return
Encode_key
::
init
(
max_length
);
return
Descriptor
::
init
(
thd
,
count
)
||
Encode_key_for_group_concat
::
init
(
max_length
);
}
}
bool
Variable_size_keys_simple
::
init
()
bool
Variable_size_keys_simple
::
init
(
THD
*
thd
,
uint
count
)
{
{
return
Encode_key
::
init
(
max_length
);
return
Descriptor
::
init
(
thd
,
count
)
||
Encode_variable_size_key
::
init
(
max_length
);
}
}
...
@@ -1103,18 +1099,11 @@ Variable_size_composite_key_desc_for_gconcat::setup_for_item(THD *thd,
...
@@ -1103,18 +1099,11 @@ Variable_size_composite_key_desc_for_gconcat::setup_for_item(THD *thd,
uint
non_const_args
,
uint
non_const_args
,
uint
arg_count
)
uint
arg_count
)
{
{
SORT_FIELD
*
sort
,
*
pos
;
if
(
init
(
thd
,
non_const_args
))
if
(
init
())
return
true
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
)
*
non_const_args
);
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
non_const_args
);
if
(
!
sort_keys
)
return
true
;
return
true
;
sort
=
pos
=
sortorder
;
SORT_FIELD
*
pos
;
pos
=
sortorder
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
{
Item
*
arg
=
item
->
get_arg
(
i
);
Item
*
arg
=
item
->
get_arg
(
i
);
...
@@ -1155,18 +1144,11 @@ Fixed_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
...
@@ -1155,18 +1144,11 @@ Fixed_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
uint
non_const_args
,
uint
non_const_args
,
uint
arg_count
)
uint
arg_count
)
{
{
SORT_FIELD
*
sort
,
*
pos
;
SORT_FIELD
*
pos
;
if
(
sortorder
)
if
(
Descriptor
::
init
(
thd
,
non_const_args
))
return
false
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
)
*
non_const_args
);
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
non_const_args
);
pos
=
sortorder
;
if
(
!
sort_keys
)
return
true
;
sort
=
pos
=
sortorder
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
{
Item
*
arg
=
item
->
get_arg
(
i
);
Item
*
arg
=
item
->
get_arg
(
i
);
...
@@ -1186,19 +1168,10 @@ Fixed_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
...
@@ -1186,19 +1168,10 @@ Fixed_size_keys_descriptor::setup_for_item(THD *thd, Item_sum *item,
bool
bool
Fixed_size_keys_descriptor
::
setup_for_field
(
THD
*
thd
,
Field
*
field
)
Fixed_size_keys_descriptor
::
setup_for_field
(
THD
*
thd
,
Field
*
field
)
{
{
SORT_FIELD
*
sort
,
*
pos
;
SORT_FIELD
*
pos
;
if
(
sortorder
)
if
(
Descriptor
::
init
(
thd
,
1
))
return
false
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
));
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
1
);
pos
=
sortorder
;
if
(
!
sort_keys
)
return
true
;
sort
=
pos
=
sortorder
;
pos
->
setup_key_part_for_fixed_size_key
(
field
);
pos
->
setup_key_part_for_fixed_size_key
(
field
);
return
false
;
return
false
;
...
@@ -1312,8 +1285,8 @@ Encode_key::~Encode_key()
...
@@ -1312,8 +1285,8 @@ Encode_key::~Encode_key()
0 NULL value
0 NULL value
>0 length of the packed record
>0 length of the packed record
*/
*/
uchar
*
Encode_key
::
make_encoded_record
(
Sort_keys
*
sort_keys
,
uchar
*
Encode_
variable_size_
key
::
make_encoded_record
(
Sort_keys
*
sort_keys
,
bool
exclude_nulls
)
bool
exclude_nulls
)
{
{
Field
*
field
;
Field
*
field
;
SORT_FIELD
*
sort_field
;
SORT_FIELD
*
sort_field
;
...
@@ -1389,4 +1362,4 @@ Encode_key_for_group_concat::make_encoded_record(Sort_keys *sort_keys,
...
@@ -1389,4 +1362,4 @@ Encode_key_for_group_concat::make_encoded_record(Sort_keys *sort_keys,
length
=
static_cast
<
uint
>
(
to
-
orig_to
);
length
=
static_cast
<
uint
>
(
to
-
orig_to
);
Variable_size_keys_descriptor
::
store_packed_length
(
orig_to
,
length
);
Variable_size_keys_descriptor
::
store_packed_length
(
orig_to
,
length
);
return
rec_ptr
;
return
rec_ptr
;
}
}
\ No newline at end of file
sql/uniques.h
View file @
4b594f07
This diff is collapsed.
Click to expand it.
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