Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
fe595244
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,发现更多精彩内容 >>
提交
fe595244
编写于
4月 15, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implemented in a different way
上级
c22f91db
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
48 addition
and
43 deletion
+48
-43
programs/client/Client.cpp
programs/client/Client.cpp
+14
-5
programs/client/ConnectionParameters.cpp
programs/client/ConnectionParameters.cpp
+0
-2
programs/client/ConnectionParameters.h
programs/client/ConnectionParameters.h
+0
-1
programs/local/LocalServer.cpp
programs/local/LocalServer.cpp
+1
-1
programs/server/HTTPHandler.cpp
programs/server/HTTPHandler.cpp
+3
-1
programs/server/TCPHandler.cpp
programs/server/TCPHandler.cpp
+2
-10
src/Client/Connection.cpp
src/Client/Connection.cpp
+1
-6
src/Client/Connection.h
src/Client/Connection.h
+0
-6
src/Core/Defines.h
src/Core/Defines.h
+0
-3
src/Core/MySQLProtocol.h
src/Core/MySQLProtocol.h
+3
-3
src/Dictionaries/ClickHouseDictionarySource.cpp
src/Dictionaries/ClickHouseDictionarySource.cpp
+1
-1
src/Interpreters/ClientInfo.cpp
src/Interpreters/ClientInfo.cpp
+8
-0
src/Interpreters/ClientInfo.h
src/Interpreters/ClientInfo.h
+4
-0
src/Interpreters/Context.cpp
src/Interpreters/Context.cpp
+7
-3
src/Interpreters/Context.h
src/Interpreters/Context.h
+2
-1
src/Interpreters/executeQuery.cpp
src/Interpreters/executeQuery.cpp
+2
-0
未找到文件。
programs/client/Client.cpp
浏览文件 @
fe595244
...
...
@@ -397,6 +397,10 @@ private:
ignore_error
=
config
().
getBool
(
"ignore-error"
,
false
);
}
ClientInfo
&
client_info
=
context
.
getClientInfo
();
client_info
.
setInitialQuery
();
client_info
.
quota_key
=
config
().
getString
(
"quota_key"
,
""
);
connect
();
/// Initialize DateLUT here to avoid counting time spent here as query execution time.
...
...
@@ -589,9 +593,6 @@ private:
connection_parameters
.
compression
,
connection_parameters
.
security
);
if
(
!
connection_parameters
.
quota_key
.
empty
())
connection
->
setQuotaKey
(
connection_parameters
.
quota_key
);
String
server_name
;
UInt64
server_version_major
=
0
;
UInt64
server_version_minor
=
0
;
...
...
@@ -906,7 +907,7 @@ private:
query_id
,
QueryProcessingStage
::
Complete
,
&
context
.
getSettingsRef
(),
nullptr
,
&
context
.
getClientInfo
()
,
true
);
sendExternalTables
();
...
...
@@ -938,7 +939,15 @@ private:
if
(
!
parsed_insert_query
.
data
&&
(
is_interactive
||
(
!
stdin_is_a_tty
&&
std_in
.
eof
())))
throw
Exception
(
"No data to insert"
,
ErrorCodes
::
NO_DATA_TO_INSERT
);
connection
->
sendQuery
(
connection_parameters
.
timeouts
,
query_without_data
,
query_id
,
QueryProcessingStage
::
Complete
,
&
context
.
getSettingsRef
(),
nullptr
,
true
);
connection
->
sendQuery
(
connection_parameters
.
timeouts
,
query_without_data
,
query_id
,
QueryProcessingStage
::
Complete
,
&
context
.
getSettingsRef
(),
&
context
.
getClientInfo
(),
true
);
sendExternalTables
();
/// Receive description of table structure.
...
...
programs/client/ConnectionParameters.cpp
浏览文件 @
fe595244
...
...
@@ -55,8 +55,6 @@ ConnectionParameters::ConnectionParameters(const Poco::Util::AbstractConfigurati
password
=
result
;
}
quota_key
=
config
.
getString
(
"quota_key"
,
""
);
compression
=
config
.
getBool
(
"compression"
,
true
)
?
Protocol
::
Compression
::
Enable
:
Protocol
::
Compression
::
Disable
;
timeouts
=
ConnectionTimeouts
(
...
...
programs/client/ConnectionParameters.h
浏览文件 @
fe595244
...
...
@@ -18,7 +18,6 @@ struct ConnectionParameters
std
::
string
default_database
;
std
::
string
user
;
std
::
string
password
;
std
::
string
quota_key
;
Protocol
::
Secure
security
=
Protocol
::
Secure
::
Disable
;
Protocol
::
Compression
compression
=
Protocol
::
Compression
::
Enable
;
ConnectionTimeouts
timeouts
;
...
...
programs/local/LocalServer.cpp
浏览文件 @
fe595244
...
...
@@ -276,7 +276,7 @@ void LocalServer::processQueries()
context
->
makeSessionContext
();
context
->
makeQueryContext
();
context
->
setUser
(
"default"
,
""
,
Poco
::
Net
::
SocketAddress
{}
,
""
);
context
->
setUser
(
"default"
,
""
,
Poco
::
Net
::
SocketAddress
{});
context
->
setCurrentQueryId
(
""
);
applyCmdSettings
();
...
...
programs/server/HTTPHandler.cpp
浏览文件 @
fe595244
...
...
@@ -267,8 +267,10 @@ void HTTPHandler::processQuery(
}
std
::
string
query_id
=
params
.
get
(
"query_id"
,
""
);
context
.
setUser
(
user
,
password
,
request
.
clientAddress
()
,
quota_key
);
context
.
setUser
(
user
,
password
,
request
.
clientAddress
());
context
.
setCurrentQueryId
(
query_id
);
if
(
!
quota_key
.
empty
())
context
.
setQuotaKey
(
quota_key
);
/// The user could specify session identifier and session timeout.
/// It allows to modify settings, create temporary tables and reuse them in subsequent requests.
...
...
programs/server/TCPHandler.cpp
浏览文件 @
fe595244
...
...
@@ -743,7 +743,6 @@ void TCPHandler::receiveHello()
UInt64
packet_type
=
0
;
String
user
=
"default"
;
String
password
;
String
quota_key
;
readVarUInt
(
packet_type
,
*
in
);
if
(
packet_type
!=
Protocol
::
Client
::
Hello
)
...
...
@@ -773,9 +772,6 @@ void TCPHandler::receiveHello()
readStringBinary
(
user
,
*
in
);
readStringBinary
(
password
,
*
in
);
if
(
client_revision
>=
DBMS_MIN_REVISION_WITH_CLIENT_PROVIDED_QUOTA_KEY
)
readStringBinary
(
quota_key
,
*
in
);
LOG_DEBUG
(
log
,
"Connected "
<<
client_name
<<
" version "
<<
client_version_major
<<
"."
<<
client_version_minor
...
...
@@ -783,28 +779,24 @@ void TCPHandler::receiveHello()
<<
", revision: "
<<
client_revision
<<
(
!
default_database
.
empty
()
?
", database: "
+
default_database
:
""
)
<<
(
!
user
.
empty
()
?
", user: "
+
user
:
""
)
<<
(
!
quota_key
.
empty
()
?
", quota_key: "
+
quota_key
:
""
)
/// quota key is not secret info.
<<
"."
);
connection_context
.
setUser
(
user
,
password
,
socket
().
peerAddress
()
,
quota_key
);
connection_context
.
setUser
(
user
,
password
,
socket
().
peerAddress
());
}
void
TCPHandler
::
receiveUnexpectedHello
()
{
UInt64
skip_uint_64
;
UInt64
client_revision
;
String
skip_string
;
readStringBinary
(
skip_string
,
*
in
);
readVarUInt
(
skip_uint_64
,
*
in
);
readVarUInt
(
skip_uint_64
,
*
in
);
readVarUInt
(
client_revision
,
*
in
);
readVarUInt
(
skip_uint_64
,
*
in
);
readStringBinary
(
skip_string
,
*
in
);
readStringBinary
(
skip_string
,
*
in
);
readStringBinary
(
skip_string
,
*
in
);
if
(
client_revision
>=
DBMS_MIN_REVISION_WITH_CLIENT_PROVIDED_QUOTA_KEY
)
readStringBinary
(
skip_string
,
*
in
);
throw
NetException
(
"Unexpected packet Hello received from client"
,
ErrorCodes
::
UNEXPECTED_PACKET_FROM_CLIENT
);
}
...
...
src/Client/Connection.cpp
浏览文件 @
fe595244
...
...
@@ -177,9 +177,6 @@ void Connection::sendHello()
writeStringBinary
(
user
,
*
out
);
writeStringBinary
(
password
,
*
out
);
if
(
client_revision
>=
DBMS_MIN_REVISION_WITH_CLIENT_PROVIDED_QUOTA_KEY
)
writeStringBinary
(
quota_key
,
*
out
);
out
->
next
();
}
...
...
@@ -404,9 +401,7 @@ void Connection::sendQuery(
if
(
!
client_info
||
client_info
->
empty
())
{
/// No client info passed - means this query initiated by me.
client_info_to_send
.
query_kind
=
ClientInfo
::
QueryKind
::
INITIAL_QUERY
;
client_info_to_send
.
fillOSUserHostNameAndVersionInfo
();
client_info_to_send
.
client_name
=
(
DBMS_NAME
" "
)
+
client_name
;
client_info_to_send
.
setInitialQuery
();
}
else
{
...
...
src/Client/Connection.h
浏览文件 @
fe595244
...
...
@@ -104,11 +104,6 @@ public:
virtual
~
Connection
()
{}
void
setQuotaKey
(
String
quota_key_
)
{
quota_key
=
std
::
move
(
quota_key_
);
}
/// Set throttler of network traffic. One throttler could be used for multiple connections to limit total traffic.
void
setThrottler
(
const
ThrottlerPtr
&
throttler_
)
{
...
...
@@ -191,7 +186,6 @@ private:
String
default_database
;
String
user
;
String
password
;
String
quota_key
;
/// Address is resolved during the first connection (or the following reconnects)
/// Use it only for logging purposes
...
...
src/Core/Defines.h
浏览文件 @
fe595244
...
...
@@ -67,9 +67,6 @@
/// Mininum revision supporting SettingsBinaryFormat::STRINGS.
#define DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS 54429
/// Minimum revision when client sends quota key.
#define DBMS_MIN_REVISION_WITH_CLIENT_PROVIDED_QUOTA_KEY 54435
/// Version of ClickHouse TCP protocol. Set to git tag with latest protocol change.
#define DBMS_TCP_PROTOCOL_VERSION 54226
...
...
src/Core/MySQLProtocol.h
浏览文件 @
fe595244
...
...
@@ -955,7 +955,7 @@ public:
if
(
auth_response
->
empty
())
{
context
.
setUser
(
user_name
,
""
,
address
,
""
);
context
.
setUser
(
user_name
,
""
,
address
);
return
;
}
...
...
@@ -978,7 +978,7 @@ public:
{
password_sha1
[
i
]
=
digest
[
i
]
^
static_cast
<
unsigned
char
>
((
*
auth_response
)[
i
]);
}
context
.
setUser
(
user_name
,
password_sha1
,
address
,
""
);
context
.
setUser
(
user_name
,
password_sha1
,
address
);
}
private:
String
scramble
;
...
...
@@ -1120,7 +1120,7 @@ public:
password
.
pop_back
();
}
context
.
setUser
(
user_name
,
password
,
address
,
""
);
context
.
setUser
(
user_name
,
password
,
address
);
}
private:
...
...
src/Dictionaries/ClickHouseDictionarySource.cpp
浏览文件 @
fe595244
...
...
@@ -73,7 +73,7 @@ ClickHouseDictionarySource::ClickHouseDictionarySource(
,
load_all_query
{
query_builder
.
composeLoadAllQuery
()}
{
/// We should set user info even for the case when the dictionary is loaded in-process (without TCP communication).
context
.
setUser
(
user
,
password
,
Poco
::
Net
::
SocketAddress
(
"127.0.0.1"
,
0
)
,
{}
);
context
.
setUser
(
user
,
password
,
Poco
::
Net
::
SocketAddress
(
"127.0.0.1"
,
0
));
/// Processors are not supported here yet.
context
.
setSetting
(
"experimental_use_processors"
,
false
);
/// Query context is needed because some code in executeQuery function may assume it exists.
...
...
src/Interpreters/ClientInfo.cpp
浏览文件 @
fe595244
...
...
@@ -113,6 +113,14 @@ void ClientInfo::read(ReadBuffer & in, const UInt64 client_protocol_revision)
}
void
ClientInfo
::
setInitialQuery
()
{
query_kind
=
QueryKind
::
INITIAL_QUERY
;
fillOSUserHostNameAndVersionInfo
();
client_name
=
(
DBMS_NAME
" "
)
+
client_name
;
}
void
ClientInfo
::
fillOSUserHostNameAndVersionInfo
()
{
os_user
.
resize
(
256
,
'\0'
);
...
...
src/Interpreters/ClientInfo.h
浏览文件 @
fe595244
...
...
@@ -84,6 +84,10 @@ public:
void
write
(
WriteBuffer
&
out
,
const
UInt64
server_protocol_revision
)
const
;
void
read
(
ReadBuffer
&
in
,
const
UInt64
client_protocol_revision
);
/// Initialize parameters on client initiating query.
void
setInitialQuery
();
private:
void
fillOSUserHostNameAndVersionInfo
();
};
...
...
src/Interpreters/Context.cpp
浏览文件 @
fe595244
...
...
@@ -620,15 +620,13 @@ ConfigurationPtr Context::getUsersConfig()
}
void
Context
::
setUser
(
const
String
&
name
,
const
String
&
password
,
const
Poco
::
Net
::
SocketAddress
&
address
,
const
String
&
quota_key
)
void
Context
::
setUser
(
const
String
&
name
,
const
String
&
password
,
const
Poco
::
Net
::
SocketAddress
&
address
)
{
auto
lock
=
getLock
();
client_info
.
current_user
=
name
;
client_info
.
current_password
=
password
;
client_info
.
current_address
=
address
;
if
(
!
quota_key
.
empty
())
client_info
.
quota_key
=
quota_key
;
auto
new_user_id
=
getAccessControlManager
().
find
<
User
>
(
name
);
std
::
shared_ptr
<
const
ContextAccess
>
new_access
;
...
...
@@ -659,6 +657,12 @@ std::shared_ptr<const User> Context::getUser() const
return
access
->
getUser
();
}
void
Context
::
setQuotaKey
(
String
quota_key_
)
{
auto
lock
=
getLock
();
client_info
.
quota_key
=
std
::
move
(
quota_key_
);
}
String
Context
::
getUserName
()
const
{
auto
lock
=
getLock
();
...
...
src/Interpreters/Context.h
浏览文件 @
fe595244
...
...
@@ -228,7 +228,8 @@ public:
/// Sets the current user, checks the password and that the specified host is allowed.
/// Must be called before getClientInfo.
void
setUser
(
const
String
&
name
,
const
String
&
password
,
const
Poco
::
Net
::
SocketAddress
&
address
,
const
String
&
quota_key
);
void
setUser
(
const
String
&
name
,
const
String
&
password
,
const
Poco
::
Net
::
SocketAddress
&
address
);
void
setQuotaKey
(
String
quota_key_
);
UserPtr
getUser
()
const
;
String
getUserName
()
const
;
...
...
src/Interpreters/executeQuery.cpp
浏览文件 @
fe595244
...
...
@@ -409,6 +409,8 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem
.
client_info
=
context
.
getClientInfo
();
std
::
cerr
<<
"Quota key: "
<<
elem
.
client_info
.
quota_key
<<
"
\n
"
;
bool
log_queries
=
settings
.
log_queries
&&
!
internal
;
/// Log into system table start of query execution, if need.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录