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
cbe93291
Commit
cbe93291
authored
Nov 23, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL,IB: add auto_inc copy mode fix [#347]
Related to #212. Extra update of sys_trx_start removed [#87].
parent
b612f3ba
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
38 deletions
+48
-38
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+20
-9
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+7
-0
sql/handler.cc
sql/handler.cc
+1
-1
sql/sql_table.cc
sql/sql_table.cc
+1
-6
sql/table.cc
sql/table.cc
+4
-0
sql/table.h
sql/table.h
+7
-0
sql/vtmd.cc
sql/vtmd.cc
+4
-4
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/ha_innodb.cc
+3
-3
storage/innobase/row/row0merge.cc
storage/innobase/row/row0merge.cc
+1
-15
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
cbe93291
...
...
@@ -466,10 +466,18 @@ Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
call verify_vtq;
No A B C D
create or replace table t (a int) with system versioning engine=innodb;
insert into t values (1), (2), (3);
delete from t where a<3;
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
alter table t add b int auto_increment unique;
call verify_vtq;
No A B C D
select * from t for system_time all;
a b
1 -1
...
...
@@ -482,6 +490,9 @@ a b
2 -2
3 1
4 2
call verify_vtq;
No A B C D
1 1 1 1 1
create or replace table t (a int) with system versioning;
insert into t values (1), (2), (3);
delete from t where a<3;
...
...
@@ -501,7 +512,13 @@ a b
create or replace table t (a int) with system versioning engine=innodb;
insert into t values (1), (2), (3);
delete from t where a<3;
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
alter table t add b tinyint auto_increment unique;
call verify_vtq;
No A B C D
select * from t for system_time all;
a b
1 -1
...
...
@@ -514,6 +531,9 @@ a b
2 -2
3 1
4 2
call verify_vtq;
No A B C D
1 1 1 1 1
create or replace table t (a int) with system versioning;
insert into t values (1), (2), (3);
delete from t where a<3;
...
...
@@ -610,15 +630,6 @@ call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
4 1 1 1 1
5 1 1 1 1
6 1 1 1 1
7 1 1 1 1
8 1 1 1 1
9 1 1 1 1
10 1 1 1 1
11 1 1 1 1
drop table t;
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
...
...
mysql-test/suite/versioning/t/alter.test
View file @
cbe93291
...
...
@@ -194,14 +194,18 @@ select * from t for system_time all;
alter
table
t
drop
system
versioning
,
algorithm
=
copy
;
show
create
table
t
;
call
verify_vtq
;
create
or
replace
table
t
(
a
int
)
with
system
versioning
engine
=
innodb
;
insert
into
t
values
(
1
),
(
2
),
(
3
);
delete
from
t
where
a
<
3
;
call
verify_vtq
;
alter
table
t
add
b
int
auto_increment
unique
;
call
verify_vtq
;
select
*
from
t
for
system_time
all
;
insert
into
t
values
(
4
,
NULL
);
select
*
from
t
for
system_time
all
;
call
verify_vtq
;
create
or
replace
table
t
(
a
int
)
with
system
versioning
;
insert
into
t
values
(
1
),
(
2
),
(
3
);
...
...
@@ -214,10 +218,13 @@ select * from t for system_time all;
create
or
replace
table
t
(
a
int
)
with
system
versioning
engine
=
innodb
;
insert
into
t
values
(
1
),
(
2
),
(
3
);
delete
from
t
where
a
<
3
;
call
verify_vtq
;
alter
table
t
add
b
tinyint
auto_increment
unique
;
call
verify_vtq
;
select
*
from
t
for
system_time
all
;
insert
into
t
values
(
4
,
NULL
);
select
*
from
t
for
system_time
all
;
call
verify_vtq
;
create
or
replace
table
t
(
a
int
)
with
system
versioning
;
insert
into
t
values
(
1
),
(
2
),
(
3
);
...
...
sql/handler.cc
View file @
cbe93291
...
...
@@ -3036,7 +3036,7 @@ int handler::update_auto_increment()
DBUG_ENTER
(
"handler::update_auto_increment"
);
// System Versioning: handle ALTER ADD COLUMN AUTO_INCREMENT
if
(
thd
->
lex
->
sql_command
==
SQLCOM_ALTER_TABLE
&&
table
->
versioned
_by_sql
())
if
(
thd
->
lex
->
sql_command
==
SQLCOM_ALTER_TABLE
&&
table
->
versioned
())
{
Field
*
end
=
table
->
vers_end_field
();
DBUG_ASSERT
(
end
);
...
...
sql/sql_table.cc
View file @
cbe93291
...
...
@@ -10180,14 +10180,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
if
(
keep_versioned
&&
to
->
versioned_by_engine
()
&&
thd
->
variables
.
vers_alter_history
!=
VERS_ALTER_HISTORY_SURVIVE
)
{
to
->
s
->
versioned
=
false
;
to
->
vers_write
=
false
;
}
error
=
to
->
file
->
ha_write_row
(
to
->
record
[
0
]);
if
(
keep_versioned
&&
to
->
versioned_by_engine
()
&&
thd
->
variables
.
vers_alter_history
!=
VERS_ALTER_HISTORY_SURVIVE
)
{
to
->
s
->
versioned
=
true
;
}
to
->
auto_increment_field_not_null
=
FALSE
;
if
(
error
)
{
...
...
sql/table.cc
View file @
cbe93291
...
...
@@ -3216,9 +3216,13 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
*
fptr
++
=
outparam
->
field
[
i
];
}
(
*
fptr
)
=
0
;
// End marker
outparam
->
vers_write
=
true
;
}
else
{
outparam
->
non_generated_field
=
NULL
;
outparam
->
vers_write
=
false
;
}
if
(
share
->
found_next_number_field
)
outparam
->
found_next_number_field
=
...
...
sql/table.h
View file @
cbe93291
...
...
@@ -1505,6 +1505,7 @@ struct TABLE
/**
System Versioning support
*/
bool
vers_write
;
bool
versioned
()
const
{
...
...
@@ -1512,6 +1513,12 @@ struct TABLE
return
s
->
versioned
;
}
bool
versioned_write
()
const
{
DBUG_ASSERT
(
versioned
()
||
!
vers_write
);
return
vers_write
;
}
/* Versioned by SQL layer */
bool
versioned_by_sql
()
const
{
...
...
sql/vtmd.cc
View file @
cbe93291
...
...
@@ -186,9 +186,9 @@ VTMD_table::update(THD *thd, const char* archive_name)
vtmd
.
table
->
mark_columns_needed_for_update
();
// not needed?
if
(
archive_name
)
{
vtmd
.
table
->
s
->
versioned
=
false
;
vtmd
.
table
->
vers_write
=
false
;
error
=
vtmd
.
table
->
file
->
ha_update_row
(
vtmd
.
table
->
record
[
1
],
vtmd
.
table
->
record
[
0
]);
vtmd
.
table
->
s
->
versioned
=
true
;
vtmd
.
table
->
vers_write
=
true
;
if
(
!
error
)
{
...
...
@@ -220,9 +220,9 @@ VTMD_table::update(THD *thd, const char* archive_name)
store_record
(
vtmd
.
table
,
record
[
1
]);
vtmd
.
table
->
field
[
FLD_ARCHIVE_NAME
]
->
store
(
archive_name
,
an_len
,
table_alias_charset
);
vtmd
.
table
->
field
[
FLD_ARCHIVE_NAME
]
->
set_notnull
();
vtmd
.
table
->
s
->
versioned
=
false
;
vtmd
.
table
->
vers_write
=
false
;
error
=
vtmd
.
table
->
file
->
ha_update_row
(
vtmd
.
table
->
record
[
1
],
vtmd
.
table
->
record
[
0
]);
vtmd
.
table
->
s
->
versioned
=
true
;
vtmd
.
table
->
vers_write
=
true
;
if
(
error
)
goto
err
;
sys_trx_end
=
(
ulonglong
)
vtmd
.
table
->
vers_start_field
()
->
val_int
();
...
...
storage/innobase/handler/ha_innodb.cc
View file @
cbe93291
...
...
@@ -8369,7 +8369,7 @@ ha_innobase::write_row(
innobase_srv_conc_enter_innodb
(
m_prebuilt
);
vers_set_fields
=
(
table
->
versioned
()
&&
vers_set_fields
=
(
table
->
versioned
_write
()
&&
(
sql_command
!=
SQLCOM_CREATE_TABLE
||
table
->
s
->
vtmd
))
?
ROW_INS_VERSIONED
:
...
...
@@ -9179,7 +9179,7 @@ ha_innobase::update_row(
innobase_srv_conc_enter_innodb
(
m_prebuilt
);
if
(
!
table
->
versioned
())
if
(
!
table
->
versioned
_write
())
m_prebuilt
->
upd_node
->
versioned
=
false
;
if
(
m_prebuilt
->
upd_node
->
versioned
)
{
...
...
@@ -9317,7 +9317,7 @@ ha_innobase::delete_row(
innobase_srv_conc_enter_innodb
(
m_prebuilt
);
bool
vers_set_fields
=
table
->
versioned
()
&&
table
->
versioned
_write
()
&&
table
->
vers_end_field
()
->
is_max
();
error
=
row_update_for_mysql
(
m_prebuilt
,
vers_set_fields
);
...
...
storage/innobase/row/row0merge.cc
View file @
cbe93291
...
...
@@ -2304,21 +2304,7 @@ row_merge_read_clustered_index(
}
if
(
old_table
->
versioned
())
{
if
(
new_table
->
versioned
()
&&
!
drop_historical
)
{
dfield_t
*
end
=
dtuple_get_nth_field
(
row
,
new_table
->
vers_end
);
byte
*
data
=
static_cast
<
byte
*>
(
dfield_get_data
(
end
));
ut_ad
(
data
);
if
(
mach_read_from_8
(
data
)
==
TRX_ID_MAX
)
{
dfield_t
*
start
=
dtuple_get_nth_field
(
row
,
new_table
->
vers_start
);
void
*
data
=
dfield_get_data
(
start
);
ut_ad
(
data
);
mach_write_to_8
(
data
,
trx
->
id
);
trx
->
vers_update_trt
=
true
;
}
}
else
{
if
(
!
new_table
->
versioned
()
||
drop_historical
)
{
const
dict_col_t
*
col
=
&
old_table
->
cols
[
old_table
->
vers_end
];
...
...
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