Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
ab1c4139
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab1c4139
编写于
8月 14, 2019
作者:
G
Gleb Novikov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added ReplicatedMergeTree support and test for constraints, also added VIOLATED_CONSTRAINT error
上级
3b9e1f9b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
60 addition
and
3 deletion
+60
-3
dbms/programs/server/config.xml
dbms/programs/server/config.xml
+4
-1
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-0
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.cpp
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.cpp
+1
-1
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.h
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.h
+1
-1
dbms/src/Storages/MergeTree/ReplicatedMergeTreeTableMetadata.cpp
...c/Storages/MergeTree/ReplicatedMergeTreeTableMetadata.cpp
+6
-0
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+4
-0
dbms/tests/queries/0_stateless/00988_constraints_replication_zookeeper.reference
...ateless/00988_constraints_replication_zookeeper.reference
+0
-0
dbms/tests/queries/0_stateless/00988_constraints_replication_zookeeper.sql
...s/0_stateless/00988_constraints_replication_zookeeper.sql
+43
-0
未找到文件。
dbms/programs/server/config.xml
浏览文件 @
ab1c4139
...
...
@@ -217,7 +217,10 @@
See https://clickhouse.yandex/docs/en/table_engines/replication/
-->
<zookeeper
incl=
"zookeeper-servers"
optional=
"true"
/>
<zookeeper>
<implementation>
testkeeper
</implementation>
</zookeeper>
<!-- Substitutions for parameters of replicated tables.
Optional. If you don't use replicated tables, you could omit that.
...
...
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
ab1c4139
...
...
@@ -443,6 +443,7 @@ namespace ErrorCodes
extern
const
int
INSECURE_PATH
=
466
;
extern
const
int
CANNOT_PARSE_BOOL
=
467
;
extern
const
int
CANNOT_PTHREAD_ATTR
=
468
;
extern
const
int
VIOLATED_CONSTRAINT
=
469
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.cpp
浏览文件 @
ab1c4139
...
...
@@ -26,7 +26,7 @@ void CheckConstraintsBlockOutputStream::write(const Block & block)
throw
Exception
{
"Violated constraint "
+
constraints
.
constraints
[
i
]
->
name
+
" in table "
+
table
+
" at indices "
+
indices_str
+
", constraint expression: "
+
serializeAST
(
*
(
constraints
.
constraints
[
i
]
->
expr
),
true
),
ErrorCodes
::
LOGICAL_ERROR
};
serializeAST
(
*
(
constraints
.
constraints
[
i
]
->
expr
),
true
),
DB
::
ErrorCodes
::
VIOLATED_CONSTRAINT
};
}
}
output
->
write
(
block
);
...
...
dbms/src/DataStreams/CheckConstraintsBlockOutputStream.h
浏览文件 @
ab1c4139
...
...
@@ -10,7 +10,7 @@ namespace DB
namespace
ErrorCodes
{
extern
const
int
CONSTRAINTS_ARE_NOT_SATISFIED
;
extern
const
int
VIOLATED_CONSTRAINT
;
}
class
CheckConstraintsBlockOutputStream
:
public
IBlockOutputStream
...
...
dbms/src/Storages/MergeTree/ReplicatedMergeTreeTableMetadata.cpp
浏览文件 @
ab1c4139
...
...
@@ -82,6 +82,9 @@ void ReplicatedMergeTreeTableMetadata::write(WriteBuffer & out) const
if
(
index_granularity_bytes
!=
0
)
out
<<
"granularity bytes: "
<<
index_granularity_bytes
<<
"
\n
"
;
if
(
!
constraints
.
empty
())
out
<<
"constraints: "
<<
constraints
<<
"
\n
"
;
}
String
ReplicatedMergeTreeTableMetadata
::
toString
()
const
...
...
@@ -125,6 +128,9 @@ void ReplicatedMergeTreeTableMetadata::read(ReadBuffer & in)
}
else
index_granularity_bytes
=
0
;
if
(
checkString
(
"constraints: "
,
in
))
in
>>
constraints
>>
"
\n
"
;
}
ReplicatedMergeTreeTableMetadata
ReplicatedMergeTreeTableMetadata
::
parse
(
const
String
&
s
)
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
ab1c4139
...
...
@@ -3144,6 +3144,10 @@ void StorageReplicatedMergeTree::alter(
if
(
new_indices_str
!=
getIndices
().
toString
())
new_metadata
.
skip_indices
=
new_indices_str
;
String
new_constraints_str
=
new_constraints
.
toString
();
if
(
new_constraints_str
!=
getConstraints
().
toString
())
new_metadata
.
constraints
=
new_constraints_str
;
String
new_metadata_str
=
new_metadata
.
toString
();
if
(
new_metadata_str
!=
ReplicatedMergeTreeTableMetadata
(
*
this
).
toString
())
changed_nodes
.
emplace_back
(
zookeeper_path
,
"metadata"
,
new_metadata_str
);
...
...
dbms/tests/queries/0_stateless/00988_constraints_replication_zookeeper.reference
0 → 100644
浏览文件 @
ab1c4139
dbms/tests/queries/0_stateless/00988_constraints_replication_zookeeper.sql
0 → 100644
浏览文件 @
ab1c4139
DROP
TABLE
IF
EXISTS
replicated_constraints1
;
DROP
TABLE
IF
EXISTS
replicated_constraints2
;
CREATE
TABLE
replicated_constraints1
(
a
UInt32
,
b
UInt32
,
CONSTRAINT
a_constraint
CHECK
a
<
10
)
ENGINE
=
ReplicatedMergeTree
(
'/clickhouse/tables/test/alter_constraints'
,
'r1'
)
ORDER
BY
(
a
);
CREATE
TABLE
replicated_constraints2
(
a
UInt32
,
b
UInt32
,
CONSTRAINT
a_constraint
CHECK
a
<
10
)
ENGINE
=
ReplicatedMergeTree
(
'/clickhouse/tables/test/alter_constraints'
,
'r2'
)
ORDER
BY
(
a
);
INSERT
INTO
replicated_constraints1
VALUES
(
1
,
2
);
INSERT
INTO
replicated_constraints2
VALUES
(
3
,
4
);
SYSTEM
SYNC
REPLICA
replicated_constraints1
;
SYSTEM
SYNC
REPLICA
replicated_constraints2
;
INSERT
INTO
replicated_constraints1
VALUES
(
10
,
10
);
-- { serverError 469 }
ALTER
TABLE
replicated_constraints1
DROP
CONSTRAINT
a_constraint
;
SYSTEM
SYNC
REPLICA
replicated_constraints2
;
INSERT
INTO
replicated_constraints1
VALUES
(
10
,
10
);
INSERT
INTO
replicated_constraints2
VALUES
(
10
,
10
);
ALTER
TABLE
replicated_constraints1
ADD
CONSTRAINT
b_constraint
CHECK
b
>
10
;
ALTER
TABLE
replicated_constraints2
ADD
CONSTRAINT
a_constraint
CHECK
a
<
10
;
SYSTEM
SYNC
REPLICA
replicated_constraints1
;
SYSTEM
SYNC
REPLICA
replicated_constraints2
;
INSERT
INTO
replicated_constraints1
VALUES
(
10
,
11
);
-- { serverError 469 }
INSERT
INTO
replicated_constraints2
VALUES
(
9
,
10
);
-- { serverError 469 }
DROP
TABLE
replicated_constraints1
;
DROP
TABLE
replicated_constraints2
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录