add the union support in sql parser. #1032. [TBASE-1140]
This commit is contained in:
parent
25fae2a1c4
commit
c18b6b1ba4
|
@ -21,17 +21,77 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "taos.h"
|
||||
#include "taosmsg.h"
|
||||
#include "tsqldef.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
|
||||
|
||||
// token type
|
||||
enum {
|
||||
TSQL_NODE_TYPE_EXPR = 0x1,
|
||||
TSQL_NODE_TYPE_ID = 0x2,
|
||||
TSQL_NODE_TYPE_VALUE = 0x4,
|
||||
TSQL_NODE_TYPE_EXPR = 0x1,
|
||||
TSQL_NODE_TYPE_ID = 0x2,
|
||||
TSQL_NODE_TYPE_VALUE = 0x4,
|
||||
};
|
||||
|
||||
extern char tTokenTypeSwitcher[13];
|
||||
|
@ -72,72 +132,12 @@ typedef struct tFieldList {
|
|||
TAOS_FIELD *p;
|
||||
} tFieldList;
|
||||
|
||||
// sql operation type
|
||||
// create table operation type
|
||||
enum TSQL_TYPE {
|
||||
TSQL_CREATE_NORMAL_METER = 0x01,
|
||||
TSQL_CREATE_NORMAL_METRIC = 0x02,
|
||||
TSQL_CREATE_METER_FROM_METRIC = 0x04,
|
||||
TSQL_CREATE_STREAM = 0x08,
|
||||
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,
|
||||
TSQL_CREATE_TABLE = 0x1,
|
||||
TSQL_CREATE_STABLE = 0x2,
|
||||
TSQL_CREATE_TABLE_FROM_STABLE = 0x3,
|
||||
TSQL_CREATE_STREAM = 0x4,
|
||||
};
|
||||
|
||||
typedef struct SQuerySQL {
|
||||
|
@ -157,33 +157,31 @@ typedef struct SQuerySQL {
|
|||
typedef struct SCreateTableSQL {
|
||||
struct SSQLToken name; // meter name, create table [meterName] xxx
|
||||
bool existCheck;
|
||||
|
||||
|
||||
int8_t type; // create normal table/from super table/ stream
|
||||
struct {
|
||||
tFieldList *pTagColumns; // for normal table, pTagColumns = NULL;
|
||||
tFieldList *pColumns;
|
||||
} colInfo;
|
||||
|
||||
struct {
|
||||
SSQLToken metricName; // metric name, for using clause
|
||||
SSQLToken stableName; // super table name, for using clause
|
||||
tVariantList *pTagVals; // create by using metric, tag value
|
||||
STagData tagdata;
|
||||
} usingInfo;
|
||||
|
||||
SQuerySQL *pSelect;
|
||||
|
||||
} SCreateTableSQL;
|
||||
|
||||
typedef struct SAlterTableSQL {
|
||||
SSQLToken name;
|
||||
int16_t type;
|
||||
STagData tagData;
|
||||
|
||||
tFieldList * pAddColumns;
|
||||
SSQLToken dropTagToken;
|
||||
tVariantList *varList; // set t=val or: change src dst
|
||||
} SAlterTableSQL;
|
||||
|
||||
typedef struct SInsertSQL {
|
||||
SSQLToken name;
|
||||
struct tSQLExprListList *pValue;
|
||||
} SInsertSQL;
|
||||
|
||||
typedef struct SCreateDBInfo {
|
||||
SSQLToken dbname;
|
||||
int32_t replica;
|
||||
|
@ -204,41 +202,68 @@ typedef struct SCreateDBInfo {
|
|||
} SCreateDBInfo;
|
||||
|
||||
typedef struct SCreateAcctSQL {
|
||||
int32_t users;
|
||||
int32_t dbs;
|
||||
int32_t tseries;
|
||||
int32_t streams;
|
||||
int32_t pps;
|
||||
int64_t storage;
|
||||
int64_t qtime;
|
||||
int32_t conns;
|
||||
int32_t maxUsers;
|
||||
int32_t maxDbs;
|
||||
int32_t maxTimeSeries;
|
||||
int32_t maxStreams;
|
||||
int32_t maxPointsPerSecond;
|
||||
int64_t maxStorage;
|
||||
int64_t maxQueryTime;
|
||||
int32_t maxConnections;
|
||||
SSQLToken stat;
|
||||
} 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 {
|
||||
int32_t nTokens; /* Number of expressions on the list */
|
||||
int32_t nAlloc; /* Number of entries allocated below */
|
||||
SSQLToken *a; /* one entry for element */
|
||||
bool existsCheck;
|
||||
|
||||
union {
|
||||
SCreateDBInfo dbOpt;
|
||||
SCreateAcctSQL acctOpt;
|
||||
SShowInfo showOpt;
|
||||
SSQLToken ip;
|
||||
};
|
||||
|
||||
SUserInfo user;
|
||||
|
||||
} tDCLSQL;
|
||||
|
||||
typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
|
||||
SQuerySQL **pClause;
|
||||
int32_t numOfClause;
|
||||
} SSubclauseInfo;
|
||||
|
||||
typedef struct SSqlInfo {
|
||||
int32_t sqlType;
|
||||
bool validSql;
|
||||
int32_t type;
|
||||
bool valid;
|
||||
|
||||
union {
|
||||
SCreateTableSQL *pCreateTableInfo;
|
||||
SInsertSQL * pInsertInfo;
|
||||
SAlterTableSQL * pAlterInfo;
|
||||
SQuerySQL * pQueryInfo;
|
||||
tDCLSQL * pDCLInfo;
|
||||
};
|
||||
|
||||
char pzErrMsg[256];
|
||||
SSubclauseInfo subclauseInfo;
|
||||
char pzErrMsg[256];
|
||||
} SSqlInfo;
|
||||
|
||||
typedef struct tSQLExpr {
|
||||
|
@ -338,31 +363,40 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
|
|||
|
||||
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pMetricName,
|
||||
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);
|
||||
|
||||
SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type);
|
||||
|
||||
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 type);
|
||||
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
|
||||
|
||||
void setCreatedMeterName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists);
|
||||
|
||||
void SQLInfoDestroy(SSqlInfo *pInfo);
|
||||
|
||||
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);
|
||||
|
||||
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 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);
|
||||
|
||||
// prefix show db.tables;
|
||||
|
|
|
@ -134,6 +134,7 @@ TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index);
|
|||
int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index);
|
||||
int32_t tscGetResRowLength(SSqlCmd* pCmd);
|
||||
void tscClearFieldInfo(SFieldInfo* pFieldInfo);
|
||||
int32_t tscNumOfFields(SSqlCmd* pCmd);
|
||||
|
||||
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
|
|||
SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta* pMeterMeta, SMetricMeta* pMetricMeta,
|
||||
int16_t numOfTags, int16_t* tags);
|
||||
SMeterMetaInfo* tscAddEmptyMeterMetaInfo(SSqlCmd* pCmd);
|
||||
int32_t tscAddQueryInfo(SSqlCmd *pCmd);
|
||||
|
||||
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr, uint64_t uid);
|
||||
int tscGetMetricMeta(SSqlObj* pSql);
|
||||
|
|
|
@ -43,66 +43,6 @@ extern "C" {
|
|||
((res->data + tscFieldInfoGetOffset(cmd, col) * res->numOfRows) + \
|
||||
(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
|
||||
struct SSqlInfo;
|
||||
|
||||
|
@ -267,6 +207,28 @@ typedef struct SDataBlockList {
|
|||
STableDataBlocks **pData;
|
||||
} 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 {
|
||||
SOrderVal order;
|
||||
int command;
|
||||
|
@ -274,18 +236,12 @@ typedef struct {
|
|||
|
||||
union {
|
||||
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
|
||||
bool import; // import/insert type
|
||||
uint8_t msgType;
|
||||
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;
|
||||
|
@ -297,22 +253,32 @@ typedef struct {
|
|||
char * payload;
|
||||
int payloadLen;
|
||||
short numOfCols;
|
||||
SColumnBaseInfo colList;
|
||||
SFieldInfo fieldsInfo;
|
||||
SSqlExprInfo exprsInfo;
|
||||
SLimitVal limit;
|
||||
SLimitVal slimit;
|
||||
int64_t globalLimit;
|
||||
STagCond tagCond;
|
||||
int16_t interpoType; // interpolate type
|
||||
int16_t numOfTables;
|
||||
|
||||
SQueryInfo *pQueryInfo;
|
||||
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
|
||||
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
|
||||
int32_t batchSize;
|
||||
|
@ -435,6 +401,8 @@ typedef struct {
|
|||
int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion);
|
||||
|
||||
void tscInitMsgs();
|
||||
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
||||
|
||||
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle);
|
||||
int tscProcessSql(SSqlObj *pSql);
|
||||
|
||||
|
|
2531
src/client/src/sql.c
2531
src/client/src/sql.c
File diff suppressed because it is too large
Load Diff
|
@ -131,8 +131,8 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
|
|||
}
|
||||
|
||||
/* update the limit value according to current retrieval results */
|
||||
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
|
||||
pCmd->limit.offset = pRes->offset;
|
||||
pCmd->pQueryInfo->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
|
||||
pCmd->pQueryInfo->limit.offset = pRes->offset;
|
||||
|
||||
if ((++(pMeterMetaInfo->vnodeIndex)) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
||||
tscTrace("%p retrieve data from next vnode:%d", pSql, pMeterMetaInfo->vnodeIndex);
|
||||
|
@ -282,7 +282,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
|
|||
}
|
||||
|
||||
/* 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) {
|
||||
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)
|
|||
assert(!pCmd->isInsertFromFile && pSql->signature == pSql);
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
assert(pCmd->numOfTables == 1);
|
||||
assert(pCmd->pQueryInfo->numOfTables == 1);
|
||||
|
||||
SDataBlockList *pDataBlocks = pCmd->pDataBlocks;
|
||||
if (pDataBlocks == NULL || pMeterMetaInfo->vnodeIndex >= pDataBlocks->nSize) {
|
||||
|
|
|
@ -53,11 +53,11 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
|
|||
*st = INT64_MAX;
|
||||
*et = INT64_MIN;
|
||||
|
||||
SLimitVal* pLimit = &pSql->cmd.limit;
|
||||
SLimitVal* pLimit = &pSql->cmd.pQueryInfo->limit;
|
||||
int32_t order = pSql->cmd.order.order;
|
||||
|
||||
pSql->pSubs[0]->cmd.tsBuf = output1;
|
||||
pSql->pSubs[1]->cmd.tsBuf = output2;
|
||||
pSql->pSubs[0]->cmd.pQueryInfo->tsBuf = output1;
|
||||
pSql->pSubs[1]->cmd.pQueryInfo->tsBuf = output2;
|
||||
|
||||
tsBufResetPos(pSupporter1->pTSBuf);
|
||||
tsBufResetPos(pSupporter2->pTSBuf);
|
||||
|
@ -113,7 +113,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSubquerySupporter* pSuppor
|
|||
}
|
||||
|
||||
// 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(output2, elem2.vnode, elem2.tag, (const char*)&elem2.ts, sizeof(elem2.ts));
|
||||
} else {
|
||||
|
@ -168,8 +168,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
|
|||
pSupporter->pState = pState;
|
||||
|
||||
pSupporter->subqueryIndex = index;
|
||||
pSupporter->interval = pSql->cmd.nAggTimeInterval;
|
||||
pSupporter->limit = pSql->cmd.limit;
|
||||
pSupporter->interval = pSql->cmd.pQueryInfo->nAggTimeInterval;
|
||||
pSupporter->limit = pSql->cmd.pQueryInfo->limit;
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, index);
|
||||
pSupporter->uid = pMeterMetaInfo->pMeterMeta->uid;
|
||||
|
@ -211,8 +211,8 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
|
|||
*/
|
||||
bool needSecondaryQuery(SSqlObj* pSql) {
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
for (int32_t i = 0; i < pCmd->colList.numOfCols; ++i) {
|
||||
SColumnBase* pBase = tscColumnBaseInfoGet(&pCmd->colList, i);
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo->colList.numOfCols; ++i) {
|
||||
SColumnBase* pBase = tscColumnBaseInfoGet(&pCmd->pQueryInfo->colList, i);
|
||||
if (pBase->colIndex.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
return true;
|
||||
}
|
||||
|
@ -272,25 +272,25 @@ int32_t tscLaunchSecondSubquery(SSqlObj* pSql) {
|
|||
tscFreeSqlCmdData(&pNew->cmd);
|
||||
|
||||
pSql->pSubs[j++] = pNew;
|
||||
pNew->cmd.tsBuf = pSub->cmd.tsBuf;
|
||||
pSub->cmd.tsBuf = NULL;
|
||||
pNew->cmd.pQueryInfo->tsBuf = pSub->cmd.pQueryInfo->tsBuf;
|
||||
pSub->cmd.pQueryInfo->tsBuf = NULL;
|
||||
|
||||
taos_free_result(pSub);
|
||||
|
||||
// set the second stage sub query for join process
|
||||
pNew->cmd.type |= TSDB_QUERY_TYPE_JOIN_SEC_STAGE;
|
||||
|
||||
pNew->cmd.nAggTimeInterval = pSupporter->interval;
|
||||
pNew->cmd.groupbyExpr = pSupporter->groupbyExpr;
|
||||
pNew->cmd.pQueryInfo->nAggTimeInterval = pSupporter->interval;
|
||||
pNew->cmd.pQueryInfo->groupbyExpr = pSupporter->groupbyExpr;
|
||||
|
||||
tscColumnBaseInfoCopy(&pNew->cmd.colList, &pSupporter->colList, 0);
|
||||
tscTagCondCopy(&pNew->cmd.tagCond, &pSupporter->tagCond);
|
||||
tscColumnBaseInfoCopy(&pNew->cmd.pQueryInfo->colList, &pSupporter->colList, 0);
|
||||
tscTagCondCopy(&pNew->cmd.pQueryInfo->tagCond, &pSupporter->tagCond);
|
||||
|
||||
tscSqlExprCopy(&pNew->cmd.exprsInfo, &pSupporter->exprsInfo, pSupporter->uid);
|
||||
tscFieldInfoCopyAll(&pSupporter->fieldsInfo, &pNew->cmd.fieldsInfo);
|
||||
tscSqlExprCopy(&pNew->cmd.pQueryInfo->exprsInfo, &pSupporter->exprsInfo, pSupporter->uid);
|
||||
tscFieldInfoCopyAll(&pSupporter->fieldsInfo, &pNew->cmd.pQueryInfo->fieldsInfo);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* during the timestamp intersection.
|
||||
*/
|
||||
pSupporter->limit = pSql->cmd.limit;
|
||||
pNew->cmd.limit = pSupporter->limit;
|
||||
pSupporter->limit = pSql->cmd.pQueryInfo->limit;
|
||||
pNew->cmd.pQueryInfo->limit = pSupporter->limit;
|
||||
|
||||
// fetch the join tag column
|
||||
if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
|
||||
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->numOfParams = 1;
|
||||
}
|
||||
|
@ -370,10 +370,10 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSubquerySupporter* pSupporter
|
|||
|
||||
// update the query time range according to the join results on timestamp
|
||||
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.etime = et;
|
||||
pSql->cmd.pQueryInfo->stime = st;
|
||||
pSql->cmd.pQueryInfo->etime = et;
|
||||
}
|
||||
|
||||
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);
|
||||
pSupporter->pTSBuf = pBuf;
|
||||
} 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);
|
||||
|
||||
tsBufMerge(pSupporter->pTSBuf, pBuf, pMeterMetaInfo->vnodeIndex);
|
||||
|
@ -424,7 +424,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
|||
} else if (numOfRows == 0) { // no data from this vnode anymore
|
||||
if (tscProjectionQueryOnMetric(&pParentSql->cmd)) {
|
||||
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 ((++pMeterMetaInfo->vnodeIndex) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
||||
|
@ -480,7 +480,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
|||
|
||||
if (tscProjectionQueryOnMetric(&pSql->cmd) && numOfRows == 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
|
||||
if ((++pMeterMetaInfo->vnodeIndex) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
||||
|
@ -555,7 +555,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
|
|||
|
||||
// wait for all subqueries completed
|
||||
pSupporter->pState->numOfTotal = numOfFetch;
|
||||
assert(pRes1->numOfRows >= 0 && pCmd1->numOfTables == 1);
|
||||
assert(pRes1->numOfRows >= 0 && pCmd1->pQueryInfo->numOfTables == 1);
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd1, 0);
|
||||
|
||||
|
@ -589,13 +589,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
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);
|
||||
|
||||
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];
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSub->cmd, 0);
|
||||
|
@ -607,7 +607,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
|
||||
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);
|
||||
if (pExpr->functionId == pSubExpr->functionId && pExpr->colInfo.colId == pSubExpr->colInfo.colId) {
|
||||
pRes->pColumnIndex[i] = (SColumnIndex){.tableIndex = tableIndexOfSub, .columnIndex = k};
|
||||
|
|
|
@ -254,16 +254,16 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
|
||||
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;
|
||||
|
||||
tscFieldInfoSetValue(&pCmd->fieldsInfo, 1, TSDB_DATA_TYPE_BINARY, "Type", typeColLength);
|
||||
tscFieldInfoSetValue(&pCmd->pQueryInfo->fieldsInfo, 1, TSDB_DATA_TYPE_BINARY, "Type", 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);
|
||||
|
||||
tscFieldInfoSetValue(&pCmd->fieldsInfo, 3, TSDB_DATA_TYPE_BINARY, "Note", noteColLength);
|
||||
tscFieldInfoSetValue(&pCmd->pQueryInfo->fieldsInfo, 3, TSDB_DATA_TYPE_BINARY, "Note", noteColLength);
|
||||
rowLen += noteColLength;
|
||||
|
||||
return rowLen;
|
||||
|
@ -321,7 +321,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
|
|||
for (int32_t j = 0; j < pSidList->numOfSids; ++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;
|
||||
int16_t offsetId = pColIndex->colIdx;
|
||||
|
||||
|
@ -352,7 +352,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
|
|||
|
||||
int32_t rowIdx = 0;
|
||||
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);
|
||||
|
||||
if (pExpr->colInfo.colIdx == -1 && pExpr->functionId == TSDB_FUNC_COUNT) {
|
||||
|
@ -444,7 +444,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
|
|||
pCmd->numOfCols = 1;
|
||||
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);
|
||||
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, 0);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#define _XOPEN_SOURCE
|
||||
|
||||
#include <hash.h>
|
||||
#include "os.h"
|
||||
#include "ihash.h"
|
||||
#include "tscSecondaryMerge.h"
|
||||
|
@ -953,7 +954,8 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
|
|||
}
|
||||
|
||||
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();
|
||||
if (NULL == pSql->pTableHashList || NULL == pSql->cmd.pDataBlocks) {
|
||||
code = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||
|
@ -1239,8 +1241,9 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion) {
|
|||
tscRemoveAllMeterMetaInfo(&pSql->cmd, false);
|
||||
|
||||
if (NULL == pSql->asyncTblPos) {
|
||||
tscTrace("continue parse sql: %s", pSql->asyncTblPos);
|
||||
tscCleanSqlCmd(&pSql->cmd);
|
||||
} else {
|
||||
tscTrace("continue parse sql: %s", pSql->asyncTblPos);
|
||||
}
|
||||
|
||||
if (tscIsInsertOrImportData(pSql->sqlstr)) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@
|
|||
|
||||
int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
|
||||
void *pParser = ParseAlloc(malloc);
|
||||
pSQLInfo->validSql = true;
|
||||
pSQLInfo->valid = true;
|
||||
|
||||
int32_t i = 0;
|
||||
while (1) {
|
||||
|
@ -50,12 +50,12 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
|
|||
}
|
||||
case TK_ILLEGAL: {
|
||||
snprintf(pSQLInfo->pzErrMsg, tListLen(pSQLInfo->pzErrMsg), "unrecognized token: \"%s\"", t0.z);
|
||||
pSQLInfo->validSql = false;
|
||||
pSQLInfo->valid = false;
|
||||
goto abort_parse;
|
||||
}
|
||||
default:
|
||||
Parse(pParser, t0.type, t0, pSQLInfo);
|
||||
if (pSQLInfo->validSql == false) {
|
||||
if (pSQLInfo->valid == false) {
|
||||
goto abort_parse;
|
||||
}
|
||||
}
|
||||
|
@ -554,58 +554,62 @@ tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExp
|
|||
return pList;
|
||||
}
|
||||
|
||||
void tSetInsertSQLElems(SSqlInfo *pInfo, SSQLToken *pName, tSQLExprListList *pList) {
|
||||
SInsertSQL *pInsert = calloc(1, sizeof(SInsertSQL));
|
||||
|
||||
pInsert->name = *pName;
|
||||
pInsert->pValue = pList;
|
||||
|
||||
pInfo->pInsertInfo = pInsert;
|
||||
pInfo->sqlType = TSQL_INSERT;
|
||||
void doDestroyQuerySql(SQuerySQL *pQuerySql) {
|
||||
if (pQuerySql == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tSQLExprListDestroy(pQuerySql->pSelection);
|
||||
|
||||
pQuerySql->pSelection = NULL;
|
||||
|
||||
tSQLExprDestroy(pQuerySql->pWhere);
|
||||
pQuerySql->pWhere = NULL;
|
||||
|
||||
tVariantListDestroy(pQuerySql->pSortOrder);
|
||||
pQuerySql->pSortOrder = NULL;
|
||||
|
||||
tVariantListDestroy(pQuerySql->pGroupby);
|
||||
pQuerySql->pGroupby = NULL;
|
||||
|
||||
tVariantListDestroy(pQuerySql->from);
|
||||
pQuerySql->from = NULL;
|
||||
|
||||
tVariantListDestroy(pQuerySql->fillType);
|
||||
|
||||
free(pQuerySql);
|
||||
}
|
||||
|
||||
void destroyQuerySql(SQuerySQL *pSql) {
|
||||
if (pSql == NULL) return;
|
||||
void destroyAllSelectClause(SSubclauseInfo *pClause) {
|
||||
if (pClause == NULL || pClause->numOfClause == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tSQLExprListDestroy(pSql->pSelection);
|
||||
pSql->pSelection = NULL;
|
||||
|
||||
tSQLExprDestroy(pSql->pWhere);
|
||||
pSql->pWhere = NULL;
|
||||
|
||||
tVariantListDestroy(pSql->pSortOrder);
|
||||
pSql->pSortOrder = NULL;
|
||||
|
||||
tVariantListDestroy(pSql->pGroupby);
|
||||
pSql->pGroupby = NULL;
|
||||
|
||||
tVariantListDestroy(pSql->from);
|
||||
pSql->from = NULL;
|
||||
|
||||
tVariantListDestroy(pSql->fillType);
|
||||
|
||||
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 *pMetricName,
|
||||
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pStableName,
|
||||
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type) {
|
||||
SCreateTableSQL *pCreate = calloc(1, sizeof(SCreateTableSQL));
|
||||
|
||||
switch (type) {
|
||||
case TSQL_CREATE_NORMAL_METER: {
|
||||
case TSQL_CREATE_TABLE: {
|
||||
pCreate->colInfo.pColumns = pCols;
|
||||
assert(pTagVals == NULL && pTags == NULL);
|
||||
break;
|
||||
}
|
||||
case TSQL_CREATE_NORMAL_METRIC: {
|
||||
case TSQL_CREATE_STABLE: {
|
||||
pCreate->colInfo.pColumns = pCols;
|
||||
pCreate->colInfo.pTagColumns = pTags;
|
||||
assert(pTagVals == NULL && pTags != NULL && pCols != NULL);
|
||||
break;
|
||||
}
|
||||
case TSQL_CREATE_METER_FROM_METRIC: {
|
||||
case TSQL_CREATE_TABLE_FROM_STABLE: {
|
||||
pCreate->usingInfo.pTagVals = pTagVals;
|
||||
pCreate->usingInfo.metricName = *pMetricName;
|
||||
pCreate->usingInfo.stableName = *pStableName;
|
||||
break;
|
||||
}
|
||||
case TSQL_CREATE_STREAM: {
|
||||
|
@ -616,19 +620,24 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
|
|||
assert(false);
|
||||
}
|
||||
|
||||
pCreate->type = type;
|
||||
return pCreate;
|
||||
}
|
||||
|
||||
SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type) {
|
||||
SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL));
|
||||
|
||||
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;
|
||||
assert(pVals == NULL);
|
||||
} 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;
|
||||
assert(pCols == NULL);
|
||||
}
|
||||
|
@ -639,27 +648,28 @@ SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tV
|
|||
void SQLInfoDestroy(SSqlInfo *pInfo) {
|
||||
if (pInfo == NULL) return;
|
||||
|
||||
if (pInfo->sqlType == TSQL_QUERY_METER) {
|
||||
destroyQuerySql(pInfo->pQueryInfo);
|
||||
} else if (pInfo->sqlType >= TSQL_CREATE_NORMAL_METER && pInfo->sqlType <= TSQL_CREATE_STREAM) {
|
||||
if (pInfo->type == TSDB_SQL_SELECT) {
|
||||
destroyAllSelectClause(&pInfo->subclauseInfo);
|
||||
} else if (pInfo->type == TSDB_SQL_CREATE_TABLE) {
|
||||
SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo;
|
||||
destroyQuerySql(pCreateTableInfo->pSelect);
|
||||
doDestroyQuerySql(pCreateTableInfo->pSelect);
|
||||
|
||||
tFieldListDestroy(pCreateTableInfo->colInfo.pColumns);
|
||||
tFieldListDestroy(pCreateTableInfo->colInfo.pTagColumns);
|
||||
|
||||
tVariantListDestroy(pCreateTableInfo->usingInfo.pTagVals);
|
||||
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);
|
||||
tFieldListDestroy(pInfo->pAlterInfo->pAddColumns);
|
||||
|
||||
tfree(pInfo->pAlterInfo);
|
||||
} else {
|
||||
if (pInfo->pDCLInfo != NULL && pInfo->pDCLInfo->nAlloc > 0) {
|
||||
free(pInfo->pDCLInfo->a);
|
||||
}
|
||||
|
||||
if (pInfo->sqlType == CREATE_DATABASE) {
|
||||
if (pInfo->type == TSDB_SQL_CREATE_DB) {
|
||||
tVariantListDestroy(pInfo->pDCLInfo->dbOpt.keep);
|
||||
}
|
||||
|
||||
|
@ -667,13 +677,52 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
void setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SSQLToken *pMeterName, int32_t type) {
|
||||
pInfo->sqlType = type;
|
||||
pInfo->pCreateTableInfo = pSqlExprInfo;
|
||||
SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
|
||||
if (pSubclause == NULL) {
|
||||
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) {
|
||||
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) {
|
||||
|
@ -703,7 +752,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken) {
|
|||
}
|
||||
|
||||
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
||||
pInfo->sqlType = type;
|
||||
pInfo->type = type;
|
||||
|
||||
if (nParam == 0) return;
|
||||
if (pInfo->pDCLInfo == NULL) pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
|
@ -718,8 +767,42 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
|||
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) {
|
||||
pInfo->sqlType = type;
|
||||
pInfo->type = type;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
}
|
||||
|
@ -731,20 +814,70 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
|
|||
}
|
||||
|
||||
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
||||
pInfo->sqlType = type;
|
||||
pInfo->type = type;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
}
|
||||
|
||||
pInfo->pDCLInfo->acctOpt = *pAcctInfo;
|
||||
|
||||
tTokenListAppend(pInfo->pDCLInfo, pName);
|
||||
|
||||
if (pPwd->n > 0) {
|
||||
tTokenListAppend(pInfo->pDCLInfo, pPwd);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken* pPwd, SSQLToken *pPrivilege) {
|
||||
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) {
|
||||
pDBInfo->numOfBlocksPerTable = 50;
|
||||
pDBInfo->compressionLevel = -1;
|
||||
|
|
|
@ -58,12 +58,12 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
|
|||
* the fields and offset attributes in pCmd and pModel may be different due to
|
||||
* merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object.
|
||||
*/
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
SQLFunctionCtx *pCtx = &pReducer->pCtx[i];
|
||||
|
||||
pCtx->aOutputBuf = pReducer->pResultBuf->data + tscFieldInfoGetOffset(pCmd, i) * pReducer->resColModel->maxCapacity;
|
||||
pCtx->order = pCmd->order.order;
|
||||
pCtx->functionId = pCmd->exprsInfo.pExprs[i].functionId;
|
||||
pCtx->functionId = pCmd->pQueryInfo[0].exprsInfo.pExprs[i].functionId;
|
||||
|
||||
// input buffer hold only one point data
|
||||
pCtx->aInputElemBuf = pReducer->pTempBuffer->data + pDesc->pSchema->colOffset[i];
|
||||
|
@ -105,10 +105,10 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
|
|||
|
||||
int16_t n = 0;
|
||||
int16_t tagLen = 0;
|
||||
SQLFunctionCtx** pTagCtx = calloc(pCmd->fieldsInfo.numOfOutputCols, POINTER_BYTES);
|
||||
SQLFunctionCtx** pTagCtx = calloc(pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols, POINTER_BYTES);
|
||||
|
||||
SQLFunctionCtx* pCtx = NULL;
|
||||
for(int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for(int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pCmd, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_TAG_DUMMY || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
tagLen += pExpr->resBytes;
|
||||
|
@ -238,7 +238,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
|||
param->pLocalData = pReducer->pLocalDataSrc;
|
||||
param->pDesc = pReducer->pDesc;
|
||||
param->numOfElems = pReducer->pLocalDataSrc[0]->pMemBuffer->numOfElemsPerPage;
|
||||
param->groupOrderType = pCmd->groupbyExpr.orderType;
|
||||
param->groupOrderType = pCmd->pQueryInfo[0].groupbyExpr.orderType;
|
||||
|
||||
pRes->code = tLoserTreeCreate(&pReducer->pLoserTree, pReducer->numOfBuffer, param, treeComparator);
|
||||
if (pReducer->pLoserTree == NULL || pRes->code != 0) {
|
||||
|
@ -247,7 +247,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
|||
|
||||
// the input data format follows the old format, but output in a new format.
|
||||
// so, all the input must be parsed as old format
|
||||
pReducer->pCtx = (SQLFunctionCtx *)calloc(pCmd->fieldsInfo.numOfOutputCols, sizeof(SQLFunctionCtx));
|
||||
pReducer->pCtx = (SQLFunctionCtx *)calloc(pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols, sizeof(SQLFunctionCtx));
|
||||
|
||||
pReducer->rowSize = pMemBuffer[0]->nElemSize;
|
||||
|
||||
|
@ -294,14 +294,14 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
|||
}
|
||||
|
||||
pReducer->pTempBuffer->numOfElems = 0;
|
||||
pReducer->pResInfo = calloc((size_t)pCmd->fieldsInfo.numOfOutputCols, sizeof(SResultInfo));
|
||||
pReducer->pResInfo = calloc((size_t)pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols, sizeof(SResultInfo));
|
||||
|
||||
tscCreateResPointerInfo(pCmd, pRes);
|
||||
tscInitSqlContext(pCmd, pRes, pReducer, pDesc);
|
||||
|
||||
// we change the maxCapacity of schema to denote that there is only one row in temp buffer
|
||||
pReducer->pDesc->pSchema->maxCapacity = 1;
|
||||
pReducer->offset = pCmd->limit.offset;
|
||||
pReducer->offset = pCmd->pQueryInfo->limit.offset;
|
||||
|
||||
pRes->pLocalReducer = pReducer;
|
||||
pRes->numOfGroups = 0;
|
||||
|
@ -309,18 +309,18 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
|||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
int16_t prec = pMeterMetaInfo->pMeterMeta->precision;
|
||||
|
||||
int64_t stime = (pCmd->stime < pCmd->etime) ? pCmd->stime : pCmd->etime;
|
||||
int64_t revisedSTime = taosGetIntervalStartTimestamp(stime, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit, prec);
|
||||
int64_t stime = (pCmd->pQueryInfo[0].stime < pCmd->pQueryInfo[0].etime) ? pCmd->pQueryInfo[0].stime : pCmd->pQueryInfo[0].etime;
|
||||
int64_t revisedSTime = taosGetIntervalStartTimestamp(stime, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit, prec);
|
||||
|
||||
SInterpolationInfo *pInterpoInfo = &pReducer->interpolationInfo;
|
||||
taosInitInterpoInfo(pInterpoInfo, pCmd->order.order, revisedSTime, pCmd->groupbyExpr.numOfGroupCols,
|
||||
taosInitInterpoInfo(pInterpoInfo, pCmd->order.order, revisedSTime, pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols,
|
||||
pReducer->rowSize);
|
||||
|
||||
int32_t startIndex = pCmd->fieldsInfo.numOfOutputCols - pCmd->groupbyExpr.numOfGroupCols;
|
||||
int32_t startIndex = pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols - pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols;
|
||||
|
||||
if (pCmd->groupbyExpr.numOfGroupCols > 0) {
|
||||
pInterpoInfo->pTags[0] = (char *)pInterpoInfo->pTags + POINTER_BYTES * pCmd->groupbyExpr.numOfGroupCols;
|
||||
for (int32_t i = 1; i < pCmd->groupbyExpr.numOfGroupCols; ++i) {
|
||||
if (pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols > 0) {
|
||||
pInterpoInfo->pTags[0] = (char *)pInterpoInfo->pTags + POINTER_BYTES * pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols;
|
||||
for (int32_t i = 1; i < pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols; ++i) {
|
||||
pInterpoInfo->pTags[i] = pReducer->resColModel->pFields[startIndex + i - 1].bytes + pInterpoInfo->pTags[i - 1];
|
||||
}
|
||||
} else {
|
||||
|
@ -444,7 +444,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
|||
tfree(pLocalReducer->interpolationInfo.pTags);
|
||||
|
||||
if (pLocalReducer->pCtx != NULL) {
|
||||
for(int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for(int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[i];
|
||||
tVariantDestroy(&pCtx->tag);
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
|||
tfree(pLocalReducer->pResultBuf);
|
||||
|
||||
if (pLocalReducer->pResInfo != NULL) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
tfree(pLocalReducer->pResInfo[i].interResultBuf);
|
||||
}
|
||||
|
||||
|
@ -494,12 +494,12 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
|||
|
||||
static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCmd, tColModel *pModel) {
|
||||
int32_t numOfGroupByCols = 0;
|
||||
if (pCmd->groupbyExpr.numOfGroupCols > 0) {
|
||||
numOfGroupByCols = pCmd->groupbyExpr.numOfGroupCols;
|
||||
if (pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols > 0) {
|
||||
numOfGroupByCols = pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols;
|
||||
}
|
||||
|
||||
// primary timestamp column is involved in final result
|
||||
if (pCmd->nAggTimeInterval != 0) {
|
||||
if (pCmd->pQueryInfo[0].nAggTimeInterval != 0) {
|
||||
numOfGroupByCols++;
|
||||
}
|
||||
|
||||
|
@ -509,14 +509,14 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
|
|||
}
|
||||
|
||||
if (numOfGroupByCols > 0) {
|
||||
int32_t startCols = pCmd->fieldsInfo.numOfOutputCols - pCmd->groupbyExpr.numOfGroupCols;
|
||||
int32_t startCols = pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols - pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols;
|
||||
|
||||
// tags value locate at the last columns
|
||||
for (int32_t i = 0; i < pCmd->groupbyExpr.numOfGroupCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols; ++i) {
|
||||
orderIdx[i] = startCols++;
|
||||
}
|
||||
|
||||
if (pCmd->nAggTimeInterval != 0) {
|
||||
if (pCmd->pQueryInfo[0].nAggTimeInterval != 0) {
|
||||
// the first column is the timestamp, handles queries like "interval(10m) group by tags"
|
||||
orderIdx[numOfGroupByCols - 1] = PRIMARYKEY_TIMESTAMP_COL_INDEX;
|
||||
}
|
||||
|
@ -550,10 +550,10 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
|
|||
|
||||
if (pOrderDesc->orderIdx.pData[numOfCols - 1] == PRIMARYKEY_TIMESTAMP_COL_INDEX) { //<= 0
|
||||
// super table interval query
|
||||
assert(pCmd->nAggTimeInterval > 0);
|
||||
assert(pCmd->pQueryInfo[0].nAggTimeInterval > 0);
|
||||
pOrderDesc->orderIdx.numOfOrderedCols -= 1;
|
||||
} else { // simple group by query
|
||||
assert(pCmd->nAggTimeInterval == 0);
|
||||
assert(pCmd->pQueryInfo[0].nAggTimeInterval == 0);
|
||||
}
|
||||
|
||||
// only one row exists
|
||||
|
@ -581,7 +581,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
pSchema = (SSchema *)calloc(1, sizeof(SSchema) * pCmd->fieldsInfo.numOfOutputCols);
|
||||
pSchema = (SSchema *)calloc(1, sizeof(SSchema) * pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
if (pSchema == NULL) {
|
||||
tscError("%p failed to allocate memory", pSql);
|
||||
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||
|
@ -589,7 +589,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
}
|
||||
|
||||
int32_t rlen = 0;
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pCmd, i);
|
||||
|
||||
pSchema[i].bytes = pExpr->resBytes;
|
||||
|
@ -599,7 +599,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
}
|
||||
|
||||
int32_t capacity = nBufferSizes / rlen;
|
||||
pModel = tColModelCreate(pSchema, pCmd->fieldsInfo.numOfOutputCols, capacity);
|
||||
pModel = tColModelCreate(pSchema, pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols, capacity);
|
||||
|
||||
for (int32_t i = 0; i < pMeterMetaInfo->pMetricMeta->numOfVnodes; ++i) {
|
||||
char tmpPath[512] = {0};
|
||||
|
@ -615,8 +615,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
memset(pSchema, 0, sizeof(SSchema) * pCmd->fieldsInfo.numOfOutputCols);
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
memset(pSchema, 0, sizeof(SSchema) * pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
||||
pSchema[i].type = pField->type;
|
||||
|
@ -624,7 +624,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
strcpy(pSchema[i].name, pField->name);
|
||||
}
|
||||
|
||||
*pFinalModel = tColModelCreate(pSchema, pCmd->fieldsInfo.numOfOutputCols, capacity);
|
||||
*pFinalModel = tColModelCreate(pSchema, pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols, capacity);
|
||||
tfree(pSchema);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -719,10 +719,10 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SSqlCmd *pC
|
|||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
int16_t prec = pMeterMetaInfo->pMeterMeta->precision;
|
||||
|
||||
int64_t stime = (pCmd->stime < pCmd->etime) ? pCmd->stime : pCmd->etime;
|
||||
int64_t revisedSTime = taosGetIntervalStartTimestamp(stime, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit, prec);
|
||||
int64_t stime = (pCmd->pQueryInfo[0].stime < pCmd->pQueryInfo[0].etime) ? pCmd->pQueryInfo[0].stime : pCmd->pQueryInfo[0].etime;
|
||||
int64_t revisedSTime = taosGetIntervalStartTimestamp(stime, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit, prec);
|
||||
|
||||
taosInitInterpoInfo(pInterpoInfo, pCmd->order.order, revisedSTime, pCmd->groupbyExpr.numOfGroupCols,
|
||||
taosInitInterpoInfo(pInterpoInfo, pCmd->order.order, revisedSTime, pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols,
|
||||
pLocalReducer->rowSize);
|
||||
|
||||
pLocalReducer->discard = true;
|
||||
|
@ -734,7 +734,7 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SSqlCmd *pC
|
|||
|
||||
// todo merge with following function
|
||||
static void reversedCopyResultToDstBuf(SSqlCmd *pCmd, SSqlRes *pRes, tFilePage *pFinalDataPage) {
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
||||
int32_t offset = tscFieldInfoGetOffset(pCmd, i);
|
||||
|
@ -751,7 +751,7 @@ static void reversedCopyResultToDstBuf(SSqlCmd *pCmd, SSqlRes *pRes, tFilePage *
|
|||
|
||||
static void reversedCopyFromInterpolationToDstBuf(SSqlCmd *pCmd, SSqlRes *pRes, tFilePage **pResPages,
|
||||
SLocalReducer *pLocalReducer) {
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
||||
int32_t offset = tscFieldInfoGetOffset(pCmd, i);
|
||||
|
@ -786,38 +786,38 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
assert(pRes->pLocalReducer == NULL);
|
||||
}
|
||||
|
||||
if (pCmd->nAggTimeInterval == 0 || pCmd->interpoType == TSDB_INTERPO_NONE) {
|
||||
if (pCmd->pQueryInfo[0].nAggTimeInterval == 0 || pCmd->pQueryInfo[0].interpoType == TSDB_INTERPO_NONE) {
|
||||
// no interval query, no interpolation
|
||||
pRes->data = pLocalReducer->pFinalRes;
|
||||
pRes->numOfRows = pFinalDataPage->numOfElems;
|
||||
pRes->numOfTotal += pRes->numOfRows;
|
||||
|
||||
if (pCmd->limit.offset > 0) {
|
||||
if (pCmd->limit.offset < pRes->numOfRows) {
|
||||
if (pCmd->pQueryInfo->limit.offset > 0) {
|
||||
if (pCmd->pQueryInfo->limit.offset < pRes->numOfRows) {
|
||||
int32_t prevSize = pFinalDataPage->numOfElems;
|
||||
tColModelErase(pLocalReducer->resColModel, pFinalDataPage, prevSize, 0, pCmd->limit.offset - 1);
|
||||
tColModelErase(pLocalReducer->resColModel, pFinalDataPage, prevSize, 0, pCmd->pQueryInfo->limit.offset - 1);
|
||||
|
||||
/* remove the hole in column model */
|
||||
tColModelCompact(pLocalReducer->resColModel, pFinalDataPage, prevSize);
|
||||
|
||||
pRes->numOfRows -= pCmd->limit.offset;
|
||||
pRes->numOfTotal -= pCmd->limit.offset;
|
||||
pCmd->limit.offset = 0;
|
||||
pRes->numOfRows -= pCmd->pQueryInfo->limit.offset;
|
||||
pRes->numOfTotal -= pCmd->pQueryInfo->limit.offset;
|
||||
pCmd->pQueryInfo->limit.offset = 0;
|
||||
} else {
|
||||
pCmd->limit.offset -= pRes->numOfRows;
|
||||
pCmd->pQueryInfo->limit.offset -= pRes->numOfRows;
|
||||
pRes->numOfRows = 0;
|
||||
pRes->numOfTotal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pCmd->limit.limit >= 0 && pRes->numOfTotal > pCmd->limit.limit) {
|
||||
if (pCmd->pQueryInfo->limit.limit >= 0 && pRes->numOfTotal > pCmd->pQueryInfo->limit.limit) {
|
||||
/* impose the limitation of output rows on the final result */
|
||||
int32_t prevSize = pFinalDataPage->numOfElems;
|
||||
int32_t overFlow = pRes->numOfTotal - pCmd->limit.limit;
|
||||
int32_t overFlow = pRes->numOfTotal - pCmd->pQueryInfo->limit.limit;
|
||||
|
||||
assert(overFlow < pRes->numOfRows);
|
||||
|
||||
pRes->numOfTotal = pCmd->limit.limit;
|
||||
pRes->numOfTotal = pCmd->pQueryInfo->limit.limit;
|
||||
pRes->numOfRows -= overFlow;
|
||||
pFinalDataPage->numOfElems -= overFlow;
|
||||
|
||||
|
@ -842,18 +842,18 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
int64_t * pPrimaryKeys = (int64_t *)pLocalReducer->pBufForInterpo;
|
||||
SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo;
|
||||
|
||||
int64_t actualETime = (pCmd->stime < pCmd->etime) ? pCmd->etime : pCmd->stime;
|
||||
int64_t actualETime = (pCmd->pQueryInfo[0].stime < pCmd->pQueryInfo[0].etime) ? pCmd->pQueryInfo[0].etime : pCmd->pQueryInfo[0].stime;
|
||||
|
||||
tFilePage **pResPages = malloc(POINTER_BYTES * pCmd->fieldsInfo.numOfOutputCols);
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
tFilePage **pResPages = malloc(POINTER_BYTES * pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->maxCapacity);
|
||||
}
|
||||
|
||||
char ** srcData = (char **)malloc((POINTER_BYTES + sizeof(int32_t)) * pCmd->fieldsInfo.numOfOutputCols);
|
||||
int32_t *functions = (int32_t *)((char *)srcData + pCmd->fieldsInfo.numOfOutputCols * sizeof(void *));
|
||||
char ** srcData = (char **)malloc((POINTER_BYTES + sizeof(int32_t)) * pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
int32_t *functions = (int32_t *)((char *)srcData + pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols * sizeof(void *));
|
||||
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
srcData[i] = pLocalReducer->pBufForInterpo + tscFieldInfoGetOffset(pCmd, i) * pInterpoInfo->numOfRawDataInRows;
|
||||
functions[i] = tscSqlExprGet(pCmd, i)->functionId;
|
||||
}
|
||||
|
@ -863,23 +863,23 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
|
||||
while (1) {
|
||||
int32_t remains = taosNumOfRemainPoints(pInterpoInfo);
|
||||
TSKEY etime = taosGetRevisedEndKey(actualETime, pCmd->order.order, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit,
|
||||
TSKEY etime = taosGetRevisedEndKey(actualETime, pCmd->order.order, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit,
|
||||
precision);
|
||||
int32_t nrows = taosGetNumOfResultWithInterpo(pInterpoInfo, pPrimaryKeys, remains, pCmd->nAggTimeInterval, etime,
|
||||
int32_t nrows = taosGetNumOfResultWithInterpo(pInterpoInfo, pPrimaryKeys, remains, pCmd->pQueryInfo[0].nAggTimeInterval, etime,
|
||||
pLocalReducer->resColModel->maxCapacity);
|
||||
|
||||
int32_t newRows = taosDoInterpoResult(pInterpoInfo, pCmd->interpoType, pResPages, remains, nrows,
|
||||
pCmd->nAggTimeInterval, pPrimaryKeys, pLocalReducer->resColModel, srcData,
|
||||
pCmd->defaultVal, functions, pLocalReducer->resColModel->maxCapacity);
|
||||
int32_t newRows = taosDoInterpoResult(pInterpoInfo, pCmd->pQueryInfo[0].interpoType, pResPages, remains, nrows,
|
||||
pCmd->pQueryInfo[0].nAggTimeInterval, pPrimaryKeys, pLocalReducer->resColModel, srcData,
|
||||
pCmd->pQueryInfo[0].defaultVal, functions, pLocalReducer->resColModel->maxCapacity);
|
||||
assert(newRows <= nrows);
|
||||
|
||||
if (pCmd->limit.offset < newRows) {
|
||||
newRows -= pCmd->limit.offset;
|
||||
if (pCmd->pQueryInfo->limit.offset < newRows) {
|
||||
newRows -= pCmd->pQueryInfo->limit.offset;
|
||||
|
||||
if (pCmd->limit.offset > 0) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
if (pCmd->pQueryInfo->limit.offset > 0) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
memmove(pResPages[i]->data, pResPages[i]->data + pField->bytes * pCmd->limit.offset, newRows * pField->bytes);
|
||||
memmove(pResPages[i]->data, pResPages[i]->data + pField->bytes * pCmd->pQueryInfo->limit.offset, newRows * pField->bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -887,10 +887,10 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
pRes->numOfRows = newRows;
|
||||
pRes->numOfTotal += newRows;
|
||||
|
||||
pCmd->limit.offset = 0;
|
||||
pCmd->pQueryInfo->limit.offset = 0;
|
||||
break;
|
||||
} else {
|
||||
pCmd->limit.offset -= newRows;
|
||||
pCmd->pQueryInfo->limit.offset -= newRows;
|
||||
pRes->numOfRows = 0;
|
||||
|
||||
int32_t rpoints = taosNumOfRemainPoints(pInterpoInfo);
|
||||
|
@ -902,7 +902,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
|
||||
/* all output for current group are completed */
|
||||
int32_t totalRemainRows =
|
||||
taosGetNumOfResWithoutLimit(pInterpoInfo, pPrimaryKeys, rpoints, pCmd->nAggTimeInterval, actualETime);
|
||||
taosGetNumOfResWithoutLimit(pInterpoInfo, pPrimaryKeys, rpoints, pCmd->pQueryInfo[0].nAggTimeInterval, actualETime);
|
||||
if (totalRemainRows <= 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -911,13 +911,13 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
}
|
||||
|
||||
if (pRes->numOfRows > 0) {
|
||||
if (pCmd->limit.limit >= 0 && pRes->numOfTotal > pCmd->limit.limit) {
|
||||
int32_t overFlow = pRes->numOfTotal - pCmd->limit.limit;
|
||||
if (pCmd->pQueryInfo->limit.limit >= 0 && pRes->numOfTotal > pCmd->pQueryInfo->limit.limit) {
|
||||
int32_t overFlow = pRes->numOfTotal - pCmd->pQueryInfo->limit.limit;
|
||||
pRes->numOfRows -= overFlow;
|
||||
|
||||
assert(pRes->numOfRows >= 0);
|
||||
|
||||
pRes->numOfTotal = pCmd->limit.limit;
|
||||
pRes->numOfTotal = pCmd->pQueryInfo->limit.limit;
|
||||
pFinalDataPage->numOfElems -= overFlow;
|
||||
|
||||
/* set remain data to be discarded, and reset the interpolation information */
|
||||
|
@ -925,7 +925,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
}
|
||||
|
||||
if (pCmd->order.order == TSQL_SO_ASC) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
||||
memcpy(pRes->data + pLocalReducer->resColModel->colOffset[i] * pRes->numOfRows, pResPages[i]->data,
|
||||
|
@ -937,7 +937,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
|
|||
}
|
||||
|
||||
pFinalDataPage->numOfElems = 0;
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
tfree(pResPages[i]);
|
||||
}
|
||||
tfree(pResPages);
|
||||
|
@ -961,7 +961,7 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
|
|||
|
||||
static void doExecuteSecondaryMerge(SSqlCmd* pCmd, SLocalReducer *pLocalReducer, bool needInit) {
|
||||
// the tag columns need to be set before all functions execution
|
||||
for(int32_t j = 0; j < pCmd->fieldsInfo.numOfOutputCols; ++j) {
|
||||
for(int32_t j = 0; j < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++j) {
|
||||
SSqlExpr * pExpr = tscSqlExprGet(pCmd, j);
|
||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[j];
|
||||
|
||||
|
@ -981,7 +981,7 @@ static void doExecuteSecondaryMerge(SSqlCmd* pCmd, SLocalReducer *pLocalReducer,
|
|||
}
|
||||
}
|
||||
|
||||
for (int32_t j = 0; j < pCmd->fieldsInfo.numOfOutputCols; ++j) {
|
||||
for (int32_t j = 0; j < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++j) {
|
||||
int32_t functionId = tscSqlExprGet(pCmd, j)->functionId;
|
||||
if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
continue;
|
||||
|
@ -1002,7 +1002,7 @@ static void handleUnprocessedRow(SSqlCmd* pCmd, SLocalReducer *pLocalReducer, tF
|
|||
static int64_t getNumOfResultLocal(SSqlCmd *pCmd, SQLFunctionCtx *pCtx) {
|
||||
int64_t maxOutput = 0;
|
||||
|
||||
for (int32_t j = 0; j < pCmd->exprsInfo.numOfExprs; ++j) {
|
||||
for (int32_t j = 0; j < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++j) {
|
||||
int32_t functionId = tscSqlExprGet(pCmd, j)->functionId;
|
||||
|
||||
/*
|
||||
|
@ -1028,7 +1028,7 @@ static int64_t getNumOfResultLocal(SSqlCmd *pCmd, SQLFunctionCtx *pCtx) {
|
|||
*/
|
||||
static void fillMultiRowsOfTagsVal(SSqlCmd *pCmd, int32_t numOfRes, SLocalReducer *pLocalReducer) {
|
||||
int32_t maxBufSize = 0; // find the max tags column length to prepare the buffer
|
||||
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, k);
|
||||
if (maxBufSize < pExpr->resBytes && pExpr->functionId == TSDB_FUNC_TAG) {
|
||||
maxBufSize = pExpr->resBytes;
|
||||
|
@ -1038,7 +1038,7 @@ static void fillMultiRowsOfTagsVal(SSqlCmd *pCmd, int32_t numOfRes, SLocalReduce
|
|||
assert(maxBufSize >= 0);
|
||||
|
||||
char *buf = malloc((size_t) maxBufSize);
|
||||
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, k);
|
||||
if (pExpr->functionId != TSDB_FUNC_TAG) {
|
||||
continue;
|
||||
|
@ -1060,7 +1060,7 @@ static void fillMultiRowsOfTagsVal(SSqlCmd *pCmd, int32_t numOfRes, SLocalReduce
|
|||
}
|
||||
|
||||
int32_t finalizeRes(SSqlCmd *pCmd, SLocalReducer *pLocalReducer) {
|
||||
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, k);
|
||||
aAggs[pExpr->functionId].xFinalize(&pLocalReducer->pCtx[k]);
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ bool needToMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, tFilePage *tmpBuff
|
|||
}
|
||||
|
||||
static bool reachGroupResultLimit(SSqlCmd *pCmd, SSqlRes *pRes) {
|
||||
return (pRes->numOfGroups >= pCmd->slimit.limit && pCmd->slimit.limit >= 0);
|
||||
return (pRes->numOfGroups >= pCmd->pQueryInfo[0].slimit.limit && pCmd->pQueryInfo[0].slimit.limit >= 0);
|
||||
}
|
||||
|
||||
static bool saveGroupResultInfo(SSqlObj *pSql) {
|
||||
|
@ -1147,9 +1147,9 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
|
|||
* ignore the output of the current group since this group is skipped by user
|
||||
* We set the numOfRows to be 0 and discard the possible remain results.
|
||||
*/
|
||||
if (pCmd->slimit.offset > 0) {
|
||||
if (pCmd->pQueryInfo[0].slimit.offset > 0) {
|
||||
pRes->numOfRows = 0;
|
||||
pCmd->slimit.offset -= 1;
|
||||
pCmd->pQueryInfo[0].slimit.offset -= 1;
|
||||
pLocalReducer->discard = !noMoreCurrentGroupRes;
|
||||
return false;
|
||||
}
|
||||
|
@ -1163,22 +1163,22 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
|
|||
#endif
|
||||
|
||||
SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo;
|
||||
int32_t startIndex = pCmd->fieldsInfo.numOfOutputCols - pCmd->groupbyExpr.numOfGroupCols;
|
||||
int32_t startIndex = pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols - pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols;
|
||||
|
||||
for (int32_t i = 0; i < pCmd->groupbyExpr.numOfGroupCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols; ++i) {
|
||||
memcpy(pInterpoInfo->pTags[i],
|
||||
pLocalReducer->pBufForInterpo + pModel->colOffset[startIndex + i] * pResBuf->numOfElems,
|
||||
pModel->pFields[startIndex + i].bytes);
|
||||
}
|
||||
|
||||
taosInterpoSetStartInfo(&pLocalReducer->interpolationInfo, pResBuf->numOfElems, pCmd->interpoType);
|
||||
taosInterpoSetStartInfo(&pLocalReducer->interpolationInfo, pResBuf->numOfElems, pCmd->pQueryInfo[0].interpoType);
|
||||
doInterpolateResult(pSql, pLocalReducer, noMoreCurrentGroupRes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void resetOutputBuf(SSqlCmd *pCmd, SLocalReducer *pLocalReducer) { // reset output buffer to the beginning
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
pLocalReducer->pCtx[i].aOutputBuf =
|
||||
pLocalReducer->pResultBuf->data + tscFieldInfoGetOffset(pCmd, i) * pLocalReducer->resColModel->maxCapacity;
|
||||
}
|
||||
|
@ -1190,17 +1190,17 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
|
|||
// In handling data in other groups, we need to reset the interpolation information for a new group data
|
||||
pRes->numOfRows = 0;
|
||||
pRes->numOfTotal = 0;
|
||||
pCmd->limit.offset = pLocalReducer->offset;
|
||||
pCmd->pQueryInfo->limit.offset = pLocalReducer->offset;
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
int16_t precision = pMeterMetaInfo->pMeterMeta->precision;
|
||||
|
||||
// for group result interpolation, do not return if not data is generated
|
||||
if (pCmd->interpoType != TSDB_INTERPO_NONE) {
|
||||
int64_t stime = (pCmd->stime < pCmd->etime) ? pCmd->stime : pCmd->etime;
|
||||
int64_t newTime = taosGetIntervalStartTimestamp(stime, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit, precision);
|
||||
if (pCmd->pQueryInfo[0].interpoType != TSDB_INTERPO_NONE) {
|
||||
int64_t stime = (pCmd->pQueryInfo[0].stime < pCmd->pQueryInfo[0].etime) ? pCmd->pQueryInfo[0].stime : pCmd->pQueryInfo[0].etime;
|
||||
int64_t newTime = taosGetIntervalStartTimestamp(stime, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit, precision);
|
||||
|
||||
taosInitInterpoInfo(&pLocalReducer->interpolationInfo, pCmd->order.order, newTime, pCmd->groupbyExpr.numOfGroupCols,
|
||||
taosInitInterpoInfo(&pLocalReducer->interpolationInfo, pCmd->order.order, newTime, pCmd->pQueryInfo[0].groupbyExpr.numOfGroupCols,
|
||||
pLocalReducer->rowSize);
|
||||
}
|
||||
}
|
||||
|
@ -1220,15 +1220,15 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
|
|||
int8_t p = pMeterMetaInfo->pMeterMeta->precision;
|
||||
|
||||
if (taosHasRemainsDataForInterpolation(pInterpoInfo)) {
|
||||
assert(pCmd->interpoType != TSDB_INTERPO_NONE);
|
||||
assert(pCmd->pQueryInfo[0].interpoType != TSDB_INTERPO_NONE);
|
||||
|
||||
tFilePage *pFinalDataBuf = pLocalReducer->pResultBuf;
|
||||
int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pInterpoInfo->numOfRawDataInRows - 1));
|
||||
|
||||
int32_t remain = taosNumOfRemainPoints(pInterpoInfo);
|
||||
TSKEY ekey = taosGetRevisedEndKey(etime, pCmd->order.order, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit, p);
|
||||
TSKEY ekey = taosGetRevisedEndKey(etime, pCmd->order.order, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit, p);
|
||||
int32_t rows = taosGetNumOfResultWithInterpo(pInterpoInfo, (TSKEY *)pLocalReducer->pBufForInterpo, remain,
|
||||
pCmd->nAggTimeInterval, ekey, pLocalReducer->resColModel->maxCapacity);
|
||||
pCmd->pQueryInfo[0].nAggTimeInterval, ekey, pLocalReducer->resColModel->maxCapacity);
|
||||
if (rows > 0) { // do interpo
|
||||
doInterpolateResult(pSql, pLocalReducer, false);
|
||||
}
|
||||
|
@ -1254,11 +1254,11 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
|||
if ((isAllSourcesCompleted(pLocalReducer) && !pLocalReducer->hasPrevRow) || pLocalReducer->pLocalDataSrc[0] == NULL ||
|
||||
prevGroupCompleted) {
|
||||
// if interpoType == TSDB_INTERPO_NONE, return directly
|
||||
if (pCmd->interpoType != TSDB_INTERPO_NONE) {
|
||||
int64_t etime = (pCmd->stime < pCmd->etime) ? pCmd->etime : pCmd->stime;
|
||||
if (pCmd->pQueryInfo[0].interpoType != TSDB_INTERPO_NONE) {
|
||||
int64_t etime = (pCmd->pQueryInfo[0].stime < pCmd->pQueryInfo[0].etime) ? pCmd->pQueryInfo[0].etime : pCmd->pQueryInfo[0].stime;
|
||||
|
||||
etime = taosGetRevisedEndKey(etime, pCmd->order.order, pCmd->nAggTimeInterval, pCmd->intervalTimeUnit, precision);
|
||||
int32_t rows = taosGetNumOfResultWithInterpo(pInterpoInfo, NULL, 0, pCmd->nAggTimeInterval, etime,
|
||||
etime = taosGetRevisedEndKey(etime, pCmd->order.order, pCmd->pQueryInfo[0].nAggTimeInterval, pCmd->pQueryInfo[0].intervalTimeUnit, precision);
|
||||
int32_t rows = taosGetNumOfResultWithInterpo(pInterpoInfo, NULL, 0, pCmd->pQueryInfo[0].nAggTimeInterval, etime,
|
||||
pLocalReducer->resColModel->maxCapacity);
|
||||
if (rows > 0) { // do interpo
|
||||
doInterpolateResult(pSql, pLocalReducer, true);
|
||||
|
@ -1291,7 +1291,7 @@ static void doMergeWithPrevRows(SSqlObj *pSql, int32_t numOfRes) {
|
|||
SSqlRes * pRes = &pSql->res;
|
||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
||||
|
||||
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, k);
|
||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k];
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,7 @@
|
|||
#include "tsocket.h"
|
||||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
#include "ihash.h"
|
||||
#include "hash.h"
|
||||
|
||||
TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, uint16_t port,
|
||||
void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) {
|
||||
|
@ -207,7 +207,7 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) {
|
|||
pRes->numOfTotal = 0;
|
||||
pSql->asyncTblPos = NULL;
|
||||
if (NULL != pSql->pTableHashList) {
|
||||
taosCleanUpIntHash(pSql->pTableHashList);
|
||||
taosCleanUpHashTable(pSql->pTableHashList);
|
||||
pSql->pTableHashList = NULL;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ int taos_num_fields(TAOS_RES *res) {
|
|||
SSqlObj *pSql = (SSqlObj *)res;
|
||||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||
|
||||
SFieldInfo *pFieldsInfo = &pSql->cmd.fieldsInfo;
|
||||
SFieldInfo *pFieldsInfo = &pSql->cmd.pQueryInfo[0].fieldsInfo;
|
||||
|
||||
return (pFieldsInfo->numOfOutputCols - pFieldsInfo->numOfHiddenCols);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
|||
SSqlObj *pSql = (SSqlObj *)res;
|
||||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||
|
||||
return pSql->cmd.fieldsInfo.pFields;
|
||||
return pSql->cmd.pQueryInfo[0].fieldsInfo.pFields;
|
||||
}
|
||||
|
||||
int taos_retrieve(TAOS_RES *res) {
|
||||
|
@ -370,7 +370,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
|
|||
pRes->numOfTotal += pRes->numOfRows;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pCmd, i, pCmd->order) +
|
||||
pRes->bytes[i] * (1 - pCmd->order.order) * (pRes->numOfRows - 1);
|
||||
}
|
||||
|
@ -386,11 +386,11 @@ static void **doSetResultRowData(SSqlObj *pSql) {
|
|||
|
||||
int32_t num = 0;
|
||||
|
||||
for (int i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pCmd, i, pCmd->order) + pRes->bytes[i] * pRes->row;
|
||||
|
||||
// primary key column cannot be null in interval query, no need to check
|
||||
if (i == 0 && pCmd->nAggTimeInterval > 0) {
|
||||
if (i == 0 && pCmd->pQueryInfo[0].nAggTimeInterval > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ static void **doSetResultRowData(SSqlObj *pSql) {
|
|||
}
|
||||
}
|
||||
|
||||
assert(num <= pCmd->fieldsInfo.numOfOutputCols);
|
||||
assert(num <= pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
|
||||
return pRes->tsrow;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
|||
SSqlCmd *pCmd1 = &pSql->pSubs[i]->cmd;
|
||||
|
||||
SMeterMetaInfo *pMetaInfo = tscGetMeterMetaInfo(pCmd1, 0);
|
||||
assert(pCmd1->numOfTables == 1);
|
||||
assert(pCmd1->pQueryInfo[0].numOfTables == 1);
|
||||
|
||||
/*
|
||||
* if the global limitation is not reached, and current result has not exhausted, or next more vnodes are
|
||||
|
@ -500,7 +500,7 @@ static void **tscJoinResultsetFromBuf(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
if (pRes->tsrow == NULL) {
|
||||
pRes->tsrow = malloc(POINTER_BYTES * pCmd->exprsInfo.numOfExprs);
|
||||
pRes->tsrow = malloc(POINTER_BYTES * pCmd->pQueryInfo[0].exprsInfo.numOfExprs);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
|
@ -526,7 +526,7 @@ static void **tscJoinResultsetFromBuf(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
if (success) { // current row of final output has been built, return to app
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
int32_t tableIndex = pRes->pColumnIndex[i].tableIndex;
|
||||
int32_t columnIndex = pRes->pColumnIndex[i].columnIndex;
|
||||
|
||||
|
@ -611,8 +611,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
* update the limit and offset value according to current retrieval results
|
||||
* Note: if pRes->offset > 0, pRes->numOfRows = 0, pRes->numOfTotal = 0;
|
||||
*/
|
||||
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
|
||||
pCmd->limit.offset = pRes->offset;
|
||||
pCmd->pQueryInfo->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
|
||||
pCmd->pQueryInfo->limit.offset = pRes->offset;
|
||||
|
||||
assert((pRes->offset >= 0 && pRes->numOfRows == 0) || (pRes->offset == 0 && pRes->numOfRows >= 0));
|
||||
|
||||
|
@ -665,8 +665,8 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
|||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
|
||||
/* update the limit value according to current retrieval results */
|
||||
pCmd->limit.limit = pSql->cmd.globalLimit - pRes->numOfTotal;
|
||||
pCmd->limit.offset = pRes->offset;
|
||||
pCmd->pQueryInfo->limit.limit = pSql->cmd.globalLimit - pRes->numOfTotal;
|
||||
pCmd->pQueryInfo->limit.offset = pRes->offset;
|
||||
|
||||
if ((++pMeterMetaInfo->vnodeIndex) < pMeterMetaInfo->pMetricMeta->numOfVnodes) {
|
||||
pSql->cmd.command = TSDB_SQL_SELECT;
|
||||
|
@ -956,7 +956,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
|||
|
||||
pSql->asyncTblPos = NULL;
|
||||
if (NULL != pSql->pTableHashList) {
|
||||
taosCleanUpIntHash(pSql->pTableHashList);
|
||||
taosCleanUpHashTable(pSql->pTableHashList);
|
||||
pSql->pTableHashList = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql);
|
|||
static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer);
|
||||
|
||||
static bool isProjectStream(SSqlCmd *pCmd) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pCmd, i);
|
||||
if (pExpr->functionId != TSDB_FUNC_PRJ) {
|
||||
return false;
|
||||
|
@ -109,18 +109,18 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
|
|||
|
||||
if (isProjectStream(&pSql->cmd)) {
|
||||
/*
|
||||
* pSql->cmd.etime, which is the start time, does not change in case of
|
||||
* pSql->cmd.pQueryInfo[0].etime, which is the start time, does not change in case of
|
||||
* repeat first execution, once the first execution failed.
|
||||
*/
|
||||
pSql->cmd.stime = pStream->stime; // start time
|
||||
pSql->cmd.pQueryInfo[0].stime = pStream->stime; // start time
|
||||
|
||||
pSql->cmd.etime = taosGetTimestamp(pStream->precision); // end time
|
||||
if (pSql->cmd.etime > pStream->etime) {
|
||||
pSql->cmd.etime = pStream->etime;
|
||||
pSql->cmd.pQueryInfo[0].etime = taosGetTimestamp(pStream->precision); // end time
|
||||
if (pSql->cmd.pQueryInfo[0].etime > pStream->etime) {
|
||||
pSql->cmd.pQueryInfo[0].etime = pStream->etime;
|
||||
}
|
||||
} else {
|
||||
pSql->cmd.stime = pStream->stime - pStream->interval;
|
||||
pSql->cmd.etime = pStream->stime - 1;
|
||||
pSql->cmd.pQueryInfo[0].stime = pStream->stime - pStream->interval;
|
||||
pSql->cmd.pQueryInfo[0].etime = pStream->stime - 1;
|
||||
}
|
||||
|
||||
// launch stream computing in a new thread
|
||||
|
@ -198,7 +198,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
pStream->useconds += pSql->res.useconds;
|
||||
|
||||
if (pStream->numOfRes == 0) {
|
||||
if (pSql->cmd.interpoType == TSDB_INTERPO_SET_VALUE || pSql->cmd.interpoType == TSDB_INTERPO_NULL) {
|
||||
if (pSql->cmd.pQueryInfo[0].interpoType == TSDB_INTERPO_SET_VALUE || pSql->cmd.pQueryInfo[0].interpoType == TSDB_INTERPO_NULL) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
|
@ -210,11 +210,11 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
void *oldPtr = pSql->res.data;
|
||||
pSql->res.data = tmpRes;
|
||||
|
||||
for (int32_t i = 1; i < pSql->cmd.fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 1; i < pSql->cmd.pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
int16_t offset = tscFieldInfoGetOffset(pCmd, i);
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
||||
assignVal(pSql->res.data + offset, (char *)(&pCmd->defaultVal[i]), pField->bytes, pField->type);
|
||||
assignVal(pSql->res.data + offset, (char *)(&pCmd->pQueryInfo[0].defaultVal[i]), pField->bytes, pField->type);
|
||||
row[i] = pSql->res.data + offset;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
row[0] = pRes->data;
|
||||
|
||||
// char result[512] = {0};
|
||||
// taos_print_row(result, row, pSql->cmd.fieldsInfo.pFields, pSql->cmd.fieldsInfo.numOfOutputCols);
|
||||
// taos_print_row(result, row, pSql->cmd.pQueryInfo[0].fieldsInfo.pFields, pSql->cmd.pQueryInfo[0].fieldsInfo.numOfOutputCols);
|
||||
// tscPrint("%p stream:%p query result: %s", pSql, pStream, result);
|
||||
tscTrace("%p stream:%p fetch result", pSql, pStream);
|
||||
|
||||
|
@ -352,36 +352,36 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
|
|||
|
||||
int64_t minIntervalTime =
|
||||
(pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinIntervalTime * 1000L : tsMinIntervalTime;
|
||||
if (pCmd->nAggTimeInterval < minIntervalTime) {
|
||||
if (pCmd->pQueryInfo[0].nAggTimeInterval < minIntervalTime) {
|
||||
tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64 "", pSql, pStream,
|
||||
pCmd->nAggTimeInterval, minIntervalTime);
|
||||
pCmd->nAggTimeInterval = minIntervalTime;
|
||||
pCmd->pQueryInfo[0].nAggTimeInterval, minIntervalTime);
|
||||
pCmd->pQueryInfo[0].nAggTimeInterval = minIntervalTime;
|
||||
}
|
||||
|
||||
pStream->interval = pCmd->nAggTimeInterval; // it shall be derived from sql string
|
||||
pStream->interval = pCmd->pQueryInfo[0].nAggTimeInterval; // it shall be derived from sql string
|
||||
|
||||
if (pCmd->nSlidingTime == 0) {
|
||||
pCmd->nSlidingTime = pCmd->nAggTimeInterval;
|
||||
if (pCmd->pQueryInfo[0].nSlidingTime == 0) {
|
||||
pCmd->pQueryInfo[0].nSlidingTime = pCmd->pQueryInfo[0].nAggTimeInterval;
|
||||
}
|
||||
|
||||
int64_t minSlidingTime =
|
||||
(pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinSlidingTime * 1000L : tsMinSlidingTime;
|
||||
|
||||
if (pCmd->nSlidingTime < minSlidingTime) {
|
||||
tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64 "", pSql, pStream, pCmd->nSlidingTime,
|
||||
minSlidingTime);
|
||||
if (pCmd->pQueryInfo[0].nSlidingTime < minSlidingTime) {
|
||||
tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64 "", pSql, pStream,
|
||||
pCmd->pQueryInfo[0].nSlidingTime, minSlidingTime);
|
||||
|
||||
pCmd->nSlidingTime = minSlidingTime;
|
||||
pCmd->pQueryInfo[0].nSlidingTime = minSlidingTime;
|
||||
}
|
||||
|
||||
if (pCmd->nSlidingTime > pCmd->nAggTimeInterval) {
|
||||
if (pCmd->pQueryInfo[0].nSlidingTime > pCmd->pQueryInfo[0].nAggTimeInterval) {
|
||||
tscWarn("%p stream:%p, sliding value:%" PRId64 " can not be larger than interval range, reset to:%" PRId64 "", pSql, pStream,
|
||||
pCmd->nSlidingTime, pCmd->nAggTimeInterval);
|
||||
pCmd->pQueryInfo[0].nSlidingTime, pCmd->pQueryInfo[0].nAggTimeInterval);
|
||||
|
||||
pCmd->nSlidingTime = pCmd->nAggTimeInterval;
|
||||
pCmd->pQueryInfo[0].nSlidingTime = pCmd->pQueryInfo[0].nAggTimeInterval;
|
||||
}
|
||||
|
||||
pStream->slidingTime = pCmd->nSlidingTime;
|
||||
pStream->slidingTime = pCmd->pQueryInfo[0].nSlidingTime;
|
||||
}
|
||||
|
||||
static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) {
|
||||
|
@ -393,10 +393,10 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
|
|||
pStream->slidingTime = tsProjectExecInterval;
|
||||
|
||||
if (stime != 0) { // first projection start from the latest event timestamp
|
||||
assert(stime >= pCmd->stime);
|
||||
assert(stime >= pCmd->pQueryInfo[0].stime);
|
||||
stime += 1; // exclude the last records from table
|
||||
} else {
|
||||
stime = pCmd->stime;
|
||||
stime = pCmd->pQueryInfo[0].stime;
|
||||
}
|
||||
} else { // timewindow based aggregation stream
|
||||
if (stime == 0) { // no data in meter till now
|
||||
|
@ -529,7 +529,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
|
|||
pStream->precision = pMeterMetaInfo->pMeterMeta->precision;
|
||||
|
||||
pStream->ctime = taosGetTimestamp(pStream->precision);
|
||||
pStream->etime = pCmd->etime;
|
||||
pStream->etime = pCmd->pQueryInfo[0].etime;
|
||||
|
||||
pSql->pStream = pStream;
|
||||
tscAddIntoStreamList(pStream);
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tscUtil.h"
|
||||
#include "hash.h"
|
||||
#include "os.h"
|
||||
#include "ihash.h"
|
||||
#include "taosmsg.h"
|
||||
#include "tcache.h"
|
||||
#include "tkey.h"
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include "tscProfile.h"
|
||||
#include "tscSecondaryMerge.h"
|
||||
#include "tschemautil.h"
|
||||
#include "tscUtil.h"
|
||||
#include "tsclient.h"
|
||||
#include "tsqldef.h"
|
||||
#include "ttimer.h"
|
||||
|
@ -47,7 +47,7 @@ void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* str, uint64_t uid) {
|
|||
len += sprintf(&tagIdBuf[len], "%d,", pMeterMetaInfo->tagColumnIndex[i]);
|
||||
}
|
||||
|
||||
STagCond* pTagCond = &pCmd->tagCond;
|
||||
STagCond* pTagCond = &pCmd->pQueryInfo[0].tagCond;
|
||||
assert(len < tListLen(tagIdBuf));
|
||||
|
||||
const int32_t maxKeySize = TSDB_MAX_TAGS_LEN; // allowed max key size
|
||||
|
@ -73,7 +73,7 @@ void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* str, uint64_t uid) {
|
|||
|
||||
int32_t keyLen = snprintf(tmp, bufSize, "%s,%s,%s,%d,%s,[%s],%d", pMeterMetaInfo->name,
|
||||
(cond != NULL ? cond->cond : NULL), (tbnameCondLen > 0 ? pTagCond->tbnameCond.cond : NULL),
|
||||
pTagCond->relType, join, tagIdBuf, pCmd->groupbyExpr.orderType);
|
||||
pTagCond->relType, join, tagIdBuf, pCmd->pQueryInfo[0].groupbyExpr.orderType);
|
||||
|
||||
assert(keyLen <= bufSize);
|
||||
|
||||
|
@ -120,7 +120,7 @@ bool tscQueryOnMetric(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
bool tscQueryMetricTags(SSqlCmd* pCmd) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
if (tscSqlExprGet(pCmd, i)->functionId != TSDB_FUNC_TAGPRJ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd) {
|
|||
bool hasTags = false;
|
||||
int32_t numOfSelectivity = 0;
|
||||
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
int32_t functId = tscSqlExprGet(pCmd, i)->functionId;
|
||||
if (functId == TSDB_FUNC_TAG_DUMMY) {
|
||||
hasTags = true;
|
||||
|
@ -232,7 +232,7 @@ bool tscProjectionQueryOnMetric(SSqlCmd* pCmd) {
|
|||
* 1. failed to get metermeta from server; 2. not a metric; 3. limit 0; 4. show query, instead of a select query
|
||||
*/
|
||||
if (pMeterMetaInfo == NULL || !UTIL_METER_IS_METRIC(pMeterMetaInfo) ||
|
||||
pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pCmd->exprsInfo.numOfExprs == 0) {
|
||||
pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pCmd->pQueryInfo[0].exprsInfo.numOfExprs == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ bool tscProjectionQueryOnMetric(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
// for project query, only the following two function is allowed
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
int32_t functionId = tscSqlExprGet(pCmd, i)->functionId;
|
||||
if (functionId != TSDB_FUNC_PRJ && functionId != TSDB_FUNC_TAGPRJ && functionId != TSDB_FUNC_TAG &&
|
||||
functionId != TSDB_FUNC_TS && functionId != TSDB_FUNC_ARITHM) {
|
||||
|
@ -254,7 +254,7 @@ bool tscProjectionQueryOnMetric(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
bool tscProjectionQueryOnTable(SSqlCmd* pCmd) {
|
||||
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; ++i) {
|
||||
int32_t functionId = tscSqlExprGet(pCmd, i)->functionId;
|
||||
if (functionId != TSDB_FUNC_PRJ && functionId != TSDB_FUNC_TS) {
|
||||
return false;
|
||||
|
@ -265,7 +265,7 @@ bool tscProjectionQueryOnTable(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
bool tscIsPointInterpQuery(SSqlCmd* pCmd) {
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
|
||||
if (pExpr == NULL) {
|
||||
return false;
|
||||
|
@ -284,7 +284,7 @@ bool tscIsPointInterpQuery(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
bool tscIsTWAQuery(SSqlCmd* pCmd) {
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
|
||||
if (pExpr == NULL) {
|
||||
continue;
|
||||
|
@ -304,8 +304,8 @@ void tscClearInterpInfo(SSqlCmd* pCmd) {
|
|||
return;
|
||||
}
|
||||
|
||||
pCmd->interpoType = TSDB_INTERPO_NONE;
|
||||
memset(pCmd->defaultVal, 0, sizeof(pCmd->defaultVal));
|
||||
pCmd->pQueryInfo[0].interpoType = TSDB_INTERPO_NONE;
|
||||
memset(pCmd->pQueryInfo[0].defaultVal, 0, sizeof(pCmd->pQueryInfo[0].defaultVal));
|
||||
}
|
||||
|
||||
void tscClearSqlMetaInfoForce(SSqlCmd* pCmd) {
|
||||
|
@ -319,7 +319,7 @@ void tscClearSqlMetaInfoForce(SSqlCmd* pCmd) {
|
|||
int32_t tscCreateResPointerInfo(SSqlCmd* pCmd, SSqlRes* pRes) {
|
||||
if (pRes->tsrow == NULL) {
|
||||
pRes->numOfnchar = 0;
|
||||
int32_t numOfOutputCols = pCmd->fieldsInfo.numOfOutputCols;
|
||||
int32_t numOfOutputCols = pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols;
|
||||
|
||||
for (int32_t i = 0; i < numOfOutputCols; ++i) {
|
||||
TAOS_FIELD* pField = tscFieldInfoGetField(pCmd, i);
|
||||
|
@ -361,18 +361,22 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
|||
void tscFreeSqlCmdData(SSqlCmd* pCmd) {
|
||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||
|
||||
tscTagCondRelease(&pCmd->tagCond);
|
||||
tscClearFieldInfo(&pCmd->fieldsInfo);
|
||||
if (pCmd->pQueryInfo == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tfree(pCmd->exprsInfo.pExprs);
|
||||
memset(&pCmd->exprsInfo, 0, sizeof(pCmd->exprsInfo));
|
||||
tscTagCondRelease(&pCmd->pQueryInfo[0].tagCond);
|
||||
tscClearFieldInfo(&pCmd->pQueryInfo[0].fieldsInfo);
|
||||
|
||||
tscColumnBaseInfoDestroy(&pCmd->colList);
|
||||
memset(&pCmd->colList, 0, sizeof(pCmd->colList));
|
||||
tfree(pCmd->pQueryInfo[0].exprsInfo.pExprs);
|
||||
memset(&pCmd->pQueryInfo[0].exprsInfo, 0, sizeof(pCmd->pQueryInfo[0].exprsInfo));
|
||||
|
||||
if (pCmd->tsBuf != NULL) {
|
||||
tsBufDestory(pCmd->tsBuf);
|
||||
pCmd->tsBuf = NULL;
|
||||
tscColumnBaseInfoDestroy(&pCmd->pQueryInfo[0].colList);
|
||||
memset(&pCmd->pQueryInfo[0].colList, 0, sizeof(pCmd->pQueryInfo[0].colList));
|
||||
|
||||
if (pCmd->pQueryInfo[0].tsBuf != NULL) {
|
||||
tsBufDestory(pCmd->pQueryInfo[0].tsBuf);
|
||||
pCmd->pQueryInfo[0].tsBuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +396,7 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
|
|||
tscRemoveFromSqlList(pSql);
|
||||
}
|
||||
|
||||
pCmd->command = -1;
|
||||
pCmd->command = 0;
|
||||
|
||||
// pSql->sqlstr will be used by tscBuildQueryStreamDesc
|
||||
pthread_mutex_lock(&pObj->mutex);
|
||||
|
@ -434,7 +438,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
|
|||
pCmd->allocSize = 0;
|
||||
|
||||
if (pSql->res.buffer != NULL) {
|
||||
for (int i = 0; i < pCmd->fieldsInfo.numOfOutputCols; i++) {
|
||||
for (int i = 0; i < pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols; i++) {
|
||||
if (pSql->res.buffer[i] != NULL) {
|
||||
tfree(pSql->res.buffer[i]);
|
||||
}
|
||||
|
@ -614,7 +618,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
|||
*/
|
||||
dataBuf->pMeterMeta = taosGetDataFromCache(tscCacheHandle, dataBuf->meterId);
|
||||
assert(initialSize > 0);
|
||||
|
||||
|
||||
if (dataBuf->pMeterMeta == NULL) {
|
||||
tfree(dataBuf);
|
||||
return TSDB_CODE_QUERY_CACHE_ERASED;
|
||||
|
@ -629,18 +633,18 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
|
|||
STableDataBlocks** dataBlocks) {
|
||||
*dataBlocks = NULL;
|
||||
|
||||
STableDataBlocks** t1 = (STableDataBlocks**) taosGetIntHashData(pHashList, id);
|
||||
STableDataBlocks** t1 = (STableDataBlocks**)taosGetDataFromHash(pHashList, (const char*)&id, sizeof(id));
|
||||
if (t1 != NULL) {
|
||||
*dataBlocks = *t1;
|
||||
}
|
||||
|
||||
if (*dataBlocks == NULL) {
|
||||
int32_t ret = tscCreateDataBlock((size_t) size, rowSize, startOffset, tableId, dataBlocks);
|
||||
int32_t ret = tscCreateDataBlock((size_t)size, rowSize, startOffset, tableId, dataBlocks);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
*dataBlocks = *(STableDataBlocks**)taosAddIntHash(pHashList, id, (char*)dataBlocks);
|
||||
taosAddToHashTable(pHashList, (const char*)&id, sizeof(int64_t), (char*)dataBlocks, POINTER_BYTES);
|
||||
tscAppendDataBlock(pDataBlockList, *dataBlocks);
|
||||
}
|
||||
|
||||
|
@ -650,19 +654,19 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
|
|||
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockList) {
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
|
||||
void* pVnodeDataBlockHashList = taosInitIntHash(8, POINTER_BYTES, taosHashInt);
|
||||
void* pVnodeDataBlockHashList = taosInitHashTable(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false);
|
||||
SDataBlockList* pVnodeDataBlockList = tscCreateBlockArrayList();
|
||||
|
||||
for (int32_t i = 0; i < pTableDataBlockList->nSize; ++i) {
|
||||
STableDataBlocks* pOneTableBlock = pTableDataBlockList->pData[i];
|
||||
|
||||
STableDataBlocks* dataBuf = NULL;
|
||||
int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pVnodeDataBlockList, pOneTableBlock->vgid,
|
||||
TSDB_PAYLOAD_SIZE, tsInsertHeadSize, 0, pOneTableBlock->meterId, &dataBuf);
|
||||
int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pVnodeDataBlockList, pOneTableBlock->vgid,
|
||||
TSDB_PAYLOAD_SIZE, tsInsertHeadSize, 0, pOneTableBlock->meterId, &dataBuf);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
tscError("%p failed to allocate the data buffer block for merging table data", pSql);
|
||||
tscDestroyBlockArrayList(pTableDataBlockList);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -679,7 +683,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
|
|||
} else { // failed to allocate memory, free already allocated memory and return error code
|
||||
tscError("%p failed to allocate memory for merging submit block, size:%d", pSql, dataBuf->nAllocSize);
|
||||
|
||||
taosCleanUpIntHash(pVnodeDataBlockHashList);
|
||||
taosCleanUpHashTable(pVnodeDataBlockHashList);
|
||||
tfree(dataBuf->pData);
|
||||
tscDestroyBlockArrayList(pVnodeDataBlockList);
|
||||
|
||||
|
@ -710,7 +714,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
|
|||
pCmd->pDataBlocks = pVnodeDataBlockList;
|
||||
|
||||
tscFreeUnusedDataBlocks(pCmd->pDataBlocks);
|
||||
taosCleanUpIntHash(pVnodeDataBlockHashList);
|
||||
taosCleanUpHashTable(pVnodeDataBlockHashList);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -729,9 +733,14 @@ void tscCloseTscObj(STscObj* pObj) {
|
|||
}
|
||||
|
||||
bool tscIsInsertOrImportData(char* sqlstr) {
|
||||
int32_t index = 0;
|
||||
SSQLToken t0 = tStrGetToken(sqlstr, &index, false, 0, NULL);
|
||||
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
||||
int32_t index = 0;
|
||||
|
||||
do {
|
||||
SSQLToken t0 = tStrGetToken(sqlstr, &index, false, 0, NULL);
|
||||
if (t0.type != TK_LP) {
|
||||
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
int tscAllocPayload(SSqlCmd* pCmd, int size) {
|
||||
|
@ -848,7 +857,7 @@ void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, co
|
|||
}
|
||||
|
||||
void tscFieldInfoCalOffset(SSqlCmd* pCmd) {
|
||||
SFieldInfo* pFieldInfo = &pCmd->fieldsInfo;
|
||||
SFieldInfo* pFieldInfo = &pCmd->pQueryInfo[0].fieldsInfo;
|
||||
pFieldInfo->pOffset[0] = 0;
|
||||
|
||||
for (int32_t i = 1; i < pFieldInfo->numOfOutputCols; ++i) {
|
||||
|
@ -857,7 +866,7 @@ void tscFieldInfoCalOffset(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
void tscFieldInfoUpdateOffset(SSqlCmd* pCmd) {
|
||||
SFieldInfo* pFieldInfo = &pCmd->fieldsInfo;
|
||||
SFieldInfo* pFieldInfo = &pCmd->pQueryInfo[0].fieldsInfo;
|
||||
if (pFieldInfo->numOfOutputCols == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -902,23 +911,27 @@ void tscFieldInfoCopyAll(SFieldInfo* src, SFieldInfo* dst) {
|
|||
}
|
||||
|
||||
TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index) {
|
||||
if (index >= pCmd->fieldsInfo.numOfOutputCols) {
|
||||
if (index >= pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &pCmd->fieldsInfo.pFields[index];
|
||||
return &pCmd->pQueryInfo[0].fieldsInfo.pFields[index];
|
||||
}
|
||||
|
||||
int32_t tscNumOfFields(SSqlCmd* pCmd) {
|
||||
return pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols;
|
||||
}
|
||||
|
||||
int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index) {
|
||||
if (index >= pCmd->fieldsInfo.numOfOutputCols) {
|
||||
if (index >= pCmd->pQueryInfo[0].fieldsInfo.numOfOutputCols) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pCmd->fieldsInfo.pOffset[index];
|
||||
return pCmd->pQueryInfo[0].fieldsInfo.pOffset[index];
|
||||
}
|
||||
|
||||
int32_t tscGetResRowLength(SSqlCmd* pCmd) {
|
||||
SFieldInfo* pFieldInfo = &pCmd->fieldsInfo;
|
||||
SFieldInfo* pFieldInfo = &pCmd->pQueryInfo[0].fieldsInfo;
|
||||
if (pFieldInfo->numOfOutputCols <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -969,7 +982,7 @@ static void _exprEvic(SSqlExprInfo* pExprInfo, int32_t index) {
|
|||
}
|
||||
|
||||
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId) {
|
||||
SSqlExprInfo* pExprInfo = &pCmd->exprsInfo;
|
||||
SSqlExprInfo* pExprInfo = &pCmd->pQueryInfo[0].exprsInfo;
|
||||
|
||||
_exprCheckSpace(pExprInfo, pExprInfo->numOfExprs + 1);
|
||||
_exprEvic(pExprInfo, index);
|
||||
|
@ -985,7 +998,7 @@ SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SCo
|
|||
int16_t size, int16_t interSize) {
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pColIndex->tableIndex);
|
||||
|
||||
SSqlExprInfo* pExprInfo = &pCmd->exprsInfo;
|
||||
SSqlExprInfo* pExprInfo = &pCmd->pQueryInfo[0].exprsInfo;
|
||||
|
||||
_exprCheckSpace(pExprInfo, pExprInfo->numOfExprs + 1);
|
||||
_exprEvic(pExprInfo, index);
|
||||
|
@ -1028,7 +1041,7 @@ SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SCo
|
|||
SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
|
||||
int16_t size) {
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
SSqlExprInfo* pExprInfo = &pCmd->exprsInfo;
|
||||
SSqlExprInfo* pExprInfo = &pCmd->pQueryInfo[0].exprsInfo;
|
||||
if (index > pExprInfo->numOfExprs) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1060,11 +1073,11 @@ void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes,
|
|||
}
|
||||
|
||||
SSqlExpr* tscSqlExprGet(SSqlCmd* pCmd, int32_t index) {
|
||||
if (pCmd->exprsInfo.numOfExprs <= index) {
|
||||
if (pCmd->pQueryInfo[0].exprsInfo.numOfExprs <= index) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &pCmd->exprsInfo.pExprs[index];
|
||||
return &pCmd->pQueryInfo[0].exprsInfo.pExprs[index];
|
||||
}
|
||||
|
||||
void tscSqlExprCopy(SSqlExprInfo* dst, const SSqlExprInfo* src, uint64_t tableuid) {
|
||||
|
@ -1144,7 +1157,7 @@ void tscColumnBaseInfoUpdateTableIndex(SColumnBaseInfo* pColList, int16_t tableI
|
|||
|
||||
// todo refactor
|
||||
SColumnBase* tscColumnBaseInfoInsert(SSqlCmd* pCmd, SColumnIndex* pColIndex) {
|
||||
SColumnBaseInfo* pcolList = &pCmd->colList;
|
||||
SColumnBaseInfo* pcolList = &pCmd->pQueryInfo[0].colList;
|
||||
|
||||
// ignore the tbname column to be inserted into source list
|
||||
if (pColIndex->columnIndex < 0) {
|
||||
|
@ -1448,7 +1461,7 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SSqlCmd* pCmd) {
|
|||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||
|
||||
for (int32_t i = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
|
||||
pColInfo[i].functionId = pExpr->functionId;
|
||||
|
||||
|
@ -1483,7 +1496,9 @@ bool tscShouldFreeHeatBeat(SSqlObj* pHb) {
|
|||
void tscCleanSqlCmd(SSqlCmd* pCmd) {
|
||||
tscFreeSqlCmdData(pCmd);
|
||||
|
||||
assert(pCmd->pMeterInfo == NULL);
|
||||
if (pCmd->pQueryInfo != NULL) {
|
||||
assert(pCmd->pQueryInfo[0].pMeterInfo == NULL);
|
||||
}
|
||||
|
||||
uint32_t allocSize = pCmd->allocSize;
|
||||
char* allocPtr = pCmd->payload;
|
||||
|
@ -1539,7 +1554,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
|
|||
SDataBlockList* pDataBlocks = pCmd->pDataBlocks;
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0);
|
||||
assert(pSql->cmd.numOfTables == 1);
|
||||
assert(pSql->cmd.pQueryInfo[0].numOfTables == 1);
|
||||
|
||||
if (pDataBlocks == NULL || pMeterMetaInfo->vnodeIndex >= pDataBlocks->nSize) {
|
||||
tscTrace("%p object should be release since all data blocks have been submit", pSql);
|
||||
|
@ -1554,18 +1569,18 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
|
|||
}
|
||||
|
||||
SMeterMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t index) {
|
||||
if (pCmd == NULL || pCmd->numOfTables == 0) {
|
||||
if (pCmd == NULL || pCmd->numOfQueries == 0 || pCmd->pQueryInfo[0].numOfTables == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert(index >= 0 && index <= pCmd->numOfTables && pCmd->pMeterInfo != NULL);
|
||||
return pCmd->pMeterInfo[index];
|
||||
assert(index >= 0 && index <= pCmd->pQueryInfo[0].numOfTables && pCmd->pQueryInfo[0].pMeterInfo != NULL);
|
||||
return pCmd->pQueryInfo[0].pMeterInfo[index];
|
||||
}
|
||||
|
||||
SMeterMetaInfo* tscGetMeterMetaInfoByUid(SSqlCmd* pCmd, uint64_t uid, int32_t* index) {
|
||||
int32_t k = -1;
|
||||
for (int32_t i = 0; i < pCmd->numOfTables; ++i) {
|
||||
if (pCmd->pMeterInfo[i]->pMeterMeta->uid == uid) {
|
||||
for (int32_t i = 0; i < pCmd->pQueryInfo->numOfTables; ++i) {
|
||||
if (pCmd->pQueryInfo[0].pMeterInfo[i]->pMeterMeta->uid == uid) {
|
||||
k = i;
|
||||
break;
|
||||
}
|
||||
|
@ -1578,17 +1593,37 @@ SMeterMetaInfo* tscGetMeterMetaInfoByUid(SSqlCmd* pCmd, uint64_t uid, int32_t* i
|
|||
return tscGetMeterMetaInfo(pCmd, k);
|
||||
}
|
||||
|
||||
int32_t tscAddQueryInfo(SSqlCmd* pCmd) {
|
||||
assert(pCmd != NULL);
|
||||
|
||||
size_t s = pCmd->numOfQueries + 1;
|
||||
char* tmp = realloc(pCmd->pQueryInfo, s * sizeof(SQueryInfo));
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pCmd->pQueryInfo = (SQueryInfo*) tmp;
|
||||
memset(&pCmd->pQueryInfo[pCmd->numOfQueries], 0, sizeof(SQueryInfo));
|
||||
|
||||
pCmd->numOfQueries++;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta* pMeterMeta, SMetricMeta* pMetricMeta,
|
||||
int16_t numOfTags, int16_t* tags) {
|
||||
void* pAlloc = realloc(pCmd->pMeterInfo, (pCmd->numOfTables + 1) * POINTER_BYTES);
|
||||
if (pCmd->pQueryInfo == NULL) {
|
||||
tscAddQueryInfo(pCmd);
|
||||
}
|
||||
|
||||
void* pAlloc = realloc(pCmd->pQueryInfo[0].pMeterInfo, (pCmd->pQueryInfo->numOfTables + 1) * POINTER_BYTES);
|
||||
if (pAlloc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pCmd->pMeterInfo = pAlloc;
|
||||
pCmd->pMeterInfo[pCmd->numOfTables] = calloc(1, sizeof(SMeterMetaInfo));
|
||||
pCmd->pQueryInfo[0].pMeterInfo = pAlloc;
|
||||
pCmd->pQueryInfo[0].pMeterInfo[pCmd->pQueryInfo->numOfTables] = calloc(1, sizeof(SMeterMetaInfo));
|
||||
|
||||
SMeterMetaInfo* pMeterMetaInfo = pCmd->pMeterInfo[pCmd->numOfTables];
|
||||
SMeterMetaInfo* pMeterMetaInfo = pCmd->pQueryInfo[0].pMeterInfo[pCmd->pQueryInfo->numOfTables];
|
||||
assert(pMeterMetaInfo != NULL);
|
||||
|
||||
if (name != NULL) {
|
||||
|
@ -1604,7 +1639,7 @@ SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta*
|
|||
memcpy(pMeterMetaInfo->tagColumnIndex, tags, sizeof(pMeterMetaInfo->tagColumnIndex[0]) * numOfTags);
|
||||
}
|
||||
|
||||
pCmd->numOfTables += 1;
|
||||
pCmd->pQueryInfo->numOfTables += 1;
|
||||
|
||||
return pMeterMetaInfo;
|
||||
}
|
||||
|
@ -1612,7 +1647,7 @@ SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta*
|
|||
SMeterMetaInfo* tscAddEmptyMeterMetaInfo(SSqlCmd* pCmd) { return tscAddMeterMetaInfo(pCmd, NULL, NULL, NULL, 0, NULL); }
|
||||
|
||||
void tscRemoveMeterMetaInfo(SSqlCmd* pCmd, int32_t index, bool removeFromCache) {
|
||||
if (index < 0 || index >= pCmd->numOfTables) {
|
||||
if (index < 0 || index >= pCmd->pQueryInfo->numOfTables) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1621,24 +1656,29 @@ void tscRemoveMeterMetaInfo(SSqlCmd* pCmd, int32_t index, bool removeFromCache)
|
|||
tscClearMeterMetaInfo(pMeterMetaInfo, removeFromCache);
|
||||
free(pMeterMetaInfo);
|
||||
|
||||
int32_t after = pCmd->numOfTables - index - 1;
|
||||
int32_t after = pCmd->pQueryInfo->numOfTables - index - 1;
|
||||
if (after > 0) {
|
||||
memmove(&pCmd->pMeterInfo[index], &pCmd->pMeterInfo[index + 1], after * sizeof(void*));
|
||||
memmove(&pCmd->pQueryInfo[0].pMeterInfo[index], &pCmd->pQueryInfo[0].pMeterInfo[index + 1], after * sizeof(void*));
|
||||
}
|
||||
|
||||
pCmd->numOfTables -= 1;
|
||||
pCmd->pQueryInfo->numOfTables -= 1;
|
||||
}
|
||||
|
||||
void tscRemoveAllMeterMetaInfo(SSqlCmd* pCmd, bool removeFromCache) {
|
||||
int64_t addr = offsetof(SSqlObj, cmd);
|
||||
|
||||
tscTrace("%p deref the metric/meter meta in cache, numOfTables:%d", ((char*)pCmd - addr), pCmd->numOfTables);
|
||||
|
||||
while (pCmd->numOfTables > 0) {
|
||||
tscRemoveMeterMetaInfo(pCmd, pCmd->numOfTables - 1, removeFromCache);
|
||||
if (pCmd->numOfQueries == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tfree(pCmd->pMeterInfo);
|
||||
tscTrace("%p deref the metric/meter meta in cache, numOfTables:%d", ((char*)pCmd - addr),
|
||||
pCmd->pQueryInfo[0].numOfTables);
|
||||
|
||||
while (pCmd->pQueryInfo[0].numOfTables > 0) {
|
||||
tscRemoveMeterMetaInfo(pCmd, pCmd->pQueryInfo->numOfTables - 1, removeFromCache);
|
||||
}
|
||||
|
||||
tfree(pCmd->pQueryInfo[0].pMeterInfo);
|
||||
}
|
||||
|
||||
void tscClearMeterMetaInfo(SMeterMetaInfo* pMeterMetaInfo, bool removeFromCache) {
|
||||
|
@ -1682,17 +1722,27 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
|||
pNew->cmd.payload = NULL;
|
||||
pNew->cmd.allocSize = 0;
|
||||
|
||||
pNew->cmd.pMeterInfo = NULL;
|
||||
|
||||
pNew->cmd.colList.pColList = NULL;
|
||||
pNew->cmd.colList.numOfAlloc = 0;
|
||||
pNew->cmd.colList.numOfCols = 0;
|
||||
|
||||
pNew->cmd.numOfTables = 0;
|
||||
pNew->cmd.tsBuf = NULL;
|
||||
|
||||
memset(&pNew->cmd.fieldsInfo, 0, sizeof(SFieldInfo));
|
||||
tscTagCondCopy(&pNew->cmd.tagCond, &pCmd->tagCond);
|
||||
pNew->cmd.pQueryInfo = NULL;
|
||||
pNew->cmd.numOfQueries = 0;
|
||||
|
||||
if (tscAddQueryInfo(&pNew->cmd) != TSDB_CODE_SUCCESS) {
|
||||
tscFreeSqlObj(pNew);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(&pNew->cmd.pQueryInfo[0], &pCmd->pQueryInfo[0], sizeof(SQueryInfo));
|
||||
pNew->cmd.pQueryInfo[0].pMeterInfo = NULL;
|
||||
|
||||
pNew->cmd.pQueryInfo[0].colList.pColList = NULL;
|
||||
pNew->cmd.pQueryInfo[0].colList.numOfAlloc = 0;
|
||||
pNew->cmd.pQueryInfo[0].colList.numOfCols = 0;
|
||||
|
||||
pNew->cmd.pQueryInfo[0].numOfTables = 0;
|
||||
pNew->cmd.pQueryInfo[0].tsBuf = NULL;
|
||||
|
||||
memset(&pNew->cmd.pQueryInfo[0].fieldsInfo, 0, sizeof(SFieldInfo));
|
||||
|
||||
tscTagCondCopy(&pNew->cmd.pQueryInfo[0].tagCond, &pCmd->pQueryInfo[0].tagCond);
|
||||
|
||||
if (tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) {
|
||||
tscError("%p new subquery failed, tableIndex:%d, vnodeIndex:%d", pSql, tableIndex, pMeterMetaInfo->vnodeIndex);
|
||||
|
@ -1700,8 +1750,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tscColumnBaseInfoCopy(&pNew->cmd.colList, &pCmd->colList, (int16_t)tableIndex);
|
||||
|
||||
tscColumnBaseInfoCopy(&pNew->cmd.pQueryInfo[0].colList, &pCmd->pQueryInfo[0].colList, (int16_t)tableIndex);
|
||||
|
||||
// set the correct query type
|
||||
if (pPrevSql != NULL) {
|
||||
pNew->cmd.type = pPrevSql->cmd.type;
|
||||
|
@ -1710,20 +1760,20 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
|||
}
|
||||
|
||||
uint64_t uid = pMeterMetaInfo->pMeterMeta->uid;
|
||||
tscSqlExprCopy(&pNew->cmd.exprsInfo, &pCmd->exprsInfo, uid);
|
||||
tscSqlExprCopy(&pNew->cmd.pQueryInfo[0].exprsInfo, &pCmd->pQueryInfo[0].exprsInfo, uid);
|
||||
|
||||
int32_t numOfOutputCols = pNew->cmd.exprsInfo.numOfExprs;
|
||||
int32_t numOfOutputCols = pNew->cmd.pQueryInfo[0].exprsInfo.numOfExprs;
|
||||
|
||||
if (numOfOutputCols > 0) {
|
||||
int32_t* indexList = calloc(1, numOfOutputCols * sizeof(int32_t));
|
||||
for (int32_t i = 0, j = 0; i < pCmd->exprsInfo.numOfExprs; ++i) {
|
||||
for (int32_t i = 0, j = 0; i < pCmd->pQueryInfo[0].exprsInfo.numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
|
||||
if (pExpr->uid == uid) {
|
||||
indexList[j++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
tscFieldInfoCopy(&pCmd->fieldsInfo, &pNew->cmd.fieldsInfo, indexList, numOfOutputCols);
|
||||
tscFieldInfoCopy(&pCmd->pQueryInfo[0].fieldsInfo, &pNew->cmd.pQueryInfo[0].fieldsInfo, indexList, numOfOutputCols);
|
||||
free(indexList);
|
||||
|
||||
tscFieldInfoUpdateOffset(&pNew->cmd);
|
||||
|
@ -1739,7 +1789,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
|||
printf("the metricmeta key is:%s\n", key);
|
||||
#endif
|
||||
|
||||
char* name = pMeterMetaInfo->name;
|
||||
char* name = pMeterMetaInfo->name;
|
||||
|
||||
SMeterMetaInfo* pFinalInfo = NULL;
|
||||
|
||||
if (pPrevSql == NULL) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef TDENGINE_HASHUTIL_H
|
||||
#define TDENGINE_HASHUTIL_H
|
||||
|
||||
#include "os.h"
|
||||
|
||||
typedef uint32_t (*_hash_fn_t)(const char *, uint32_t);
|
||||
|
||||
|
|
190
src/inc/sql.y
190
src/inc/sql.y
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
|
||||
%syntax_error {
|
||||
pInfo->validSql = false;
|
||||
pInfo->valid = false;
|
||||
int32_t outputBufLen = tListLen(pInfo->pzErrMsg);
|
||||
int32_t len = 0;
|
||||
|
||||
|
@ -59,25 +59,25 @@
|
|||
program ::= cmd. {}
|
||||
|
||||
//////////////////////////////////THE SHOW STATEMENT///////////////////////////////////////////
|
||||
cmd ::= SHOW DATABASES. { setDCLSQLElems(pInfo, SHOW_DATABASES, 0);}
|
||||
cmd ::= SHOW MNODES. { setDCLSQLElems(pInfo, SHOW_MNODES, 0);}
|
||||
cmd ::= SHOW DNODES. { setDCLSQLElems(pInfo, SHOW_DNODES, 0);}
|
||||
cmd ::= SHOW ACCOUNTS. { setDCLSQLElems(pInfo, SHOW_ACCOUNTS, 0);}
|
||||
cmd ::= SHOW USERS. { setDCLSQLElems(pInfo, SHOW_USERS, 0);}
|
||||
cmd ::= SHOW DATABASES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DB, 0, 0);}
|
||||
cmd ::= SHOW MNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MNODE, 0, 0);}
|
||||
cmd ::= SHOW DNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DNODE, 0, 0);}
|
||||
cmd ::= SHOW ACCOUNTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_ACCT, 0, 0);}
|
||||
cmd ::= SHOW USERS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_USER, 0, 0);}
|
||||
|
||||
cmd ::= SHOW MODULES. { setDCLSQLElems(pInfo, SHOW_MODULES, 0); }
|
||||
cmd ::= SHOW QUERIES. { setDCLSQLElems(pInfo, SHOW_QUERIES, 0); }
|
||||
cmd ::= SHOW CONNECTIONS.{ setDCLSQLElems(pInfo, SHOW_CONNECTIONS, 0);}
|
||||
cmd ::= SHOW STREAMS. { setDCLSQLElems(pInfo, SHOW_STREAMS, 0); }
|
||||
cmd ::= SHOW CONFIGS. { setDCLSQLElems(pInfo, SHOW_CONFIGS, 0); }
|
||||
cmd ::= SHOW SCORES. { setDCLSQLElems(pInfo, SHOW_SCORES, 0); }
|
||||
cmd ::= SHOW GRANTS. { setDCLSQLElems(pInfo, SHOW_GRANTS, 0); }
|
||||
cmd ::= SHOW MODULES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MODULE, 0, 0); }
|
||||
cmd ::= SHOW QUERIES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_QUERIES, 0, 0); }
|
||||
cmd ::= SHOW CONNECTIONS.{ setShowOptions(pInfo, TSDB_MGMT_TABLE_CONNS, 0, 0);}
|
||||
cmd ::= SHOW STREAMS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
|
||||
cmd ::= SHOW CONFIGS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_CONFIGS, 0, 0); }
|
||||
cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
|
||||
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
|
||||
|
||||
cmd ::= SHOW VNODES. { setDCLSQLElems(pInfo, SHOW_VNODES, 0); }
|
||||
cmd ::= SHOW VNODES IPTOKEN(X). { setDCLSQLElems(pInfo, SHOW_VNODES, 1, &X); }
|
||||
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
|
||||
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
|
||||
|
||||
%type dbPrefix {SSQLToken}
|
||||
dbPrefix(A) ::=. {A.n = 0;}
|
||||
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
|
||||
dbPrefix(A) ::= ids(X) DOT. {A = X; }
|
||||
|
||||
%type cpxName {SSQLToken}
|
||||
|
@ -85,60 +85,60 @@ cpxName(A) ::= . {A.n = 0; }
|
|||
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
|
||||
|
||||
cmd ::= SHOW dbPrefix(X) TABLES. {
|
||||
setDCLSQLElems(pInfo, SHOW_TABLES, 1, &X);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &X, 0);
|
||||
}
|
||||
|
||||
cmd ::= SHOW dbPrefix(X) TABLES LIKE ids(Y). {
|
||||
setDCLSQLElems(pInfo, SHOW_TABLES, 2, &X, &Y);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &X, &Y);
|
||||
}
|
||||
|
||||
cmd ::= SHOW dbPrefix(X) STABLES. {
|
||||
setDCLSQLElems(pInfo, SHOW_STABLES, 1, &X);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &X, 0);
|
||||
}
|
||||
|
||||
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
|
||||
SSQLToken token;
|
||||
setDBName(&token, &X);
|
||||
setDCLSQLElems(pInfo, SHOW_STABLES, 2, &token, &Y);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
|
||||
}
|
||||
|
||||
cmd ::= SHOW dbPrefix(X) VGROUPS. {
|
||||
SSQLToken token;
|
||||
setDBName(&token, &X);
|
||||
setDCLSQLElems(pInfo, SHOW_VGROUPS, 1, &token);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
||||
}
|
||||
|
||||
//drop configure for tables
|
||||
cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
|
||||
X.n += Z.n;
|
||||
setDCLSQLElems(pInfo, DROP_TABLE, 2, &X, &Y);
|
||||
setDropDBTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y);
|
||||
}
|
||||
|
||||
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDCLSQLElems(pInfo, DROP_DATABASE, 2, &X, &Y); }
|
||||
cmd ::= DROP DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, DROP_DNODE, 1, &X); }
|
||||
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, DROP_USER, 1, &X); }
|
||||
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, DROP_ACCOUNT, 1, &X); }
|
||||
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDBTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y); }
|
||||
cmd ::= DROP DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &X); }
|
||||
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &X); }
|
||||
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &X); }
|
||||
|
||||
/////////////////////////////////THE USE STATEMENT//////////////////////////////////////////
|
||||
cmd ::= USE ids(X). { setDCLSQLElems(pInfo, USE_DATABASE, 1, &X);}
|
||||
cmd ::= USE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_USE_DB, 1, &X);}
|
||||
|
||||
/////////////////////////////////THE DESCRIBE STATEMENT/////////////////////////////////////
|
||||
cmd ::= DESCRIBE ids(X) cpxName(Y). {
|
||||
X.n += Y.n;
|
||||
setDCLSQLElems(pInfo, DESCRIBE_TABLE, 1, &X);
|
||||
setDCLSQLElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &X);
|
||||
}
|
||||
|
||||
/////////////////////////////////THE ALTER STATEMENT////////////////////////////////////////
|
||||
cmd ::= ALTER USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &X, &Y); }
|
||||
cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &X, &Y);}
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &X, &Y); }
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &X, &Y, &Z); }
|
||||
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &X); }
|
||||
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_LOCAL, 2, &X, &Y); }
|
||||
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &X, &Y, &t);}
|
||||
cmd ::= ALTER USER ids(X) PASS ids(Y). { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PASSWD, &X, &Y, NULL); }
|
||||
cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PRIVILEGES, &X, NULL, &Y);}
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &X, &Y); }
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
|
||||
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
|
||||
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
|
||||
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
||||
|
||||
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { SSQLToken t = {0}; setCreateAcctSQL(pInfo, ALTER_ACCT, &X, &t, &Z);}
|
||||
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, ALTER_ACCT, &X, &Y, &Z);}
|
||||
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
|
||||
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
|
||||
|
||||
// An IDENTIFIER can be a generic identifier, or one of several keywords.
|
||||
// Any non-standard keyword can also be an identifier.
|
||||
|
@ -157,11 +157,11 @@ ifnotexists(X) ::= . {X.n = 0;}
|
|||
|
||||
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
|
||||
//create option for dnode/db/user/account
|
||||
cmd ::= CREATE DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &X);}
|
||||
cmd ::= CREATE DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &X);}
|
||||
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
|
||||
{ setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &X, &Y, &Z);}
|
||||
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDBSQL(pInfo, CREATE_DATABASE, &X, &Y, &Z);}
|
||||
cmd ::= CREATE USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, CREATE_USER, 2, &X, &Y);}
|
||||
{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
|
||||
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
|
||||
cmd ::= CREATE USER ids(X) PASS ids(Y). { setCreateUserSQL(pInfo, &X, &Y);}
|
||||
|
||||
pps(Y) ::= . {Y.n = 0; }
|
||||
pps(Y) ::= PPS INTEGER(X). {Y = X; }
|
||||
|
@ -192,14 +192,14 @@ state(Y) ::= STATE ids(X). {Y = X; }
|
|||
|
||||
%type acct_optr {SCreateAcctSQL}
|
||||
acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K) conns(L) state(M). {
|
||||
Y.users = (K.n>0)?atoi(K.z):-1;
|
||||
Y.dbs = (E.n>0)?atoi(E.z):-1;
|
||||
Y.tseries = (D.n>0)?atoi(D.z):-1;
|
||||
Y.streams = (F.n>0)?atoi(F.z):-1;
|
||||
Y.pps = (C.n>0)?atoi(C.z):-1;
|
||||
Y.storage = (P.n>0)?strtoll(P.z, NULL, 10):-1;
|
||||
Y.qtime = (Q.n>0)?strtoll(Q.z, NULL, 10):-1;
|
||||
Y.conns = (L.n>0)?atoi(L.z):-1;
|
||||
Y.maxUsers = (K.n>0)?atoi(K.z):-1;
|
||||
Y.maxDbs = (E.n>0)?atoi(E.z):-1;
|
||||
Y.maxTimeSeries = (D.n>0)?atoi(D.z):-1;
|
||||
Y.maxStreams = (F.n>0)?atoi(F.z):-1;
|
||||
Y.maxPointsPerSecond = (C.n>0)?atoi(C.z):-1;
|
||||
Y.maxStorage = (P.n>0)?strtoll(P.z, NULL, 10):-1;
|
||||
Y.maxQueryTime = (Q.n>0)?strtoll(Q.z, NULL, 10):-1;
|
||||
Y.maxConnections = (L.n>0)?atoi(L.z):-1;
|
||||
Y.stat = M;
|
||||
}
|
||||
|
||||
|
@ -264,29 +264,29 @@ cmd ::= CREATE TABLE ifnotexists(Y) ids(X) cpxName(Z) create_table_args. {
|
|||
|
||||
%type create_table_args{SCreateTableSQL*}
|
||||
create_table_args(A) ::= LP columnlist(X) RP. {
|
||||
A = tSetCreateSQLElems(X, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER);
|
||||
setSQLInfo(pInfo, A, NULL, TSQL_CREATE_NORMAL_METER);
|
||||
A = tSetCreateSQLElems(X, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE);
|
||||
setSQLInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
}
|
||||
|
||||
// create metric
|
||||
// create super table
|
||||
create_table_args(A) ::= LP columnlist(X) RP TAGS LP columnlist(Y) RP. {
|
||||
A = tSetCreateSQLElems(X, Y, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC);
|
||||
setSQLInfo(pInfo, A, NULL, TSQL_CREATE_NORMAL_METRIC);
|
||||
A = tSetCreateSQLElems(X, Y, NULL, NULL, NULL, TSQL_CREATE_STABLE);
|
||||
setSQLInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
}
|
||||
|
||||
// create meter by using metric
|
||||
// create meter meter_name using metric_name tags(tag_values1, tag_values2)
|
||||
// create table by using super table
|
||||
// create table table_name using super_table_name tags(tag_values1, tag_values2)
|
||||
create_table_args(A) ::= USING ids(X) cpxName(F) TAGS LP tagitemlist(Y) RP. {
|
||||
X.n += F.n;
|
||||
A = tSetCreateSQLElems(NULL, NULL, &X, Y, NULL, TSQL_CREATE_METER_FROM_METRIC);
|
||||
setSQLInfo(pInfo, A, NULL, TSQL_CREATE_METER_FROM_METRIC);
|
||||
A = tSetCreateSQLElems(NULL, NULL, &X, Y, NULL, TSQL_CREATE_TABLE_FROM_STABLE);
|
||||
setSQLInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
}
|
||||
|
||||
// create stream
|
||||
// create table table_name as select count(*) from metric_name interval(time)
|
||||
// create table table_name as select count(*) from super_table_name interval(time)
|
||||
create_table_args(A) ::= AS select(S). {
|
||||
A = tSetCreateSQLElems(NULL, NULL, NULL, NULL, S, TSQL_CREATE_STREAM);
|
||||
setSQLInfo(pInfo, A, NULL, TSQL_CREATE_STREAM);
|
||||
setSQLInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
}
|
||||
|
||||
%type column{TAOS_FIELD}
|
||||
|
@ -343,16 +343,21 @@ tagitem(A) ::= PLUS(X) FLOAT(Y). {
|
|||
}
|
||||
|
||||
//////////////////////// The SELECT statement /////////////////////////////////
|
||||
cmd ::= select(X). {
|
||||
setSQLInfo(pInfo, X, NULL, TSQL_QUERY_METER);
|
||||
}
|
||||
|
||||
%type select {SQuerySQL*}
|
||||
%destructor select {destroyQuerySql($$);}
|
||||
%destructor select {doDestroyQuerySql($$);}
|
||||
select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) fill_opt(F) sliding_opt(S) groupby_opt(P) orderby_opt(Z) having_opt(N) slimit_opt(G) limit_opt(L). {
|
||||
A = tSetQuerySQLElems(&T, W, X, Y, P, Z, &K, &S, F, &L, &G);
|
||||
}
|
||||
|
||||
%type union {SSubclauseInfo*}
|
||||
%destructor union {destroyAllSelectClause($$);}
|
||||
|
||||
union(Y) ::= select(X). { Y = setSubclause(NULL, X); }
|
||||
union(Y) ::= LP union(X) RP. { Y = X; }
|
||||
union(Y) ::= union(Z) UNION select(X). { Y = appendSelectClause(Z, X); }
|
||||
|
||||
cmd ::= union(X). { setSQLInfo(pInfo, X, NULL, TSDB_SQL_SELECT); }
|
||||
|
||||
// Support for the SQL exprssion without from & where subclauses, e.g.,
|
||||
// select current_database(),
|
||||
// select server_version(), select client_version(),
|
||||
|
@ -572,34 +577,14 @@ exprlist(A) ::= expritem(X). {A = tSQLExprListAppend(0,X,0);}
|
|||
expritem(A) ::= expr(X). {A = X;}
|
||||
expritem(A) ::= . {A = 0;}
|
||||
|
||||
////////////////////////// The INSERT command /////////////////////////////////
|
||||
// add support "values() values() values() tags()" operation....
|
||||
cmd ::= INSERT INTO cpxName(X) insert_value_list(K). {
|
||||
tSetInsertSQLElems(pInfo, &X, K);
|
||||
}
|
||||
|
||||
%type insert_value_list {tSQLExprListList*}
|
||||
insert_value_list(X) ::= VALUES LP itemlist(Y) RP. {X = tSQLListListAppend(NULL, Y);}
|
||||
insert_value_list(X) ::= insert_value_list(K) VALUES LP itemlist(Y) RP.
|
||||
{X = tSQLListListAppend(K, Y);}
|
||||
|
||||
//cmd ::= INSERT INTO cpxName(X) select(S).
|
||||
// {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);}
|
||||
|
||||
%type itemlist {tSQLExprList*}
|
||||
%destructor itemlist {tSQLExprListDestroy($$);}
|
||||
|
||||
itemlist(A) ::= itemlist(X) COMMA expr(Y). {A = tSQLExprListAppend(X,Y,0);}
|
||||
itemlist(A) ::= expr(X). {A = tSQLExprListAppend(0,X,0);}
|
||||
|
||||
///////////////////////////////////reset query cache//////////////////////////////////////
|
||||
cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, RESET_QUERY_CACHE, 0);}
|
||||
cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
|
||||
|
||||
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
|
||||
X.n += F.n;
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, A, NULL, ALTER_TABLE_ADD_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_ADD_COLUMN);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
|
||||
|
@ -608,15 +593,15 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
|
|||
toTSDBType(A.type);
|
||||
tVariantList* K = tVariantListAppendToken(NULL, &A, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, K, ALTER_TABLE_DROP_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
|
||||
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
|
||||
X.n += Y.n;
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, A, NULL, ALTER_TABLE_TAGS_ADD);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_ADD);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
||||
X.n += Z.n;
|
||||
|
@ -624,8 +609,8 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
|||
toTSDBType(Y.type);
|
||||
tVariantList* A = tVariantListAppendToken(NULL, &Y, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_DROP);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
|
||||
|
@ -637,8 +622,8 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
|
|||
toTSDBType(Z.type);
|
||||
A = tVariantListAppendToken(A, &Z, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_CHG);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
|
||||
cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
|
||||
|
@ -648,17 +633,18 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
|
|||
tVariantList* A = tVariantListAppendToken(NULL, &Y, -1);
|
||||
A = tVariantListAppend(A, &Z, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_SET);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_SET);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////kill statement///////////////////////////////////////
|
||||
cmd ::= KILL CONNECTION IPTOKEN(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &X);}
|
||||
cmd ::= KILL STREAM IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &X);}
|
||||
cmd ::= KILL QUERY IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &X);}
|
||||
cmd ::= KILL CONNECTION IPTOKEN(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &X);}
|
||||
cmd ::= KILL STREAM IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setKillSQL(pInfo, TSDB_SQL_KILL_STREAM, &X);}
|
||||
cmd ::= KILL QUERY IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setKillSQL(pInfo, TSDB_SQL_KILL_QUERY, &X);}
|
||||
|
||||
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
|
||||
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
|
||||
LIKE MATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL
|
||||
COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF
|
||||
SPREAD TWA INTERP LAST_ROW NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE NULL.
|
||||
SPREAD TWA INTERP LAST_ROW NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE NULL INSERT INTO
|
||||
VALUES.
|
||||
|
|
|
@ -74,10 +74,10 @@ extern "C" {
|
|||
#define TSDB_MSG_TYPE_CREATE_MNODE_RSP 44
|
||||
#define TSDB_MSG_TYPE_DROP_MNODE 45
|
||||
#define TSDB_MSG_TYPE_DROP_MNODE_RSP 46
|
||||
#define TSDB_MSG_TYPE_CREATE_PNODE 47
|
||||
#define TSDB_MSG_TYPE_CREATE_PNODE_RSP 48
|
||||
#define TSDB_MSG_TYPE_DROP_PNODE 49
|
||||
#define TSDB_MSG_TYPE_DROP_PNODE_RSP 50
|
||||
#define TSDB_MSG_TYPE_CREATE_DNODE 47
|
||||
#define TSDB_MSG_TYPE_CREATE_DNODE_RSP 48
|
||||
#define TSDB_MSG_TYPE_DROP_DNODE 49
|
||||
#define TSDB_MSG_TYPE_DROP_DNODE_RSP 50
|
||||
#define TSDB_MSG_TYPE_CREATE_DB 51
|
||||
#define TSDB_MSG_TYPE_CREATE_DB_RSP 52
|
||||
#define TSDB_MSG_TYPE_DROP_DB 53
|
||||
|
@ -147,7 +147,7 @@ enum _mgmt_table {
|
|||
TSDB_MGMT_TABLE_USER,
|
||||
TSDB_MGMT_TABLE_DB,
|
||||
TSDB_MGMT_TABLE_TABLE,
|
||||
TSDB_MGMT_TABLE_PNODE,
|
||||
TSDB_MGMT_TABLE_DNODE,
|
||||
TSDB_MGMT_TABLE_MNODE,
|
||||
TSDB_MGMT_TABLE_VGROUP,
|
||||
TSDB_MGMT_TABLE_METRIC,
|
||||
|
@ -312,7 +312,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char db[TSDB_METER_ID_LEN];
|
||||
short ignoreNotExists;
|
||||
uint8_t ignoreNotExists;
|
||||
} SDropDbMsg, SUseDbMsg;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -119,97 +119,100 @@
|
|||
#define TK_COMMA 101
|
||||
#define TK_NULL 102
|
||||
#define TK_SELECT 103
|
||||
#define TK_FROM 104
|
||||
#define TK_VARIABLE 105
|
||||
#define TK_INTERVAL 106
|
||||
#define TK_FILL 107
|
||||
#define TK_SLIDING 108
|
||||
#define TK_ORDER 109
|
||||
#define TK_BY 110
|
||||
#define TK_ASC 111
|
||||
#define TK_DESC 112
|
||||
#define TK_GROUP 113
|
||||
#define TK_HAVING 114
|
||||
#define TK_LIMIT 115
|
||||
#define TK_OFFSET 116
|
||||
#define TK_SLIMIT 117
|
||||
#define TK_SOFFSET 118
|
||||
#define TK_WHERE 119
|
||||
#define TK_NOW 120
|
||||
#define TK_INSERT 121
|
||||
#define TK_INTO 122
|
||||
#define TK_VALUES 123
|
||||
#define TK_RESET 124
|
||||
#define TK_QUERY 125
|
||||
#define TK_ADD 126
|
||||
#define TK_COLUMN 127
|
||||
#define TK_TAG 128
|
||||
#define TK_CHANGE 129
|
||||
#define TK_SET 130
|
||||
#define TK_KILL 131
|
||||
#define TK_CONNECTION 132
|
||||
#define TK_COLON 133
|
||||
#define TK_STREAM 134
|
||||
#define TK_ABORT 135
|
||||
#define TK_AFTER 136
|
||||
#define TK_ATTACH 137
|
||||
#define TK_BEFORE 138
|
||||
#define TK_BEGIN 139
|
||||
#define TK_CASCADE 140
|
||||
#define TK_CLUSTER 141
|
||||
#define TK_CONFLICT 142
|
||||
#define TK_COPY 143
|
||||
#define TK_DEFERRED 144
|
||||
#define TK_DELIMITERS 145
|
||||
#define TK_DETACH 146
|
||||
#define TK_EACH 147
|
||||
#define TK_END 148
|
||||
#define TK_EXPLAIN 149
|
||||
#define TK_FAIL 150
|
||||
#define TK_FOR 151
|
||||
#define TK_IGNORE 152
|
||||
#define TK_IMMEDIATE 153
|
||||
#define TK_INITIALLY 154
|
||||
#define TK_INSTEAD 155
|
||||
#define TK_MATCH 156
|
||||
#define TK_KEY 157
|
||||
#define TK_OF 158
|
||||
#define TK_RAISE 159
|
||||
#define TK_REPLACE 160
|
||||
#define TK_RESTRICT 161
|
||||
#define TK_ROW 162
|
||||
#define TK_STATEMENT 163
|
||||
#define TK_TRIGGER 164
|
||||
#define TK_VIEW 165
|
||||
#define TK_ALL 166
|
||||
#define TK_COUNT 167
|
||||
#define TK_SUM 168
|
||||
#define TK_AVG 169
|
||||
#define TK_MIN 170
|
||||
#define TK_MAX 171
|
||||
#define TK_FIRST 172
|
||||
#define TK_LAST 173
|
||||
#define TK_TOP 174
|
||||
#define TK_BOTTOM 175
|
||||
#define TK_STDDEV 176
|
||||
#define TK_PERCENTILE 177
|
||||
#define TK_APERCENTILE 178
|
||||
#define TK_LEASTSQUARES 179
|
||||
#define TK_HISTOGRAM 180
|
||||
#define TK_DIFF 181
|
||||
#define TK_SPREAD 182
|
||||
#define TK_TWA 183
|
||||
#define TK_INTERP 184
|
||||
#define TK_LAST_ROW 185
|
||||
#define TK_SEMI 186
|
||||
#define TK_NONE 187
|
||||
#define TK_PREV 188
|
||||
#define TK_LINEAR 189
|
||||
#define TK_IMPORT 190
|
||||
#define TK_METRIC 191
|
||||
#define TK_TBNAME 192
|
||||
#define TK_JOIN 193
|
||||
#define TK_METRICS 194
|
||||
#define TK_STABLE 195
|
||||
#define TK_UNION 104
|
||||
#define TK_FROM 105
|
||||
#define TK_VARIABLE 106
|
||||
#define TK_INTERVAL 107
|
||||
#define TK_FILL 108
|
||||
#define TK_SLIDING 109
|
||||
#define TK_ORDER 110
|
||||
#define TK_BY 111
|
||||
#define TK_ASC 112
|
||||
#define TK_DESC 113
|
||||
#define TK_GROUP 114
|
||||
#define TK_HAVING 115
|
||||
#define TK_LIMIT 116
|
||||
#define TK_OFFSET 117
|
||||
#define TK_SLIMIT 118
|
||||
#define TK_SOFFSET 119
|
||||
#define TK_WHERE 120
|
||||
#define TK_NOW 121
|
||||
#define TK_RESET 122
|
||||
#define TK_QUERY 123
|
||||
#define TK_ADD 124
|
||||
#define TK_COLUMN 125
|
||||
#define TK_TAG 126
|
||||
#define TK_CHANGE 127
|
||||
#define TK_SET 128
|
||||
#define TK_KILL 129
|
||||
#define TK_CONNECTION 130
|
||||
#define TK_COLON 131
|
||||
#define TK_STREAM 132
|
||||
#define TK_ABORT 133
|
||||
#define TK_AFTER 134
|
||||
#define TK_ATTACH 135
|
||||
#define TK_BEFORE 136
|
||||
#define TK_BEGIN 137
|
||||
#define TK_CASCADE 138
|
||||
#define TK_CLUSTER 139
|
||||
#define TK_CONFLICT 140
|
||||
#define TK_COPY 141
|
||||
#define TK_DEFERRED 142
|
||||
#define TK_DELIMITERS 143
|
||||
#define TK_DETACH 144
|
||||
#define TK_EACH 145
|
||||
#define TK_END 146
|
||||
#define TK_EXPLAIN 147
|
||||
#define TK_FAIL 148
|
||||
#define TK_FOR 149
|
||||
#define TK_IGNORE 150
|
||||
#define TK_IMMEDIATE 151
|
||||
#define TK_INITIALLY 152
|
||||
#define TK_INSTEAD 153
|
||||
#define TK_MATCH 154
|
||||
#define TK_KEY 155
|
||||
#define TK_OF 156
|
||||
#define TK_RAISE 157
|
||||
#define TK_REPLACE 158
|
||||
#define TK_RESTRICT 159
|
||||
#define TK_ROW 160
|
||||
#define TK_STATEMENT 161
|
||||
#define TK_TRIGGER 162
|
||||
#define TK_VIEW 163
|
||||
#define TK_ALL 164
|
||||
#define TK_COUNT 165
|
||||
#define TK_SUM 166
|
||||
#define TK_AVG 167
|
||||
#define TK_MIN 168
|
||||
#define TK_MAX 169
|
||||
#define TK_FIRST 170
|
||||
#define TK_LAST 171
|
||||
#define TK_TOP 172
|
||||
#define TK_BOTTOM 173
|
||||
#define TK_STDDEV 174
|
||||
#define TK_PERCENTILE 175
|
||||
#define TK_APERCENTILE 176
|
||||
#define TK_LEASTSQUARES 177
|
||||
#define TK_HISTOGRAM 178
|
||||
#define TK_DIFF 179
|
||||
#define TK_SPREAD 180
|
||||
#define TK_TWA 181
|
||||
#define TK_INTERP 182
|
||||
#define TK_LAST_ROW 183
|
||||
#define TK_SEMI 184
|
||||
#define TK_NONE 185
|
||||
#define TK_PREV 186
|
||||
#define TK_LINEAR 187
|
||||
#define TK_IMPORT 188
|
||||
#define TK_METRIC 189
|
||||
#define TK_TBNAME 190
|
||||
#define TK_JOIN 191
|
||||
#define TK_METRICS 192
|
||||
#define TK_STABLE 193
|
||||
#define TK_INSERT 194
|
||||
#define TK_INTO 195
|
||||
#define TK_VALUES 196
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -162,15 +162,6 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
|
|||
|
||||
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 taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||
|
|
|
@ -22,7 +22,8 @@ extern "C" {
|
|||
|
||||
#include "os.h"
|
||||
|
||||
#include "ihash.h"
|
||||
#include "hash.h"
|
||||
#include "hashutil.h"
|
||||
|
||||
#define GET_QINFO_ADDR(x) ((char*)(x)-offsetof(SQInfo, query))
|
||||
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0)
|
||||
|
@ -117,11 +118,9 @@ typedef enum {
|
|||
#define SET_MASTER_SCAN_FLAG(runtime) ((runtime)->scanFlag = MASTER_SCAN)
|
||||
|
||||
typedef int (*__block_search_fn_t)(char* data, int num, int64_t key, int order);
|
||||
typedef int32_t (*__read_data_fn_t)(int fd, SQInfo* pQInfo, SQueryFilesInfo* pQueryFile, char* buf, uint64_t offset,
|
||||
int32_t size);
|
||||
|
||||
static FORCE_INLINE SMeterObj* getMeterObj(void* hashHandle, int32_t sid) {
|
||||
return *(SMeterObj**)taosGetIntHashData(hashHandle, sid);
|
||||
return *(SMeterObj**)taosGetDataFromHash(hashHandle, (const char*) &sid, sizeof(sid));
|
||||
}
|
||||
|
||||
bool isQueryKilled(SQuery* pQuery);
|
||||
|
|
|
@ -172,7 +172,7 @@ typedef struct SMeterDataInfo {
|
|||
} SMeterDataInfo;
|
||||
|
||||
typedef struct SMeterQuerySupportObj {
|
||||
void* pMeterObj;
|
||||
void* pMetersHashTable; // meter table hash list
|
||||
|
||||
SMeterSidExtInfo** pMeterSidExtInfo;
|
||||
int32_t numOfMeters;
|
||||
|
|
|
@ -894,7 +894,7 @@ int mgmtProcessShowMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
|||
SShowRspMsg *pShowRsp;
|
||||
SShowObj * pShow = NULL;
|
||||
|
||||
if (pShowMsg->type == TSDB_MGMT_TABLE_PNODE || TSDB_MGMT_TABLE_GRANTS || TSDB_MGMT_TABLE_SCORES) {
|
||||
if (pShowMsg->type == TSDB_MGMT_TABLE_DNODE || TSDB_MGMT_TABLE_GRANTS || TSDB_MGMT_TABLE_SCORES) {
|
||||
if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_SHOW_RSP) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1467,8 +1467,8 @@ void mgmtInitProcessShellMsg() {
|
|||
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CONNECT] = mgmtProcessConnectMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_HEARTBEAT] = mgmtProcessHeartBeatMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_PNODE] = mgmtProcessCreateDnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_PNODE] = mgmtProcessDropDnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DNODE] = mgmtProcessCreateDnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DNODE] = mgmtProcessDropDnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_MNODE] = mgmtProcessCreateMnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_MNODE] = mgmtProcessDropMnodeMsg;
|
||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CFG_MNODE] = mgmtProcessCfgMnodeMsg;
|
||||
|
|
|
@ -3383,6 +3383,10 @@ void forwardQueryStartPosition(SQueryRuntimeEnv *pRuntimeEnv) {
|
|||
updateOffsetVal(pRuntimeEnv, &blockInfo, pBlock);
|
||||
} else {
|
||||
pQuery->limit.offset -= maxReads;
|
||||
|
||||
// update the lastkey, since the following skip operation may traverse to another media. update the lastkey first.
|
||||
pQuery->lastKey = (QUERY_IS_ASC_QUERY(pQuery))? blockInfo.keyLast+1:blockInfo.keyFirst-1;
|
||||
|
||||
doSkipDataBlock(pRuntimeEnv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ int mgmtProcessAlterAcctMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
|||
}
|
||||
|
||||
int mgmtProcessCreateDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||
return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_PNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
int mgmtProcessCfgMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||
|
@ -36,7 +36,7 @@ int mgmtProcessDropMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
|||
}
|
||||
|
||||
int mgmtProcessDropDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||
return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_PNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
int mgmtProcessDropAcctMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||
|
|
Loading…
Reference in New Issue