Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
134c0528
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
134c0528
编写于
4月 24, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' into fix/liaohj_main
上级
83465878
a4258a5a
变更
51
展开全部
隐藏空白更改
内联
并排
Showing
51 changed file
with
3515 addition
and
1952 deletion
+3515
-1952
cmake/taostools_CMakeLists.txt.in
cmake/taostools_CMakeLists.txt.in
+1
-1
include/common/tcommon.h
include/common/tcommon.h
+2
-0
include/common/ttokendef.h
include/common/ttokendef.h
+330
-329
include/util/tdef.h
include/util/tdef.h
+4
-4
include/util/tutil.h
include/util/tutil.h
+15
-5
packaging/tools/makeclient.sh
packaging/tools/makeclient.sh
+2
-1
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+14
-1
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+16
-1
source/client/src/clientSml.c
source/client/src/clientSml.c
+32
-12
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+115
-57
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+3
-6
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+29
-7
source/common/src/tglobal.c
source/common/src/tglobal.c
+1
-1
source/dnode/mgmt/node_mgmt/src/dmNodes.c
source/dnode/mgmt/node_mgmt/src/dmNodes.c
+4
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+8
-2
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+4
-3
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+33
-16
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-0
source/libs/command/src/command.c
source/libs/command/src/command.c
+6
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+5
-0
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+1
-5
source/libs/function/CMakeLists.txt
source/libs/function/CMakeLists.txt
+40
-0
source/libs/function/test/udf1_dup.c
source/libs/function/test/udf1_dup.c
+42
-0
source/libs/function/test/udf2_dup.c
source/libs/function/test/udf2_dup.c
+78
-0
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+172
-13
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+20
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+29
-4
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2067
-1451
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-1
source/os/src/osLocale.c
source/os/src/osLocale.c
+1
-1
tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json
...taos-tools/taosbenchmark/json/rest_auto_create_table.json
+1
-2
tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json
...-taos-tools/taosbenchmark/json/sml_auto_create_table.json
+1
-2
tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json
...taos-tools/taosbenchmark/json/stmt_auto_create_table.json
+1
-2
tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json
...aos-tools/taosbenchmark/json/taosc_auto_create_table.json
+1
-2
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/script/tsim/db/table_prefix_suffix.sim
tests/script/tsim/db/table_prefix_suffix.sim
+182
-0
tests/script/tsim/query/sys_tbname.sim
tests/script/tsim/query/sys_tbname.sim
+22
-1
tests/script/tsim/query/tableCount.sim
tests/script/tsim/query/tableCount.sim
+5
-0
tests/script/tsim/tag/bigint.sim
tests/script/tsim/tag/bigint.sim
+11
-0
tests/script/tsim/tag/double.sim
tests/script/tsim/tag/double.sim
+9
-0
tests/script/tsim/tag/float.sim
tests/script/tsim/tag/float.sim
+10
-0
tests/script/tsim/tag/int.sim
tests/script/tsim/tag/int.sim
+10
-0
tests/script/tsim/tag/int_float.sim
tests/script/tsim/tag/int_float.sim
+12
-0
tests/script/tsim/tag/tinyint.sim
tests/script/tsim/tag/tinyint.sim
+22
-0
tests/system-test/0-others/udf_create.py
tests/system-test/0-others/udf_create.py
+23
-0
tests/system-test/7-tmq/stbTagFilter-1ctb.py
tests/system-test/7-tmq/stbTagFilter-1ctb.py
+4
-4
tests/system-test/7-tmq/stbTagFilter-multiCtb.py
tests/system-test/7-tmq/stbTagFilter-multiCtb.py
+4
-4
tests/system-test/7-tmq/subscribeDb3.py
tests/system-test/7-tmq/subscribeDb3.py
+6
-5
tests/system-test/7-tmq/tmqDropStb.py
tests/system-test/7-tmq/tmqDropStb.py
+2
-2
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+110
-0
未找到文件。
cmake/taostools_CMakeLists.txt.in
浏览文件 @
134c0528
...
...
@@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG
0681d8b
GIT_TAG
4378702
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
...
...
include/common/tcommon.h
浏览文件 @
134c0528
...
...
@@ -341,6 +341,8 @@ typedef struct {
float
f
;
};
size_t
length
;
bool
keyEscaped
;
bool
valueEscaped
;
}
SSmlKv
;
#define QUERY_ASC_FORWARD_STEP 1
...
...
include/common/ttokendef.h
浏览文件 @
134c0528
此差异已折叠。
点击以展开。
include/util/tdef.h
浏览文件 @
134c0528
...
...
@@ -368,11 +368,11 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_STT_TRIGGER 1
#define TSDB_MAX_STT_TRIGGER 16
#define TSDB_DEFAULT_SST_TRIGGER 1
#define TSDB_MIN_HASH_PREFIX
0
#define TSDB_MAX_HASH_PREFIX
128
#define TSDB_MIN_HASH_PREFIX
(2 - TSDB_TABLE_NAME_LEN)
#define TSDB_MAX_HASH_PREFIX
(TSDB_TABLE_NAME_LEN - 2)
#define TSDB_DEFAULT_HASH_PREFIX 0
#define TSDB_MIN_HASH_SUFFIX
0
#define TSDB_MAX_HASH_SUFFIX
128
#define TSDB_MIN_HASH_SUFFIX
(2 - TSDB_TABLE_NAME_LEN)
#define TSDB_MAX_HASH_SUFFIX
(TSDB_TABLE_NAME_LEN - 2)
#define TSDB_DEFAULT_HASH_SUFFIX 0
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
...
...
include/util/tutil.h
浏览文件 @
134c0528
...
...
@@ -81,14 +81,22 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
static
FORCE_INLINE
int32_t
taosGetTbHashVal
(
const
char
*
tbname
,
int32_t
tblen
,
int32_t
method
,
int32_t
prefix
,
int32_t
suffix
)
{
if
(
prefix
==
0
&&
suffix
==
0
)
{
if
(
(
prefix
==
0
&&
suffix
==
0
)
||
(
tblen
<=
(
prefix
+
suffix
))
||
(
tblen
<=
-
1
*
(
prefix
+
suffix
))
||
prefix
*
suffix
<
0
)
{
return
MurmurHash3_32
(
tbname
,
tblen
);
}
else
if
(
prefix
>
0
||
suffix
>
0
)
{
return
MurmurHash3_32
(
tbname
+
prefix
,
tblen
-
prefix
-
suffix
);
}
else
{
if
(
tblen
<=
(
prefix
+
suffix
))
{
return
MurmurHash3_32
(
tbname
,
tblen
);
}
else
{
return
MurmurHash3_32
(
tbname
+
prefix
,
tblen
-
prefix
-
suffix
);
char
tbName
[
TSDB_TABLE_FNAME_LEN
];
int32_t
offset
=
0
;
if
(
prefix
<
0
)
{
offset
=
-
1
*
prefix
;
strncpy
(
tbName
,
tbname
,
offset
);
}
if
(
suffix
<
0
)
{
strncpy
(
tbName
+
offset
,
tbname
+
tblen
+
suffix
,
-
1
*
suffix
);
offset
+=
-
1
*
suffix
;
}
return
MurmurHash3_32
(
tbName
,
offset
);
}
}
...
...
@@ -98,6 +106,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
goto LABEL; \
}
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
#ifdef __cplusplus
}
#endif
...
...
packaging/tools/makeclient.sh
浏览文件 @
134c0528
...
...
@@ -197,7 +197,8 @@ if [[ $productName == "TDengine" ]]; then
mkdir
-p
${
install_dir
}
/connector
if
[[
"
$pagMode
"
!=
"lite"
]]
&&
[[
"
$cpuType
"
!=
"aarch32"
]]
;
then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
[
-f
${
build_dir
}
/lib/
*
.jar
]
&&
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
jars
=
$(
ls
${
build_dir
}
/lib/
*
.jar 2>/dev/null|wc
-l
)
[
"
${
jars
}
"
!=
"0"
]
&&
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
fi
git clone
--depth
1 https://github.com/taosdata/driver-go
${
install_dir
}
/connector/go
rm
-rf
${
install_dir
}
/connector/go/.git
||
:
...
...
packaging/tools/makepkg.sh
浏览文件 @
134c0528
...
...
@@ -338,7 +338,20 @@ if [ "$verMode" == "cluster" ] || [ "$verMode" == "cloud" ]; then
connector_dir
=
"
${
code_dir
}
/connector"
mkdir
-p
${
install_dir
}
/connector
if
[[
"
$pagMode
"
!=
"lite"
]]
&&
[[
"
$cpuType
"
!=
"aarch32"
]]
;
then
[
-f
${
build_dir
}
/lib/
*
.jar
]
&&
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
tmp_pwd
=
`
pwd
`
cd
${
install_dir
}
/connector
if
[
!
-d
taos-connector-jdbc
]
;
then
git clone
-b
main
--depth
=
1 https://github.com/taosdata/taos-connector-jdbc.git
||
:
fi
cd
taos-connector-jdbc
mvn clean package
-Dmaven
.test.skip
=
true
echo
${
build_dir
}
/lib/
cp
target/
*
.jar
${
build_dir
}
/lib/
cd
${
install_dir
}
/connector
rm
-rf
taos-connector-jdbc
cd
${
tmp_pwd
}
jars
=
$(
ls
${
build_dir
}
/lib/
*
.jar 2>/dev/null|wc
-l
)
[
"
${
jars
}
"
!=
"0"
]
&&
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
||
:
git clone
--depth
1 https://github.com/taosdata/driver-go
${
install_dir
}
/connector/go
rm
-rf
${
install_dir
}
/connector/go/.git
||
:
...
...
source/client/inc/clientSml.h
浏览文件 @
134c0528
...
...
@@ -70,7 +70,7 @@ extern "C" {
#define VALUE_LEN 6
#define OTD_JSON_FIELDS_NUM 4
#define MAX_RETRY_TIMES 10
0
#define MAX_RETRY_TIMES 10
typedef
TSDB_SML_PROTOCOL_TYPE
SMLProtocolType
;
typedef
enum
{
...
...
@@ -107,6 +107,7 @@ typedef struct {
int32_t
colsLen
;
int32_t
timestampLen
;
bool
measureEscaped
;
SArray
*
colArray
;
}
SSmlLineInfo
;
...
...
@@ -206,6 +207,19 @@ typedef struct {
#define IS_SAME_KEY (maxKV->keyLen == kv.keyLen && memcmp(maxKV->key, kv.key, kv.keyLen) == 0)
#define IS_SLASH_LETTER_IN_MEASUREMENT(sql) \
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE))
#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len))
#define PROCESS_SLASH_IN_MEASUREMENT(key, keyLen) \
for (int i = 1; i < keyLen; ++i) { \
if (IS_SLASH_LETTER_IN_MEASUREMENT(key + i)) { \
MOVE_FORWARD_ONE(key + i, keyLen - i); \
keyLen--; \
} \
}
extern
int64_t
smlFactorNS
[
3
];
extern
int64_t
smlFactorS
[
3
];
...
...
@@ -237,6 +251,7 @@ uint8_t smlGetTimestampLen(int64_t num);
void
clearColValArray
(
SArray
*
pCols
);
void
smlDestroyTableInfo
(
SSmlHandle
*
info
,
SSmlTableInfo
*
tag
);
void
freeSSmlKv
(
void
*
data
);
int32_t
smlParseInfluxString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
int32_t
smlParseTelnetString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
int32_t
smlParseJSON
(
SSmlHandle
*
info
,
char
*
payload
);
...
...
source/client/src/clientSml.c
浏览文件 @
134c0528
...
...
@@ -535,7 +535,7 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
if
(
index
)
{
if
(
colField
[
*
index
].
type
!=
kv
->
type
)
{
uError
(
"SML:0x%"
PRIx64
" point type and db type mismatch. point type: %d, db type: %d, key: %s"
,
info
->
id
,
colField
[
*
index
].
type
,
kv
->
type
,
kv
->
key
);
return
TSDB_CODE_
TSC_INVALID_VALUE
;
return
TSDB_CODE_
SML_INVALID_DATA
;
}
if
((
colField
[
*
index
].
type
==
TSDB_DATA_TYPE_VARCHAR
&&
...
...
@@ -765,8 +765,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
size_t
superTableLen
=
0
;
void
*
superTable
=
taosHashGetKey
(
tmp
,
&
superTableLen
);
char
*
measure
=
taosMemoryMalloc
(
superTableLen
);
memcpy
(
measure
,
superTable
,
superTableLen
);
PROCESS_SLASH_IN_MEASUREMENT
(
measure
,
superTableLen
);
memset
(
pName
.
tname
,
0
,
TSDB_TABLE_NAME_LEN
);
memcpy
(
pName
.
tname
,
superTable
,
superTableLen
);
memcpy
(
pName
.
tname
,
measure
,
superTableLen
);
taosMemoryFree
(
measure
);
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
...
...
@@ -1049,7 +1053,7 @@ void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
// }
// taosMemoryFree(tag->key);
taosArrayDestroy
(
tag
->
cols
);
taosArrayDestroy
(
tag
->
tags
);
taosArrayDestroy
Ex
(
tag
->
tags
,
freeSSmlKv
);
taosMemoryFree
(
tag
);
}
...
...
@@ -1063,6 +1067,12 @@ void clearColValArray(SArray *pCols) {
}
}
void
freeSSmlKv
(
void
*
data
){
SSmlKv
*
kv
=
(
SSmlKv
*
)
data
;
if
(
kv
->
keyEscaped
)
taosMemoryFree
((
void
*
)(
kv
->
key
));
if
(
kv
->
valueEscaped
)
taosMemoryFree
((
void
*
)(
kv
->
value
));
}
void
smlDestroyInfo
(
SSmlHandle
*
info
)
{
if
(
!
info
)
return
;
qDestroyQuery
(
info
->
pQuery
);
...
...
@@ -1098,11 +1108,11 @@ void smlDestroyInfo(SSmlHandle *info) {
}
taosArrayDestroy
(
info
->
valueJsonArray
);
taosArrayDestroy
(
info
->
preLineTagKV
);
taosArrayDestroy
Ex
(
info
->
preLineTagKV
,
freeSSmlKv
);
if
(
!
info
->
dataFormat
)
{
for
(
int
i
=
0
;
i
<
info
->
lineNum
;
i
++
)
{
taosArrayDestroy
(
info
->
lines
[
i
].
colArray
);
taosArrayDestroy
Ex
(
info
->
lines
[
i
].
colArray
,
freeSSmlKv
);
if
(
info
->
parseJsonByLib
)
{
taosMemoryFree
(
info
->
lines
[
i
].
tags
);
}
...
...
@@ -1165,8 +1175,10 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) {
}
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
i
);
terrno
=
0
;
taosHashPut
(
kvHash
,
kv
->
key
,
kv
->
keyLen
,
&
kv
,
POINTER_BYTES
);
if
(
terrno
==
TSDB_CODE_DUP_KEY
)
{
taosHashCleanup
(
kvHash
);
return
terrno
;
}
}
...
...
@@ -1240,12 +1252,13 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
uDebug
(
"SML:0x%"
PRIx64
" smlParseLineBottom add meta, format:%d, linenum:%d"
,
info
->
id
,
info
->
dataFormat
,
info
->
lineNum
);
SSmlSTableMeta
*
meta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
meta
,
POINTER_BYTES
);
terrno
=
0
;
smlInsertMeta
(
meta
->
tagHash
,
meta
->
tags
,
tinfo
->
tags
);
if
(
terrno
==
TSDB_CODE_DUP_KEY
)
{
return
terrno
;
}
smlInsertMeta
(
meta
->
colHash
,
meta
->
cols
,
elements
->
colArray
);
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
meta
,
POINTER_BYTES
);
}
}
uDebug
(
"SML:0x%"
PRIx64
" smlParseLineBottom end, format:%d, linenum:%d"
,
info
->
id
,
info
->
dataFormat
,
info
->
lineNum
);
...
...
@@ -1304,9 +1317,15 @@ static int32_t smlInsertData(SSmlHandle *info) {
uDebug
(
"SML:0x%"
PRIx64
" smlInsertData table:%s, uid:%"
PRIu64
", format:%d"
,
info
->
id
,
pName
.
tname
,
tableData
->
uid
,
info
->
dataFormat
);
int
measureLen
=
tableData
->
sTableNameLen
;
char
*
measure
=
(
char
*
)
taosMemoryMalloc
(
tableData
->
sTableNameLen
);
memcpy
(
measure
,
tableData
->
sTableName
,
tableData
->
sTableNameLen
);
PROCESS_SLASH_IN_MEASUREMENT
(
measure
,
measureLen
);
code
=
smlBindData
(
info
->
pQuery
,
info
->
dataFormat
,
tableData
->
tags
,
(
*
pMeta
)
->
cols
,
tableData
->
cols
,
(
*
pMeta
)
->
tableMeta
,
tableData
->
childTableName
,
tableData
->
sTableName
,
tableData
->
sTableNam
eLen
,
(
*
pMeta
)
->
tableMeta
,
tableData
->
childTableName
,
measure
,
measur
eLen
,
info
->
ttl
,
info
->
msgBuf
.
buf
,
info
->
msgBuf
.
len
);
taosMemoryFree
(
measure
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlBindData failed"
,
info
->
id
);
return
code
;
...
...
@@ -1420,14 +1439,14 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
char
cTmp
=
0
;
// for print tmp if is raw
if
(
info
->
isRawLine
)
{
cTmp
=
tmp
[
len
-
1
];
tmp
[
len
-
1
]
=
'\0'
;
cTmp
=
tmp
[
len
];
tmp
[
len
]
=
'\0'
;
}
uDebug
(
"SML:0x%"
PRIx64
" smlParseLine israw:%d, numLines:%d, protocol:%d, len:%d, sql:%s"
,
info
->
id
,
info
->
isRawLine
,
numLines
,
info
->
protocol
,
len
,
tmp
);
if
(
info
->
isRawLine
)
{
tmp
[
len
-
1
]
=
cTmp
;
tmp
[
len
]
=
cTmp
;
}
if
(
info
->
protocol
==
TSDB_SML_LINE_PROTOCOL
)
{
...
...
@@ -1449,6 +1468,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
code
=
TSDB_CODE_SML_INVALID_PROTOCOL_TYPE
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tmp
[
len
]
=
'\0'
;
uError
(
"SML:0x%"
PRIx64
" smlParseLine failed. line %d : %s"
,
info
->
id
,
i
,
tmp
);
return
code
;
}
...
...
@@ -1494,8 +1514,8 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
do
{
code
=
smlModifyDBSchemas
(
info
);
if
(
code
==
0
)
break
;
taosMsleep
(
5
00
);
if
(
code
==
0
||
code
==
TSDB_CODE_SML_INVALID_DATA
)
break
;
taosMsleep
(
1
00
);
uInfo
(
"SML:0x%"
PRIx64
" smlModifyDBSchemas retry code:%s, times:%d"
,
info
->
id
,
tstrerror
(
code
),
retryNum
);
}
while
(
retryNum
++
<
taosHashGetSize
(
info
->
superTables
)
*
MAX_RETRY_TIMES
);
...
...
source/client/src/clientSmlLine.c
浏览文件 @
134c0528
...
...
@@ -21,32 +21,33 @@
#include "clientSml.h"
// comma ,
// #define IS_SLASH_COMMA(sql) (*(sql) == COMMA && *((sql)-1) == SLASH)
#define IS_COMMA(sql) (*(sql) == COMMA && *((sql)-1) != SLASH)
// space
// #define IS_SLASH_SPACE(sql) (*(sql) == SPACE && *((sql)-1) == SLASH)
#define IS_SPACE(sql) (*(sql) == SPACE && *((sql)-1) != SLASH)
// equal =
// #define IS_SLASH_EQUAL(sql) (*(sql) == EQUAL && *((sql)-1) == SLASH)
#define IS_EQUAL(sql) (*(sql) == EQUAL && *((sql)-1) != SLASH)
// quote "
// #define IS_SLASH_QUOTE(sql) (*(sql) == QUOTE && *((sql)-1) == SLASH)
#define IS_QUOTE(sql) (*(sql) == QUOTE && *((sql)-1) != SLASH)
//#define IS_QUOTE(sql) (*(sql) == QUOTE && *((sql)-1) != SLASH)
// SLASH
// #define IS_SLASH_SLASH(sql) (*(sql) == SLASH && *((sql)-1) == SLASH)
#define IS_SLASH_LETTER(sql) \
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE || *(sql) == EQUAL || *(sql) == QUOTE || \
*(sql) == SLASH)) // (IS_SLASH_COMMA(sql) || IS_SLASH_SPACE(sql) || IS_SLASH_EQUAL(sql) ||
// IS_SLASH_QUOTE(sql) || IS_SLASH_SLASH(sql))
#define IS_SLASH_LETTER_IN_FIELD_VALUE(sql) \
(*((sql)-1) == SLASH && (*(sql) == QUOTE || *(sql) == SLASH))
#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len))
#define IS_SLASH_LETTER_IN_TAG_FIELD_KEY(sql) \
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE || *(sql) == EQUAL))
#define PROCESS_SLASH(key, keyLen) \
#define PROCESS_SLASH_IN_FIELD_VALUE(key, keyLen) \
for (int i = 1; i < keyLen; ++i) { \
if (IS_SLASH_LETTER_IN_FIELD_VALUE(key + i)) { \
MOVE_FORWARD_ONE(key + i, keyLen - i); \
keyLen--; \
} \
}
#define PROCESS_SLASH_IN_TAG_FIELD_KEY(key, keyLen) \
for (int i = 1; i < keyLen; ++i) { \
if (IS_SLASH_LETTER(key + i)) { \
if (IS_SLASH_LETTER
_IN_TAG_FIELD_KEY
(key + i)) { \
MOVE_FORWARD_ONE(key + i, keyLen - i); \
i--; \
keyLen--; \
} \
}
...
...
@@ -151,7 +152,17 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
SSmlSTableMeta
*
sMeta
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
))
{
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
currElement
->
measure
,
currElement
->
measureLen
);
char
*
measure
=
currElement
->
measure
;
int
measureLen
=
currElement
->
measureLen
;
if
(
currElement
->
measureEscaped
){
measure
=
(
char
*
)
taosMemoryMalloc
(
currElement
->
measureLen
);
memcpy
(
measure
,
currElement
->
measure
,
currElement
->
measureLen
);
PROCESS_SLASH_IN_MEASUREMENT
(
measure
,
measureLen
);
}
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
measure
,
measureLen
);
if
(
currElement
->
measureEscaped
){
taosMemoryFree
(
measure
);
}
if
(
pTableMeta
==
NULL
)
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
...
...
@@ -171,17 +182,18 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
info
->
maxTagKVs
=
(
*
tmp
)
->
tags
;
}
}
taosArrayClear
(
preLineKV
);
taosArrayClear
Ex
(
preLineKV
,
freeSSmlKv
);
while
(
*
sql
<
sqlEnd
)
{
if
(
unlikely
(
IS_SPACE
(
*
sql
)))
{
break
;
}
bool
hasSlash
=
false
;
// parse key
const
char
*
key
=
*
sql
;
size_t
keyLen
=
0
;
bool
keyEscaped
=
false
;
size_t
keyLenEscaped
=
0
;
while
(
*
sql
<
sqlEnd
)
{
if
(
unlikely
(
IS_COMMA
(
*
sql
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid data"
,
*
sql
);
...
...
@@ -192,16 +204,14 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
(
*
sql
)
++
;
break
;
}
if
(
!
hasSlash
)
{
hasSlash
=
(
*
(
*
sql
)
==
SLASH
);
if
(
IS_SLASH_LETTER_IN_TAG_FIELD_KEY
(
*
sql
))
{
keyLenEscaped
++
;
keyEscaped
=
true
;
}
(
*
sql
)
++
;
}
if
(
unlikely
(
hasSlash
))
{
PROCESS_SLASH
(
key
,
keyLen
)
}
if
(
unlikely
(
IS_INVALID_COL_LEN
(
keyLen
)))
{
if
(
unlikely
(
IS_INVALID_COL_LEN
(
keyLen
-
keyLenEscaped
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid key or key is too long than 64"
,
key
);
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
...
...
@@ -209,7 +219,8 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
// parse value
const
char
*
value
=
*
sql
;
size_t
valueLen
=
0
;
hasSlash
=
false
;
bool
valueEscaped
=
false
;
size_t
valueLenEscaped
=
0
;
while
(
*
sql
<
sqlEnd
)
{
// parse value
if
(
unlikely
(
IS_SPACE
(
*
sql
)
||
IS_COMMA
(
*
sql
)))
{
...
...
@@ -219,8 +230,9 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
TSDB_CODE_SML_INVALID_DATA
;
}
if
(
!
hasSlash
)
{
hasSlash
=
(
*
(
*
sql
)
==
SLASH
);
if
(
IS_SLASH_LETTER_IN_TAG_FIELD_KEY
(
*
sql
))
{
valueLenEscaped
++
;
valueEscaped
=
true
;
}
(
*
sql
)
++
;
...
...
@@ -232,15 +244,24 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
TSDB_CODE_SML_INVALID_DATA
;
}
if
(
unlikely
(
hasSlash
))
{
PROCESS_SLASH
(
value
,
valueLen
)
}
if
(
unlikely
(
valueLen
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
))
{
if
(
unlikely
(
valueLen
-
valueLenEscaped
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
))
{
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
}
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
type
=
TSDB_DATA_TYPE_NCHAR
,
.
value
=
value
,
.
length
=
valueLen
};
if
(
keyEscaped
){
char
*
tmp
=
(
char
*
)
taosMemoryMalloc
(
keyLen
);
memcpy
(
tmp
,
key
,
keyLen
);
PROCESS_SLASH_IN_TAG_FIELD_KEY
(
tmp
,
keyLen
);
key
=
tmp
;
}
if
(
valueEscaped
){
char
*
tmp
=
(
char
*
)
taosMemoryMalloc
(
valueLen
);
memcpy
(
tmp
,
value
,
valueLen
);
PROCESS_SLASH_IN_TAG_FIELD_KEY
(
tmp
,
valueLen
);
value
=
tmp
;
}
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
type
=
TSDB_DATA_TYPE_NCHAR
,
.
value
=
value
,
.
length
=
valueLen
,
.
keyEscaped
=
keyEscaped
,
.
valueEscaped
=
valueEscaped
};
taosArrayPush
(
preLineKV
,
&
kv
);
if
(
info
->
dataFormat
)
{
if
(
unlikely
(
cnt
+
1
>
info
->
currSTableMeta
->
tableInfo
.
numOfTags
))
{
info
->
dataFormat
=
false
;
...
...
@@ -266,7 +287,6 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
info
->
needModifySchema
=
true
;
}
}
taosArrayPush
(
preLineKV
,
&
kv
);
cnt
++
;
if
(
IS_SPACE
(
*
sql
))
{
...
...
@@ -285,6 +305,11 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tinfo
->
tags
=
taosArrayDup
(
preLineKV
,
NULL
);
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
preLineKV
);
i
++
){
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
i
);
if
(
kv
->
keyEscaped
)
kv
->
key
=
NULL
;
if
(
kv
->
valueEscaped
)
kv
->
value
=
NULL
;
}
smlSetCTableName
(
tinfo
);
tinfo
->
uid
=
info
->
uid
++
;
...
...
@@ -321,7 +346,17 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
SSmlSTableMeta
**
tmp
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
);
if
(
unlikely
(
tmp
==
NULL
))
{
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
currElement
->
measure
,
currElement
->
measureLen
);
char
*
measure
=
currElement
->
measure
;
int
measureLen
=
currElement
->
measureLen
;
if
(
currElement
->
measureEscaped
){
measure
=
(
char
*
)
taosMemoryMalloc
(
currElement
->
measureLen
);
memcpy
(
measure
,
currElement
->
measure
,
currElement
->
measureLen
);
PROCESS_SLASH_IN_MEASUREMENT
(
measure
,
measureLen
);
}
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
measure
,
measureLen
);
if
(
currElement
->
measureEscaped
){
taosMemoryFree
(
measure
);
}
if
(
pTableMeta
==
NULL
)
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
...
...
@@ -352,10 +387,11 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
break
;
}
bool
hasSlash
=
false
;
// parse key
const
char
*
key
=
*
sql
;
size_t
keyLen
=
0
;
bool
keyEscaped
=
false
;
size_t
keyLenEscaped
=
0
;
while
(
*
sql
<
sqlEnd
)
{
if
(
unlikely
(
IS_COMMA
(
*
sql
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid data"
,
*
sql
);
...
...
@@ -366,16 +402,14 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
(
*
sql
)
++
;
break
;
}
if
(
!
hasSlash
)
{
hasSlash
=
(
*
(
*
sql
)
==
SLASH
);
if
(
IS_SLASH_LETTER_IN_TAG_FIELD_KEY
(
*
sql
))
{
keyLenEscaped
++
;
keyEscaped
=
true
;
}
(
*
sql
)
++
;
}
if
(
unlikely
(
hasSlash
))
{
PROCESS_SLASH
(
key
,
keyLen
)
}
if
(
unlikely
(
IS_INVALID_COL_LEN
(
keyLen
)))
{
if
(
unlikely
(
IS_INVALID_COL_LEN
(
keyLen
-
keyLenEscaped
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid key or key is too long than 64"
,
key
);
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
...
...
@@ -383,11 +417,13 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
// parse value
const
char
*
value
=
*
sql
;
size_t
valueLen
=
0
;
hasSlash
=
false
;
bool
isInQuote
=
false
;
bool
valueEscaped
=
false
;
size_t
valueLenEscaped
=
0
;
bool
isInQuote
=
false
;
const
char
*
escapeChar
=
NULL
;
while
(
*
sql
<
sqlEnd
)
{
// parse value
if
(
unlikely
(
IS_QUOTE
(
*
sql
)))
{
if
(
unlikely
(
*
(
*
sql
)
==
QUOTE
&&
(
*
(
*
sql
-
1
)
!=
SLASH
||
(
*
sql
-
1
)
==
escapeChar
)))
{
isInQuote
=
!
isInQuote
;
(
*
sql
)
++
;
continue
;
...
...
@@ -395,13 +431,12 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
if
(
!
isInQuote
)
{
if
(
unlikely
(
IS_SPACE
(
*
sql
)
||
IS_COMMA
(
*
sql
)))
{
break
;
}
else
if
(
unlikely
(
IS_EQUAL
(
*
sql
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid data"
,
*
sql
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
}
if
(
!
hasSlash
)
{
hasSlash
=
(
*
(
*
sql
)
==
SLASH
);
if
(
IS_SLASH_LETTER_IN_FIELD_VALUE
(
*
sql
)
&&
(
*
sql
-
1
)
!=
escapeChar
)
{
escapeChar
=
*
sql
;
valueEscaped
=
true
;
valueLenEscaped
++
;
}
(
*
sql
)
++
;
...
...
@@ -416,9 +451,6 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid value"
,
value
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
if
(
unlikely
(
hasSlash
))
{
PROCESS_SLASH
(
value
,
valueLen
)
}
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
value
=
value
,
.
length
=
valueLen
};
int32_t
ret
=
smlParseValue
(
&
kv
,
&
info
->
msgBuf
);
...
...
@@ -427,11 +459,28 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
ret
;
}
if
(
keyEscaped
){
char
*
tmp
=
(
char
*
)
taosMemoryMalloc
(
kv
.
keyLen
);
memcpy
(
tmp
,
key
,
kv
.
keyLen
);
PROCESS_SLASH_IN_TAG_FIELD_KEY
(
tmp
,
kv
.
keyLen
);
kv
.
key
=
tmp
;
kv
.
keyEscaped
=
keyEscaped
;
}
if
(
valueEscaped
){
char
*
tmp
=
(
char
*
)
taosMemoryMalloc
(
kv
.
length
);
memcpy
(
tmp
,
kv
.
value
,
kv
.
length
);
PROCESS_SLASH_IN_FIELD_VALUE
(
tmp
,
kv
.
length
);
kv
.
value
=
tmp
;
kv
.
valueEscaped
=
valueEscaped
;
}
if
(
info
->
dataFormat
)
{
// cnt begin 0, add ts so + 2
if
(
unlikely
(
cnt
+
2
>
info
->
currSTableMeta
->
tableInfo
.
numOfColumns
))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
freeSSmlKv
(
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
// bind data
...
...
@@ -440,22 +489,26 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
uDebug
(
"smlBuildCol error, retry"
);
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
freeSSmlKv
(
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
if
(
cnt
>=
taosArrayGetSize
(
info
->
masColKVs
))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
freeSSmlKv
(
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
info
->
masColKVs
,
cnt
);
if
(
kv
.
type
!=
maxKV
->
type
)
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
freeSSmlKv
(
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
if
(
unlikely
(
!
IS_SAME_KEY
))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
freeSSmlKv
(
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -463,6 +516,7 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
maxKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
freeSSmlKv
(
&
kv
);
}
else
{
if
(
currElement
->
colArray
==
NULL
)
{
currElement
->
colArray
=
taosArrayInit_s
(
sizeof
(
SSmlKv
),
1
);
...
...
@@ -487,10 +541,12 @@ int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine
elements
->
measure
=
sql
;
// parse measure
size_t
measureLenEscaped
=
0
;
while
(
sql
<
sqlEnd
)
{
if
(
unlikely
((
sql
!=
elements
->
measure
)
&&
IS_SLASH_LETTER
(
sql
)))
{
MOVE_FORWARD_ONE
(
sql
,
sqlEnd
-
sql
);
sqlEnd
--
;
if
(
unlikely
((
sql
!=
elements
->
measure
)
&&
IS_SLASH_LETTER_IN_MEASUREMENT
(
sql
)))
{
elements
->
measureEscaped
=
true
;
measureLenEscaped
++
;
sql
++
;
continue
;
}
if
(
unlikely
(
IS_COMMA
(
sql
)))
{
...
...
@@ -503,7 +559,7 @@ int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine
sql
++
;
}
elements
->
measureLen
=
sql
-
elements
->
measure
;
if
(
unlikely
(
IS_INVALID_TABLE_LEN
(
elements
->
measureLen
)))
{
if
(
unlikely
(
IS_INVALID_TABLE_LEN
(
elements
->
measureLen
-
measureLenEscaped
)))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"measure is empty or too large than 192"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
}
...
...
@@ -581,7 +637,9 @@ int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine
.
keyLen
=
TS_LEN
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
i
=
ts
,
.
length
=
(
size_t
)
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
};
.
length
=
(
size_t
)
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
,
.
keyEscaped
=
false
,
.
valueEscaped
=
false
};
if
(
info
->
dataFormat
)
{
uDebug
(
"SML:0x%"
PRIx64
" smlParseInfluxString format true, ts:%"
PRId64
,
info
->
id
,
ts
);
ret
=
smlBuildCol
(
info
->
currTableDataCtx
,
info
->
currSTableMeta
->
schema
,
&
kv
,
0
);
...
...
source/client/src/clientTmq.c
浏览文件 @
134c0528
...
...
@@ -373,9 +373,6 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) {
SArray
*
container
=
&
list
->
container
;
if
(
src
==
NULL
||
src
[
0
]
==
0
)
return
-
1
;
char
*
topic
=
taosStrdup
(
src
);
if
(
topic
[
0
]
!=
'`'
)
{
strtolower
(
topic
,
src
);
}
if
(
taosArrayPush
(
container
,
&
topic
)
==
NULL
)
return
-
1
;
return
0
;
}
...
...
@@ -1243,9 +1240,6 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
taosMemoryFree
(
pParam
);
if
(
code
!=
0
)
{
tscWarn
(
"consumer:0x%"
PRIx64
" msg from vgId:%d discarded, epoch %d, since %s, reqId:0x%"
PRIx64
,
tmq
->
consumerId
,
vgId
,
epoch
,
tstrerror
(
code
),
requestId
);
if
(
pMsg
->
pData
)
taosMemoryFree
(
pMsg
->
pData
);
if
(
pMsg
->
pEpSet
)
taosMemoryFree
(
pMsg
->
pEpSet
);
...
...
@@ -1267,6 +1261,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
}
else
if
(
code
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
// poll data while insert
taosMsleep
(
500
);
}
else
{
tscError
(
"consumer:0x%"
PRIx64
" msg from vgId:%d discarded, epoch %d, since %s, reqId:0x%"
PRIx64
,
tmq
->
consumerId
,
vgId
,
epoch
,
tstrerror
(
code
),
requestId
);
}
goto
CREATE_MSG_FAIL
;
...
...
source/client/test/smlTest.cpp
浏览文件 @
134c0528
...
...
@@ -50,8 +50,9 @@ TEST(testCase, smlParseInfluxString_Test) {
int
ret
=
smlParseInfluxString
(
info
,
sql
,
sql
+
strlen
(
sql
),
&
elements
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
elements
.
measure
,
sql
);
ASSERT_EQ
(
elements
.
measureLen
,
strlen
(
",st"
));
ASSERT_EQ
(
elements
.
measureTagsLen
,
strlen
(
",st,t1=3,t2=4,t3=t3"
));
ASSERT_EQ
(
elements
.
measureLen
,
strlen
(
"
\\
,st"
));
ASSERT_EQ
(
elements
.
measureEscaped
,
true
);
ASSERT_EQ
(
elements
.
measureTagsLen
,
strlen
(
"
\\
,st,t1=3,t2=4,t3=t3"
));
ASSERT_EQ
(
elements
.
tags
,
sql
+
elements
.
measureLen
+
1
);
ASSERT_EQ
(
elements
.
tagsLen
,
strlen
(
"t1=3,t2=4,t3=t3"
));
...
...
@@ -204,7 +205,26 @@ TEST(testCase, smlParseCols_Error_Test) {
"st,t=1 c=-3.402823466e+39u64 1626006833639000000"
,
"st,t=1 c=-339u64 1626006833639000000"
,
"st,t=1 c=18446744073709551616u64 1626006833639000000"
,
"st,t=1 c=1=2 1626006833639000000"
};
"st,t=1 c=1=2 1626006833639000000,"
,
// escape error test
// measure comma,space
"s,t,t=1 c=1 1626006833639000000,"
,
"s t,t=1 c=1 1626006833639000000,"
,
//tag key comma,equal,space
"st,t,t=1 c=2 1626006833639000000,"
,
"st,t=t=1 c=2 1626006833639000000,"
,
"st,t t=1 c=2 1626006833639000000,"
,
//tag value comma,equal,space
"st,tt=a,a c=2 1626006833639000000,"
,
"st,t=t=a a c=2 1626006833639000000,"
,
"st,t t=a=a c=2 1626006833639000000,"
,
//field key comma,equal,space
"st,tt=aa c,1=2 1626006833639000000,"
,
"st,tt=aa c=1=2 1626006833639000000,"
,
"st,tt=aa c 1=2 1626006833639000000,"
,
//field value double quote,slash
"st,tt=aa c=
\"
a
\"
a
\"
1626006833639000000,"
,
};
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_LINE_PROTOCOL
;
...
...
@@ -256,16 +276,18 @@ TEST(testCase, smlParseCols_Test) {
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
"cb=in"
,
5
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
5
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_BINARY
);
ASSERT_EQ
(
kv
->
length
,
17
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"pass,it "
,
8
),
0
);
ASSERT_EQ
(
kv
->
length
,
18
);
ASSERT_EQ
(
kv
->
keyEscaped
,
true
);
ASSERT_EQ
(
kv
->
valueEscaped
,
false
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"pass
\\
,it "
,
9
),
0
);
// nchar
kv
=
(
SSmlKv
*
)
taosArrayGet
(
elements
.
colArray
,
2
);
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
"cnch"
,
4
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
4
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_NCHAR
);
ASSERT_EQ
(
kv
->
length
,
8
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"ii=sd"
,
5
),
0
);
ASSERT_EQ
(
kv
->
length
,
9
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"ii
\\
=sd"
,
5
),
0
);
// bool
kv
=
(
SSmlKv
*
)
taosArrayGet
(
elements
.
colArray
,
3
);
...
...
source/common/src/tglobal.c
浏览文件 @
134c0528
...
...
@@ -198,7 +198,7 @@ int32_t tsTransPullupInterval = 2;
int32_t
tsMqRebalanceInterval
=
2
;
int32_t
tsStreamCheckpointTickInterval
=
1
;
int32_t
tsTtlUnit
=
86400
;
int32_t
tsTtlPushInterval
=
864
00
;
int32_t
tsTtlPushInterval
=
36
00
;
int32_t
tsGrantHBInterval
=
60
;
int32_t
tsUptimeInterval
=
300
;
// seconds
char
tsUdfdResFuncs
[
512
]
=
""
;
// udfd resident funcs that teardown when udfd exits
...
...
source/dnode/mgmt/node_mgmt/src/dmNodes.c
浏览文件 @
134c0528
...
...
@@ -132,11 +132,15 @@ int32_t dmRunDnode(SDnode *pDnode) {
int32_t
count
=
0
;
if
(
dmOpenNodes
(
pDnode
)
!=
0
)
{
dError
(
"failed to open nodes since %s"
,
terrstr
());
dmCloseNodes
(
pDnode
);
return
-
1
;
}
if
(
dmStartNodes
(
pDnode
)
!=
0
)
{
dError
(
"failed to start nodes since %s"
,
terrstr
());
dmSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
dmStopNodes
(
pDnode
);
dmCloseNodes
(
pDnode
);
return
-
1
;
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
134c0528
...
...
@@ -373,6 +373,8 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if
(
pCfg
->
sstTrigger
<
TSDB_MIN_STT_TRIGGER
||
pCfg
->
sstTrigger
>
TSDB_MAX_STT_TRIGGER
)
return
-
1
;
if
(
pCfg
->
hashPrefix
<
TSDB_MIN_HASH_PREFIX
||
pCfg
->
hashPrefix
>
TSDB_MAX_HASH_PREFIX
)
return
-
1
;
if
(
pCfg
->
hashSuffix
<
TSDB_MIN_HASH_SUFFIX
||
pCfg
->
hashSuffix
>
TSDB_MAX_HASH_SUFFIX
)
return
-
1
;
if
((
pCfg
->
hashSuffix
*
pCfg
->
hashPrefix
)
<
0
)
return
-
1
;
if
((
pCfg
->
hashPrefix
+
pCfg
->
hashSuffix
)
>=
(
TSDB_TABLE_NAME_LEN
-
1
))
return
-
1
;
if
(
pCfg
->
tsdbPageSize
<
TSDB_MIN_TSDB_PAGESIZE
||
pCfg
->
tsdbPageSize
>
TSDB_MAX_TSDB_PAGESIZE
)
return
-
1
;
if
(
taosArrayGetSize
(
pCfg
->
pRetensions
)
!=
pCfg
->
numOfRetensions
)
return
-
1
;
...
...
@@ -409,8 +411,6 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
walRollPeriod
<
0
)
pCfg
->
walRollPeriod
=
TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD
;
if
(
pCfg
->
walSegmentSize
<
0
)
pCfg
->
walSegmentSize
=
TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE
;
if
(
pCfg
->
sstTrigger
<=
0
)
pCfg
->
sstTrigger
=
TSDB_DEFAULT_SST_TRIGGER
;
if
(
pCfg
->
hashPrefix
<
0
)
pCfg
->
hashPrefix
=
TSDB_DEFAULT_HASH_PREFIX
;
if
(
pCfg
->
hashSuffix
<
0
)
pCfg
->
hashSuffix
=
TSDB_DEFAULT_HASH_SUFFIX
;
if
(
pCfg
->
tsdbPageSize
<=
0
)
pCfg
->
tsdbPageSize
=
TSDB_DEFAULT_TSDB_PAGESIZE
;
}
...
...
@@ -553,6 +553,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
int32_t
dbLen
=
strlen
(
dbObj
.
name
)
+
1
;
mInfo
(
"db:%s, hashPrefix adjust from %d to %d"
,
dbObj
.
name
,
dbObj
.
cfg
.
hashPrefix
,
dbObj
.
cfg
.
hashPrefix
+
dbLen
);
dbObj
.
cfg
.
hashPrefix
+=
dbLen
;
}
else
if
(
dbObj
.
cfg
.
hashPrefix
<
0
)
{
int32_t
dbLen
=
strlen
(
dbObj
.
name
)
+
1
;
mInfo
(
"db:%s, hashPrefix adjust from %d to %d"
,
dbObj
.
name
,
dbObj
.
cfg
.
hashPrefix
,
dbObj
.
cfg
.
hashPrefix
-
dbLen
);
dbObj
.
cfg
.
hashPrefix
-=
dbLen
;
}
SVgObj
*
pVgroups
=
NULL
;
...
...
@@ -1788,6 +1792,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
int16_t
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
if
(
hashPrefix
>
0
)
{
hashPrefix
=
pDb
->
cfg
.
hashPrefix
-
strlen
(
pDb
->
name
)
-
1
;
}
else
if
(
hashPrefix
<
0
)
{
hashPrefix
=
pDb
->
cfg
.
hashPrefix
+
strlen
(
pDb
->
name
)
+
1
;
}
colDataSetVal
(
pColInfo
,
rows
,
(
const
char
*
)
&
hashPrefix
,
false
);
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
134c0528
...
...
@@ -187,23 +187,24 @@ _err:
int32_t
metaSnapWrite
(
SMetaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
int32_t
line
=
0
;
SMeta
*
pMeta
=
pWriter
->
pMeta
;
SMetaEntry
metaEntry
=
{
0
};
SDecoder
*
pDecoder
=
&
(
SDecoder
){
0
};
tDecoderInit
(
pDecoder
,
pData
+
sizeof
(
SSnapDataHdr
),
nData
-
sizeof
(
SSnapDataHdr
));
code
=
metaDecodeEntry
(
pDecoder
,
&
metaEntry
);
if
(
code
)
goto
_err
;
VND_CHECK_CODE
(
code
,
line
,
_err
)
;
code
=
metaHandleEntry
(
pMeta
,
&
metaEntry
);
if
(
code
)
goto
_err
;
VND_CHECK_CODE
(
code
,
line
,
_err
)
;
tDecoderClear
(
pDecoder
);
return
code
;
_err:
tDecoderClear
(
pDecoder
);
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s
"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
)
);
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s
at line:%d"
,
TD_VID
(
pMeta
->
pVnode
),
terrstr
(),
line
);
return
code
;
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
134c0528
...
...
@@ -1029,7 +1029,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
metaTrace
(
"vgId:%d, start to save version:%"
PRId64
" uid:%"
PRId64
" ctime:%"
PRId64
,
TD_VID
(
pMeta
->
pVnode
),
pME
->
version
,
pME
->
uid
,
ctimeKey
.
ctime
);
return
tdbTb
In
sert
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
NULL
,
0
,
pMeta
->
txn
);
}
int
metaDeleteCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
@@ -1044,7 +1044,7 @@ int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
if
(
metaBuildNColIdxKey
(
&
ncolKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTb
In
sert
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
NULL
,
0
,
pMeta
->
txn
);
}
int
metaDeleteNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
@@ -1878,24 +1878,24 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
}
static
int
metaUpdateSuidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTb
In
sert
(
pMeta
->
pSuidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pSuidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
0
,
pMeta
->
txn
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTb
In
sert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
pMeta
->
txn
);
}
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STtlIdxKey
ttlKey
=
{
0
};
metaBuildTtlIdxKey
(
&
ttlKey
,
pME
);
if
(
ttlKey
.
dtime
==
0
)
return
0
;
return
tdbTb
In
sert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
pMeta
->
txn
);
}
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SCtbIdxKey
ctbIdxKey
=
{.
suid
=
pME
->
ctbEntry
.
suid
,
.
uid
=
pME
->
uid
};
return
tdbTb
In
sert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
pME
->
ctbEntry
.
pTags
,
return
tdbTb
Up
sert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
pME
->
ctbEntry
.
pTags
,
((
STag
*
)(
pME
->
ctbEntry
.
pTags
))
->
len
,
pMeta
->
txn
);
}
...
...
@@ -2065,49 +2065,66 @@ _exit:
}
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
int32_t
code
=
0
;
int32_t
line
=
0
;
metaWLock
(
pMeta
);
// save to table.db
if
(
metaSaveToTbDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaSaveToTbDb
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update uid.idx
if
(
metaUpdateUidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateUidIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update name.idx
if
(
metaUpdateNameIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateNameIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
// update ctb.idx
if
(
metaUpdateCtbIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateCtbIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update tag.idx
if
(
metaUpdateTagIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateTagIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
else
{
// update schema.db
if
(
metaSaveToSkmDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaSaveToSkmDb
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateSuidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateSuidIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
}
if
(
metaUpdateCtimeIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateCtimeIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
metaUpdateNcolIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateNcolIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateTtlIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
metaULock
(
pMeta
);
metaDebug
(
"vgId:%d, handle meta entry, ver:%"
PRId64
", uid:%"
PRId64
", name:%s"
,
TD_VID
(
pMeta
->
pVnode
),
pME
->
version
,
pME
->
uid
,
pME
->
name
);
return
0
;
_err:
metaULock
(
pMeta
);
metaError
(
"vgId:%d, failed to handle meta entry since %s at line:%d, ver:%"
PRId64
", uid:%"
PRId64
", name:%s"
,
TD_VID
(
pMeta
->
pVnode
),
terrstr
(),
line
,
pME
->
version
,
pME
->
uid
,
pME
->
name
);
return
-
1
;
}
// refactor later
void
*
metaGetIdx
(
SMeta
*
pMeta
)
{
return
pMeta
->
pTagIdx
;
}
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
)
{
return
pMeta
->
pTagIvtIdx
;
}
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
134c0528
...
...
@@ -1348,6 +1348,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
code
=
terrno
;
goto
_exit
;
}
terrno
=
0
;
pSubmitTbData
->
uid
=
pSubmitTbData
->
pCreateTbReq
->
uid
;
// update uid if table exist for using below
}
}
...
...
source/libs/command/src/command.c
浏览文件 @
134c0528
...
...
@@ -278,7 +278,12 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
char
*
retentions
=
buildRetension
(
pCfg
->
pRetensions
);
int32_t
dbFNameLen
=
strlen
(
dbFName
);
int32_t
hashPrefix
=
(
pCfg
->
hashPrefix
>
(
dbFNameLen
+
1
))
?
(
pCfg
->
hashPrefix
-
dbFNameLen
-
1
)
:
0
;
int32_t
hashPrefix
=
0
;
if
(
pCfg
->
hashPrefix
>
0
)
{
hashPrefix
=
pCfg
->
hashPrefix
-
dbFNameLen
-
1
;
}
else
if
(
pCfg
->
hashPrefix
<
0
)
{
hashPrefix
=
pCfg
->
hashPrefix
+
dbFNameLen
+
1
;
}
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
...
...
source/libs/executor/src/executor.c
浏览文件 @
134c0528
...
...
@@ -1108,6 +1108,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
pScanBaseInfo
->
dataReader
=
NULL
;
// let's seek to the next version in wal file
int64_t
firstVer
=
walGetFirstVer
(
pInfo
->
tqReader
->
pWalReader
->
pWal
);
if
(
pOffset
->
version
+
1
<
firstVer
){
pOffset
->
version
=
firstVer
-
1
;
}
if
(
tqSeekVer
(
pInfo
->
tqReader
,
pOffset
->
version
+
1
,
id
)
<
0
)
{
qError
(
"tqSeekVer failed ver:%"
PRId64
", %s"
,
pOffset
->
version
+
1
,
id
);
return
-
1
;
...
...
source/libs/executor/src/sysscanoperator.c
浏览文件 @
134c0528
...
...
@@ -1482,11 +1482,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
pInfo
->
pIdx
->
init
=
1
;
SSDataBlock
*
blk
=
sysTableBuildUserTablesByUids
(
pOperator
);
return
blk
;
}
else
if
(
flt
==
-
2
)
{
qDebug
(
"%s failed to get sys table info by idx, empty result"
,
GET_TASKID
(
pTaskInfo
));
return
NULL
;
}
else
if
(
flt
==
-
1
)
{
// not idx
}
else
if
((
flt
==
-
1
)
||
(
flt
==
-
2
))
{
qDebug
(
"%s failed to get sys table info by idx, scan sys table one by one"
,
GET_TASKID
(
pTaskInfo
));
}
}
else
if
(
pCondition
!=
NULL
&&
(
pInfo
->
pIdx
!=
NULL
&&
pInfo
->
pIdx
->
init
==
1
))
{
...
...
source/libs/function/CMakeLists.txt
浏览文件 @
134c0528
...
...
@@ -79,6 +79,26 @@ ENDIF ()
target_link_libraries
(
udf1 PUBLIC os
${
LINK_JEMALLOC
}
)
add_library
(
udf1_dup STATIC MODULE test/udf1_dup.c
)
target_include_directories
(
udf1_dup
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/function"
"
${
TD_SOURCE_DIR
}
/include/util"
"
${
TD_SOURCE_DIR
}
/include/common"
"
${
TD_SOURCE_DIR
}
/include/client"
"
${
TD_SOURCE_DIR
}
/include/os"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
IF
(
TD_LINUX_64 AND JEMALLOC_ENABLED
)
ADD_DEPENDENCIES
(
udf1_dup jemalloc
)
ENDIF
()
target_link_libraries
(
udf1_dup PUBLIC os
${
LINK_JEMALLOC
}
)
add_library
(
udf2 STATIC MODULE test/udf2.c
)
target_include_directories
(
udf2
...
...
@@ -99,6 +119,26 @@ target_link_libraries(
udf2 PUBLIC os
${
LINK_JEMALLOC
}
)
add_library
(
udf2_dup STATIC MODULE test/udf2_dup.c
)
target_include_directories
(
udf2_dup
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/function"
"
${
TD_SOURCE_DIR
}
/include/util"
"
${
TD_SOURCE_DIR
}
/include/common"
"
${
TD_SOURCE_DIR
}
/include/client"
"
${
TD_SOURCE_DIR
}
/include/os"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
IF
(
TD_LINUX_64 AND JEMALLOC_ENABLED
)
ADD_DEPENDENCIES
(
udf2_dup jemalloc
)
ENDIF
()
target_link_libraries
(
udf2_dup PUBLIC os
${
LINK_JEMALLOC
}
)
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
add_executable
(
udfd src/udfd.c
)
target_include_directories
(
...
...
source/libs/function/test/udf1_dup.c
0 → 100644
浏览文件 @
134c0528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef LINUX
#include <unistd.h>
#endif
#ifdef WINDOWS
#include <windows.h>
#endif
#include "taosudf.h"
DLL_EXPORT
int32_t
udf1_dup_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_dup_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_dup
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
SUdfColumnData
*
resultData
=
&
resultCol
->
colData
;
for
(
int32_t
i
=
0
;
i
<
block
->
numOfRows
;
++
i
)
{
int
j
=
0
;
for
(;
j
<
block
->
numOfCols
;
++
j
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
j
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
break
;
}
}
if
(
j
==
block
->
numOfCols
)
{
int32_t
luckyNum
=
2
;
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
}
}
// to simulate actual processing delay by udf
#ifdef LINUX
usleep
(
1
*
1000
);
// usleep takes sleep time in us (1 millionth of a second)
#endif
#ifdef WINDOWS
Sleep
(
1
);
#endif
resultData
->
numOfRows
=
block
->
numOfRows
;
return
0
;
}
source/libs/function/test/udf2_dup.c
0 → 100644
浏览文件 @
134c0528
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "taosudf.h"
DLL_EXPORT
int32_t
udf2_dup_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_dup_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_dup_start
(
SUdfInterBuf
*
buf
)
{
*
(
int64_t
*
)(
buf
->
buf
)
=
0
;
buf
->
bufLen
=
sizeof
(
double
);
buf
->
numOfResult
=
1
;
return
0
;
}
DLL_EXPORT
int32_t
udf2_dup
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
double
sumSquares
=
0
;
if
(
interBuf
->
numOfResult
==
1
)
{
sumSquares
=
*
(
double
*
)
interBuf
->
buf
;
}
int8_t
numNotNull
=
0
;
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
||
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_DOUBLE
))
{
return
TSDB_CODE_UDF_INVALID_INPUT
;
}
}
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
block
->
numOfRows
;
++
j
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
if
(
udfColDataIsNull
(
col
,
j
))
{
continue
;
}
switch
(
col
->
colMeta
.
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
char
*
cell
=
udfColDataGetData
(
col
,
j
);
int32_t
num
=
*
(
int32_t
*
)
cell
;
sumSquares
+=
(
double
)
num
*
num
;
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
char
*
cell
=
udfColDataGetData
(
col
,
j
);
double
num
=
*
(
double
*
)
cell
;
sumSquares
+=
num
*
num
;
break
;
}
default:
break
;
}
++
numNotNull
;
}
}
*
(
double
*
)(
newInterBuf
->
buf
)
=
sumSquares
;
newInterBuf
->
bufLen
=
sizeof
(
double
);
if
(
interBuf
->
numOfResult
==
0
&&
numNotNull
==
0
)
{
newInterBuf
->
numOfResult
=
0
;
}
else
{
newInterBuf
->
numOfResult
=
1
;
}
return
0
;
}
DLL_EXPORT
int32_t
udf2_dup_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
if
(
buf
->
numOfResult
==
0
)
{
resultData
->
numOfResult
=
0
;
return
0
;
}
double
sumSquares
=
*
(
double
*
)(
buf
->
buf
);
*
(
double
*
)(
resultData
->
buf
)
=
sqrt
(
sumSquares
)
+
100
;
resultData
->
bufLen
=
sizeof
(
double
);
resultData
->
numOfResult
=
1
;
return
0
;
}
source/libs/index/src/indexFilter.c
浏览文件 @
134c0528
...
...
@@ -221,6 +221,71 @@ static FORCE_INLINE int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCt
param
->
status
=
SFLT_COARSE_INDEX
;
return
0
;
}
static
int32_t
sifNeedConvertCond
(
SNode
*
l
,
SNode
*
r
)
{
if
(
nodeType
(
l
)
!=
QUERY_NODE_COLUMN
||
nodeType
(
r
)
!=
QUERY_NODE_VALUE
)
{
return
0
;
}
SColumnNode
*
c
=
(
SColumnNode
*
)
l
;
SValueNode
*
v
=
(
SValueNode
*
)
r
;
int32_t
ctype
=
c
->
node
.
resType
.
type
;
int32_t
vtype
=
v
->
node
.
resType
.
type
;
if
(
!
IS_VAR_DATA_TYPE
(
ctype
)
&&
IS_VAR_DATA_TYPE
(
vtype
))
{
return
1
;
}
return
0
;
}
static
int32_t
sifInitParamValByCol
(
SNode
*
r
,
SNode
*
l
,
SIFParam
*
param
,
SIFCtx
*
ctx
)
{
param
->
status
=
SFLT_COARSE_INDEX
;
SColumnNode
*
cn
=
(
SColumnNode
*
)
r
;
SValueNode
*
vn
=
(
SValueNode
*
)
l
;
if
(
vn
->
typeData
==
TSDB_DATA_TYPE_NULL
&&
(
vn
->
literal
==
NULL
||
strlen
(
vn
->
literal
)
==
0
))
{
param
->
status
=
SFLT_NOT_INDEX
;
return
0
;
}
SDataType
*
pType
=
&
cn
->
node
.
resType
;
int32_t
type
=
pType
->
type
;
SDataType
*
pVType
=
&
vn
->
node
.
resType
;
int32_t
vtype
=
pVType
->
type
;
char
*
pData
=
nodesGetValueFromNode
(
vn
);
int32_t
valLen
=
0
;
char
**
value
=
&
param
->
condValue
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
int32_t
dataLen
=
varDataTLen
(
pData
);
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
*
pData
==
TSDB_DATA_TYPE_NULL
)
{
dataLen
=
0
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_NCHAR
)
{
dataLen
=
varDataTLen
(
pData
);
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_DOUBLE
)
{
dataLen
=
LONG_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
;
}
dataLen
+=
CHAR_BYTES
;
}
valLen
=
dataLen
;
}
else
{
valLen
=
pType
->
bytes
;
}
char
*
tv
=
taosMemoryCalloc
(
1
,
valLen
+
1
);
if
(
tv
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
memcpy
(
tv
,
pData
,
valLen
);
*
value
=
tv
;
param
->
colId
=
-
1
;
param
->
colValType
=
(
uint8_t
)(
vn
->
node
.
resType
.
type
);
if
(
vn
->
literal
!=
NULL
&&
strlen
(
vn
->
literal
)
<=
sizeof
(
param
->
colName
))
{
memcpy
(
param
->
colName
,
vn
->
literal
,
strlen
(
vn
->
literal
));
}
else
{
param
->
status
=
SFLT_NOT_INDEX
;
}
return
0
;
}
static
int32_t
sifInitParam
(
SNode
*
node
,
SIFParam
*
param
,
SIFCtx
*
ctx
)
{
param
->
status
=
SFLT_COARSE_INDEX
;
switch
(
nodeType
(
node
))
{
...
...
@@ -317,8 +382,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
return
TSDB_CODE_SUCCESS
;
}
else
{
SIF_ERR_JRET
(
sifInitParam
(
node
->
pLeft
,
&
paramList
[
0
],
ctx
));
if
(
nParam
>
1
)
{
// if (sifNeedConvertCond(node->pLeft, node->pRight)) {
// SIF_ERR_JRET(sifInitParamValByCol(node->pLeft, node->pRight, ¶mList[1], ctx));
// } else {
SIF_ERR_JRET
(
sifInitParam
(
node
->
pRight
,
&
paramList
[
1
],
ctx
));
// }
// if (paramList[0].colValType == TSDB_DATA_TYPE_JSON &&
// ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) {
// return TSDB_CODE_OUT_OF_MEMORY;
...
...
@@ -404,60 +474,149 @@ static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reve
}
return
NULL
;
}
int32_t
sifStr2Num
(
char
*
buf
,
int32_t
len
,
int8_t
type
,
void
*
val
)
{
// signed/unsigned/float
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
int64_t
v
=
0
;
if
(
0
!=
toInteger
(
buf
,
len
,
10
,
&
v
))
{
return
-
1
;
}
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
*
(
int64_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
*
(
int32_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_TINYINT
)
{
*
(
int8_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_SMALLINT
)
{
*
(
int16_t
*
)
val
=
v
;
}
}
else
if
(
IS_FLOAT_TYPE
(
type
))
{
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
*
(
float
*
)
val
=
taosStr2Float
(
buf
,
NULL
);
}
else
{
*
(
double
*
)
val
=
taosStr2Double
(
buf
,
NULL
);
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
v
=
0
;
if
(
0
!=
toUInteger
(
buf
,
len
,
10
,
&
v
))
{
return
-
1
;
}
if
(
type
==
TSDB_DATA_TYPE_UBIGINT
)
{
*
(
uint64_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_UINT
)
{
*
(
uint32_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_UTINYINT
)
{
*
(
uint8_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_USMALLINT
)
{
*
(
uint16_t
*
)
val
=
v
;
}
}
else
{
return
-
1
;
}
return
0
;
}
static
void
sifSetFltParam
(
SIFParam
*
left
,
SIFParam
*
right
,
SDataTypeBuf
*
typedata
,
SMetaFltParam
*
param
)
{
int8_t
ltype
=
left
->
colValType
,
rtype
=
right
->
colValType
;
static
int32_t
sifSetFltParam
(
SIFParam
*
left
,
SIFParam
*
right
,
SDataTypeBuf
*
typedata
,
SMetaFltParam
*
param
)
{
int32_t
code
=
0
;
int8_t
ltype
=
left
->
colValType
,
rtype
=
right
->
colValType
;
if
(
!
IS_NUMERIC_TYPE
(
ltype
)
||
!
((
IS_NUMERIC_TYPE
(
rtype
))
||
rtype
==
TSDB_DATA_TYPE_VARCHAR
))
{
return
-
1
;
}
if
(
ltype
==
TSDB_DATA_TYPE_FLOAT
)
{
float
f
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
f
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
f
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_FLOAT
,
&
f
));
}
typedata
->
f
=
f
;
param
->
val
=
&
typedata
->
f
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
d
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
d
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
d
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_DOUBLE
,
&
d
));
}
typedata
->
d
=
d
;
param
->
val
=
&
typedata
->
d
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
i64
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i64
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i64
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_BIGINT
,
&
i64
));
}
typedata
->
i64
=
i64
;
param
->
val
=
&
typedata
->
i64
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_INT
)
{
int32_t
i32
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i32
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i32
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_INT
,
&
i32
));
}
typedata
->
i32
=
i32
;
param
->
val
=
&
typedata
->
i32
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_SMALLINT
)
{
int16_t
i16
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i16
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i16
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_SMALLINT
,
&
i16
));
}
typedata
->
i16
=
i16
;
param
->
val
=
&
typedata
->
i16
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_TINYINT
)
{
int8_t
i8
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i8
)
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i8
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_TINYINT
,
&
i8
));
}
typedata
->
i8
=
i8
;
param
->
val
=
&
typedata
->
i8
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UBIGINT
)
{
uint64_t
u64
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u64
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u64
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UBIGINT
,
&
u64
));
}
typedata
->
u64
=
u64
;
param
->
val
=
&
typedata
->
u64
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UINT
)
{
uint32_t
u32
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u32
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u32
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UINT
,
&
u32
));
}
typedata
->
u32
=
u32
;
param
->
val
=
&
typedata
->
u32
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_USMALLINT
)
{
uint16_t
u16
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u16
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u16
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_USMALLINT
,
&
u16
));
}
typedata
->
u16
=
u16
;
param
->
val
=
&
typedata
->
u16
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UTINYINT
)
{
uint8_t
u8
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u8
);
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u8
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UTINYINT
,
&
u8
));
}
typedata
->
u8
=
u8
;
param
->
val
=
&
typedata
->
u8
;
}
return
0
;
}
static
int32_t
sifDoIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
int
ret
=
0
;
...
...
@@ -498,7 +657,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
param
.
val
=
buf
;
}
}
else
{
sifSetFltParam
(
left
,
right
,
&
typedata
,
&
param
)
;
if
(
sifSetFltParam
(
left
,
right
,
&
typedata
,
&
param
)
!=
0
)
return
-
1
;
}
ret
=
metaFilterTableIds
(
arg
->
metaEx
,
&
param
,
output
->
result
);
}
...
...
source/libs/parser/inc/sql.y
100644 → 100755
浏览文件 @
134c0528
...
...
@@ -221,8 +221,8 @@ db_options(A) ::= db_options(B) WAL_RETENTION_SIZE NK_MINUS(D) NK_INTEGER(C).
db_options(A) ::= db_options(B) WAL_ROLL_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_ROLL_PERIOD, &C); }
db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_SEGMENT_SIZE, &C); }
db_options(A) ::= db_options(B) STT_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STT_TRIGGER, &C); }
db_options(A) ::= db_options(B) TABLE_PREFIX
NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, &
C); }
db_options(A) ::= db_options(B) TABLE_SUFFIX
NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, &
C); }
db_options(A) ::= db_options(B) TABLE_PREFIX
signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX,
C); }
db_options(A) ::= db_options(B) TABLE_SUFFIX
signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX,
C); }
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
134c0528
...
...
@@ -1024,12 +1024,28 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
case
DB_OPTION_STT_TRIGGER
:
pDbOptions
->
sstTrigger
=
taosStr2Int32
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
case
DB_OPTION_TABLE_PREFIX
:
pDbOptions
->
tablePrefix
=
taosStr2Int32
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
case
DB_OPTION_TABLE_PREFIX
:
{
SValueNode
*
pNode
=
(
SValueNode
*
)
pVal
;
if
(
TSDB_DATA_TYPE_BIGINT
==
pNode
->
node
.
resType
.
type
||
TSDB_DATA_TYPE_UBIGINT
==
pNode
->
node
.
resType
.
type
)
{
pDbOptions
->
tablePrefix
=
taosStr2Int32
(
pNode
->
literal
,
NULL
,
10
);
}
else
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid table_prefix data type"
);
pCxt
->
errCode
=
TSDB_CODE_PAR_SYNTAX_ERROR
;
}
nodesDestroyNode
((
SNode
*
)
pNode
);
break
;
case
DB_OPTION_TABLE_SUFFIX
:
pDbOptions
->
tableSuffix
=
taosStr2Int32
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
}
case
DB_OPTION_TABLE_SUFFIX
:{
SValueNode
*
pNode
=
(
SValueNode
*
)
pVal
;
if
(
TSDB_DATA_TYPE_BIGINT
==
pNode
->
node
.
resType
.
type
||
TSDB_DATA_TYPE_UBIGINT
==
pNode
->
node
.
resType
.
type
)
{
pDbOptions
->
tableSuffix
=
taosStr2Int32
(
pNode
->
literal
,
NULL
,
10
);
}
else
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid table_suffix data type"
);
pCxt
->
errCode
=
TSDB_CODE_PAR_SYNTAX_ERROR
;
}
nodesDestroyNode
((
SNode
*
)
pNode
);
break
;
}
default:
break
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
134c0528
...
...
@@ -4177,6 +4177,34 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkDbTbPrefixSuffixOptions
(
STranslateContext
*
pCxt
,
int32_t
tbPrefix
,
int32_t
tbSuffix
)
{
if
(
tbPrefix
<
TSDB_MIN_HASH_PREFIX
||
tbPrefix
>
TSDB_MAX_HASH_PREFIX
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DB_OPTION
,
"Invalid option table_prefix: %d valid range: [%d, %d]"
,
tbPrefix
,
TSDB_MIN_HASH_PREFIX
,
TSDB_MAX_HASH_PREFIX
);
}
if
(
tbSuffix
<
TSDB_MIN_HASH_SUFFIX
||
tbSuffix
>
TSDB_MAX_HASH_SUFFIX
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DB_OPTION
,
"Invalid option table_suffix: %d valid range: [%d, %d]"
,
tbSuffix
,
TSDB_MIN_HASH_SUFFIX
,
TSDB_MAX_HASH_SUFFIX
);
}
if
((
tbPrefix
*
tbSuffix
)
<
0
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DB_OPTION
,
"Invalid option table_prefix & table_suffix: mixed usage not allowed"
);
}
if
((
tbPrefix
+
tbSuffix
)
>=
(
TSDB_TABLE_NAME_LEN
-
1
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DB_OPTION
,
"Invalid option table_prefix & table_suffix: exceed max table name length"
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkOptionsDependency
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDatabaseOptions
*
pOptions
)
{
int32_t
daysPerFile
=
pOptions
->
daysPerFile
;
int64_t
daysToKeep0
=
pOptions
->
keep
[
0
];
...
...
@@ -4284,10 +4312,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
code
=
checkDbRangeOption
(
pCxt
,
"sstTrigger"
,
pOptions
->
sstTrigger
,
TSDB_MIN_STT_TRIGGER
,
TSDB_MAX_STT_TRIGGER
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbRangeOption
(
pCxt
,
"tablePrefix"
,
pOptions
->
tablePrefix
,
TSDB_MIN_HASH_PREFIX
,
TSDB_MAX_HASH_PREFIX
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbRangeOption
(
pCxt
,
"tableSuffix"
,
pOptions
->
tableSuffix
,
TSDB_MIN_HASH_SUFFIX
,
TSDB_MAX_HASH_SUFFIX
);
code
=
checkDbTbPrefixSuffixOptions
(
pCxt
,
pOptions
->
tablePrefix
,
pOptions
->
tableSuffix
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkOptionsDependency
(
pCxt
,
pDbName
,
pOptions
);
...
...
source/libs/parser/src/sql.c
浏览文件 @
134c0528
此差异已折叠。
点击以展开。
source/libs/planner/src/planOptimizer.c
浏览文件 @
134c0528
...
...
@@ -2526,7 +2526,7 @@ static bool tbCntScanOptIsEligibleAggFuncs(SNodeList* pAggFuncs) {
return
false
;
}
}
return
true
;
return
LIST_LENGTH
(
pAggFuncs
)
>
0
;
}
static
bool
tbCntScanOptIsEligibleAgg
(
SAggLogicNode
*
pAgg
)
{
...
...
source/os/src/osLocale.c
浏览文件 @
134c0528
...
...
@@ -171,7 +171,7 @@ void taosGetSystemLocale(char *outLocale, char *outCharset) {
strcpy
(
outLocale
,
"en_US.UTF-8"
);
}
else
{
tstrncpy
(
outLocale
,
locale
,
TD_LOCALE_LEN
);
// printf("locale not configured, set to system default:%s
", outLocale);
printf
(
"locale not configured, set to system default:%s
\n
"
,
outLocale
);
}
// if user does not specify the charset, extract it from locale
...
...
tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json
浏览文件 @
134c0528
...
...
@@ -11,6 +11,7 @@
"confirm_parameter_prompt"
:
"no"
,
"prepared_rand"
:
100
,
"chinese"
:
"no"
,
"escape_character"
:
"yes"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
10
,
"databases"
:
[{
...
...
@@ -29,7 +30,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
@@ -54,7 +54,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb3-2_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json
浏览文件 @
134c0528
...
...
@@ -11,6 +11,7 @@
"confirm_parameter_prompt"
:
"no"
,
"prepared_rand"
:
100
,
"chinese"
:
"no"
,
"escape_character"
:
"yes"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
10
,
"databases"
:
[{
...
...
@@ -29,7 +30,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
@@ -54,7 +54,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb4-2_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json
浏览文件 @
134c0528
...
...
@@ -11,6 +11,7 @@
"confirm_parameter_prompt"
:
"no"
,
"prepared_rand"
:
100
,
"chinese"
:
"no"
,
"escape_character"
:
"yes"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
10
,
"databases"
:
[{
...
...
@@ -29,7 +30,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
@@ -54,7 +54,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb2-2_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
tests/develop-test/5-taos-tools/taosbenchmark/json/taosc_auto_create_table.json
浏览文件 @
134c0528
...
...
@@ -11,6 +11,7 @@
"confirm_parameter_prompt"
:
"no"
,
"prepared_rand"
:
100
,
"chinese"
:
"no"
,
"escape_character"
:
"yes"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
10
,
"databases"
:
[{
...
...
@@ -29,7 +30,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
@@ -55,7 +55,6 @@
"child_table_exists"
:
"no"
,
"childtable_count"
:
8
,
"childtable_prefix"
:
"stb1-2_"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"yes"
,
"batch_create_tbl_num"
:
10
,
"data_source"
:
"rand"
,
...
...
tests/parallel_test/cases.task
浏览文件 @
134c0528
...
...
@@ -746,6 +746,7 @@
,,y,script,./test.sh -f tsim/db/show_create_table.sim
,,y,script,./test.sh -f tsim/db/tables.sim
,,y,script,./test.sh -f tsim/db/taosdlog.sim
,,y,script,./test.sh -f tsim/db/table_prefix_suffix.sim
,,y,script,./test.sh -f tsim/dnode/balance_replica1.sim
,,y,script,./test.sh -f tsim/dnode/balance_replica3.sim
,,y,script,./test.sh -f tsim/dnode/balance1.sim
...
...
tests/script/tsim/db/table_prefix_suffix.sim
0 → 100644
浏览文件 @
134c0528
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql drop database if exists db1;
sql create database db1 vgroups 5 TABLE_PREFIX 1 TABLE_SUFFIX 2;
sql use db1;
sql create table atb1aa (ts timestamp, f1 int);
sql create table btb1bb (ts timestamp, f1 int);
sql create table ctb1cc (ts timestamp, f1 int);
sql create table dtb1dd (ts timestamp, f1 int);
sql create table atb2aa (ts timestamp, f1 int);
sql create table btb2bb (ts timestamp, f1 int);
sql create table ctb2cc (ts timestamp, f1 int);
sql create table dtb2dd (ts timestamp, f1 int);
sql create table etb2ee (ts timestamp, f1 int);
sql show create database db1;
sql select count(*) a from information_schema.ins_tables where db_name='db1' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db1;
sql drop database if exists db2;
sql create database db2 vgroups 5 TABLE_PREFIX -1 TABLE_SUFFIX -2;
sql use db2;
sql create table taaa11 (ts timestamp, f1 int);
sql create table tbbb11 (ts timestamp, f1 int);
sql create table tccc11 (ts timestamp, f1 int);
sql create table tddd11 (ts timestamp, f1 int);
sql create table taaa22 (ts timestamp, f1 int);
sql create table tbbb22 (ts timestamp, f1 int);
sql create table tccc22 (ts timestamp, f1 int);
sql create table tddd22 (ts timestamp, f1 int);
sql create table teee22 (ts timestamp, f1 int);
sql show create database db2;
sql select count(*) a from information_schema.ins_tables where db_name='db2' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db2;
sql drop database if exists db3;
sql create database db3 vgroups 5 TABLE_PREFIX -1;
sql use db3;
sql create table taaa11 (ts timestamp, f1 int);
sql create table tbbb11 (ts timestamp, f1 int);
sql create table tccc11 (ts timestamp, f1 int);
sql create table tddd11 (ts timestamp, f1 int);
sql create table zaaa22 (ts timestamp, f1 int);
sql create table zbbb22 (ts timestamp, f1 int);
sql create table zccc22 (ts timestamp, f1 int);
sql create table zddd22 (ts timestamp, f1 int);
sql create table zeee22 (ts timestamp, f1 int);
sql show create database db3;
sql select count(*) a from information_schema.ins_tables where db_name='db3' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db3;
sql drop database if exists db4;
sql create database db4 vgroups 5 TABLE_SUFFIX -2;
sql use db4;
sql create table taaa11 (ts timestamp, f1 int);
sql create table tbbb11 (ts timestamp, f1 int);
sql create table tccc11 (ts timestamp, f1 int);
sql create table tddd11 (ts timestamp, f1 int);
sql create table zaaa22 (ts timestamp, f1 int);
sql create table zbbb22 (ts timestamp, f1 int);
sql create table zccc22 (ts timestamp, f1 int);
sql create table zddd22 (ts timestamp, f1 int);
sql create table zeee22 (ts timestamp, f1 int);
sql show create database db4;
sql select count(*) a from information_schema.ins_tables where db_name='db4' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db4;
sql drop database if exists db5;
sql create database db5 vgroups 5 TABLE_PREFIX 1;
sql use db5;
sql create table taaa11 (ts timestamp, f1 int);
sql create table baaa11 (ts timestamp, f1 int);
sql create table caaa11 (ts timestamp, f1 int);
sql create table daaa11 (ts timestamp, f1 int);
sql create table faaa11 (ts timestamp, f1 int);
sql create table gbbb11 (ts timestamp, f1 int);
sql create table hbbb11 (ts timestamp, f1 int);
sql create table ibbb11 (ts timestamp, f1 int);
sql create table jbbb11 (ts timestamp, f1 int);
sql show create database db5;
sql select count(*) a from information_schema.ins_tables where db_name='db5' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db5;
sql drop database if exists db6;
sql create database db6 vgroups 5 TABLE_SUFFIX 2;
sql use db6;
sql create table taaa11 (ts timestamp, f1 int);
sql create table taaa12 (ts timestamp, f1 int);
sql create table taaa13 (ts timestamp, f1 int);
sql create table taaa14 (ts timestamp, f1 int);
sql create table tbbb23 (ts timestamp, f1 int);
sql create table tbbb24 (ts timestamp, f1 int);
sql create table tbbb31 (ts timestamp, f1 int);
sql create table tbbb32 (ts timestamp, f1 int);
sql create table tbbb33 (ts timestamp, f1 int);
sql show create database db6;
sql select count(*) a from information_schema.ins_tables where db_name='db6' group by vgroup_id having(count(*) > 0) order by a;
if $rows != 2 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql drop database if exists db6;
sql drop database if exists db7;
sql create database db7 vgroups 5 TABLE_PREFIX -100 TABLE_SUFFIX -92;
sql use db7;
sql create table taaa11 (ts timestamp, f1 int);
sql create table taaa12 (ts timestamp, f1 int);
sql create table taaa13 (ts timestamp, f1 int);
sql create table tbbb21 (ts timestamp, f1 int);
sql create table tbbb22 (ts timestamp, f1 int);
sql create table tbbb23 (ts timestamp, f1 int);
sql create table tbbb24 (ts timestamp, f1 int);
sql create table tccc31 (ts timestamp, f1 int);
sql create table tccc32 (ts timestamp, f1 int);
sql create table tccc33 (ts timestamp, f1 int);
sql create table tddd24 (ts timestamp, f1 int);
sql create table tddd31 (ts timestamp, f1 int);
sql create table tddd32 (ts timestamp, f1 int);
sql create table tddd33 (ts timestamp, f1 int);
sql show create database db7;
sql select count(*) a from information_schema.ins_tables where db_name='db7' group by vgroup_id having(count(*) > 0) order by a;
sql drop database if exists db7;
sql_error create database db8 vgroups 5 TABLE_PREFIX -1 TABLE_SUFFIX 2;
sql_error create database db8 vgroups 5 TABLE_PREFIX 191 TABLE_SUFFIX 192;
sql_error create database db8 vgroups 5 TABLE_PREFIX -192 TABLE_SUFFIX -191;
sql_error create database db8 vgroups 5 TABLE_PREFIX 100 TABLE_SUFFIX 92;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/query/sys_tbname.sim
浏览文件 @
134c0528
...
...
@@ -109,5 +109,26 @@ if $rows != 5000 then
return -1
endi
sql create database d1;
sql create stable d1.st1 (ts timestamp, f int) tags(t int);
sql create stable d1.st2 (ts timestamp, f int) tags(t int);
sql create table d1.ct1 using d1.st1 tags(1);
sql create table d1.ct2 using d1.st2 tags(2);
sql create database d2;
sql create stable d2.st1(ts timestamp, f int) tags(t int);
sql create stable d2.st2(ts timestamp, f int) tags(t int);
sql create table d2.ct1 using d2.st1 tags(1);
sql create table d2.ct2 using d2.st2 tags(2);
sql create database d3;
sql create stable d3.st1(ts timestamp, f int) tags(t int);
sql create stable d3.st2(ts timestamp, f int) tags(t int);
sql create table d3.ct1 using d3.st1 tags(1);
sql create table d3.ct2 using d3.st2 tags(2);
sql select count(*), stable_name, db_name from information_schema.ins_tables where db_name != 'd2' group by stable_name,db_name
print $rows
if $rows != 9 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/query/tableCount.sim
浏览文件 @
134c0528
...
...
@@ -104,4 +104,9 @@ if $data62 != 5 then
return -1
endi
sql select distinct db_name from information_schema.ins_tables;
print $rows
if $rows != 4 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tag/bigint.sim
浏览文件 @
134c0528
...
...
@@ -123,6 +123,17 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/double.sim
浏览文件 @
134c0528
...
...
@@ -123,6 +123,15 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1';
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1.0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/float.sim
浏览文件 @
134c0528
...
...
@@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1.0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/int.sim
浏览文件 @
134c0528
...
...
@@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1";
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/int_float.sim
浏览文件 @
134c0528
...
...
@@ -85,10 +85,22 @@ sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/tinyint.sim
浏览文件 @
134c0528
...
...
@@ -115,14 +115,36 @@ sql select * from $mt where tgcol = 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '0'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/system-test/0-others/udf_create.py
浏览文件 @
134c0528
...
...
@@ -47,17 +47,27 @@ class TDTestCase:
if
platform
.
system
().
lower
()
==
'windows'
:
self
.
libudf1
=
subprocess
.
Popen
(
'(for /r %s %%i in ("udf1.d*") do @echo %%i)|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf1_dup
=
subprocess
.
Popen
(
'(for /r %s %%i in ("udf1_dup.d*") do @echo %%i)|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf2
=
subprocess
.
Popen
(
'(for /r %s %%i in ("udf2.d*") do @echo %%i)|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf2_dup
=
subprocess
.
Popen
(
'(for /r %s %%i in ("udf2_dup.d*") do @echo %%i)|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
if
(
not
tdDnodes
.
dnodes
[
0
].
remoteIP
==
""
):
tdDnodes
.
dnodes
[
0
].
remote_conn
.
get
(
tdDnodes
.
dnodes
[
0
].
config
[
"path"
]
+
'/debug/build/lib/libudf1.so'
,
projPath
+
"
\\
debug
\\
build
\\
lib
\\
"
)
tdDnodes
.
dnodes
[
0
].
remote_conn
.
get
(
tdDnodes
.
dnodes
[
0
].
config
[
"path"
]
+
'/debug/build/lib/libudf1_dup.so'
,
projPath
+
"
\\
debug
\\
build
\\
lib
\\
"
)
tdDnodes
.
dnodes
[
0
].
remote_conn
.
get
(
tdDnodes
.
dnodes
[
0
].
config
[
"path"
]
+
'/debug/build/lib/libudf2.so'
,
projPath
+
"
\\
debug
\\
build
\\
lib
\\
"
)
tdDnodes
.
dnodes
[
0
].
remote_conn
.
get
(
tdDnodes
.
dnodes
[
0
].
config
[
"path"
]
+
'/debug/build/lib/libudf2_dup.so'
,
projPath
+
"
\\
debug
\\
build
\\
lib
\\
"
)
self
.
libudf1
=
self
.
libudf1
.
replace
(
'udf1.dll'
,
'libudf1.so'
)
self
.
libudf1_dup
=
self
.
libudf1_dup
.
replace
(
'udf1_dup.dll'
,
'libudf1_dup.so'
)
self
.
libudf2
=
self
.
libudf2
.
replace
(
'udf2.dll'
,
'libudf2.so'
)
self
.
libudf2_dup
=
self
.
libudf2_dup
.
replace
(
'udf2_dup.dll'
,
'libudf2_dup.so'
)
else
:
self
.
libudf1
=
subprocess
.
Popen
(
'find %s -name "libudf1.so"|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf1_dup
=
subprocess
.
Popen
(
'find %s -name "libudf1_dup.so"|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf2
=
subprocess
.
Popen
(
'find %s -name "libudf2.so"|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf2_dup
=
subprocess
.
Popen
(
'find %s -name "libudf2_dup.so"|grep lib|head -n1'
%
projPath
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
().
decode
(
"utf-8"
)
self
.
libudf1
=
self
.
libudf1
.
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
)
self
.
libudf1_dup
=
self
.
libudf1_dup
.
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
)
self
.
libudf2
=
self
.
libudf2
.
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
)
self
.
libudf2_dup
=
self
.
libudf2_dup
.
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
)
def
prepare_data
(
self
):
...
...
@@ -174,10 +184,12 @@ class TDTestCase:
# create scalar functions
tdSql
.
execute
(
"create function udf1 as '%s' outputtype int;"
%
self
.
libudf1
)
tdSql
.
execute
(
"create function udf1_dup as '%s' outputtype int;"
%
self
.
libudf1_dup
)
# create aggregate functions
tdSql
.
execute
(
"create aggregate function udf2 as '%s' outputtype double bufSize 8;"
%
self
.
libudf2
)
tdSql
.
execute
(
"create aggregate function udf2_dup as '%s' outputtype double bufSize 8;"
%
self
.
libudf2_dup
)
functions
=
tdSql
.
getResult
(
"show functions"
)
function_nums
=
len
(
functions
)
...
...
@@ -188,6 +200,13 @@ class TDTestCase:
# scalar functions
# udf1_dup
tdSql
.
query
(
"select udf1(num1) ,udf1_dup(num1) from tb"
)
tdSql
.
checkData
(
1
,
0
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
2
)
tdSql
.
execute
(
"use db "
)
tdSql
.
query
(
"select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
...
...
@@ -238,6 +257,10 @@ class TDTestCase:
# aggregate functions
tdSql
.
query
(
"select udf2(num1) ,udf2_dup(num1) from tb"
)
val
=
tdSql
.
queryResult
[
0
][
0
]
+
100
tdSql
.
checkData
(
0
,
1
,
val
)
tdSql
.
query
(
"select udf2(num1) ,udf2(num2), udf2(num3) from tb"
)
tdSql
.
checkData
(
0
,
0
,
15.362291496
)
tdSql
.
checkData
(
0
,
1
,
10000949.553189287
)
...
...
tests/system-test/7-tmq/stbTagFilter-1ctb.py
浏览文件 @
134c0528
...
...
@@ -111,7 +111,7 @@ class TDTestCase:
topicFromStb1
=
'topic_UpperCase_stb1'
# queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
queryString
=
"select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
sqlString
=
"create topic
%s
as %s"
%
(
topicFromStb1
,
queryString
)
sqlString
=
"create topic
`%s`
as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
...
...
@@ -148,7 +148,7 @@ class TDTestCase:
tmqCom
.
checkFileContent
(
consumerId
,
queryString
)
tdSql
.
query
(
"drop topic
%s
"
%
topicFromStb1
)
tdSql
.
query
(
"drop topic
`%s`
"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
def
tmqCase2
(
self
):
...
...
@@ -196,7 +196,7 @@ class TDTestCase:
topicFromStb1
=
'topic_UpperCase_stb1'
queryString
=
"select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
# queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
sqlString
=
"create topic
%s
as %s"
%
(
topicFromStb1
,
queryString
)
sqlString
=
"create topic
`%s`
as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
...
...
@@ -242,7 +242,7 @@ class TDTestCase:
# tmqCom.checkFileContent(consumerId, queryString)
tdSql
.
query
(
"drop topic
%s
"
%
topicFromStb1
)
tdSql
.
query
(
"drop topic
`%s`
"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 2 end ...... "
)
...
...
tests/system-test/7-tmq/stbTagFilter-multiCtb.py
浏览文件 @
134c0528
...
...
@@ -111,7 +111,7 @@ class TDTestCase:
topicFromStb1
=
'topic_UpperCase_stb1'
queryString
=
"select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
# queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
sqlString
=
"create topic
%s
as %s"
%
(
topicFromStb1
,
queryString
)
sqlString
=
"create topic
`%s`
as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
...
...
@@ -148,7 +148,7 @@ class TDTestCase:
# tmqCom.checkFileContent(consumerId, queryString)
tdSql
.
query
(
"drop topic
%s
"
%
topicFromStb1
)
tdSql
.
query
(
"drop topic
`%s`
"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
def
tmqCase2
(
self
):
...
...
@@ -196,7 +196,7 @@ class TDTestCase:
topicFromStb1
=
'topic_UpperCase_stb1'
# queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
queryString
=
"select ts, c1, c2, t4 from %s.%s where t4 == 'beijing' or t4 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
sqlString
=
"create topic
%s
as %s"
%
(
topicFromStb1
,
queryString
)
sqlString
=
"create topic
`%s`
as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
...
...
@@ -244,7 +244,7 @@ class TDTestCase:
# tmqCom.checkFileContent(consumerId, queryString)
tdSql
.
query
(
"drop topic
%s
"
%
topicFromStb1
)
tdSql
.
query
(
"drop topic
`%s`
"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 2 end ...... "
)
...
...
tests/system-test/7-tmq/subscribeDb3.py
浏览文件 @
134c0528
...
...
@@ -82,7 +82,7 @@ class TDTestCase:
tdSql
.
query
(
"select * from %s.notifyinfo"
%
cdbName
)
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
if
tdSql
.
getRows
()
==
2
:
print
(
tdSql
.
getData
(
0
,
1
),
tdSql
.
getData
(
1
,
1
))
tdLog
.
info
(
"row[0][1]: %d, row[1][1]: %d"
%
(
tdSql
.
getData
(
0
,
1
),
tdSql
.
getData
(
1
,
1
)
))
if
tdSql
.
getData
(
1
,
1
)
==
1
:
break
time
.
sleep
(
0.1
)
...
...
@@ -122,6 +122,7 @@ class TDTestCase:
os
.
system
(
shellCmd
)
def
create_tables
(
self
,
tsql
,
dbName
,
vgroups
,
stbName
,
ctbNum
,
rowsPerTbl
):
tdLog
.
info
(
"start create tables......"
)
tsql
.
execute
(
"create database if not exists %s vgroups %d wal_retention_period 3600"
%
(
dbName
,
vgroups
))
tsql
.
execute
(
"use %s"
%
dbName
)
tsql
.
execute
(
"create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"
%
stbName
)
...
...
@@ -137,11 +138,11 @@ class TDTestCase:
tsql
.
execute
(
sql
)
event
.
set
()
tdLog
.
debug
(
"complete to create database[%s], stable[%s] and %d child tables"
%
(
dbName
,
stbName
,
ctbNum
))
tdLog
.
info
(
"complete to create database[%s], stable[%s] and %d child tables"
%
(
dbName
,
stbName
,
ctbNum
))
return
def
insert_data
(
self
,
tsql
,
dbName
,
stbName
,
ctbNum
,
rowsPerTbl
,
batchNum
,
startTs
):
tdLog
.
debug
(
"start to insert data ............"
)
tdLog
.
info
(
"start to insert data ............"
)
tsql
.
execute
(
"use %s"
%
dbName
)
pre_insert
=
"insert into "
sql
=
pre_insert
...
...
@@ -163,7 +164,7 @@ class TDTestCase:
if
sql
!=
pre_insert
:
#print("insert sql:%s"%sql)
tsql
.
execute
(
sql
)
tdLog
.
debug
(
"insert data ............ [OK]"
)
tdLog
.
info
(
"insert data ............ [OK]"
)
return
def
prepareEnv
(
self
,
**
parameterDict
):
...
...
@@ -286,7 +287,7 @@ class TDTestCase:
prepareEnvThread
.
start
()
tdLog
.
info
(
"create topics from db"
)
topicName1
=
'topic_db1'
topicName1
=
'topic_db1
1
'
tdSql
.
execute
(
"create topic %s as database %s"
%
(
topicName1
,
parameterDict
[
'dbName'
]))
consumerId
=
0
...
...
tests/system-test/7-tmq/tmqDropStb.py
浏览文件 @
134c0528
...
...
@@ -82,7 +82,7 @@ class TDTestCase:
tdLog
.
info
(
"create topics from db"
)
topicName1
=
'UpperCasetopic_%s'
%
(
self
.
paraDict
[
'dbName'
])
tdSql
.
execute
(
"create topic
%s
as database %s"
%
(
topicName1
,
self
.
paraDict
[
'dbName'
]))
tdSql
.
execute
(
"create topic
`%s`
as database %s"
%
(
topicName1
,
self
.
paraDict
[
'dbName'
]))
topicList
=
topicName1
+
','
+
topicName1
keyList
=
'%s,%s,%s,%s'
%
(
self
.
groupId
,
self
.
autoCommit
,
self
.
autoCommitInterval
,
self
.
autoOffset
)
...
...
@@ -113,7 +113,7 @@ class TDTestCase:
tdLog
.
exit
(
"tmq consume rows error!"
)
time
.
sleep
(
10
)
tdSql
.
query
(
"drop topic
%s
"
%
topicName1
)
tdSql
.
query
(
"drop topic
`%s`
"
%
topicName1
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
...
...
utils/test/c/sml_test.c
浏览文件 @
134c0528
...
...
@@ -895,6 +895,63 @@ int smlProcess_18784_Test() {
return
code
;
}
int
sml_escape_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists db_escape"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use db_escape"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"d
\\
,i=
\\
s
\\
k
\"
,dev
\"
i
\\
,
\\
=
\\
ce=s
\"
i
\\
,
\\
=
\\
dc inode
\"
i
\\
,
\\
=
\\
s_used=176059i,total=1076048383523889174i 1661943960000000000"
,
"d
\\
,i=
\\
s
\\
k
\"
,dev
\"
i
\\
,
\\
=
\\
ce=s
\"
i
\\
,
\\
=
\\
dc inode
\"
i
\\
,
\\
=
\\
s_f
\\\\
ree=
\"\\\"
id,= ei
\\\\\\
f
\"
1661943960000000000"
,
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
printf
(
"%s result:%s, rows:%d
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
),
taos_affected_rows
(
pRes
));
int
code
=
taos_errno
(
pRes
);
ASSERT
(
!
code
);
ASSERT
(
taos_affected_rows
(
pRes
)
==
1
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"select * from `d,i= s
\\
k
\"
`"
);
//check stable name
ASSERT
(
pRes
);
int
fieldNum
=
taos_field_count
(
pRes
);
ASSERT
(
fieldNum
==
5
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
int
numFields
=
taos_num_fields
(
pRes
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pRes
);
ASSERT
(
numFields
==
5
);
ASSERT
(
strncmp
(
fields
[
1
].
name
,
"inode
\"
i,= s_used"
,
sizeof
(
"inode
\"
i,= s_used"
)
-
1
)
==
0
);
ASSERT
(
strncmp
(
fields
[
2
].
name
,
"total"
,
sizeof
(
"total"
)
-
1
)
==
0
);
ASSERT
(
strncmp
(
fields
[
3
].
name
,
"inode
\"
i,= s_f
\\\\
ree"
,
sizeof
(
"inode
\"
i,= s_f
\\\\
ree"
)
-
1
)
==
0
);
ASSERT
(
strncmp
(
fields
[
4
].
name
,
"dev
\"
i,= ce"
,
sizeof
(
"dev
\"
i,= ce"
)
-
1
)
==
0
);
TAOS_ROW
row
=
NULL
;
int32_t
rowIndex
=
0
;
while
((
row
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
int64_t
used
=
*
(
int64_t
*
)
row
[
1
];
int64_t
total
=
*
(
int64_t
*
)
row
[
2
];
if
(
rowIndex
==
0
)
{
ASSERT
(
ts
==
1661943960000
);
ASSERT
(
used
==
176059
);
ASSERT
(
total
==
1076048383523889174
);
ASSERT
(
strncmp
(
row
[
3
],
"
\"
id,= ei
\\\\
f"
,
sizeof
(
"
\"
id,= ei
\\\\
f"
)
-
1
)
==
0
);
ASSERT
(
strncmp
(
row
[
4
],
"s
\"
i,= dc"
,
sizeof
(
"s
\"
i,= dc"
)
-
1
)
==
0
);
}
rowIndex
++
;
}
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_19221_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -961,6 +1018,55 @@ int sml_ts2164_Test() {
return
code
;
}
int
sml_ts3116_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"DROP DATABASE IF EXISTS ts3116"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE DATABASE IF NOT EXISTS ts3116 BUFFER 384 MINROWS 1000 PAGES 256 PRECISION 'ns'"
);
taos_free_result
(
pRes
);
char
*
sql
=
{
"meters,location=la,groupid=ca current=11.8,voltage=221"
,
};
pRes
=
taos_query
(
taos
,
"use ts3116"
);
taos_free_result
(
pRes
);
int32_t
totalRows
=
0
;
char
*
tmp
=
(
char
*
)
taosMemoryCalloc
(
1024
,
1
);
memcpy
(
tmp
,
sql
,
strlen
(
sql
));
totalRows
=
0
;
pRes
=
taos_schemaless_insert_raw
(
taos
,
tmp
,
strlen
(
tmp
),
&
totalRows
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
taosMemoryFree
(
tmp
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
char
*
sql1
=
{
"meters,location=la,groupid=ca
\\
=3 current=11.8,voltage=221
\n
meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27"
,
};
pRes
=
taos_query
(
taos
,
"use ts3116"
);
taos_free_result
(
pRes
);
tmp
=
(
char
*
)
taosMemoryCalloc
(
1024
,
1
);
memcpy
(
tmp
,
sql1
,
strlen
(
sql1
));
totalRows
=
0
;
pRes
=
taos_schemaless_insert_raw
(
taos
,
tmp
,
strlen
(
tmp
),
&
totalRows
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
taosMemoryFree
(
tmp
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_td22898_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -1195,6 +1301,10 @@ int main(int argc, char *argv[]) {
}
int
ret
=
0
;
ret
=
sml_escape_Test
();
ASSERT
(
!
ret
);
ret
=
sml_ts3116_Test
();
ASSERT
(
!
ret
);
ret
=
sml_ts2385_Test
();
// this test case need config sml table name using ./sml_test config_file
ASSERT
(
!
ret
);
// for(int i = 0; i < sizeof(str)/sizeof(str[0]); i++){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录