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
a5a7ab19
Commit
a5a7ab19
authored
Jul 19, 2019
by
Eugene Kosov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: this is how to use span
parent
da7d82b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
32 deletions
+28
-32
storage/innobase/handler/handler0alter.cc
storage/innobase/handler/handler0alter.cc
+28
-32
No files found.
storage/innobase/handler/handler0alter.cc
View file @
a5a7ab19
...
@@ -52,6 +52,9 @@ Smart ALTER TABLE
...
@@ -52,6 +52,9 @@ Smart ALTER TABLE
#include "row0sel.h"
#include "row0sel.h"
#include "ha_innodb.h"
#include "ha_innodb.h"
#include "ut0stage.h"
#include "ut0stage.h"
#include "span.h"
using
st_
::
span
;
static
const
char
*
MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN
=
static
const
char
*
MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN
=
"INPLACE ADD or DROP of virtual columns cannot be "
"INPLACE ADD or DROP of virtual columns cannot be "
...
@@ -1272,20 +1275,22 @@ innobase_set_foreign_key_option(
...
@@ -1272,20 +1275,22 @@ innobase_set_foreign_key_option(
/*******************************************************************//**
/*******************************************************************//**
Check if a foreign key constraint can make use of an index
Check if a foreign key constraint can make use of an index
that is being created.
that is being created.
@param[in] col_names column names
@param[in] n_cols number of columns
@param[in] keys index information
@param[in] add indexes being created
@return useable index, or NULL if none found */
@return useable index, or NULL if none found */
static
MY_ATTRIBUTE
((
nonnull
,
warn_unused_result
))
static
MY_ATTRIBUTE
((
nonnull
,
warn_unused_result
))
const
KEY
*
const
KEY
*
innobase_find_equiv_index
(
innobase_find_equiv_index
(
/*======================*/
const
char
*
const
*
col_names
,
const
char
*
const
*
col_names
,
/*!< in: column names */
uint
n_cols
,
uint
n_cols
,
/*!< in: number of columns */
const
KEY
*
keys
,
const
KEY
*
keys
,
/*!< in: index information */
span
<
uint
>
add
)
const
uint
*
add
,
/*!< in: indexes being created */
uint
n_add
)
/*!< in: number of indexes to create */
{
{
for
(
uint
i
=
0
;
i
<
n_add
;
i
++
)
{
for
(
span
<
uint
>::
iterator
it
=
add
.
begin
(),
end
=
add
.
end
();
it
!=
end
;
const
KEY
*
key
=
&
keys
[
add
[
i
]];
++
it
)
{
const
KEY
*
key
=
&
keys
[
*
it
];
if
(
key
->
user_defined_key_parts
<
n_cols
if
(
key
->
user_defined_key_parts
<
n_cols
||
key
->
flags
&
HA_SPATIAL
)
{
||
key
->
flags
&
HA_SPATIAL
)
{
...
@@ -1336,7 +1341,7 @@ innobase_find_equiv_index(
...
@@ -1336,7 +1341,7 @@ innobase_find_equiv_index(
Find an index whose first fields are the columns in the array
Find an index whose first fields are the columns in the array
in the same order and is not marked for deletion
in the same order and is not marked for deletion
@return matching index, NULL if not found */
@return matching index, NULL if not found */
static
MY_ATTRIBUTE
((
nonnull
(
1
,
2
,
6
),
warn_unused_result
))
static
MY_ATTRIBUTE
((
nonnull
(
1
,
2
,
5
),
warn_unused_result
))
dict_index_t
*
dict_index_t
*
innobase_find_fk_index
(
innobase_find_fk_index
(
/*===================*/
/*===================*/
...
@@ -1346,10 +1351,8 @@ innobase_find_fk_index(
...
@@ -1346,10 +1351,8 @@ innobase_find_fk_index(
const
char
**
col_names
,
const
char
**
col_names
,
/*!< in: column names, or NULL
/*!< in: column names, or NULL
to use table->col_names */
to use table->col_names */
dict_index_t
**
drop_index
,
span
<
dict_index_t
*>
drop_index
,
/*!< in: indexes to be dropped */
/*!< in: indexes to be dropped */
ulint
n_drop_index
,
/*!< in: size of drop_index[] */
const
char
**
columns
,
/*!< in: array of column names */
const
char
**
columns
,
/*!< in: array of column names */
ulint
n_cols
)
/*!< in: number of columns */
ulint
n_cols
)
/*!< in: number of columns */
{
{
...
@@ -1358,21 +1361,14 @@ innobase_find_fk_index(
...
@@ -1358,21 +1361,14 @@ innobase_find_fk_index(
index
=
dict_table_get_first_index
(
table
);
index
=
dict_table_get_first_index
(
table
);
while
(
index
!=
NULL
)
{
while
(
index
!=
NULL
)
{
if
(
dict_foreign_qualify_index
(
if
(
dict_foreign_qualify_index
(
table
,
col_names
,
columns
,
table
,
col_names
,
columns
,
n_cols
,
n_cols
,
index
,
NULL
,
true
,
0
,
index
,
NULL
,
true
,
0
,
NULL
,
NULL
,
NULL
)
NULL
,
NULL
,
NULL
))
{
&&
std
::
find
(
drop_index
.
begin
(),
drop_index
.
end
(),
index
)
for
(
ulint
i
=
0
;
i
<
n_drop_index
;
i
++
)
{
==
drop_index
.
end
())
{
if
(
index
==
drop_index
[
i
])
{
return
index
;
/* Skip to-be-dropped indexes. */
goto
next_rec
;
}
}
return
(
index
);
}
}
next_rec:
index
=
dict_table_get_next_index
(
index
);
index
=
dict_table_get_next_index
(
index
);
}
}
...
@@ -1519,7 +1515,7 @@ innobase_get_foreign_key_info(
...
@@ -1519,7 +1515,7 @@ innobase_get_foreign_key_info(
index
=
innobase_find_fk_index
(
index
=
innobase_find_fk_index
(
ha_alter_info
,
ha_alter_info
,
table
,
col_names
,
table
,
col_names
,
drop_index
,
n_drop_index
,
span
<
dict_index_t
*>
(
drop_index
,
n_drop_index
)
,
column_names
,
i
);
column_names
,
i
);
/* MySQL would add a index in the creation
/* MySQL would add a index in the creation
...
@@ -1534,8 +1530,8 @@ innobase_get_foreign_key_info(
...
@@ -1534,8 +1530,8 @@ innobase_get_foreign_key_info(
if
(
!
index
&&
!
innobase_find_equiv_index
(
if
(
!
index
&&
!
innobase_find_equiv_index
(
column_names
,
static_cast
<
uint
>
(
i
),
column_names
,
static_cast
<
uint
>
(
i
),
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
index_add_buffer
,
span
<
uint
>
(
ha_alter_info
->
index_add_buffer
,
ha_alter_info
->
index_add_count
))
{
ha_alter_info
->
index_add_count
)
))
{
my_error
(
my_error
(
ER_FK_NO_INDEX_CHILD
,
ER_FK_NO_INDEX_CHILD
,
MYF
(
0
),
MYF
(
0
),
...
@@ -5180,8 +5176,8 @@ innobase_check_foreign_key_index(
...
@@ -5180,8 +5176,8 @@ innobase_check_foreign_key_index(
foreign
->
referenced_col_names
,
foreign
->
referenced_col_names
,
foreign
->
n_fields
,
foreign
->
n_fields
,
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
index_add_buffer
,
span
<
uint
>
(
ha_alter_info
->
index_add_buffer
,
ha_alter_info
->
index_add_count
))
{
ha_alter_info
->
index_add_count
)
))
{
/* Index cannot be dropped. */
/* Index cannot be dropped. */
trx
->
error_info
=
index
;
trx
->
error_info
=
index
;
...
@@ -5215,8 +5211,8 @@ innobase_check_foreign_key_index(
...
@@ -5215,8 +5211,8 @@ innobase_check_foreign_key_index(
foreign
->
foreign_col_names
,
foreign
->
foreign_col_names
,
foreign
->
n_fields
,
foreign
->
n_fields
,
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
key_info_buffer
,
ha_alter_info
->
index_add_buffer
,
span
<
uint
>
(
ha_alter_info
->
index_add_buffer
,
ha_alter_info
->
index_add_count
))
{
ha_alter_info
->
index_add_count
)
))
{
/* Index cannot be dropped. */
/* Index cannot be dropped. */
trx
->
error_info
=
index
;
trx
->
error_info
=
index
;
...
...
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