CREATE SHADOW RULE
语法用于创建影子库压测规则。
CreateShadowRule ::=
'CREATE' 'SHADOW' 'RULE' ifNotExists? shadowRuleDefinition (',' shadowRuleDefinition)*
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
shadowRuleDefinition ::=
ruleName '(' storageUnitMapping shadowTableRule (',' shadowTableRule)* ')'
storageUnitMapping ::=
'SOURCE' '=' storageUnitName ',' 'SHADOW' '=' storageUnitName
shadowTableRule ::=
tableName '(' shadowAlgorithm ')'
shadowAlgorithm ::=
'TYPE' '(' 'NAME' '=' shadowAlgorithmType ',' propertiesDefinition ')'
ruleName ::=
identifier
storageUnitName ::=
identifier
tableName ::=
identifier
algorithmName ::=
identifier
shadowAlgorithmType ::=
string
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
key ::=
string
value ::=
literal
ruleName
无法被创建;storageUnitMapping
指定源数据库和影子库的映射关系,需使用 RDL
管理的 STORAGE UNIT
,请参考 存储单元;shadowAlgorithm
可同时作用于多个 shadowTableRule
;algorithmName
会根据 ruleName
、tableName
和 shadowAlgorithmType
自动生成;shadowAlgorithmType
目前支持 VALUE_MATCH
、REGEX_MATCH
和 SIMPLE_HINT
;ifNotExists
子句用于避免出现 Duplicate shadow rule
错误。CREATE SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"="true", "foo"="bar"))),
t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1')))
);
ifNotExists
子句创建影子库压测规则CREATE SHADOW RULE IF NOT EXISTS shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"="true", "foo"="bar"))),
t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1')))
);
CREATE
、SHADOW
、RULE
、SOURCE
、SHADOW
、TYPE
、NAME
、PROPERTIES