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
bba4488a
Commit
bba4488a
authored
Nov 23, 2019
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move overlaps check to a separate function
parent
b3cdef5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
32 deletions
+23
-32
sql/handler.cc
sql/handler.cc
+6
-31
sql/table.cc
sql/table.cc
+9
-0
sql/table.h
sql/table.h
+8
-1
No files found.
sql/handler.cc
View file @
bba4488a
...
...
@@ -6982,18 +6982,18 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
for
(
uint
key_nr
=
0
;
key_nr
<
table_share
->
keys
;
key_nr
++
)
{
const
KEY
*
key_info
=
table
->
key_info
+
key_nr
;
const
uint
key_parts
=
key_info
->
user_defined_key_parts
;
if
(
!
key_info
->
without_overlaps
)
const
KEY
&
key_info
=
table
->
key_info
[
key_nr
]
;
const
uint
key_parts
=
key_info
.
user_defined_key_parts
;
if
(
!
key_info
.
without_overlaps
)
continue
;
key_copy
(
check_overlaps_buffer
,
new_data
,
key_info
,
0
);
key_copy
(
check_overlaps_buffer
,
new_data
,
&
key_info
,
0
);
if
(
is_update
)
{
bool
key_used
=
false
;
for
(
uint
k
=
0
;
k
<
key_parts
&&
!
key_used
;
k
++
)
key_used
=
bitmap_is_set
(
table
->
write_set
,
key_info
->
key_part
[
k
].
fieldnr
-
1
);
key_info
.
key_part
[
k
].
fieldnr
-
1
);
if
(
!
key_used
)
continue
;
}
...
...
@@ -7036,32 +7036,7 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
continue
;
}
uint
period_key_part_nr
=
key_parts
-
2
;
int
cmp_res
=
0
;
for
(
uint
part_nr
=
0
;
!
cmp_res
&&
part_nr
<
period_key_part_nr
;
part_nr
++
)
{
Field
*
f
=
key_info
->
key_part
[
part_nr
].
field
;
cmp_res
=
f
->
cmp
(
f
->
ptr_in_record
(
new_data
),
f
->
ptr_in_record
(
record_buffer
));
}
if
(
cmp_res
)
continue
;
/* key is different => no overlaps */
int
period_cmp
[
2
][
2
]
=
{
/* l1 > l2, l1 > r2, r1 > l2, r1 > r2 */
};
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
for
(
int
j
=
0
;
j
<
2
;
j
++
)
{
Field
*
lhs
=
key_info
->
key_part
[
period_key_part_nr
+
i
].
field
;
Field
*
rhs
=
key_info
->
key_part
[
period_key_part_nr
+
j
].
field
;
period_cmp
[
i
][
j
]
=
lhs
->
cmp
(
lhs
->
ptr_in_record
(
new_data
),
rhs
->
ptr_in_record
(
record_buffer
));
}
}
if
((
period_cmp
[
0
][
0
]
<=
0
&&
period_cmp
[
1
][
0
]
>
0
)
||
(
period_cmp
[
0
][
0
]
>=
0
&&
period_cmp
[
0
][
1
]
<
0
))
if
(
table
->
check_period_overlaps
(
key_info
,
key_info
,
new_data
,
record_buffer
)
==
0
)
{
handler
->
ha_index_end
();
return
HA_ERR_FOUND_DUPP_KEY
;
...
...
sql/table.cc
View file @
bba4488a
...
...
@@ -8618,6 +8618,15 @@ void TABLE::evaluate_update_default_function()
DBUG_VOID_RETURN
;
}
int
TABLE
::
check_period_overlaps
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
)
{
int
cmp_res
=
key_period_compare_bases
(
lhs_key
,
rhs_key
,
lhs
,
rhs
);
if
(
cmp_res
)
return
cmp_res
;
return
key_period_compare_periods
(
lhs_key
,
rhs_key
,
lhs
,
rhs
);
}
void
TABLE
::
vers_update_fields
()
{
...
...
sql/table.h
View file @
bba4488a
...
...
@@ -803,7 +803,7 @@ struct TABLE_SHARE
#endif
/**
System versioning support.
System versioning
and application-time periods
support.
*/
struct
period_info_t
{
...
...
@@ -1637,6 +1637,13 @@ struct TABLE
ha_rows
*
rows_inserted
);
bool
vers_check_update
(
List
<
Item
>
&
items
);
/*
@return -1, lhs precedes rhs
0, lhs overlaps rhs
1, lhs succeeds rhs
*/
static
int
check_period_overlaps
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
);
int
delete_row
();
void
vers_update_fields
();
void
vers_update_end
();
...
...
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