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
4fd48678
Commit
4fd48678
authored
Feb 09, 2018
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALTER TABLE ... DROP COLUMN sys_start
update all unique keys, not just PK
parent
dfd42ed9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
64 deletions
+30
-64
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+17
-0
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+6
-0
sql/handler.cc
sql/handler.cc
+0
-59
sql/sql_table.cc
sql/sql_table.cc
+7
-5
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
4fd48678
...
...
@@ -390,6 +390,23 @@ a b
2 NULL
3 1
4 2
create or replace table t (a int, b int primary key, c int unique) with system versioning;
insert t values (1,2,3),(1,3,4),(1,4,5);
alter table t drop system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`),
UNIQUE KEY `c` (`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t;
a b c
1 2 3
1 3 4
1 4 5
create or replace table t (
a int,
row_start timestamp(6) as row start invisible,
...
...
mysql-test/suite/versioning/t/alter.test
View file @
4fd48678
...
...
@@ -267,6 +267,12 @@ select * from t for system_time all;
insert
into
t
values
(
4
,
0
);
select
*
from
t
for
system_time
all
;
create
or
replace
table
t
(
a
int
,
b
int
primary
key
,
c
int
unique
)
with
system
versioning
;
insert
t
values
(
1
,
2
,
3
),(
1
,
3
,
4
),(
1
,
4
,
5
);
alter
table
t
drop
system
versioning
;
show
create
table
t
;
select
*
from
t
;
create
or
replace
table
t
(
a
int
,
row_start
timestamp
(
6
)
as
row
start
invisible
,
...
...
sql/handler.cc
View file @
4fd48678
...
...
@@ -7135,29 +7135,6 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return
false
;
}
static
bool
is_dropping_primary_key
(
Alter_info
*
alter_info
)
{
List_iterator_fast
<
Alter_drop
>
it
(
alter_info
->
drop_list
);
while
(
Alter_drop
*
ad
=
it
++
)
{
if
(
ad
->
type
==
Alter_drop
::
KEY
&&
!
my_strcasecmp
(
system_charset_info
,
ad
->
name
,
primary_key_name
))
return
true
;
}
return
false
;
}
static
bool
is_adding_primary_key
(
Alter_info
*
alter_info
)
{
List_iterator_fast
<
Key
>
it
(
alter_info
->
key_list
);
while
(
Key
*
key
=
it
++
)
{
if
(
key
->
type
==
Key
::
PRIMARY
)
return
true
;
}
return
false
;
}
bool
Vers_parse_info
::
fix_alter_info
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE
*
table
)
{
...
...
@@ -7188,42 +7165,6 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return
true
;
}
if
(
share
->
primary_key
!=
MAX_KEY
&&
!
is_adding_primary_key
(
alter_info
)
&&
!
is_dropping_primary_key
(
alter_info
))
{
alter_info
->
flags
|=
Alter_info
::
ALTER_DROP_INDEX
;
Alter_drop
*
ad
=
new
(
thd
->
mem_root
)
Alter_drop
(
Alter_drop
::
KEY
,
primary_key_name
,
false
);
if
(
!
ad
||
alter_info
->
drop_list
.
push_back
(
ad
,
thd
->
mem_root
))
return
true
;
alter_info
->
flags
|=
Alter_info
::
ALTER_ADD_INDEX
;
LEX_CSTRING
key_name
=
{
NULL
,
0
};
DDL_options_st
options
;
options
.
init
();
Key
*
pk
=
new
(
thd
->
mem_root
)
Key
(
Key
::
PRIMARY
,
&
key_name
,
HA_KEY_ALG_UNDEF
,
false
,
options
);
if
(
!
pk
)
return
true
;
st_key
&
key
=
table
->
key_info
[
share
->
primary_key
];
for
(
st_key_part_info
*
it
=
key
.
key_part
,
*
end
=
it
+
key
.
user_defined_key_parts
;
it
!=
end
;
++
it
)
{
if
(
it
->
field
->
vers_sys_field
())
continue
;
Key_part_spec
*
key_part_spec
=
new
(
thd
->
mem_root
)
Key_part_spec
(
&
it
->
field
->
field_name
,
it
->
length
);
if
(
!
key_part_spec
||
pk
->
columns
.
push_back
(
key_part_spec
,
thd
->
mem_root
))
return
true
;
}
alter_info
->
key_list
.
push_back
(
pk
);
}
return
false
;
}
...
...
sql/sql_table.cc
View file @
4fd48678
...
...
@@ -8260,9 +8260,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
bool
delete_index_stat
=
FALSE
;
for
(
uint
j
=
0
;
j
<
key_info
->
user_defined_key_parts
;
j
++
,
key_part
++
)
{
if
(
!
key_part
->
field
)
Field
*
kfield
=
key_part
->
field
;
if
(
!
kfield
)
continue
;
// Wrong field (from UNIREG)
const
char
*
key_part_name
=
k
ey_part
->
field
->
field_name
.
str
;
const
char
*
key_part_name
=
kfield
->
field_name
.
str
;
Create_field
*
cfield
;
uint
key_part_length
;
...
...
@@ -8284,6 +8285,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if
(
table
->
s
->
primary_key
==
i
)
modified_primary_key
=
TRUE
;
delete_index_stat
=
TRUE
;
if
(
!
(
kfield
->
flags
&
VERS_SYSTEM_FIELD
))
dropped_key_part
=
key_part_name
;
continue
;
// Field is removed
}
...
...
@@ -8321,10 +8323,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
cfield
->
real_field_type
()
<=
MYSQL_TYPE_BLOB
)
?
blob_length_by_type
(
cfield
->
real_field_type
())
:
cfield
->
length
)
<
key_part_length
/
k
ey_part
->
field
->
charset
()
->
mbmaxlen
)))
key_part_length
/
kfield
->
charset
()
->
mbmaxlen
)))
key_part_length
=
0
;
// Use whole field
}
key_part_length
/=
k
ey_part
->
field
->
charset
()
->
mbmaxlen
;
key_part_length
/=
kfield
->
charset
()
->
mbmaxlen
;
key_parts
.
push_back
(
new
Key_part_spec
(
&
cfield
->
field_name
,
key_part_length
),
thd
->
mem_root
);
...
...
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