Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f2016993
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看板
提交
f2016993
编写于
1月 02, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the union support in sql parser: fix some bugs. #1032. [TBASE-1140]
上级
c9827141
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
589 addition
and
531 deletion
+589
-531
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-3
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+70
-88
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+7
-9
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+179
-148
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+142
-114
src/client/src/tscSQLParserImpl.c
src/client/src/tscSQLParserImpl.c
+2
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+147
-143
src/client/src/tscSql.c
src/client/src/tscSql.c
+7
-7
src/client/src/tscStream.c
src/client/src/tscStream.c
+4
-4
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+19
-14
src/inc/tsdb.h
src/inc/tsdb.h
+8
-1
src/system/detail/src/vnodeShell.c
src/system/detail/src/vnodeShell.c
+1
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
f2016993
...
@@ -110,7 +110,7 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
...
@@ -110,7 +110,7 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
int32_t
setMeterID
(
S
SqlObj
*
pSql
,
int32_t
subClauseIndex
,
SSQLToken
*
pzTableName
,
int32_t
tableIndex
);
int32_t
setMeterID
(
S
MeterMetaInfo
*
pMeterMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
...
@@ -198,8 +198,8 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd);
...
@@ -198,8 +198,8 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd);
void
tscGetMetricMetaCacheKey
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
char
*
keyStr
,
uint64_t
uid
);
void
tscGetMetricMetaCacheKey
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
char
*
meterId
,
int32_t
tableIndex
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
SMeterMetaInfo
*
pMeterMetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
char
*
meterId
,
bool
createIfNotExists
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
SMeterMetaInfo
*
pMeterMetaInfo
,
bool
createIfNotExists
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
...
...
src/client/inc/tsclient.h
浏览文件 @
f2016993
...
@@ -55,17 +55,17 @@ typedef struct SSqlGroupbyExpr {
...
@@ -55,17 +55,17 @@ typedef struct SSqlGroupbyExpr {
}
SSqlGroupbyExpr
;
}
SSqlGroupbyExpr
;
typedef
struct
SMeterMetaInfo
{
typedef
struct
SMeterMetaInfo
{
SMeterMeta
*
pMeterMeta
;
// metermeta
SMeterMeta
*
pMeterMeta
;
// metermeta
SMetricMeta
*
pMetricMeta
;
// metricmeta
SMetricMeta
*
pMetricMeta
;
// metricmeta
/*
/*
* 1. keep the vnode index during the multi-vnode super table projection query
* 1. keep the vnode index during the multi-vnode super table projection query
* 2. keep the vnode index for multi-vnode insertion
* 2. keep the vnode index for multi-vnode insertion
*/
*/
int32_t
vnodeIndex
;
int32_t
vnodeIndex
;
char
name
[
TSDB_METER_ID_LEN
+
1
];
// table(super table) name
char
name
[
TSDB_METER_ID_LEN
+
1
];
// table(super table) name
int16_t
numOfTags
;
// total required tags in query, including groupby tags
int16_t
numOfTags
;
// total required tags in query, including groupby tags
int16_t
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
int16_t
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
}
SMeterMetaInfo
;
}
SMeterMetaInfo
;
/* the structure for sql function in select clause */
/* the structure for sql function in select clause */
...
@@ -170,23 +170,23 @@ typedef struct SParamInfo {
...
@@ -170,23 +170,23 @@ typedef struct SParamInfo {
}
SParamInfo
;
}
SParamInfo
;
typedef
struct
STableDataBlocks
{
typedef
struct
STableDataBlocks
{
char
meterId
[
TSDB_METER_ID_LEN
];
char
meterId
[
TSDB_METER_ID_LEN
];
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
bool
ordered
;
// if current rows are ordered or not
bool
ordered
;
// if current rows are ordered or not
int64_t
vgid
;
// virtual group id
int64_t
vgid
;
// virtual group id
int64_t
prevTS
;
// previous timestamp, recorded to decide if the records array is ts ascending
int64_t
prevTS
;
// previous timestamp, recorded to decide if the records array is ts ascending
int32_t
numOfMeters
;
// number of tables in current submit block
int32_t
numOfMeters
;
// number of tables in current submit block
int32_t
rowSize
;
// row size for current table
int32_t
rowSize
;
// row size for current table
uint32_t
nAllocSize
;
uint32_t
nAllocSize
;
uint32_t
size
;
uint32_t
size
;
/*
/*
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* to avoid it to be removed from cache
* to avoid it to be removed from cache
*/
*/
SMeterMeta
*
pMeterMeta
;
SMeterMeta
*
pMeterMeta
;
union
{
union
{
char
*
filename
;
char
*
filename
;
char
*
pData
;
char
*
pData
;
...
@@ -208,79 +208,61 @@ typedef struct SDataBlockList {
...
@@ -208,79 +208,61 @@ typedef struct SDataBlockList {
}
SDataBlockList
;
}
SDataBlockList
;
typedef
struct
SQueryInfo
{
typedef
struct
SQueryInfo
{
uint16_t
type
;
// query
type
uint16_t
type
;
// query/insert/import
type
char
intervalTimeUnit
;
char
intervalTimeUnit
;
int64_t
etime
,
stime
;
int64_t
etime
,
stime
;
int64_t
nAggTimeInterval
;
// aggregation time interval
int64_t
nAggTimeInterval
;
// aggregation time interval
int64_t
nSlidingTime
;
// sliding window in mseconds
int64_t
nSlidingTime
;
// sliding window in mseconds
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SColumnBaseInfo
colList
;
SColumnBaseInfo
colList
;
SFieldInfo
fieldsInfo
;
SFieldInfo
fieldsInfo
;
SSqlExprInfo
exprsInfo
;
SSqlExprInfo
exprsInfo
;
SLimitVal
limit
;
SLimitVal
limit
;
SLimitVal
slimit
;
SLimitVal
slimit
;
STagCond
tagCond
;
STagCond
tagCond
;
SOrderVal
order
;
SOrderVal
order
;
int16_t
interpoType
;
// interpolate type
int16_t
interpoType
;
// interpolate type
int16_t
numOfTables
;
int16_t
numOfTables
;
SMeterMetaInfo
**
pMeterInfo
;
SMeterMetaInfo
**
pMeterInfo
;
struct
STSBuf
*
tsBuf
;
struct
STSBuf
*
tsBuf
;
// todo use dynamic allocated memory for defaultVal
int64_t
*
defaultVal
;
// default value for interpolation
int64_t
defaultVal
[
TSDB_MAX_COLUMNS
];
// default value for interpolation
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
}
SQueryInfo
;
}
SQueryInfo
;
// data source from sql string or from file
enum
{
DATA_FROM_SQL_STRING
=
1
,
DATA_FROM_DATA_FILE
=
2
,
};
typedef
struct
{
typedef
struct
{
// SOrderVal order;
int
command
;
int
command
;
uint8_t
msgType
;
int
count
;
// TODO refactor
union
{
union
{
bool
existsCheck
;
// check if the table exists
bool
existsCheck
;
// check if the table exists or not
bool
import
;
// import/insert type
bool
inStream
;
// denote if current sql is executed in stream or not
bool
createOnDemand
;
// if the table is missing, on-the-fly create it. during getmeterMeta
int8_t
dataSourceType
;
// load data from file or not
};
};
int8_t
isInsertFromFile
;
// load data from file or not
union
{
uint8_t
msgType
;
int32_t
count
;
int32_t
numOfTablesInSubmit
;
};
/*
short
numOfCols
;
* use to keep short request msg and error msg, in such case, SSqlCmd->payload == SSqlCmd->ext;
uint32_t
allocSize
;
* create table/query/insert operations will exceed the TSDB_SQLCMD_SIZE.
char
*
payload
;
*
int
payloadLen
;
* In such cases, allocate the memory dynamically, and need to free the memory
int64_t
globalLimit
;
*/
SQueryInfo
**
pQueryInfo
;
uint32_t
allocSize
;
int32_t
numOfClause
;
char
*
payload
;
int
payloadLen
;
short
numOfCols
;
int64_t
globalLimit
;
SQueryInfo
**
pQueryInfo
;
int32_t
numOfClause
;
// char intervalTimeUnit;
// int64_t etime, stime;
// int64_t nAggTimeInterval; // aggregation time interval
// int64_t nSlidingTime; // sliding window in mseconds
// SSqlGroupbyExpr groupbyExpr; // group by tags info
//
// SColumnBaseInfo colList;
// SFieldInfo fieldsInfo;
// SSqlExprInfo exprsInfo;
// SLimitVal limit;
// SLimitVal slimit;
// STagCond tagCond;
// int16_t interpoType; // interpolate type
// int16_t numOfTables;
// SMeterMetaInfo **pMeterInfo;
// struct STSBuf * tsBuf;
// // todo use dynamic allocated memory for defaultVal
// int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation
// submit data blocks branched according to vnode
// submit data blocks branched according to vnode
SDataBlockList
*
pDataBlocks
;
SDataBlockList
*
pDataBlocks
;
// for parameter ('?') binding and batch processing
// for parameter ('?') binding and batch processing
int32_t
batchSize
;
int32_t
batchSize
;
...
@@ -359,8 +341,8 @@ typedef struct _sql_obj {
...
@@ -359,8 +341,8 @@ typedef struct _sql_obj {
SSqlCmd
cmd
;
SSqlCmd
cmd
;
SSqlRes
res
;
SSqlRes
res
;
uint8_t
numOfSubs
;
uint8_t
numOfSubs
;
char
*
asyncTblPos
;
char
*
asyncTblPos
;
void
*
pTableHashList
;
void
*
pTableHashList
;
struct
_sql_obj
**
pSubs
;
struct
_sql_obj
**
pSubs
;
struct
_sql_obj
*
prev
,
*
next
;
struct
_sql_obj
*
prev
,
*
next
;
}
SSqlObj
;
}
SSqlObj
;
...
@@ -402,7 +384,7 @@ typedef struct {
...
@@ -402,7 +384,7 @@ typedef struct {
// tscSql API
// tscSql API
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
void
tscInitMsgs
();
void
tscInitMsgs
();
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
void
*
tscProcessMsgFromServer
(
char
*
msg
,
void
*
ahandle
,
void
*
thandle
);
void
*
tscProcessMsgFromServer
(
char
*
msg
,
void
*
ahandle
,
void
*
thandle
);
...
@@ -423,12 +405,12 @@ int taos_retrieve(TAOS_RES *res);
...
@@ -423,12 +405,12 @@ int taos_retrieve(TAOS_RES *res);
* transfer function for metric query in stream computing, the function need to be change
* transfer function for metric query in stream computing, the function need to be change
* before send query message to vnode
* before send query message to vnode
*/
*/
int32_t
tscTansformSQLFunctionFor
MetricQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscTansformSQLFunctionFor
STableQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
);
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
);
int32_t
tscCreateResPointerInfo
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
int32_t
tscCreateResPointerInfo
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
void
tscFreeSqlCmdData
(
SSqlCmd
*
pCmd
);
void
tscFreeSqlCmdData
(
SSqlCmd
*
pCmd
);
...
@@ -449,14 +431,14 @@ void tscFreeSqlObj(SSqlObj *pObj);
...
@@ -449,14 +431,14 @@ void tscFreeSqlObj(SSqlObj *pObj);
void
tscCloseTscObj
(
STscObj
*
pObj
);
void
tscCloseTscObj
(
STscObj
*
pObj
);
void
tscProcessMultiVnodesInsert
(
SSqlObj
*
pSql
);
void
tscProcessMultiVnodesInsert
(
SSqlObj
*
pSql
);
void
tscProcessMultiVnodesInsertFor
File
(
SSqlObj
*
pSql
);
void
tscProcessMultiVnodesInsertFrom
File
(
SSqlObj
*
pSql
);
void
tscKillMetricQuery
(
SSqlObj
*
pSql
);
void
tscKillMetricQuery
(
SSqlObj
*
pSql
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
bool
tscIsUpdateQuery
(
STscObj
*
pObj
);
bool
tscIsUpdateQuery
(
STscObj
*
pObj
);
bool
tscHasReachLimitation
(
SSqlObj
*
pSql
);
bool
tscHasReachLimitation
(
SSqlObj
*
pSql
);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
...
...
src/client/src/tscAsync.c
浏览文件 @
f2016993
...
@@ -413,13 +413,13 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -413,13 +413,13 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
assert
(
!
pCmd
->
isInsertFromFile
&&
pSql
->
signature
==
pSql
);
assert
(
pCmd
->
dataSourceType
!=
0
&&
pSql
->
signature
==
pSql
);
int32_t
index
=
0
;
int32_t
index
=
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
index
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
FromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
...
@@ -456,7 +456,6 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -456,7 +456,6 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
SSqlObj
*
pSql
=
(
SSqlObj
*
)
param
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
param
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
@@ -480,7 +479,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -480,7 +479,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
pMeterMetaInfo
->
pMeterMeta
==
NULL
);
assert
(
pMeterMetaInfo
->
pMeterMeta
==
NULL
);
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
,
0
);
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
);
code
=
tscSendMsgToServer
(
pSql
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
pRes
->
code
=
code
;
...
@@ -513,7 +512,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -513,7 +512,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace
(
"%p get metricMeta during metric query successfully"
,
pSql
);
tscTrace
(
"%p get metricMeta during metric query successfully"
,
pSql
);
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
@@ -529,12 +528,11 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -529,12 +528,11 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
}
else
{
// stream computing
}
else
{
// stream computing
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
if
(
code
==
TSDB_CODE_SUCCESS
&&
UTIL_METER_IS_SUPERTABLE
(
pMeterMetaInfo
))
{
if
(
code
==
TSDB_CODE_SUCCESS
&&
UTIL_METER_IS_SUPERTABLE
(
pMeterMetaInfo
))
{
code
=
tscGetMetricMeta
(
pSql
);
code
=
tscGetMetricMeta
(
pSql
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
...
@@ -557,7 +555,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -557,7 +555,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
*/
*/
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
tscTansformSQLFunctionFor
Metric
Query
(
pQueryInfo
);
tscTansformSQLFunctionFor
STable
Query
(
pQueryInfo
);
tscIncStreamExecutionCount
(
pSql
->
pStream
);
tscIncStreamExecutionCount
(
pSql
->
pStream
);
}
else
{
}
else
{
tscTrace
(
"%p get meterMeta/metricMeta successfully"
,
pSql
);
tscTrace
(
"%p get meterMeta/metricMeta successfully"
,
pSql
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
f2016993
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
f2016993
此差异已折叠。
点击以展开。
src/client/src/tscSQLParserImpl.c
浏览文件 @
f2016993
...
@@ -589,6 +589,8 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
...
@@ -589,6 +589,8 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
SQuerySQL
*
pQuerySql
=
pClause
->
pClause
[
i
];
SQuerySQL
*
pQuerySql
=
pClause
->
pClause
[
i
];
doDestroyQuerySql
(
pQuerySql
);
doDestroyQuerySql
(
pQuerySql
);
}
}
tfree
(
pClause
->
pClause
);
}
}
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
pStableName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
pStableName
,
...
...
src/client/src/tscServer.c
浏览文件 @
f2016993
此差异已折叠。
点击以展开。
src/client/src/tscSql.c
浏览文件 @
f2016993
...
@@ -298,8 +298,11 @@ int taos_num_fields(TAOS_RES *res) {
...
@@ -298,8 +298,11 @@ int taos_num_fields(TAOS_RES *res) {
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
pQueryInfo
==
NULL
)
{
return
0
;
}
SFieldInfo
*
pFieldsInfo
=
&
pQueryInfo
->
fieldsInfo
;
SFieldInfo
*
pFieldsInfo
=
&
pQueryInfo
->
fieldsInfo
;
return
(
pFieldsInfo
->
numOfOutputCols
-
pFieldsInfo
->
numOfHiddenCols
);
return
(
pFieldsInfo
->
numOfOutputCols
-
pFieldsInfo
->
numOfHiddenCols
);
}
}
...
@@ -993,11 +996,8 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -993,11 +996,8 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
int
code
=
TSDB_CODE_INVALID_METER_ID
;
int
code
=
TSDB_CODE_INVALID_METER_ID
;
char
*
str
=
(
char
*
)
tblNameList
;
char
*
str
=
(
char
*
)
tblNameList
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
NULL
;
if
(
pQueryInfo
==
NULL
)
{
tscGetQueryInfoDetailSafely
(
pCmd
,
0
,
&
pQueryInfo
);
tscAddSubqueryInfo
(
pCmd
);
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
}
SMeterMetaInfo
*
pMeterMetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
...
@@ -1034,7 +1034,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1034,7 +1034,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
return
code
;
return
code
;
}
}
if
((
code
=
setMeterID
(
p
Sql
,
0
,
&
sToken
,
0
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
setMeterID
(
p
MeterMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
...
src/client/src/tscStream.c
浏览文件 @
f2016993
...
@@ -70,7 +70,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
...
@@ -70,7 +70,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
,
0
);
int
code
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
);
pSql
->
res
.
code
=
code
;
pSql
->
res
.
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
@@ -82,7 +82,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
...
@@ -82,7 +82,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
}
}
tscTansformSQLFunctionFor
Metric
Query
(
pQueryInfo
);
tscTansformSQLFunctionFor
STable
Query
(
pQueryInfo
);
// failed to get meter/metric meta, retry in 10sec.
// failed to get meter/metric meta, retry in 10sec.
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -391,6 +391,7 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
...
@@ -391,6 +391,7 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
}
}
pStream
->
slidingTime
=
pQueryInfo
->
nSlidingTime
;
pStream
->
slidingTime
=
pQueryInfo
->
nSlidingTime
;
pQueryInfo
->
nAggTimeInterval
=
0
;
// clear the interval value to avoid the force time window split by query processor
}
}
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
stime
)
{
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
stime
)
{
...
@@ -507,8 +508,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -507,8 +508,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
return
NULL
;
return
NULL
;
}
}
// TODO later refactor use enum
pSql
->
cmd
.
inStream
=
1
;
// 1 means sql in stream, allowed the sliding clause.
pSql
->
cmd
.
count
=
1
;
// 1 means sql in stream, allowed the sliding clause.
pRes
->
code
=
tscToSQLCmd
(
pSql
,
&
SQLInfo
);
pRes
->
code
=
tscToSQLCmd
(
pSql
,
&
SQLInfo
);
SQLInfoDestroy
(
&
SQLInfo
);
SQLInfoDestroy
(
&
SQLInfo
);
...
...
src/client/src/tscUtil.c
浏览文件 @
f2016993
...
@@ -319,7 +319,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
...
@@ -319,7 +319,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
}
}
pQueryInfo
->
interpoType
=
TSDB_INTERPO_NONE
;
pQueryInfo
->
interpoType
=
TSDB_INTERPO_NONE
;
memset
(
pQueryInfo
->
defaultVal
,
0
,
sizeof
(
pQueryInfo
->
defaultVal
)
);
tfree
(
pQueryInfo
->
defaultVal
);
}
}
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
)
{
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
)
{
...
@@ -398,20 +398,20 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
...
@@ -398,20 +398,20 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
tfree
(
pSql
->
sqlstr
);
tfree
(
pSql
->
sqlstr
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tfree
(
p
Sql
->
res
.
pRsp
);
tfree
(
p
Res
->
pRsp
);
p
Sql
->
res
.
row
=
0
;
p
Res
->
row
=
0
;
p
Sql
->
res
.
numOfRows
=
0
;
p
Res
->
numOfRows
=
0
;
p
Sql
->
res
.
numOfTotal
=
0
;
p
Res
->
numOfTotal
=
0
;
p
Sql
->
res
.
numOfGroups
=
0
;
p
Res
->
numOfGroups
=
0
;
tfree
(
p
Sql
->
res
.
pGroupRec
);
tfree
(
p
Res
->
pGroupRec
);
tscDestroyLocalReducer
(
pSql
);
tscDestroyLocalReducer
(
pSql
);
tfree
(
pSql
->
pSubs
);
tfree
(
pSql
->
pSubs
);
pSql
->
numOfSubs
=
0
;
pSql
->
numOfSubs
=
0
;
tscDestroyResPointerInfo
(
pRes
);
tscDestroyResPointerInfo
(
pRes
);
tfree
(
p
Sql
->
res
.
pColumnIndex
);
tfree
(
p
Res
->
pColumnIndex
);
tscFreeSqlCmdData
(
pCmd
);
tscFreeSqlCmdData
(
pCmd
);
}
}
...
@@ -535,7 +535,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
...
@@ -535,7 +535,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
assert
(
pDataBlock
->
pMeterMeta
!=
NULL
);
assert
(
pDataBlock
->
pMeterMeta
!=
NULL
);
pCmd
->
coun
t
=
pDataBlock
->
numOfMeters
;
pCmd
->
numOfTablesInSubmi
t
=
pDataBlock
->
numOfMeters
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
// set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
// set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
...
@@ -1548,7 +1548,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
...
@@ -1548,7 +1548,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
tscTrace
(
"%p object should be release since all data blocks have been submit"
,
pSql
);
tscTrace
(
"%p object should be release since all data blocks have been submit"
,
pSql
);
...
@@ -1664,6 +1664,8 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
...
@@ -1664,6 +1664,8 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
memset
(
&
pQueryInfo
->
colList
,
0
,
sizeof
(
pQueryInfo
->
colList
));
memset
(
&
pQueryInfo
->
colList
,
0
,
sizeof
(
pQueryInfo
->
colList
));
pQueryInfo
->
tsBuf
=
tsBufDestory
(
pQueryInfo
->
tsBuf
);
pQueryInfo
->
tsBuf
=
tsBufDestory
(
pQueryInfo
->
tsBuf
);
tfree
(
pQueryInfo
->
defaultVal
);
}
}
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
...
@@ -1814,15 +1816,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -1814,15 +1816,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
memcpy
(
pNewQueryInfo
,
pQueryInfo
,
sizeof
(
SQueryInfo
));
memcpy
(
pNewQueryInfo
,
pQueryInfo
,
sizeof
(
SQueryInfo
));
pNewQueryInfo
->
pMeterInfo
=
NULL
;
memset
(
&
pNewQueryInfo
->
colList
,
0
,
sizeof
(
pNewQueryInfo
->
colList
));
memset
(
&
pNewQueryInfo
->
colList
,
0
,
sizeof
(
pNewQueryInfo
->
colList
));
memset
(
&
pNewQueryInfo
->
fieldsInfo
,
0
,
sizeof
(
SFieldInfo
));
memset
(
&
pNewQueryInfo
->
fieldsInfo
,
0
,
sizeof
(
SFieldInfo
));
pNewQueryInfo
->
pMeterInfo
=
NULL
;
pNewQueryInfo
->
defaultVal
=
NULL
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
tsBuf
=
NULL
;
pNewQueryInfo
->
tsBuf
=
NULL
;
tscTagCondCopy
(
&
pNewQueryInfo
->
tagCond
,
&
pQueryInfo
->
tagCond
);
tscTagCondCopy
(
&
pNewQueryInfo
->
tagCond
,
&
pQueryInfo
->
tagCond
);
pNewQueryInfo
->
defaultVal
=
malloc
(
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
*
sizeof
(
int64_t
));
memcpy
(
pNewQueryInfo
->
defaultVal
,
pQueryInfo
->
defaultVal
,
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
*
sizeof
(
int64_t
));
if
(
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
pMeterMetaInfo
->
vnodeIndex
);
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
pMeterMetaInfo
->
vnodeIndex
);
...
@@ -1910,8 +1915,8 @@ void tscDoQuery(SSqlObj* pSql) {
...
@@ -1910,8 +1915,8 @@ void tscDoQuery(SSqlObj* pSql) {
tscAddIntoSqlList
(
pSql
);
tscAddIntoSqlList
(
pSql
);
}
}
if
(
pCmd
->
isInsertFromFile
==
1
)
{
if
(
pCmd
->
dataSourceType
==
DATA_FROM_DATA_FILE
)
{
tscProcessMultiVnodesInsertF
or
File
(
pSql
);
tscProcessMultiVnodesInsertF
rom
File
(
pSql
);
}
else
{
}
else
{
// pSql may be released in this function if it is a async insertion.
// pSql may be released in this function if it is a async insertion.
tscProcessSql
(
pSql
);
tscProcessSql
(
pSql
);
...
...
src/inc/tsdb.h
浏览文件 @
f2016993
...
@@ -208,7 +208,7 @@ extern "C" {
...
@@ -208,7 +208,7 @@ extern "C" {
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_QUERY_TYPE_
QUERY 0 // normal query
#define TSDB_QUERY_TYPE_
NON_TYPE 0x00U // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01U // free qhandle at vnode
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01U // free qhandle at vnode
/*
/*
...
@@ -224,6 +224,13 @@ extern "C" {
...
@@ -224,6 +224,13 @@ extern "C" {
#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40U // select *,columns... query
#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40U // select *,columns... query
#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80U // join sub query at the second stage
#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80U // join sub query at the second stage
#define TSDB_QUERY_TYPE_INSERT 0x100U // insert type
#define TSDB_QUERY_TYPE_IMPORT 0x200U // import data
#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0)
#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type))
#define TSDB_QUERY_RESET_TYPE(x) ((x) = TSDB_QUERY_TYPE_NON_TYPE)
#define TSQL_SO_ASC 1
#define TSQL_SO_ASC 1
#define TSQL_SO_DESC 0
#define TSQL_SO_DESC 0
...
...
src/system/detail/src/vnodeShell.c
浏览文件 @
f2016993
...
@@ -585,6 +585,7 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
...
@@ -585,6 +585,7 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
SShellSubmitMsg
*
pSubmit
=
&
shellSubmit
;
SShellSubmitMsg
*
pSubmit
=
&
shellSubmit
;
SShellSubmitBlock
*
pBlocks
=
NULL
;
SShellSubmitBlock
*
pBlocks
=
NULL
;
pSubmit
->
import
=
htons
(
pSubmit
->
import
);
pSubmit
->
vnode
=
htons
(
pSubmit
->
vnode
);
pSubmit
->
vnode
=
htons
(
pSubmit
->
vnode
);
pSubmit
->
numOfSid
=
htonl
(
pSubmit
->
numOfSid
);
pSubmit
->
numOfSid
=
htonl
(
pSubmit
->
numOfSid
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录