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
383baa81
Commit
383baa81
authored
Jul 13, 2023
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: invert return code
parent
010f535b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
sql/sql_class.cc
sql/sql_class.cc
+9
-9
sql/sql_class.h
sql/sql_class.h
+1
-1
sql/sql_table.cc
sql/sql_table.cc
+5
-6
No files found.
sql/sql_class.cc
View file @
383baa81
...
...
@@ -213,11 +213,11 @@ Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root)
We only compare field names
RETURN
0
Generated key is a prefix of other key
1 Not equal
true
Generated key is a prefix of other key
false Not a prefix
*/
bool
foreign_key_prefix
(
Key
*
a
,
Key
*
b
)
bool
is_
foreign_key_prefix
(
Key
*
a
,
Key
*
b
)
{
/* Ensure that 'a' is the generated key */
if
(
a
->
generated
)
...
...
@@ -228,13 +228,13 @@ bool foreign_key_prefix(Key *a, Key *b)
else
{
if
(
!
b
->
generated
)
return
TRUE
;
// No foreign key
return
false
;
// No foreign key
swap_variables
(
Key
*
,
a
,
b
);
// Put generated key in 'a'
}
/* Test if 'a' is a prefix of 'b' */
if
(
a
->
columns
.
elements
>
b
->
columns
.
elements
)
return
TRUE
;
// Can't be prefix
return
false
;
// Can't be prefix
List_iterator
<
Key_part_spec
>
col_it1
(
a
->
columns
);
List_iterator
<
Key_part_spec
>
col_it2
(
b
->
columns
);
...
...
@@ -254,17 +254,17 @@ bool foreign_key_prefix(Key *a, Key *b)
}
}
if
(
!
found
)
return
TRUE
;
// Error
return
false
;
// Error
}
return
FALSE
;
// Is prefix
return
true
;
// Is prefix
#else
while
((
col1
=
col_it1
++
))
{
col2
=
col_it2
++
;
if
(
!
(
*
col1
==
*
col2
))
return
TRUE
;
return
false
;
}
return
FALSE
;
// Is prefix
return
true
;
// Is prefix
#endif
}
...
...
sql/sql_class.h
View file @
383baa81
...
...
@@ -446,7 +446,7 @@ class Key :public Sql_alloc, public DDL_options {
Key
(
const
Key
&
rhs
,
MEM_ROOT
*
mem_root
);
virtual
~
Key
()
=
default
;
/* Equality comparison of keys (ignoring name) */
friend
bool
foreign_key_prefix
(
Key
*
a
,
Key
*
b
);
friend
bool
is_
foreign_key_prefix
(
Key
*
a
,
Key
*
b
);
/**
Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for Key_part_spec::clone
...
...
sql/sql_table.cc
View file @
383baa81
...
...
@@ -3835,13 +3835,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
while
((
key2
=
key_iterator2
++
)
!=
key
)
{
/*
foreign_key_prefix(key, key2) returns 0 if key or key2, or both, is
'generated', and a generated key is a prefix of the other key.
Then we do not need the generated shorter key.
is_foreign_key_prefix(key, key2) returns true if key or key2, or
both, is 'generated', and a generated key is a prefix of the other
key.
Then we do not need the generated shorter key.
*/
if
((
key2
->
type
!=
Key
::
FOREIGN_KEY
&&
key2
->
name
.
str
!=
ignore_key
&&
!
foreign_key_prefix
(
key
,
key2
)))
if
(
key2
->
type
!=
Key
::
FOREIGN_KEY
&&
key2
->
name
.
str
!=
ignore_key
&&
is_foreign_key_prefix
(
key
,
key2
))
{
/* mark that the generated key should be ignored */
if
(
!
key2
->
generated
||
...
...
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