Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
7e7fe3c4
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,发现更多精彩内容 >>
提交
7e7fe3c4
编写于
3月 02, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Execute table functions once for a query [#CLICKHOUSE-3615]
上级
651a3128
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
43 addition
and
14 deletion
+43
-14
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-0
dbms/src/Interpreters/Context.cpp
dbms/src/Interpreters/Context.cpp
+27
-13
dbms/src/Interpreters/Context.h
dbms/src/Interpreters/Context.h
+6
-0
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+4
-1
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
+3
-0
dbms/src/Interpreters/executeQuery.cpp
dbms/src/Interpreters/executeQuery.cpp
+2
-0
未找到文件。
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
7e7fe3c4
...
...
@@ -368,6 +368,7 @@ namespace ErrorCodes
extern
const
int
CANNOT_GET_CREATE_TABLE_QUERY
=
390
;
extern
const
int
EXTERNAL_LIBRARY_ERROR
=
391
;
extern
const
int
QUERY_IS_PROHIBITED
=
392
;
extern
const
int
THERE_IS_NO_QUERY
=
393
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
...
...
dbms/src/Interpreters/Context.cpp
浏览文件 @
7e7fe3c4
...
...
@@ -76,6 +76,7 @@ namespace ErrorCodes
extern
const
int
DATABASE_ALREADY_EXISTS
;
extern
const
int
TABLE_METADATA_DOESNT_EXIST
;
extern
const
int
THERE_IS_NO_SESSION
;
extern
const
int
THERE_IS_NO_QUERY
;
extern
const
int
NO_ELEMENTS_IN_CONFIG
;
extern
const
int
DDL_GUARD_IS_ACTIVE
;
extern
const
int
TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT
;
...
...
@@ -919,30 +920,29 @@ ASTPtr Context::getCreateQuery(const String & database_name, const String & tabl
Settings
Context
::
getSettings
()
const
{
auto
lock
=
getLock
();
return
settings
;
}
Limits
Context
::
getLimits
()
const
{
auto
lock
=
getLock
();
return
settings
.
limits
;
}
void
Context
::
setSettings
(
const
Settings
&
settings_
)
{
auto
lock
=
getLock
();
settings
=
settings_
;
}
void
Context
::
setSetting
(
const
String
&
name
,
const
Field
&
value
)
{
auto
lock
=
getLock
();
if
(
name
==
"profile"
)
{
auto
lock
=
getLock
();
settings
.
setProfile
(
value
.
safeGet
<
String
>
(),
*
shared
->
users_config
);
}
else
settings
.
set
(
name
,
value
);
}
...
...
@@ -950,9 +950,11 @@ void Context::setSetting(const String & name, const Field & value)
void
Context
::
setSetting
(
const
String
&
name
,
const
std
::
string
&
value
)
{
auto
lock
=
getLock
();
if
(
name
==
"profile"
)
{
auto
lock
=
getLock
();
settings
.
setProfile
(
value
,
*
shared
->
users_config
);
}
else
settings
.
set
(
name
,
value
);
}
...
...
@@ -960,14 +962,12 @@ void Context::setSetting(const String & name, const std::string & value)
String
Context
::
getCurrentDatabase
()
const
{
auto
lock
=
getLock
();
return
current_database
;
}
String
Context
::
getCurrentQueryId
()
const
{
auto
lock
=
getLock
();
return
client_info
.
current_query_id
;
}
...
...
@@ -982,8 +982,6 @@ void Context::setCurrentDatabase(const String & name)
void
Context
::
setCurrentQueryId
(
const
String
&
query_id
)
{
auto
lock
=
getLock
();
if
(
!
client_info
.
current_query_id
.
empty
())
throw
Exception
(
"Logical error: attempt to set query_id twice"
,
ErrorCodes
::
LOGICAL_ERROR
);
...
...
@@ -1006,8 +1004,12 @@ void Context::setCurrentQueryId(const String & query_id)
};
}
random
;
{
auto
lock
=
getLock
();
random
.
a
=
shared
->
rng
();
random
.
b
=
shared
->
rng
();
}
/// Use protected constructor.
struct
UUID
:
Poco
::
UUID
...
...
@@ -1025,14 +1027,12 @@ void Context::setCurrentQueryId(const String & query_id)
String
Context
::
getDefaultFormat
()
const
{
auto
lock
=
getLock
();
return
default_format
.
empty
()
?
"TabSeparated"
:
default_format
;
}
void
Context
::
setDefaultFormat
(
const
String
&
name
)
{
auto
lock
=
getLock
();
default_format
=
name
;
}
...
...
@@ -1047,6 +1047,20 @@ void Context::setMacros(Macros && macros)
shared
->
macros
=
macros
;
}
const
Context
&
Context
::
getQueryContext
()
const
{
if
(
!
query_context
)
throw
Exception
(
"There is no query"
,
ErrorCodes
::
THERE_IS_NO_QUERY
);
return
*
query_context
;
}
Context
&
Context
::
getQueryContext
()
{
if
(
!
query_context
)
throw
Exception
(
"There is no query"
,
ErrorCodes
::
THERE_IS_NO_QUERY
);
return
*
query_context
;
}
const
Context
&
Context
::
getSessionContext
()
const
{
if
(
!
session_context
)
...
...
dbms/src/Interpreters/Context.h
浏览文件 @
7e7fe3c4
...
...
@@ -105,6 +105,7 @@ private:
/// Thus, used in HTTP interface. If not specified - then some globally default format is used.
Tables
external_tables
;
/// Temporary tables. Keyed by table name.
Tables
table_function_results
;
/// Temporary tables obtained by execution of table functions. Keyed by AST tree id.
Context
*
query_context
=
nullptr
;
Context
*
session_context
=
nullptr
;
/// Session context or nullptr. Could be equal to this.
Context
*
global_context
=
nullptr
;
/// Global context or nullptr. Could be equal to this.
SystemLogsPtr
system_logs
;
/// Used to log queries and operations on parts
...
...
@@ -257,6 +258,10 @@ public:
/// For methods below you may need to acquire a lock by yourself.
std
::
unique_lock
<
std
::
recursive_mutex
>
getLock
()
const
;
const
Context
&
getQueryContext
()
const
;
Context
&
getQueryContext
();
bool
hasQueryContext
()
const
{
return
query_context
!=
nullptr
;
}
const
Context
&
getSessionContext
()
const
;
Context
&
getSessionContext
();
bool
hasSessionContext
()
const
{
return
session_context
!=
nullptr
;
}
...
...
@@ -265,6 +270,7 @@ public:
Context
&
getGlobalContext
();
bool
hasGlobalContext
()
const
{
return
global_context
!=
nullptr
;
}
void
setQueryContext
(
Context
&
context_
)
{
query_context
=
&
context_
;
}
void
setSessionContext
(
Context
&
context_
)
{
session_context
=
&
context_
;
}
void
setGlobalContext
(
Context
&
context_
)
{
global_context
=
&
context_
;
}
...
...
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
7e7fe3c4
...
...
@@ -103,6 +103,9 @@ void InterpreterSelectQuery::init(const Names & required_result_column_names)
{
ProfileEvents
::
increment
(
ProfileEvents
::
SelectQuery
);
if
(
!
context
.
hasQueryContext
())
context
.
setQueryContext
(
context
);
initSettings
();
const
Settings
&
settings
=
context
.
getSettingsRef
();
...
...
@@ -128,7 +131,7 @@ void InterpreterSelectQuery::init(const Names & required_result_column_names)
else
if
(
table_expression
&&
typeid_cast
<
const
ASTFunction
*>
(
table_expression
.
get
()))
{
/// Read from table function.
storage
=
context
.
executeTableFunction
(
table_expression
);
storage
=
context
.
getQueryContext
().
executeTableFunction
(
table_expression
);
}
else
{
...
...
dbms/src/Interpreters/InterpreterSelectWithUnionQuery.cpp
浏览文件 @
7e7fe3c4
...
...
@@ -32,6 +32,9 @@ InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(
to_stage
(
to_stage_
),
subquery_depth
(
subquery_depth_
)
{
if
(
!
context
.
hasQueryContext
())
context
.
setQueryContext
(
context
);
const
ASTSelectWithUnionQuery
&
ast
=
typeid_cast
<
const
ASTSelectWithUnionQuery
&>
(
*
query_ptr
);
size_t
num_selects
=
ast
.
list_of_selects
->
children
.
size
();
...
...
dbms/src/Interpreters/executeQuery.cpp
浏览文件 @
7e7fe3c4
...
...
@@ -140,6 +140,8 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
ProfileEvents
::
increment
(
ProfileEvents
::
Query
);
time_t
current_time
=
time
(
nullptr
);
context
.
setQueryContext
(
context
);
const
Settings
&
settings
=
context
.
getSettingsRef
();
ParserQuery
parser
(
end
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录