-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default value when generate the update rows #1006
Conversation
only on the condition PreWrite.schemaVersion < schemaVersion of the table replicated to downstream.
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
Tested with this PR got unexpected NULL value in down stream
|
can you describe the detailed step? |
@july2993 I ran the following SQLs from upstream /* init */ drop table if exists accounts;
/* init */ create table accounts(id int primary key, balance bigint, aa int);
/* init */ insert into accounts values(1, 100, 1), (2, 0, 2), (3, 1, 3);
/* TXN1 */ set session tidb_enable_amend_pessimistic_txn = 1;
/* DDL */ set session tidb_enable_amend_pessimistic_txn = 1;
/* TXN1 */ begin;
/* DDL */ alter table accounts add column bb int default 10;
/* TXN1 */ update accounts set balance = id where 1;
/* TXN1 */ commit;
/* TXN1 */ select * from accounts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add an integration test for this case?
It's caused by |
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
yes, current test using a temporal tool https://github.com/july2993/tk/blob/4465f27496e7c6d8c509e8fde75bfce070c8c4b3/cmd/amend/amend.go#L42 |
I tried this case and got error /* init */ drop table if exists accounts;
/* init */ create table accounts(id int primary key, balance bigint);
/* init */ insert into accounts values(1, 100), (2, 0), (3, 1);
/* TXN */ set session tidb_enable_amend_pessimistic_txn = 1;
/* DDL */ set session tidb_enable_amend_pessimistic_txn = 1;
/* TXN */ begin;
/* DDL */ alter table accounts add column bb int not null;
/* DDL */ alter table accounts add column cc int not null;
/* TXN */ update accounts set balance = id where 1;
/* TXN */ commit;
/* TXN */ select * from accounts;
|
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@you06 PTAL again? |
I'm running some tests on the latest commit. |
I did some tests today, there is a problem with enum type. The test case is /* init */ drop table if exists t;
/* init */ create table t (id int primary key, c int);
/* init */ insert into t (id, c) values (1, 1);
/* txn */ begin;
/* txn */ update t set c = 2 where id = 1;
/* ddl */ alter table t add column cc enum('a','b','c','d','e') default 'b';
/* txn */ commit; Drainer will execute |
fix in 18393fe |
drainer/translator/table_info.go
Outdated
IsDroppingColumn(id int64) bool | ||
CanAppendDefaultValue(id int64, schemaVersion int64) bool | ||
// IsDroppingColumn(id int64) bool | ||
TableBySchemaVersion(version int64, tid int64) (info *model.TableInfo, ok bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name here is a bit confusing.
id
andtid
are both table's id.version
andschemaVersion
are both schema's version.- the order of id and version is not same.
LGTM |
/run-all-tests tidb=release-4.0 tikv=release-4.0 pd=release-4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
What is changed and how it works?
only on the condition PreWrite.schemaVersion < schemaVersion of the
table replicated to downstream.
Check List
Tests
enable amend:
set global tidb_enable_amend_pessimistic_txn = 1;
run:
Code changes
Side effects
Release note