Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
38fa1af5
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,发现更多精彩内容 >>
提交
38fa1af5
编写于
11月 11, 2019
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable quota consumptions for the system queries and for selecting
from the `system.quota` and `system.quotas` tables.
上级
d9b1a733
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
74 addition
and
32 deletion
+74
-32
dbms/src/Interpreters/IInterpreter.h
dbms/src/Interpreters/IInterpreter.h
+3
-0
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+13
-2
dbms/src/Interpreters/InterpreterSelectQuery.h
dbms/src/Interpreters/InterpreterSelectQuery.h
+4
-1
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
+13
-0
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.h
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.h
+4
-1
dbms/src/Interpreters/InterpreterSystemQuery.cpp
dbms/src/Interpreters/InterpreterSystemQuery.cpp
+3
-1
dbms/src/Interpreters/InterpreterSystemQuery.h
dbms/src/Interpreters/InterpreterSystemQuery.h
+3
-0
dbms/src/Interpreters/SelectQueryOptions.h
dbms/src/Interpreters/SelectQueryOptions.h
+8
-11
dbms/src/Interpreters/executeQuery.cpp
dbms/src/Interpreters/executeQuery.cpp
+23
-16
未找到文件。
dbms/src/Interpreters/IInterpreter.h
浏览文件 @
38fa1af5
...
@@ -22,6 +22,9 @@ public:
...
@@ -22,6 +22,9 @@ public:
virtual
bool
canExecuteWithProcessors
()
const
{
return
false
;
}
virtual
bool
canExecuteWithProcessors
()
const
{
return
false
;
}
virtual
bool
ignoreQuota
()
const
{
return
false
;
}
virtual
bool
ignoreLimits
()
const
{
return
false
;
}
virtual
~
IInterpreter
()
{}
virtual
~
IInterpreter
()
{}
};
};
...
...
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
38fa1af5
...
@@ -419,6 +419,17 @@ InterpreterSelectQuery::InterpreterSelectQuery(
...
@@ -419,6 +419,17 @@ InterpreterSelectQuery::InterpreterSelectQuery(
/// null non-const columns to avoid useless memory allocations. However, a valid block sample
/// null non-const columns to avoid useless memory allocations. However, a valid block sample
/// requires all columns to be of size 0, thus we need to sanitize the block here.
/// requires all columns to be of size 0, thus we need to sanitize the block here.
sanitizeBlock
(
result_header
);
sanitizeBlock
(
result_header
);
/// Remove limits for some tables in the `system` database.
if
(
storage
&&
(
storage
->
getDatabaseName
()
==
"system"
))
{
String
table_name
=
storage
->
getTableName
();
if
((
table_name
==
"quotas"
)
||
(
table_name
==
"quota_usage"
)
||
(
table_name
==
"one"
))
{
options
.
ignore_quota
=
true
;
options
.
ignore_limits
=
true
;
}
}
}
}
...
@@ -1783,7 +1794,7 @@ void InterpreterSelectQuery::executeFetchColumns(
...
@@ -1783,7 +1794,7 @@ void InterpreterSelectQuery::executeFetchColumns(
if
(
!
options
.
ignore_limits
)
if
(
!
options
.
ignore_limits
)
stream
->
setLimits
(
limits
);
stream
->
setLimits
(
limits
);
if
(
options
.
to_stage
==
QueryProcessingStage
::
Complete
)
if
(
!
options
.
ignore_quota
&&
(
options
.
to_stage
==
QueryProcessingStage
::
Complete
)
)
stream
->
setQuota
(
quota
);
stream
->
setQuota
(
quota
);
}
}
...
@@ -1793,7 +1804,7 @@ void InterpreterSelectQuery::executeFetchColumns(
...
@@ -1793,7 +1804,7 @@ void InterpreterSelectQuery::executeFetchColumns(
if
(
!
options
.
ignore_limits
)
if
(
!
options
.
ignore_limits
)
pipe
.
setLimits
(
limits
);
pipe
.
setLimits
(
limits
);
if
(
options
.
to_stage
==
QueryProcessingStage
::
Complete
)
if
(
!
options
.
ignore_quota
&&
(
options
.
to_stage
==
QueryProcessingStage
::
Complete
)
)
pipe
.
setQuota
(
quota
);
pipe
.
setQuota
(
quota
);
}
}
}
}
...
...
dbms/src/Interpreters/InterpreterSelectQuery.h
浏览文件 @
38fa1af5
...
@@ -74,6 +74,9 @@ public:
...
@@ -74,6 +74,9 @@ public:
QueryPipeline
executeWithProcessors
()
override
;
QueryPipeline
executeWithProcessors
()
override
;
bool
canExecuteWithProcessors
()
const
override
{
return
true
;
}
bool
canExecuteWithProcessors
()
const
override
{
return
true
;
}
bool
ignoreLimits
()
const
override
{
return
options
.
ignore_limits
;
}
bool
ignoreQuota
()
const
override
{
return
options
.
ignore_quota
;
}
Block
getSampleBlock
();
Block
getSampleBlock
();
void
ignoreWithTotals
();
void
ignoreWithTotals
();
...
@@ -260,7 +263,7 @@ private:
...
@@ -260,7 +263,7 @@ private:
*/
*/
void
initSettings
();
void
initSettings
();
const
SelectQueryOptions
options
;
SelectQueryOptions
options
;
ASTPtr
query_ptr
;
ASTPtr
query_ptr
;
std
::
shared_ptr
<
Context
>
context
;
std
::
shared_ptr
<
Context
>
context
;
SyntaxAnalyzerResultPtr
syntax_analyzer_result
;
SyntaxAnalyzerResultPtr
syntax_analyzer_result
;
...
...
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
浏览文件 @
38fa1af5
...
@@ -107,6 +107,19 @@ InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(
...
@@ -107,6 +107,19 @@ InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(
result_header
=
getCommonHeaderForUnion
(
headers
);
result_header
=
getCommonHeaderForUnion
(
headers
);
}
}
/// InterpreterSelectWithUnionQuery ignores limits if all nested interpreters ignore limits.
bool
all_nested_ignore_limits
=
true
;
bool
all_nested_ignore_quota
=
true
;
for
(
auto
&
interpreter
:
nested_interpreters
)
{
if
(
!
interpreter
->
ignoreLimits
())
all_nested_ignore_limits
=
false
;
if
(
!
interpreter
->
ignoreQuota
())
all_nested_ignore_quota
=
false
;
}
options
.
ignore_limits
|=
all_nested_ignore_limits
;
options
.
ignore_quota
|=
all_nested_ignore_quota
;
}
}
...
...
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.h
浏览文件 @
38fa1af5
...
@@ -34,6 +34,9 @@ public:
...
@@ -34,6 +34,9 @@ public:
QueryPipeline
executeWithProcessors
()
override
;
QueryPipeline
executeWithProcessors
()
override
;
bool
canExecuteWithProcessors
()
const
override
{
return
true
;
}
bool
canExecuteWithProcessors
()
const
override
{
return
true
;
}
bool
ignoreLimits
()
const
override
{
return
options
.
ignore_limits
;
}
bool
ignoreQuota
()
const
override
{
return
options
.
ignore_quota
;
}
Block
getSampleBlock
();
Block
getSampleBlock
();
static
Block
getSampleBlock
(
static
Block
getSampleBlock
(
...
@@ -45,7 +48,7 @@ public:
...
@@ -45,7 +48,7 @@ public:
ASTPtr
getQuery
()
const
{
return
query_ptr
;
}
ASTPtr
getQuery
()
const
{
return
query_ptr
;
}
private:
private:
const
SelectQueryOptions
options
;
SelectQueryOptions
options
;
ASTPtr
query_ptr
;
ASTPtr
query_ptr
;
std
::
shared_ptr
<
Context
>
context
;
std
::
shared_ptr
<
Context
>
context
;
...
...
dbms/src/Interpreters/InterpreterSystemQuery.cpp
浏览文件 @
38fa1af5
...
@@ -121,7 +121,9 @@ void startStopAction(Context & context, ASTSystemQuery & query, StorageActionBlo
...
@@ -121,7 +121,9 @@ void startStopAction(Context & context, ASTSystemQuery & query, StorageActionBlo
InterpreterSystemQuery
::
InterpreterSystemQuery
(
const
ASTPtr
&
query_ptr_
,
Context
&
context_
)
InterpreterSystemQuery
::
InterpreterSystemQuery
(
const
ASTPtr
&
query_ptr_
,
Context
&
context_
)
:
query_ptr
(
query_ptr_
->
clone
()),
context
(
context_
),
log
(
&
Poco
::
Logger
::
get
(
"InterpreterSystemQuery"
))
{}
:
query_ptr
(
query_ptr_
->
clone
()),
context
(
context_
),
log
(
&
Poco
::
Logger
::
get
(
"InterpreterSystemQuery"
))
{
}
BlockIO
InterpreterSystemQuery
::
execute
()
BlockIO
InterpreterSystemQuery
::
execute
()
...
...
dbms/src/Interpreters/InterpreterSystemQuery.h
浏览文件 @
38fa1af5
...
@@ -20,6 +20,9 @@ public:
...
@@ -20,6 +20,9 @@ public:
BlockIO
execute
()
override
;
BlockIO
execute
()
override
;
bool
ignoreQuota
()
const
override
{
return
true
;
}
bool
ignoreLimits
()
const
override
{
return
true
;
}
private:
private:
ASTPtr
query_ptr
;
ASTPtr
query_ptr
;
Context
&
context
;
Context
&
context
;
...
...
dbms/src/Interpreters/SelectQueryOptions.h
浏览文件 @
38fa1af5
...
@@ -24,19 +24,16 @@ struct SelectQueryOptions
...
@@ -24,19 +24,16 @@ struct SelectQueryOptions
{
{
QueryProcessingStage
::
Enum
to_stage
;
QueryProcessingStage
::
Enum
to_stage
;
size_t
subquery_depth
;
size_t
subquery_depth
;
bool
only_analyze
;
bool
only_analyze
=
false
;
bool
modify_inplace
;
bool
modify_inplace
=
false
;
bool
remove_duplicates
;
bool
remove_duplicates
=
false
;
bool
ignore_limits
;
bool
ignore_quota
=
false
;
bool
ignore_limits
=
false
;
SelectQueryOptions
(
QueryProcessingStage
::
Enum
stage
=
QueryProcessingStage
::
Complete
,
size_t
depth
=
0
)
SelectQueryOptions
(
QueryProcessingStage
::
Enum
stage
=
QueryProcessingStage
::
Complete
,
size_t
depth
=
0
)
:
to_stage
(
stage
)
:
to_stage
(
stage
),
subquery_depth
(
depth
)
,
subquery_depth
(
depth
)
{
,
only_analyze
(
false
)
}
,
modify_inplace
(
false
)
,
remove_duplicates
(
false
)
,
ignore_limits
(
false
)
{}
SelectQueryOptions
copy
()
const
{
return
*
this
;
}
SelectQueryOptions
copy
()
const
{
return
*
this
;
}
...
...
dbms/src/Interpreters/executeQuery.cpp
浏览文件 @
38fa1af5
...
@@ -271,10 +271,6 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
...
@@ -271,10 +271,6 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
/// Check the limits.
/// Check the limits.
checkASTSizeLimits
(
*
ast
,
settings
);
checkASTSizeLimits
(
*
ast
,
settings
);
auto
quota
=
context
.
getQuota
();
quota
->
used
(
Quota
::
QUERIES
,
1
);
quota
->
checkExceeded
(
Quota
::
ERRORS
);
/// Put query to process list. But don't put SHOW PROCESSLIST query itself.
/// Put query to process list. But don't put SHOW PROCESSLIST query itself.
ProcessList
::
EntryPtr
process_list_entry
;
ProcessList
::
EntryPtr
process_list_entry
;
if
(
!
internal
&&
!
ast
->
as
<
ASTShowProcesslistQuery
>
())
if
(
!
internal
&&
!
ast
->
as
<
ASTShowProcesslistQuery
>
())
...
@@ -312,6 +308,21 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
...
@@ -312,6 +308,21 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
auto
interpreter
=
InterpreterFactory
::
get
(
ast
,
context
,
stage
);
auto
interpreter
=
InterpreterFactory
::
get
(
ast
,
context
,
stage
);
bool
use_processors
=
settings
.
experimental_use_processors
&&
allow_processors
&&
interpreter
->
canExecuteWithProcessors
();
bool
use_processors
=
settings
.
experimental_use_processors
&&
allow_processors
&&
interpreter
->
canExecuteWithProcessors
();
QuotaContextPtr
quota
;
if
(
!
interpreter
->
ignoreQuota
())
{
quota
=
context
.
getQuota
();
quota
->
used
(
Quota
::
QUERIES
,
1
);
quota
->
checkExceeded
(
Quota
::
ERRORS
);
}
IBlockInputStream
::
LocalLimits
limits
;
if
(
!
interpreter
->
ignoreLimits
())
{
limits
.
mode
=
IBlockInputStream
::
LIMITS_CURRENT
;
limits
.
size_limits
=
SizeLimits
(
settings
.
max_result_rows
,
settings
.
max_result_bytes
,
settings
.
result_overflow_mode
);
}
if
(
use_processors
)
if
(
use_processors
)
pipeline
=
interpreter
->
executeWithProcessors
();
pipeline
=
interpreter
->
executeWithProcessors
();
else
else
...
@@ -338,17 +349,12 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
...
@@ -338,17 +349,12 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
/// Hold element of process list till end of query execution.
/// Hold element of process list till end of query execution.
res
.
process_list_entry
=
process_list_entry
;
res
.
process_list_entry
=
process_list_entry
;
IBlockInputStream
::
LocalLimits
limits
;
limits
.
mode
=
IBlockInputStream
::
LIMITS_CURRENT
;
limits
.
size_limits
=
SizeLimits
(
settings
.
max_result_rows
,
settings
.
max_result_bytes
,
settings
.
result_overflow_mode
);
if
(
use_processors
)
if
(
use_processors
)
{
{
pipeline
.
setProgressCallback
(
context
.
getProgressCallback
());
pipeline
.
setProcessListElement
(
context
.
getProcessListElement
());
/// Limits on the result, the quota on the result, and also callback for progress.
/// Limits on the result, the quota on the result, and also callback for progress.
/// Limits apply only to the final result.
/// Limits apply only to the final result.
pipeline
.
setProgressCallback
(
context
.
getProgressCallback
());
pipeline
.
setProcessListElement
(
context
.
getProcessListElement
());
if
(
stage
==
QueryProcessingStage
::
Complete
)
if
(
stage
==
QueryProcessingStage
::
Complete
)
{
{
pipeline
.
resize
(
1
);
pipeline
.
resize
(
1
);
...
@@ -362,17 +368,18 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
...
@@ -362,17 +368,18 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
}
}
else
else
{
{
/// Limits on the result, the quota on the result, and also callback for progress.
/// Limits apply only to the final result.
if
(
res
.
in
)
if
(
res
.
in
)
{
{
res
.
in
->
setProgressCallback
(
context
.
getProgressCallback
());
res
.
in
->
setProgressCallback
(
context
.
getProgressCallback
());
res
.
in
->
setProcessListElement
(
context
.
getProcessListElement
());
res
.
in
->
setProcessListElement
(
context
.
getProcessListElement
());
/// Limits on the result, the quota on the result, and also callback for progress.
/// Limits apply only to the final result.
if
(
stage
==
QueryProcessingStage
::
Complete
)
if
(
stage
==
QueryProcessingStage
::
Complete
)
{
{
res
.
in
->
setLimits
(
limits
);
if
(
!
interpreter
->
ignoreQuota
())
res
.
in
->
setQuota
(
quota
);
res
.
in
->
setQuota
(
quota
);
if
(
!
interpreter
->
ignoreLimits
())
res
.
in
->
setLimits
(
limits
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录