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
87c2db37
Commit
87c2db37
authored
Nov 23, 2019
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of a cycle
parent
bba4488a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
38 deletions
+74
-38
sql/handler.cc
sql/handler.cc
+28
-38
sql/key.cc
sql/key.cc
+42
-0
sql/key.h
sql/key.h
+4
-0
No files found.
sql/handler.cc
View file @
87c2db37
...
@@ -7002,49 +7002,39 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
...
@@ -7002,49 +7002,39 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
if
(
error
)
if
(
error
)
return
error
;
return
error
;
for
(
int
run
=
0
;
run
<
2
;
run
++
)
auto
old_row_found
=
[
is_update
,
old_data
,
record_buffer
,
this
](){
{
if
(
run
==
0
)
{
error
=
handler
->
ha_index_read_map
(
record_buffer
,
check_overlaps_buffer
,
key_part_map
((
1
<<
key_parts
)
-
1
),
HA_READ_KEY_OR_PREV
);
if
(
error
==
HA_ERR_KEY_NOT_FOUND
)
continue
;
}
else
{
error
=
handler
->
ha_index_next
(
record_buffer
);
if
(
error
==
HA_ERR_END_OF_FILE
)
continue
;
}
if
(
error
)
{
handler
->
ha_index_end
();
return
error
;
}
/* In case of update it could appear that the nearest neighbour is
/* In case of update it could appear that the nearest neighbour is
* a record we are updating. It means, that there are no overlaps
* a record we are updating. It means, that there are no overlaps
* from this side. */
* from this side. */
if
(
is_update
&&
memcmp
(
old_data
+
table
->
s
->
null_bytes
,
return
is_update
&&
memcmp
(
old_data
+
table
->
s
->
null_bytes
,
record_buffer
+
table
->
s
->
null_bytes
,
record_buffer
+
table
->
s
->
null_bytes
,
table
->
s
->
reclength
-
table
->
s
->
null_bytes
)
==
0
)
table
->
s
->
reclength
-
table
->
s
->
null_bytes
)
==
0
;
{
};
continue
;
}
if
(
table
->
check_period_overlaps
(
key_info
,
key_info
,
new_data
,
record_buffer
)
==
0
)
error
=
handler
->
ha_index_read_map
(
record_buffer
,
{
check_overlaps_buffer
,
handler
->
ha_index_end
();
key_part_map
((
1
<<
key_parts
)
-
1
),
return
HA_ERR_FOUND_DUPP_KEY
;
HA_READ_KEY_OR_PREV
);
}
}
if
(
!
error
&&
!
old_row_found
()
error
=
handler
->
ha_index_end
();
&&
table
->
check_period_overlaps
(
key_info
,
key_info
,
if
(
error
)
new_data
,
record_buffer
)
==
0
)
return
error
;
error
=
HA_ERR_FOUND_DUPP_KEY
;
if
(
!
error
||
error
==
HA_ERR_KEY_NOT_FOUND
)
error
=
handler
->
ha_index_next
(
record_buffer
);
if
(
!
error
&&
!
old_row_found
()
&&
table
->
check_period_overlaps
(
key_info
,
key_info
,
new_data
,
record_buffer
)
==
0
)
error
=
HA_ERR_FOUND_DUPP_KEY
;
if
(
error
==
HA_ERR_END_OF_FILE
)
error
=
0
;
int
end_error
=
handler
->
ha_index_end
();
if
(
error
||
end_error
)
return
error
?
error
:
end_error
;
}
}
return
0
;
return
0
;
}
}
...
...
sql/key.cc
View file @
87c2db37
...
@@ -896,3 +896,45 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
...
@@ -896,3 +896,45 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
}
}
return
FALSE
;
return
FALSE
;
}
}
int
key_period_compare_bases
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
)
{
uint
base_part_nr
=
lhs_key
.
user_defined_key_parts
-
2
;
int
cmp_res
=
0
;
for
(
uint
part_nr
=
0
;
!
cmp_res
&&
part_nr
<
base_part_nr
;
part_nr
++
)
{
Field
*
f
=
lhs_key
.
key_part
[
part_nr
].
field
;
cmp_res
=
f
->
cmp
(
f
->
ptr_in_record
(
lhs
),
rhs_key
.
key_part
[
part_nr
].
field
->
ptr_in_record
(
rhs
));
}
return
cmp_res
;
}
int
key_period_compare_periods
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
)
{
uint
base_part_nr
=
lhs_key
.
user_defined_key_parts
-
2
;
Field
*
lhs_fields
[]
=
{
lhs_key
.
key_part
[
base_part_nr
].
field
,
lhs_key
.
key_part
[
base_part_nr
+
1
].
field
};
Field
*
rhs_fields
[]
=
{
rhs_key
.
key_part
[
base_part_nr
].
field
,
rhs_key
.
key_part
[
base_part_nr
+
1
].
field
};
int
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
++
)
{
cmp
[
i
][
j
]
=
lhs_fields
[
0
]
->
cmp
(
lhs_fields
[
i
]
->
ptr_in_record
(
lhs
),
rhs_fields
[
j
]
->
ptr_in_record
(
rhs
));
}
}
bool
overlaps
=
(
cmp
[
0
][
0
]
<=
0
&&
cmp
[
1
][
0
]
>
0
)
||
(
cmp
[
0
][
0
]
>=
0
&&
cmp
[
0
][
1
]
<
0
);
return
overlaps
?
0
:
cmp
[
0
][
0
];
}
\ No newline at end of file
sql/key.h
View file @
87c2db37
...
@@ -40,5 +40,9 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
...
@@ -40,5 +40,9 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
const
uchar
*
key1
,
const
uchar
*
key2
);
const
uchar
*
key1
,
const
uchar
*
key2
);
extern
"C"
int
key_rec_cmp
(
void
*
key_info
,
uchar
*
a
,
uchar
*
b
);
extern
"C"
int
key_rec_cmp
(
void
*
key_info
,
uchar
*
a
,
uchar
*
b
);
int
key_tuple_cmp
(
KEY_PART_INFO
*
part
,
uchar
*
key1
,
uchar
*
key2
,
uint
tuple_length
);
int
key_tuple_cmp
(
KEY_PART_INFO
*
part
,
uchar
*
key1
,
uchar
*
key2
,
uint
tuple_length
);
int
key_period_compare_bases
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
);
int
key_period_compare_periods
(
const
KEY
&
lhs_key
,
const
KEY
&
rhs_key
,
const
uchar
*
lhs
,
const
uchar
*
rhs
);
#endif
/* KEY_INCLUDED */
#endif
/* KEY_INCLUDED */
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