Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c18b6b1b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c18b6b1b
编写于
12月 30, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the union support in sql parser. #1032. [TBASE-1140]
上级
25fae2a1
变更
25
展开全部
隐藏空白更改
内联
并排
Showing
25 changed file
with
3674 addition
and
3438 deletion
+3674
-3438
src/client/inc/tscSQLParser.h
src/client/inc/tscSQLParser.h
+130
-96
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-0
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+47
-79
src/client/src/sql.c
src/client/src/sql.c
+1464
-1063
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+4
-4
src/client/src/tscJoinProcess.c
src/client/src/tscJoinProcess.c
+32
-32
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+7
-7
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+5
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+868
-1064
src/client/src/tscSQLParserImpl.c
src/client/src/tscSQLParserImpl.c
+189
-56
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+97
-97
src/client/src/tscServer.c
src/client/src/tscServer.c
+438
-582
src/client/src/tscSql.c
src/client/src/tscSql.c
+16
-16
src/client/src/tscStream.c
src/client/src/tscStream.c
+29
-29
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+141
-90
src/inc/hashutil.h
src/inc/hashutil.h
+1
-0
src/inc/sql.y
src/inc/sql.y
+90
-104
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-6
src/inc/tsqldef.h
src/inc/tsqldef.h
+95
-92
src/inc/tutil.h
src/inc/tutil.h
+0
-9
src/system/detail/inc/vnodeQueryImpl.h
src/system/detail/inc/vnodeQueryImpl.h
+3
-4
src/system/detail/inc/vnodeRead.h
src/system/detail/inc/vnodeRead.h
+1
-1
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+3
-3
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+4
-0
src/system/lite/src/mgmtShell.spec.c
src/system/lite/src/mgmtShell.spec.c
+2
-2
未找到文件。
src/client/inc/tscSQLParser.h
浏览文件 @
c18b6b1b
...
@@ -21,17 +21,77 @@ extern "C" {
...
@@ -21,17 +21,77 @@ extern "C" {
#endif
#endif
#include "taos.h"
#include "taos.h"
#include "taosmsg.h"
#include "tsqldef.h"
#include "tsqldef.h"
#include "ttypes.h"
#include "ttypes.h"
#include "taosmsg.h"
enum
_sql_cmd
{
TSDB_SQL_SELECT
=
1
,
TSDB_SQL_FETCH
,
TSDB_SQL_INSERT
,
TSDB_SQL_MGMT
,
// the SQL below is for mgmt node
TSDB_SQL_CREATE_DB
,
TSDB_SQL_CREATE_TABLE
,
TSDB_SQL_DROP_DB
,
TSDB_SQL_DROP_TABLE
,
TSDB_SQL_CREATE_ACCT
,
TSDB_SQL_CREATE_USER
,
//10
TSDB_SQL_DROP_ACCT
,
TSDB_SQL_DROP_USER
,
TSDB_SQL_ALTER_USER
,
TSDB_SQL_ALTER_ACCT
,
TSDB_SQL_ALTER_TABLE
,
TSDB_SQL_ALTER_DB
,
TSDB_SQL_CREATE_MNODE
,
TSDB_SQL_DROP_MNODE
,
TSDB_SQL_CREATE_DNODE
,
TSDB_SQL_DROP_DNODE
,
// 20
TSDB_SQL_CFG_DNODE
,
TSDB_SQL_CFG_MNODE
,
TSDB_SQL_SHOW
,
TSDB_SQL_RETRIEVE
,
TSDB_SQL_KILL_QUERY
,
TSDB_SQL_KILL_STREAM
,
TSDB_SQL_KILL_CONNECTION
,
TSDB_SQL_READ
,
// SQL below is for read operation
TSDB_SQL_CONNECT
,
TSDB_SQL_USE_DB
,
// 30
TSDB_SQL_META
,
TSDB_SQL_METRIC
,
TSDB_SQL_MULTI_META
,
TSDB_SQL_HB
,
TSDB_SQL_LOCAL
,
// SQL below for client local
TSDB_SQL_DESCRIBE_TABLE
,
TSDB_SQL_RETRIEVE_METRIC
,
TSDB_SQL_METRIC_JOIN_RETRIEVE
,
TSDB_SQL_RETRIEVE_TAGS
,
/*
* build empty result instead of accessing dnode to fetch result
* reset the client cache
*/
TSDB_SQL_RETRIEVE_EMPTY_RESULT
,
//40
TSDB_SQL_RESET_CACHE
,
TSDB_SQL_SERV_STATUS
,
TSDB_SQL_CURRENT_DB
,
TSDB_SQL_SERV_VERSION
,
TSDB_SQL_CLI_VERSION
,
TSDB_SQL_CURRENT_USER
,
TSDB_SQL_CFG_LOCAL
,
TSDB_SQL_MAX
//48
};
#define MAX_TOKEN_LEN 30
#define MAX_TOKEN_LEN 30
// token type
// token type
enum
{
enum
{
TSQL_NODE_TYPE_EXPR
=
0x1
,
TSQL_NODE_TYPE_EXPR
=
0x1
,
TSQL_NODE_TYPE_ID
=
0x2
,
TSQL_NODE_TYPE_ID
=
0x2
,
TSQL_NODE_TYPE_VALUE
=
0x4
,
TSQL_NODE_TYPE_VALUE
=
0x4
,
};
};
extern
char
tTokenTypeSwitcher
[
13
];
extern
char
tTokenTypeSwitcher
[
13
];
...
@@ -72,72 +132,12 @@ typedef struct tFieldList {
...
@@ -72,72 +132,12 @@ typedef struct tFieldList {
TAOS_FIELD
*
p
;
TAOS_FIELD
*
p
;
}
tFieldList
;
}
tFieldList
;
//
sql
operation type
//
create table
operation type
enum
TSQL_TYPE
{
enum
TSQL_TYPE
{
TSQL_CREATE_NORMAL_METER
=
0x01
,
TSQL_CREATE_TABLE
=
0x1
,
TSQL_CREATE_NORMAL_METRIC
=
0x02
,
TSQL_CREATE_STABLE
=
0x2
,
TSQL_CREATE_METER_FROM_METRIC
=
0x04
,
TSQL_CREATE_TABLE_FROM_STABLE
=
0x3
,
TSQL_CREATE_STREAM
=
0x08
,
TSQL_CREATE_STREAM
=
0x4
,
TSQL_QUERY_METER
=
0x10
,
TSQL_INSERT
=
0x20
,
DROP_DNODE
=
0x40
,
DROP_DATABASE
=
0x41
,
DROP_TABLE
=
0x42
,
DROP_USER
=
0x43
,
DROP_ACCOUNT
=
0x44
,
USE_DATABASE
=
0x50
,
// show operation
SHOW_DATABASES
=
0x60
,
SHOW_TABLES
=
0x61
,
SHOW_STABLES
=
0x62
,
SHOW_MNODES
=
0x63
,
SHOW_DNODES
=
0x64
,
SHOW_ACCOUNTS
=
0x65
,
SHOW_USERS
=
0x66
,
SHOW_VGROUPS
=
0x67
,
SHOW_QUERIES
=
0x68
,
SHOW_STREAMS
=
0x69
,
SHOW_CONFIGS
=
0x6a
,
SHOW_SCORES
=
0x6b
,
SHOW_MODULES
=
0x6c
,
SHOW_CONNECTIONS
=
0x6d
,
SHOW_GRANTS
=
0x6e
,
SHOW_VNODES
=
0x6f
,
// create dnode
CREATE_DNODE
=
0x80
,
CREATE_DATABASE
=
0x81
,
CREATE_USER
=
0x82
,
CREATE_ACCOUNT
=
0x83
,
DESCRIBE_TABLE
=
0x90
,
ALTER_USER_PASSWD
=
0xA0
,
ALTER_USER_PRIVILEGES
=
0xA1
,
ALTER_DNODE
=
0xA2
,
ALTER_LOCAL
=
0xA3
,
ALTER_DATABASE
=
0xA4
,
ALTER_ACCT
=
0xA5
,
// reset operation
RESET_QUERY_CACHE
=
0xB0
,
// alter tags
ALTER_TABLE_TAGS_ADD
=
0xC0
,
ALTER_TABLE_TAGS_DROP
=
0xC1
,
ALTER_TABLE_TAGS_CHG
=
0xC2
,
ALTER_TABLE_TAGS_SET
=
0xC4
,
// alter table column
ALTER_TABLE_ADD_COLUMN
=
0xD0
,
ALTER_TABLE_DROP_COLUMN
=
0xD1
,
KILL_QUERY
=
0xD2
,
KILL_STREAM
=
0xD3
,
KILL_CONNECTION
=
0xD4
,
};
};
typedef
struct
SQuerySQL
{
typedef
struct
SQuerySQL
{
...
@@ -157,33 +157,31 @@ typedef struct SQuerySQL {
...
@@ -157,33 +157,31 @@ typedef struct SQuerySQL {
typedef
struct
SCreateTableSQL
{
typedef
struct
SCreateTableSQL
{
struct
SSQLToken
name
;
// meter name, create table [meterName] xxx
struct
SSQLToken
name
;
// meter name, create table [meterName] xxx
bool
existCheck
;
bool
existCheck
;
int8_t
type
;
// create normal table/from super table/ stream
struct
{
struct
{
tFieldList
*
pTagColumns
;
// for normal table, pTagColumns = NULL;
tFieldList
*
pTagColumns
;
// for normal table, pTagColumns = NULL;
tFieldList
*
pColumns
;
tFieldList
*
pColumns
;
}
colInfo
;
}
colInfo
;
struct
{
struct
{
SSQLToken
metricName
;
// metric
name, for using clause
SSQLToken
stableName
;
// super table
name, for using clause
tVariantList
*
pTagVals
;
// create by using metric, tag value
tVariantList
*
pTagVals
;
// create by using metric, tag value
STagData
tagdata
;
}
usingInfo
;
}
usingInfo
;
SQuerySQL
*
pSelect
;
SQuerySQL
*
pSelect
;
}
SCreateTableSQL
;
}
SCreateTableSQL
;
typedef
struct
SAlterTableSQL
{
typedef
struct
SAlterTableSQL
{
SSQLToken
name
;
SSQLToken
name
;
int16_t
type
;
STagData
tagData
;
tFieldList
*
pAddColumns
;
tFieldList
*
pAddColumns
;
SSQLToken
dropTagToken
;
tVariantList
*
varList
;
// set t=val or: change src dst
tVariantList
*
varList
;
// set t=val or: change src dst
}
SAlterTableSQL
;
}
SAlterTableSQL
;
typedef
struct
SInsertSQL
{
SSQLToken
name
;
struct
tSQLExprListList
*
pValue
;
}
SInsertSQL
;
typedef
struct
SCreateDBInfo
{
typedef
struct
SCreateDBInfo
{
SSQLToken
dbname
;
SSQLToken
dbname
;
int32_t
replica
;
int32_t
replica
;
...
@@ -204,41 +202,68 @@ typedef struct SCreateDBInfo {
...
@@ -204,41 +202,68 @@ typedef struct SCreateDBInfo {
}
SCreateDBInfo
;
}
SCreateDBInfo
;
typedef
struct
SCreateAcctSQL
{
typedef
struct
SCreateAcctSQL
{
int32_t
u
sers
;
int32_t
maxU
sers
;
int32_t
d
bs
;
int32_t
maxD
bs
;
int32_t
ts
eries
;
int32_t
maxTimeS
eries
;
int32_t
s
treams
;
int32_t
maxS
treams
;
int32_t
pps
;
int32_t
maxPointsPerSecond
;
int64_t
s
torage
;
int64_t
maxS
torage
;
int64_t
qt
ime
;
int64_t
maxQueryT
ime
;
int32_t
con
ns
;
int32_t
maxConnectio
ns
;
SSQLToken
stat
;
SSQLToken
stat
;
}
SCreateAcctSQL
;
}
SCreateAcctSQL
;
typedef
struct
SShowInfo
{
uint8_t
showType
;
SSQLToken
prefix
;
SSQLToken
pattern
;
}
SShowInfo
;
typedef
struct
SUserInfo
{
SSQLToken
user
;
SSQLToken
passwd
;
// bool hasPasswd;
SSQLToken
privilege
;
// bool hasPrivilege;
int16_t
type
;
}
SUserInfo
;
typedef
struct
tDCLSQL
{
typedef
struct
tDCLSQL
{
int32_t
nTokens
;
/* Number of expressions on the list */
int32_t
nTokens
;
/* Number of expressions on the list */
int32_t
nAlloc
;
/* Number of entries allocated below */
int32_t
nAlloc
;
/* Number of entries allocated below */
SSQLToken
*
a
;
/* one entry for element */
SSQLToken
*
a
;
/* one entry for element */
bool
existsCheck
;
union
{
union
{
SCreateDBInfo
dbOpt
;
SCreateDBInfo
dbOpt
;
SCreateAcctSQL
acctOpt
;
SCreateAcctSQL
acctOpt
;
SShowInfo
showOpt
;
SSQLToken
ip
;
};
};
SUserInfo
user
;
}
tDCLSQL
;
}
tDCLSQL
;
typedef
struct
SSubclauseInfo
{
// "UNION" multiple select sub-clause
SQuerySQL
**
pClause
;
int32_t
numOfClause
;
}
SSubclauseInfo
;
typedef
struct
SSqlInfo
{
typedef
struct
SSqlInfo
{
int32_t
sqlT
ype
;
int32_t
t
ype
;
bool
valid
Sql
;
bool
valid
;
union
{
union
{
SCreateTableSQL
*
pCreateTableInfo
;
SCreateTableSQL
*
pCreateTableInfo
;
SInsertSQL
*
pInsertInfo
;
SAlterTableSQL
*
pAlterInfo
;
SAlterTableSQL
*
pAlterInfo
;
SQuerySQL
*
pQueryInfo
;
tDCLSQL
*
pDCLInfo
;
tDCLSQL
*
pDCLInfo
;
};
};
char
pzErrMsg
[
256
];
SSubclauseInfo
subclauseInfo
;
char
pzErrMsg
[
256
];
}
SSqlInfo
;
}
SSqlInfo
;
typedef
struct
tSQLExpr
{
typedef
struct
tSQLExpr
{
...
@@ -338,31 +363,40 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
...
@@ -338,31 +363,40 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
pMetricName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
pMetricName
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
);
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
);
void
tSQLExprDestroy
(
tSQLExpr
*
);
void
tSQLExprNodeDestroy
(
tSQLExpr
*
pExpr
);
void
tSQLExprDestroy
(
tSQLExpr
*
);
void
tSQLExprNodeDestroy
(
tSQLExpr
*
pExpr
);
tSQLExpr
*
tSQLExprNodeClone
(
tSQLExpr
*
pExpr
);
tSQLExpr
*
tSQLExprNodeClone
(
tSQLExpr
*
pExpr
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SSQLToken
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SSQLToken
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
tSQLExprListList
*
tSQLListListAppend
(
tSQLExprListList
*
pList
,
tSQLExprList
*
pExprList
);
tSQLExprListList
*
tSQLListListAppend
(
tSQLExprListList
*
pList
,
tSQLExprList
*
pExprList
);
void
tSetInsertSQLElems
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pName
,
tSQLExprListList
*
pList
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
void
doDestroyQuerySql
(
SQuerySQL
*
pSql
);
void
destroyQuerySql
(
SQuerySQL
*
pSql
);
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SSQLToken
*
pMeterName
,
int32_t
type
);
SSubclauseInfo
*
setSubclause
(
SSubclauseInfo
*
pClause
,
void
*
pSqlExprInfo
);
void
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SSQLToken
*
pMeterName
,
int32_t
typ
e
);
SSubclauseInfo
*
appendSelectClause
(
SSubclauseInfo
*
pInfo
,
void
*
pSubclaus
e
);
void
setCreatedMeterName
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pMeterName
,
SSQLToken
*
pIfNotExists
);
void
setCreatedMeterName
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pMeterName
,
SSQLToken
*
pIfNotExists
);
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
);
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SSQLToken
*
existsCheck
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
prefix
,
SSQLToken
*
pPatterns
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SSQLToken
*
pToken
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SSQLToken
*
pToken
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQLToken
*
pIgExists
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQLToken
*
pIgExists
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pName
,
SSQLToken
*
pPasswd
);
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
ip
);
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQLToken
*
pPrivilege
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
// prefix show db.tables;
// prefix show db.tables;
...
...
src/client/inc/tscUtil.h
浏览文件 @
c18b6b1b
...
@@ -134,6 +134,7 @@ TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index);
...
@@ -134,6 +134,7 @@ TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index);
int16_t
tscFieldInfoGetOffset
(
SSqlCmd
*
pCmd
,
int32_t
index
);
int16_t
tscFieldInfoGetOffset
(
SSqlCmd
*
pCmd
,
int32_t
index
);
int32_t
tscGetResRowLength
(
SSqlCmd
*
pCmd
);
int32_t
tscGetResRowLength
(
SSqlCmd
*
pCmd
);
void
tscClearFieldInfo
(
SFieldInfo
*
pFieldInfo
);
void
tscClearFieldInfo
(
SFieldInfo
*
pFieldInfo
);
int32_t
tscNumOfFields
(
SSqlCmd
*
pCmd
);
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
...
@@ -186,6 +187,7 @@ void tscClearMeterMetaInfo(SMeterMetaInfo* pMeterMetaInfo, bool remov
...
@@ -186,6 +187,7 @@ void tscClearMeterMetaInfo(SMeterMetaInfo* pMeterMetaInfo, bool remov
SMeterMetaInfo
*
tscAddMeterMetaInfo
(
SSqlCmd
*
pCmd
,
const
char
*
name
,
SMeterMeta
*
pMeterMeta
,
SMetricMeta
*
pMetricMeta
,
SMeterMetaInfo
*
tscAddMeterMetaInfo
(
SSqlCmd
*
pCmd
,
const
char
*
name
,
SMeterMeta
*
pMeterMeta
,
SMetricMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
);
int16_t
numOfTags
,
int16_t
*
tags
);
SMeterMetaInfo
*
tscAddEmptyMeterMetaInfo
(
SSqlCmd
*
pCmd
);
SMeterMetaInfo
*
tscAddEmptyMeterMetaInfo
(
SSqlCmd
*
pCmd
);
int32_t
tscAddQueryInfo
(
SSqlCmd
*
pCmd
);
void
tscGetMetricMetaCacheKey
(
SSqlCmd
*
pCmd
,
char
*
keyStr
,
uint64_t
uid
);
void
tscGetMetricMetaCacheKey
(
SSqlCmd
*
pCmd
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
);
...
...
src/client/inc/tsclient.h
浏览文件 @
c18b6b1b
...
@@ -43,66 +43,6 @@ extern "C" {
...
@@ -43,66 +43,6 @@ extern "C" {
((res->data + tscFieldInfoGetOffset(cmd, col) * res->numOfRows) + \
((res->data + tscFieldInfoGetOffset(cmd, col) * res->numOfRows) + \
(1 - ord.order) * (res->numOfRows - 1) * tscFieldInfoGetField(cmd, col)->bytes)
(1 - ord.order) * (res->numOfRows - 1) * tscFieldInfoGetField(cmd, col)->bytes)
enum
_sql_cmd
{
TSDB_SQL_SELECT
,
TSDB_SQL_FETCH
,
TSDB_SQL_INSERT
,
TSDB_SQL_MGMT
,
// the SQL below is for mgmt node
TSDB_SQL_CREATE_DB
,
TSDB_SQL_CREATE_TABLE
,
TSDB_SQL_DROP_DB
,
TSDB_SQL_DROP_TABLE
,
TSDB_SQL_CREATE_ACCT
,
TSDB_SQL_CREATE_USER
,
TSDB_SQL_DROP_ACCT
,
// 10
TSDB_SQL_DROP_USER
,
TSDB_SQL_ALTER_USER
,
TSDB_SQL_ALTER_ACCT
,
TSDB_SQL_ALTER_TABLE
,
TSDB_SQL_ALTER_DB
,
TSDB_SQL_CREATE_MNODE
,
TSDB_SQL_DROP_MNODE
,
TSDB_SQL_CREATE_DNODE
,
TSDB_SQL_DROP_DNODE
,
TSDB_SQL_CFG_DNODE
,
// 20
TSDB_SQL_CFG_MNODE
,
TSDB_SQL_SHOW
,
TSDB_SQL_RETRIEVE
,
TSDB_SQL_KILL_QUERY
,
TSDB_SQL_KILL_STREAM
,
TSDB_SQL_KILL_CONNECTION
,
TSDB_SQL_READ
,
// SQL below is for read operation
TSDB_SQL_CONNECT
,
TSDB_SQL_USE_DB
,
TSDB_SQL_META
,
// 30
TSDB_SQL_METRIC
,
TSDB_SQL_MULTI_META
,
TSDB_SQL_HB
,
TSDB_SQL_LOCAL
,
// SQL below for client local
TSDB_SQL_DESCRIBE_TABLE
,
TSDB_SQL_RETRIEVE_METRIC
,
TSDB_SQL_METRIC_JOIN_RETRIEVE
,
TSDB_SQL_RETRIEVE_TAGS
,
/*
* build empty result instead of accessing dnode to fetch result
* reset the client cache
*/
TSDB_SQL_RETRIEVE_EMPTY_RESULT
,
TSDB_SQL_RESET_CACHE
,
// 40
TSDB_SQL_SERV_STATUS
,
TSDB_SQL_CURRENT_DB
,
TSDB_SQL_SERV_VERSION
,
TSDB_SQL_CLI_VERSION
,
TSDB_SQL_CURRENT_USER
,
TSDB_SQL_CFG_LOCAL
,
TSDB_SQL_MAX
};
// forward declaration
// forward declaration
struct
SSqlInfo
;
struct
SSqlInfo
;
...
@@ -267,6 +207,28 @@ typedef struct SDataBlockList {
...
@@ -267,6 +207,28 @@ typedef struct SDataBlockList {
STableDataBlocks
**
pData
;
STableDataBlocks
**
pData
;
}
SDataBlockList
;
}
SDataBlockList
;
typedef
struct
SQueryInfo
{
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
}
SQueryInfo
;
typedef
struct
{
typedef
struct
{
SOrderVal
order
;
SOrderVal
order
;
int
command
;
int
command
;
...
@@ -274,18 +236,12 @@ typedef struct {
...
@@ -274,18 +236,12 @@ typedef struct {
union
{
union
{
bool
existsCheck
;
// check if the table exists
bool
existsCheck
;
// check if the table exists
int8_t
showType
;
// show command
type
bool
import
;
// import/insert
type
};
};
int8_t
isInsertFromFile
;
// load data from file or not
int8_t
isInsertFromFile
;
// load data from file or not
bool
import
;
// import/insert type
uint8_t
msgType
;
uint8_t
msgType
;
uint16_t
type
;
// query type
uint16_t
type
;
// query type
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
/*
/*
* use to keep short request msg and error msg, in such case, SSqlCmd->payload == SSqlCmd->ext;
* use to keep short request msg and error msg, in such case, SSqlCmd->payload == SSqlCmd->ext;
...
@@ -297,22 +253,32 @@ typedef struct {
...
@@ -297,22 +253,32 @@ typedef struct {
char
*
payload
;
char
*
payload
;
int
payloadLen
;
int
payloadLen
;
short
numOfCols
;
short
numOfCols
;
SColumnBaseInfo
colList
;
SFieldInfo
fieldsInfo
;
SSqlExprInfo
exprsInfo
;
SLimitVal
limit
;
SLimitVal
slimit
;
int64_t
globalLimit
;
int64_t
globalLimit
;
STagCond
tagCond
;
int16_t
interpoType
;
// interpolate type
SQueryInfo
*
pQueryInfo
;
int16_t
numOfTables
;
int32_t
numOfQueries
;
// 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
;
SMeterMetaInfo
**
pMeterInfo
;
struct
STSBuf
*
tsBuf
;
// todo use dynamic allocated memory for defaultVal
int64_t
defaultVal
[
TSDB_MAX_COLUMNS
];
// default value for interpolation
// for parameter ('?') binding and batch processing
// for parameter ('?') binding and batch processing
int32_t
batchSize
;
int32_t
batchSize
;
...
@@ -435,6 +401,8 @@ typedef struct {
...
@@ -435,6 +401,8 @@ typedef struct {
int
tsParseSql
(
SSqlObj
*
pSql
,
char
*
acct
,
char
*
db
,
bool
multiVnodeInsertion
);
int
tsParseSql
(
SSqlObj
*
pSql
,
char
*
acct
,
char
*
db
,
bool
multiVnodeInsertion
);
void
tscInitMsgs
();
void
tscInitMsgs
();
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
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
...
...
src/client/src/sql.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscAsync.c
浏览文件 @
c18b6b1b
...
@@ -131,8 +131,8 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
...
@@ -131,8 +131,8 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
}
}
/* update the limit value according to current retrieval results */
/* update the limit value according to current retrieval results */
pCmd
->
limit
.
limit
=
pCmd
->
globalLimit
-
pRes
->
numOfTotal
;
pCmd
->
pQueryInfo
->
limit
.
limit
=
pCmd
->
globalLimit
-
pRes
->
numOfTotal
;
pCmd
->
limit
.
offset
=
pRes
->
offset
;
pCmd
->
pQueryInfo
->
limit
.
offset
=
pRes
->
offset
;
if
((
++
(
pMeterMetaInfo
->
vnodeIndex
))
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
if
((
++
(
pMeterMetaInfo
->
vnodeIndex
))
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
tscTrace
(
"%p retrieve data from next vnode:%d"
,
pSql
,
pMeterMetaInfo
->
vnodeIndex
);
tscTrace
(
"%p retrieve data from next vnode:%d"
,
pSql
,
pMeterMetaInfo
->
vnodeIndex
);
...
@@ -282,7 +282,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
...
@@ -282,7 +282,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
}
}
/* update the limit value according to current retrieval results */
/* update the limit value according to current retrieval results */
pCmd
->
limit
.
limit
=
pCmd
->
globalLimit
-
pRes
->
numOfTotal
;
pCmd
->
pQueryInfo
->
limit
.
limit
=
pCmd
->
globalLimit
-
pRes
->
numOfTotal
;
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<=
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<=
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
// reset flag to launch query first.
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
// reset flag to launch query first.
...
@@ -407,7 +407,7 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -407,7 +407,7 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
assert
(
!
pCmd
->
isInsertFromFile
&&
pSql
->
signature
==
pSql
);
assert
(
!
pCmd
->
isInsertFromFile
&&
pSql
->
signature
==
pSql
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
assert
(
pCmd
->
numOfTables
==
1
);
assert
(
pCmd
->
pQueryInfo
->
numOfTables
==
1
);
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
...
...
src/client/src/tscJoinProcess.c
浏览文件 @
c18b6b1b
...
@@ -53,11 +53,11 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
...
@@ -53,11 +53,11 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
*
st
=
INT64_MAX
;
*
st
=
INT64_MAX
;
*
et
=
INT64_MIN
;
*
et
=
INT64_MIN
;
SLimitVal
*
pLimit
=
&
pSql
->
cmd
.
limit
;
SLimitVal
*
pLimit
=
&
pSql
->
cmd
.
pQueryInfo
->
limit
;
int32_t
order
=
pSql
->
cmd
.
order
.
order
;
int32_t
order
=
pSql
->
cmd
.
order
.
order
;
pSql
->
pSubs
[
0
]
->
cmd
.
tsBuf
=
output1
;
pSql
->
pSubs
[
0
]
->
cmd
.
pQueryInfo
->
tsBuf
=
output1
;
pSql
->
pSubs
[
1
]
->
cmd
.
tsBuf
=
output2
;
pSql
->
pSubs
[
1
]
->
cmd
.
pQueryInfo
->
tsBuf
=
output2
;
tsBufResetPos
(
pSupporter1
->
pTSBuf
);
tsBufResetPos
(
pSupporter1
->
pTSBuf
);
tsBufResetPos
(
pSupporter2
->
pTSBuf
);
tsBufResetPos
(
pSupporter2
->
pTSBuf
);
...
@@ -113,7 +113,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
...
@@ -113,7 +113,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
}
}
// in case of stable query, limit/offset is not applied here
// in case of stable query, limit/offset is not applied here
if
(
pLimit
->
offset
==
0
||
pSql
->
cmd
.
nAggTimeInterval
>
0
||
QUERY_IS_STABLE_QUERY
(
pSql
->
cmd
.
type
))
{
if
(
pLimit
->
offset
==
0
||
pSql
->
cmd
.
pQueryInfo
->
nAggTimeInterval
>
0
||
QUERY_IS_STABLE_QUERY
(
pSql
->
cmd
.
type
))
{
tsBufAppend
(
output1
,
elem1
.
vnode
,
elem1
.
tag
,
(
const
char
*
)
&
elem1
.
ts
,
sizeof
(
elem1
.
ts
));
tsBufAppend
(
output1
,
elem1
.
vnode
,
elem1
.
tag
,
(
const
char
*
)
&
elem1
.
ts
,
sizeof
(
elem1
.
ts
));
tsBufAppend
(
output2
,
elem2
.
vnode
,
elem2
.
tag
,
(
const
char
*
)
&
elem2
.
ts
,
sizeof
(
elem2
.
ts
));
tsBufAppend
(
output2
,
elem2
.
vnode
,
elem2
.
tag
,
(
const
char
*
)
&
elem2
.
ts
,
sizeof
(
elem2
.
ts
));
}
else
{
}
else
{
...
@@ -168,8 +168,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
...
@@ -168,8 +168,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
pSupporter
->
pState
=
pState
;
pSupporter
->
pState
=
pState
;
pSupporter
->
subqueryIndex
=
index
;
pSupporter
->
subqueryIndex
=
index
;
pSupporter
->
interval
=
pSql
->
cmd
.
nAggTimeInterval
;
pSupporter
->
interval
=
pSql
->
cmd
.
pQueryInfo
->
nAggTimeInterval
;
pSupporter
->
limit
=
pSql
->
cmd
.
limit
;
pSupporter
->
limit
=
pSql
->
cmd
.
pQueryInfo
->
limit
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
index
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
index
);
pSupporter
->
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
pSupporter
->
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
...
@@ -211,8 +211,8 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
...
@@ -211,8 +211,8 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
*/
*/
bool
needSecondaryQuery
(
SSqlObj
*
pSql
)
{
bool
needSecondaryQuery
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
for
(
int32_t
i
=
0
;
i
<
pCmd
->
colList
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
SColumnBase
*
pBase
=
tscColumnBaseInfoGet
(
&
pCmd
->
colList
,
i
);
SColumnBase
*
pBase
=
tscColumnBaseInfoGet
(
&
pCmd
->
pQueryInfo
->
colList
,
i
);
if
(
pBase
->
colIndex
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pBase
->
colIndex
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
true
;
return
true
;
}
}
...
@@ -272,25 +272,25 @@ int32_t tscLaunchSecondSubquery(SSqlObj* pSql) {
...
@@ -272,25 +272,25 @@ int32_t tscLaunchSecondSubquery(SSqlObj* pSql) {
tscFreeSqlCmdData
(
&
pNew
->
cmd
);
tscFreeSqlCmdData
(
&
pNew
->
cmd
);
pSql
->
pSubs
[
j
++
]
=
pNew
;
pSql
->
pSubs
[
j
++
]
=
pNew
;
pNew
->
cmd
.
tsBuf
=
pSub
->
cmd
.
tsBuf
;
pNew
->
cmd
.
pQueryInfo
->
tsBuf
=
pSub
->
cmd
.
pQueryInfo
->
tsBuf
;
pSub
->
cmd
.
tsBuf
=
NULL
;
pSub
->
cmd
.
pQueryInfo
->
tsBuf
=
NULL
;
taos_free_result
(
pSub
);
taos_free_result
(
pSub
);
// set the second stage sub query for join process
// set the second stage sub query for join process
pNew
->
cmd
.
type
|=
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
;
pNew
->
cmd
.
type
|=
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
;
pNew
->
cmd
.
nAggTimeInterval
=
pSupporter
->
interval
;
pNew
->
cmd
.
pQueryInfo
->
nAggTimeInterval
=
pSupporter
->
interval
;
pNew
->
cmd
.
groupbyExpr
=
pSupporter
->
groupbyExpr
;
pNew
->
cmd
.
pQueryInfo
->
groupbyExpr
=
pSupporter
->
groupbyExpr
;
tscColumnBaseInfoCopy
(
&
pNew
->
cmd
.
colList
,
&
pSupporter
->
colList
,
0
);
tscColumnBaseInfoCopy
(
&
pNew
->
cmd
.
pQueryInfo
->
colList
,
&
pSupporter
->
colList
,
0
);
tscTagCondCopy
(
&
pNew
->
cmd
.
tagCond
,
&
pSupporter
->
tagCond
);
tscTagCondCopy
(
&
pNew
->
cmd
.
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
tscSqlExprCopy
(
&
pNew
->
cmd
.
exprsInfo
,
&
pSupporter
->
exprsInfo
,
pSupporter
->
uid
);
tscSqlExprCopy
(
&
pNew
->
cmd
.
pQueryInfo
->
exprsInfo
,
&
pSupporter
->
exprsInfo
,
pSupporter
->
uid
);
tscFieldInfoCopyAll
(
&
pSupporter
->
fieldsInfo
,
&
pNew
->
cmd
.
fieldsInfo
);
tscFieldInfoCopyAll
(
&
pSupporter
->
fieldsInfo
,
&
pNew
->
cmd
.
pQueryInfo
->
fieldsInfo
);
// add the ts function for interval query if it is missing
// add the ts function for interval query if it is missing
if
(
pSupporter
->
exprsInfo
.
pExprs
[
0
].
functionId
!=
TSDB_FUNC_TS
&&
pNew
->
cmd
.
nAggTimeInterval
>
0
)
{
if
(
pSupporter
->
exprsInfo
.
pExprs
[
0
].
functionId
!=
TSDB_FUNC_TS
&&
pNew
->
cmd
.
pQueryInfo
->
nAggTimeInterval
>
0
)
{
tscAddTimestampColumn
(
&
pNew
->
cmd
,
TSDB_FUNC_TS
,
0
);
tscAddTimestampColumn
(
&
pNew
->
cmd
,
TSDB_FUNC_TS
,
0
);
}
}
...
@@ -304,15 +304,15 @@ int32_t tscLaunchSecondSubquery(SSqlObj* pSql) {
...
@@ -304,15 +304,15 @@ int32_t tscLaunchSecondSubquery(SSqlObj* pSql) {
* When handling the projection query, the offset value will be modified for table-table join, which is changed
* When handling the projection query, the offset value will be modified for table-table join, which is changed
* during the timestamp intersection.
* during the timestamp intersection.
*/
*/
pSupporter
->
limit
=
pSql
->
cmd
.
limit
;
pSupporter
->
limit
=
pSql
->
cmd
.
pQueryInfo
->
limit
;
pNew
->
cmd
.
limit
=
pSupporter
->
limit
;
pNew
->
cmd
.
pQueryInfo
->
limit
=
pSupporter
->
limit
;
// fetch the join tag column
// fetch the join tag column
if
(
UTIL_METER_IS_METRIC
(
pMeterMetaInfo
))
{
if
(
UTIL_METER_IS_METRIC
(
pMeterMetaInfo
))
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
&
pNew
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
&
pNew
->
cmd
,
0
);
assert
(
pNew
->
cmd
.
tagCond
.
joinInfo
.
hasJoin
);
assert
(
pNew
->
cmd
.
pQueryInfo
->
tagCond
.
joinInfo
.
hasJoin
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pNew
->
cmd
.
tagCond
,
pMeterMetaInfo
->
pMeterMeta
->
uid
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pNew
->
cmd
.
pQueryInfo
->
tagCond
,
pMeterMetaInfo
->
pMeterMeta
->
uid
);
pExpr
->
param
[
0
].
i64Key
=
tagColIndex
;
pExpr
->
param
[
0
].
i64Key
=
tagColIndex
;
pExpr
->
numOfParams
=
1
;
pExpr
->
numOfParams
=
1
;
}
}
...
@@ -370,10 +370,10 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSubquerySupporter* pSupporter
...
@@ -370,10 +370,10 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSubquerySupporter* pSupporter
// update the query time range according to the join results on timestamp
// update the query time range according to the join results on timestamp
static
void
updateQueryTimeRange
(
SSqlObj
*
pSql
,
int64_t
st
,
int64_t
et
)
{
static
void
updateQueryTimeRange
(
SSqlObj
*
pSql
,
int64_t
st
,
int64_t
et
)
{
assert
(
pSql
->
cmd
.
stime
<=
st
&&
pSql
->
cmd
.
etime
>=
et
);
assert
(
pSql
->
cmd
.
pQueryInfo
->
stime
<=
st
&&
pSql
->
cmd
.
pQueryInfo
->
etime
>=
et
);
pSql
->
cmd
.
stime
=
st
;
pSql
->
cmd
.
pQueryInfo
->
stime
=
st
;
pSql
->
cmd
.
etime
=
et
;
pSql
->
cmd
.
pQueryInfo
->
etime
=
et
;
}
}
static
void
joinRetrieveCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
static
void
joinRetrieveCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
...
@@ -408,7 +408,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -408,7 +408,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
tscTrace
(
"%p create tmp file for ts block:%s"
,
pSql
,
pBuf
->
path
);
tscTrace
(
"%p create tmp file for ts block:%s"
,
pSql
,
pBuf
->
path
);
pSupporter
->
pTSBuf
=
pBuf
;
pSupporter
->
pTSBuf
=
pBuf
;
}
else
{
}
else
{
assert
(
pSql
->
cmd
.
numOfTables
==
1
);
// for subquery, only one metermetaInfo
assert
(
pSql
->
cmd
.
pQueryInfo
->
numOfTables
==
1
);
// for subquery, only one metermetaInfo
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pMeterMetaInfo
->
vnodeIndex
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pMeterMetaInfo
->
vnodeIndex
);
...
@@ -424,7 +424,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -424,7 +424,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
}
else
if
(
numOfRows
==
0
)
{
// no data from this vnode anymore
}
else
if
(
numOfRows
==
0
)
{
// no data from this vnode anymore
if
(
tscProjectionQueryOnMetric
(
&
pParentSql
->
cmd
))
{
if
(
tscProjectionQueryOnMetric
(
&
pParentSql
->
cmd
))
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
assert
(
pSql
->
cmd
.
numOfTables
==
1
);
assert
(
pSql
->
cmd
.
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode
// for projection query, need to try next vnode
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
...
@@ -480,7 +480,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -480,7 +480,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
if
(
tscProjectionQueryOnMetric
(
&
pSql
->
cmd
)
&&
numOfRows
==
0
)
{
if
(
tscProjectionQueryOnMetric
(
&
pSql
->
cmd
)
&&
numOfRows
==
0
)
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
assert
(
pSql
->
cmd
.
numOfTables
==
1
);
assert
(
pSql
->
cmd
.
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode if current vnode is exhausted
// for projection query, need to try next vnode if current vnode is exhausted
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
if
((
++
pMeterMetaInfo
->
vnodeIndex
)
<
pMeterMetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
...
@@ -555,7 +555,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
...
@@ -555,7 +555,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
// wait for all subqueries completed
// wait for all subqueries completed
pSupporter
->
pState
->
numOfTotal
=
numOfFetch
;
pSupporter
->
pState
->
numOfTotal
=
numOfFetch
;
assert
(
pRes1
->
numOfRows
>=
0
&&
pCmd1
->
numOfTables
==
1
);
assert
(
pRes1
->
numOfRows
>=
0
&&
pCmd1
->
pQueryInfo
->
numOfTables
==
1
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd1
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd1
,
0
);
...
@@ -589,13 +589,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -589,13 +589,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
return
;
// the column transfer support struct has been built
return
;
// the column transfer support struct has been built
}
}
pRes
->
pColumnIndex
=
calloc
(
1
,
sizeof
(
SColumnIndex
)
*
pCmd
->
fieldsInfo
.
numOfOutputCols
);
pRes
->
pColumnIndex
=
calloc
(
1
,
sizeof
(
SColumnIndex
)
*
pCmd
->
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
int32_t
tableIndexOfSub
=
-
1
;
int32_t
tableIndexOfSub
=
-
1
;
for
(
int32_t
j
=
0
;
j
<
pCmd
->
numOfTables
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pCmd
->
pQueryInfo
->
numOfTables
;
++
j
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
j
];
SSqlObj
*
pSub
=
pSql
->
pSubs
[
j
];
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSub
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSub
->
cmd
,
0
);
...
@@ -607,7 +607,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -607,7 +607,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
SSqlCmd
*
pSubCmd
=
&
pSql
->
pSubs
[
tableIndexOfSub
]
->
cmd
;
SSqlCmd
*
pSubCmd
=
&
pSql
->
pSubs
[
tableIndexOfSub
]
->
cmd
;
for
(
int32_t
k
=
0
;
k
<
pSubCmd
->
exprsInfo
.
numOfExprs
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pSubCmd
->
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
SSqlExpr
*
pSubExpr
=
tscSqlExprGet
(
pSubCmd
,
k
);
SSqlExpr
*
pSubExpr
=
tscSqlExprGet
(
pSubCmd
,
k
);
if
(
pExpr
->
functionId
==
pSubExpr
->
functionId
&&
pExpr
->
colInfo
.
colId
==
pSubExpr
->
colInfo
.
colId
)
{
if
(
pExpr
->
functionId
==
pSubExpr
->
functionId
&&
pExpr
->
colInfo
.
colId
==
pSubExpr
->
colInfo
.
colId
)
{
pRes
->
pColumnIndex
[
i
]
=
(
SColumnIndex
){.
tableIndex
=
tableIndexOfSub
,
.
columnIndex
=
k
};
pRes
->
pColumnIndex
[
i
]
=
(
SColumnIndex
){.
tableIndex
=
tableIndexOfSub
,
.
columnIndex
=
k
};
...
...
src/client/src/tscLocal.c
浏览文件 @
c18b6b1b
...
@@ -254,16 +254,16 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -254,16 +254,16 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
pCmd
->
order
.
order
=
TSQL_SO_ASC
;
pCmd
->
order
.
order
=
TSQL_SO_ASC
;
tscFieldInfoSetValue
(
&
pCmd
->
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
"Field"
,
TSDB_COL_NAME_LEN
);
tscFieldInfoSetValue
(
&
pCmd
->
pQueryInfo
->
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
"Field"
,
TSDB_COL_NAME_LEN
);
rowLen
+=
TSDB_COL_NAME_LEN
;
rowLen
+=
TSDB_COL_NAME_LEN
;
tscFieldInfoSetValue
(
&
pCmd
->
fieldsInfo
,
1
,
TSDB_DATA_TYPE_BINARY
,
"Type"
,
typeColLength
);
tscFieldInfoSetValue
(
&
pCmd
->
pQueryInfo
->
fieldsInfo
,
1
,
TSDB_DATA_TYPE_BINARY
,
"Type"
,
typeColLength
);
rowLen
+=
typeColLength
;
rowLen
+=
typeColLength
;
tscFieldInfoSetValue
(
&
pCmd
->
fieldsInfo
,
2
,
TSDB_DATA_TYPE_INT
,
"Length"
,
sizeof
(
int32_t
));
tscFieldInfoSetValue
(
&
pCmd
->
pQueryInfo
->
fieldsInfo
,
2
,
TSDB_DATA_TYPE_INT
,
"Length"
,
sizeof
(
int32_t
));
rowLen
+=
sizeof
(
int32_t
);
rowLen
+=
sizeof
(
int32_t
);
tscFieldInfoSetValue
(
&
pCmd
->
fieldsInfo
,
3
,
TSDB_DATA_TYPE_BINARY
,
"Note"
,
noteColLength
);
tscFieldInfoSetValue
(
&
pCmd
->
pQueryInfo
->
fieldsInfo
,
3
,
TSDB_DATA_TYPE_BINARY
,
"Note"
,
noteColLength
);
rowLen
+=
noteColLength
;
rowLen
+=
noteColLength
;
return
rowLen
;
return
rowLen
;
...
@@ -321,7 +321,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
...
@@ -321,7 +321,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
for
(
int32_t
j
=
0
;
j
<
pSidList
->
numOfSids
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pSidList
->
numOfSids
;
++
j
)
{
SMeterSidExtInfo
*
pSidExt
=
tscGetMeterSidInfo
(
pSidList
,
j
);
SMeterSidExtInfo
*
pSidExt
=
tscGetMeterSidInfo
(
pSidList
,
j
);
for
(
int32_t
k
=
0
;
k
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pCmd
->
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
k
)
{
SColIndexEx
*
pColIndex
=
&
tscSqlExprGet
(
pCmd
,
k
)
->
colInfo
;
SColIndexEx
*
pColIndex
=
&
tscSqlExprGet
(
pCmd
,
k
)
->
colInfo
;
int16_t
offsetId
=
pColIndex
->
colIdx
;
int16_t
offsetId
=
pColIndex
->
colIdx
;
...
@@ -352,7 +352,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
...
@@ -352,7 +352,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
int32_t
rowIdx
=
0
;
int32_t
rowIdx
=
0
;
for
(
int32_t
i
=
0
;
i
<
totalNumOfResults
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalNumOfResults
;
++
i
)
{
for
(
int32_t
k
=
0
;
k
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pCmd
->
pQueryInfo
[
0
].
fieldsInfo
.
numOfOutputCols
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
if
(
pExpr
->
colInfo
.
colIdx
==
-
1
&&
pExpr
->
functionId
==
TSDB_FUNC_COUNT
)
{
if
(
pExpr
->
colInfo
.
colIdx
==
-
1
&&
pExpr
->
functionId
==
TSDB_FUNC_COUNT
)
{
...
@@ -444,7 +444,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
...
@@ -444,7 +444,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
pCmd
->
numOfCols
=
1
;
pCmd
->
numOfCols
=
1
;
pCmd
->
order
.
order
=
TSQL_SO_ASC
;
pCmd
->
order
.
order
=
TSQL_SO_ASC
;
tscFieldInfoSetValue
(
&
pCmd
->
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
columnName
,
valueLength
);
tscFieldInfoSetValue
(
&
pCmd
->
pQueryInfo
[
0
].
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
columnName
,
valueLength
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pCmd
,
0
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pCmd
,
0
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
c18b6b1b
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE
#include <hash.h>
#include "os.h"
#include "os.h"
#include "ihash.h"
#include "ihash.h"
#include "tscSecondaryMerge.h"
#include "tscSecondaryMerge.h"
...
@@ -953,7 +954,8 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
...
@@ -953,7 +954,8 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
}
}
if
((
NULL
==
pSql
->
asyncTblPos
)
&&
(
NULL
==
pSql
->
pTableHashList
))
{
if
((
NULL
==
pSql
->
asyncTblPos
)
&&
(
NULL
==
pSql
->
pTableHashList
))
{
pSql
->
pTableHashList
=
taosInitIntHash
(
128
,
POINTER_BYTES
,
taosHashInt
);
pSql
->
pTableHashList
=
taosInitHashTable
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
);
pSql
->
cmd
.
pDataBlocks
=
tscCreateBlockArrayList
();
pSql
->
cmd
.
pDataBlocks
=
tscCreateBlockArrayList
();
if
(
NULL
==
pSql
->
pTableHashList
||
NULL
==
pSql
->
cmd
.
pDataBlocks
)
{
if
(
NULL
==
pSql
->
pTableHashList
||
NULL
==
pSql
->
cmd
.
pDataBlocks
)
{
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
@@ -1239,8 +1241,9 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion) {
...
@@ -1239,8 +1241,9 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion) {
tscRemoveAllMeterMetaInfo
(
&
pSql
->
cmd
,
false
);
tscRemoveAllMeterMetaInfo
(
&
pSql
->
cmd
,
false
);
if
(
NULL
==
pSql
->
asyncTblPos
)
{
if
(
NULL
==
pSql
->
asyncTblPos
)
{
tscTrace
(
"continue parse sql: %s"
,
pSql
->
asyncTblPos
);
tscCleanSqlCmd
(
&
pSql
->
cmd
);
tscCleanSqlCmd
(
&
pSql
->
cmd
);
}
else
{
tscTrace
(
"continue parse sql: %s"
,
pSql
->
asyncTblPos
);
}
}
if
(
tscIsInsertOrImportData
(
pSql
->
sqlstr
))
{
if
(
tscIsInsertOrImportData
(
pSql
->
sqlstr
))
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscSQLParserImpl.c
浏览文件 @
c18b6b1b
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pStr
)
{
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pStr
)
{
void
*
pParser
=
ParseAlloc
(
malloc
);
void
*
pParser
=
ParseAlloc
(
malloc
);
pSQLInfo
->
valid
Sql
=
true
;
pSQLInfo
->
valid
=
true
;
int32_t
i
=
0
;
int32_t
i
=
0
;
while
(
1
)
{
while
(
1
)
{
...
@@ -50,12 +50,12 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
...
@@ -50,12 +50,12 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
}
}
case
TK_ILLEGAL
:
{
case
TK_ILLEGAL
:
{
snprintf
(
pSQLInfo
->
pzErrMsg
,
tListLen
(
pSQLInfo
->
pzErrMsg
),
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
snprintf
(
pSQLInfo
->
pzErrMsg
,
tListLen
(
pSQLInfo
->
pzErrMsg
),
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
pSQLInfo
->
valid
Sql
=
false
;
pSQLInfo
->
valid
=
false
;
goto
abort_parse
;
goto
abort_parse
;
}
}
default:
default:
Parse
(
pParser
,
t0
.
type
,
t0
,
pSQLInfo
);
Parse
(
pParser
,
t0
.
type
,
t0
,
pSQLInfo
);
if
(
pSQLInfo
->
valid
Sql
==
false
)
{
if
(
pSQLInfo
->
valid
==
false
)
{
goto
abort_parse
;
goto
abort_parse
;
}
}
}
}
...
@@ -554,58 +554,62 @@ tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExp
...
@@ -554,58 +554,62 @@ tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExp
return
pList
;
return
pList
;
}
}
void
tSetInsertSQLElems
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pName
,
tSQLExprListList
*
pList
)
{
void
doDestroyQuerySql
(
SQuerySQL
*
pQuerySql
)
{
SInsertSQL
*
pInsert
=
calloc
(
1
,
sizeof
(
SInsertSQL
));
if
(
pQuerySql
==
NULL
)
{
return
;
pInsert
->
name
=
*
pName
;
}
pInsert
->
pValue
=
pList
;
tSQLExprListDestroy
(
pQuerySql
->
pSelection
);
pInfo
->
pInsertInfo
=
pInsert
;
pInfo
->
sqlType
=
TSQL_INSERT
;
pQuerySql
->
pSelection
=
NULL
;
}
tSQLExprDestroy
(
pQuerySql
->
pWhere
);
void
destroyQuerySql
(
SQuerySQL
*
pSql
)
{
pQuerySql
->
pWhere
=
NULL
;
if
(
pSql
==
NULL
)
return
;
tVariantListDestroy
(
pQuerySql
->
pSortOrder
);
tSQLExprListDestroy
(
pSql
->
pSelection
);
pQuerySql
->
pSortOrder
=
NULL
;
pSql
->
pSelection
=
NULL
;
tVariantListDestroy
(
pQuerySql
->
pGroupby
);
tSQLExprDestroy
(
pSql
->
pWhere
);
pQuerySql
->
pGroupby
=
NULL
;
pSql
->
pWhere
=
NULL
;
tVariantListDestroy
(
pQuerySql
->
from
);
tVariantListDestroy
(
pSql
->
pSortOrder
);
pQuerySql
->
from
=
NULL
;
pSql
->
pSortOrder
=
NULL
;
tVariantListDestroy
(
pQuerySql
->
fillType
);
tVariantListDestroy
(
pSql
->
pGroupby
);
pSql
->
pGroupby
=
NULL
;
free
(
pQuerySql
);
}
tVariantListDestroy
(
pSql
->
from
);
pSql
->
from
=
NULL
;
void
destroyAllSelectClause
(
SSubclauseInfo
*
pClause
)
{
if
(
pClause
==
NULL
||
pClause
->
numOfClause
==
0
)
{
tVariantListDestroy
(
pSql
->
fillType
);
return
;
}
free
(
pSql
);
for
(
int32_t
i
=
0
;
i
<
pClause
->
numOfClause
;
++
i
)
{
SQuerySQL
*
pQuerySql
=
pClause
->
pClause
[
i
];
doDestroyQuerySql
(
pQuerySql
);
}
}
}
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
p
Metric
Name
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SSQLToken
*
p
Stable
Name
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
)
{
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
)
{
SCreateTableSQL
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateTableSQL
));
SCreateTableSQL
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateTableSQL
));
switch
(
type
)
{
switch
(
type
)
{
case
TSQL_CREATE_
NORMAL_METER
:
{
case
TSQL_CREATE_
TABLE
:
{
pCreate
->
colInfo
.
pColumns
=
pCols
;
pCreate
->
colInfo
.
pColumns
=
pCols
;
assert
(
pTagVals
==
NULL
&&
pTags
==
NULL
);
assert
(
pTagVals
==
NULL
&&
pTags
==
NULL
);
break
;
break
;
}
}
case
TSQL_CREATE_
NORMAL_METRIC
:
{
case
TSQL_CREATE_
STABLE
:
{
pCreate
->
colInfo
.
pColumns
=
pCols
;
pCreate
->
colInfo
.
pColumns
=
pCols
;
pCreate
->
colInfo
.
pTagColumns
=
pTags
;
pCreate
->
colInfo
.
pTagColumns
=
pTags
;
assert
(
pTagVals
==
NULL
&&
pTags
!=
NULL
&&
pCols
!=
NULL
);
assert
(
pTagVals
==
NULL
&&
pTags
!=
NULL
&&
pCols
!=
NULL
);
break
;
break
;
}
}
case
TSQL_CREATE_
METER_FROM_METRIC
:
{
case
TSQL_CREATE_
TABLE_FROM_STABLE
:
{
pCreate
->
usingInfo
.
pTagVals
=
pTagVals
;
pCreate
->
usingInfo
.
pTagVals
=
pTagVals
;
pCreate
->
usingInfo
.
metricName
=
*
pMetric
Name
;
pCreate
->
usingInfo
.
stableName
=
*
pStable
Name
;
break
;
break
;
}
}
case
TSQL_CREATE_STREAM
:
{
case
TSQL_CREATE_STREAM
:
{
...
@@ -616,19 +620,24 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
...
@@ -616,19 +620,24 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
assert
(
false
);
assert
(
false
);
}
}
pCreate
->
type
=
type
;
return
pCreate
;
return
pCreate
;
}
}
SAlterTableSQL
*
tAlterTableSQLElems
(
SSQLToken
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
tAlterTableSQLElems
(
SSQLToken
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
pAlterTable
->
name
=
*
pMeterName
;
pAlterTable
->
name
=
*
pMeterName
;
pAlterTable
->
type
=
type
;
if
(
type
==
ALTER_TABLE_ADD_COLUMN
||
type
==
ALTER_TABLE_TAGS_ADD
)
{
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
pAlterTable
->
pAddColumns
=
pCols
;
pAlterTable
->
pAddColumns
=
pCols
;
assert
(
pVals
==
NULL
);
assert
(
pVals
==
NULL
);
}
else
{
}
else
{
/* ALTER_TABLE_TAGS_CHG, ALTER_TABLE_TAGS_SET, ALTER_TABLE_TAGS_DROP,
/*
* ALTER_TABLE_DROP_COLUMN */
* ALTER_TABLE_TAGS_CHG, ALTER_TABLE_TAGS_SET, ALTER_TABLE_TAGS_DROP,
* ALTER_TABLE_DROP_COLUMN
*/
pAlterTable
->
varList
=
pVals
;
pAlterTable
->
varList
=
pVals
;
assert
(
pCols
==
NULL
);
assert
(
pCols
==
NULL
);
}
}
...
@@ -639,27 +648,28 @@ SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tV
...
@@ -639,27 +648,28 @@ SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tV
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
)
{
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
)
return
;
if
(
pInfo
==
NULL
)
return
;
if
(
pInfo
->
sqlType
==
TSQL_QUERY_METER
)
{
if
(
pInfo
->
type
==
TSDB_SQL_SELECT
)
{
destroy
QuerySql
(
pInfo
->
pQuery
Info
);
destroy
AllSelectClause
(
&
pInfo
->
subclause
Info
);
}
else
if
(
pInfo
->
sqlType
>=
TSQL_CREATE_NORMAL_METER
&&
pInfo
->
sqlType
<=
TSQL_CREATE_STREAM
)
{
}
else
if
(
pInfo
->
type
==
TSDB_SQL_CREATE_TABLE
)
{
SCreateTableSQL
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
SCreateTableSQL
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
destroyQuerySql
(
pCreateTableInfo
->
pSelect
);
d
oD
estroyQuerySql
(
pCreateTableInfo
->
pSelect
);
tFieldListDestroy
(
pCreateTableInfo
->
colInfo
.
pColumns
);
tFieldListDestroy
(
pCreateTableInfo
->
colInfo
.
pColumns
);
tFieldListDestroy
(
pCreateTableInfo
->
colInfo
.
pTagColumns
);
tFieldListDestroy
(
pCreateTableInfo
->
colInfo
.
pTagColumns
);
tVariantListDestroy
(
pCreateTableInfo
->
usingInfo
.
pTagVals
);
tVariantListDestroy
(
pCreateTableInfo
->
usingInfo
.
pTagVals
);
tfree
(
pInfo
->
pCreateTableInfo
);
tfree
(
pInfo
->
pCreateTableInfo
);
}
else
if
(
pInfo
->
sqlType
>=
ALTER_TABLE_TAGS_ADD
&&
pInfo
->
sqlType
<=
ALTER_TABLE_DROP_COLUMN
)
{
}
else
if
(
pInfo
->
type
==
TSDB_SQL_ALTER_TABLE
)
{
tVariantListDestroy
(
pInfo
->
pAlterInfo
->
varList
);
tVariantListDestroy
(
pInfo
->
pAlterInfo
->
varList
);
tFieldListDestroy
(
pInfo
->
pAlterInfo
->
pAddColumns
);
tFieldListDestroy
(
pInfo
->
pAlterInfo
->
pAddColumns
);
tfree
(
pInfo
->
pAlterInfo
);
tfree
(
pInfo
->
pAlterInfo
);
}
else
{
}
else
{
if
(
pInfo
->
pDCLInfo
!=
NULL
&&
pInfo
->
pDCLInfo
->
nAlloc
>
0
)
{
if
(
pInfo
->
pDCLInfo
!=
NULL
&&
pInfo
->
pDCLInfo
->
nAlloc
>
0
)
{
free
(
pInfo
->
pDCLInfo
->
a
);
free
(
pInfo
->
pDCLInfo
->
a
);
}
}
if
(
pInfo
->
sqlType
==
CREATE_DATABASE
)
{
if
(
pInfo
->
type
==
TSDB_SQL_CREATE_DB
)
{
tVariantListDestroy
(
pInfo
->
pDCLInfo
->
dbOpt
.
keep
);
tVariantListDestroy
(
pInfo
->
pDCLInfo
->
dbOpt
.
keep
);
}
}
...
@@ -667,13 +677,52 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
...
@@ -667,13 +677,52 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
}
}
}
}
void
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SSQLToken
*
pMeterName
,
int32_t
type
)
{
SSubclauseInfo
*
setSubclause
(
SSubclauseInfo
*
pSubclause
,
void
*
pSqlExprInfo
)
{
pInfo
->
sqlType
=
type
;
if
(
pSubclause
==
NULL
)
{
pInfo
->
pCreateTableInfo
=
pSqlExprInfo
;
pSubclause
=
calloc
(
1
,
sizeof
(
SSubclauseInfo
));
}
int32_t
newSize
=
pSubclause
->
numOfClause
+
1
;
char
*
tmp
=
realloc
(
pSubclause
->
pClause
,
newSize
*
POINTER_BYTES
);
if
(
tmp
==
NULL
)
{
return
pSubclause
;
}
pSubclause
->
pClause
=
(
SQuerySQL
**
)
tmp
;
pSubclause
->
pClause
[
newSize
-
1
]
=
pSqlExprInfo
;
pSubclause
->
numOfClause
++
;
return
pSubclause
;
}
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SSQLToken
*
pMeterName
,
int32_t
type
)
{
pInfo
->
type
=
type
;
if
(
type
==
TSDB_SQL_SELECT
)
{
pInfo
->
subclauseInfo
=
*
(
SSubclauseInfo
*
)
pSqlExprInfo
;
free
(
pSqlExprInfo
);
}
else
{
pInfo
->
pCreateTableInfo
=
pSqlExprInfo
;
}
if
(
pMeterName
!=
NULL
)
{
if
(
pMeterName
!=
NULL
)
{
pInfo
->
pCreateTableInfo
->
name
=
*
pMeterName
;
pInfo
->
pCreateTableInfo
->
name
=
*
pMeterName
;
}
}
return
pInfo
;
}
SSubclauseInfo
*
appendSelectClause
(
SSubclauseInfo
*
pQueryInfo
,
void
*
pSubclause
)
{
char
*
tmp
=
realloc
(
pQueryInfo
->
pClause
,
(
pQueryInfo
->
numOfClause
+
1
)
*
POINTER_BYTES
);
if
(
tmp
==
NULL
)
{
// out of memory
return
pQueryInfo
;
}
pQueryInfo
->
pClause
=
(
SQuerySQL
**
)
tmp
;
pQueryInfo
->
pClause
[
pQueryInfo
->
numOfClause
++
]
=
pSubclause
;
return
pQueryInfo
;
}
}
void
setCreatedMeterName
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pMeterName
,
SSQLToken
*
pIfNotExists
)
{
void
setCreatedMeterName
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pMeterName
,
SSQLToken
*
pIfNotExists
)
{
...
@@ -703,7 +752,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken) {
...
@@ -703,7 +752,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken) {
}
}
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParam
,
...)
{
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParam
,
...)
{
pInfo
->
sqlT
ype
=
type
;
pInfo
->
t
ype
=
type
;
if
(
nParam
==
0
)
return
;
if
(
nParam
==
0
)
return
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
if
(
pInfo
->
pDCLInfo
==
NULL
)
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -718,8 +767,42 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
...
@@ -718,8 +767,42 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_end
(
va
);
va_end
(
va
);
}
}
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SSQLToken
*
existsCheck
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
prefix
,
SSQLToken
*
pPatterns
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
pInfo
->
type
=
TSDB_SQL_SHOW
;
SShowInfo
*
pShowInfo
=
&
pInfo
->
pDCLInfo
->
showOpt
;
pShowInfo
->
showType
=
type
;
if
(
prefix
!=
NULL
&&
prefix
->
type
!=
0
)
{
pShowInfo
->
prefix
=
*
prefix
;
}
else
{
pShowInfo
->
prefix
.
type
=
0
;
}
if
(
pPatterns
!=
NULL
&&
pPatterns
->
type
!=
0
)
{
pShowInfo
->
pattern
=
*
pPatterns
;
}
else
{
pShowInfo
->
pattern
.
type
=
0
;
}
}
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQLToken
*
pIgExists
)
{
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQLToken
*
pIgExists
)
{
pInfo
->
sqlT
ype
=
type
;
pInfo
->
t
ype
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
}
...
@@ -731,18 +814,68 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
...
@@ -731,18 +814,68 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
}
}
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
pInfo
->
sqlT
ype
=
type
;
pInfo
->
t
ype
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
}
pInfo
->
pDCLInfo
->
acctOpt
=
*
pAcctInfo
;
pInfo
->
pDCLInfo
->
acctOpt
=
*
pAcctInfo
;
assert
(
pName
!=
NULL
);
pInfo
->
pDCLInfo
->
user
.
user
=
*
pName
;
if
(
pPwd
!=
NULL
)
{
pInfo
->
pDCLInfo
->
user
.
passwd
=
*
pPwd
;
// pInfo->pDCLInfo->user.hasPasswd = true;
}
else
{
// pInfo->pDCLInfo->user.hasPasswd = false;
}
}
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pName
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SSQLToken
*
pName
,
SSQLToken
*
pPasswd
)
{
pInfo
->
type
=
TSDB_SQL_CREATE_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
assert
(
pName
!=
NULL
&&
pPasswd
!=
NULL
);
pInfo
->
pDCLInfo
->
user
.
user
=
*
pName
;
pInfo
->
pDCLInfo
->
user
.
passwd
=
*
pPasswd
;
}
if
(
pPwd
->
n
>
0
)
{
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQLToken
*
pPrivilege
)
{
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pPwd
);
pInfo
->
type
=
TSDB_SQL_ALTER_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
assert
(
pName
!=
NULL
);
SUserInfo
*
pUser
=
&
pInfo
->
pDCLInfo
->
user
;
pUser
->
type
=
type
;
pUser
->
user
=
*
pName
;
if
(
pPwd
!=
NULL
)
{
pUser
->
passwd
=
*
pPwd
;
// pUser->hasPasswd = true;
}
if
(
pPrivilege
!=
NULL
)
{
pUser
->
privilege
=
*
pPrivilege
;
// pUser->hasPrivilege = true;
}
}
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
ip
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
}
assert
(
ip
!=
NULL
);
pInfo
->
pDCLInfo
->
ip
=
*
ip
;
}
}
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
)
{
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
)
{
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscSql.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscStream.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/inc/hashutil.h
浏览文件 @
c18b6b1b
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#ifndef TDENGINE_HASHUTIL_H
#ifndef TDENGINE_HASHUTIL_H
#define TDENGINE_HASHUTIL_H
#define TDENGINE_HASHUTIL_H
#include "os.h"
typedef
uint32_t
(
*
_hash_fn_t
)(
const
char
*
,
uint32_t
);
typedef
uint32_t
(
*
_hash_fn_t
)(
const
char
*
,
uint32_t
);
...
...
src/inc/sql.y
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/inc/taosmsg.h
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/inc/tsqldef.h
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/inc/tutil.h
浏览文件 @
c18b6b1b
...
@@ -162,15 +162,6 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
...
@@ -162,15 +162,6 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
int32_t
taosInitTimer
(
void
(
*
callback
)(
int
),
int32_t
ms
);
int32_t
taosInitTimer
(
void
(
*
callback
)(
int
),
int32_t
ms
);
/**
* murmur hash algorithm
* @key usually string
* @len key length
* @seed hash seed
* @out an int32 value
*/
uint32_t
MurmurHash3_32
(
const
void
*
key
,
int32_t
len
);
bool
taosMbsToUcs4
(
char
*
mbs
,
int32_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
);
bool
taosMbsToUcs4
(
char
*
mbs
,
int32_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
);
bool
taosUcs4ToMbs
(
void
*
ucs4
,
int32_t
ucs4_max_len
,
char
*
mbs
);
bool
taosUcs4ToMbs
(
void
*
ucs4
,
int32_t
ucs4_max_len
,
char
*
mbs
);
...
...
src/system/detail/inc/vnodeQueryImpl.h
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/system/detail/inc/vnodeRead.h
浏览文件 @
c18b6b1b
...
@@ -172,7 +172,7 @@ typedef struct SMeterDataInfo {
...
@@ -172,7 +172,7 @@ typedef struct SMeterDataInfo {
}
SMeterDataInfo
;
}
SMeterDataInfo
;
typedef
struct
SMeterQuerySupportObj
{
typedef
struct
SMeterQuerySupportObj
{
void
*
pMeter
Obj
;
void
*
pMeter
sHashTable
;
// meter table hash list
SMeterSidExtInfo
**
pMeterSidExtInfo
;
SMeterSidExtInfo
**
pMeterSidExtInfo
;
int32_t
numOfMeters
;
int32_t
numOfMeters
;
...
...
src/system/detail/src/mgmtShell.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
src/system/lite/src/mgmtShell.spec.c
浏览文件 @
c18b6b1b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录