-
Notifications
You must be signed in to change notification settings - Fork 92
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
Feat/shadow #412
Feat/shadow #412
Conversation
1. create shadow tables in init.sql & sharding.sql 2. hide shadow tables for "show tables" command 3. impl shadow match hint rule (only select) 4. support shadow type match regex (only select)
add integration test for shadow tables
1. impl shadow match hint rule (insert/update/delete) 2. support shadow type match regex (insert/update/delete) 3、integrate test
/* | ||
for _, sqlCase := range cases.ExShRegexCases { | ||
for _, sense := range sqlCase.Sense { | ||
if strings.Compare(strings.TrimSpace(sense), "shadow") == 0 { | ||
params := strings.Split(sqlCase.Parameters, ",") | ||
args := make([]interface{}, 0, len(params)) | ||
for _, param := range params { | ||
k, _ := test.GetValueByType(param) | ||
args = append(args, k) | ||
} |
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.
无用的可以删掉
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.
并不是无用,hint模式和regex模式的yaml配置只能生效一个,ExShHintCases是给hint模式的配置用的,ExShRegexCases是给regex模式的配置用的。默认配置是hint模式,所以就注释掉了ExShRegexCases,如果修改配置文件,就能用到这部分代码了
sense: | ||
- shadow | ||
expected: | ||
type: "rowAffect" | ||
value: 0 | ||
value: 1 |
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.
加个换行吧
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.
哪个地方?我是按case组来换行的,如果每个case都换行的,似乎不好看
pkg/runtime/optimize/dml/delete.go
Outdated
//first shadow_rule, and then sharding_rule | ||
if o.ShadowRule != nil && !matchShadow { | ||
if matchShadow, err = (*optimize.ShadowSharder)(o.ShadowRule).Shard(stmt.Table, constants.ShadowDelete, stmt.Where, o.Args...); err != nil { | ||
return nil, errors.Wrap(err, "calculate shards failed") |
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.
calculate shadow shards failed 会不会更直接点
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.
多个shadow规则并存时采用优先方案还是排它方案,相对来说,优先方案省事一些,而且逻辑上也比较清晰
modify error messages and comments
ignore parameters temporary
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
Feature: support shadow type match regex #365:
3、integrate test
Test Cases:
[hint mode]
/*A! shadow(shadow) */ INSERT INTO student(id,uid,score,name,nickname,gender,birth_year) values (1,3,100,'lilei','shadow test',1,1980);
/*A! shadow(shadow) */ SELECT * FROM student WHERE uid = 3;
/*A! shadow(shadow) */ UPDATE student SET score = 98 WHERE uid = 3;
/*A! shadow(shadow) */ DELETE FROM student WHERE uid = 3;
[regex mode]
INSERT INTO student(id,uid,score,name,nickname,gender,birth_year) values (1,2,100,'hanmeimei','shadow test',1,1981);
SELECT * FROM student WHERE uid = 2 AND name = 'hanmeimei';
UPDATE student SET score = 98 WHERE uid = 2 AND name = 'hanmeimei';
DELETE FROM student WHERE uid = 2 AND name = 'hanmeimei';
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: