Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
413b780b
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,发现更多精彩内容 >>
提交
413b780b
编写于
6月 16, 2019
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various fixes for PVS-Studio
上级
9679e30b
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
176 addition
and
245 deletion
+176
-245
dbms/programs/server/MySQLHandler.h
dbms/programs/server/MySQLHandler.h
+2
-2
dbms/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h
...rc/AggregateFunctions/AggregateFunctionStatisticsSimple.h
+1
-0
dbms/src/Common/PoolWithFailoverBase.h
dbms/src/Common/PoolWithFailoverBase.h
+3
-3
dbms/src/Common/TaskStatsInfoGetter.cpp
dbms/src/Common/TaskStatsInfoGetter.cpp
+13
-4
dbms/src/Common/Volnitsky.h
dbms/src/Common/Volnitsky.h
+2
-2
dbms/src/Common/tests/thread_creation_latency.cpp
dbms/src/Common/tests/thread_creation_latency.cpp
+5
-40
dbms/src/DataTypes/tests/CMakeLists.txt
dbms/src/DataTypes/tests/CMakeLists.txt
+0
-6
dbms/src/DataTypes/tests/data_type_get_common_type.cpp
dbms/src/DataTypes/tests/data_type_get_common_type.cpp
+0
-166
dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp
dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp
+127
-0
dbms/src/Formats/CapnProtoRowInputStream.h
dbms/src/Formats/CapnProtoRowInputStream.h
+3
-3
dbms/src/Functions/FunctionsConversion.h
dbms/src/Functions/FunctionsConversion.h
+3
-3
dbms/src/Functions/SimdJSONParser.h
dbms/src/Functions/SimdJSONParser.h
+3
-3
dbms/src/IO/ReadBufferFromFileBase.h
dbms/src/IO/ReadBufferFromFileBase.h
+1
-1
dbms/src/IO/WriteBufferFromOStream.h
dbms/src/IO/WriteBufferFromOStream.h
+1
-1
dbms/src/IO/readFloatText.h
dbms/src/IO/readFloatText.h
+1
-1
dbms/src/Interpreters/ExpressionActions.h
dbms/src/Interpreters/ExpressionActions.h
+1
-1
dbms/src/Interpreters/SyntaxAnalyzer.cpp
dbms/src/Interpreters/SyntaxAnalyzer.cpp
+8
-7
dbms/src/Interpreters/tests/hash_map_string_small.cpp
dbms/src/Interpreters/tests/hash_map_string_small.cpp
+1
-1
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h
+1
-1
未找到文件。
dbms/programs/server/MySQLHandler.h
浏览文件 @
413b780b
...
...
@@ -43,8 +43,8 @@ private:
size_t
connection_id
=
0
;
size_t
server_capability_flags
;
size_t
client_capability_flags
;
size_t
server_capability_flags
=
0
;
size_t
client_capability_flags
=
0
;
RSA
&
public_key
;
RSA
&
private_key
;
...
...
dbms/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h
浏览文件 @
413b780b
...
...
@@ -411,6 +411,7 @@ public:
return
"covarSamp"
;
if
constexpr
(
StatFunc
::
kind
==
StatisticsFunctionKind
::
corr
)
return
"corr"
;
__builtin_unreachable
();
}
DataTypePtr
getReturnType
()
const
override
...
...
dbms/src/Common/PoolWithFailoverBase.h
浏览文件 @
413b780b
...
...
@@ -167,9 +167,9 @@ PoolWithFailoverBase<TNestedPool>::getMany(
struct
ShuffledPool
{
NestedPool
*
pool
;
const
PoolState
*
state
;
size_t
index
;
NestedPool
*
pool
{}
;
const
PoolState
*
state
{}
;
size_t
index
=
0
;
size_t
error_count
=
0
;
};
...
...
dbms/src/Common/TaskStatsInfoGetter.cpp
浏览文件 @
413b780b
...
...
@@ -90,12 +90,17 @@ struct NetlinkMessage
const
char
*
request_buf
=
reinterpret_cast
<
const
char
*>
(
this
);
ssize_t
request_size
=
header
.
nlmsg_len
;
::
sockaddr_nl
nladdr
{};
union
{
::
sockaddr_nl
nladdr
{};
::
sockaddr
sockaddr
;
};
nladdr
.
nl_family
=
AF_NETLINK
;
while
(
true
)
{
ssize_t
bytes_sent
=
::
sendto
(
fd
,
request_buf
,
request_size
,
0
,
reinterpret_cast
<
const
::
sockaddr
*>
(
&
nladdr
)
,
sizeof
(
nladdr
));
ssize_t
bytes_sent
=
::
sendto
(
fd
,
request_buf
,
request_size
,
0
,
&
sockaddr
,
sizeof
(
nladdr
));
if
(
bytes_sent
<=
0
)
{
...
...
@@ -236,10 +241,14 @@ TaskStatsInfoGetter::TaskStatsInfoGetter()
if
(
0
!=
::
setsockopt
(
netlink_socket_fd
,
SOL_SOCKET
,
SO_RCVTIMEO
,
reinterpret_cast
<
const
char
*>
(
&
tv
),
sizeof
(
tv
)))
throwFromErrno
(
"Can't set timeout on PF_NETLINK socket"
,
ErrorCodes
::
NETLINK_ERROR
);
::
sockaddr_nl
addr
{};
union
{
::
sockaddr_nl
addr
{};
::
sockaddr
sockaddr
;
};
addr
.
nl_family
=
AF_NETLINK
;
if
(
::
bind
(
netlink_socket_fd
,
reinterpret_cast
<
const
::
sockaddr
*>
(
&
addr
)
,
sizeof
(
addr
))
<
0
)
if
(
::
bind
(
netlink_socket_fd
,
&
sockaddr
,
sizeof
(
addr
))
<
0
)
throwFromErrno
(
"Can't bind PF_NETLINK socket"
,
ErrorCodes
::
NETLINK_ERROR
);
taskstats_family_id
=
getFamilyId
(
netlink_socket_fd
);
...
...
dbms/src/Common/Volnitsky.h
浏览文件 @
413b780b
...
...
@@ -187,8 +187,8 @@ namespace VolnitskyTraits
/// put ngram for uppercase
utf8
.
convert
(
u_u32
,
seq
,
sizeof
(
seq
));
chars
.
c0
=
seq
[
seq_ngram_offset
];
chars
.
c1
=
seq
[
seq_ngram_offset
+
1
];
chars
.
c0
=
seq
[
seq_ngram_offset
];
//-V519
chars
.
c1
=
seq
[
seq_ngram_offset
+
1
];
//-V519
putNGramBase
(
n
,
offset
);
}
}
...
...
dbms/src/Common/tests/thread_creation_latency.cpp
浏览文件 @
413b780b
...
...
@@ -8,18 +8,10 @@
#include <Common/ThreadPool.h>
int
x
=
0
;
int
value
=
0
;
void
f
()
{
++
x
;
}
/*void f()
{
std::vector<std::string> vec;
for (size_t i = 0; i < 100; ++i)
vec.push_back(std::string(rand() % 10, ' '));
}*/
void
*
g
(
void
*
)
{
f
();
return
{};
}
void
f
()
{
++
value
;
}
void
*
g
(
void
*
)
{
f
();
return
{};
}
namespace
DB
...
...
@@ -34,7 +26,7 @@ namespace DB
template
<
typename
F
>
void
test
(
size_t
n
,
const
char
*
name
,
F
&&
kernel
)
{
x
=
0
;
value
=
0
;
Stopwatch
watch
;
Stopwatch
watch_one
;
...
...
@@ -62,7 +54,7 @@ void test(size_t n, const char * name, F && kernel)
<<
n
/
watch
.
elapsedSeconds
()
<<
" ops/sec., "
<<
"avg latency: "
<<
watch
.
elapsedSeconds
()
/
n
*
1000000
<<
" μs, "
<<
"max latency: "
<<
max_seconds
*
1000000
<<
" μs "
<<
"(res = "
<<
x
<<
")"
<<
"(res = "
<<
value
<<
")"
<<
std
::
endl
;
}
...
...
@@ -71,13 +63,6 @@ int main(int argc, char ** argv)
{
size_t
n
=
argc
==
2
?
DB
::
parse
<
UInt64
>
(
argv
[
1
])
:
100000
;
/* test(n, "Create and destroy boost::threadpool each iteration", []
{
boost::threadpool::pool tp(1);
tp.schedule(f);
tp.wait();
});*/
test
(
n
,
"Create and destroy ThreadPool each iteration"
,
[]
{
ThreadPool
tp
(
1
);
...
...
@@ -100,16 +85,6 @@ int main(int argc, char ** argv)
thread
.
join
();
});
/* {
boost::threadpool::pool tp(1);
test(n, "Schedule job for boost::threadpool each iteration", [&tp]
{
tp.schedule(f);
tp.wait();
});
}*/
{
ThreadPool
tp
(
1
);
...
...
@@ -120,16 +95,6 @@ int main(int argc, char ** argv)
});
}
/* {
boost::threadpool::pool tp(128);
test(n, "Schedule job for boost::threadpool with 128 threads each iteration", [&tp]
{
tp.schedule(f);
tp.wait();
});
}*/
{
ThreadPool
tp
(
128
);
...
...
dbms/src/DataTypes/tests/CMakeLists.txt
浏览文件 @
413b780b
add_executable
(
data_types_number_fixed data_types_number_fixed.cpp
)
target_link_libraries
(
data_types_number_fixed PRIVATE dbms
)
add_executable
(
data_type_string data_type_string.cpp
)
target_link_libraries
(
data_type_string PRIVATE dbms
)
if
(
USE_GTEST
)
add_executable
(
data_type_get_common_type data_type_get_common_type.cpp
)
target_link_libraries
(
data_type_get_common_type PRIVATE dbms
${
GTEST_BOTH_LIBRARIES
}
)
endif
()
dbms/src/DataTypes/tests/data_type_get_common_type.cpp
已删除
100644 → 0
浏览文件 @
9679e30b
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/getLeastSupertype.h>
#include <DataTypes/getMostSubtype.h>
#include <sstream>
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>
using
namespace
DB
;
TEST
(
data_type
,
data_type_get_common_type_Test
)
{
try
{
auto
&
data_type_factory
=
DataTypeFactory
::
instance
();
auto
typeFromString
=
[
&
data_type_factory
](
const
std
::
string
&
str
)
{
return
data_type_factory
.
get
(
str
);
};
auto
typesFromString
=
[
&
typeFromString
](
const
std
::
string
&
str
)
{
std
::
istringstream
data_types_stream
(
str
);
DataTypes
data_types
;
std
::
string
data_type
;
while
(
data_types_stream
>>
data_type
)
data_types
.
push_back
(
typeFromString
(
data_type
));
return
data_types
;
};
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
""
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Int8 Int8"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 Int16"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt32 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Int8 Int32 Int64"
))
->
equals
(
*
typeFromString
(
"Int64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt32 Int64"
))
->
equals
(
*
typeFromString
(
"Int64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 Float64"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt16 Int16"
))
->
equals
(
*
typeFromString
(
"Float32"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt16 Int32"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 Int16 UInt32"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Date Date"
))
->
equals
(
*
typeFromString
(
"Date"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Date DateTime"
))
->
equals
(
*
typeFromString
(
"DateTime"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"String FixedString(32) FixedString(8)"
))
->
equals
(
*
typeFromString
(
"String"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(UInt8) Array(UInt8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(UInt8) Array(Int8)"
))
->
equals
(
*
typeFromString
(
"Array(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Float32) Array(Int16) Array(UInt32)"
))
->
equals
(
*
typeFromString
(
"Array(Float64)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(UInt8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(Int8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(Int16))"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Date) Array(DateTime)"
))
->
equals
(
*
typeFromString
(
"Array(DateTime)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(String)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(Nothing) Nothing"
))
->
equals
(
*
typeFromString
(
"Nullable(Nothing)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(UInt8) Int8"
))
->
equals
(
*
typeFromString
(
"Nullable(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(Nothing) UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Nullable(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int8,UInt8) Tuple(UInt8,Int8)"
))
->
equals
(
*
typeFromString
(
"Tuple(Int16,Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Tuple(Nullable(Nothing)) Tuple(Nullable(UInt8))"
))
->
equals
(
*
typeFromString
(
"Tuple(Nullable(UInt8))"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Int8 String"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Int64 UInt64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Float64 Int64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int64) Tuple(UInt64)"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int64, Int8) Tuple(UInt64)"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Array(Int64) Array(String)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
""
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 Int8"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 UInt16"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 UInt32 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 Int32 Int64"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 Int64 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 Float64"
))
->
equals
(
*
typeFromString
(
"Float32"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 UInt16 Int16"
))
->
equals
(
*
typeFromString
(
"UInt16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 UInt16 Int32"
))
->
equals
(
*
typeFromString
(
"UInt16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 Int16 UInt32"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"DateTime DateTime"
))
->
equals
(
*
typeFromString
(
"DateTime"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Date DateTime"
))
->
equals
(
*
typeFromString
(
"Date"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"String FixedString(8)"
))
->
equals
(
*
typeFromString
(
"FixedString(8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"FixedString(16) FixedString(8)"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(UInt8) Array(UInt8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(UInt8) Array(Int8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Float32) Array(Int16) Array(UInt32)"
))
->
equals
(
*
typeFromString
(
"Array(Int16)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(UInt8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(Int8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Date) Array(DateTime)"
))
->
equals
(
*
typeFromString
(
"Array(Date)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(FixedString(32))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(FixedString(32))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(UInt8) Int8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(UInt8) Nullable(Int8)"
))
->
equals
(
*
typeFromString
(
"Nullable(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) Nullable(Int8)"
))
->
equals
(
*
typeFromString
(
"Nullable(Nothing)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Tuple(Int8,UInt8) Tuple(UInt8,Int8)"
))
->
equals
(
*
typeFromString
(
"Tuple(UInt8,UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Tuple(Nullable(Nothing)) Tuple(Nullable(UInt8))"
))
->
equals
(
*
typeFromString
(
"Tuple(Nullable(Nothing))"
)));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"Int8 String"
),
true
));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"Nothing"
),
true
));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"FixedString(16) FixedString(8) String"
),
true
));
}
catch
(
const
Exception
&
e
)
{
std
::
string
text
=
e
.
displayText
();
bool
print_stack_trace
=
true
;
auto
embedded_stack_trace_pos
=
text
.
find
(
"Stack trace"
);
if
(
std
::
string
::
npos
!=
embedded_stack_trace_pos
&&
!
print_stack_trace
)
text
.
resize
(
embedded_stack_trace_pos
);
std
::
cerr
<<
"Code: "
<<
e
.
code
()
<<
". "
<<
text
<<
std
::
endl
<<
std
::
endl
;
if
(
print_stack_trace
&&
std
::
string
::
npos
==
embedded_stack_trace_pos
)
{
std
::
cerr
<<
"Stack trace:"
<<
std
::
endl
<<
e
.
getStackTrace
().
toString
();
}
throw
;
}
catch
(
const
Poco
::
Exception
&
e
)
{
std
::
cerr
<<
"Poco::Exception: "
<<
e
.
displayText
()
<<
std
::
endl
;
throw
;
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"std::exception: "
<<
e
.
what
()
<<
std
::
endl
;
throw
;
}
catch
(...)
{
std
::
cerr
<<
"Unknown exception"
<<
std
::
endl
;
throw
;
}
}
dbms/src/DataTypes/tests/gtest_data_type_get_common_type.cpp
0 → 100644
浏览文件 @
413b780b
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/getLeastSupertype.h>
#include <DataTypes/getMostSubtype.h>
#include <sstream>
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>
using
namespace
DB
;
TEST
(
data_type
,
data_type_get_common_type_Test
)
{
auto
&
data_type_factory
=
DataTypeFactory
::
instance
();
auto
typeFromString
=
[
&
data_type_factory
](
const
std
::
string
&
str
)
{
return
data_type_factory
.
get
(
str
);
};
auto
typesFromString
=
[
&
typeFromString
](
const
std
::
string
&
str
)
{
std
::
istringstream
data_types_stream
(
str
);
DataTypes
data_types
;
std
::
string
data_type
;
while
(
data_types_stream
>>
data_type
)
data_types
.
push_back
(
typeFromString
(
data_type
));
return
data_types
;
};
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
""
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Int8 Int8"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 Int16"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt32 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Int8 Int32 Int64"
))
->
equals
(
*
typeFromString
(
"Int64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"UInt8 UInt32 Int64"
))
->
equals
(
*
typeFromString
(
"Int64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 Float64"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt16 Int16"
))
->
equals
(
*
typeFromString
(
"Float32"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt16 Int32"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Float32 Int16 UInt32"
))
->
equals
(
*
typeFromString
(
"Float64"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Date Date"
))
->
equals
(
*
typeFromString
(
"Date"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Date DateTime"
))
->
equals
(
*
typeFromString
(
"DateTime"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"String FixedString(32) FixedString(8)"
))
->
equals
(
*
typeFromString
(
"String"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(UInt8) Array(UInt8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(UInt8) Array(Int8)"
))
->
equals
(
*
typeFromString
(
"Array(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Float32) Array(Int16) Array(UInt32)"
))
->
equals
(
*
typeFromString
(
"Array(Float64)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(UInt8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(Int8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(Int16))"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(Date) Array(DateTime)"
))
->
equals
(
*
typeFromString
(
"Array(DateTime)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(String)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(Nothing) Nothing"
))
->
equals
(
*
typeFromString
(
"Nullable(Nothing)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(UInt8) Int8"
))
->
equals
(
*
typeFromString
(
"Nullable(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Nullable(Nothing) UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Nullable(Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int8,UInt8) Tuple(UInt8,Int8)"
))
->
equals
(
*
typeFromString
(
"Tuple(Int16,Int16)"
)));
ASSERT_TRUE
(
getLeastSupertype
(
typesFromString
(
"Tuple(Nullable(Nothing)) Tuple(Nullable(UInt8))"
))
->
equals
(
*
typeFromString
(
"Tuple(Nullable(UInt8))"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Int8 String"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Int64 UInt64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Float32 UInt64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Float64 Int64"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int64) Tuple(UInt64)"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Tuple(Int64, Int8) Tuple(UInt64)"
)));
EXPECT_ANY_THROW
(
getLeastSupertype
(
typesFromString
(
"Array(Int64) Array(String)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
""
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 UInt8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 Int8"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 UInt16"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 UInt32 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Int8 Int32 Int64"
))
->
equals
(
*
typeFromString
(
"Int8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"UInt8 Int64 UInt64"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 Float64"
))
->
equals
(
*
typeFromString
(
"Float32"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 UInt16 Int16"
))
->
equals
(
*
typeFromString
(
"UInt16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 UInt16 Int32"
))
->
equals
(
*
typeFromString
(
"UInt16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Float32 Int16 UInt32"
))
->
equals
(
*
typeFromString
(
"Int16"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"DateTime DateTime"
))
->
equals
(
*
typeFromString
(
"DateTime"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Date DateTime"
))
->
equals
(
*
typeFromString
(
"Date"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"String FixedString(8)"
))
->
equals
(
*
typeFromString
(
"FixedString(8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"FixedString(16) FixedString(8)"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(UInt8) Array(UInt8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(UInt8) Array(Int8)"
))
->
equals
(
*
typeFromString
(
"Array(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Float32) Array(Int16) Array(UInt32)"
))
->
equals
(
*
typeFromString
(
"Array(Int16)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(UInt8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Array(UInt8)) Array(Array(Int8))"
))
->
equals
(
*
typeFromString
(
"Array(Array(UInt8))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(Date) Array(DateTime)"
))
->
equals
(
*
typeFromString
(
"Array(Date)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(FixedString(32))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Array(String) Array(FixedString(32))"
))
->
equals
(
*
typeFromString
(
"Array(FixedString(32))"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) Nothing"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(UInt8) Int8"
))
->
equals
(
*
typeFromString
(
"UInt8"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) UInt8 Int8"
))
->
equals
(
*
typeFromString
(
"Nothing"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(UInt8) Nullable(Int8)"
))
->
equals
(
*
typeFromString
(
"Nullable(UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Nullable(Nothing) Nullable(Int8)"
))
->
equals
(
*
typeFromString
(
"Nullable(Nothing)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Tuple(Int8,UInt8) Tuple(UInt8,Int8)"
))
->
equals
(
*
typeFromString
(
"Tuple(UInt8,UInt8)"
)));
ASSERT_TRUE
(
getMostSubtype
(
typesFromString
(
"Tuple(Nullable(Nothing)) Tuple(Nullable(UInt8))"
))
->
equals
(
*
typeFromString
(
"Tuple(Nullable(Nothing))"
)));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"Int8 String"
),
true
));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"Nothing"
),
true
));
EXPECT_ANY_THROW
(
getMostSubtype
(
typesFromString
(
"FixedString(16) FixedString(8) String"
),
true
));
}
dbms/src/Formats/CapnProtoRowInputStream.h
浏览文件 @
413b780b
...
...
@@ -48,9 +48,9 @@ private:
struct
Action
{
enum
Type
{
POP
,
PUSH
,
READ
};
Type
type
;
capnp
::
StructSchema
::
Field
field
=
{};
BlockPositionList
columns
=
{};
Type
type
{}
;
capnp
::
StructSchema
::
Field
field
{};
BlockPositionList
columns
{};
};
// Wrapper for classes that could throw in destructor
...
...
dbms/src/Functions/FunctionsConversion.h
浏览文件 @
413b780b
...
...
@@ -394,10 +394,10 @@ inline void parseImpl<DataTypeUUID>(DataTypeUUID::FieldType & x, ReadBuffer & rb
template
<
typename
DataType
>
bool
tryParseImpl
(
typename
DataType
::
FieldType
&
x
,
ReadBuffer
&
rb
,
const
DateLUTImpl
*
)
{
if
constexpr
(
std
::
is_integral_v
<
typename
DataType
::
FieldType
>
)
return
tryReadIntText
(
x
,
rb
);
else
if
constexpr
(
std
::
is_floating_point_v
<
typename
DataType
::
FieldType
>
)
if
constexpr
(
std
::
is_floating_point_v
<
typename
DataType
::
FieldType
>
)
return
tryReadFloatText
(
x
,
rb
);
else
/*if constexpr (std::is_integral_v<typename DataType::FieldType>)*/
return
tryReadIntText
(
x
,
rb
);
}
template
<
>
...
...
dbms/src/Functions/SimdJSONParser.h
浏览文件 @
413b780b
...
...
@@ -95,7 +95,7 @@ struct SimdJSONParser
{
do
++
size
;
while
(
it2
.
next
()
&&
it2
.
next
());
while
(
it2
.
next
()
&&
it2
.
next
());
//-V501
}
return
size
;
}
...
...
@@ -116,13 +116,13 @@ struct SimdJSONParser
if
(
!
it
.
down
())
return
false
;
while
(
index
--
)
if
(
!
it
.
next
()
||
!
it
.
next
())
if
(
!
it
.
next
()
||
!
it
.
next
())
//-V501
return
false
;
return
it
.
next
();
}
static
bool
objectMemberByName
(
Iterator
&
it
,
const
StringRef
&
name
)
{
return
it
.
move_to_key
(
name
.
data
);
}
static
bool
nextObjectMember
(
Iterator
&
it
)
{
return
it
.
next
()
&&
it
.
next
();
}
static
bool
nextObjectMember
(
Iterator
&
it
)
{
return
it
.
next
()
&&
it
.
next
();
}
//-V501
static
bool
nextObjectMember
(
Iterator
&
it
,
StringRef
&
next_key
)
{
...
...
dbms/src/IO/ReadBufferFromFileBase.h
浏览文件 @
413b780b
...
...
@@ -41,7 +41,7 @@ public:
protected:
ProfileCallback
profile_callback
;
clockid_t
clock_type
;
clockid_t
clock_type
{}
;
/// Children implementation should be able to seek backwards
virtual
off_t
doSeek
(
off_t
off
,
int
whence
)
=
0
;
...
...
dbms/src/IO/WriteBufferFromOStream.h
浏览文件 @
413b780b
...
...
@@ -12,7 +12,7 @@ namespace DB
class
WriteBufferFromOStream
:
public
BufferWithOwnMemory
<
WriteBuffer
>
{
protected:
std
::
ostream
*
ostr
;
std
::
ostream
*
ostr
{}
;
void
nextImpl
()
override
;
...
...
dbms/src/IO/readFloatText.h
浏览文件 @
413b780b
...
...
@@ -312,7 +312,7 @@ template <typename T, typename ReturnType>
ReturnType
readFloatTextFastImpl
(
T
&
x
,
ReadBuffer
&
in
)
{
static_assert
(
std
::
is_same_v
<
T
,
double
>
||
std
::
is_same_v
<
T
,
float
>
,
"Argument for readFloatTextImpl must be float or double"
);
static_assert
(
'a'
>
'.'
&&
'A'
>
'.'
&&
'\n'
<
'.'
&&
'\t'
<
'.'
&&
'\''
<
'.'
&&
'"'
<
'.'
,
"Layout of char is not like ASCII"
);
//-V5
01
static_assert
(
'a'
>
'.'
&&
'A'
>
'.'
&&
'\n'
<
'.'
&&
'\t'
<
'.'
&&
'\''
<
'.'
&&
'"'
<
'.'
,
"Layout of char is not like ASCII"
);
//-V5
90
static
constexpr
bool
throw_exception
=
std
::
is_same_v
<
ReturnType
,
void
>
;
...
...
dbms/src/Interpreters/ExpressionActions.h
浏览文件 @
413b780b
...
...
@@ -69,7 +69,7 @@ public:
ADD_ALIASES
,
};
Type
type
;
Type
type
{}
;
/// For ADD/REMOVE/COPY_COLUMN.
std
::
string
source_name
;
...
...
dbms/src/Interpreters/SyntaxAnalyzer.cpp
浏览文件 @
413b780b
...
...
@@ -474,6 +474,14 @@ void getArrayJoinedColumns(ASTPtr & query, SyntaxAnalyzerResult & result, const
}
}
[[
noreturn
]]
static
void
throwSyntaxException
(
const
String
&
msg
)
{
throw
Exception
(
"Invalid expression for JOIN ON. "
+
msg
+
" Supported syntax: JOIN ON Expr([table.]column, ...) = Expr([table.]column, ...) "
"[AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]"
,
ErrorCodes
::
INVALID_JOIN_ON_EXPRESSION
);
};
/// Parse JOIN ON expression and collect ASTs for joined columns.
void
collectJoinedColumnsFromJoinOnExpr
(
AnalyzedJoin
&
analyzed_join
,
const
ASTTableJoin
&
table_join
)
{
...
...
@@ -528,13 +536,6 @@ void collectJoinedColumnsFromJoinOnExpr(AnalyzedJoin & analyzed_join, const ASTT
return
table_belonging
;
};
const
auto
supported_syntax
=
" Supported syntax: JOIN ON Expr([table.]column, ...) = Expr([table.]column, ...) "
"[AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]"
;
auto
throwSyntaxException
=
[
&
](
const
String
&
msg
)
{
throw
Exception
(
"Invalid expression for JOIN ON. "
+
msg
+
supported_syntax
,
ErrorCodes
::
INVALID_JOIN_ON_EXPRESSION
);
};
/// For equal expression find out corresponding table for each part, translate qualified names and add asts to join keys.
auto
add_columns_from_equals_expr
=
[
&
](
const
ASTPtr
&
expr
)
{
...
...
dbms/src/Interpreters/tests/hash_map_string_small.cpp
浏览文件 @
413b780b
...
...
@@ -23,7 +23,7 @@
struct
SmallStringRef
{
UInt32
size
;
UInt32
size
=
0
;
union
{
...
...
dbms/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h
浏览文件 @
413b780b
...
...
@@ -20,7 +20,7 @@ namespace DB
struct
ReplicatedMergeTreeQuorumEntry
{
String
part_name
;
size_t
required_number_of_replicas
;
size_t
required_number_of_replicas
{}
;
std
::
set
<
String
>
replicas
;
ReplicatedMergeTreeQuorumEntry
()
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录