Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
1eb8f0a4
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,发现更多精彩内容 >>
提交
1eb8f0a4
编写于
9月 23, 2020
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in storage buffer during alter
上级
626c2dad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
2 deletion
+31
-2
src/Storages/StorageBuffer.cpp
src/Storages/StorageBuffer.cpp
+6
-2
tests/queries/0_stateless/01506_buffer_table_alter_block_structure.reference
...teless/01506_buffer_table_alter_block_structure.reference
+3
-0
tests/queries/0_stateless/01506_buffer_table_alter_block_structure.sql
.../0_stateless/01506_buffer_table_alter_block_structure.sql
+22
-0
未找到文件。
src/Storages/StorageBuffer.cpp
浏览文件 @
1eb8f0a4
...
...
@@ -447,7 +447,9 @@ private:
/// Sort the columns in the block. This is necessary to make it easier to concatenate the blocks later.
Block
sorted_block
=
block
.
sortColumns
();
if
(
!
buffer
.
data
)
/// During alter we flash all buffers to storage, but buffer structure
/// may change and we update it from the new incoming block
if
(
buffer
.
data
.
rows
()
==
0
)
{
buffer
.
data
=
sorted_block
.
cloneEmpty
();
}
...
...
@@ -829,7 +831,9 @@ void StorageBuffer::alter(const AlterCommands & params, const Context & context,
checkAlterIsPossible
(
params
,
context
.
getSettingsRef
());
auto
metadata_snapshot
=
getInMemoryMetadataPtr
();
/// So that no blocks of the old structure remain.
/// Flush all buffers to storages, so that no non-empty blocks of the old
/// structure remain. Structure of empty blocks will be updated during first
/// insert.
optimize
({}
/*query*/
,
metadata_snapshot
,
{}
/*partition_id*/
,
false
/*final*/
,
false
/*deduplicate*/
,
context
);
StorageInMemoryMetadata
new_metadata
=
*
metadata_snapshot
;
...
...
tests/queries/0_stateless/01506_buffer_table_alter_block_structure.reference
0 → 100644
浏览文件 @
1eb8f0a4
2020-01-01 00:05:00
2020-01-01 00:05:00
2020-01-01 00:06:00 hello
tests/queries/0_stateless/01506_buffer_table_alter_block_structure.sql
0 → 100644
浏览文件 @
1eb8f0a4
DROP
TABLE
IF
EXISTS
buf_dest
;
DROP
TABLE
IF
EXISTS
buf
;
CREATE
TABLE
buf_dest
(
timestamp
DateTime
)
ENGINE
=
MergeTree
PARTITION
BY
toYYYYMMDD
(
timestamp
)
ORDER
BY
(
timestamp
);
CREATE
TABLE
buf
(
timestamp
DateTime
)
Engine
=
Buffer
(
currentDatabase
(),
buf_dest
,
16
,
3
,
20
,
2000000
,
20000000
,
100000000
,
300000000
);;
INSERT
INTO
buf
(
timestamp
)
VALUES
(
toDateTime
(
'2020-01-01 00:05:00'
));
ALTER
TABLE
buf_dest
ADD
COLUMN
s
String
;
ALTER
TABLE
buf
ADD
COLUMN
s
String
;
SELECT
*
FROM
buf
;
INSERT
INTO
buf
(
timestamp
,
s
)
VALUES
(
toDateTime
(
'2020-01-01 00:06:00'
),
'hello'
);
SELECT
*
FROM
buf
ORDER
BY
timestamp
;
DROP
TABLE
IF
EXISTS
buf
;
DROP
TABLE
IF
EXISTS
buf_dest
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录