Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
拾光师
TDengine
提交
8e188274
T
TDengine
项目概览
拾光师
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8e188274
编写于
10月 21, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1764]
上级
015f1b82
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
87 addition
and
119 deletion
+87
-119
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-4
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+7
-6
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+2
-2
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+5
-7
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+21
-16
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+19
-3
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+25
-77
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
8e188274
...
...
@@ -149,14 +149,13 @@ int tscAllocPayload(SSqlCmd* pCmd, int size);
TAOS_FIELD
tscCreateField
(
int8_t
type
,
const
char
*
name
,
int16_t
bytes
);
S
FieldSupInfo
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
);
S
FieldSupInfo
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
);
S
InternalField
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
);
S
InternalField
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
);
S
FieldSupInfo
*
tscFieldInfoGetSupp
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
S
InternalField
*
tscFieldInfoGetInternalField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoCopy
(
SFieldInfo
*
dst
,
const
SFieldInfo
*
src
);
void
tscFieldInfoUpdateOffsetForInterResult
(
SQueryInfo
*
pQueryInfo
);
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
...
...
src/client/inc/tsclient.h
浏览文件 @
8e188274
...
...
@@ -142,16 +142,17 @@ typedef struct SColumnIndex {
int16_t
columnIndex
;
}
SColumnIndex
;
typedef
struct
SFieldSupInfo
{
typedef
struct
SInternalField
{
TAOS_FIELD
field
;
bool
visible
;
SExprInfo
*
pArithExprInfo
;
SSqlExpr
*
pSqlExpr
;
}
S
FieldSupInfo
;
}
S
InternalField
;
typedef
struct
SFieldInfo
{
int16_t
numOfOutput
;
// number of column in result
SArray
*
pFields
;
// SArray<TAOS_FIELD>
SArray
*
pSupportInfo
;
// SArray<SFieldSupInfo
>
int16_t
numOfOutput
;
// number of column in result
TAOS_FIELD
*
final
;
SArray
*
internalField
;
// SArray<SInternalField
>
}
SFieldInfo
;
typedef
struct
SColumn
{
...
...
@@ -469,7 +470,7 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
FORCE_INLINE
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
S
FieldSupInfo
*
pInfo
=
(
SFieldSupInfo
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
pSupportInfo
,
columnIndex
);
S
InternalField
*
pInfo
=
(
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
columnIndex
);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
...
...
src/client/src/tscAsync.c
浏览文件 @
8e188274
...
...
@@ -327,7 +327,7 @@ void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows) {
}
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
){
S
FieldSupInfo
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
S
InternalField
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
// pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pSup->pSqlExpr->resBytes * pRes->row;
}
else
{
...
...
@@ -348,7 +348,7 @@ void tscProcessFetchRow(SSchedMsg *pMsg) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
)
{
S
FieldSupInfo
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
S
InternalField
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
...
...
src/client/src/tscLocal.c
浏览文件 @
8e188274
...
...
@@ -239,7 +239,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
TAOS_FIELD
f
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
};
tstrncpy
(
f
.
name
,
"Field"
,
sizeof
(
f
.
name
));
S
FieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
S
InternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
(
TSDB_COL_NAME_LEN
-
1
),
false
);
...
...
@@ -485,7 +485,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
tstrncpy
(
f
.
name
,
"Database"
,
sizeof
(
f
.
name
));
}
S
FieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
S
InternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
f
.
bytes
,
f
.
bytes
-
VARSTR_HEADER_SIZE
,
false
);
...
...
@@ -922,19 +922,17 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
tscFieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
pQueryInfo
->
fieldsInfo
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
TAOS_FIELD
));
pQueryInfo
->
fieldsInfo
.
pSupportInfo
=
taosArrayInit
(
1
,
sizeof
(
SFieldSupInfo
));
pQueryInfo
->
fieldsInfo
.
internalField
=
taosArrayInit
(
1
,
sizeof
(
SInternalField
));
TAOS_FIELD
f
=
tscCreateField
((
int8_t
)
type
,
columnName
,
(
int16_t
)
valueLength
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
(
int32_t
)
valueLength
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
0
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
0
);
SInternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
0
);
pInfo
->
pSqlExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
memcpy
(
pRes
->
data
,
val
,
p
Field
->
bytes
);
memcpy
(
pRes
->
data
,
val
,
p
Info
->
field
.
bytes
);
}
int
tscProcessLocalCmd
(
SSqlObj
*
pSql
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
8e188274
...
...
@@ -122,7 +122,7 @@ static int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSql
static
int32_t
doCheckForCreateFromStable
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
static
int32_t
doCheckForStream
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
static
int32_t
doCheckForQuery
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
,
int32_t
index
);
static
int32_t
exprTreeFromSqlExpr
(
SSqlCmd
*
pCmd
,
tExprNode
**
pExpr
,
const
tSQLExpr
*
pSqlExpr
,
S
Array
*
pExprInfo
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pCols
);
static
int32_t
exprTreeFromSqlExpr
(
SSqlCmd
*
pCmd
,
tExprNode
**
pExpr
,
const
tSQLExpr
*
pSqlExpr
,
S
QueryInfo
*
pQueryInfo
,
SArray
*
pCols
,
int64_t
*
uid
);
/*
* Used during parsing query sql. Since the query sql usually small in length, error position
...
...
@@ -1250,7 +1250,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
tExprNode
*
pNode
=
NULL
;
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pNode
,
pItem
->
pNode
,
pQueryInfo
->
exprList
,
pQueryInfo
,
colList
);
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pNode
,
pItem
->
pNode
,
pQueryInfo
,
colList
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosArrayDestroy
(
colList
);
tExprTreeDestroy
(
&
pNode
,
NULL
);
...
...
@@ -1306,17 +1306,17 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
insertResultField
(
pQueryInfo
,
exprIndex
,
&
columnList
,
sizeof
(
double
),
TSDB_DATA_TYPE_DOUBLE
,
aliasName
,
NULL
);
int32_t
slot
=
tscNumOfFields
(
pQueryInfo
)
-
1
;
S
FieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
slot
);
S
InternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
slot
);
if
(
pInfo
->
pSqlExpr
==
NULL
)
{
SExprInfo
*
pArithExprInfo
=
calloc
(
1
,
sizeof
(
SExprInfo
));
// arithmetic expression always return result in the format of double float
pArithExprInfo
->
bytes
=
sizeof
(
double
);
pArithExprInfo
->
bytes
=
sizeof
(
double
);
pArithExprInfo
->
interBytes
=
sizeof
(
double
);
pArithExprInfo
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pArithExprInfo
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pArithExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
->
exprList
,
pQueryInfo
,
NULL
);
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pArithExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
,
NULL
,
&
pArithExprInfo
->
uid
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
&
pArithExprInfo
->
pExpr
,
NULL
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"invalid expression in select clause"
);
...
...
@@ -1373,7 +1373,7 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) {
int32_t
numOfCols
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
tscAddSpecialColumnForSelect
(
pQueryInfo
,
numOfCols
,
TSDB_FUNC_PRJ
,
&
index
,
pSchema
,
TSDB_COL_NORMAL
);
S
FieldSupInfo
*
pSupInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
numOfCols
);
S
InternalField
*
pSupInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
numOfCols
);
pSupInfo
->
visible
=
false
;
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_PROJECTION_QUERY
;
...
...
@@ -1470,7 +1470,7 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
}
TAOS_FIELD
f
=
tscCreateField
(
type
,
fieldName
,
bytes
);
S
FieldSupInfo
*
pInfo
=
tscFieldInfoInsert
(
&
pQueryInfo
->
fieldsInfo
,
outputIndex
,
&
f
);
S
InternalField
*
pInfo
=
tscFieldInfoInsert
(
&
pQueryInfo
->
fieldsInfo
,
outputIndex
,
&
f
);
pInfo
->
pSqlExpr
=
pSqlExpr
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -4063,7 +4063,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tExprNode
*
p
=
NULL
;
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
NULL
,
pQueryInfo
,
colList
);
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
TRY
(
0
)
{
...
...
@@ -5316,7 +5316,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
tscAddSpecialColumnForSelect
(
pQueryInfo
,
(
int32_t
)
size
,
TSDB_FUNC_PRJ
,
&
colIndex
,
pSchema
,
TSDB_COL_NORMAL
);
S
FieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
(
int32_t
)
size
);
S
InternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
(
int32_t
)
size
);
doLimitOutputNormalColOfGroupby
(
pInfo
->
pSqlExpr
);
pInfo
->
visible
=
false
;
}
...
...
@@ -6361,19 +6361,19 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
return
TSDB_CODE_SUCCESS
;
// Does not build query message here
}
int32_t
exprTreeFromSqlExpr
(
SSqlCmd
*
pCmd
,
tExprNode
**
pExpr
,
const
tSQLExpr
*
pSqlExpr
,
S
Array
*
pExprInfo
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pCols
)
{
int32_t
exprTreeFromSqlExpr
(
SSqlCmd
*
pCmd
,
tExprNode
**
pExpr
,
const
tSQLExpr
*
pSqlExpr
,
S
QueryInfo
*
pQueryInfo
,
SArray
*
pCols
,
int64_t
*
uid
)
{
tExprNode
*
pLeft
=
NULL
;
tExprNode
*
pRight
=
NULL
;
if
(
pSqlExpr
->
pLeft
!=
NULL
)
{
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pLeft
,
pSqlExpr
->
pLeft
,
p
ExprInfo
,
pQueryInfo
,
pCols
);
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pLeft
,
pSqlExpr
->
pLeft
,
p
QueryInfo
,
pCols
,
uid
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
}
if
(
pSqlExpr
->
pRight
!=
NULL
)
{
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pRight
,
pSqlExpr
->
pRight
,
p
ExprInfo
,
pQueryInfo
,
pCols
);
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pRight
,
pSqlExpr
->
pRight
,
p
QueryInfo
,
pCols
,
uid
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
...
...
@@ -6400,14 +6400,19 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
strncpy
((
*
pExpr
)
->
pSchema
->
name
,
pSqlExpr
->
operand
.
z
,
pSqlExpr
->
operand
.
n
);
// set the input column data byte and type.
size_t
size
=
taosArrayGetSize
(
p
ExprInfo
);
size_t
size
=
taosArrayGetSize
(
p
QueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSqlExpr
*
p1
=
taosArrayGetP
(
p
ExprInfo
,
i
);
SSqlExpr
*
p1
=
taosArrayGetP
(
p
QueryInfo
->
exprList
,
i
);
if
(
strcmp
((
*
pExpr
)
->
pSchema
->
name
,
p1
->
aliasName
)
==
0
)
{
(
*
pExpr
)
->
pSchema
->
type
=
(
uint8_t
)
p1
->
resType
;
(
*
pExpr
)
->
pSchema
->
type
=
(
uint8_t
)
p1
->
resType
;
(
*
pExpr
)
->
pSchema
->
bytes
=
p1
->
resBytes
;
if
(
uid
!=
NULL
)
{
*
uid
=
p1
->
uid
;
}
break
;
}
}
...
...
src/client/src/tscServer.c
浏览文件 @
8e188274
...
...
@@ -1934,7 +1934,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
tscColumnListInsert
(
pQueryInfo
->
colList
,
&
index
);
TAOS_FIELD
f
=
tscCreateField
(
pSchema
->
type
,
pSchema
->
name
,
pSchema
->
bytes
);
S
FieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
S
InternalField
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
pTableSchema
[
i
].
bytes
,
false
);
...
...
src/client/src/tscSql.c
浏览文件 @
8e188274
...
...
@@ -370,7 +370,7 @@ int taos_num_fields(TAOS_RES *res) {
size_t
numOfCols
=
tscNumOfFields
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
S
FieldSupInfo
*
pInfo
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
S
InternalField
*
pInfo
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
pInfo
->
visible
)
{
num
++
;
}
...
...
@@ -406,8 +406,24 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
if
(
numOfCols
==
0
)
{
return
NULL
;
}
return
pQueryInfo
->
fieldsInfo
.
pFields
->
pData
;
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
if
(
pFieldInfo
->
final
==
NULL
)
{
TAOS_FIELD
*
f
=
calloc
(
pFieldInfo
->
numOfOutput
,
sizeof
(
TAOS_FIELD
));
int32_t
j
=
0
;
for
(
int32_t
i
=
0
;
i
<
pFieldInfo
->
numOfOutput
;
++
i
)
{
SInternalField
*
pField
=
tscFieldInfoGetInternalField
(
pFieldInfo
,
i
);
if
(
pField
->
visible
)
{
f
[
j
++
]
=
pField
->
field
;
}
}
pFieldInfo
->
final
=
f
;
}
return
pFieldInfo
->
final
;
}
int
taos_retrieve
(
TAOS_RES
*
res
)
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
8e188274
...
...
@@ -2013,7 +2013,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
static
char
*
getResultBlockPosition
(
SSqlCmd
*
pCmd
,
SSqlRes
*
pRes
,
int32_t
columnIndex
,
int16_t
*
bytes
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
FieldSupInfo
*
pInfo
=
(
SFieldSupInfo
*
)
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
columnIndex
);
S
InternalField
*
pInfo
=
(
SInternalField
*
)
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
internalField
,
columnIndex
);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
*
bytes
=
pInfo
->
pSqlExpr
->
resBytes
;
...
...
@@ -2163,7 +2163,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
S
FieldSupInfo
*
pSup
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
S
InternalField
*
pSup
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
}
...
...
@@ -2173,7 +2173,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
continue
;
}
TAOS_FIELD
*
pField
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
pFields
,
i
);
TAOS_FIELD
*
pField
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
pRes
->
tsrow
[
i
]
!=
NULL
&&
pField
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
transferNcharData
(
pSql
,
i
,
pField
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
8e188274
...
...
@@ -847,35 +847,30 @@ TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) {
return
f
;
}
S
FieldSupInfo
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
)
{
S
InternalField
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
)
{
assert
(
pFieldInfo
!=
NULL
);
taosArrayPush
(
pFieldInfo
->
pFields
,
pField
);
pFieldInfo
->
numOfOutput
++
;
struct
S
FieldSupInfo
info
=
{
struct
S
InternalField
info
=
{
.
pSqlExpr
=
NULL
,
.
pArithExprInfo
=
NULL
,
.
visible
=
true
,
};
return
taosArrayPush
(
pFieldInfo
->
pSupportInfo
,
&
info
);
}
SFieldSupInfo
*
tscFieldInfoGetSupp
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
)
{
return
TARRAY_GET_ELEM
(
pFieldInfo
->
pSupportInfo
,
index
);
info
.
field
=
*
pField
;
return
taosArrayPush
(
pFieldInfo
->
internalField
,
&
info
);
}
SFieldSupInfo
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
)
{
taosArrayInsert
(
pFieldInfo
->
pFields
,
index
,
field
);
SInternalField
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
)
{
pFieldInfo
->
numOfOutput
++
;
struct
SFieldSupInfo
info
=
{
struct
SInternalField
info
=
{
.
pSqlExpr
=
NULL
,
.
pArithExprInfo
=
NULL
,
.
visible
=
true
,
};
return
taosArrayInsert
(
pFieldInfo
->
pSupportInfo
,
index
,
&
info
);
info
.
field
=
*
field
;
return
taosArrayInsert
(
pFieldInfo
->
internalField
,
index
,
&
info
);
}
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
)
{
...
...
@@ -909,29 +904,18 @@ void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo) {
}
}
void
tscFieldInfoCopy
(
SFieldInfo
*
dst
,
const
SFieldInfo
*
src
)
{
dst
->
numOfOutput
=
src
->
numOfOutput
;
if
(
dst
->
pFields
==
NULL
)
{
dst
->
pFields
=
taosArrayClone
(
src
->
pFields
);
}
else
{
taosArrayCopy
(
dst
->
pFields
,
src
->
pFields
);
}
if
(
dst
->
pSupportInfo
==
NULL
)
{
dst
->
pSupportInfo
=
taosArrayClone
(
src
->
pSupportInfo
);
}
else
{
taosArrayCopy
(
dst
->
pSupportInfo
,
src
->
pSupportInfo
);
}
SInternalField
*
tscFieldInfoGetInternalField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
)
{
assert
(
index
<
pFieldInfo
->
numOfOutput
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
index
);
}
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
)
{
assert
(
index
<
pFieldInfo
->
numOfOutput
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
pFields
,
index
)
;
return
&
((
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
index
))
->
field
;
}
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
)
{
S
FieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
index
);
S
InternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
index
);
assert
(
pInfo
!=
NULL
&&
pInfo
->
pSqlExpr
!=
NULL
);
return
pInfo
->
pSqlExpr
->
offset
;
...
...
@@ -978,10 +962,8 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
return
;
}
taosArrayDestroy
(
pFieldInfo
->
pFields
);
for
(
int32_t
i
=
0
;
i
<
pFieldInfo
->
numOfOutput
;
++
i
)
{
S
FieldSupInfo
*
pInfo
=
taosArrayGet
(
pFieldInfo
->
pSupportInfo
,
i
);
S
InternalField
*
pInfo
=
taosArrayGet
(
pFieldInfo
->
internalField
,
i
);
if
(
pInfo
->
pArithExprInfo
!=
NULL
)
{
tExprTreeDestroy
(
&
pInfo
->
pArithExprInfo
->
pExpr
,
NULL
);
...
...
@@ -989,7 +971,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
}
}
taosArrayDestroy
(
pFieldInfo
->
pSupportInfo
);
taosArrayDestroy
(
pFieldInfo
->
internalField
);
memset
(
pFieldInfo
,
0
,
sizeof
(
SFieldInfo
));
}
...
...
@@ -1633,11 +1615,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
}
void
tscInitQueryInfo
(
SQueryInfo
*
pQueryInfo
)
{
assert
(
pQueryInfo
->
fieldsInfo
.
pFields
==
NULL
);
pQueryInfo
->
fieldsInfo
.
pFields
=
taosArrayInit
(
4
,
sizeof
(
TAOS_FIELD
));
assert
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
==
NULL
);
pQueryInfo
->
fieldsInfo
.
pSupportInfo
=
taosArrayInit
(
4
,
sizeof
(
SFieldSupInfo
));
assert
(
pQueryInfo
->
fieldsInfo
.
internalField
==
NULL
);
pQueryInfo
->
fieldsInfo
.
internalField
=
taosArrayInit
(
4
,
sizeof
(
SInternalField
));
assert
(
pQueryInfo
->
exprList
==
NULL
);
pQueryInfo
->
exprList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
...
@@ -1849,54 +1828,23 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
return
pNew
;
}
// current sql function is not direct output result, so create a dummy output field
static
void
doSetNewFieldInfo
(
SQueryInfo
*
pNewQueryInfo
,
SSqlExpr
*
pExpr
)
{
TAOS_FIELD
f
=
{.
type
=
(
uint8_t
)
pExpr
->
resType
,
.
bytes
=
pExpr
->
resBytes
};
tstrncpy
(
f
.
name
,
pExpr
->
aliasName
,
sizeof
(
f
.
name
));
SFieldSupInfo
*
pInfo1
=
tscFieldInfoAppend
(
&
pNewQueryInfo
->
fieldsInfo
,
&
f
);
pInfo1
->
pSqlExpr
=
pExpr
;
pInfo1
->
visible
=
false
;
}
static
void
doSetSqlExprAndResultFieldInfo
(
SQueryInfo
*
pQueryInfo
,
SQueryInfo
*
pNewQueryInfo
,
int64_t
uid
)
{
int32_t
numOfOutput
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
if
(
numOfOutput
==
0
)
{
return
;
}
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
// set the field info in pNewQueryInfo object
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
p
New
QueryInfo
,
i
);
if
(
pExpr
->
uid
==
uid
)
{
if
(
i
<
pFieldInfo
->
numOfOutput
)
{
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
i
);
if
(
pInfo
->
pSqlExpr
!=
NULL
)
{
TAOS_FIELD
*
p
=
tscFieldInfoGetField
(
pFieldInfo
,
i
);
assert
(
strcmp
(
p
->
name
,
pExpr
->
aliasName
)
==
0
);
SFieldSupInfo
*
pInfo1
=
tscFieldInfoAppend
(
&
pNewQueryInfo
->
fieldsInfo
,
p
);
*
pInfo1
=
*
pInfo
;
}
else
{
assert
(
pInfo
->
pArithExprInfo
!=
NULL
);
doSetNewFieldInfo
(
pNewQueryInfo
,
pExpr
);
}
}
else
{
// it is a arithmetic column, does not have actual field for sqlExpr, so build it
doSetNewFieldInfo
(
pNewQueryInfo
,
pExpr
);
}
}
TAOS_FIELD
f
=
tscCreateField
(
pExpr
->
resType
,
pExpr
->
aliasName
,
pExpr
->
resBytes
);
SInternalField
*
pInfo1
=
tscFieldInfoAppend
(
&
pNewQueryInfo
->
fieldsInfo
,
&
f
);
pInfo1
->
pSqlExpr
=
pExpr
;
}
// make sure the the sqlExpr for each fields is correct
numOfExprs
=
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
// update the pSqlExpr pointer in SFieldSupInfo according the field name
// update the pSqlExpr pointer in SInternalField according the field name
// make sure the pSqlExpr point to the correct SqlExpr in pNewQueryInfo, not SqlExpr in pQueryInfo
for
(
int32_t
f
=
0
;
f
<
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
f
)
{
TAOS_FIELD
*
field
=
tscFieldInfoGetField
(
&
pNewQueryInfo
->
fieldsInfo
,
f
);
...
...
@@ -1906,7 +1854,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p
SSqlExpr
*
pExpr1
=
tscSqlExprGet
(
pNewQueryInfo
,
k1
);
if
(
strcmp
(
field
->
name
,
pExpr1
->
aliasName
)
==
0
)
{
// establish link according to the result field name
S
FieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pNewQueryInfo
->
fieldsInfo
,
f
);
S
InternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pNewQueryInfo
->
fieldsInfo
,
f
);
pInfo
->
pSqlExpr
=
pExpr1
;
matched
=
true
;
...
...
src/inc/taosmsg.h
浏览文件 @
8e188274
...
...
@@ -407,6 +407,7 @@ typedef struct SExprInfo {
int16_t
bytes
;
int16_t
type
;
int32_t
interBytes
;
int64_t
uid
;
}
SExprInfo
;
typedef
struct
SColumnFilterInfo
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录