Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b7b8edf2
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看板
提交
b7b8edf2
编写于
4月 23, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-171] fix bugs in create table
上级
41008f5d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
86 addition
and
68 deletion
+86
-68
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+6
-3
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+4
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+21
-19
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+4
-4
src/client/src/tscServer.c
src/client/src/tscServer.c
+10
-15
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+2
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+34
-18
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+3
-0
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+2
-3
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
b7b8edf2
...
...
@@ -146,9 +146,12 @@ int32_t tscFieldInfoCompare(const SFieldInfo* pFieldInfo1, const SFieldInfo* pFi
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
int32_t
tscGetResRowLength
(
SArray
*
pExprList
);
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
);
SSqlExpr
*
tscSqlExprAppend
(
SArray
*
exprInfo
,
int16_t
functionId
);
SSqlExpr
*
tscSqlExprAppend
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
);
SSqlExpr
*
tscSqlExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
int16_t
size
);
...
...
@@ -160,7 +163,7 @@ void tscSqlExprInfoDestroy(SArray* pExprInfo);
SColumn
*
tscColumnClone
(
const
SColumn
*
src
);
SColumn
*
tscColumnListInsert
(
SArray
*
pColList
,
SColumnIndex
*
colIndex
);
void
tscColumnList
Assign
(
SArray
*
dst
,
const
SArray
*
src
,
int16_t
tableIndex
);
void
tscColumnList
Copy
(
SArray
*
dst
,
const
SArray
*
src
,
int16_t
tableIndex
);
void
tscColumnListDestroy
(
SArray
*
pColList
);
SColumnFilterInfo
*
tscFilterInfoClone
(
const
SColumnFilterInfo
*
src
,
int32_t
numOfFilters
);
...
...
src/client/src/tscLocal.c
浏览文件 @
b7b8edf2
...
...
@@ -247,7 +247,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
strncpy
(
f
.
name
,
"Field"
,
TSDB_COL_NAME_LEN
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
TSDB_COL_NAME_LEN
,
TSDB_COL_NAME_LEN
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
TSDB_COL_NAME_LEN
,
TSDB_COL_NAME_LEN
);
rowLen
+=
TSDB_COL_NAME_LEN
;
...
...
@@ -256,7 +256,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
strncpy
(
f
.
name
,
"Type"
,
TSDB_COL_NAME_LEN
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
typeColLength
,
typeColLength
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
typeColLength
,
typeColLength
);
rowLen
+=
typeColLength
;
...
...
@@ -265,7 +265,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
strncpy
(
f
.
name
,
"Length"
,
TSDB_COL_NAME_LEN
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
sizeof
(
int32_t
));
pInfo
->
pSqlExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
sizeof
(
int32_t
));
rowLen
+=
sizeof
(
int32_t
);
...
...
@@ -274,7 +274,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
strncpy
(
f
.
name
,
"Note"
,
TSDB_COL_NAME_LEN
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
noteColLength
,
noteColLength
);
pInfo
->
pSqlExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
noteColLength
,
noteColLength
);
rowLen
+=
noteColLength
;
return
rowLen
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
b7b8edf2
...
...
@@ -649,7 +649,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
}
SColumnIndex
index
=
{
tableIndex
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
TSDB_FUNC_TS
,
&
index
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
0
,
TSDB_FUNC_TS
,
&
index
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
SColumnList
ids
=
getColumnList
(
1
,
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
...
...
@@ -1168,7 +1168,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
// expr string is set as the parameter of function
SColumnIndex
index
=
{.
tableIndex
=
tableIndex
};
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_ARITHM
,
&
index
,
TSDB_DATA_TYPE_DOUBLE
,
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_ARITHM
,
&
index
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
sizeof
(
double
));
addExprParams
(
pExpr
,
arithmeticExprStr
,
TSDB_DATA_TYPE_BINARY
,
strlen
(
arithmeticExprStr
),
index
.
tableIndex
);
...
...
@@ -1292,7 +1292,7 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c
pQueryInfo
->
type
=
(
functionId
==
TSDB_FUNC_TAGPRJ
)
?
TSDB_QUERY_TYPE_STABLE_QUERY
:
TSDB_QUERY_TYPE_PROJECTION_QUERY
;
SColumnIndex
index
=
{
tableIndex
,
colIndex
};
return
tscSqlExpr
Insert
(
pQueryInfo
,
functionId
,
&
index
,
pSchema
->
type
,
pSchema
->
bytes
,
pSchema
->
bytes
);
return
tscSqlExpr
Append
(
pQueryInfo
,
functionId
,
&
index
,
pSchema
->
type
,
pSchema
->
bytes
,
pSchema
->
bytes
);
}
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
)
{
...
...
@@ -1346,7 +1346,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
flag
)
{
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionId
,
pIndex
,
pColSchema
->
type
,
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionId
,
pIndex
,
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
bytes
);
SColumnList
ids
=
getColumnList
(
1
,
pIndex
->
tableIndex
,
pIndex
->
columnIndex
);
...
...
@@ -1474,7 +1474,7 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
getRevisedName
(
columnName
,
functionID
,
TSDB_COL_NAME_LEN
,
pSchema
[
pColIndex
->
columnIndex
].
name
);
}
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionID
,
pColIndex
,
type
,
bytes
,
bytes
);
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionID
,
pColIndex
,
type
,
bytes
,
bytes
);
strncpy
(
pExpr
->
aliasName
,
columnName
,
tListLen
(
pExpr
->
aliasName
));
// for all queries, the timestamp column needs to be loaded
...
...
@@ -1531,7 +1531,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
index
=
(
SColumnIndex
){
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
}
else
{
// count the number of meters created according to the metric
if
(
getColumnIndexByName
(
pToken
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1546,13 +1546,13 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
}
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
}
}
else
{
// count(*) is equalled to count(primary_timestamp_key)
index
=
(
SColumnIndex
){
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
);
}
memset
(
pExpr
->
aliasName
,
0
,
tListLen
(
pExpr
->
aliasName
));
...
...
@@ -1632,7 +1632,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
if
(
optr
==
TK_DIFF
)
{
colIndex
+=
1
;
SColumnIndex
indexTS
=
{.
tableIndex
=
index
.
tableIndex
,
.
columnIndex
=
0
};
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
indexTS
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
indexTS
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
SColumnList
ids
=
getColumnList
(
1
,
0
,
0
);
...
...
@@ -1644,7 +1644,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionID
,
&
index
,
resultType
,
resultSize
,
resultSize
);
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionID
,
&
index
,
resultType
,
resultSize
,
resultSize
);
if
(
optr
==
TK_LEASTSQUARES
)
{
/* set the leastsquares parameters */
...
...
@@ -1836,7 +1836,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
return
TSDB_CODE_INVALID_SQL
;
}
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionId
,
&
index
,
resultType
,
resultSize
,
resultSize
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionId
,
&
index
,
resultType
,
resultSize
,
resultSize
);
addExprParams
(
pExpr
,
val
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
0
);
}
else
{
tVariantDump
(
pVariant
,
val
,
TSDB_DATA_TYPE_BIGINT
);
...
...
@@ -1853,7 +1853,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
// set the first column ts for top/bottom query
SColumnIndex
index1
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TS
,
&
index1
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TS
,
&
index1
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
const
int32_t
TS_COLUMN_INDEX
=
0
;
SColumnList
ids
=
getColumnList
(
1
,
0
,
TS_COLUMN_INDEX
);
...
...
@@ -1862,7 +1862,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
colIndex
+=
1
;
// the first column is ts
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionId
,
&
index
,
resultType
,
resultSize
,
resultSize
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionId
,
&
index
,
resultType
,
resultSize
,
resultSize
);
addExprParams
(
pExpr
,
val
,
TSDB_DATA_TYPE_BIGINT
,
sizeof
(
int64_t
),
0
);
}
...
...
@@ -4815,7 +4815,7 @@ void tscAddTimestampColumn(SQueryInfo* pQueryInfo, int16_t functionId, int16_t t
if
(
pExpr
==
NULL
||
pExpr
->
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
pExpr
->
functionId
!=
functionId
)
{
SColumnIndex
index
=
{
tableIndex
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
functionId
,
&
index
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
functionId
,
&
index
,
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_KEYSIZE
,
TSDB_KEYSIZE
);
pExpr
->
colInfo
.
flag
=
TSDB_COL_NORMAL
;
// NOTE: tag column does not add to source column list
...
...
@@ -4844,7 +4844,7 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
int16_t
bytes
=
pSchema
[
index
.
columnIndex
].
bytes
;
char
*
name
=
pSchema
[
index
.
columnIndex
].
name
;
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TAG
,
&
index
,
type
,
bytes
,
bytes
);
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TAG
,
&
index
,
type
,
bytes
,
bytes
);
pExpr
->
colInfo
.
flag
=
TSDB_COL_TAG
;
// NOTE: tag column does not add to source column list
...
...
@@ -4877,7 +4877,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
index
};
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_PRJ
,
&
colIndex
,
pSchema
->
type
,
pSchema
->
bytes
,
pSchema
->
bytes
);
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_PRJ
,
&
colIndex
,
pSchema
->
type
,
pSchema
->
bytes
,
pSchema
->
bytes
);
pExpr
->
colInfo
.
flag
=
TSDB_COL_NORMAL
;
doLimitOutputNormalColOfGroupby
(
pExpr
);
...
...
@@ -5121,7 +5121,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
{
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SSqlExpr
*
pExpr
=
tscSqlExpr
Insert
(
pQueryInfo
,
TSDB_FUNC_TAG
,
&
index
,
type
,
bytes
,
bytes
);
SSqlExpr
*
pExpr
=
tscSqlExpr
Append
(
pQueryInfo
,
TSDB_FUNC_TAG
,
&
index
,
type
,
bytes
,
bytes
);
memset
(
pExpr
->
aliasName
,
0
,
tListLen
(
pExpr
->
aliasName
));
strncpy
(
pExpr
->
aliasName
,
name
,
TSDB_COL_NAME_LEN
);
...
...
@@ -5269,7 +5269,9 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
}
}
SSqlExpr
*
pExpr1
=
tscSqlExprAppend
(
pQueryInfo
->
exprsInfo
,
TSDB_FUNC_TAG_DUMMY
);
SColumnIndex
ind
=
{
0
};
SSqlExpr
*
pExpr1
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TAG_DUMMY
,
&
ind
,
TSDB_DATA_TYPE_INT
,
tDataTypeDesc
[
TSDB_DATA_TYPE_INT
].
nSize
,
tDataTypeDesc
[
TSDB_DATA_TYPE_INT
].
nSize
);
const
char
*
name
=
(
pExprList
->
a
[
0
].
aliasName
!=
NULL
)
?
pExprList
->
a
[
0
].
aliasName
:
functionsInfo
[
index
].
name
;
strncpy
(
pExpr1
->
aliasName
,
name
,
tListLen
(
pExpr1
->
aliasName
));
...
...
@@ -5443,7 +5445,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
if
(
pTagList
!=
NULL
)
{
// create metric[optional]
for
(
int32_t
i
=
0
;
i
<
pTagList
->
nField
;
++
i
)
{
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
pTagList
->
p
[
col
]);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
pTagList
->
p
[
i
]);
}
pCmd
->
count
=
pTagList
->
nField
;
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
b7b8edf2
...
...
@@ -161,18 +161,18 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
precision
=
pTableMetaMsg
->
precision
,
.
numOfColumns
=
pTableMetaMsg
->
numOfColumns
,
.
precision
=
pTableMetaMsg
->
precision
};
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
uid
=
pTableMetaMsg
->
uid
;
//
pTableMeta->vgroupInfo = pTableMetaMsg->vgroup;
pTableMeta
->
vgroupInfo
=
pTableMetaMsg
->
vgroup
;
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
b7b8edf2
...
...
@@ -2169,13 +2169,11 @@ int tscProcessShowRsp(SSqlObj *pSql) {
strcpy
(
key
+
1
,
"showlist"
);
taosCacheRelease
(
tscCacheHandle
,
(
void
*
)
&
(
pTableMetaInfo
->
pTableMeta
),
false
);
size_t
size
=
0
;
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
pTableMetaInfo
->
pTableMeta
=
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pTableMeta
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
pTableMetaInfo
->
pTableMeta
=
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pTableMeta
,
size
,
tsMeterMetaKeepTimer
);
SSchema
*
pTableSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
if
(
pQueryInfo
->
colList
==
NULL
)
{
...
...
@@ -2185,23 +2183,20 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
SColumnIndex
index
=
{
0
};
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
)
{
pSchema
=
pMetaMsg
->
schema
;
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
,
++
pSchema
)
{
index
.
columnIndex
=
i
;
tscColumnListInsert
(
pQueryInfo
->
colList
,
&
index
);
TAOS_FIELD
field
=
{
.
bytes
=
pSchema
->
bytes
,
.
type
=
pSchema
->
type
,
};
strncpy
(
field
.
name
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
tscFieldInfoAppend
(
pFieldInfo
,
&
field
);
TAOS_FIELD
f
=
tscCreateField
(
pSchema
->
type
,
pSchema
->
name
,
pSchema
->
bytes
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
i
);
pInfo
->
pSqlExpr
=
tscSqlExprInsert
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
pTableSchema
[
i
].
bytes
);
}
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
tscFieldInfoUpdateOffset
(
pQueryInfo
);
tfree
(
pTableMeta
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
b7b8edf2
...
...
@@ -301,7 +301,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pQueryInfo
->
intervalTime
=
pSupporter
->
interval
;
pQueryInfo
->
groupbyExpr
=
pSupporter
->
groupbyExpr
;
tscColumnList
Assign
(
pQueryInfo
->
colList
,
pSupporter
->
colList
,
0
);
tscColumnList
Copy
(
pQueryInfo
->
colList
,
pSupporter
->
colList
,
0
);
tscTagCondCopy
(
&
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
pQueryInfo
->
exprsInfo
=
tscSqlExprCopy
(
pSupporter
->
exprsInfo
,
pSupporter
->
uid
,
false
);
...
...
@@ -856,7 +856,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
pCol
->
colIndex
.
tableIndex
=
0
;
}
tscColumnList
Assign
(
pSupporter
->
colList
,
pNewQueryInfo
->
colList
,
0
);
tscColumnList
Copy
(
pSupporter
->
colList
,
pNewQueryInfo
->
colList
,
0
);
pSupporter
->
exprsInfo
=
tscSqlExprCopy
(
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopy
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
...
...
src/client/src/tscUtil.c
浏览文件 @
b7b8edf2
...
...
@@ -946,19 +946,12 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
memset
(
pFieldInfo
,
0
,
sizeof
(
SFieldInfo
));
}
SSqlExpr
*
tscSqlExprAppend
(
SArray
*
exprInfo
,
int16_t
functionId
)
{
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
pExpr
->
functionId
=
functionId
;
return
taosArrayPush
(
exprInfo
,
&
pExpr
);
}
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
static
SSqlExpr
*
doBuildSqlExpr
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
int16_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
pExpr
->
functionId
=
functionId
;
// set the correct column index
...
...
@@ -968,8 +961,9 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIn
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pColIndex
->
columnIndex
);
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
}
// tag columns require the column index revised.
int16_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
pColIndex
->
columnIndex
>=
numOfCols
)
{
pExpr
->
colInfo
.
flag
=
TSDB_COL_TAG
;
}
else
{
...
...
@@ -979,13 +973,31 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIn
pExpr
->
colInfo
.
flag
=
TSDB_COL_TAG
;
}
}
pExpr
->
colInfo
.
colIndex
=
pColIndex
->
columnIndex
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
interResBytes
=
interSize
;
pExpr
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
pExpr
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
return
pExpr
;
}
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
int32_t
num
=
taosArrayGetSize
(
pQueryInfo
->
exprsInfo
);
if
(
index
==
num
)
{
return
tscSqlExprAppend
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
interSize
);
}
SSqlExpr
*
pExpr
=
doBuildSqlExpr
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
interSize
);
taosArrayInsert
(
pQueryInfo
->
exprsInfo
,
index
,
&
pExpr
);
return
pExpr
;
}
SSqlExpr
*
tscSqlExprAppend
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
SSqlExpr
*
pExpr
=
doBuildSqlExpr
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
interSize
);
taosArrayPush
(
pQueryInfo
->
exprsInfo
,
&
pExpr
);
return
pExpr
;
}
...
...
@@ -1183,7 +1195,7 @@ static void tscColumnDestroy(SColumn* pCol) {
free
(
pCol
);
}
void
tscColumnList
Assign
(
SArray
*
dst
,
const
SArray
*
src
,
int16_t
tableIndex
)
{
void
tscColumnList
Copy
(
SArray
*
dst
,
const
SArray
*
src
,
int16_t
tableIndex
)
{
if
(
src
==
NULL
)
{
return
;
}
...
...
@@ -1764,14 +1776,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
memcpy
(
pNewQueryInfo
,
pQueryInfo
,
sizeof
(
SQueryInfo
));
memset
(
&
pNewQueryInfo
->
colList
,
0
,
sizeof
(
pNewQueryInfo
->
colList
));
memset
(
&
pNewQueryInfo
->
fieldsInfo
,
0
,
sizeof
(
SFieldInfo
));
pNewQueryInfo
->
pTableMetaInfo
=
NULL
;
pNewQueryInfo
->
defaultVal
=
NULL
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
tsBuf
=
NULL
;
pNewQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pNewQueryInfo
->
fieldsInfo
.
pFields
=
taosArrayInit
(
4
,
sizeof
(
TAOS_FIELD
));
pNewQueryInfo
->
fieldsInfo
.
pSupportInfo
=
taosArrayInit
(
4
,
sizeof
(
SFieldSupInfo
));
pNewQueryInfo
->
exprsInfo
=
taosArrayInit
(
4
,
POINTER_BYTES
);
tscTagCondCopy
(
&
pNewQueryInfo
->
tagCond
,
&
pQueryInfo
->
tagCond
);
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
...
...
@@ -1785,7 +1801,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
return
NULL
;
}
tscColumnList
Assign
(
pNewQueryInfo
->
colList
,
pQueryInfo
->
colList
,
(
int16_t
)
tableIndex
);
tscColumnList
Copy
(
pNewQueryInfo
->
colList
,
pQueryInfo
->
colList
,
(
int16_t
)
tableIndex
);
// set the correct query type
if
(
pPrevSql
!=
NULL
)
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
b7b8edf2
...
...
@@ -730,6 +730,9 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
SSchema
*
tschema
=
pStable
->
schema
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
tschema
[
col
].
bytes
=
htons
(
tschema
[
col
].
bytes
);
// todo 1. check the length of each column; 2. check the total length of all columns
assert
(
tschema
[
col
].
type
>=
TSDB_DATA_TYPE_BOOL
&&
tschema
[
col
].
type
<=
TSDB_DATA_TYPE_NCHAR
);
}
SSdbOper
oper
=
{
...
...
src/query/src/queryExecutor.c
浏览文件 @
b7b8edf2
...
...
@@ -1306,8 +1306,6 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY
pTWAInfo
->
EKey
=
pQuery
->
window
.
ekey
;
}
// pCtx->ptsList = tsCol;
}
else
if
(
functionId
==
TSDB_FUNC_ARITHM
)
{
pCtx
->
param
[
1
].
pz
=
param
;
}
...
...
@@ -3781,7 +3779,8 @@ void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, STableDataInfo *
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
STableQueryInfo
*
pTableQueryInfo
=
pTableDataInfo
->
pTableQInfo
;
SWindowResInfo
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
pQuery
->
pos
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
0
:
pDataBlockInfo
->
rows
-
1
;
if
(
pQuery
->
numOfFilterCols
>
0
||
pRuntimeEnv
->
pTSBuf
!=
NULL
)
{
rowwiseApplyFunctions
(
pRuntimeEnv
,
pStatis
,
pDataBlockInfo
,
pWindowResInfo
,
pDataBlock
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录