Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
TDengine
提交
fa5d5ed7
TDengine
项目概览
yiicenne
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa5d5ed7
编写于
6月 10, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-582] fix crash.
上级
4f829d7f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
53 addition
and
40 deletion
+53
-40
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+0
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+10
-13
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+0
-8
src/common/inc/tname.h
src/common/inc/tname.h
+3
-0
src/common/src/tname.c
src/common/src/tname.c
+13
-0
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+12
-8
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+13
-8
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-1
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
fa5d5ed7
...
...
@@ -151,7 +151,6 @@ typedef struct SRateInfo {
double
sum
;
// for sum/avg
}
SRateInfo
;
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
int16_t
*
type
,
int16_t
*
bytes
,
int32_t
*
interBytes
,
int16_t
extLength
,
bool
isSuperTable
)
{
if
(
!
isValidDataType
(
dataType
,
dataBytes
))
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
fa5d5ed7
...
...
@@ -348,7 +348,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
pToken
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
if
(
tscValidateTableNameLength
(
pToken
->
n
)
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -1056,7 +1056,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
totalLen
+=
1
;
/* here we only check the table name length limitation */
if
(
tableName
->
n
>
TSDB_TABLE_NAME_LEN
)
{
if
(
!
tscValidateTableNameLength
(
tableName
->
n
)
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
else
{
// pDB == NULL, the db prefix name is specified in tableName
...
...
@@ -1402,9 +1402,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
}
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
};
strcpy
(
colSchema
.
name
,
TSQL_TBNAME_L
);
SSchema
colSchema
=
tGetTableNameColumnSchema
();
tscAddSpecialColumnForSelect
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
true
);
}
else
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
...
...
@@ -1914,9 +1912,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
SSchema
s
=
{
0
};
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
s
.
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
s
.
type
=
TSDB_DATA_TYPE_BINARY
;
s
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
s
=
tGetTableNameColumnSchema
();
}
else
{
s
=
pTagSchema
[
index
.
columnIndex
];
}
...
...
@@ -2230,7 +2226,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
if
(
pCmd
->
payloadLen
>=
TSDB_TABLE_NAME_LEN
)
{
if
(
!
tscValidateTableNameLength
(
pCmd
->
payloadLen
)
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
...
@@ -2861,7 +2857,7 @@ static int32_t tablenameListToString(tSQLExpr* pExpr, SStringBuilder* sb) {
taosStringBuilderAppendString
(
sb
,
TBNAME_LIST_SEP
);
}
if
(
pSub
->
val
.
nLen
<=
0
||
pSub
->
val
.
nLen
>
TSDB_TABLE_NAME_LEN
)
{
if
(
pSub
->
val
.
nLen
<=
0
||
!
tscValidateTableNameLength
(
pSub
->
val
.
nLen
)
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
...
...
@@ -5232,9 +5228,10 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
int16_t
colIndex
=
pColIndex
->
colIndex
;
if
(
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
type
=
TSDB_DATA_TYPE_BINARY
;
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
// todo extract method
name
=
TSQL_TBNAME_L
;
SSchema
s
=
tGetTableNameColumnSchema
();
type
=
s
.
type
;
bytes
=
s
.
bytes
;
name
=
s
.
name
;
}
else
{
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
{
SSchema
*
tagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
fa5d5ed7
...
...
@@ -50,14 +50,6 @@ int32_t tscGetNumOfColumns(const STableMeta* pTableMeta) {
SSchema
*
tscGetTableSchema
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
// if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
// STableMeta* pSTableMeta = pTableMeta->pSTable;
// assert (pSTableMeta != NULL);
//
// return pSTableMeta->schema;
// }
return
(
SSchema
*
)
pTableMeta
->
schema
;
}
...
...
src/common/inc/tname.h
浏览文件 @
fa5d5ed7
...
...
@@ -23,5 +23,8 @@ void extractTableName(const char *tableId, char *name);
char
*
extractDBName
(
const
char
*
tableId
,
char
*
name
);
SSchema
tGetTableNameColumnSchema
();
bool
tscValidateTableNameLength
(
size_t
len
);
#endif // TDENGINE_NAME_H
src/common/src/tname.c
浏览文件 @
fa5d5ed7
...
...
@@ -37,3 +37,16 @@ char* extractDBName(const char* tableId, char* name) {
return
strncpy
(
name
,
&
tableId
[
offset1
+
1
],
len
);
}
SSchema
tGetTableNameColumnSchema
()
{
SSchema
s
=
{
0
};
s
.
bytes
=
TSDB_TABLE_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
;
s
.
type
=
TSDB_DATA_TYPE_BINARY
;
s
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
strncpy
(
s
.
name
,
TSQL_TBNAME_L
,
TSDB_COL_NAME_LEN
);
return
s
;
}
bool
tscValidateTableNameLength
(
size_t
len
)
{
return
len
<
TSDB_TABLE_NAME_LEN
;
}
\ No newline at end of file
src/inc/taosdef.h
浏览文件 @
fa5d5ed7
...
...
@@ -200,7 +200,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
#define TSDB_NODE_NAME_LEN 64
#define TSDB_TABLE_NAME_LEN 193
#define TSDB_TABLE_NAME_LEN 193
// it is a null-terminated string
#define TSDB_DB_NAME_LEN 33
#define TSDB_COL_NAME_LEN 65
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
fa5d5ed7
...
...
@@ -1078,8 +1078,9 @@ static int32_t mnodeGetShowSuperTableMeta(STableMetaMsg *pMeta, SShowObj *pShow,
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
SSchema
tbnameSchema
=
tGetTableNameColumnSchema
();
pShow
->
bytes
[
cols
]
=
tbnameSchema
.
bytes
;
pSchema
[
cols
].
type
=
tbnameSchema
.
type
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -2079,8 +2080,9 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
SSchema
s
=
tGetTableNameColumnSchema
();
pShow
->
bytes
[
cols
]
=
s
.
bytes
;
pSchema
[
cols
].
type
=
s
.
type
;
strcpy
(
pSchema
[
cols
].
name
,
"table_name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -2097,8 +2099,9 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
SSchema
tbCol
=
tGetTableNameColumnSchema
();
pShow
->
bytes
[
cols
]
=
tbCol
.
bytes
;
pSchema
[
cols
].
type
=
tbCol
.
type
;
strcpy
(
pSchema
[
cols
].
name
,
"stable_name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -2268,8 +2271,9 @@ static int32_t mnodeGetStreamTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, vo
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
SSchema
tbnameColSchema
=
tGetTableNameColumnSchema
();
pShow
->
bytes
[
cols
]
=
tbnameColSchema
.
bytes
;
pSchema
[
cols
].
type
=
tbnameColSchema
.
type
;
strcpy
(
pSchema
[
cols
].
name
,
"table_name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
src/query/src/qExecutor.c
浏览文件 @
fa5d5ed7
...
...
@@ -1368,8 +1368,10 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
int32_t
index
=
pSqlFuncMsg
->
colInfo
.
colIndex
;
if
(
TSDB_COL_IS_TAG
(
pIndex
->
flag
))
{
if
(
pIndex
->
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// todo refactor
pCtx
->
inputBytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pCtx
->
inputType
=
TSDB_DATA_TYPE_BINARY
;
SSchema
s
=
tGetTableNameColumnSchema
();
pCtx
->
inputBytes
=
s
.
bytes
;
pCtx
->
inputType
=
s
.
type
;
}
else
{
pCtx
->
inputBytes
=
pQuery
->
tagColList
[
index
].
bytes
;
pCtx
->
inputType
=
pQuery
->
tagColList
[
index
].
type
;
...
...
@@ -5143,8 +5145,9 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
type
=
TSDB_DATA_TYPE_DOUBLE
;
bytes
=
tDataTypeDesc
[
type
].
nSize
;
}
else
if
(
pExprs
[
i
].
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
&&
pExprs
[
i
].
base
.
functionId
==
TSDB_FUNC_TAGPRJ
)
{
// parse the normal column
type
=
TSDB_DATA_TYPE_BINARY
;
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
SSchema
s
=
tGetTableNameColumnSchema
();
type
=
s
.
type
;
bytes
=
s
.
bytes
;
}
else
{
int32_t
j
=
getColumnIndexInSource
(
pQueryMsg
,
&
pExprs
[
i
].
base
,
pTagCols
);
assert
(
j
<
pQueryMsg
->
numOfCols
||
j
<
pQueryMsg
->
numOfTags
||
j
==
TSDB_TBNAME_COLUMN_INDEX
);
...
...
@@ -5154,10 +5157,11 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
type
=
pCol
->
type
;
bytes
=
pCol
->
bytes
;
}
else
{
type
=
TSDB_DATA_TYPE_BINARY
;
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
}
SSchema
s
=
tGetTableNameColumnSchema
();
type
=
s
.
type
;
bytes
=
s
.
bytes
;
}
}
int32_t
param
=
pExprs
[
i
].
base
.
arg
[
0
].
argValue
.
i64
;
...
...
@@ -6025,6 +6029,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
qTrace
(
"QInfo:%p create count(tbname) query, res:%d rows:1"
,
pQInfo
,
count
);
}
else
{
// return only the tags|table name etc.
count
=
0
;
SSchema
tbnameSchema
=
tGetTableNameColumnSchema
();
while
(
pQInfo
->
tableIndex
<
num
&&
count
<
pQuery
->
rec
.
capacity
)
{
int32_t
i
=
pQInfo
->
tableIndex
++
;
...
...
@@ -6034,7 +6039,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
for
(
int32_t
j
=
0
;
j
<
pQuery
->
numOfOutput
;
++
j
)
{
if
(
pExprInfo
[
j
].
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
char
*
data
=
tsdbGetTableName
(
pQInfo
->
tsdb
,
&
item
->
id
);
char
*
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
((
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
)
;
char
*
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
tbnameSchema
.
bytes
;
memcpy
(
dst
,
data
,
varDataTLen
(
data
));
}
else
{
// todo refactor
int16_t
type
=
pExprInfo
[
j
].
type
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
fa5d5ed7
...
...
@@ -1942,7 +1942,7 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
f1
=
(
char
*
)
pTable1
->
name
;
f2
=
(
char
*
)
pTable2
->
name
;
type
=
TSDB_DATA_TYPE_BINARY
;
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
bytes
=
tGetTableNameColumnSchema
().
bytes
;
}
else
{
STColumn
*
pCol
=
schemaColAt
(
pTableGroupSupp
->
pTagSchema
,
colIndex
);
bytes
=
pCol
->
bytes
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录