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
b2111251
Commit
b2111251
authored
Sep 22, 2017
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On instant ADD COLUMN, preserve the values of old instant-add columns
parent
19f853f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
18 deletions
+45
-18
storage/innobase/handler/handler0alter.cc
storage/innobase/handler/handler0alter.cc
+45
-18
No files found.
storage/innobase/handler/handler0alter.cc
View file @
b2111251
...
...
@@ -342,7 +342,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
i
++
)
{
dict_col_t
&
col
=
old_table
->
cols
[
i
];
ut_ad
(
col
.
def_val
.
len
!=
UNIV_SQL_DEFAULT
);
if
(
const
void
*&
def
=
col
.
def_val
.
data
)
{
if
(
col
.
def_val
.
len
==
0
)
{
col
.
def_val
.
data
=
field_ref_zero
;
}
else
if
(
const
void
*&
def
=
col
.
def_val
.
data
)
{
def
=
mem_heap_dup
(
old_table
->
heap
,
def
,
col
.
def_val
.
len
);
}
else
{
...
...
@@ -4200,24 +4202,54 @@ innobase_add_instant_try(
continue
;
}
dict_col_t
*
col
=
dict_table_get_nth_col
(
new_table
,
i
);
const
dict_col_t
*
old_col
=
new_field
->
field
?
dict_table_get_nth_col
(
user_table
,
i
)
:
NULL
;
DBUG_ASSERT
(
!
strcmp
((
*
af
)
->
field_name
.
str
,
dict_table_get_col_name
(
new_table
,
i
)));
DBUG_ASSERT
(
!
col
->
def_val
.
data
);
DBUG_ASSERT
(
col
->
def_val
.
len
==
UNIV_SQL_DEFAULT
);
dfield_t
*
dfield
=
dtuple_get_nth_field
(
row
,
i
);
if
((
*
af
)
->
is_real_null
()
||
(
new_field
->
field
&&
(
*
af
)
->
real_maybe_null
()))
{
/* Store NULL for added columns that are NULL
by default, and for nullable pre-existing columns. */
dfield_set_null
(
dfield
);
}
else
{
switch
((
*
af
)
->
type
())
{
case
MYSQL_TYPE_VARCHAR
:
if
(
new_field
->
field
)
{
if
(
new_field
->
field
)
{
DBUG_ASSERT
(
col
->
mtype
==
old_col
->
mtype
);
DBUG_ASSERT
(
col
->
prtype
==
old_col
->
prtype
);
DBUG_ASSERT
(
col
->
mbminmaxlen
==
old_col
->
mbminmaxlen
);
DBUG_ASSERT
(
col
->
len
>=
old_col
->
len
);
col
->
def_val
=
old_col
->
def_val
;
if
(
old_col
->
def_val
.
len
==
UNIV_SQL_DEFAULT
)
{
/* We may only have missing DEFAULT
value for 'core' columns. */
DBUG_ASSERT
(
dict_col_get_clust_pos
(
old_col
,
old_index
)
<
old_index
->
n_core_fields
);
if
((
*
af
)
->
real_maybe_null
())
{
/* Store NULL for nullable
'core' columns. */
dfield_set_null
(
dfield
);
}
else
if
((
*
af
)
->
type
()
==
MYSQL_TYPE_VARCHAR
)
{
/* Store the empty string for
pre-existing VARCHAR NOT NULL
columns. */
dfield_set_data
(
dfield
,
""
,
0
);
break
;
}
else
{
goto
set_not_null_default_from_sql
;
}
}
else
{
dfield_set_data
(
dfield
,
old_col
->
def_val
.
data
,
old_col
->
def_val
.
len
);
}
}
else
if
((
*
af
)
->
is_real_null
())
{
/* Store NULL for added DEFAULT NULL columns. */
dfield_set_null
(
dfield
);
col
->
def_val
.
len
=
UNIV_SQL_NULL
;
}
else
{
set_not_null_default_from_sql:
switch
((
*
af
)
->
type
())
{
case
MYSQL_TYPE_VARCHAR
:
dfield_set_data
(
dfield
,
reinterpret_cast
<
const
Field_varstring
*>
...
...
@@ -4256,17 +4288,12 @@ innobase_add_instant_try(
:
NULL
,
true
,
(
*
af
)
->
ptr
,
len
,
dict_table_is_comp
(
user_table
));
}
}
ut_ad
(
!
dict_table_get_nth_col
(
new_table
,
i
)
->
def_val
.
data
);
ut_ad
(
dict_table_get_nth_col
(
new_table
,
i
)
->
def_val
.
len
==
UNIV_SQL_DEFAULT
);
if
(
!
new_field
->
field
)
{
dict_col_t
*
col
=
dict_table_get_nth_col
(
new_table
,
i
);
col
->
def_val
.
data
=
dfield_get_data
(
dfield
);
col
->
def_val
.
len
=
dfield_get_len
(
dfield
);
}
if
(
!
new_field
->
field
)
{
pars_info_t
*
info
=
pars_info_create
();
pars_info_add_ull_literal
(
info
,
"id"
,
user_table
->
id
);
pars_info_add_int4_literal
(
info
,
"pos"
,
i
);
...
...
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