diff --git a/include/client/taos.h b/include/client/taos.h
index 8b1517c6ff..f098a48631 100644
--- a/include/client/taos.h
+++ b/include/client/taos.h
@@ -51,6 +51,7 @@ typedef void **TAOS_ROW;
#define TSDB_DATA_TYPE_JSON 17 // json
#define TSDB_DATA_TYPE_DECIMAL 18 // decimal
#define TSDB_DATA_TYPE_BLOB 19 // binary
+#define TSDB_DATA_TYPE_MEDIUMBLOB 20
typedef enum {
TSDB_OPTION_LOCALE,
diff --git a/include/common/tmsg.h b/include/common/tmsg.h
index 2e4d3ff44e..c3940f640e 100644
--- a/include/common/tmsg.h
+++ b/include/common/tmsg.h
@@ -419,7 +419,11 @@ typedef struct {
* But for data in vnode side, we need all the following information.
*/
typedef struct {
- int16_t colId;
+ union {
+ int16_t colId;
+ int16_t slotId;
+ };
+
int16_t type;
int16_t bytes;
SColumnFilterList flist;
diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h
index fe5e1cc68c..2ce06348a3 100644
--- a/include/common/ttokendef.h
+++ b/include/common/ttokendef.h
@@ -57,63 +57,86 @@
#define TK_VGROUPS 39
#define TK_SINGLESTABLE 40
#define TK_STREAMMODE 41
-#define TK_NK_FLOAT 42
-#define TK_NK_BOOL 43
-#define TK_TIMESTAMP 44
-#define TK_NK_VARIABLE 45
-#define TK_NK_COMMA 46
-#define TK_NK_ID 47
-#define TK_NK_LP 48
-#define TK_NK_RP 49
-#define TK_NK_DOT 50
-#define TK_BETWEEN 51
-#define TK_IS 52
-#define TK_NULL 53
-#define TK_NK_LT 54
-#define TK_NK_GT 55
-#define TK_NK_LE 56
-#define TK_NK_GE 57
-#define TK_NK_NE 58
-#define TK_NK_EQ 59
-#define TK_LIKE 60
-#define TK_MATCH 61
-#define TK_NMATCH 62
-#define TK_IN 63
-#define TK_FROM 64
-#define TK_AS 65
-#define TK_JOIN 66
-#define TK_ON 67
-#define TK_INNER 68
-#define TK_SELECT 69
-#define TK_DISTINCT 70
-#define TK_WHERE 71
-#define TK_PARTITION 72
-#define TK_BY 73
-#define TK_SESSION 74
-#define TK_STATE_WINDOW 75
-#define TK_INTERVAL 76
-#define TK_SLIDING 77
-#define TK_FILL 78
-#define TK_VALUE 79
-#define TK_NONE 80
-#define TK_PREV 81
-#define TK_LINEAR 82
-#define TK_NEXT 83
-#define TK_GROUP 84
-#define TK_HAVING 85
-#define TK_ORDER 86
-#define TK_SLIMIT 87
-#define TK_SOFFSET 88
-#define TK_LIMIT 89
-#define TK_OFFSET 90
-#define TK_ASC 91
-#define TK_DESC 92
-#define TK_NULLS 93
-#define TK_FIRST 94
-#define TK_LAST 95
+#define TK_USE 42
+#define TK_TABLE 43
+#define TK_NK_LP 44
+#define TK_NK_RP 45
+#define TK_NK_ID 46
+#define TK_NK_DOT 47
+#define TK_NK_COMMA 48
+#define TK_COMMENT 49
+#define TK_BOOL 50
+#define TK_TINYINT 51
+#define TK_SMALLINT 52
+#define TK_INT 53
+#define TK_INTEGER 54
+#define TK_BIGINT 55
+#define TK_FLOAT 56
+#define TK_DOUBLE 57
+#define TK_BINARY 58
+#define TK_TIMESTAMP 59
+#define TK_NCHAR 60
+#define TK_UNSIGNED 61
+#define TK_JSON 62
+#define TK_VARCHAR 63
+#define TK_MEDIUMBLOB 64
+#define TK_BLOB 65
+#define TK_VARBINARY 66
+#define TK_DECIMAL 67
+#define TK_SHOW 68
+#define TK_DATABASES 69
+#define TK_TABLES 70
+#define TK_NK_FLOAT 71
+#define TK_NK_BOOL 72
+#define TK_NK_VARIABLE 73
+#define TK_BETWEEN 74
+#define TK_IS 75
+#define TK_NULL 76
+#define TK_NK_LT 77
+#define TK_NK_GT 78
+#define TK_NK_LE 79
+#define TK_NK_GE 80
+#define TK_NK_NE 81
+#define TK_NK_EQ 82
+#define TK_LIKE 83
+#define TK_MATCH 84
+#define TK_NMATCH 85
+#define TK_IN 86
+#define TK_FROM 87
+#define TK_AS 88
+#define TK_JOIN 89
+#define TK_ON 90
+#define TK_INNER 91
+#define TK_SELECT 92
+#define TK_DISTINCT 93
+#define TK_WHERE 94
+#define TK_PARTITION 95
+#define TK_BY 96
+#define TK_SESSION 97
+#define TK_STATE_WINDOW 98
+#define TK_INTERVAL 99
+#define TK_SLIDING 100
+#define TK_FILL 101
+#define TK_VALUE 102
+#define TK_NONE 103
+#define TK_PREV 104
+#define TK_LINEAR 105
+#define TK_NEXT 106
+#define TK_GROUP 107
+#define TK_HAVING 108
+#define TK_ORDER 109
+#define TK_SLIMIT 110
+#define TK_SOFFSET 111
+#define TK_LIMIT 112
+#define TK_OFFSET 113
+#define TK_ASC 114
+#define TK_DESC 115
+#define TK_NULLS 116
+#define TK_FIRST 117
+#define TK_LAST 118
#define TK_SPACE 300
-#define TK_COMMENT 301
+#define TK_NK_COMMENT 301
#define TK_ILLEGAL 302
#define TK_HEX 303 // hex number 0x123
#define TK_OCT 304 // oct number
diff --git a/include/libs/index/index.h b/include/libs/index/index.h
index 47eb97cc3a..453b49e4c6 100644
--- a/include/libs/index/index.h
+++ b/include/libs/index/index.h
@@ -29,6 +29,12 @@ typedef struct SIndexOpts SIndexOpts;
typedef struct SIndexMultiTermQuery SIndexMultiTermQuery;
typedef struct SArray SIndexMultiTerm;
+typedef struct SIndex SIndexJson;
+typedef struct SIndexTerm SIndexJsonTerm;
+typedef struct SIndexOpts SIndexJsonOpts;
+typedef struct SIndexMultiTermQuery SIndexJsonMultiTermQuery;
+typedef struct SArray SIndexJsonMultiTerm;
+
typedef enum {
ADD_VALUE, // add index colume value
DEL_VALUE, // delete index column value
@@ -39,24 +45,108 @@ typedef enum {
} SIndexOperOnColumn;
typedef enum { MUST = 0, SHOULD = 1, NOT = 2 } EIndexOperatorType;
-typedef enum { QUERY_TERM = 0, QUERY_PREFIX = 1, QUERY_SUFFIX = 2, QUERY_REGEX = 3 } EIndexQueryType;
+typedef enum { QUERY_TERM = 0, QUERY_PREFIX = 1, QUERY_SUFFIX = 2, QUERY_REGEX = 3, QUERY_RANGE = 4 } EIndexQueryType;
+
/*
- * @param: oper
- *
+ * create multi query
+ * @param oper (input, relation between querys)
*/
SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType oper);
-void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery);
-int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType type);
+
/*
- * @param:
- * @param:
+ * destroy multi query
+ * @param pQuery (input, multi-query-object to be destory)
+ */
+
+void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery);
+/*
+ * add query to multi query
+ * @param pQuery (input, multi-query-object)
+ * @param term (input, single query term)
+ * @param type (input, single query type)
+ * @return error code
+ */
+int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType type);
+/*
+ * open index
+ * @param opt (input, index opt)
+ * @param path (input, index path)
+ * @param index (output, index object)
+ * @return error code
+ */
+int indexOpen(SIndexOpts* opt, const char* path, SIndex** index);
+/*
+ * close index
+ * @param index (input, index to be closed)
+ * @return error code
*/
-int indexOpen(SIndexOpts* opt, const char* path, SIndex** index);
void indexClose(SIndex* index);
-int indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid);
-int indexDelete(SIndex* index, SIndexMultiTermQuery* query);
-int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
-int indexRebuild(SIndex* index, SIndexOpts* opt);
+
+/*
+ * insert terms into index
+ * @param index (input, index object)
+ * @param term (input, terms inserted into index)
+ * @param uid (input, uid of terms)
+ * @return error code
+ */
+int indexPut(SIndex* index, SIndexMultiTerm* terms, uint64_t uid);
+/*
+ * delete terms that meet query condition
+ * @param index (input, index object)
+ * @param query (input, condition query to deleted)
+ * @return error code
+ */
+
+int indexDelete(SIndex* index, SIndexMultiTermQuery* query);
+/*
+ * search index
+ * @param index (input, index object)
+ * @param query (input, multi query condition)
+ * @param result(output, query result)
+ * @return error code
+ */
+int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
+/*
+ * rebuild index
+ * @param index (input, index object)
+ * @parma opt (input, rebuild index opts)
+ * @return error code
+ */
+int indexRebuild(SIndex* index, SIndexOpts* opt);
+
+/*
+ * open index
+ * @param opt (input,index json opt)
+ * @param path (input, index json path)
+ * @param index (output, index json object)
+ * @return error code
+ */
+int tIndexJsonOpen(SIndexJsonOpts* opts, const char* path, SIndexJson** index);
+/*
+ * close index
+ * @param index (input, index to be closed)
+ * @return void
+ */
+
+void tIndexJsonClose(SIndexJson* index);
+
+/*
+ * insert terms into index
+ * @param index (input, index object)
+ * @param term (input, terms inserted into index)
+ * @param uid (input, uid of terms)
+ * @return error code
+ */
+int tIndexJsonPut(SIndexJson* index, SIndexJsonMultiTerm* terms, uint64_t uid);
+/*
+ * search index
+ * @param index (input, index object)
+ * @param query (input, multi query condition)
+ * @param result(output, query result)
+ * @return error code
+ */
+
+int tIndexJsonSearch(SIndexJson* index, SIndexJsonMultiTermQuery* query, SArray* result);
/*
* @param
* @param
diff --git a/include/libs/monitor/monitor.h b/include/libs/monitor/monitor.h
index 4b7c6a9bc9..00cb7c3dbc 100644
--- a/include/libs/monitor/monitor.h
+++ b/include/libs/monitor/monitor.h
@@ -23,6 +23,11 @@
extern "C" {
#endif
+#define MON_STATUS_LEN 8
+#define MON_ROLE_LEN 9
+#define MON_VER_LEN 12
+#define MON_LOG_LEN 1024
+
typedef struct {
int32_t dnode_id;
char dnode_ep[TSDB_EP_LEN];
@@ -31,19 +36,19 @@ typedef struct {
typedef struct {
int32_t dnode_id;
char dnode_ep[TSDB_EP_LEN];
- char status[8];
+ char status[MON_STATUS_LEN];
} SMonDnodeDesc;
typedef struct {
int32_t mnode_id;
char mnode_ep[TSDB_EP_LEN];
- char role[8];
+ char role[MON_ROLE_LEN];
} SMonMnodeDesc;
typedef struct {
char first_ep[TSDB_EP_LEN];
int32_t first_ep_dnode_id;
- char version[12];
+ char version[MON_VER_LEN];
float master_uptime; // day
int32_t monitor_interval; // sec
int32_t vgroups_total;
@@ -57,19 +62,18 @@ typedef struct {
typedef struct {
int32_t dnode_id;
- int8_t vnode_online;
- char vnode_role[8];
+ char vnode_role[MON_ROLE_LEN];
} SMonVnodeDesc;
typedef struct {
int32_t vgroup_id;
+ char database_name[TSDB_DB_NAME_LEN];
+ int32_t tables_num;
+ char status[MON_STATUS_LEN];
SMonVnodeDesc vnodes[TSDB_MAX_REPLICA];
} SMonVgroupDesc;
typedef struct {
- char database_name[TSDB_DB_NAME_LEN];
- int32_t tables_num;
- int8_t status;
SArray *vgroups; // array of SMonVgroupDesc
} SMonVgroupInfo;
@@ -84,18 +88,18 @@ typedef struct {
float cpu_engine;
float cpu_system;
float cpu_cores;
- float mem_engine; // MB
- float mem_system; // MB
- float mem_total; // MB
+ int64_t mem_engine; // KB
+ int64_t mem_system; // KB
+ int64_t mem_total; // KB
float disk_engine; // GB
float disk_used; // GB
float disk_total; // GB
- float net_in; // Kb/s
- float net_out; // Kb/s
- float io_read; // Mb/s
- float io_write; // Mb/s
- float io_read_disk; // Mb/s
- float io_write_disk; // Mb/s
+ int64_t net_in;
+ int64_t net_out;
+ float io_read;
+ float io_write;
+ float io_read_disk;
+ float io_write_disk;
int32_t req_select;
float req_select_rate;
int32_t req_insert;
@@ -107,7 +111,7 @@ typedef struct {
int32_t errors;
int32_t vnodes_num;
int32_t masters;
- int32_t has_mnode;
+ int8_t has_mnode;
} SMonDnodeInfo;
typedef struct {
@@ -117,13 +121,15 @@ typedef struct {
} SMonDiskDesc;
typedef struct {
- SArray *disks; // array of SMonDiskDesc
+ SArray *datadirs; // array of SMonDiskDesc
+ SMonDiskDesc logdir;
+ SMonDiskDesc tempdir;
} SMonDiskInfo;
typedef struct {
int64_t ts;
int8_t level;
- char content[1024];
+ char content[MON_LOG_LEN];
} SMonLogItem;
typedef struct SMonInfo SMonInfo;
diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h
index 9344fd09c3..cddecfd9c5 100644
--- a/include/libs/nodes/cmdnodes.h
+++ b/include/libs/nodes/cmdnodes.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef _TD_PLANN_NODES_H_
-#define _TD_PLANN_NODES_H_
+#ifndef _TD_CMD_NODES_H_
+#define _TD_CMD_NODES_H_
#ifdef __cplusplus
extern "C" {
@@ -49,6 +49,11 @@ typedef struct SCreateDatabaseStmt {
SDatabaseOptions options;
} SCreateDatabaseStmt;
+typedef struct SUseDatabaseStmt {
+ ENodeType type;
+ char dbName[TSDB_DB_NAME_LEN];
+} SUseDatabaseStmt;
+
typedef struct STableOptions {
int32_t keep;
int32_t ttl;
@@ -77,4 +82,4 @@ typedef struct SCreateTableStmt {
}
#endif
-#endif /*_TD_PLANN_NODES_H_*/
+#endif /*_TD_CMD_NODES_H_*/
diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h
index eadf618d08..d04873ec12 100644
--- a/include/libs/nodes/nodes.h
+++ b/include/libs/nodes/nodes.h
@@ -70,16 +70,19 @@ typedef enum ENodeType {
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR,
QUERY_NODE_SELECT_STMT,
- QUERY_NODE_SHOW_STMT,
QUERY_NODE_VNODE_MODIF_STMT,
QUERY_NODE_CREATE_DATABASE_STMT,
QUERY_NODE_CREATE_TABLE_STMT,
+ QUERY_NODE_USE_DATABASE_STMT,
+ QUERY_NODE_SHOW_DATABASES_STMT, // temp
+ QUERY_NODE_SHOW_TABLES_STMT, // temp
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN,
QUERY_NODE_LOGIC_PLAN_JOIN,
QUERY_NODE_LOGIC_PLAN_AGG,
QUERY_NODE_LOGIC_PLAN_PROJECT,
+ QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
QUERY_NODE_LOGIC_SUBPLAN,
QUERY_NODE_LOGIC_PLAN,
@@ -94,6 +97,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
QUERY_NODE_PHYSICAL_PLAN_SORT,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
+ QUERY_NODE_PHYSICAL_PLAN_INSERT,
QUERY_NODE_PHYSICAL_SUBPLAN,
QUERY_NODE_PHYSICAL_PLAN
} ENodeType;
@@ -125,6 +129,7 @@ void nodesDestroyNode(SNodeptr pNode);
SNodeList* nodesMakeList();
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
+int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index);
@@ -153,6 +158,7 @@ bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
SNodeptr nodesCloneNode(const SNodeptr pNode);
SNodeList* nodesCloneList(const SNodeList* pList);
+const char* nodesNodeName(ENodeType type);
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h
index c1516969ff..c805eba320 100644
--- a/include/libs/nodes/plannodes.h
+++ b/include/libs/nodes/plannodes.h
@@ -43,6 +43,7 @@ typedef struct SScanLogicNode {
SLogicNode node;
SNodeList* pScanCols;
struct STableMeta* pMeta;
+ SVgroupsInfo* pVgroupList;
EScanType scanType;
uint8_t scanFlag; // denotes reversed scan of data or not
STimeWindow scanRange;
@@ -65,11 +66,27 @@ typedef struct SProjectLogicNode {
SNodeList* pProjections;
} SProjectLogicNode;
+typedef struct SVnodeModifLogicNode {
+ ENodeType type;;
+ int32_t msgType;
+ SArray* pDataBlocks;
+ SVgDataBlocks* pVgDataBlocks;
+} SVnodeModifLogicNode;
+
+typedef enum ESubplanType {
+ SUBPLAN_TYPE_MERGE = 1,
+ SUBPLAN_TYPE_PARTIAL,
+ SUBPLAN_TYPE_SCAN,
+ SUBPLAN_TYPE_MODIFY
+} ESubplanType;
+
typedef struct SSubLogicPlan {
ENodeType type;
SNodeList* pChildren;
SNodeList* pParents;
SLogicNode* pNode;
+ ESubplanType subplanType;
+ int32_t level;
} SSubLogicPlan;
typedef struct SQueryLogicPlan {
@@ -96,7 +113,7 @@ typedef struct SDataBlockDescNode {
typedef struct SPhysiNode {
ENodeType type;
- SDataBlockDescNode outputDataBlockDesc;
+ SDataBlockDescNode* pOutputDataBlockDesc;
SNode* pConditions;
SNodeList* pChildren;
struct SPhysiNode* pParent;
@@ -158,7 +175,7 @@ typedef struct SExchangePhysiNode {
typedef struct SDataSinkNode {
ENodeType type;;
- SDataBlockDescNode inputDataBlockDesc;
+ SDataBlockDescNode* pInputDataBlockDesc;
} SDataSinkNode;
typedef struct SDataDispatcherNode {
@@ -178,13 +195,6 @@ typedef struct SSubplanId {
int32_t subplanId;
} SSubplanId;
-typedef enum ESubplanType {
- SUBPLAN_TYPE_MERGE = 1,
- SUBPLAN_TYPE_PARTIAL,
- SUBPLAN_TYPE_SCAN,
- SUBPLAN_TYPE_MODIFY
-} ESubplanType;
-
typedef struct SSubplan {
ENodeType type;
SSubplanId id; // unique id of the subplan
diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h
index 4cc39325f7..6f321561d1 100644
--- a/include/libs/nodes/querynodes.h
+++ b/include/libs/nodes/querynodes.h
@@ -123,6 +123,7 @@ struct STableMeta;
typedef struct SRealTableNode {
STableNode table; // QUERY_NODE_REAL_TABLE
struct STableMeta* pMeta;
+ SVgroupsInfo* pVgroupList;
} SRealTableNode;
typedef struct STempTableNode {
@@ -264,6 +265,7 @@ typedef struct SVgDataBlocks {
typedef struct SVnodeModifOpStmt {
ENodeType nodeType;
+ ENodeType sqlNodeType;
SArray* pDataBlocks; // data block for each vgroup, SArray.
int8_t schemaAttache; // denote if submit block is built with table schema or not
uint8_t payloadType; // EPayloadType. 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h
index cb23a30aac..1dfb81630c 100644
--- a/include/libs/parser/parser.h
+++ b/include/libs/parser/parser.h
@@ -38,16 +38,20 @@ typedef struct SParseContext {
typedef struct SCmdMsgInfo {
int16_t msgType;
SEpSet epSet;
- char* pMsg;
+ void* pMsg;
int32_t msgLen;
+ void* pExtension; // todo remove it soon
} SCmdMsgInfo;
typedef struct SQuery {
- bool isCmd;
+ bool directRpc;
+ bool haveResultSet;
+ ENodeType sqlNodeType;
SNode* pRoot;
int32_t numOfResCols;
SSchema* pResSchema;
SCmdMsgInfo* pCmdMsg;
+ int32_t msgType;
} SQuery;
int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h
index cf650f95d1..0d62b7f0df 100644
--- a/include/libs/planner/planner.h
+++ b/include/libs/planner/planner.h
@@ -28,7 +28,7 @@ typedef struct SPlanContext {
} SPlanContext;
// Create the physical plan for the query, according to the AST.
-int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan);
+int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNodeList);
// Set datasource of this subplan, multiple calls may be made to a subplan.
// @subplan subplan to be schedule
diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h
index cd04783dbc..53fad4607a 100644
--- a/include/libs/sync/sync.h
+++ b/include/libs/sync/sync.h
@@ -34,9 +34,7 @@ typedef enum {
TAOS_SYNC_STATE_FOLLOWER = 0,
TAOS_SYNC_STATE_CANDIDATE = 1,
TAOS_SYNC_STATE_LEADER = 2,
-} ESyncRole;
-
-typedef ESyncRole ESyncState;
+} ESyncState;
typedef struct SSyncBuffer {
void* data;
diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h
index b6d10c81bf..1b41da33bb 100644
--- a/include/libs/tfs/tfs.h
+++ b/include/libs/tfs/tfs.h
@@ -17,6 +17,7 @@
#define _TD_TFS_H_
#include "tdef.h"
+#include "monitor.h"
#ifdef __cplusplus
extern "C" {
@@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir);
*/
void tfsClosedir(STfsDir *pDir);
+/**
+ * @brief Get disk info of tfs.
+ *
+ * @param pTfs The fs object.
+ * @param pInfo The info object.
+ */
+int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/os/osDir.h b/include/os/osDir.h
index eda83ea0ea..223c603352 100644
--- a/include/os/osDir.h
+++ b/include/os/osDir.h
@@ -21,7 +21,7 @@ extern "C" {
#endif
void taosRemoveDir(const char *dirname);
-int32_t taosDirExist(char *dirname);
+bool taosDirExist(char *dirname);
int32_t taosMkDir(const char *dirname);
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
diff --git a/include/os/osEnv.h b/include/os/osEnv.h
index 4ac073f6c2..1426ba87f6 100644
--- a/include/os/osEnv.h
+++ b/include/os/osEnv.h
@@ -28,11 +28,11 @@ extern char tsCharset[];
extern char tsLocale[];
extern int8_t tsDaylight;
extern bool tsEnableCoreFile;
-extern int64_t tsPageSize;
+extern int64_t tsPageSizeKB;
extern int64_t tsOpenMax;
extern int64_t tsStreamMax;
-extern int32_t tsNumOfCores;
-extern int32_t tsTotalMemoryMB;
+extern float tsNumOfCores;
+extern int64_t tsTotalMemoryKB;
extern char configDir[];
extern char tsDataDir[];
diff --git a/include/os/osFile.h b/include/os/osFile.h
index cbd5d693c5..7e3a5277c8 100644
--- a/include/os/osFile.h
+++ b/include/os/osFile.h
@@ -25,8 +25,12 @@ extern "C" {
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
- // #define close CLOSE_FUNC_TAOS_FORBID
- // #define fclose FCLOSE_FUNC_TAOS_FORBID
+ #define access ACCESS_FUNC_TAOS_FORBID
+ #define stat STAT_FUNC_TAOS_FORBID
+ #define lstat LSTAT_FUNC_TAOS_FORBID
+ #define fstat FSTAT_FUNC_TAOS_FORBID
+ #define close CLOSE_FUNC_TAOS_FORBID
+ #define fclose FCLOSE_FUNC_TAOS_FORBID
#endif
#ifndef PATH_MAX
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
+TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions);
+
+#define TD_FILE_ACCESS_EXIST_OK 0x1
+#define TD_FILE_ACCESS_READ_OK 0x2
+#define TD_FILE_ACCESS_WRITE_OK 0x4
+bool taosCheckAccessFile(const char *pathname, int mode);
int32_t taosLockFile(TdFilePtr pFile);
int32_t taosUnLockFile(TdFilePtr pFile);
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t taosUmaskFile(int32_t maskVal);
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
+int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno);
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime);
-
-TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions);
+bool taosCheckExistFile(const char *pathname);
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence);
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t length);
@@ -62,7 +72,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
-void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
+void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf);
int32_t taosEOFFile(TdFilePtr pFile);
@@ -71,7 +81,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
int32_t taosRenameFile(const char *oldName, const char *newName);
int64_t taosCopyFile(const char *from, const char *to);
-void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
+void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size);
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length);
bool taosValidFile(TdFilePtr pFile);
-int taosGetErrorFile(TdFilePtr pFile);
+int32_t taosGetErrorFile(TdFilePtr pFile);
#ifdef __cplusplus
}
diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h
index bf9d7662e6..e14dba8269 100644
--- a/include/os/osSysinfo.h
+++ b/include/os/osSysinfo.h
@@ -34,19 +34,19 @@ typedef struct {
} SDiskSpace;
void taosGetSystemInfo();
-bool taosGetEmail(char *email, int32_t maxLen);
-bool taosGetOsReleaseName(char *releaseName, int32_t maxLen);
-bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores);
-int32_t taosGetCpuCores();
-bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
-bool taosGetTotalSysMemoryKB(uint64_t *kb);
-bool taosGetProcMemory(float *memoryUsedMB); //
-bool taosGetSysMemory(float *memoryUsedMB); //
+int32_t taosGetEmail(char *email, int32_t maxLen);
+int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen);
+int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores);
+int32_t taosGetCpuCores(float *numOfCores);
+int32_t taosGetCpuUsage(float *cpu_system, float *cpu_engine);
+int32_t taosGetTotalMemory(int64_t *totalKB);
+int32_t taosGetProcMemory(int64_t *usedKB);
+int32_t taosGetSysMemory(int64_t *usedKB);
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
-bool taosReadProcIO(int64_t *rchars, int64_t *wchars);
-bool taosGetProcIO(float *readKB, float *writeKB);
-bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes);
-bool taosGetBandSpeed(float *bandSpeedKb);
+int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars);
+int32_t taosGetProcIO(float *readKB, float *writeKB);
+int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes);
+int32_t taosGetBandSpeed(float *bandSpeedKb);
int32_t taosSystem(const char *cmd);
void taosKillSystem();
diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c
index 18f945975f..2adc6dd4e2 100644
--- a/source/client/src/clientImpl.c
+++ b/source/client/src/clientImpl.c
@@ -161,7 +161,7 @@ int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) {
}
code = qParseQuerySql(&cxt, pQuery);
- if (TSDB_CODE_SUCCESS == code && !((*pQuery)->isCmd)) {
+ if (TSDB_CODE_SUCCESS == code && ((*pQuery)->haveResultSet)) {
setResSchemaInfo(&pRequest->body.resInfo, (*pQuery)->pResSchema, (*pQuery)->numOfResCols);
}
@@ -176,6 +176,14 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
STscObj* pTscObj = pRequest->pTscObj;
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
+
+ if (pMsgInfo->msgType == TDMT_VND_SHOW_TABLES) {
+ SShowReqInfo* pShowReqInfo = &pRequest->body.showInfo;
+ if (pShowReqInfo->pArray == NULL) {
+ pShowReqInfo->currentIndex = 0; // set the first vnode/ then iterate the next vnode
+ pShowReqInfo->pArray = pMsgInfo->pExtension;
+ }
+ }
int64_t transporterId = 0;
asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg);
@@ -183,20 +191,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
return TSDB_CODE_SUCCESS;
}
-int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pDag, SArray* pNodeList) {
- // pRequest->type = pQuery->type;
-
+int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList) {
+ pRequest->type = pQuery->msgType;
SPlanContext cxt = { .queryId = pRequest->requestId, .pAstRoot = pQuery->pRoot };
- int32_t code = qCreateQueryPlan(&cxt, pDag);
+ int32_t code = qCreateQueryPlan(&cxt, pPlan, pNodeList);
if (code != 0) {
return code;
}
-
- // if (pQuery->type == TSDB_SQL_SELECT) {
- // setResSchemaInfo(&pRequest->body.resInfo, pSchema, numOfCols);
- // pRequest->type = TDMT_VND_QUERY;
- // }
-
return code;
}
@@ -226,7 +227,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
return pRequest->code;
}
- if (TSDB_SQL_INSERT == pRequest->type || TSDB_SQL_CREATE_TABLE == pRequest->type) {
+ if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) {
pRequest->body.resInfo.numOfRows = res.numOfRows;
if (pRequest->body.queryJob != 0) {
@@ -254,7 +255,7 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
CHECK_CODE_GOTO(parseSql(pRequest, &pQuery), _return);
- if (pQuery->isCmd) {
+ if (pQuery->directRpc) {
CHECK_CODE_GOTO(execDdlQuery(pRequest, pQuery), _return);
} else {
CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList), _return);
diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c
index 5998b7c9ce..93b66e3369 100644
--- a/source/common/src/tglobal.c
+++ b/source/common/src/tglobal.c
@@ -279,11 +279,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if (cfgAddLocale(pCfg, "locale", tsLocale) != 0) return -1;
if (cfgAddCharset(pCfg, "charset", tsCharset) != 0) return -1;
if (cfgAddBool(pCfg, "enableCoreFile", 1, 1) != 0) return -1;
- if (cfgAddInt32(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1) != 0) return -1;
- if (cfgAddInt32(pCfg, "pageSize(KB)", tsPageSize, 0, INT64_MAX, 1) != 0) return -1;
+ if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 0, 100000, 1) != 0) return -1;
if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1;
if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1;
- if (cfgAddInt32(pCfg, "totalMemory(MB)", tsTotalMemoryMB, 0, INT32_MAX, 1) != 0) return -1;
+ if (cfgAddInt32(pCfg, "pageSize(KB)", tsPageSizeKB, 0, INT64_MAX, 1) != 0) return -1;
+ if (cfgAddInt64(pCfg, "totalMemory(KB)", tsTotalMemoryKB, 0, INT64_MAX, 1) != 0) return -1;
if (cfgAddString(pCfg, "os sysname", info.sysname, 1) != 0) return -1;
if (cfgAddString(pCfg, "os nodename", info.nodename, 1) != 0) return -1;
if (cfgAddString(pCfg, "os release", info.release, 1) != 0) return -1;
@@ -404,10 +404,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
const char *charset = cfgGetItem(pCfg, "charset")->str;
taosSetSystemLocale(locale, charset);
- if (tsNumOfCores <= 1) {
- tsNumOfCores = 2;
- }
-
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
taosSetConsoleEcho(enableCore);
diff --git a/source/common/test/commonTests.cpp b/source/common/test/commonTests.cpp
index 4821d60875..563efe4d54 100644
--- a/source/common/test/commonTests.cpp
+++ b/source/common/test/commonTests.cpp
@@ -1,6 +1,4 @@
-#include "tcommon.h"
#include
-#include
#include
#pragma GCC diagnostic push
@@ -10,6 +8,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
+#include "tep.h"
+#include "tcommon.h"
#include "taos.h"
#include "tvariant.h"
#include "tdef.h"
diff --git a/source/common/test/tmsgTest.cpp b/source/common/test/tmsgTest.cpp
index ca33d24a8c..e8c3284ea5 100644
--- a/source/common/test/tmsgTest.cpp
+++ b/source/common/test/tmsgTest.cpp
@@ -1,6 +1,6 @@
#include
-#include "gtest/gtest.h"
+#include
#include "tmsg.h"
diff --git a/source/dnode/mgmt/impl/inc/dndEnv.h b/source/dnode/mgmt/impl/inc/dndEnv.h
index cbd5eb5827..efe54ee1e5 100644
--- a/source/dnode/mgmt/impl/inc/dndEnv.h
+++ b/source/dnode/mgmt/impl/inc/dndEnv.h
@@ -31,7 +31,7 @@ typedef struct {
SDnode *pDnode;
STaosQueue *queue;
union {
- SQWorkerPool pool;
+ SQWorkerPool pool;
SWWorkerPool mpool;
};
} SDnodeWorker;
@@ -137,6 +137,8 @@ typedef struct SDnode {
SStartupReq startup;
} SDnode;
+int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/dnode/mgmt/impl/inc/dndMnode.h b/source/dnode/mgmt/impl/inc/dndMnode.h
index 0f03bb3832..0aee3b4b43 100644
--- a/source/dnode/mgmt/impl/inc/dndMnode.h
+++ b/source/dnode/mgmt/impl/inc/dndMnode.h
@@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
SMonGrantInfo *pGrantInfo);
+int8_t dndIsMnode(SDnode *pDnode);
#ifdef __cplusplus
}
diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c
index 2539443b41..1cbdf0c1dc 100644
--- a/source/dnode/mgmt/impl/src/dndEnv.c
+++ b/source/dnode/mgmt/impl/src/dndEnv.c
@@ -323,3 +323,12 @@ void dndCleanup() {
taosStopCacheRefreshWorker();
dInfo("dnode env is cleaned up");
}
+
+int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
+ tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name));
+ pInfo->logdir.size = tsLogSpace.size;
+ tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
+ pInfo->tempdir.size = tsTempSpace.size;
+
+ return tfsGetMonitorInfo(pDnode->pTfs, pInfo);
+}
\ No newline at end of file
diff --git a/source/dnode/mgmt/impl/src/dndMgmt.c b/source/dnode/mgmt/impl/src/dndMgmt.c
index 4bf8b82043..60cfdc299c 100644
--- a/source/dnode/mgmt/impl/src/dndMgmt.c
+++ b/source/dnode/mgmt/impl/src/dndMgmt.c
@@ -474,20 +474,48 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse(&rpcRsp);
}
-void dndGetBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
+static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
pInfo->dnode_id = dndGetDnodeId(pDnode);
tstrncpy(pInfo->dnode_ep, tsLocalEp, TSDB_EP_LEN);
}
+static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
+ pInfo->uptime = (taosGetTimestampMs() - pDnode->dmgmt.rebootTime) / (86400000.0f);
+ taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system);
+ pInfo->cpu_cores = tsNumOfCores;
+ taosGetProcMemory(&pInfo->mem_engine);
+ taosGetSysMemory(&pInfo->mem_system);
+ pInfo->mem_total = tsTotalMemoryKB;
+ pInfo->disk_engine = 0;
+ pInfo->disk_used = tsDataSpace.size.used / (1024 * 1024 * 1024.0);
+ pInfo->disk_total = tsDataSpace.size.avail / (1024 * 1024 * 1024.0);
+ taosGetCardInfo(NULL, &pInfo->net_in, &pInfo->net_out);
+ taosGetProcIO(&pInfo->io_read, &pInfo->io_write);
+ pInfo->io_read_disk = 0;
+ pInfo->io_write_disk = 0;
+ pInfo->req_select = 0;
+ pInfo->req_select_rate = 0;
+ pInfo->req_insert = 0;
+ pInfo->req_insert_success = 0;
+ pInfo->req_insert_rate = 0;
+ pInfo->req_insert_batch = 0;
+ pInfo->req_insert_batch_success = 0;
+ pInfo->req_insert_batch_rate = 0;
+ pInfo->errors = 0;
+ pInfo->vnodes_num = 0;
+ pInfo->masters = 0;
+ pInfo->has_mnode = dndIsMnode(pDnode);
+}
+
static void dndSendMonitorReport(SDnode *pDnode) {
- if (!tsEnableMonitor || tsMonitorFqdn[0] == 0) return;
+ if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
+ dTrace("pDnode:%p, send monitor report to %s:%u", pDnode, tsMonitorFqdn, tsMonitorPort);
+
SMonInfo *pMonitor = monCreateMonitorInfo();
if (pMonitor == NULL) return;
- dTrace("pDnode:%p, send monitor report to %s:%u", pDnode, tsMonitorFqdn, tsMonitorPort);
-
SMonBasicInfo basicInfo = {0};
- dndGetBasicInfo(pDnode, &basicInfo);
+ dndGetMonitorBasicInfo(pDnode, &basicInfo);
monSetBasicInfo(pMonitor, &basicInfo);
SMonClusterInfo clusterInfo = {0};
@@ -499,6 +527,20 @@ static void dndSendMonitorReport(SDnode *pDnode) {
monSetGrantInfo(pMonitor, &grantInfo);
}
+ SMonDnodeInfo dnodeInfo = {0};
+ dndGetMonitorDnodeInfo(pDnode, &dnodeInfo);
+ monSetDnodeInfo(pMonitor, &dnodeInfo);
+
+ SMonDiskInfo diskInfo = {0};
+ if (dndGetMonitorDiskInfo(pDnode, &diskInfo) == 0) {
+ monSetDiskInfo(pMonitor, &diskInfo);
+ }
+
+ taosArrayDestroy(clusterInfo.dnodes);
+ taosArrayDestroy(clusterInfo.mnodes);
+ taosArrayDestroy(vgroupInfo.vgroups);
+ taosArrayDestroy(diskInfo.datadirs);
+
monSendReport(pMonitor);
monCleanupMonitorInfo(pMonitor);
}
diff --git a/source/dnode/mgmt/impl/src/dndMnode.c b/source/dnode/mgmt/impl/src/dndMnode.c
index 6cb117867f..47e74b5c57 100644
--- a/source/dnode/mgmt/impl/src/dndMnode.c
+++ b/source/dnode/mgmt/impl/src/dndMnode.c
@@ -639,4 +639,11 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
int32_t code = mndGetMonitorInfo(pMnode, pClusterInfo, pVgroupInfo, pGrantInfo);
dndReleaseMnode(pDnode, pMnode);
return code;
+}
+
+int8_t dndIsMnode(SDnode *pDnode) {
+ SMnode *pMnode = dndAcquireMnode(pDnode);
+ if (pMnode == NULL) return 0;
+ dndReleaseMnode(pDnode, pMnode);
+ return 1;
}
\ No newline at end of file
diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c
index 1cd7593846..968319e7b4 100644
--- a/source/dnode/mnode/impl/src/mndTelem.c
+++ b/source/dnode/mnode/impl/src/mndTelem.c
@@ -52,23 +52,20 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
tjsonAddStringToObject(pJson, "instanceId", clusterName);
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
- if (taosGetOsReleaseName(tmp, sizeof(tmp))) {
+ if (taosGetOsReleaseName(tmp, sizeof(tmp)) == 0) {
tjsonAddStringToObject(pJson, "os", tmp);
}
- int32_t numOfCores = 0;
- if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores)) {
+ float numOfCores = 0;
+ if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) {
tjsonAddStringToObject(pJson, "cpuModel", tmp);
tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
} else {
- tjsonAddDoubleToObject(pJson, "numOfCpu", taosGetCpuCores());
+ tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores);
}
- uint64_t memoryKB = 0;
- if (taosGetTotalSysMemoryKB(&memoryKB)) {
- snprintf(tmp, sizeof(tmp), "%" PRIu64 " kB", memoryKB);
- tjsonAddStringToObject(pJson, "memory", tmp);
- }
+ snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
+ tjsonAddStringToObject(pJson, "memory", tmp);
tjsonAddStringToObject(pJson, "version", version);
tjsonAddStringToObject(pJson, "buildInfo", buildinfo);
diff --git a/source/dnode/vnode/src/tq/tqMetaStore.c b/source/dnode/vnode/src/tq/tqMetaStore.c
index 6d5085ee74..ce00c98ff9 100644
--- a/source/dnode/vnode/src/tq/tqMetaStore.c
+++ b/source/dnode/vnode/src/tq/tqMetaStore.c
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
char name[pathLen + 10];
strcpy(name, path);
- if (taosDirExist(name) != 0 && taosMkDir(name) != 0) {
+ if (!taosDirExist(name) && taosMkDir(name) != 0) {
terrno = TSDB_CODE_TQ_FAILED_TO_CREATE_DIR;
tqError("failed to create dir:%s since %s ", name, terrstr());
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c
index 2e7116969e..7a95820115 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCommit.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile *pRSmadF = TSDB_READ_SMAD_FILE(&(pCommith->readh));
SDFile *pWSmadF = TSDB_COMMIT_SMAD_FILE(pCommith);
- if (access(TSDB_FILE_FULL_NAME(pRSmadF), F_OK) != 0) {
+ if (!taosCheckExistFile(TSDB_FILE_FULL_NAME(pRSmadF))) {
tsdbDebug("vgId:%d create data file %s as not exist", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pRSmadF));
tsdbInitDFile(pRepo, pWSmadF, did, fid, FS_TXN_VERSION(REPO_FS(pRepo)), TSDB_FILE_SMAD);
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile *pRSmalF = TSDB_READ_SMAL_FILE(&(pCommith->readh));
SDFile *pWSmalF = TSDB_COMMIT_SMAL_FILE(pCommith);
- if ((pCommith->isLFileSame) && access(TSDB_FILE_FULL_NAME(pRSmalF), F_OK) == 0) {
+ if ((pCommith->isLFileSame) && taosCheckExistFile(TSDB_FILE_FULL_NAME(pRSmalF))) {
tsdbInitDFileEx(pWSmalF, pRSmalF);
if (tsdbOpenDFile(pWSmalF, O_RDWR) < 0) {
tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWSmalF),
diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c
index dcc9700d83..411a166caa 100644
--- a/source/dnode/vnode/src/tsdb/tsdbFS.c
+++ b/source/dnode/vnode/src/tsdb/tsdbFS.c
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
tsdbGetTxnFname(pRepo, TSDB_TXN_CURR_FILE, current);
tsdbGetRtnSnap(pRepo, &pRepo->rtn);
- if (access(current, F_OK) == 0) {
+ if (taosCheckExistFile(current)) {
if (tsdbOpenFSFromCurrent(pRepo) < 0) {
tsdbError("vgId:%d failed to open FS since %s", REPO_ID(pRepo), tstrerror(terrno));
return -1;
diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c
index 4d70c429ff..74fb8c1c1f 100644
--- a/source/dnode/vnode/src/tsdb/tsdbFile.c
+++ b/source/dnode/vnode/src/tsdb/tsdbFile.c
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
- struct stat dfstat;
SDFile df;
tsdbInitDFileEx(&df, pDFile);
- if (access(TSDB_FILE_FULL_NAME(pDFile), F_OK) != 0) {
+ if (!taosCheckExistFile(TSDB_FILE_FULL_NAME(pDFile))) {
tsdbError("vgId:%d data file %s not exit, report to upper layer to fix it", REPO_ID(pRepo),
TSDB_FILE_FULL_NAME(pDFile));
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE(pDFile, TSDB_FILE_STATE_BAD);
return 0;
}
-
- if (stat(TSDB_FILE_FULL_NAME(&df), &dfstat) < 0) {
+ int64_t file_size = 0;
+ if (taosStatFile(TSDB_FILE_FULL_NAME(&df), &file_size, NULL) < 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
- if (pDFile->info.size < dfstat.st_size) {
+ if (pDFile->info.size < file_size) {
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if (tsdbOpenDFile(&df, TD_FILE_WRITE) < 0) {
return -1;
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
tsdbCloseDFile(&df);
tsdbInfo("vgId:%d file %s is truncated from %" PRId64 " to %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile),
- dfstat.st_size, pDFile->info.size);
- } else if (pDFile->info.size > dfstat.st_size) {
+ file_size, pDFile->info.size);
+ } else if (pDFile->info.size > file_size) {
tsdbError("vgId:%d data file %s has wrong size %" PRId64 " expected %" PRId64 ", report to upper layer to fix it",
- REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), dfstat.st_size, pDFile->info.size);
+ REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), file_size, pDFile->info.size);
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE(pDFile, TSDB_FILE_STATE_BAD);
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt
index 78625d1eed..d766f3cbf1 100644
--- a/source/libs/CMakeLists.txt
+++ b/source/libs/CMakeLists.txt
@@ -1,4 +1,3 @@
-add_definitions("-D ALLOW_FORBID_FUNC")
add_subdirectory(transport)
add_subdirectory(sync)
add_subdirectory(tdb)
diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp
index b417a645be..b05fc7812a 100644
--- a/source/libs/catalog/test/catalogTests.cpp
+++ b/source/libs/catalog/test/catalogTests.cpp
@@ -14,9 +14,7 @@
*/
#include
-#include
#include
-#include "os.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
@@ -24,8 +22,10 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wformat"
+#include
-#include "addr_any.h"
+#include "os.h"
+#include "tglobal.h"
#include "catalog.h"
#include "stub.h"
#include "taos.h"
diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c
index 4f1b83ad5d..9c86e19166 100644
--- a/source/libs/executor/src/dataDispatcher.c
+++ b/source/libs/executor/src/dataDispatcher.c
@@ -39,7 +39,7 @@ typedef struct SDataCacheEntry {
typedef struct SDataDispatchHandle {
SDataSinkHandle sink;
SDataSinkManager* pManager;
- SDataBlockDescNode schema;
+ SDataBlockDescNode* pSchema;
STaosQueue* pDataBlocks;
SDataDispatchBuf nextOutput;
int32_t status;
@@ -109,14 +109,14 @@ static void copyData(const SInputData* pInput, const SDataBlockDescNode* pSchema
// data format: SDataCacheEntry | col1_data col2_data ... | numOfTables | STableIdInfo STableIdInfo ...
static void toDataCacheEntry(const SDataDispatchHandle* pHandle, const SInputData* pInput, SDataDispatchBuf* pBuf) {
SDataCacheEntry* pEntry = (SDataCacheEntry*)pBuf->pData;
- pEntry->compressed = (int8_t)needCompress(pInput->pData, &(pHandle->schema));
+ pEntry->compressed = (int8_t)needCompress(pInput->pData, pHandle->pSchema);
pEntry->numOfRows = pInput->pData->info.rows;
pEntry->dataLen = 0;
pBuf->useSize = DATA_META_LENGTH(pInput->pTableRetrieveTsMap);
- copyData(pInput, &pHandle->schema, pEntry->data, pEntry->compressed, &pEntry->dataLen);
+ copyData(pInput, pHandle->pSchema, pEntry->data, pEntry->compressed, &pEntry->dataLen);
if (0 == pEntry->compressed) {
- pEntry->dataLen = pHandle->schema.resultRowSize * pInput->pData->info.rows;
+ pEntry->dataLen = pHandle->pSchema->resultRowSize * pInput->pData->info.rows;
}
pBuf->useSize += pEntry->dataLen;
// todo completed
@@ -130,7 +130,7 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
return false;
}
- pBuf->allocSize = DATA_META_LENGTH(pInput->pTableRetrieveTsMap) + pDispatcher->schema.resultRowSize * pInput->pData->info.rows;
+ pBuf->allocSize = DATA_META_LENGTH(pInput->pTableRetrieveTsMap) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows;
pBuf->pData = malloc(pBuf->allocSize);
if (pBuf->pData == NULL) {
qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno));
@@ -196,7 +196,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
if (NULL == pDispatcher->nextOutput.pData) {
assert(pDispatcher->queryEnd);
pOutput->useconds = pDispatcher->useconds;
- pOutput->precision = pDispatcher->schema.precision;
+ pOutput->precision = pDispatcher->pSchema->precision;
return TSDB_CODE_SUCCESS;
}
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDispatcher->nextOutput.pData);
@@ -208,7 +208,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pthread_mutex_lock(&pDispatcher->mutex);
pOutput->queryEnd = pDispatcher->queryEnd;
pOutput->useconds = pDispatcher->useconds;
- pOutput->precision = pDispatcher->schema.precision;
+ pOutput->precision = pDispatcher->pSchema->precision;
pthread_mutex_unlock(&pDispatcher->mutex);
return TSDB_CODE_SUCCESS;
}
@@ -238,7 +238,7 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
dispatcher->sink.fGetData = getDataBlock;
dispatcher->sink.fDestroy = destroyDataSinker;
dispatcher->pManager = pManager;
- dispatcher->schema = pDataSink->inputDataBlockDesc;
+ dispatcher->pSchema = pDataSink->pInputDataBlockDesc;
dispatcher->status = DS_BUF_EMPTY;
dispatcher->queryEnd = false;
dispatcher->pDataBlocks = taosOpenQueue();
diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c
index 8cae5f8768..cad7bff7cb 100644
--- a/source/libs/executor/src/executorimpl.c
+++ b/source/libs/executor/src/executorimpl.c
@@ -315,8 +315,6 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
}
SSDataBlock* createOutputBuf_rv(SArray* pExprInfo, int32_t numOfRows) {
- const static int32_t minSize = 8;
-
size_t numOfOutput = taosArrayGetSize(pExprInfo);
SSDataBlock *res = calloc(1, sizeof(SSDataBlock));
@@ -330,15 +328,28 @@ SSDataBlock* createOutputBuf_rv(SArray* pExprInfo, int32_t numOfRows) {
idata.info.type = pExpr->base.resSchema.type;
idata.info.bytes = pExpr->base.resSchema.bytes;
idata.info.colId = pExpr->base.resSchema.colId;
-
- int32_t size = TMAX(idata.info.bytes * numOfRows, minSize);
- idata.pData = calloc(1, size); // at least to hold a pointer on x64 platform
taosArrayPush(res->pDataBlock, &idata);
}
+ blockDataEnsureCapacity(res, numOfRows);
return res;
}
+SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
+ int32_t numOfCols = LIST_LENGTH(pNode->pSlots);
+ SSDataBlock* pBlock = calloc(1, sizeof(SSDataBlock));
+ pBlock->info.numOfCols = numOfCols;
+ pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
+
+ for(int32_t i = 0; i < numOfCols; ++i) {
+ SColumnInfoData idata = {{0}};
+ SSlotDescNode* pDescNode = nodesListGetNode(pNode->pSlots, i);
+ idata.info.type = pDescNode->dataType.type;
+ idata.info.bytes = pDescNode->dataType.bytes;
+ idata.info.slotId = pDescNode->slotId;
+ }
+}
+
static bool isSelectivityWithTagsQuery(SqlFunctionCtx *pCtx, int32_t numOfOutput) {
return true;
// bool hasTags = false;
@@ -2215,10 +2226,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
if (pQueryAttr->tsCompQuery && pRuntimeEnv->outputBuf && pRuntimeEnv->outputBuf->pDataBlock && taosArrayGetSize(pRuntimeEnv->outputBuf->pDataBlock) > 0) {
SColumnInfoData* pColInfoData = taosArrayGet(pRuntimeEnv->outputBuf->pDataBlock, 0);
if (pColInfoData) {
- FILE *f = *(FILE **)pColInfoData->pData; // TODO refactor
- if (f) {
- fclose(f);
- *(FILE **)pColInfoData->pData = NULL;
+ TdFilePtr pFile = *(TdFilePtr *)pColInfoData->pData; // TODO refactor
+ if (pFile != NULL) {
+ taosCloseFile(&pFile);
+ *(TdFilePtr *)pColInfoData->pData = NULL;
}
}
}
@@ -8041,6 +8052,10 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t tableUid, STableGroupInfo* pGroupInfo, uint64_t queryId, uint64_t taskId);
SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
+ if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_PROJECT) { // ignore the project node
+ pPhyNode = nodesListGetNode(pPhyNode->pChildren, 0);
+ }
+
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pPhyNode)) {
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
@@ -8119,15 +8134,15 @@ static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STa
cond.twindow = pTableScanNode->scanRange;
cond.type = BLOCK_LOAD_OFFSET_SEQ_ORDER;
+// cond.type = pTableScanNode->scanFlag;
for (int32_t i = 0; i < cond.numOfCols; ++i) {
- // SExprInfo* pExprInfo = taosArrayGetP(pTableScanNode->scan.node.pTargets, i);
- // assert(pExprInfo->pExpr->nodeType == TEXPR_COL_NODE);
+ STargetNode* pNode = (STargetNode*)nodesListGetNode(pTableScanNode->scan.pScanCols, i);
- // SSchema* pSchema = pExprInfo->pExpr->pSchema;
- // cond.colList[i].type = pSchema->type;
- // cond.colList[i].bytes = pSchema->bytes;
- // cond.colList[i].colId = pSchema->colId;
+ SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
+ cond.colList[i].type = pColNode->colType;
+ cond.colList[i].bytes = pColNode->node.resType.type;
+ cond.colList[i].colId = pColNode->colId;
}
return tsdbQueryTables(readHandle, &cond, pGroupInfo, queryId, taskId);
diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp
index de64958793..bfa6325211 100644
--- a/source/libs/executor/test/executorTests.cpp
+++ b/source/libs/executor/test/executorTests.cpp
@@ -13,10 +13,7 @@
* along with this program. If not, see .
*/
-#include
-#include
#include
-#include
#include
#pragma GCC diagnostic push
@@ -26,6 +23,9 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
+#include "tglobal.h"
+#include "executorimpl.h"
+#include "function.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
@@ -224,587 +224,717 @@ int main(int argc, char** argv) {
TEST(testCase, build_executor_tree_Test) {
const char* msg = "{\n"
- " \"Type\": \"33\",\n"
- " \"Name\": \"PhysiProject\",\n"
- " \"PhysiProject\": {\n"
- " \"OutputDataBlockDesc\": {\n"
- " \"Type\": \"19\",\n"
- " \"Name\": \"TupleDesc\",\n"
- " \"TupleDesc\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"Slots\": [\n"
+ " \"NodeType\": \"48\",\n"
+ " \"Name\": \"PhysiSubplan\",\n"
+ " \"PhysiSubplan\": {\n"
+ " \"Id\": {\n"
+ " \"QueryId\": \"0\",\n"
+ " \"TemplateId\": \"0\",\n"
+ " \"SubplanId\": \"0\"\n"
+ " },\n"
+ " \"SubplanType\": \"0\",\n"
+ " \"MsgType\": \"515\",\n"
+ " \"Level\": \"0\",\n"
+ " \"NodeAddr\": {\n"
+ " \"Id\": \"1\",\n"
+ " \"InUse\": \"0\",\n"
+ " \"NumOfEps\": \"1\",\n"
+ " \"Eps\": [\n"
+ " {\n"
+ " \"Fqdn\": \"node1\",\n"
+ " \"Port\": \"6030\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"RootNode\": {\n"
+ " \"NodeType\": \"41\",\n"
+ " \"Name\": \"PhysiProject\",\n"
+ " \"PhysiProject\": {\n"
+ " \"OutputDataBlockDesc\": {\n"
+ " \"NodeType\": \"19\",\n"
+ " \"Name\": \"TupleDesc\",\n"
+ " \"TupleDesc\": {\n"
+ " \"DataBlockId\": \"1\",\n"
+ " \"Slots\": [\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"0\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"9\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"1\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"4\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"4\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"2\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"8\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"20\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"3\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"5\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"4\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"5\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"Children\": [\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"38\",\n"
+ " \"Name\": \"PhysiTableScan\",\n"
+ " \"PhysiTableScan\": {\n"
+ " \"OutputDataBlockDesc\": {\n"
+ " \"NodeType\": \"19\",\n"
+ " \"Name\": \"TupleDesc\",\n"
+ " \"TupleDesc\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"Slots\": [\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"0\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"9\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"1\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"4\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"4\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"2\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"8\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"20\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"3\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"5\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"4\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"5\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": true\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"ScanCols\": [\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"9\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"ts\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"1\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"ts\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"1\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"4\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"4\"\n"
+ " },\n"
+ " \"AliasName\": \"c1\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"2\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c1\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"2\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"8\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"20\"\n"
+ " },\n"
+ " \"AliasName\": \"c2\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"3\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c2\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"3\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"5\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c3\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"4\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c3\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"4\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c4\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"5\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c4\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"5\",\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c5\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"6\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c5\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"TableId\": \"1\",\n"
+ " \"TableType\": \"3\",\n"
+ " \"ScanOrder\": \"1\",\n"
+ " \"ScanCount\": \"1\",\n"
+ " \"ReverseScanCount\": \"0\",\n"
+ " \"ScanFlag\": \"0\",\n"
+ " \"StartKey\": \"-9223372036854775808\",\n"
+ " \"EndKey\": \"9223372036854775807\"\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"Projections\": [\n"
+ " {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"0\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"9\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"9\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"ts\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"1\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"ts\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"0\"\n"
+ " }\n"
+ " }\n"
" }\n"
" },\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"1\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"4\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"4\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"4\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"4\"\n"
+ " },\n"
+ " \"AliasName\": \"c1\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"2\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c1\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"1\"\n"
+ " }\n"
+ " }\n"
" }\n"
" },\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"2\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"8\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"20\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"8\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"20\"\n"
+ " },\n"
+ " \"AliasName\": \"c2\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"3\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c2\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"2\"\n"
+ " }\n"
+ " }\n"
" }\n"
" },\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"3\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"5\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"5\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c3\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"4\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c3\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"3\"\n"
+ " }\n"
+ " }\n"
" }\n"
" },\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"4\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c4\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"5\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c4\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"4\"\n"
+ " }\n"
+ " }\n"
" }\n"
" },\n"
" {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
+ " \"NodeType\": \"18\",\n"
+ " \"Name\": \"Target\",\n"
+ " \"Target\": {\n"
+ " \"DataBlockId\": \"1\",\n"
" \"SlotId\": \"5\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": false\n"
+ " \"Expr\": {\n"
+ " \"NodeType\": \"1\",\n"
+ " \"Name\": \"Column\",\n"
+ " \"Column\": {\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"AliasName\": \"c5\",\n"
+ " \"TableId\": \"0\",\n"
+ " \"ColId\": \"6\",\n"
+ " \"ColType\": \"1\",\n"
+ " \"DbName\": \"test\",\n"
+ " \"TableName\": \"t1\",\n"
+ " \"TableAlias\": \"t1\",\n"
+ " \"ColName\": \"c5\",\n"
+ " \"DataBlockId\": \"0\",\n"
+ " \"SlotId\": \"5\"\n"
+ " }\n"
+ " }\n"
" }\n"
" }\n"
" ]\n"
" }\n"
" },\n"
- " \"Children\": [\n"
- " {\n"
- " \"Type\": \"30\",\n"
- " \"Name\": \"PhysiTableScan\",\n"
- " \"PhysiTableScan\": {\n"
- " \"OutputDataBlockDesc\": {\n"
- " \"Type\": \"19\",\n"
- " \"Name\": \"TupleDesc\",\n"
- " \"TupleDesc\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"Slots\": [\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"0\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"9\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"1\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"4\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"4\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"2\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"8\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"20\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"3\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"5\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"4\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"20\",\n"
- " \"Name\": \"SlotDesc\",\n"
- " \"SlotDesc\": {\n"
- " \"SlotId\": \"5\",\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"Reserve\": false,\n"
- " \"Output\": true\n"
- " }\n"
+ " \"DataSink\": {\n"
+ " \"NodeType\": \"46\",\n"
+ " \"Name\": \"PhysiDispatch\",\n"
+ " \"PhysiDispatch\": {\n"
+ " \"InputDataBlockDesc\": {\n"
+ " \"NodeType\": \"19\",\n"
+ " \"Name\": \"TupleDesc\",\n"
+ " \"TupleDesc\": {\n"
+ " \"DataBlockId\": \"1\",\n"
+ " \"Slots\": [\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"0\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"9\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
" }\n"
- " ]\n"
- " }\n"
- " },\n"
- " \"ScanCols\": [\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"9\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"ts\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"1\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"ts\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"1\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"4\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"4\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"2\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"8\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"20\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"3\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"5\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"4\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"NodeType\": \"20\",\n"
+ " \"Name\": \"SlotDesc\",\n"
+ " \"SlotDesc\": {\n"
+ " \"SlotId\": \"5\",\n"
+ " \"DataType\": {\n"
+ " \"Type\": \"7\",\n"
+ " \"Precision\": \"0\",\n"
+ " \"Scale\": \"0\",\n"
+ " \"Bytes\": \"8\"\n"
+ " },\n"
+ " \"Reserve\": false,\n"
+ " \"Output\": false\n"
" }\n"
" }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"1\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"4\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"4\"\n"
- " },\n"
- " \"AliasName\": \"c1\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"2\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c1\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"2\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"8\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"20\"\n"
- " },\n"
- " \"AliasName\": \"c2\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"3\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c2\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"3\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"5\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c3\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"4\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c3\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"4\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c4\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"5\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c4\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"5\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c5\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"6\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c5\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " }\n"
- " ],\n"
- " \"TableId\": \"1\",\n"
- " \"TableType\": \"3\",\n"
- " \"ScanOrder\": \"1\",\n"
- " \"ScanCount\": \"1\",\n"
- " \"ReverseScanCount\": \"0\",\n"
- " \"ScanFlag\": \"0\",\n"
- " \"StartKey\": \"-9223372036854775808\",\n"
- " \"EndKey\": \"9223372036854775807\"\n"
- " }\n"
- " }\n"
- " ],\n"
- " \"Projections\": [\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"0\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"9\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"ts\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"1\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"ts\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"0\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"1\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"4\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"4\"\n"
- " },\n"
- " \"AliasName\": \"c1\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"2\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c1\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"1\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"2\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"8\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"20\"\n"
- " },\n"
- " \"AliasName\": \"c2\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"3\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c2\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"2\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"3\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"5\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c3\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"4\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c3\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"3\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"4\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c4\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"5\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c4\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"4\"\n"
- " }\n"
- " }\n"
- " }\n"
- " },\n"
- " {\n"
- " \"Type\": \"18\",\n"
- " \"Name\": \"Target\",\n"
- " \"Target\": {\n"
- " \"DataBlockId\": \"1\",\n"
- " \"SlotId\": \"5\",\n"
- " \"Expr\": {\n"
- " \"Type\": \"1\",\n"
- " \"Name\": \"Column\",\n"
- " \"Column\": {\n"
- " \"DataType\": {\n"
- " \"Type\": \"7\",\n"
- " \"Precision\": \"0\",\n"
- " \"Scale\": \"0\",\n"
- " \"Bytes\": \"8\"\n"
- " },\n"
- " \"AliasName\": \"c5\",\n"
- " \"TableId\": \"0\",\n"
- " \"ColId\": \"6\",\n"
- " \"ColType\": \"1\",\n"
- " \"DbName\": \"test\",\n"
- " \"TableName\": \"t1\",\n"
- " \"TableAlias\": \"t1\",\n"
- " \"ColName\": \"c5\",\n"
- " \"DataBlockId\": \"0\",\n"
- " \"SlotId\": \"5\"\n"
- " }\n"
+ " ]\n"
" }\n"
" }\n"
" }\n"
- " ]\n"
+ " }\n"
" }\n"
"}";
diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp
index fc366e4cc8..612b0705ea 100644
--- a/source/libs/executor/test/sortTests.cpp
+++ b/source/libs/executor/test/sortTests.cpp
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-#include
#include
#include
#include
@@ -26,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
+#include "executorimpl.h"
#include "executor.h"
#include "stub.h"
#include "taos.h"
diff --git a/source/libs/index/inc/indexInt.h b/source/libs/index/inc/indexInt.h
index 59ed5b79f5..0fcaf11087 100644
--- a/source/libs/index/inc/indexInt.h
+++ b/source/libs/index/inc/indexInt.h
@@ -122,30 +122,53 @@ typedef struct TFileCacheKey {
int indexFlushCacheToTFile(SIndex* sIdx, void*);
int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
+// int32_t indexSerialKey(ICacheKey* key, char* buf);
+// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
-#define indexFatal(...) \
- do { \
- if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("index FATAL ", 255, __VA_ARGS__); } \
+#define indexFatal(...) \
+ do { \
+ if (sDebugFlag & DEBUG_FATAL) { \
+ taosPrintLog("index FATAL ", 255, __VA_ARGS__); \
+ } \
} while (0)
-#define indexError(...) \
- do { \
- if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("index ERROR ", 255, __VA_ARGS__); } \
+#define indexError(...) \
+ do { \
+ if (sDebugFlag & DEBUG_ERROR) { \
+ taosPrintLog("index ERROR ", 255, __VA_ARGS__); \
+ } \
} while (0)
-#define indexWarn(...) \
- do { \
- if (sDebugFlag & DEBUG_WARN) { taosPrintLog("index WARN ", 255, __VA_ARGS__); } \
+#define indexWarn(...) \
+ do { \
+ if (sDebugFlag & DEBUG_WARN) { \
+ taosPrintLog("index WARN ", 255, __VA_ARGS__); \
+ } \
} while (0)
-#define indexInfo(...) \
- do { \
- if (sDebugFlag & DEBUG_INFO) { taosPrintLog("index ", 255, __VA_ARGS__); } \
+#define indexInfo(...) \
+ do { \
+ if (sDebugFlag & DEBUG_INFO) { \
+ taosPrintLog("index ", 255, __VA_ARGS__); \
+ } \
} while (0)
-#define indexDebug(...) \
- do { \
- if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
+#define indexDebug(...) \
+ do { \
+ if (sDebugFlag & DEBUG_DEBUG) { \
+ taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
+ } \
} while (0)
-#define indexTrace(...) \
- do { \
- if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
+#define indexTrace(...) \
+ do { \
+ if (sDebugFlag & DEBUG_TRACE) { \
+ taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
+ } \
+ } while (0)
+
+#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
+#define INDEX_TYPE_GET_TYPE(ty) (ty & 0x0F)
+#define INDEX_TYPE_ADD_EXTERN_TYPE(ty, exTy) \
+ do { \
+ uint8_t oldTy = ty; \
+ ty = (ty >> 4) | exTy; \
+ ty = (ty << 4) | oldTy; \
} while (0)
#ifdef __cplusplus
diff --git a/source/libs/index/inc/index_comm.h b/source/libs/index/inc/index_comm.h
new file mode 100644
index 0000000000..0d8418ba65
--- /dev/null
+++ b/source/libs/index/inc/index_comm.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _TD_INDEX_COMM_H_
+#define _TD_INDEX_COMM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char JSON_COLUMN[];
+extern char JSON_VALUE_DELIM;
+
+char* indexPackJsonData(SIndexTerm* itm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c
index 5147734a85..168e819073 100644
--- a/source/libs/index/src/index.c
+++ b/source/libs/index/src/index.c
@@ -2,8 +2,8 @@
* Copyright (c) 2019 TAOS Data, Inc.
*
* This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
+ * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
+ * Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -30,6 +30,8 @@
void* indexQhandle = NULL;
+static char JSON_COLUMN[] = "JSON";
+
void indexInit() {
// refactor later
indexQhandle = taosInitScheduler(INDEX_QUEUE_SIZE, INDEX_NUM_OF_THREADS, "index");
@@ -63,6 +65,9 @@ static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch);
static void indexMergeCacheAndTFile(SArray* result, IterateValue* icache, IterateValue* iTfv);
static void indexMergeSameKey(SArray* result, TFileValue* tv);
+// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
+// int32_t indexSerialKey(ICacheKey* key, char* buf);
+
int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
pthread_once(&isInit, indexInit);
SIndex* sIdx = calloc(1, sizeof(SIndex));
@@ -148,7 +153,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm* p = taosArrayGetP(fVals, i);
char buf[128] = {0};
- ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName)};
+ ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName), .colType = p->colType};
int32_t sz = indexSerialCacheKey(&key, buf);
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
@@ -163,7 +168,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm* p = taosArrayGetP(fVals, i);
char buf[128] = {0};
- ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName)};
+ ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName), .colType = p->colType};
int32_t sz = indexSerialCacheKey(&key, buf);
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
@@ -330,8 +335,9 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
IndexCache* cache = NULL;
char buf[128] = {0};
- ICacheKey key = {.suid = term->suid, .colName = term->colName, .nColName = strlen(term->colName)};
- int32_t sz = indexSerialCacheKey(&key, buf);
+ ICacheKey key = {
+ .suid = term->suid, .colName = term->colName, .nColName = strlen(term->colName), .colType = term->colType};
+ int32_t sz = indexSerialCacheKey(&key, buf);
pthread_mutex_lock(&sIdx->mtx);
IndexCache** pCache = taosHashGet(sIdx->colObj, buf, sz);
@@ -555,11 +561,17 @@ END:
}
int32_t indexSerialCacheKey(ICacheKey* key, char* buf) {
+ bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(key->colType, TSDB_DATA_TYPE_JSON);
+
char* p = buf;
SERIALIZE_MEM_TO_BUF(buf, key, suid);
SERIALIZE_VAR_TO_BUF(buf, '_', char);
// SERIALIZE_MEM_TO_BUF(buf, key, colType);
// SERIALIZE_VAR_TO_BUF(buf, '_', char);
- SERIALIZE_STR_MEM_TO_BUF(buf, key, colName, key->nColName);
+ if (hasJson) {
+ SERIALIZE_STR_VAR_TO_BUF(buf, JSON_COLUMN, strlen(JSON_COLUMN));
+ } else {
+ SERIALIZE_STR_MEM_TO_BUF(buf, key, colName, key->nColName);
+ }
return buf - p;
}
diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c
index d6a7141825..599bac3fe6 100644
--- a/source/libs/index/src/index_cache.c
+++ b/source/libs/index/src/index_cache.c
@@ -14,6 +14,7 @@
*/
#include "index_cache.h"
+#include "index_comm.h"
#include "index_util.h"
#include "tcompare.h"
#include "tsched.h"
@@ -44,8 +45,9 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in
indexError("failed to create index cache");
return NULL;
};
+
cache->mem = indexInternalCacheCreate(type);
- cache->colName = tstrdup(colName);
+ cache->colName = INDEX_TYPE_CONTAIN_EXTERN_TYPE(type, TSDB_DATA_TYPE_JSON) ? tstrdup(JSON_COLUMN) : tstrdup(colName);
cache->type = type;
cache->index = idx;
cache->version = 0;
@@ -207,11 +209,11 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
}
}
}
-
int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
if (cache == NULL) {
return -1;
}
+ bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(term->colType, TSDB_DATA_TYPE_JSON);
IndexCache* pCache = cache;
indexCacheRef(pCache);
@@ -222,8 +224,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
}
// set up key
ct->colType = term->colType;
- ct->colVal = (char*)calloc(1, sizeof(char) * (term->nColVal + 1));
- memcpy(ct->colVal, term->colVal, term->nColVal);
+ if (hasJson) {
+ ct->colVal = indexPackJsonData(term);
+ } else {
+ ct->colVal = (char*)calloc(1, sizeof(char) * (term->nColVal + 1));
+ memcpy(ct->colVal, term->colVal, term->nColVal);
+ }
ct->version = atomic_add_fetch_32(&pCache->version, 1);
// set value
ct->uid = uid;
@@ -294,13 +300,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
SIndexTerm* term = query->term;
EIndexQueryType qtype = query->qType;
- CacheTerm ct = {.colVal = term->colVal, .version = atomic_load_32(&pCache->version)};
+
+ bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(term->colType, TSDB_DATA_TYPE_JSON);
+ char* p = term->colVal;
+ if (hasJson) {
+ p = indexPackJsonData(term);
+ }
+ CacheTerm ct = {.colVal = p, .version = atomic_load_32(&pCache->version)};
int ret = indexQueryMem(mem, &ct, qtype, result, s);
if (ret == 0 && *s != kTypeDeletion) {
// continue search in imm
ret = indexQueryMem(imm, &ct, qtype, result, s);
}
+ if (hasJson) {
+ tfree(p);
+ }
indexMemUnRef(mem);
indexMemUnRef(imm);
@@ -367,6 +382,8 @@ static int32_t indexCacheTermCompare(const void* l, const void* r) {
}
static MemTable* indexInternalCacheCreate(int8_t type) {
+ type = INDEX_TYPE_CONTAIN_EXTERN_TYPE(type, TSDB_DATA_TYPE_JSON) ? TSDB_DATA_TYPE_BINARY : type;
+
MemTable* tbl = calloc(1, sizeof(MemTable));
indexMemRef(tbl);
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
@@ -389,9 +406,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
IterateValue* iv = &itera->val;
iterateValueDestroy(iv, false);
- // IterateValue* iv = &itera->val;
- // IterateValue tIterVal = {.colVal = NULL, .val = taosArrayInit(1, sizeof(uint64_t))};
-
bool next = tSkipListIterNext(iter);
if (next) {
SSkipListNode* node = tSkipListIterGet(iter);
@@ -411,10 +425,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
taosArrayPush(iv->val, &ct->uid);
}
- // IterateValue* iv = &itera->val;
- // iterateValueDestroy(iv, true);
- //*iv = tIterVal;
-
return next;
}
diff --git a/source/libs/index/src/index_comm.c b/source/libs/index/src/index_comm.c
new file mode 100644
index 0000000000..4f3cbaa4da
--- /dev/null
+++ b/source/libs/index/src/index_comm.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "index.h"
+#include "indexInt.h"
+
+char JSON_COLUMN[] = "JSON";
+char JSON_VALUE_DELIM = '&';
+
+char* indexPackJsonData(SIndexTerm* itm) {
+ /*
+ * |<-----colname---->|<-----dataType---->|<--------colVal---------->|
+ * |<-----string----->|<-----uint8_t----->|<----depend on dataType-->|
+ */
+ uint8_t ty = INDEX_TYPE_GET_TYPE(itm->colType);
+
+ int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
+ char* buf = (char*)calloc(1, sz);
+ char* p = buf;
+
+ memcpy(p, itm->colName, itm->nColName);
+ p += itm->nColName;
+
+ memcpy(p, &JSON_VALUE_DELIM, sizeof(JSON_VALUE_DELIM));
+ p += sizeof(JSON_VALUE_DELIM);
+
+ memcpy(p, &ty, sizeof(ty));
+ p += sizeof(ty);
+
+ memcpy(p, &JSON_VALUE_DELIM, sizeof(JSON_VALUE_DELIM));
+ p += sizeof(JSON_VALUE_DELIM);
+
+ memcpy(p, itm->colVal, itm->nColVal);
+
+ return buf;
+}
diff --git a/source/libs/index/src/index_fst_counting_writer.c b/source/libs/index/src/index_fst_counting_writer.c
index 16d9893778..8cb2ff9246 100644
--- a/source/libs/index/src/index_fst_counting_writer.c
+++ b/source/libs/index/src/index_fst_counting_writer.c
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
static int writeCtxGetSize(WriterCtx* ctx) {
if (ctx->type == TFile) {
- struct stat fstat;
- stat(ctx->file.buf, &fstat);
- return fstat.st_size;
+ int64_t file_size = 0;
+ taosStatFile(ctx->file.buf, &file_size, NULL);
+ return (int)file_size;
}
return 0;
}
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
- struct stat fstat;
- stat(path, &fstat);
- ctx->file.size = fstat.st_size;
+ int64_t file_size = 0;
+ taosFStatFile(ctx->file.pFile, &file_size, NULL);
+ ctx->file.size = (int)file_size;
#ifdef USE_MMAP
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
#endif
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
#endif
}
if (ctx->file.readOnly == false) {
- struct stat fstat;
- stat(ctx->file.buf, &fstat);
+ int64_t file_size = 0;
+ taosStatFile(ctx->file.buf, &file_size, NULL);
+ // struct stat fstat;
+ // stat(ctx->file.buf, &fstat);
// indexError("write file size: %d", (int)(fstat.st_size));
}
if (remove) { unlink(ctx->file.buf); }
diff --git a/source/libs/index/src/index_json.c b/source/libs/index/src/index_json.c
new file mode 100644
index 0000000000..de88ff3c8a
--- /dev/null
+++ b/source/libs/index/src/index_json.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#include "index.h"
+#include "indexInt.h"
+
+int tIndexJsonOpen(SIndexJsonOpts *opts, const char *path, SIndexJson **index) {
+ // handle
+ return indexOpen(opts, path, index);
+}
+int tIndexJsonPut(SIndexJson *index, SIndexJsonMultiTerm *terms, uint64_t uid) {
+ for (int i = 0; i < taosArrayGetSize(terms); i++) {
+ SIndexJsonTerm *p = taosArrayGetP(terms, i);
+ INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
+ }
+ return indexPut(index, terms, uid);
+ // handle put
+}
+
+int tIndexJsonSearch(SIndexJson *index, SIndexJsonMultiTermQuery *tq, SArray *result) {
+ SArray *terms = tq->query;
+ for (int i = 0; i < taosArrayGetSize(terms); i++) {
+ SIndexJsonTerm *p = taosArrayGetP(terms, i);
+ INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
+ }
+ return indexSearch(index, tq, result);
+ // handle search
+}
+
+void tIndexJsonClose(SIndexJson *index) {
+ return indexClose(index);
+ // handle close
+}
diff --git a/source/libs/index/src/index_tfile.c b/source/libs/index/src/index_tfile.c
index e44f8fc1c3..0947c796b2 100644
--- a/source/libs/index/src/index_tfile.c
+++ b/source/libs/index/src/index_tfile.c
@@ -15,6 +15,7 @@ p *
#include "index_tfile.h"
#include "index.h"
+#include "index_comm.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_util.h"
@@ -186,13 +187,20 @@ void tfileReaderDestroy(TFileReader* reader) {
int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* result) {
SIndexTerm* term = query->term;
+ bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(term->colType, TSDB_DATA_TYPE_JSON);
EIndexQueryType qtype = query->qType;
int ret = -1;
// refactor to callback later
if (qtype == QUERY_TERM) {
uint64_t offset;
- FstSlice key = fstSliceCreate(term->colVal, term->nColVal);
+ char* p = term->colVal;
+ uint64_t sz = term->nColVal;
+ if (hasJson) {
+ p = indexPackJsonData(term);
+ sz = strlen(p);
+ }
+ FstSlice key = fstSliceCreate(p, sz);
if (fstGet(reader->fst, &key, &offset)) {
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName,
term->colVal);
@@ -202,10 +210,17 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
term->colVal);
}
fstSliceDestroy(&key);
+ if (hasJson) {
+ free(p);
+ }
} else if (qtype == QUERY_PREFIX) {
// handle later
//
- } else {
+ } else if (qtype == QUERY_SUFFIX) {
+ // handle later
+ } else if (qtype == QUERY_REGEX) {
+ // handle later
+ } else if (qtype == QUERY_RANGE) {
// handle later
}
tfileReaderUnRef(reader);
@@ -260,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
__compar_fn_t fn;
int8_t colType = tw->header.colType;
+ colType = INDEX_TYPE_GET_TYPE(colType);
if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
fn = tfileStrCompare;
} else {
@@ -557,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) {
static int tfileWriteData(TFileWriter* write, TFileValue* tval) {
TFileHeader* header = &write->header;
uint8_t colType = header->colType;
+
+ colType = INDEX_TYPE_GET_TYPE(colType);
if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
FstSlice key = fstSliceCreate((uint8_t*)(tval->colVal), (size_t)strlen(tval->colVal));
if (fstBuilderInsert(write->fb, key, tval->offset)) {
@@ -586,11 +604,10 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
int64_t nread = reader->ctx->readFrom(reader->ctx, buf, sizeof(buf), 0);
if (nread == -1) {
- indexError("actual Read: %d, to read: %d, errno: %d, filename: %s", (int)(nread), (int)sizeof(buf),
- errno, reader->ctx->file.buf);
+ indexError("actual Read: %d, to read: %d, errno: %d, filename: %s", (int)(nread), (int)sizeof(buf), errno,
+ reader->ctx->file.buf);
} else {
- indexInfo("actual Read: %d, to read: %d, filename: %s", (int)(nread), (int)sizeof(buf),
- reader->ctx->file.buf);
+ indexInfo("actual Read: %d, to read: %d, filename: %s", (int)(nread), (int)sizeof(buf), reader->ctx->file.buf);
}
// assert(nread == sizeof(buf));
memcpy(&reader->header, buf, sizeof(buf));
diff --git a/source/libs/index/test/CMakeLists.txt b/source/libs/index/test/CMakeLists.txt
index bed42be3e5..1ebf85368b 100644
--- a/source/libs/index/test/CMakeLists.txt
+++ b/source/libs/index/test/CMakeLists.txt
@@ -2,6 +2,7 @@ add_executable(indexTest "")
add_executable(fstTest "")
add_executable(fstUT "")
add_executable(UtilUT "")
+add_executable(jsonUT "")
target_sources(indexTest
PRIVATE
@@ -21,6 +22,10 @@ target_sources(UtilUT
"utilUT.cc"
)
+target_sources(jsonUT
+ PRIVATE
+ "jsonUT.cc"
+)
target_include_directories ( indexTest
PUBLIC
"${CMAKE_SOURCE_DIR}/include/libs/index"
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
"${CMAKE_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
+
+target_include_directories (jsonUT
+ PUBLIC
+ "${CMAKE_SOURCE_DIR}/include/libs/index"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
+)
target_link_libraries (indexTest
os
util
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
index
)
+target_link_libraries (jsonUT
+ os
+ util
+ common
+ gtest_main
+ index
+)
#add_test(
# NAME index_test
diff --git a/source/libs/index/test/fstTest.cc b/source/libs/index/test/fstTest.cc
index 698945ae14..cb3206a611 100644
--- a/source/libs/index/test/fstTest.cc
+++ b/source/libs/index/test/fstTest.cc
@@ -301,13 +301,18 @@ void validateTFile(char* arg) {
}
}
-void iterTFileReader(char* path, char* ver) {
- int version = atoi(ver);
- TFileReader* reader = tfileReaderOpen(path, 0, version, "tag1");
- Iterate* iter = tfileIteratorCreate(reader);
- bool tn = iter ? iter->next(iter) : false;
- int count = 0;
- int termCount = 0;
+void iterTFileReader(char* path, char* uid, char* colName, char* ver) {
+ // tfInit();
+
+ uint64_t suid = atoi(uid);
+ int version = atoi(ver);
+
+ TFileReader* reader = tfileReaderOpen(path, suid, version, colName);
+
+ Iterate* iter = tfileIteratorCreate(reader);
+ bool tn = iter ? iter->next(iter) : false;
+ int count = 0;
+ int termCount = 0;
while (tn == true) {
count++;
IterateValue* cv = iter->getValue(iter);
@@ -323,9 +328,9 @@ void iterTFileReader(char* path, char* ver) {
int main(int argc, char* argv[]) {
// tool to check all kind of fst test
// if (argc > 1) { validateTFile(argv[1]); }
- if (argc > 2) {
- // opt
- iterTFileReader(argv[1], argv[2]);
+ if (argc > 4) {
+ // path suid colName ver
+ iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
}
// checkFstCheckIterator();
// checkFstLongTerm();
diff --git a/source/libs/index/test/fstUT.cc b/source/libs/index/test/fstUT.cc
index 2d3d2f8894..6e9c88bc79 100644
--- a/source/libs/index/test/fstUT.cc
+++ b/source/libs/index/test/fstUT.cc
@@ -213,21 +213,21 @@ class FstEnv : public ::testing::Test {
TEST_F(FstEnv, writeNormal) {
fst->CreateWriter();
- std::string str("aa");
+ std::string str("11");
for (int i = 0; i < 10; i++) {
- str[0] = 'a' + i;
+ str[0] = '1' + i;
str.resize(2);
assert(fst->Put(str, i) == true);
}
// order failed
- assert(fst->Put("aa", 1) == false);
+ assert(fst->Put("11", 1) == false);
fst->DestroyWriter();
fst->CreateReader();
uint64_t val;
- assert(fst->Get("a", &val) == false);
- assert(fst->Get("aa", &val) == true);
+ assert(fst->Get("1", &val) == false);
+ assert(fst->Get("11", &val) == true);
assert(val == 0);
std::vector rlt;
@@ -235,3 +235,19 @@ TEST_F(FstEnv, writeNormal) {
assert(fst->Search(ctx, rlt) == true);
}
TEST_F(FstEnv, WriteMillonrRecord) {}
+TEST_F(FstEnv, writeAbNormal) {
+ fst->CreateWriter();
+ std::string str1("voltage&\b&ab");
+ std::string str2("voltbge&\b&ab");
+
+ fst->Put(str1, 1);
+ fst->Put(str2, 2);
+
+ fst->DestroyWriter();
+
+ fst->CreateReader();
+ uint64_t val;
+ assert(fst->Get("1", &val) == false);
+ assert(fst->Get("voltage&\b&ab", &val) == true);
+ assert(val == 1);
+}
diff --git a/source/libs/index/test/jsonUT.cc b/source/libs/index/test/jsonUT.cc
new file mode 100644
index 0000000000..e5c79d137f
--- /dev/null
+++ b/source/libs/index/test/jsonUT.cc
@@ -0,0 +1,135 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include "index.h"
+#include "indexInt.h"
+#include "index_cache.h"
+#include "index_fst.h"
+#include "index_fst_counting_writer.h"
+#include "index_fst_util.h"
+#include "index_tfile.h"
+#include "index_util.h"
+#include "tglobal.h"
+#include "tskiplist.h"
+#include "tutil.h"
+
+static std::string dir = "/tmp/json";
+class JsonEnv : public ::testing::Test {
+ protected:
+ virtual void SetUp() {
+ taosRemoveDir(dir.c_str());
+ taosMkDir(dir.c_str());
+ printf("set up\n");
+ opts = indexOptsCreate();
+ int ret = tIndexJsonOpen(opts, dir.c_str(), &index);
+ assert(ret == 0);
+ }
+ virtual void TearDown() {
+ tIndexJsonClose(index);
+ indexOptsDestroy(opts);
+ printf("destory\n");
+ }
+ SIndexJsonOpts* opts;
+ SIndexJson* index;
+};
+
+TEST_F(JsonEnv, testWrite) {
+ {
+ std::string colName("test");
+ std::string colVal("ab");
+ SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SIndexMultiTerm* terms = indexMultiTermCreate();
+ indexMultiTermAdd(terms, term);
+ for (size_t i = 0; i < 100; i++) {
+ tIndexJsonPut(index, terms, i);
+ }
+ indexMultiTermDestroy(terms);
+ }
+ {
+ std::string colName("voltage");
+ std::string colVal("ab1");
+ SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SIndexMultiTerm* terms = indexMultiTermCreate();
+ indexMultiTermAdd(terms, term);
+ for (size_t i = 0; i < 100; i++) {
+ tIndexJsonPut(index, terms, i);
+ }
+ indexMultiTermDestroy(terms);
+ }
+ {
+ std::string colName("voltage");
+ std::string colVal("123");
+ SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SIndexMultiTerm* terms = indexMultiTermCreate();
+ indexMultiTermAdd(terms, term);
+ for (size_t i = 0; i < 100; i++) {
+ tIndexJsonPut(index, terms, i);
+ }
+ indexMultiTermDestroy(terms);
+ }
+ {
+ std::string colName("test");
+ std::string colVal("ab");
+
+ SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
+ SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SArray* result = taosArrayInit(1, sizeof(uint64_t));
+ indexMultiTermQueryAdd(mq, q, QUERY_TERM);
+ tIndexJsonSearch(index, mq, result);
+ assert(100 == taosArrayGetSize(result));
+ indexMultiTermQueryDestroy(mq);
+ }
+}
+TEST_F(JsonEnv, testWriteMillonData) {
+ {
+ std::string colName("test");
+ std::string colVal("ab");
+ SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SIndexMultiTerm* terms = indexMultiTermCreate();
+ indexMultiTermAdd(terms, term);
+ for (size_t i = 0; i < 100; i++) {
+ tIndexJsonPut(index, terms, i);
+ }
+ indexMultiTermDestroy(terms);
+ }
+ {
+ std::string colName("voltagefdadfa");
+ std::string colVal("abxxxxxxxxxxxx");
+ SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SIndexMultiTerm* terms = indexMultiTermCreate();
+ indexMultiTermAdd(terms, term);
+ for (size_t i = 0; i < 1000000; i++) {
+ tIndexJsonPut(index, terms, i);
+ }
+ indexMultiTermDestroy(terms);
+ }
+ {
+ std::string colName("test");
+ std::string colVal("ab");
+
+ SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
+ SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+
+ SArray* result = taosArrayInit(1, sizeof(uint64_t));
+ indexMultiTermQueryAdd(mq, q, QUERY_TERM);
+ tIndexJsonSearch(index, mq, result);
+ assert(100 == taosArrayGetSize(result));
+ indexMultiTermQueryDestroy(mq);
+ }
+}
diff --git a/source/libs/monitor/src/monitor.c b/source/libs/monitor/src/monitor.c
index 811ee40dc8..ecf9da218b 100644
--- a/source/libs/monitor/src/monitor.c
+++ b/source/libs/monitor/src/monitor.c
@@ -23,7 +23,7 @@
static SMonitor tsMonitor = {0};
int32_t monInit(const SMonCfg *pCfg) {
- tsMonitor.logs = taosArrayInit(16, sizeof(SMonInfo));
+ tsMonitor.logs = taosArrayInit(16, sizeof(SMonLogItem));
if (tsMonitor.logs == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@@ -44,7 +44,7 @@ void monCleanup() {
void monAddLogItem(SMonLogItem *pItem) {
taosWLockLatch(&tsMonitor.lock);
int32_t size = taosArrayGetSize(tsMonitor.logs);
- if (size > tsMonitor.maxLogs) {
+ if (size >= tsMonitor.maxLogs) {
uInfo("too many logs for monitor");
} else {
taosArrayPush(tsMonitor.logs, pItem);
@@ -54,7 +54,10 @@ void monAddLogItem(SMonLogItem *pItem) {
SMonInfo *monCreateMonitorInfo() {
SMonInfo *pMonitor = calloc(1, sizeof(SMonInfo));
- if (pMonitor == NULL) return NULL;
+ if (pMonitor == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
taosWLockLatch(&tsMonitor.lock);
pMonitor->logs = taosArrayDup(tsMonitor.logs);
@@ -77,41 +80,257 @@ void monCleanupMonitorInfo(SMonInfo *pMonitor) {
free(pMonitor);
}
+void monSetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo) {
+ SJson *pJson = pMonitor->pJson;
+ int64_t ms = taosGetTimestampMs();
+ char buf[40] = {0};
+ taosFormatUtcTime(buf, sizeof(buf), ms, TSDB_TIME_PRECISION_MILLI);
+
+ tjsonAddStringToObject(pJson, "ts", buf);
+ tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
+ tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
+}
+
+void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
+ SJson *pJson = tjsonCreateObject();
+ if (pJson == NULL) return;
+ if (tjsonAddItemToObject(pMonitor->pJson, "cluster_info", pJson) != 0) {
+ tjsonDelete(pJson);
+ return;
+ }
+
+ tjsonAddStringToObject(pJson, "first_ep", pInfo->first_ep);
+ tjsonAddDoubleToObject(pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id);
+ tjsonAddStringToObject(pJson, "version", pInfo->version);
+ tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime);
+ tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval);
+ tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total);
+ tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive);
+ tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total);
+ tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive);
+ tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total);
+
+ SJson *pDnodesJson = tjsonAddArrayToObject(pJson, "dnodes");
+ if (pDnodesJson == NULL) return;
+
+ for (int32_t i = 0; i < taosArrayGetSize(pInfo->dnodes); ++i) {
+ SJson *pDnodeJson = tjsonCreateObject();
+ if (pDnodeJson == NULL) continue;
+
+ SMonDnodeDesc *pDnodeDesc = taosArrayGet(pInfo->dnodes, i);
+ tjsonAddDoubleToObject(pDnodeJson, "dnode_id", pDnodeDesc->dnode_id);
+ tjsonAddStringToObject(pDnodeJson, "dnode_ep", pDnodeDesc->dnode_ep);
+ tjsonAddStringToObject(pDnodeJson, "status", pDnodeDesc->status);
+
+ if (tjsonAddItemToArray(pDnodesJson, pDnodeJson) != 0) tjsonDelete(pDnodeJson);
+ }
+
+ SJson *pMnodesJson = tjsonAddArrayToObject(pJson, "mnodes");
+ if (pMnodesJson == NULL) return;
+
+ for (int32_t i = 0; i < taosArrayGetSize(pInfo->dnodes); ++i) {
+ SJson *pMnodeJson = tjsonCreateObject();
+ if (pMnodeJson == NULL) continue;
+
+ SMonMnodeDesc *pMnodeDesc = taosArrayGet(pInfo->dnodes, i);
+ tjsonAddDoubleToObject(pMnodeJson, "mnode_id", pMnodeDesc->mnode_id);
+ tjsonAddStringToObject(pMnodeJson, "mnode_ep", pMnodeDesc->mnode_ep);
+ tjsonAddStringToObject(pMnodeJson, "role", pMnodeDesc->role);
+
+ if (tjsonAddItemToArray(pMnodesJson, pMnodeJson) != 0) tjsonDelete(pMnodeJson);
+ }
+}
+
+void monSetVgroupInfo(SMonInfo *pMonitor, SMonVgroupInfo *pInfo) {
+ SJson *pJson = tjsonAddArrayToObject(pMonitor->pJson, "vgroup_infos");
+ if (pJson == NULL) return;
+
+ for (int32_t i = 0; i < taosArrayGetSize(pInfo->vgroups); ++i) {
+ SJson *pVgroupJson = tjsonCreateObject();
+ if (pVgroupJson == NULL) continue;
+ if (tjsonAddItemToArray(pJson, pVgroupJson) != 0) {
+ tjsonDelete(pVgroupJson);
+ continue;
+ }
+
+ SMonVgroupDesc *pVgroupDesc = taosArrayGet(pInfo->vgroups, i);
+ tjsonAddDoubleToObject(pVgroupJson, "vgroup_id", pVgroupDesc->vgroup_id);
+ tjsonAddStringToObject(pVgroupJson, "database_name", pVgroupDesc->database_name);
+ tjsonAddDoubleToObject(pVgroupJson, "tables_num", pVgroupDesc->tables_num);
+ tjsonAddStringToObject(pVgroupJson, "status", pVgroupDesc->status);
+
+ SJson *pVnodesJson = tjsonAddArrayToObject(pVgroupJson, "vnodes");
+ if (pVnodesJson == NULL) continue;
+
+ for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) {
+ SMonVnodeDesc *pVnodeDesc = &pVgroupDesc->vnodes[j];
+ if (pVnodeDesc->dnode_id <= 0) continue;
+
+ SJson *pVnodeJson = tjsonCreateObject();
+ if (pVnodeJson == NULL) continue;
+
+ tjsonAddDoubleToObject(pVnodeJson, "dnode_id", pVnodeDesc->dnode_id);
+ tjsonAddStringToObject(pVnodeJson, "vnode_role", pVnodeDesc->vnode_role);
+
+ if (tjsonAddItemToArray(pVnodesJson, pVnodeJson) != 0) tjsonDelete(pVnodeJson);
+ }
+ }
+}
+
+void monSetGrantInfo(SMonInfo *pMonitor, SMonGrantInfo *pInfo) {
+ SJson *pJson = tjsonCreateObject();
+ if (pJson == NULL) return;
+ if (tjsonAddItemToObject(pMonitor->pJson, "grant_info", pJson) != 0) {
+ tjsonDelete(pJson);
+ return;
+ }
+
+ tjsonAddDoubleToObject(pJson, "expire_time", pInfo->expire_time);
+ tjsonAddDoubleToObject(pJson, "timeseries_used", pInfo->timeseries_used);
+ tjsonAddDoubleToObject(pJson, "timeseries_total", pInfo->timeseries_total);
+}
+
+void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
+ SJson *pJson = tjsonCreateObject();
+ if (pJson == NULL) return;
+ if (tjsonAddItemToObject(pMonitor->pJson, "dnode_info", pJson) != 0) {
+ tjsonDelete(pJson);
+ return;
+ }
+
+ tjsonAddDoubleToObject(pJson, "uptime", pInfo->uptime);
+ tjsonAddDoubleToObject(pJson, "cpu_engine", pInfo->cpu_engine);
+ tjsonAddDoubleToObject(pJson, "cpu_system", pInfo->cpu_system);
+ tjsonAddDoubleToObject(pJson, "cpu_cores", pInfo->cpu_cores);
+ tjsonAddDoubleToObject(pJson, "mem_engine", pInfo->mem_engine);
+ tjsonAddDoubleToObject(pJson, "mem_system", pInfo->mem_system);
+ tjsonAddDoubleToObject(pJson, "mem_total", pInfo->mem_total);
+ tjsonAddDoubleToObject(pJson, "disk_engine", pInfo->disk_engine);
+ tjsonAddDoubleToObject(pJson, "disk_used", pInfo->disk_used);
+ tjsonAddDoubleToObject(pJson, "disk_total", pInfo->disk_total);
+ tjsonAddDoubleToObject(pJson, "net_in", pInfo->net_in);
+ tjsonAddDoubleToObject(pJson, "net_out", pInfo->net_out);
+ tjsonAddDoubleToObject(pJson, "io_read", pInfo->io_read);
+ tjsonAddDoubleToObject(pJson, "io_write", pInfo->io_write);
+ tjsonAddDoubleToObject(pJson, "io_read_disk", pInfo->io_read_disk);
+ tjsonAddDoubleToObject(pJson, "io_write_disk", pInfo->io_write_disk);
+ tjsonAddDoubleToObject(pJson, "req_select", pInfo->req_select);
+ tjsonAddDoubleToObject(pJson, "req_select_rate", pInfo->req_select_rate);
+ tjsonAddDoubleToObject(pJson, "req_insert", pInfo->req_insert);
+ tjsonAddDoubleToObject(pJson, "req_insert_success", pInfo->req_insert_success);
+ tjsonAddDoubleToObject(pJson, "req_insert_rate", pInfo->req_insert_rate);
+ tjsonAddDoubleToObject(pJson, "req_insert_batch", pInfo->req_insert_batch);
+ tjsonAddDoubleToObject(pJson, "req_insert_batch_success", pInfo->req_insert_batch_success);
+ tjsonAddDoubleToObject(pJson, "req_insert_batch_rate", pInfo->req_insert_batch_rate);
+ tjsonAddDoubleToObject(pJson, "errors", pInfo->errors);
+ tjsonAddDoubleToObject(pJson, "vnodes_num", pInfo->vnodes_num);
+ tjsonAddDoubleToObject(pJson, "masters", pInfo->masters);
+ tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode);
+}
+
+void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
+ SJson *pJson = tjsonCreateObject();
+ if (pJson == NULL) return;
+ if (tjsonAddItemToObject(pMonitor->pJson, "disk_infos", pJson) != 0) {
+ tjsonDelete(pJson);
+ return;
+ }
+
+ SJson *pDatadirsJson = tjsonAddArrayToObject(pJson, "datadir");
+ if (pDatadirsJson == NULL) return;
+
+ for (int32_t i = 0; i < taosArrayGetSize(pInfo->datadirs); ++i) {
+ SJson *pDatadirJson = tjsonCreateObject();
+ if (pDatadirJson == NULL) continue;
+
+ SMonDiskDesc *pDatadirDesc = taosArrayGet(pInfo->datadirs, i);
+ if (tjsonAddStringToObject(pDatadirJson, "name", pDatadirDesc->name) != 0) tjsonDelete(pDatadirJson);
+ if (tjsonAddDoubleToObject(pDatadirJson, "level", pDatadirDesc->level) != 0) tjsonDelete(pDatadirJson);
+ if (tjsonAddDoubleToObject(pDatadirJson, "avail", pDatadirDesc->size.avail) != 0) tjsonDelete(pDatadirJson);
+ if (tjsonAddDoubleToObject(pDatadirJson, "used", pDatadirDesc->size.used) != 0) tjsonDelete(pDatadirJson);
+ if (tjsonAddDoubleToObject(pDatadirJson, "total", pDatadirDesc->size.total) != 0) tjsonDelete(pDatadirJson);
+
+ if (tjsonAddItemToArray(pDatadirsJson, pDatadirJson) != 0) tjsonDelete(pDatadirJson);
+ }
+
+ SJson *pLogdirJson = tjsonCreateObject();
+ if (pLogdirJson == NULL) return;
+ if (tjsonAddItemToObject(pJson, "logdir", pLogdirJson) != 0) return;
+ tjsonAddStringToObject(pLogdirJson, "name", pInfo->logdir.name);
+ tjsonAddDoubleToObject(pLogdirJson, "avail", pInfo->logdir.size.avail);
+ tjsonAddDoubleToObject(pLogdirJson, "used", pInfo->logdir.size.used);
+ tjsonAddDoubleToObject(pLogdirJson, "total", pInfo->logdir.size.total);
+
+ SJson *pTempdirJson = tjsonCreateObject();
+ if (pTempdirJson == NULL) return;
+ if (tjsonAddItemToObject(pJson, "tempdir", pTempdirJson) != 0) return;
+ tjsonAddStringToObject(pTempdirJson, "name", pInfo->tempdir.name);
+ tjsonAddDoubleToObject(pTempdirJson, "avail", pInfo->tempdir.size.avail);
+ tjsonAddDoubleToObject(pTempdirJson, "used", pInfo->tempdir.size.used);
+ tjsonAddDoubleToObject(pTempdirJson, "total", pInfo->tempdir.size.total);
+}
+
+static void monSetLogInfo(SMonInfo *pMonitor) {
+ SJson *pJson = tjsonCreateObject();
+ if (pJson == NULL) return;
+ if (tjsonAddItemToObject(pMonitor->pJson, "log_infos", pJson) != 0) {
+ tjsonDelete(pJson);
+ return;
+ }
+
+ SJson *pLogsJson = tjsonAddArrayToObject(pJson, "logs");
+ if (pLogsJson == NULL) return;
+
+ for (int32_t i = 0; i < taosArrayGetSize(pMonitor->logs); ++i) {
+ SJson *pLogJson = tjsonCreateObject();
+ if (pLogJson == NULL) continue;
+
+ SMonLogItem *pLogItem = taosArrayGet(pMonitor->logs, i);
+
+ char buf[40] = {0};
+ taosFormatUtcTime(buf, sizeof(buf), pLogItem->ts, TSDB_TIME_PRECISION_MILLI);
+
+ tjsonAddStringToObject(pLogJson, "ts", buf);
+ tjsonAddDoubleToObject(pLogJson, "level", pLogItem->level);
+ tjsonAddStringToObject(pLogJson, "content", pLogItem->content);
+
+ if (tjsonAddItemToArray(pLogsJson, pLogJson) != 0) tjsonDelete(pLogJson);
+ }
+
+ SJson *pSummaryJson = tjsonAddArrayToObject(pJson, "summary");
+ if (pSummaryJson == NULL) return;
+
+ SJson *pLogError = tjsonCreateObject();
+ if (pLogError == NULL) return;
+ tjsonAddStringToObject(pLogError, "level", "error");
+ tjsonAddDoubleToObject(pLogError, "total", 1);
+ if (tjsonAddItemToArray(pSummaryJson, pLogError) != 0) tjsonDelete(pLogError);
+
+ SJson *pLogInfo = tjsonCreateObject();
+ if (pLogInfo == NULL) return;
+ tjsonAddStringToObject(pLogInfo, "level", "info");
+ tjsonAddDoubleToObject(pLogInfo, "total", 1);
+ if (tjsonAddItemToArray(pSummaryJson, pLogInfo) != 0) tjsonDelete(pLogInfo);
+
+ SJson *pLogDebug = tjsonCreateObject();
+ if (pLogDebug == NULL) return;
+ tjsonAddStringToObject(pLogDebug, "level", "debug");
+ tjsonAddDoubleToObject(pLogDebug, "total", 1);
+ if (tjsonAddItemToArray(pSummaryJson, pLogDebug) != 0) tjsonDelete(pLogDebug);
+
+ SJson *pLogTrace = tjsonCreateObject();
+ if (pLogTrace == NULL) return;
+ tjsonAddStringToObject(pLogTrace, "level", "trace");
+ tjsonAddDoubleToObject(pLogTrace, "total", 1);
+ if (tjsonAddItemToArray(pSummaryJson, pLogTrace) != 0) tjsonDelete(pLogTrace);
+}
+
void monSendReport(SMonInfo *pMonitor) {
+ monSetLogInfo(pMonitor);
+
char *pCont = tjsonToString(pMonitor->pJson);
if (pCont != NULL) {
taosSendHttpReport(tsMonitor.server, tsMonitor.port, pCont, strlen(pCont));
free(pCont);
}
}
-
-void monSetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo) {
- SJson *pJson = pMonitor->pJson;
- tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
- tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
-
- int64_t ms = taosGetTimestampMs();
- char buf[40] = {0};
- taosFormatUtcTime(buf, sizeof(buf), ms, TSDB_TIME_PRECISION_MILLI);
- tjsonAddStringToObject(pJson, "ts", buf);
-}
-
-void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
-
-}
-
-void monSetVgroupInfo(SMonInfo *pMonitor, SMonVgroupInfo *pInfo) {
-
-}
-
-void monSetGrantInfo(SMonInfo *pMonitor, SMonGrantInfo *pInfo) {
-
-}
-
-void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
-
-}
-
-void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
-
-}
diff --git a/source/libs/monitor/test/monTest.cpp b/source/libs/monitor/test/monTest.cpp
index a1805d0c9c..ad48ed5407 100644
--- a/source/libs/monitor/test/monTest.cpp
+++ b/source/libs/monitor/test/monTest.cpp
@@ -13,21 +13,262 @@
#include "os.h"
#include "monitor.h"
+#include "tglobal.h"
class MonitorTest : public ::testing::Test {
protected:
- static void SetUpTestSuite() { root = "/tmp/monTest"; }
- static void TearDownTestSuite() {}
+ static void SetUpTestSuite() {
+ SMonCfg cfg;
+ cfg.maxLogs = 2;
+ cfg.port = 80;
+ cfg.server = "localhost";
+ monInit(&cfg);
+ }
+
+ static void TearDownTestSuite() { monCleanup(); }
public:
void SetUp() override {}
void TearDown() override {}
- static const char *root;
+ void GetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo);
+ void GetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo);
+ void GetVgroupInfo(SMonInfo *pMonitor, SMonVgroupInfo *pInfo);
+ void GetGrantInfo(SMonInfo *pMonitor, SMonGrantInfo *pInfo);
+ void GetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo);
+ void GetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo);
+ void AddLogInfo1();
+ void AddLogInfo2();
};
-const char *MonitorTest::root;
-
-TEST_F(MonitorTest, 01_Open_Close) {
-
+void MonitorTest::GetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo) {
+ pInfo->dnode_id = 1;
+ strcpy(pInfo->dnode_ep, "localhost");
+}
+
+void MonitorTest::GetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
+ strcpy(pInfo->first_ep, "localhost:6030");
+ pInfo->first_ep_dnode_id = 1;
+ strcpy(pInfo->version, "3.0.0.0");
+ pInfo->master_uptime = 1;
+ pInfo->monitor_interval = 2;
+ pInfo->vgroups_total = 3;
+ pInfo->vgroups_alive = 43;
+ pInfo->vnodes_total = 5;
+ pInfo->vnodes_alive = 6;
+ pInfo->connections_total = 7;
+
+ pInfo->dnodes = taosArrayInit(4, sizeof(SMonDnodeDesc));
+ SMonDnodeDesc d1 = {0};
+ d1.dnode_id = 1;
+ strcpy(d1.dnode_ep, "localhost:6030");
+ strcpy(d1.status, "ready");
+ taosArrayPush(pInfo->dnodes, &d1);
+ SMonDnodeDesc d2 = {0};
+ d2.dnode_id = 2;
+ strcpy(d2.dnode_ep, "localhost:7030");
+ strcpy(d2.status, "offline");
+ taosArrayPush(pInfo->dnodes, &d2);
+
+ pInfo->mnodes = taosArrayInit(4, sizeof(SMonMnodeDesc));
+ SMonMnodeDesc m1 = {0};
+ m1.mnode_id = 1;
+ strcpy(m1.mnode_ep, "localhost:6030");
+ strcpy(m1.role, "master");
+ taosArrayPush(pInfo->mnodes, &m1);
+ SMonMnodeDesc m2 = {0};
+ m2.mnode_id = 2;
+ strcpy(m2.mnode_ep, "localhost:7030");
+ strcpy(m2.role, "unsynced");
+ taosArrayPush(pInfo->mnodes, &m2);
+}
+
+void MonitorTest::GetVgroupInfo(SMonInfo *pMonitor, SMonVgroupInfo *pInfo) {
+ pInfo->vgroups = taosArrayInit(4, sizeof(SMonVgroupDesc));
+
+ SMonVgroupDesc vg1 = {0};
+ vg1.vgroup_id = 1;
+ strcpy(vg1.database_name, "d1");
+ vg1.tables_num = 4;
+ strcpy(vg1.status, "ready");
+ vg1.vnodes[0].dnode_id = 1;
+ strcpy(vg1.vnodes[0].vnode_role, "master");
+ vg1.vnodes[1].dnode_id = 2;
+ strcpy(vg1.vnodes[1].vnode_role, "slave");
+ taosArrayPush(pInfo->vgroups, &vg1);
+
+ SMonVgroupDesc vg2 = {0};
+ vg2.vgroup_id = 2;
+ strcpy(vg2.database_name, "d2");
+ vg2.tables_num = 5;
+ strcpy(vg2.status, "offline");
+ vg2.vnodes[0].dnode_id = 1;
+ strcpy(vg2.vnodes[0].vnode_role, "master");
+ vg2.vnodes[1].dnode_id = 2;
+ strcpy(vg2.vnodes[1].vnode_role, "unsynced");
+ taosArrayPush(pInfo->vgroups, &vg2);
+
+ SMonVgroupDesc vg3 = {0};
+ vg3.vgroup_id = 3;
+ strcpy(vg3.database_name, "d3");
+ vg3.tables_num = 6;
+ strcpy(vg3.status, "ready");
+ vg3.vnodes[0].dnode_id = 1;
+ strcpy(vg3.vnodes[0].vnode_role, "master");
+ taosArrayPush(pInfo->vgroups, &vg3);
+}
+
+void MonitorTest::GetGrantInfo(SMonInfo *pMonitor, SMonGrantInfo *pInfo) {
+ pInfo->expire_time = 1234567;
+ pInfo->timeseries_total = 234567;
+ pInfo->timeseries_used = 34567;
+}
+
+void MonitorTest::GetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
+ pInfo->uptime = 1.2;
+ pInfo->cpu_engine = 2.1;
+ pInfo->cpu_system = 2.1;
+ pInfo->cpu_cores = 2;
+ pInfo->mem_engine = 3.1;
+ pInfo->mem_system = 3.2;
+ pInfo->mem_total = 3.3;
+ pInfo->disk_engine = 4.1;
+ pInfo->disk_used = 4.2;
+ pInfo->disk_total = 4.3;
+ pInfo->net_in = 5.1;
+ pInfo->net_out = 5.2;
+ pInfo->io_read = 6.1;
+ pInfo->io_write = 6.2;
+ pInfo->io_read_disk = 7.1;
+ pInfo->io_write_disk = 7.2;
+ pInfo->req_select = 8;
+ pInfo->req_select_rate = 8.1;
+ pInfo->req_insert = 9;
+ pInfo->req_insert_success = 10;
+ pInfo->req_insert_rate = 10.1;
+ pInfo->req_insert_batch = 11;
+ pInfo->req_insert_batch_success = 12;
+ pInfo->req_insert_batch_rate = 12.3;
+ pInfo->errors = 4;
+ pInfo->vnodes_num = 5;
+ pInfo->masters = 6;
+ pInfo->has_mnode = 1;
+}
+
+void MonitorTest::GetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
+ pInfo->datadirs = taosArrayInit(2, sizeof(SMonDiskDesc));
+ SMonDiskDesc d1 = {0};
+ strcpy(d1.name, "/t1/d1/d");
+ d1.level = 0;
+ d1.size.avail = 11;
+ d1.size.total = 12;
+ d1.size.used = 13;
+ taosArrayPush(pInfo->datadirs, &d1);
+
+ SMonDiskDesc d2 = {0};
+ strcpy(d2.name, "/t2d2/d");
+ d2.level = 2;
+ d2.size.avail = 21;
+ d2.size.total = 22;
+ d2.size.used = 23;
+ taosArrayPush(pInfo->datadirs, &d2);
+
+ SMonDiskDesc d3 = {0};
+ strcpy(d3.name, "/t3/d3/d");
+ d3.level = 3;
+ d3.size.avail = 31;
+ d3.size.total = 32;
+ d3.size.used = 33;
+ taosArrayPush(pInfo->datadirs, &d3);
+
+ strcpy(pInfo->logdir.name, "/log/dir/d");
+ pInfo->logdir.size.avail = 41;
+ pInfo->logdir.size.total = 42;
+ pInfo->logdir.size.used = 43;
+
+ strcpy(pInfo->tempdir.name, "/data/dir/d");
+ pInfo->tempdir.size.avail = 51;
+ pInfo->tempdir.size.total = 52;
+ pInfo->tempdir.size.used = 53;
+}
+
+void MonitorTest::AddLogInfo1() {
+ SMonLogItem log1 = {0};
+ log1.ts = taosGetTimestampMs();
+ log1.level = 1;
+ strcpy(log1.content, "1 -------------------------- a");
+ monAddLogItem(&log1);
+
+ SMonLogItem log2 = {0};
+ log2.ts = taosGetTimestampMs();
+ log2.level = 1;
+ strcpy(log2.content, "1 ------------------------ b");
+ monAddLogItem(&log2);
+
+ SMonLogItem log3 = {0};
+ log3.ts = taosGetTimestampMs();
+ log3.level = 1;
+ strcpy(log3.content, "1 ------- c");
+ monAddLogItem(&log3);
+}
+
+void MonitorTest::AddLogInfo2() {
+ SMonLogItem log1;
+ log1.ts = taosGetTimestampMs();
+ log1.level = 01;
+ strcpy(log1.content, "2 ------- a");
+ monAddLogItem(&log1);
+
+ SMonLogItem log2;
+ log2.ts = taosGetTimestampMs();
+ log2.level = 0;
+ strcpy(log2.content, "2 ------- b");
+ monAddLogItem(&log2);
+}
+
+TEST_F(MonitorTest, 01_Full) {
+ AddLogInfo1();
+
+ SMonInfo *pMonitor = monCreateMonitorInfo();
+ if (pMonitor == NULL) return;
+
+ SMonBasicInfo basicInfo = {0};
+ GetBasicInfo(pMonitor, &basicInfo);
+ monSetBasicInfo(pMonitor, &basicInfo);
+
+ SMonClusterInfo clusterInfo = {0};
+ SMonVgroupInfo vgroupInfo = {0};
+ SMonGrantInfo grantInfo = {0};
+ GetClusterInfo(pMonitor, &clusterInfo);
+ GetVgroupInfo(pMonitor, &vgroupInfo);
+ GetGrantInfo(pMonitor, &grantInfo);
+ monSetClusterInfo(pMonitor, &clusterInfo);
+ monSetVgroupInfo(pMonitor, &vgroupInfo);
+ monSetGrantInfo(pMonitor, &grantInfo);
+
+ SMonDnodeInfo dnodeInfo = {0};
+ GetDnodeInfo(pMonitor, &dnodeInfo);
+ monSetDnodeInfo(pMonitor, &dnodeInfo);
+
+ SMonDiskInfo diskInfo = {0};
+ GetDiskInfo(pMonitor, &diskInfo);
+ monSetDiskInfo(pMonitor, &diskInfo);
+
+ monSendReport(pMonitor);
+ monCleanupMonitorInfo(pMonitor);
+
+ taosArrayDestroy(clusterInfo.dnodes);
+ taosArrayDestroy(clusterInfo.mnodes);
+ taosArrayDestroy(vgroupInfo.vgroups);
+ taosArrayDestroy(diskInfo.datadirs);
+}
+
+TEST_F(MonitorTest, 02_Log) {
+ AddLogInfo2();
+
+ SMonInfo *pMonitor = monCreateMonitorInfo();
+ if (pMonitor == NULL) return;
+
+ monSendReport(pMonitor);
+ monCleanupMonitorInfo(pMonitor);
}
diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c
index a125906faf..e633dcfd93 100644
--- a/source/libs/nodes/src/nodesCloneFuncs.c
+++ b/source/libs/nodes/src/nodesCloneFuncs.c
@@ -13,6 +13,7 @@
* along with this program. If not, see .
*/
+#include "plannodes.h"
#include "querynodes.h"
#include "taos.h"
#include "taoserror.h"
@@ -157,6 +158,29 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
return (SNode*)pDst;
}
+static SNode* logicSubplanCopy(const SSubLogicPlan* pSrc, SSubLogicPlan* pDst) {
+ COPY_NODE_FIELD(pNode);
+ COPY_SCALAR_FIELD(subplanType);
+ return (SNode*)pDst;
+}
+
+static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
+ COPY_SCALAR_FIELD(dataBlockId);
+ COPY_NODE_LIST_FIELD(pSlots);
+ COPY_SCALAR_FIELD(resultRowSize);
+ COPY_SCALAR_FIELD(precision);
+ return (SNode*)pDst;
+}
+
+static SNode* slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) {
+ COPY_SCALAR_FIELD(slotId);
+ dataTypeCopy(&pSrc->dataType, &pDst->dataType);
+ COPY_SCALAR_FIELD(reserve);
+ COPY_SCALAR_FIELD(output);
+ COPY_SCALAR_FIELD(tag);
+ return (SNode*)pDst;
+}
+
SNodeptr nodesCloneNode(const SNodeptr pNode) {
if (NULL == pNode) {
return NULL;
@@ -187,9 +211,17 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst);
case QUERY_NODE_ORDER_BY_EXPR:
case QUERY_NODE_LIMIT:
+ break;
+ case QUERY_NODE_DATABLOCK_DESC:
+ return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
+ case QUERY_NODE_SLOT_DESC:
+ return slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst);
+ case QUERY_NODE_LOGIC_SUBPLAN:
+ return logicSubplanCopy((const SSubLogicPlan*)pNode, (SSubLogicPlan*)pDst);
default:
break;
}
+ printf("nodesCloneNode unknown node = %s\n", nodesNodeName(nodeType(pNode)));
return pDst;
}
diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c
index f01aac7b5c..ad9c392bc2 100644
--- a/source/libs/nodes/src/nodesCodeFuncs.c
+++ b/source/libs/nodes/src/nodesCodeFuncs.c
@@ -24,7 +24,7 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj);
static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** pNode);
static int32_t makeNodeByJson(const SJson* pJson, SNode** pNode);
-static char* nodeName(ENodeType type) {
+const char* nodesNodeName(ENodeType type) {
switch (type) {
case QUERY_NODE_COLUMN:
return "Column";
@@ -58,20 +58,32 @@ static char* nodeName(ENodeType type) {
return "NodeList";
case QUERY_NODE_FILL:
return "Fill";
- case QUERY_NODE_TARGET:
- return "Target";
case QUERY_NODE_RAW_EXPR:
return "RawExpr";
+ case QUERY_NODE_TARGET:
+ return "Target";
case QUERY_NODE_DATABLOCK_DESC:
return "TupleDesc";
case QUERY_NODE_SLOT_DESC:
return "SlotDesc";
+ case QUERY_NODE_COLUMN_DEF:
+ return "ColumnDef";
case QUERY_NODE_SET_OPERATOR:
return "SetOperator";
case QUERY_NODE_SELECT_STMT:
return "SelectStmt";
- case QUERY_NODE_SHOW_STMT:
- return "ShowStmt";
+ case QUERY_NODE_VNODE_MODIF_STMT:
+ return "VnodeModifStmt";
+ case QUERY_NODE_CREATE_DATABASE_STMT:
+ return "CreateDatabaseStmt";
+ case QUERY_NODE_CREATE_TABLE_STMT:
+ return "CreateTableStmt";
+ case QUERY_NODE_USE_DATABASE_STMT:
+ return "UseDatabaseStmt";
+ case QUERY_NODE_SHOW_DATABASES_STMT:
+ return "ShowDatabaseStmt";
+ case QUERY_NODE_SHOW_TABLES_STMT:
+ return "ShowTablesStmt";
case QUERY_NODE_LOGIC_PLAN_SCAN:
return "LogicScan";
case QUERY_NODE_LOGIC_PLAN_JOIN:
@@ -80,16 +92,34 @@ static char* nodeName(ENodeType type) {
return "LogicAgg";
case QUERY_NODE_LOGIC_PLAN_PROJECT:
return "LogicProject";
+ case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
+ return "LogicVnodeModif";
+ case QUERY_NODE_LOGIC_SUBPLAN:
+ return "LogicSubplan";
+ case QUERY_NODE_LOGIC_PLAN:
+ return "LogicPlan";
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
return "PhysiTagScan";
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
return "PhysiTableScan";
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
+ return "PhysiTableSeqScan";
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
+ return "PhysiSreamScan";
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
return "PhysiProject";
case QUERY_NODE_PHYSICAL_PLAN_JOIN:
return "PhysiJoin";
case QUERY_NODE_PHYSICAL_PLAN_AGG:
return "PhysiAgg";
+ case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
+ return "PhysiExchange";
+ case QUERY_NODE_PHYSICAL_PLAN_SORT:
+ return "PhysiSort";
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ return "PhysiDispatch";
+ case QUERY_NODE_PHYSICAL_PLAN_INSERT:
+ return "PhysiInsert";
case QUERY_NODE_PHYSICAL_SUBPLAN:
return "PhysiSubplan";
case QUERY_NODE_PHYSICAL_PLAN:
@@ -234,7 +264,7 @@ static const char* jkPhysiPlanChildren = "Children";
static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
const SPhysiNode* pNode = (const SPhysiNode*)pObj;
- int32_t code = tjsonAddObject(pJson, jkPhysiPlanOutputDataBlockDesc, nodeToJson, &pNode->outputDataBlockDesc);
+ int32_t code = tjsonAddObject(pJson, jkPhysiPlanOutputDataBlockDesc, nodeToJson, pNode->pOutputDataBlockDesc);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkPhysiPlanConditions, nodeToJson, pNode->pConditions);
}
@@ -248,7 +278,7 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
SPhysiNode* pNode = (SPhysiNode*)pObj;
- int32_t code = tjsonToObject(pJson, jkPhysiPlanOutputDataBlockDesc, jsonToNode, &pNode->outputDataBlockDesc);
+ int32_t code = jsonToNodeObject(pJson, jkPhysiPlanOutputDataBlockDesc, (SNode**)&pNode->pOutputDataBlockDesc);
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkPhysiPlanConditions, &pNode->pConditions);
}
@@ -466,6 +496,26 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) {
return code;
}
+static const char* jkDataSinkInputDataBlockDesc = "InputDataBlockDesc";
+
+static int32_t physicDataSinkNodeToJson(const void* pObj, SJson* pJson) {
+ const SDataSinkNode* pNode = (const SDataSinkNode*)pObj;
+ return tjsonAddObject(pJson, jkDataSinkInputDataBlockDesc, nodeToJson, pNode->pInputDataBlockDesc);
+}
+
+static int32_t jsonToPhysicDataSinkNode(const SJson* pJson, void* pObj) {
+ SDataSinkNode* pNode = (SDataSinkNode*)pObj;
+ return jsonToNodeObject(pJson, jkDataSinkInputDataBlockDesc, (SNode**)&pNode->pInputDataBlockDesc);
+}
+
+static int32_t physiDispatchNodeToJson(const void* pObj, SJson* pJson) {
+ return physicDataSinkNodeToJson(pObj, pJson);
+}
+
+static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) {
+ return jsonToPhysicDataSinkNode(pJson, pObj);
+}
+
static const char* jkSubplanIdQueryId = "QueryId";
static const char* jkSubplanIdTemplateId = "TemplateId";
static const char* jkSubplanIdSubplanId = "SubplanId";
@@ -833,41 +883,43 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddBoolToObject(pJson, jkValueDuration, pNode->isDuration);
}
- switch (pNode->node.resType.type) {
- case TSDB_DATA_TYPE_NULL:
- break;
- case TSDB_DATA_TYPE_BOOL:
- code = tjsonAddIntegerToObject(pJson, jkValueDuration, pNode->datum.b);
- break;
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_SMALLINT:
- case TSDB_DATA_TYPE_INT:
- case TSDB_DATA_TYPE_BIGINT:
- case TSDB_DATA_TYPE_TIMESTAMP:
- code = tjsonAddIntegerToObject(pJson, jkValueDuration, pNode->datum.i);
- break;
- case TSDB_DATA_TYPE_UTINYINT:
- case TSDB_DATA_TYPE_USMALLINT:
- case TSDB_DATA_TYPE_UINT:
- case TSDB_DATA_TYPE_UBIGINT:
- code = tjsonAddIntegerToObject(pJson, jkValueDuration, pNode->datum.u);
- break;
- case TSDB_DATA_TYPE_FLOAT:
- case TSDB_DATA_TYPE_DOUBLE:
- code = tjsonAddDoubleToObject(pJson, jkValueDuration, pNode->datum.d);
- break;
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- case TSDB_DATA_TYPE_VARCHAR:
- case TSDB_DATA_TYPE_VARBINARY:
- code = tjsonAddStringToObject(pJson, jkValueLiteral, pNode->datum.p);
- break;
- case TSDB_DATA_TYPE_JSON:
- case TSDB_DATA_TYPE_DECIMAL:
- case TSDB_DATA_TYPE_BLOB:
- // todo
- default:
- break;
+ if (TSDB_CODE_SUCCESS == code) {
+ switch (pNode->node.resType.type) {
+ case TSDB_DATA_TYPE_NULL:
+ break;
+ case TSDB_DATA_TYPE_BOOL:
+ code = tjsonAddIntegerToObject(pJson, jkValueDatum, pNode->datum.b);
+ break;
+ case TSDB_DATA_TYPE_TINYINT:
+ case TSDB_DATA_TYPE_SMALLINT:
+ case TSDB_DATA_TYPE_INT:
+ case TSDB_DATA_TYPE_BIGINT:
+ case TSDB_DATA_TYPE_TIMESTAMP:
+ code = tjsonAddIntegerToObject(pJson, jkValueDatum, pNode->datum.i);
+ break;
+ case TSDB_DATA_TYPE_UTINYINT:
+ case TSDB_DATA_TYPE_USMALLINT:
+ case TSDB_DATA_TYPE_UINT:
+ case TSDB_DATA_TYPE_UBIGINT:
+ code = tjsonAddIntegerToObject(pJson, jkValueDatum, pNode->datum.u);
+ break;
+ case TSDB_DATA_TYPE_FLOAT:
+ case TSDB_DATA_TYPE_DOUBLE:
+ code = tjsonAddDoubleToObject(pJson, jkValueDatum, pNode->datum.d);
+ break;
+ case TSDB_DATA_TYPE_BINARY:
+ case TSDB_DATA_TYPE_NCHAR:
+ case TSDB_DATA_TYPE_VARCHAR:
+ case TSDB_DATA_TYPE_VARBINARY:
+ code = tjsonAddStringToObject(pJson, jkValueDatum, pNode->datum.p);
+ break;
+ case TSDB_DATA_TYPE_JSON:
+ case TSDB_DATA_TYPE_DECIMAL:
+ case TSDB_DATA_TYPE_BLOB:
+ // todo
+ default:
+ break;
+ }
}
return code;
@@ -883,41 +935,43 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBoolValue(pJson, jkValueDuration, &pNode->isDuration);
}
- switch (pNode->node.resType.type) {
- case TSDB_DATA_TYPE_NULL:
- break;
- case TSDB_DATA_TYPE_BOOL:
- code = tjsonGetBoolValue(pJson, jkValueDuration, &pNode->datum.b);
- break;
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_SMALLINT:
- case TSDB_DATA_TYPE_INT:
- case TSDB_DATA_TYPE_BIGINT:
- case TSDB_DATA_TYPE_TIMESTAMP:
- code = tjsonGetBigIntValue(pJson, jkValueDuration, &pNode->datum.i);
- break;
- case TSDB_DATA_TYPE_UTINYINT:
- case TSDB_DATA_TYPE_USMALLINT:
- case TSDB_DATA_TYPE_UINT:
- case TSDB_DATA_TYPE_UBIGINT:
- code = tjsonGetUBigIntValue(pJson, jkValueDuration, &pNode->datum.u);
- break;
- case TSDB_DATA_TYPE_FLOAT:
- case TSDB_DATA_TYPE_DOUBLE:
- code = tjsonGetDoubleValue(pJson, jkValueDuration, &pNode->datum.d);
- break;
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- case TSDB_DATA_TYPE_VARCHAR:
- case TSDB_DATA_TYPE_VARBINARY:
- code = tjsonDupStringValue(pJson, jkValueLiteral, &pNode->datum.p);
- break;
- case TSDB_DATA_TYPE_JSON:
- case TSDB_DATA_TYPE_DECIMAL:
- case TSDB_DATA_TYPE_BLOB:
- // todo
- default:
- break;
+ if (TSDB_CODE_SUCCESS == code) {
+ switch (pNode->node.resType.type) {
+ case TSDB_DATA_TYPE_NULL:
+ break;
+ case TSDB_DATA_TYPE_BOOL:
+ code = tjsonGetBoolValue(pJson, jkValueDatum, &pNode->datum.b);
+ break;
+ case TSDB_DATA_TYPE_TINYINT:
+ case TSDB_DATA_TYPE_SMALLINT:
+ case TSDB_DATA_TYPE_INT:
+ case TSDB_DATA_TYPE_BIGINT:
+ case TSDB_DATA_TYPE_TIMESTAMP:
+ code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
+ break;
+ case TSDB_DATA_TYPE_UTINYINT:
+ case TSDB_DATA_TYPE_USMALLINT:
+ case TSDB_DATA_TYPE_UINT:
+ case TSDB_DATA_TYPE_UBIGINT:
+ code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
+ break;
+ case TSDB_DATA_TYPE_FLOAT:
+ case TSDB_DATA_TYPE_DOUBLE:
+ code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
+ break;
+ case TSDB_DATA_TYPE_BINARY:
+ case TSDB_DATA_TYPE_NCHAR:
+ case TSDB_DATA_TYPE_VARCHAR:
+ case TSDB_DATA_TYPE_VARBINARY:
+ code = tjsonDupStringValue(pJson, jkValueDatum, &pNode->datum.p);
+ break;
+ case TSDB_DATA_TYPE_JSON:
+ case TSDB_DATA_TYPE_DECIMAL:
+ case TSDB_DATA_TYPE_BLOB:
+ // todo
+ default:
+ break;
+ }
}
return code;
@@ -1249,23 +1303,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case QUERY_NODE_STATE_WINDOW:
case QUERY_NODE_SESSION_WINDOW:
case QUERY_NODE_INTERVAL_WINDOW:
+ break;
case QUERY_NODE_NODE_LIST:
return nodeListNodeToJson(pObj, pJson);
case QUERY_NODE_FILL:
+ case QUERY_NODE_RAW_EXPR:
break;
case QUERY_NODE_TARGET:
return targetNodeToJson(pObj, pJson);
- case QUERY_NODE_RAW_EXPR:
- break;
case QUERY_NODE_DATABLOCK_DESC:
return dataBlockDescNodeToJson(pObj, pJson);
case QUERY_NODE_SLOT_DESC:
return slotDescNodeToJson(pObj, pJson);
+ case QUERY_NODE_COLUMN_DEF:
case QUERY_NODE_SET_OPERATOR:
break;
case QUERY_NODE_SELECT_STMT:
return selectStmtTojson(pObj, pJson);
- case QUERY_NODE_SHOW_STMT:
+ case QUERY_NODE_VNODE_MODIF_STMT:
+ case QUERY_NODE_CREATE_DATABASE_STMT:
+ case QUERY_NODE_CREATE_TABLE_STMT:
+ case QUERY_NODE_USE_DATABASE_STMT:
+ case QUERY_NODE_SHOW_DATABASES_STMT:
+ case QUERY_NODE_SHOW_TABLES_STMT:
break;
case QUERY_NODE_LOGIC_PLAN_SCAN:
return logicScanNodeToJson(pObj, pJson);
@@ -1275,16 +1335,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return logicAggNodeToJson(pObj, pJson);
case QUERY_NODE_LOGIC_PLAN_PROJECT:
return logicProjectNodeToJson(pObj, pJson);
+ case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
+ case QUERY_NODE_LOGIC_SUBPLAN:
+ case QUERY_NODE_LOGIC_PLAN:
+ break;
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
return physiTagScanNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
return physiTableScanNodeToJson(pObj, pJson);
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
+ break;
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
return physiProjectNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_JOIN:
return physiJoinNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_AGG:
return physiAggNodeToJson(pObj, pJson);
+ case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
+ case QUERY_NODE_PHYSICAL_PLAN_SORT:
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ return physiDispatchNodeToJson(pObj, pJson);
+ case QUERY_NODE_PHYSICAL_PLAN_INSERT:
+ break;
case QUERY_NODE_PHYSICAL_SUBPLAN:
return subplanToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN:
@@ -1292,7 +1365,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
default:
break;
}
- printf("================================ specificNodeToJson unknown node = %s\n", nodeName(nodeType(pObj)));
+ printf("================================ specificNodeToJson unknown node = %s\n", nodesNodeName(nodeType(pObj)));
return TSDB_CODE_SUCCESS;
}
@@ -1334,8 +1407,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
// break;
// case QUERY_NODE_SELECT_STMT:
// return jsonToSelectStmt(pJson, pObj);
- // case QUERY_NODE_SHOW_STMT:
- // break;
// case QUERY_NODE_LOGIC_PLAN_SCAN:
// return jsonToLogicScanNode(pJson, pObj);
// case QUERY_NODE_LOGIC_PLAN_JOIN:
@@ -1354,6 +1425,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return jsonToPhysiJoinNode(pJson, pObj);
case QUERY_NODE_PHYSICAL_PLAN_AGG:
return jsonToPhysiAggNode(pJson, pObj);
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ return jsonToPhysiDispatchNode(pJson, pObj);
case QUERY_NODE_PHYSICAL_SUBPLAN:
return jsonToSubplan(pJson, pObj);
case QUERY_NODE_PHYSICAL_PLAN:
@@ -1361,6 +1434,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
default:
break;
}
+ printf("================================ jsonToSpecificNode unknown node = %s\n", nodesNodeName(nodeType(pObj)));
return TSDB_CODE_SUCCESS;
}
@@ -1372,10 +1446,10 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
int32_t code = tjsonAddIntegerToObject(pJson, jkNodeType, pNode->type);
if (TSDB_CODE_SUCCESS == code) {
- code = tjsonAddStringToObject(pJson, jkNodeName, nodeName(pNode->type));
+ code = tjsonAddStringToObject(pJson, jkNodeName, nodesNodeName(pNode->type));
}
if (TSDB_CODE_SUCCESS == code) {
- code = tjsonAddObject(pJson, nodeName(pNode->type), specificNodeToJson, pNode);
+ code = tjsonAddObject(pJson, nodesNodeName(pNode->type), specificNodeToJson, pNode);
}
return code;
@@ -1388,7 +1462,10 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj) {
int32_t code = tjsonGetIntValue(pJson, jkNodeType, &val);
pNode->type = val;
if (TSDB_CODE_SUCCESS == code) {
- code = tjsonToObject(pJson, nodeName(pNode->type), jsonToSpecificNode, pNode);
+ code = tjsonToObject(pJson, nodesNodeName(pNode->type), jsonToSpecificNode, pNode);
+ if (TSDB_CODE_SUCCESS != code) {
+ printf("%s toNode error\n", nodesNodeName(pNode->type));
+ }
}
return code;
@@ -1411,7 +1488,7 @@ static int32_t makeNodeByJson(const SJson* pJson, SNode** pNode) {
static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** pNode) {
SJson* pJsonNode = tjsonGetObjectItem(pJson, pName);
if (NULL == pJsonNode) {
- return TSDB_CODE_FAILED;
+ return TSDB_CODE_SUCCESS;
}
return makeNodeByJson(pJsonNode, pNode);
}
diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c
index 7fffaa268c..d32f43d902 100644
--- a/source/libs/nodes/src/nodesUtilFuncs.c
+++ b/source/libs/nodes/src/nodesUtilFuncs.c
@@ -13,6 +13,7 @@
* along with this program. If not, see .
*/
+#include "cmdnodes.h"
#include "querynodes.h"
#include "plannodes.h"
#include "taos.h"
@@ -65,12 +66,29 @@ SNodeptr nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SFillNode));
case QUERY_NODE_RAW_EXPR:
return makeNode(type, sizeof(SRawExprNode));
+ case QUERY_NODE_TARGET:
+ return makeNode(type, sizeof(STargetNode));
+ case QUERY_NODE_DATABLOCK_DESC:
+ return makeNode(type, sizeof(SDataBlockDescNode));
+ case QUERY_NODE_SLOT_DESC:
+ return makeNode(type, sizeof(SSlotDescNode));
+ case QUERY_NODE_COLUMN_DEF:
+ return makeNode(type, sizeof(SColumnDefNode));
case QUERY_NODE_SET_OPERATOR:
return makeNode(type, sizeof(SSetOperator));
case QUERY_NODE_SELECT_STMT:
return makeNode(type, sizeof(SSelectStmt));
- // case QUERY_NODE_SHOW_STMT:
- // return makeNode(type, sizeof(SShowStmt));
+ case QUERY_NODE_VNODE_MODIF_STMT:
+ return makeNode(type, sizeof(SVnodeModifOpStmt));
+ case QUERY_NODE_CREATE_DATABASE_STMT:
+ return makeNode(type, sizeof(SCreateDatabaseStmt));
+ case QUERY_NODE_CREATE_TABLE_STMT:
+ return makeNode(type, sizeof(SCreateTableStmt));
+ case QUERY_NODE_USE_DATABASE_STMT:
+ return makeNode(type, sizeof(SUseDatabaseStmt));
+ case QUERY_NODE_SHOW_DATABASES_STMT:
+ case QUERY_NODE_SHOW_TABLES_STMT:
+ return makeNode(type, sizeof(SNode));;
case QUERY_NODE_LOGIC_PLAN_SCAN:
return makeNode(type, sizeof(SScanLogicNode));
case QUERY_NODE_LOGIC_PLAN_JOIN:
@@ -79,26 +97,34 @@ SNodeptr nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SAggLogicNode));
case QUERY_NODE_LOGIC_PLAN_PROJECT:
return makeNode(type, sizeof(SProjectLogicNode));
+ case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
+ return makeNode(type, sizeof(SVnodeModifLogicNode));
case QUERY_NODE_LOGIC_SUBPLAN:
return makeNode(type, sizeof(SSubLogicPlan));
case QUERY_NODE_LOGIC_PLAN:
return makeNode(type, sizeof(SQueryLogicPlan));
- case QUERY_NODE_TARGET:
- return makeNode(type, sizeof(STargetNode));
- case QUERY_NODE_DATABLOCK_DESC:
- return makeNode(type, sizeof(SDataBlockDescNode));
- case QUERY_NODE_SLOT_DESC:
- return makeNode(type, sizeof(SSlotDescNode));
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
return makeNode(type, sizeof(STagScanPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
return makeNode(type, sizeof(STableScanPhysiNode));
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
+ return makeNode(type, sizeof(STableSeqScanPhysiNode));
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
+ return makeNode(type, sizeof(SNode));
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
return makeNode(type, sizeof(SProjectPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_JOIN:
return makeNode(type, sizeof(SJoinPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_AGG:
return makeNode(type, sizeof(SAggPhysiNode));
+ case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
+ return makeNode(type, sizeof(SExchangePhysiNode));
+ case QUERY_NODE_PHYSICAL_PLAN_SORT:
+ return makeNode(type, sizeof(SNode));
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ return makeNode(type, sizeof(SDataDispatcherNode));
+ case QUERY_NODE_PHYSICAL_PLAN_INSERT:
+ return makeNode(type, sizeof(SDataInserterNode));
case QUERY_NODE_PHYSICAL_SUBPLAN:
return makeNode(type, sizeof(SSubplan));
case QUERY_NODE_PHYSICAL_PLAN:
@@ -106,6 +132,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
default:
break;
}
+ printf("================================ nodesMakeNode unknown node = %s\n", nodesNodeName(type));
return NULL;
}
@@ -176,6 +203,17 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
return TSDB_CODE_SUCCESS;
}
+int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
+ if (NULL == pNode) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ int32_t code = nodesListAppend(pList, pNode);
+ if (TSDB_CODE_SUCCESS != code) {
+ nodesDestroyNode(pNode);
+ }
+ return code;
+}
+
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) {
if (NULL == pTarget || NULL == pSrc) {
return TSDB_CODE_SUCCESS;
diff --git a/source/libs/parser/inc/astCreateFuncs.h b/source/libs/parser/inc/astCreateFuncs.h
index 5cddd82e2c..6c03543527 100644
--- a/source/libs/parser/inc/astCreateFuncs.h
+++ b/source/libs/parser/inc/astCreateFuncs.h
@@ -116,8 +116,14 @@ typedef enum ETableOptionType {
STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt);
STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal);
SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment);
+SDataType createDataType(uint8_t type);
+SDataType createVarLenDataType(uint8_t type, const SToken* pLen);
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, const STokenPair* pFullTableName, SNodeList* pCols, STableOptions* pOptions);
+SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName);
+
+SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/libs/parser/inc/new_sql.y b/source/libs/parser/inc/new_sql.y
index 0ecacc432a..3c4e852521 100644
--- a/source/libs/parser/inc/new_sql.y
+++ b/source/libs/parser/inc/new_sql.y
@@ -92,22 +92,25 @@ db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C).
db_options(A) ::= db_options(B) SINGLESTABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); }
db_options(A) ::= db_options(B) STREAMMODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); }
+/************************************************ create database *****************************************************/
+cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
+
/************************************************ create table *******************************************************/
cmd ::= CREATE TABLE exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP table_options(D). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, &B, C, D);}
%type full_table_name { STokenPair }
%destructor full_table_name { }
-full_table_name(A) ::= NK_ID(B). { A = { .first = B, .second = nil_token}; }
-full_table_name(A) ::= NK_ID(B) NK_DOT NK_ID(C). { A = { .first = B, .second = C}; }
+full_table_name(A) ::= NK_ID(B). { STokenPair t = { .first = nil_token, .second = B }; A = t; }
+full_table_name(A) ::= NK_ID(B) NK_DOT NK_ID(C). { STokenPair t = { .first = B, .second = C }; A = t; }
%type column_def_list { SNodeList* }
%destructor column_def_list { nodesDestroyList($$); }
column_def_list(A) ::= column_def(B). { A = createNodeList(pCxt, B); }
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
-column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, B, C, NULL); }
-column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, B, C, &D); }
+column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); }
+column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
%type type_name { SDataType }
%destructor type_name { }
@@ -115,6 +118,7 @@ type_name(A) ::= BOOL.
type_name(A) ::= TINYINT. { A = createDataType(TSDB_DATA_TYPE_TINYINT); }
type_name(A) ::= SMALLINT. { A = createDataType(TSDB_DATA_TYPE_SMALLINT); }
type_name(A) ::= INT. { A = createDataType(TSDB_DATA_TYPE_INT); }
+type_name(A) ::= INTEGER. { A = createDataType(TSDB_DATA_TYPE_INT); }
type_name(A) ::= BIGINT. { A = createDataType(TSDB_DATA_TYPE_BIGINT); }
type_name(A) ::= FLOAT. { A = createDataType(TSDB_DATA_TYPE_FLOAT); }
type_name(A) ::= DOUBLE. { A = createDataType(TSDB_DATA_TYPE_DOUBLE); }
@@ -134,14 +138,16 @@ type_name(A) ::= DECIMAL.
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
-%type table_options { SDatabaseOptions* }
+%type table_options { STableOptions* }
%destructor table_options { tfree($$); }
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
table_options(A) ::= table_options(B) COMMENT NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
-//cmd ::= SHOW DATABASES. { PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); }
+/************************************************ show ***************************************************************/
+cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
+cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT); }
/************************************************ select *************************************************************/
cmd ::= query_expression(A). { PARSER_TRACE; pCxt->pRootNode = A; }
diff --git a/source/libs/parser/src/astCreateFuncs.c b/source/libs/parser/src/astCreateFuncs.c
index a9e10da143..8b254ce7af 100644
--- a/source/libs/parser/src/astCreateFuncs.c
+++ b/source/libs/parser/src/astCreateFuncs.c
@@ -44,7 +44,7 @@ static SDatabaseOptions* setDbBlocks(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_TOTAL_BLOCKS || val > TSDB_MAX_TOTAL_BLOCKS) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option totalBlocks: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS);
+ "invalid db option totalBlocks: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS);
pCxt->valid = false;
return pOptions;
}
@@ -56,7 +56,7 @@ static SDatabaseOptions* setDbCache(SAstCreateContext* pCxt, SDatabaseOptions* p
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_CACHE_BLOCK_SIZE || val > TSDB_MAX_CACHE_BLOCK_SIZE) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option cacheBlockSize: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE);
+ "invalid db option cacheBlockSize: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE);
pCxt->valid = false;
return pOptions;
}
@@ -68,7 +68,7 @@ static SDatabaseOptions* setDbCacheLast(SAstCreateContext* pCxt, SDatabaseOption
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_CACHE_LAST_ROW || val > TSDB_MAX_DB_CACHE_LAST_ROW) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option cacheLast: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_DB_CACHE_LAST_ROW, TSDB_MAX_DB_CACHE_LAST_ROW);
+ "invalid db option cacheLast: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_CACHE_LAST_ROW, TSDB_MAX_DB_CACHE_LAST_ROW);
pCxt->valid = false;
return pOptions;
}
@@ -80,7 +80,7 @@ static SDatabaseOptions* setDbComp(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_COMP_LEVEL || val > TSDB_MAX_COMP_LEVEL) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option compression: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
+ "invalid db option compression: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
pCxt->valid = false;
return pOptions;
}
@@ -92,7 +92,7 @@ static SDatabaseOptions* setDbDays(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DAYS_PER_FILE || val > TSDB_MAX_DAYS_PER_FILE) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option daysPerFile: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
+ "invalid db option daysPerFile: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
pCxt->valid = false;
return pOptions;
}
@@ -104,7 +104,7 @@ static SDatabaseOptions* setDbFsync(SAstCreateContext* pCxt, SDatabaseOptions* p
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_FSYNC_PERIOD || val > TSDB_MAX_FSYNC_PERIOD) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option fsyncPeriod: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
+ "invalid db option fsyncPeriod: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
pCxt->valid = false;
return pOptions;
}
@@ -116,7 +116,7 @@ static SDatabaseOptions* setDbMaxRows(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_MAX_ROW_FBLOCK || val > TSDB_MAX_MAX_ROW_FBLOCK) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option maxRowsPerBlock: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_MAX_ROW_FBLOCK, TSDB_MAX_MAX_ROW_FBLOCK);
+ "invalid db option maxRowsPerBlock: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_MAX_ROW_FBLOCK, TSDB_MAX_MAX_ROW_FBLOCK);
pCxt->valid = false;
return pOptions;
}
@@ -128,7 +128,7 @@ static SDatabaseOptions* setDbMinRows(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_MIN_ROW_FBLOCK || val > TSDB_MAX_MIN_ROW_FBLOCK) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option minRowsPerBlock: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK);
+ "invalid db option minRowsPerBlock: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK);
pCxt->valid = false;
return pOptions;
}
@@ -140,7 +140,7 @@ static SDatabaseOptions* setDbKeep(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_KEEP || val > TSDB_MAX_KEEP) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option keep: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP);
+ "invalid db option keep: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP);
pCxt->valid = false;
return pOptions;
}
@@ -168,7 +168,7 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_QUORUM_OPTION || val > TSDB_MAX_DB_QUORUM_OPTION) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option quorum: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION);
+ "invalid db option quorum: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION);
pCxt->valid = false;
return pOptions;
}
@@ -180,7 +180,7 @@ static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_REPLICA_OPTION || val > TSDB_MAX_DB_REPLICA_OPTION) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option replications: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION);
+ "invalid db option replications: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION);
pCxt->valid = false;
return pOptions;
}
@@ -192,7 +192,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_TTL_OPTION) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option ttl: %" PRId64 ", should be greater than or equal to %d", val, TSDB_MIN_DB_TTL_OPTION);
+ "invalid db option ttl: %"PRId64", should be greater than or equal to %d", val, TSDB_MIN_DB_TTL_OPTION);
pCxt->valid = false;
return pOptions;
}
@@ -203,7 +203,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
static SDatabaseOptions* setDbWal(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) {
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_WAL_LEVEL || val > TSDB_MAX_WAL_LEVEL) {
- snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option walLevel: %" PRId64 ", only 1-2 allowed", val);
+ snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option walLevel: %"PRId64", only 1-2 allowed", val);
pCxt->valid = false;
return pOptions;
}
@@ -215,7 +215,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_VNODES_PER_DB || val > TSDB_MAX_VNODES_PER_DB) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid db option vgroups: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB);
+ "invalid db option vgroups: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB);
pCxt->valid = false;
return pOptions;
}
@@ -226,7 +226,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
static SDatabaseOptions* setDbSingleStable(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) {
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_SINGLE_STABLE_OPTION || val > TSDB_MAX_DB_SINGLE_STABLE_OPTION) {
- snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option singleStable: %" PRId64 ", only 0-1 allowed", val);
+ snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option singleStable: %"PRId64", only 0-1 allowed", val);
pCxt->valid = false;
return pOptions;
}
@@ -237,7 +237,7 @@ static SDatabaseOptions* setDbSingleStable(SAstCreateContext* pCxt, SDatabaseOpt
static SDatabaseOptions* setDbStreamMode(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) {
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_STREAM_MODE_OPTION || val > TSDB_MAX_DB_STREAM_MODE_OPTION) {
- snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option streamMode: %" PRId64 ", only 0-1 allowed", val);
+ snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option streamMode: %"PRId64", only 0-1 allowed", val);
pCxt->valid = false;
return pOptions;
}
@@ -269,7 +269,7 @@ static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOpti
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_KEEP || val > TSDB_MAX_KEEP) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid table option keep: %" PRId64 " valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP);
+ "invalid table option keep: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP);
pCxt->valid = false;
return pOptions;
}
@@ -281,7 +281,7 @@ static STableOptions* setTableTtl(SAstCreateContext* pCxt, STableOptions* pOptio
int64_t val = strtol(pVal->z, NULL, 10);
if (val < TSDB_MIN_DB_TTL_OPTION) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
- "invalid table option ttl: %" PRId64 ", should be greater than or equal to %d", val, TSDB_MIN_DB_TTL_OPTION);
+ "invalid table option ttl: %"PRId64", should be greater than or equal to %d", val, TSDB_MIN_DB_TTL_OPTION);
pCxt->valid = false;
return pOptions;
}
@@ -714,11 +714,21 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDat
strncpy(pCol->colName, pColName->z, pColName->n);
pCol->dataType = dataType;
if (NULL != pComment) {
- strncpy(pCol->colName, pColName->z, pColName->n);
+ strncpy(pCol->comments, pComment->z, pComment->n);
}
return (SNode*)pCol;
}
+SDataType createDataType(uint8_t type) {
+ SDataType dt = { .type = type, .precision = 0, .scale = 0, .bytes = tDataTypes[type].bytes };
+ return dt;
+}
+
+SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
+ SDataType dt = { .type = type, .precision = 0, .scale = 0, .bytes = tDataTypes[type].bytes };
+ return dt;
+}
+
SNode* createCreateTableStmt(SAstCreateContext* pCxt,
bool ignoreExists, const STokenPair* pFullTableName, SNodeList* pCols, STableOptions* pOptions) {
SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT);
@@ -732,3 +742,16 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
pStmt->options = *pOptions;
return (SNode*)pStmt;
}
+
+SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
+ SUseDatabaseStmt* pStmt = (SUseDatabaseStmt*)nodesMakeNode(QUERY_NODE_USE_DATABASE_STMT);
+ CHECK_OUT_OF_MEM(pStmt);
+ strncpy(pStmt->dbName, pDbName->z, pDbName->n);
+ return (SNode*)pStmt;
+}
+
+SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
+ SNode* pStmt = nodesMakeNode(type);;
+ CHECK_OUT_OF_MEM(pStmt);
+ return pStmt;
+}
diff --git a/source/libs/parser/src/astParse.c b/source/libs/parser/src/astParse.c
index 7519b36861..a64cb55146 100644
--- a/source/libs/parser/src/astParse.c
+++ b/source/libs/parser/src/astParse.c
@@ -26,18 +26,20 @@ extern void NewParse(void*, int, SToken, void*);
extern void NewParseFree(void*, FFree);
extern void NewParseTrace(FILE*, char*);
-static bool isCmd(const SNode* pRootNode) {
- if (NULL == pRootNode) {
- return true;
+static void setQuery(SAstCreateContext* pCxt, SQuery* pQuery) {
+ pQuery->pRoot = pCxt->pRootNode;
+ ENodeType type = nodeType(pCxt->pRootNode);
+ if (QUERY_NODE_SELECT_STMT == type) {
+ pQuery->haveResultSet = true;
+ pQuery->directRpc = false;
+ } else if (QUERY_NODE_CREATE_TABLE_STMT == type) {
+ pQuery->haveResultSet = false;
+ pQuery->directRpc = false;
+ } else {
+ pQuery->haveResultSet = false;
+ pQuery->directRpc = true;
}
- switch (nodeType(pRootNode)) {
- case QUERY_NODE_SELECT_STMT:
- case QUERY_NODE_CREATE_TABLE_STMT:
- return false;
- default:
- break;
- }
- return true;
+ pQuery->msgType = (QUERY_NODE_CREATE_TABLE_STMT == type ? TDMT_VND_CREATE_TABLE : TDMT_VND_QUERY);
}
int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
@@ -60,6 +62,10 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
case TK_COMMENT: {
break;
}
+ case TK_SEMI: {
+ NewParse(pParser, 0, t0, &cxt);
+ goto abort_parse;
+ }
case TK_QUESTION:
case TK_ILLEGAL: {
snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unrecognized token: \"%s\"", t0.z);
@@ -89,8 +95,7 @@ abort_parse:
if (NULL == *pQuery) {
return TSDB_CODE_OUT_OF_MEMORY;
}
- (*pQuery)->isCmd = isCmd(cxt.pRootNode);
- (*pQuery)->pRoot = cxt.pRootNode;
+ setQuery(&cxt, *pQuery);
}
return cxt.valid ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
}
diff --git a/source/libs/parser/src/astTranslate.c b/source/libs/parser/src/astTranslate.c
index 24a9468d2a..be5cf62a3c 100644
--- a/source/libs/parser/src/astTranslate.c
+++ b/source/libs/parser/src/astTranslate.c
@@ -561,6 +561,29 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
return TSDB_CODE_SUCCESS;
}
+static int32_t setTableVgroupList(STranslateContext *pCxt, SName* name, SVgroupsInfo **pVgList) {
+ SArray* vgroupList = NULL;
+ int32_t code = catalogGetTableDistVgInfo(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &(pCxt->pParseCxt->mgmtEpSet), name, &vgroupList);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+
+ size_t vgroupNum = taosArrayGetSize(vgroupList);
+
+ SVgroupsInfo *vgList = calloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum);
+ vgList->numOfVgroups = vgroupNum;
+
+ for (int32_t i = 0; i < vgroupNum; ++i) {
+ SVgroupInfo *vg = taosArrayGet(vgroupList, i);
+ vgList->vgroups[i] = *vg;
+ }
+
+ *pVgList = vgList;
+ taosArrayDestroy(vgroupList);
+
+ return TSDB_CODE_SUCCESS;
+}
+
static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
int32_t code = TSDB_CODE_SUCCESS;
switch (nodeType(pTable)) {
@@ -572,6 +595,10 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if (TSDB_CODE_SUCCESS != code) {
return generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName);
}
+ code = setTableVgroupList(pCxt, &name, &(pRealTable->pVgroupList));
+ if (TSDB_CODE_SUCCESS != code) {
+ return code;
+ }
code = addNamespace(pCxt, pRealTable);
break;
}
@@ -829,7 +856,73 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
return TSDB_CODE_SUCCESS;
}
-static int32_t translateCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
+static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) {
+ SName name = {0};
+ tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
+
+ SUseDbReq usedbReq = {0};
+ tNameExtractFullName(&name, usedbReq.db);
+
+ pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
+ if (NULL== pCxt->pCmdMsg) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
+ pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB;
+ pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
+ pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
+ if (NULL== pCxt->pCmdMsg->pMsg) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq);
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t translateShowDatabases(STranslateContext* pCxt) {
+ SShowReq showReq = { .type = TSDB_MGMT_TABLE_DB };
+
+ pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
+ if (NULL== pCxt->pCmdMsg) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
+ pCxt->pCmdMsg->msgType = TDMT_MND_SHOW;
+ pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq);
+ pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
+ if (NULL== pCxt->pCmdMsg->pMsg) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq);
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t translateShowTables(STranslateContext* pCxt) {
+ SName name = {0};
+ SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq));
+ tNameSetDbName(&name, pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, strlen(pCxt->pParseCxt->db));
+ char dbFname[TSDB_DB_FNAME_LEN] = {0};
+ tNameGetFullDbName(&name, dbFname);
+
+ SArray* array = NULL;
+ int32_t code = catalogGetDBVgInfo(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, dbFname, false, &array);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+ SVgroupInfo* info = taosArrayGet(array, 0);
+ pShowReq->head.vgId = htonl(info->vgId);
+
+ pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
+ if (NULL== pCxt->pCmdMsg) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ pCxt->pCmdMsg->epSet = info->epset;
+ pCxt->pCmdMsg->msgType = TDMT_VND_SHOW_TABLES;
+ pCxt->pCmdMsg->msgLen = sizeof(SVShowTablesReq);
+ pCxt->pCmdMsg->pMsg = pShowReq;
+ pCxt->pCmdMsg->pExtension = array;
+
return TSDB_CODE_SUCCESS;
}
@@ -842,8 +935,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case QUERY_NODE_CREATE_DATABASE_STMT:
code = translateCreateDatabase(pCxt, (SCreateDatabaseStmt*)pNode);
break;
- case QUERY_NODE_CREATE_TABLE_STMT:
- code = translateCreateTable(pCxt, (SCreateTableStmt*)pNode);
+ case QUERY_NODE_USE_DATABASE_STMT:
+ code = translateUseDatabase(pCxt, (SUseDatabaseStmt*)pNode);
+ break;
+ case QUERY_NODE_SHOW_DATABASES_STMT:
+ code = translateShowDatabases(pCxt);
+ break;
+ case QUERY_NODE_SHOW_TABLES_STMT:
+ code = translateShowTables(pCxt);
break;
default:
break;
@@ -862,7 +961,7 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
return code;
}
-int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
+static int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
if (QUERY_NODE_SELECT_STMT == nodeType(pQuery->pRoot)) {
SSelectStmt* pSelect = (SSelectStmt*)pQuery->pRoot;
pQuery->numOfResCols = LIST_LENGTH(pSelect->pProjectionList);
@@ -882,7 +981,7 @@ int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
return TSDB_CODE_SUCCESS;
}
-void destroyTranslateContext(STranslateContext* pCxt) {
+static void destroyTranslateContext(STranslateContext* pCxt) {
taosArrayDestroy(pCxt->pNsLevel);
if (NULL != pCxt->pCmdMsg) {
tfree(pCxt->pCmdMsg->pMsg);
@@ -890,6 +989,122 @@ void destroyTranslateContext(STranslateContext* pCxt) {
}
}
+typedef struct SVgroupTablesBatch {
+ SVCreateTbBatchReq req;
+ SVgroupInfo info;
+} SVgroupTablesBatch;
+
+static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema) {
+ pSchema->colId = colId;
+ pSchema->type = pCol->dataType.type;
+ pSchema->bytes = pCol->dataType.bytes;
+ strcpy(pSchema->name, pCol->colName);
+}
+
+static int32_t doBuildSingleTableBatchReq(SName* pTableName, SNodeList* pColumns, SVgroupInfo* pVgroupInfo, SVgroupTablesBatch* pBatch) {
+ SVCreateTbReq req = {0};
+ req.type = TD_NORMAL_TABLE;
+ req.name = strdup(tNameGetTableName(pTableName));
+
+ req.ntbCfg.nCols = LIST_LENGTH(pColumns);
+ int32_t num = req.ntbCfg.nCols;
+
+ req.ntbCfg.pSchema = calloc(num, sizeof(SSchema));
+ SNode* pCol;
+ int32_t index = 0;
+ FOREACH(pCol, pColumns) {
+ toSchema((SColumnDefNode*)pCol, index + 1, req.ntbCfg.pSchema + index);
+ ++index;
+ }
+
+ pBatch->info = *pVgroupInfo;
+ pBatch->req.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
+ if (pBatch->req.pArray == NULL) {
+ return TSDB_CODE_QRY_OUT_OF_MEMORY;
+ }
+
+ taosArrayPush(pBatch->req.pArray, &req);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t serializeVgroupTablesBatchImpl(SVgroupTablesBatch* pTbBatch, SArray* pBufArray) {
+ int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req));
+ void* buf = malloc(tlen);
+ if (buf == NULL) {
+ // TODO: handle error
+ }
+
+ ((SMsgHead*)buf)->vgId = htonl(pTbBatch->info.vgId);
+ ((SMsgHead*)buf)->contLen = htonl(tlen);
+
+ void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
+ tSerializeSVCreateTbBatchReq(&pBuf, &(pTbBatch->req));
+
+ SVgDataBlocks* pVgData = calloc(1, sizeof(SVgDataBlocks));
+ pVgData->vg = pTbBatch->info;
+ pVgData->pData = buf;
+ pVgData->size = tlen;
+ pVgData->numOfTables = (int32_t) taosArrayGetSize(pTbBatch->req.pArray);
+
+ taosArrayPush(pBufArray, &pVgData);
+}
+
+static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
+ size_t size = taosArrayGetSize(pTbBatch->req.pArray);
+ for(int32_t i = 0; i < size; ++i) {
+ SVCreateTbReq* pTableReq = taosArrayGet(pTbBatch->req.pArray, i);
+ tfree(pTableReq->name);
+
+ if (pTableReq->type == TSDB_NORMAL_TABLE) {
+ tfree(pTableReq->ntbCfg.pSchema);
+ } else if (pTableReq->type == TSDB_CHILD_TABLE) {
+ tfree(pTableReq->ctbCfg.pTag);
+ } else {
+ assert(0);
+ }
+ }
+
+ taosArrayDestroy(pTbBatch->req.pArray);
+}
+
+static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
+ if (QUERY_NODE_CREATE_TABLE_STMT == nodeType(pQuery->pRoot)) {
+ SCreateTableStmt* pStmt = (SCreateTableStmt*)pQuery->pRoot;
+
+ SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId };
+ if ('\0' == pStmt->dbName[0]) {
+ strcpy(tableName.dbname, pCxt->pParseCxt->db);
+ } else {
+ strcpy(tableName.dbname, pStmt->dbName);
+ }
+ strcpy(tableName.tname, pStmt->tableName);
+ SVgroupInfo info = {0};
+ catalogGetTableHashVgroup(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &tableName, &info);
+
+ SVgroupTablesBatch tbatch = {0};
+ int32_t code = doBuildSingleTableBatchReq(&tableName, pStmt->pCols, &info, &tbatch);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+
+ SArray* pBufArray = taosArrayInit(1, POINTER_BYTES);
+ if (pBufArray == NULL) {
+ return TSDB_CODE_QRY_OUT_OF_MEMORY;
+ }
+
+ serializeVgroupTablesBatchImpl(&tbatch, pBufArray);
+ destroyCreateTbReqBatch(&tbatch);
+
+ SVnodeModifOpStmt* pNewStmt = nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT);
+ pNewStmt->sqlNodeType = nodeType(pQuery->pRoot);
+ pNewStmt->pDataBlocks = pBufArray;
+ pQuery->sqlNodeType = nodeType(pQuery->pRoot);
+ nodesDestroyNode(pQuery->pRoot);
+ pQuery->pRoot = (SNode*)pNewStmt;
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) {
STranslateContext cxt = {
.pParseCxt = pParseCxt,
@@ -900,14 +1115,18 @@ int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) {
.currClause = 0
};
int32_t code = fmFuncMgtInit();
+ if (TSDB_CODE_SUCCESS == code) {
+ code = rewriteQuery(&cxt, pQuery);
+ }
if (TSDB_CODE_SUCCESS == code) {
code = translateQuery(&cxt, pQuery->pRoot);
}
if (TSDB_CODE_SUCCESS == code) {
- if (pQuery->isCmd) {
+ if (pQuery->directRpc) {
pQuery->pCmdMsg = cxt.pCmdMsg;
cxt.pCmdMsg = NULL;
- } else {
+ }
+ if (pQuery->haveResultSet) {
code = setReslutSchema(&cxt, pQuery);
}
}
diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c
index d8e805ab82..d953192478 100644
--- a/source/libs/parser/src/insertParser.c
+++ b/source/libs/parser/src/insertParser.c
@@ -159,12 +159,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
}
static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
- SName name = {0};
- createSName(&name, pTname, pCxt->pComCxt, &pCxt->msg);
-
- char tableName[TSDB_TABLE_FNAME_LEN] = {0};
- tNameExtractFullName(&name, tableName);
SParseContext* pBasicCtx = pCxt->pComCxt;
+ SName name = {0};
+ createSName(&name, pTname, pBasicCtx, &pCxt->msg);
CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta));
SVgroupInfo vg;
CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg));
@@ -939,6 +936,13 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
+ *pQuery = calloc(1, sizeof(SQuery));
+ if (NULL == *pQuery) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ (*pQuery)->directRpc = false;
+ (*pQuery)->haveResultSet = false;
+ (*pQuery)->msgType = TDMT_VND_SUBMIT;
(*pQuery)->pRoot = (SNode*)context.pOutput;
context.pOutput->payloadType = PAYLOAD_TYPE_KV;
diff --git a/source/libs/parser/src/new_sql.c b/source/libs/parser/src/new_sql.c
index fb9040c190..af3bd203a5 100644
--- a/source/libs/parser/src/new_sql.c
+++ b/source/libs/parser/src/new_sql.c
@@ -109,22 +109,25 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
-#define YYNOCODE 152
+#define YYNOCODE 180
#define YYACTIONTYPE unsigned short int
#define NewParseTOKENTYPE SToken
typedef union {
int yyinit;
NewParseTOKENTYPE yy0;
- SNodeList* yy8;
- EOrder yy50;
- EOperatorType yy60;
- SDatabaseOptions* yy87;
- SNode* yy104;
- SToken yy129;
- bool yy185;
- ENullOrder yy186;
- EJoinType yy228;
- EFillMode yy246;
+ EOperatorType yy20;
+ STableOptions* yy46;
+ EFillMode yy54;
+ STokenPair yy57;
+ SNodeList* yy64;
+ bool yy137;
+ SDatabaseOptions* yy199;
+ SToken yy209;
+ ENullOrder yy217;
+ EOrder yy218;
+ EJoinType yy252;
+ SNode* yy272;
+ SDataType yy304;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -139,17 +142,17 @@ typedef union {
#define NewParseCTX_PARAM
#define NewParseCTX_FETCH
#define NewParseCTX_STORE
-#define YYNSTATE 170
-#define YYNRULE 160
-#define YYNTOKEN 96
-#define YY_MAX_SHIFT 169
-#define YY_MIN_SHIFTREDUCE 286
-#define YY_MAX_SHIFTREDUCE 445
-#define YY_ERROR_ACTION 446
-#define YY_ACCEPT_ACTION 447
-#define YY_NO_ACTION 448
-#define YY_MIN_REDUCE 449
-#define YY_MAX_REDUCE 608
+#define YYNSTATE 212
+#define YYNRULE 197
+#define YYNTOKEN 119
+#define YY_MAX_SHIFT 211
+#define YY_MIN_SHIFTREDUCE 353
+#define YY_MAX_SHIFTREDUCE 549
+#define YY_ERROR_ACTION 550
+#define YY_ACCEPT_ACTION 551
+#define YY_NO_ACTION 552
+#define YY_MIN_REDUCE 553
+#define YY_MAX_REDUCE 749
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -216,216 +219,255 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (757)
+#define YY_ACTTAB_COUNT (871)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 486, 476, 73, 146, 501, 147, 587, 114, 89, 487,
- /* 10 */ 105, 490, 30, 28, 26, 25, 24, 478, 476, 97,
- /* 20 */ 586, 92, 23, 72, 585, 30, 28, 26, 25, 24,
- /* 30 */ 479, 476, 146, 501, 92, 65, 486, 476, 117, 146,
- /* 40 */ 501, 147, 9, 8, 41, 487, 556, 490, 526, 328,
- /* 50 */ 129, 22, 101, 523, 346, 347, 348, 349, 350, 351,
- /* 60 */ 352, 354, 355, 356, 22, 101, 449, 346, 347, 348,
- /* 70 */ 349, 350, 351, 352, 354, 355, 356, 486, 476, 169,
- /* 80 */ 146, 501, 147, 412, 395, 89, 487, 108, 490, 168,
- /* 90 */ 364, 167, 166, 165, 164, 163, 162, 161, 160, 159,
- /* 100 */ 140, 158, 157, 156, 155, 154, 153, 152, 387, 113,
- /* 110 */ 410, 411, 413, 414, 136, 486, 476, 319, 146, 501,
- /* 120 */ 147, 131, 10, 39, 487, 122, 490, 526, 131, 10,
- /* 130 */ 55, 91, 522, 123, 118, 116, 486, 476, 321, 132,
- /* 140 */ 501, 147, 141, 587, 40, 487, 20, 490, 526, 55,
- /* 150 */ 55, 540, 99, 522, 49, 353, 70, 54, 357, 486,
- /* 160 */ 476, 585, 132, 501, 147, 139, 71, 40, 487, 537,
- /* 170 */ 490, 526, 107, 553, 386, 99, 522, 49, 486, 476,
- /* 180 */ 143, 146, 501, 147, 6, 383, 85, 487, 134, 490,
- /* 190 */ 26, 25, 24, 502, 486, 476, 554, 146, 501, 147,
- /* 200 */ 75, 42, 40, 487, 409, 490, 526, 146, 501, 2,
- /* 210 */ 99, 522, 599, 121, 545, 322, 383, 540, 540, 124,
- /* 220 */ 343, 560, 486, 476, 144, 146, 501, 147, 447, 115,
- /* 230 */ 40, 487, 149, 490, 526, 536, 535, 557, 99, 522,
- /* 240 */ 599, 567, 486, 476, 322, 146, 501, 147, 138, 583,
- /* 250 */ 40, 487, 112, 490, 526, 29, 27, 57, 99, 522,
- /* 260 */ 599, 587, 56, 59, 11, 31, 62, 308, 358, 544,
- /* 270 */ 128, 29, 27, 388, 314, 54, 45, 310, 566, 585,
- /* 280 */ 11, 9, 8, 308, 43, 309, 311, 148, 314, 110,
- /* 290 */ 106, 1, 111, 310, 51, 533, 534, 61, 538, 29,
- /* 300 */ 27, 309, 311, 148, 314, 98, 106, 1, 11, 444,
- /* 310 */ 445, 308, 55, 136, 486, 476, 5, 146, 501, 147,
- /* 320 */ 547, 310, 83, 487, 31, 490, 125, 325, 64, 309,
- /* 330 */ 311, 148, 314, 109, 106, 1, 29, 27, 48, 483,
- /* 340 */ 4, 481, 587, 66, 308, 383, 318, 321, 308, 30,
- /* 350 */ 28, 26, 25, 24, 310, 44, 54, 541, 310, 32,
- /* 360 */ 585, 67, 309, 311, 148, 314, 309, 311, 148, 314,
- /* 370 */ 16, 106, 7, 486, 476, 102, 146, 501, 147, 508,
- /* 380 */ 584, 41, 487, 602, 490, 526, 145, 319, 142, 525,
- /* 390 */ 522, 74, 317, 55, 79, 486, 476, 151, 146, 501,
- /* 400 */ 147, 77, 80, 41, 487, 3, 490, 526, 31, 14,
- /* 410 */ 58, 133, 522, 128, 406, 136, 60, 35, 408, 45,
- /* 420 */ 29, 27, 135, 47, 63, 119, 36, 43, 441, 442,
- /* 430 */ 402, 401, 308, 120, 481, 29, 27, 68, 533, 127,
- /* 440 */ 37, 126, 310, 18, 587, 15, 33, 308, 380, 379,
- /* 450 */ 309, 311, 148, 314, 69, 106, 7, 310, 54, 34,
- /* 460 */ 29, 27, 585, 8, 480, 309, 311, 148, 314, 53,
- /* 470 */ 106, 1, 308, 344, 326, 486, 476, 17, 146, 501,
- /* 480 */ 147, 435, 310, 46, 487, 12, 490, 38, 430, 429,
- /* 490 */ 309, 311, 148, 314, 103, 106, 7, 486, 476, 19,
- /* 500 */ 146, 501, 147, 76, 21, 89, 487, 100, 490, 30,
- /* 510 */ 28, 26, 25, 24, 30, 28, 26, 25, 24, 434,
- /* 520 */ 433, 13, 137, 600, 30, 28, 26, 25, 24, 486,
- /* 530 */ 476, 104, 146, 501, 147, 312, 470, 46, 487, 287,
- /* 540 */ 490, 486, 476, 150, 146, 501, 147, 299, 306, 84,
- /* 550 */ 487, 305, 490, 486, 476, 304, 146, 501, 147, 78,
- /* 560 */ 448, 86, 487, 303, 490, 302, 301, 486, 476, 300,
- /* 570 */ 146, 501, 147, 298, 297, 81, 487, 601, 490, 296,
- /* 580 */ 486, 476, 295, 146, 501, 147, 294, 293, 87, 487,
- /* 590 */ 292, 490, 486, 476, 291, 146, 501, 147, 290, 448,
- /* 600 */ 82, 487, 448, 490, 486, 476, 448, 146, 501, 147,
- /* 610 */ 448, 448, 88, 487, 448, 490, 448, 30, 28, 26,
- /* 620 */ 25, 24, 448, 448, 486, 476, 448, 146, 501, 147,
- /* 630 */ 448, 448, 498, 487, 448, 490, 486, 476, 448, 146,
- /* 640 */ 501, 147, 448, 448, 497, 487, 448, 490, 486, 476,
- /* 650 */ 448, 146, 501, 147, 328, 448, 496, 487, 448, 490,
- /* 660 */ 486, 476, 448, 146, 501, 147, 448, 448, 95, 487,
- /* 670 */ 448, 490, 486, 476, 448, 146, 501, 147, 448, 448,
- /* 680 */ 94, 487, 448, 490, 448, 486, 476, 448, 146, 501,
- /* 690 */ 147, 448, 448, 96, 487, 448, 490, 486, 476, 448,
- /* 700 */ 146, 501, 147, 448, 448, 93, 487, 448, 490, 486,
- /* 710 */ 476, 448, 146, 501, 147, 448, 448, 90, 487, 448,
- /* 720 */ 490, 448, 448, 128, 448, 448, 448, 448, 128, 45,
- /* 730 */ 448, 448, 448, 448, 45, 448, 448, 43, 448, 448,
- /* 740 */ 448, 448, 43, 448, 448, 448, 130, 50, 533, 534,
- /* 750 */ 448, 538, 52, 533, 534, 448, 538,
+ /* 0 */ 619, 617, 105, 188, 117, 728, 578, 48, 23, 75,
+ /* 10 */ 76, 642, 30, 28, 26, 25, 24, 158, 126, 727,
+ /* 20 */ 681, 100, 129, 726, 681, 30, 28, 26, 25, 24,
+ /* 30 */ 553, 620, 617, 642, 100, 68, 627, 617, 678, 158,
+ /* 40 */ 159, 499, 677, 42, 628, 432, 631, 667, 26, 25,
+ /* 50 */ 24, 666, 663, 211, 681, 210, 209, 208, 207, 206,
+ /* 60 */ 205, 204, 203, 202, 697, 201, 200, 199, 198, 197,
+ /* 70 */ 196, 195, 676, 423, 22, 109, 141, 450, 451, 452,
+ /* 80 */ 453, 454, 455, 456, 458, 459, 460, 22, 109, 134,
+ /* 90 */ 450, 451, 452, 453, 454, 455, 456, 458, 459, 460,
+ /* 100 */ 10, 10, 143, 143, 382, 186, 185, 184, 386, 183,
+ /* 110 */ 388, 389, 182, 391, 179, 118, 397, 176, 399, 400,
+ /* 120 */ 173, 170, 642, 575, 148, 627, 617, 84, 158, 159,
+ /* 130 */ 9, 8, 40, 628, 58, 631, 667, 6, 487, 80,
+ /* 140 */ 99, 663, 423, 642, 579, 48, 627, 617, 58, 144,
+ /* 150 */ 159, 82, 728, 41, 628, 190, 631, 667, 642, 20,
+ /* 160 */ 189, 107, 663, 52, 158, 115, 57, 643, 457, 133,
+ /* 170 */ 726, 461, 191, 642, 468, 74, 627, 617, 151, 144,
+ /* 180 */ 159, 119, 694, 41, 628, 491, 631, 667, 426, 58,
+ /* 190 */ 551, 107, 663, 52, 78, 642, 425, 426, 627, 617,
+ /* 200 */ 161, 158, 159, 155, 513, 41, 628, 43, 631, 667,
+ /* 210 */ 9, 8, 695, 107, 663, 740, 642, 2, 65, 627,
+ /* 220 */ 617, 62, 158, 159, 701, 152, 41, 628, 728, 631,
+ /* 230 */ 667, 135, 130, 128, 107, 663, 740, 642, 73, 59,
+ /* 240 */ 627, 617, 57, 158, 159, 724, 726, 41, 628, 698,
+ /* 250 */ 631, 667, 146, 29, 27, 107, 663, 740, 29, 27,
+ /* 260 */ 492, 686, 11, 487, 127, 412, 685, 11, 156, 462,
+ /* 270 */ 412, 708, 31, 429, 490, 414, 31, 548, 549, 624,
+ /* 280 */ 414, 60, 622, 403, 150, 1, 168, 114, 153, 124,
+ /* 290 */ 1, 642, 114, 148, 627, 617, 122, 158, 159, 418,
+ /* 300 */ 160, 90, 628, 85, 631, 160, 47, 447, 29, 27,
+ /* 310 */ 123, 707, 413, 415, 418, 29, 27, 413, 415, 418,
+ /* 320 */ 412, 728, 163, 162, 11, 64, 106, 412, 5, 137,
+ /* 330 */ 414, 688, 67, 58, 121, 57, 4, 414, 69, 726,
+ /* 340 */ 7, 51, 114, 422, 45, 487, 425, 1, 682, 114,
+ /* 350 */ 642, 32, 70, 627, 617, 160, 158, 159, 16, 649,
+ /* 360 */ 49, 628, 160, 631, 110, 743, 725, 413, 415, 418,
+ /* 370 */ 154, 157, 140, 77, 413, 415, 418, 421, 164, 642,
+ /* 380 */ 148, 166, 627, 617, 46, 158, 159, 194, 58, 42,
+ /* 390 */ 628, 44, 631, 667, 192, 29, 27, 145, 663, 149,
+ /* 400 */ 741, 71, 674, 139, 81, 138, 86, 412, 728, 83,
+ /* 410 */ 87, 29, 27, 147, 412, 98, 3, 414, 31, 14,
+ /* 420 */ 61, 510, 57, 412, 414, 63, 726, 1, 642, 114,
+ /* 430 */ 35, 627, 617, 414, 158, 159, 512, 50, 96, 628,
+ /* 440 */ 113, 631, 160, 7, 66, 114, 506, 505, 36, 160,
+ /* 450 */ 131, 37, 15, 132, 413, 415, 418, 622, 160, 18,
+ /* 460 */ 484, 413, 415, 418, 483, 34, 33, 72, 29, 27,
+ /* 470 */ 413, 415, 418, 8, 621, 642, 56, 534, 627, 617,
+ /* 480 */ 412, 158, 159, 430, 448, 42, 628, 539, 631, 667,
+ /* 490 */ 414, 17, 12, 38, 664, 30, 28, 26, 25, 24,
+ /* 500 */ 7, 533, 114, 111, 538, 537, 112, 642, 79, 13,
+ /* 510 */ 627, 617, 416, 158, 159, 160, 611, 96, 628, 120,
+ /* 520 */ 631, 610, 609, 574, 167, 396, 116, 413, 415, 418,
+ /* 530 */ 642, 377, 171, 627, 617, 165, 158, 159, 404, 169,
+ /* 540 */ 92, 628, 401, 631, 398, 642, 381, 172, 627, 617,
+ /* 550 */ 175, 158, 159, 178, 174, 96, 628, 108, 631, 642,
+ /* 560 */ 177, 180, 627, 617, 392, 158, 159, 408, 181, 49,
+ /* 570 */ 628, 642, 631, 136, 627, 617, 390, 158, 159, 395,
+ /* 580 */ 407, 91, 628, 187, 631, 406, 642, 394, 393, 627,
+ /* 590 */ 617, 39, 158, 159, 354, 193, 93, 628, 366, 631,
+ /* 600 */ 642, 373, 372, 627, 617, 371, 158, 159, 370, 742,
+ /* 610 */ 88, 628, 369, 631, 642, 552, 368, 627, 617, 367,
+ /* 620 */ 158, 159, 365, 364, 94, 628, 363, 631, 642, 552,
+ /* 630 */ 362, 627, 617, 361, 158, 159, 360, 359, 89, 628,
+ /* 640 */ 552, 631, 642, 552, 358, 627, 617, 357, 158, 159,
+ /* 650 */ 552, 552, 95, 628, 552, 631, 642, 552, 552, 627,
+ /* 660 */ 617, 552, 158, 159, 552, 552, 639, 628, 642, 631,
+ /* 670 */ 552, 627, 617, 552, 158, 159, 552, 552, 638, 628,
+ /* 680 */ 642, 631, 552, 627, 617, 552, 158, 159, 552, 552,
+ /* 690 */ 637, 628, 552, 631, 642, 552, 552, 627, 617, 552,
+ /* 700 */ 158, 159, 552, 552, 103, 628, 642, 631, 552, 627,
+ /* 710 */ 617, 552, 158, 159, 552, 552, 102, 628, 642, 631,
+ /* 720 */ 552, 627, 617, 552, 158, 159, 552, 552, 104, 628,
+ /* 730 */ 552, 631, 642, 552, 552, 627, 617, 552, 158, 159,
+ /* 740 */ 552, 552, 101, 628, 552, 631, 642, 552, 516, 627,
+ /* 750 */ 617, 19, 158, 159, 140, 552, 97, 628, 552, 631,
+ /* 760 */ 140, 30, 28, 26, 25, 24, 46, 30, 28, 26,
+ /* 770 */ 25, 24, 46, 44, 125, 514, 515, 517, 518, 44,
+ /* 780 */ 552, 552, 142, 53, 674, 675, 552, 679, 140, 54,
+ /* 790 */ 674, 675, 21, 679, 552, 30, 28, 26, 25, 24,
+ /* 800 */ 46, 552, 30, 28, 26, 25, 24, 44, 552, 552,
+ /* 810 */ 552, 552, 552, 552, 552, 552, 552, 55, 674, 675,
+ /* 820 */ 552, 679, 552, 552, 552, 552, 552, 552, 432, 552,
+ /* 830 */ 552, 552, 552, 552, 552, 552, 552, 552, 552, 552,
+ /* 840 */ 552, 552, 552, 552, 552, 552, 552, 552, 552, 552,
+ /* 850 */ 552, 552, 552, 552, 552, 552, 552, 552, 552, 552,
+ /* 860 */ 552, 552, 552, 552, 552, 552, 552, 552, 552, 545,
+ /* 870 */ 546,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 101, 102, 150, 104, 105, 106, 129, 141, 109, 110,
- /* 10 */ 111, 112, 12, 13, 14, 15, 16, 101, 102, 103,
- /* 20 */ 143, 21, 114, 115, 147, 12, 13, 14, 15, 16,
- /* 30 */ 101, 102, 104, 105, 21, 134, 101, 102, 110, 104,
- /* 40 */ 105, 106, 1, 2, 109, 110, 108, 112, 113, 49,
- /* 50 */ 127, 51, 52, 118, 54, 55, 56, 57, 58, 59,
- /* 60 */ 60, 61, 62, 63, 51, 52, 0, 54, 55, 56,
- /* 70 */ 57, 58, 59, 60, 61, 62, 63, 101, 102, 18,
- /* 80 */ 104, 105, 106, 53, 14, 109, 110, 111, 112, 23,
- /* 90 */ 49, 25, 26, 27, 28, 29, 30, 31, 32, 33,
- /* 100 */ 46, 35, 36, 37, 38, 39, 40, 41, 4, 79,
- /* 110 */ 80, 81, 82, 83, 100, 101, 102, 47, 104, 105,
- /* 120 */ 106, 47, 48, 109, 110, 47, 112, 113, 47, 48,
- /* 130 */ 69, 117, 118, 74, 75, 76, 101, 102, 47, 104,
- /* 140 */ 105, 106, 88, 129, 109, 110, 51, 112, 113, 69,
- /* 150 */ 69, 107, 117, 118, 119, 60, 65, 143, 63, 101,
- /* 160 */ 102, 147, 104, 105, 106, 3, 131, 109, 110, 125,
- /* 170 */ 112, 113, 137, 138, 70, 117, 118, 119, 101, 102,
- /* 180 */ 46, 104, 105, 106, 67, 68, 109, 110, 21, 112,
- /* 190 */ 14, 15, 16, 105, 101, 102, 138, 104, 105, 106,
- /* 200 */ 144, 46, 109, 110, 49, 112, 113, 104, 105, 130,
- /* 210 */ 117, 118, 119, 110, 66, 47, 68, 107, 107, 142,
- /* 220 */ 53, 128, 101, 102, 90, 104, 105, 106, 96, 78,
- /* 230 */ 109, 110, 100, 112, 113, 125, 125, 108, 117, 118,
- /* 240 */ 119, 140, 101, 102, 47, 104, 105, 106, 86, 128,
- /* 250 */ 109, 110, 77, 112, 113, 12, 13, 139, 117, 118,
- /* 260 */ 119, 129, 65, 46, 21, 46, 49, 24, 49, 128,
- /* 270 */ 98, 12, 13, 14, 45, 143, 104, 34, 140, 147,
- /* 280 */ 21, 1, 2, 24, 112, 42, 43, 44, 45, 102,
- /* 290 */ 47, 48, 102, 34, 122, 123, 124, 139, 126, 12,
- /* 300 */ 13, 42, 43, 44, 45, 102, 47, 48, 21, 94,
- /* 310 */ 95, 24, 69, 100, 101, 102, 85, 104, 105, 106,
- /* 320 */ 136, 34, 109, 110, 46, 112, 84, 49, 135, 42,
- /* 330 */ 43, 44, 45, 72, 47, 48, 12, 13, 133, 48,
- /* 340 */ 71, 50, 129, 132, 24, 68, 47, 47, 24, 12,
- /* 350 */ 13, 14, 15, 16, 34, 104, 143, 107, 34, 64,
- /* 360 */ 147, 120, 42, 43, 44, 45, 42, 43, 44, 45,
- /* 370 */ 48, 47, 48, 101, 102, 93, 104, 105, 106, 116,
- /* 380 */ 146, 109, 110, 151, 112, 113, 89, 47, 87, 117,
- /* 390 */ 118, 145, 47, 69, 98, 101, 102, 20, 104, 105,
- /* 400 */ 106, 97, 99, 109, 110, 46, 112, 113, 46, 73,
- /* 410 */ 49, 117, 118, 98, 49, 100, 48, 46, 49, 104,
- /* 420 */ 12, 13, 14, 48, 48, 24, 48, 112, 91, 92,
- /* 430 */ 49, 49, 24, 46, 50, 12, 13, 122, 123, 124,
- /* 440 */ 48, 126, 34, 46, 129, 73, 66, 24, 49, 49,
- /* 450 */ 42, 43, 44, 45, 50, 47, 48, 34, 143, 46,
- /* 460 */ 12, 13, 147, 2, 50, 42, 43, 44, 45, 50,
- /* 470 */ 47, 48, 24, 53, 49, 101, 102, 46, 104, 105,
- /* 480 */ 106, 49, 34, 109, 110, 73, 112, 4, 24, 24,
- /* 490 */ 42, 43, 44, 45, 24, 47, 48, 101, 102, 2,
- /* 500 */ 104, 105, 106, 50, 2, 109, 110, 111, 112, 12,
- /* 510 */ 13, 14, 15, 16, 12, 13, 14, 15, 16, 24,
- /* 520 */ 24, 48, 148, 149, 12, 13, 14, 15, 16, 101,
- /* 530 */ 102, 24, 104, 105, 106, 34, 0, 109, 110, 22,
- /* 540 */ 112, 101, 102, 21, 104, 105, 106, 34, 24, 109,
- /* 550 */ 110, 24, 112, 101, 102, 24, 104, 105, 106, 19,
- /* 560 */ 152, 109, 110, 24, 112, 24, 24, 101, 102, 24,
- /* 570 */ 104, 105, 106, 24, 24, 109, 110, 149, 112, 24,
- /* 580 */ 101, 102, 24, 104, 105, 106, 24, 24, 109, 110,
- /* 590 */ 24, 112, 101, 102, 24, 104, 105, 106, 24, 152,
- /* 600 */ 109, 110, 152, 112, 101, 102, 152, 104, 105, 106,
- /* 610 */ 152, 152, 109, 110, 152, 112, 152, 12, 13, 14,
- /* 620 */ 15, 16, 152, 152, 101, 102, 152, 104, 105, 106,
- /* 630 */ 152, 152, 109, 110, 152, 112, 101, 102, 152, 104,
- /* 640 */ 105, 106, 152, 152, 109, 110, 152, 112, 101, 102,
- /* 650 */ 152, 104, 105, 106, 49, 152, 109, 110, 152, 112,
- /* 660 */ 101, 102, 152, 104, 105, 106, 152, 152, 109, 110,
- /* 670 */ 152, 112, 101, 102, 152, 104, 105, 106, 152, 152,
- /* 680 */ 109, 110, 152, 112, 152, 101, 102, 152, 104, 105,
- /* 690 */ 106, 152, 152, 109, 110, 152, 112, 101, 102, 152,
- /* 700 */ 104, 105, 106, 152, 152, 109, 110, 152, 112, 101,
- /* 710 */ 102, 152, 104, 105, 106, 152, 152, 109, 110, 152,
- /* 720 */ 112, 152, 152, 98, 152, 152, 152, 152, 98, 104,
- /* 730 */ 152, 152, 152, 152, 104, 152, 152, 112, 152, 152,
- /* 740 */ 152, 152, 112, 152, 152, 152, 121, 122, 123, 124,
- /* 750 */ 152, 126, 122, 123, 124, 152, 126,
+ /* 0 */ 130, 131, 132, 128, 124, 157, 126, 127, 142, 143,
+ /* 10 */ 178, 127, 12, 13, 14, 15, 16, 133, 169, 171,
+ /* 20 */ 135, 21, 138, 175, 135, 12, 13, 14, 15, 16,
+ /* 30 */ 0, 130, 131, 127, 21, 162, 130, 131, 153, 133,
+ /* 40 */ 134, 14, 153, 137, 138, 45, 140, 141, 14, 15,
+ /* 50 */ 16, 145, 146, 23, 135, 25, 26, 27, 28, 29,
+ /* 60 */ 30, 31, 32, 33, 136, 35, 36, 37, 38, 39,
+ /* 70 */ 40, 41, 153, 46, 74, 75, 155, 77, 78, 79,
+ /* 80 */ 80, 81, 82, 83, 84, 85, 86, 74, 75, 46,
+ /* 90 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
+ /* 100 */ 44, 44, 46, 46, 50, 51, 52, 53, 54, 55,
+ /* 110 */ 56, 57, 58, 59, 60, 18, 62, 63, 64, 65,
+ /* 120 */ 66, 67, 127, 0, 129, 130, 131, 19, 133, 134,
+ /* 130 */ 1, 2, 137, 138, 92, 140, 141, 90, 91, 42,
+ /* 140 */ 145, 146, 46, 127, 126, 127, 130, 131, 92, 133,
+ /* 150 */ 134, 43, 157, 137, 138, 32, 140, 141, 127, 74,
+ /* 160 */ 37, 145, 146, 147, 133, 68, 171, 127, 83, 138,
+ /* 170 */ 175, 86, 49, 127, 45, 159, 130, 131, 3, 133,
+ /* 180 */ 134, 165, 166, 137, 138, 4, 140, 141, 46, 92,
+ /* 190 */ 119, 145, 146, 147, 172, 127, 46, 46, 130, 131,
+ /* 200 */ 129, 133, 134, 48, 45, 137, 138, 48, 140, 141,
+ /* 210 */ 1, 2, 166, 145, 146, 147, 127, 158, 45, 130,
+ /* 220 */ 131, 48, 133, 134, 156, 48, 137, 138, 157, 140,
+ /* 230 */ 141, 97, 98, 99, 145, 146, 147, 127, 88, 88,
+ /* 240 */ 130, 131, 171, 133, 134, 156, 175, 137, 138, 136,
+ /* 250 */ 140, 141, 21, 12, 13, 145, 146, 147, 12, 13,
+ /* 260 */ 14, 89, 21, 91, 101, 24, 156, 21, 113, 45,
+ /* 270 */ 24, 168, 48, 45, 93, 34, 48, 117, 118, 44,
+ /* 280 */ 34, 167, 47, 45, 109, 44, 48, 46, 111, 100,
+ /* 290 */ 44, 127, 46, 129, 130, 131, 131, 133, 134, 73,
+ /* 300 */ 59, 137, 138, 45, 140, 59, 48, 76, 12, 13,
+ /* 310 */ 131, 168, 71, 72, 73, 12, 13, 71, 72, 73,
+ /* 320 */ 24, 157, 69, 70, 21, 167, 131, 24, 108, 107,
+ /* 330 */ 34, 164, 163, 92, 95, 171, 94, 34, 160, 175,
+ /* 340 */ 44, 161, 46, 46, 133, 91, 46, 44, 135, 46,
+ /* 350 */ 127, 87, 148, 130, 131, 59, 133, 134, 44, 144,
+ /* 360 */ 137, 138, 59, 140, 116, 179, 174, 71, 72, 73,
+ /* 370 */ 110, 112, 121, 173, 71, 72, 73, 46, 121, 127,
+ /* 380 */ 129, 46, 130, 131, 133, 133, 134, 20, 92, 137,
+ /* 390 */ 138, 140, 140, 141, 123, 12, 13, 145, 146, 176,
+ /* 400 */ 177, 150, 151, 152, 120, 154, 121, 24, 157, 120,
+ /* 410 */ 122, 12, 13, 14, 24, 125, 48, 34, 48, 96,
+ /* 420 */ 45, 45, 171, 24, 34, 44, 175, 44, 127, 46,
+ /* 430 */ 48, 130, 131, 34, 133, 134, 45, 44, 137, 138,
+ /* 440 */ 139, 140, 59, 44, 44, 46, 45, 45, 44, 59,
+ /* 450 */ 24, 44, 96, 48, 71, 72, 73, 47, 59, 48,
+ /* 460 */ 45, 71, 72, 73, 45, 48, 89, 47, 12, 13,
+ /* 470 */ 71, 72, 73, 2, 47, 127, 47, 24, 130, 131,
+ /* 480 */ 24, 133, 134, 45, 76, 137, 138, 45, 140, 141,
+ /* 490 */ 34, 48, 96, 4, 146, 12, 13, 14, 15, 16,
+ /* 500 */ 44, 24, 46, 24, 24, 24, 24, 127, 47, 44,
+ /* 510 */ 130, 131, 34, 133, 134, 59, 0, 137, 138, 139,
+ /* 520 */ 140, 0, 0, 0, 24, 61, 24, 71, 72, 73,
+ /* 530 */ 127, 46, 24, 130, 131, 47, 133, 134, 45, 44,
+ /* 540 */ 137, 138, 45, 140, 45, 127, 34, 44, 130, 131,
+ /* 550 */ 44, 133, 134, 44, 24, 137, 138, 139, 140, 127,
+ /* 560 */ 24, 24, 130, 131, 45, 133, 134, 24, 44, 137,
+ /* 570 */ 138, 127, 140, 170, 130, 131, 45, 133, 134, 61,
+ /* 580 */ 24, 137, 138, 49, 140, 24, 127, 61, 61, 130,
+ /* 590 */ 131, 44, 133, 134, 22, 21, 137, 138, 34, 140,
+ /* 600 */ 127, 24, 24, 130, 131, 24, 133, 134, 24, 177,
+ /* 610 */ 137, 138, 24, 140, 127, 180, 24, 130, 131, 24,
+ /* 620 */ 133, 134, 24, 24, 137, 138, 24, 140, 127, 180,
+ /* 630 */ 24, 130, 131, 24, 133, 134, 24, 24, 137, 138,
+ /* 640 */ 180, 140, 127, 180, 24, 130, 131, 24, 133, 134,
+ /* 650 */ 180, 180, 137, 138, 180, 140, 127, 180, 180, 130,
+ /* 660 */ 131, 180, 133, 134, 180, 180, 137, 138, 127, 140,
+ /* 670 */ 180, 130, 131, 180, 133, 134, 180, 180, 137, 138,
+ /* 680 */ 127, 140, 180, 130, 131, 180, 133, 134, 180, 180,
+ /* 690 */ 137, 138, 180, 140, 127, 180, 180, 130, 131, 180,
+ /* 700 */ 133, 134, 180, 180, 137, 138, 127, 140, 180, 130,
+ /* 710 */ 131, 180, 133, 134, 180, 180, 137, 138, 127, 140,
+ /* 720 */ 180, 130, 131, 180, 133, 134, 180, 180, 137, 138,
+ /* 730 */ 180, 140, 127, 180, 180, 130, 131, 180, 133, 134,
+ /* 740 */ 180, 180, 137, 138, 180, 140, 127, 180, 76, 130,
+ /* 750 */ 131, 2, 133, 134, 121, 180, 137, 138, 180, 140,
+ /* 760 */ 121, 12, 13, 14, 15, 16, 133, 12, 13, 14,
+ /* 770 */ 15, 16, 133, 140, 102, 103, 104, 105, 106, 140,
+ /* 780 */ 180, 180, 149, 150, 151, 152, 180, 154, 121, 150,
+ /* 790 */ 151, 152, 2, 154, 180, 12, 13, 14, 15, 16,
+ /* 800 */ 133, 180, 12, 13, 14, 15, 16, 140, 180, 180,
+ /* 810 */ 180, 180, 180, 180, 180, 180, 180, 150, 151, 152,
+ /* 820 */ 180, 154, 180, 180, 180, 180, 180, 180, 45, 180,
+ /* 830 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 840 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 850 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 860 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 114,
+ /* 870 */ 115, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 880 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 890 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 900 */ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ /* 910 */ 180, 180, 180, 180, 180,
};
-#define YY_SHIFT_COUNT (169)
+#define YY_SHIFT_COUNT (211)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (605)
+#define YY_SHIFT_MAX (790)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 61, 243, 259, 287, 287, 287, 287, 324, 287, 287,
- /* 10 */ 81, 423, 448, 408, 448, 448, 448, 448, 448, 448,
- /* 20 */ 448, 448, 448, 448, 448, 448, 448, 448, 448, 448,
- /* 30 */ 448, 448, 74, 74, 74, 320, 78, 78, 80, 0,
- /* 40 */ 13, 13, 320, 91, 91, 91, 337, 30, 59, 197,
- /* 50 */ 148, 117, 148, 70, 162, 104, 168, 151, 175, 229,
- /* 60 */ 229, 151, 175, 229, 231, 242, 261, 269, 277, 299,
- /* 70 */ 300, 295, 322, 282, 297, 301, 340, 345, 377, 757,
- /* 80 */ 66, 497, 502, 605, 512, 512, 512, 512, 512, 512,
- /* 90 */ 512, 41, 95, 176, 176, 176, 176, 155, 217, 280,
- /* 100 */ 219, 167, 215, 54, 134, 278, 291, 359, 362, 336,
- /* 110 */ 361, 365, 368, 371, 369, 375, 376, 381, 378, 382,
- /* 120 */ 401, 387, 384, 392, 397, 372, 399, 400, 404, 380,
- /* 130 */ 413, 414, 419, 461, 420, 425, 432, 431, 412, 483,
- /* 140 */ 464, 465, 470, 495, 496, 507, 453, 473, 501, 536,
- /* 150 */ 517, 522, 524, 527, 531, 539, 541, 542, 545, 513,
- /* 160 */ 549, 550, 555, 558, 562, 563, 566, 570, 574, 540,
+ /* 0 */ 97, 241, 246, 303, 303, 303, 303, 296, 303, 303,
+ /* 10 */ 56, 383, 456, 399, 456, 456, 456, 456, 456, 456,
+ /* 20 */ 456, 456, 456, 456, 456, 456, 456, 456, 456, 456,
+ /* 30 */ 456, 456, 57, 57, 57, 390, 43, 43, 42, 96,
+ /* 40 */ 0, 13, 13, 390, 150, 150, 150, 96, 54, 755,
+ /* 50 */ 672, 134, 151, 172, 47, 172, 27, 175, 181, 142,
+ /* 60 */ 163, 189, 226, 226, 163, 189, 226, 220, 222, 239,
+ /* 70 */ 242, 254, 297, 300, 264, 314, 248, 259, 260, 96,
+ /* 80 */ 331, 335, 367, 331, 367, 871, 871, 30, 749, 790,
+ /* 90 */ 783, 483, 483, 483, 483, 483, 483, 483, 123, 129,
+ /* 100 */ 85, 34, 34, 34, 34, 159, 173, 209, 224, 231,
+ /* 110 */ 160, 177, 155, 228, 235, 253, 238, 258, 108, 368,
+ /* 120 */ 370, 323, 375, 376, 381, 382, 391, 393, 400, 401,
+ /* 130 */ 404, 402, 426, 405, 410, 407, 411, 356, 415, 419,
+ /* 140 */ 420, 377, 417, 427, 429, 471, 408, 438, 442, 443,
+ /* 150 */ 396, 489, 453, 477, 479, 480, 481, 482, 461, 465,
+ /* 160 */ 478, 516, 521, 522, 523, 485, 488, 493, 500, 502,
+ /* 170 */ 495, 497, 508, 503, 499, 530, 506, 519, 536, 509,
+ /* 180 */ 531, 537, 524, 464, 518, 526, 527, 512, 534, 543,
+ /* 190 */ 556, 561, 547, 572, 574, 577, 578, 581, 584, 588,
+ /* 200 */ 592, 595, 564, 598, 599, 602, 606, 609, 612, 613,
+ /* 210 */ 620, 623,
};
-#define YY_REDUCE_COUNT (79)
-#define YY_REDUCE_MIN (-148)
-#define YY_REDUCE_MAX (630)
+#define YY_REDUCE_COUNT (86)
+#define YY_REDUCE_MIN (-168)
+#define YY_REDUCE_MAX (667)
static const short yy_reduce_ofst[] = {
- /* 0 */ 132, 14, 35, 58, 93, 121, 141, 213, 272, 294,
- /* 10 */ 315, -65, 374, -101, -24, 77, 396, 428, 440, 452,
- /* 20 */ 466, 479, 491, 503, 523, 535, 547, 559, 571, 584,
- /* 30 */ 596, 608, 625, 172, 630, -84, -72, 103, -123, -92,
- /* 40 */ -92, -92, -71, 44, 110, 111, -148, -134, -99, -62,
- /* 50 */ -77, -77, -77, 88, 56, 79, 129, 101, 118, 187,
- /* 60 */ 190, 138, 158, 203, 184, 193, 205, 211, -77, 251,
- /* 70 */ 250, 241, 263, 232, 234, 246, 88, 296, 304, 303,
+ /* 0 */ 71, -5, 16, 46, 68, 89, 110, 164, -94, 252,
+ /* 10 */ 251, 348, 223, 301, 380, 403, 418, 432, 444, 459,
+ /* 20 */ 473, 487, 501, 515, 529, 541, 553, 567, 579, 591,
+ /* 30 */ 605, 619, 633, 639, 667, -130, -116, 31, -152, -120,
+ /* 40 */ -134, -134, -134, -99, -115, -111, -81, 18, -125, -168,
+ /* 50 */ -151, -127, -72, -79, -79, -79, 40, 22, 59, 113,
+ /* 60 */ 103, 114, 165, 179, 143, 158, 195, 167, 169, 180,
+ /* 70 */ 178, -79, 211, 213, 204, 215, 186, 192, 200, 40,
+ /* 80 */ 257, 271, 284, 285, 289, 290, 288,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 10 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 20 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 30 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 40 */ 528, 446, 446, 539, 539, 539, 603, 446, 563, 555,
- /* 50 */ 531, 545, 532, 446, 588, 548, 446, 570, 568, 446,
- /* 60 */ 446, 570, 568, 446, 582, 578, 561, 559, 545, 446,
- /* 70 */ 446, 446, 446, 606, 594, 590, 446, 446, 451, 452,
- /* 80 */ 446, 446, 446, 446, 581, 580, 505, 504, 503, 499,
- /* 90 */ 500, 446, 446, 494, 495, 493, 492, 446, 446, 529,
- /* 100 */ 446, 446, 446, 591, 595, 446, 482, 552, 562, 446,
- /* 110 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 120 */ 446, 446, 482, 446, 579, 446, 538, 534, 446, 446,
- /* 130 */ 530, 481, 446, 524, 446, 446, 446, 589, 446, 446,
- /* 140 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 150 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
- /* 160 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446,
+ /* 0 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 10 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 20 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 30 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 40 */ 550, 669, 550, 550, 680, 680, 680, 550, 550, 744,
+ /* 50 */ 550, 704, 696, 672, 686, 673, 550, 729, 689, 550,
+ /* 60 */ 711, 709, 550, 550, 711, 709, 550, 723, 719, 702,
+ /* 70 */ 700, 686, 550, 550, 550, 550, 747, 735, 731, 550,
+ /* 80 */ 550, 550, 555, 550, 555, 605, 556, 550, 550, 550,
+ /* 90 */ 550, 722, 721, 646, 645, 644, 640, 641, 550, 550,
+ /* 100 */ 550, 635, 636, 634, 633, 550, 550, 670, 550, 550,
+ /* 110 */ 550, 732, 736, 550, 623, 550, 550, 550, 550, 693,
+ /* 120 */ 703, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 130 */ 550, 550, 550, 550, 623, 550, 720, 550, 679, 675,
+ /* 140 */ 550, 550, 671, 622, 550, 665, 550, 550, 550, 730,
+ /* 150 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 160 */ 550, 550, 550, 550, 550, 550, 576, 550, 550, 550,
+ /* 170 */ 602, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 180 */ 550, 550, 550, 587, 585, 584, 583, 550, 580, 550,
+ /* 190 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 200 */ 550, 550, 550, 550, 550, 550, 550, 550, 550, 550,
+ /* 210 */ 550, 550,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -574,116 +616,144 @@ static const char *const yyTokenName[] = {
/* 39 */ "VGROUPS",
/* 40 */ "SINGLESTABLE",
/* 41 */ "STREAMMODE",
- /* 42 */ "NK_FLOAT",
- /* 43 */ "NK_BOOL",
- /* 44 */ "TIMESTAMP",
- /* 45 */ "NK_VARIABLE",
- /* 46 */ "NK_COMMA",
- /* 47 */ "NK_ID",
- /* 48 */ "NK_LP",
- /* 49 */ "NK_RP",
- /* 50 */ "NK_DOT",
- /* 51 */ "BETWEEN",
- /* 52 */ "IS",
- /* 53 */ "NULL",
- /* 54 */ "NK_LT",
- /* 55 */ "NK_GT",
- /* 56 */ "NK_LE",
- /* 57 */ "NK_GE",
- /* 58 */ "NK_NE",
- /* 59 */ "NK_EQ",
- /* 60 */ "LIKE",
- /* 61 */ "MATCH",
- /* 62 */ "NMATCH",
- /* 63 */ "IN",
- /* 64 */ "FROM",
- /* 65 */ "AS",
- /* 66 */ "JOIN",
- /* 67 */ "ON",
- /* 68 */ "INNER",
- /* 69 */ "SELECT",
- /* 70 */ "DISTINCT",
- /* 71 */ "WHERE",
- /* 72 */ "PARTITION",
- /* 73 */ "BY",
- /* 74 */ "SESSION",
- /* 75 */ "STATE_WINDOW",
- /* 76 */ "INTERVAL",
- /* 77 */ "SLIDING",
- /* 78 */ "FILL",
- /* 79 */ "VALUE",
- /* 80 */ "NONE",
- /* 81 */ "PREV",
- /* 82 */ "LINEAR",
- /* 83 */ "NEXT",
- /* 84 */ "GROUP",
- /* 85 */ "HAVING",
- /* 86 */ "ORDER",
- /* 87 */ "SLIMIT",
- /* 88 */ "SOFFSET",
- /* 89 */ "LIMIT",
- /* 90 */ "OFFSET",
- /* 91 */ "ASC",
- /* 92 */ "DESC",
- /* 93 */ "NULLS",
- /* 94 */ "FIRST",
- /* 95 */ "LAST",
- /* 96 */ "cmd",
- /* 97 */ "exists_opt",
- /* 98 */ "db_name",
- /* 99 */ "db_options",
- /* 100 */ "query_expression",
- /* 101 */ "literal",
- /* 102 */ "duration_literal",
- /* 103 */ "literal_list",
- /* 104 */ "table_name",
- /* 105 */ "column_name",
- /* 106 */ "function_name",
- /* 107 */ "table_alias",
- /* 108 */ "column_alias",
- /* 109 */ "expression",
- /* 110 */ "column_reference",
- /* 111 */ "expression_list",
- /* 112 */ "subquery",
- /* 113 */ "predicate",
- /* 114 */ "compare_op",
- /* 115 */ "in_op",
- /* 116 */ "in_predicate_value",
- /* 117 */ "boolean_value_expression",
- /* 118 */ "boolean_primary",
- /* 119 */ "common_expression",
- /* 120 */ "from_clause",
- /* 121 */ "table_reference_list",
- /* 122 */ "table_reference",
- /* 123 */ "table_primary",
- /* 124 */ "joined_table",
- /* 125 */ "alias_opt",
- /* 126 */ "parenthesized_joined_table",
- /* 127 */ "join_type",
- /* 128 */ "search_condition",
- /* 129 */ "query_specification",
- /* 130 */ "set_quantifier_opt",
- /* 131 */ "select_list",
- /* 132 */ "where_clause_opt",
- /* 133 */ "partition_by_clause_opt",
- /* 134 */ "twindow_clause_opt",
- /* 135 */ "group_by_clause_opt",
- /* 136 */ "having_clause_opt",
- /* 137 */ "select_sublist",
- /* 138 */ "select_item",
- /* 139 */ "sliding_opt",
- /* 140 */ "fill_opt",
- /* 141 */ "fill_mode",
- /* 142 */ "group_by_list",
- /* 143 */ "query_expression_body",
- /* 144 */ "order_by_clause_opt",
- /* 145 */ "slimit_clause_opt",
- /* 146 */ "limit_clause_opt",
- /* 147 */ "query_primary",
- /* 148 */ "sort_specification_list",
- /* 149 */ "sort_specification",
- /* 150 */ "ordering_specification_opt",
- /* 151 */ "null_ordering_opt",
+ /* 42 */ "USE",
+ /* 43 */ "TABLE",
+ /* 44 */ "NK_LP",
+ /* 45 */ "NK_RP",
+ /* 46 */ "NK_ID",
+ /* 47 */ "NK_DOT",
+ /* 48 */ "NK_COMMA",
+ /* 49 */ "COMMENT",
+ /* 50 */ "BOOL",
+ /* 51 */ "TINYINT",
+ /* 52 */ "SMALLINT",
+ /* 53 */ "INT",
+ /* 54 */ "INTEGER",
+ /* 55 */ "BIGINT",
+ /* 56 */ "FLOAT",
+ /* 57 */ "DOUBLE",
+ /* 58 */ "BINARY",
+ /* 59 */ "TIMESTAMP",
+ /* 60 */ "NCHAR",
+ /* 61 */ "UNSIGNED",
+ /* 62 */ "JSON",
+ /* 63 */ "VARCHAR",
+ /* 64 */ "MEDIUMBLOB",
+ /* 65 */ "BLOB",
+ /* 66 */ "VARBINARY",
+ /* 67 */ "DECIMAL",
+ /* 68 */ "SHOW",
+ /* 69 */ "DATABASES",
+ /* 70 */ "TABLES",
+ /* 71 */ "NK_FLOAT",
+ /* 72 */ "NK_BOOL",
+ /* 73 */ "NK_VARIABLE",
+ /* 74 */ "BETWEEN",
+ /* 75 */ "IS",
+ /* 76 */ "NULL",
+ /* 77 */ "NK_LT",
+ /* 78 */ "NK_GT",
+ /* 79 */ "NK_LE",
+ /* 80 */ "NK_GE",
+ /* 81 */ "NK_NE",
+ /* 82 */ "NK_EQ",
+ /* 83 */ "LIKE",
+ /* 84 */ "MATCH",
+ /* 85 */ "NMATCH",
+ /* 86 */ "IN",
+ /* 87 */ "FROM",
+ /* 88 */ "AS",
+ /* 89 */ "JOIN",
+ /* 90 */ "ON",
+ /* 91 */ "INNER",
+ /* 92 */ "SELECT",
+ /* 93 */ "DISTINCT",
+ /* 94 */ "WHERE",
+ /* 95 */ "PARTITION",
+ /* 96 */ "BY",
+ /* 97 */ "SESSION",
+ /* 98 */ "STATE_WINDOW",
+ /* 99 */ "INTERVAL",
+ /* 100 */ "SLIDING",
+ /* 101 */ "FILL",
+ /* 102 */ "VALUE",
+ /* 103 */ "NONE",
+ /* 104 */ "PREV",
+ /* 105 */ "LINEAR",
+ /* 106 */ "NEXT",
+ /* 107 */ "GROUP",
+ /* 108 */ "HAVING",
+ /* 109 */ "ORDER",
+ /* 110 */ "SLIMIT",
+ /* 111 */ "SOFFSET",
+ /* 112 */ "LIMIT",
+ /* 113 */ "OFFSET",
+ /* 114 */ "ASC",
+ /* 115 */ "DESC",
+ /* 116 */ "NULLS",
+ /* 117 */ "FIRST",
+ /* 118 */ "LAST",
+ /* 119 */ "cmd",
+ /* 120 */ "exists_opt",
+ /* 121 */ "db_name",
+ /* 122 */ "db_options",
+ /* 123 */ "full_table_name",
+ /* 124 */ "column_def_list",
+ /* 125 */ "table_options",
+ /* 126 */ "column_def",
+ /* 127 */ "column_name",
+ /* 128 */ "type_name",
+ /* 129 */ "query_expression",
+ /* 130 */ "literal",
+ /* 131 */ "duration_literal",
+ /* 132 */ "literal_list",
+ /* 133 */ "table_name",
+ /* 134 */ "function_name",
+ /* 135 */ "table_alias",
+ /* 136 */ "column_alias",
+ /* 137 */ "expression",
+ /* 138 */ "column_reference",
+ /* 139 */ "expression_list",
+ /* 140 */ "subquery",
+ /* 141 */ "predicate",
+ /* 142 */ "compare_op",
+ /* 143 */ "in_op",
+ /* 144 */ "in_predicate_value",
+ /* 145 */ "boolean_value_expression",
+ /* 146 */ "boolean_primary",
+ /* 147 */ "common_expression",
+ /* 148 */ "from_clause",
+ /* 149 */ "table_reference_list",
+ /* 150 */ "table_reference",
+ /* 151 */ "table_primary",
+ /* 152 */ "joined_table",
+ /* 153 */ "alias_opt",
+ /* 154 */ "parenthesized_joined_table",
+ /* 155 */ "join_type",
+ /* 156 */ "search_condition",
+ /* 157 */ "query_specification",
+ /* 158 */ "set_quantifier_opt",
+ /* 159 */ "select_list",
+ /* 160 */ "where_clause_opt",
+ /* 161 */ "partition_by_clause_opt",
+ /* 162 */ "twindow_clause_opt",
+ /* 163 */ "group_by_clause_opt",
+ /* 164 */ "having_clause_opt",
+ /* 165 */ "select_sublist",
+ /* 166 */ "select_item",
+ /* 167 */ "sliding_opt",
+ /* 168 */ "fill_opt",
+ /* 169 */ "fill_mode",
+ /* 170 */ "group_by_list",
+ /* 171 */ "query_expression_body",
+ /* 172 */ "order_by_clause_opt",
+ /* 173 */ "slimit_clause_opt",
+ /* 174 */ "limit_clause_opt",
+ /* 175 */ "query_primary",
+ /* 176 */ "sort_specification_list",
+ /* 177 */ "sort_specification",
+ /* 178 */ "ordering_specification_opt",
+ /* 179 */ "null_ordering_opt",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -712,145 +782,182 @@ static const char *const yyRuleName[] = {
/* 18 */ "db_options ::= db_options VGROUPS NK_INTEGER",
/* 19 */ "db_options ::= db_options SINGLESTABLE NK_INTEGER",
/* 20 */ "db_options ::= db_options STREAMMODE NK_INTEGER",
- /* 21 */ "cmd ::= query_expression",
- /* 22 */ "literal ::= NK_INTEGER",
- /* 23 */ "literal ::= NK_FLOAT",
- /* 24 */ "literal ::= NK_STRING",
- /* 25 */ "literal ::= NK_BOOL",
- /* 26 */ "literal ::= TIMESTAMP NK_STRING",
- /* 27 */ "literal ::= duration_literal",
- /* 28 */ "duration_literal ::= NK_VARIABLE",
- /* 29 */ "literal_list ::= literal",
- /* 30 */ "literal_list ::= literal_list NK_COMMA literal",
- /* 31 */ "db_name ::= NK_ID",
- /* 32 */ "table_name ::= NK_ID",
- /* 33 */ "column_name ::= NK_ID",
- /* 34 */ "function_name ::= NK_ID",
- /* 35 */ "table_alias ::= NK_ID",
- /* 36 */ "column_alias ::= NK_ID",
- /* 37 */ "expression ::= literal",
- /* 38 */ "expression ::= column_reference",
- /* 39 */ "expression ::= function_name NK_LP expression_list NK_RP",
- /* 40 */ "expression ::= function_name NK_LP NK_STAR NK_RP",
- /* 41 */ "expression ::= subquery",
- /* 42 */ "expression ::= NK_LP expression NK_RP",
- /* 43 */ "expression ::= NK_PLUS expression",
- /* 44 */ "expression ::= NK_MINUS expression",
- /* 45 */ "expression ::= expression NK_PLUS expression",
- /* 46 */ "expression ::= expression NK_MINUS expression",
- /* 47 */ "expression ::= expression NK_STAR expression",
- /* 48 */ "expression ::= expression NK_SLASH expression",
- /* 49 */ "expression ::= expression NK_REM expression",
- /* 50 */ "expression_list ::= expression",
- /* 51 */ "expression_list ::= expression_list NK_COMMA expression",
- /* 52 */ "column_reference ::= column_name",
- /* 53 */ "column_reference ::= table_name NK_DOT column_name",
- /* 54 */ "predicate ::= expression compare_op expression",
- /* 55 */ "predicate ::= expression BETWEEN expression AND expression",
- /* 56 */ "predicate ::= expression NOT BETWEEN expression AND expression",
- /* 57 */ "predicate ::= expression IS NULL",
- /* 58 */ "predicate ::= expression IS NOT NULL",
- /* 59 */ "predicate ::= expression in_op in_predicate_value",
- /* 60 */ "compare_op ::= NK_LT",
- /* 61 */ "compare_op ::= NK_GT",
- /* 62 */ "compare_op ::= NK_LE",
- /* 63 */ "compare_op ::= NK_GE",
- /* 64 */ "compare_op ::= NK_NE",
- /* 65 */ "compare_op ::= NK_EQ",
- /* 66 */ "compare_op ::= LIKE",
- /* 67 */ "compare_op ::= NOT LIKE",
- /* 68 */ "compare_op ::= MATCH",
- /* 69 */ "compare_op ::= NMATCH",
- /* 70 */ "in_op ::= IN",
- /* 71 */ "in_op ::= NOT IN",
- /* 72 */ "in_predicate_value ::= NK_LP expression_list NK_RP",
- /* 73 */ "boolean_value_expression ::= boolean_primary",
- /* 74 */ "boolean_value_expression ::= NOT boolean_primary",
- /* 75 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
- /* 76 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
- /* 77 */ "boolean_primary ::= predicate",
- /* 78 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
- /* 79 */ "common_expression ::= expression",
- /* 80 */ "common_expression ::= boolean_value_expression",
- /* 81 */ "from_clause ::= FROM table_reference_list",
- /* 82 */ "table_reference_list ::= table_reference",
- /* 83 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
- /* 84 */ "table_reference ::= table_primary",
- /* 85 */ "table_reference ::= joined_table",
- /* 86 */ "table_primary ::= table_name alias_opt",
- /* 87 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
- /* 88 */ "table_primary ::= subquery alias_opt",
- /* 89 */ "table_primary ::= parenthesized_joined_table",
- /* 90 */ "alias_opt ::=",
- /* 91 */ "alias_opt ::= table_alias",
- /* 92 */ "alias_opt ::= AS table_alias",
- /* 93 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
- /* 94 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
- /* 95 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
- /* 96 */ "join_type ::=",
- /* 97 */ "join_type ::= INNER",
- /* 98 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
- /* 99 */ "set_quantifier_opt ::=",
- /* 100 */ "set_quantifier_opt ::= DISTINCT",
- /* 101 */ "set_quantifier_opt ::= ALL",
- /* 102 */ "select_list ::= NK_STAR",
- /* 103 */ "select_list ::= select_sublist",
- /* 104 */ "select_sublist ::= select_item",
- /* 105 */ "select_sublist ::= select_sublist NK_COMMA select_item",
- /* 106 */ "select_item ::= common_expression",
- /* 107 */ "select_item ::= common_expression column_alias",
- /* 108 */ "select_item ::= common_expression AS column_alias",
- /* 109 */ "select_item ::= table_name NK_DOT NK_STAR",
- /* 110 */ "where_clause_opt ::=",
- /* 111 */ "where_clause_opt ::= WHERE search_condition",
- /* 112 */ "partition_by_clause_opt ::=",
- /* 113 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
- /* 114 */ "twindow_clause_opt ::=",
- /* 115 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP",
- /* 116 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP",
- /* 117 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
- /* 118 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
- /* 119 */ "sliding_opt ::=",
- /* 120 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
- /* 121 */ "fill_opt ::=",
- /* 122 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
- /* 123 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
- /* 124 */ "fill_mode ::= NONE",
- /* 125 */ "fill_mode ::= PREV",
- /* 126 */ "fill_mode ::= NULL",
- /* 127 */ "fill_mode ::= LINEAR",
- /* 128 */ "fill_mode ::= NEXT",
- /* 129 */ "group_by_clause_opt ::=",
- /* 130 */ "group_by_clause_opt ::= GROUP BY group_by_list",
- /* 131 */ "group_by_list ::= expression",
- /* 132 */ "group_by_list ::= group_by_list NK_COMMA expression",
- /* 133 */ "having_clause_opt ::=",
- /* 134 */ "having_clause_opt ::= HAVING search_condition",
- /* 135 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
- /* 136 */ "query_expression_body ::= query_primary",
- /* 137 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
- /* 138 */ "query_primary ::= query_specification",
- /* 139 */ "order_by_clause_opt ::=",
- /* 140 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
- /* 141 */ "slimit_clause_opt ::=",
- /* 142 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
- /* 143 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
- /* 144 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 145 */ "limit_clause_opt ::=",
- /* 146 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
- /* 147 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
- /* 148 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 149 */ "subquery ::= NK_LP query_expression NK_RP",
- /* 150 */ "search_condition ::= common_expression",
- /* 151 */ "sort_specification_list ::= sort_specification",
- /* 152 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
- /* 153 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt",
- /* 154 */ "ordering_specification_opt ::=",
- /* 155 */ "ordering_specification_opt ::= ASC",
- /* 156 */ "ordering_specification_opt ::= DESC",
- /* 157 */ "null_ordering_opt ::=",
- /* 158 */ "null_ordering_opt ::= NULLS FIRST",
- /* 159 */ "null_ordering_opt ::= NULLS LAST",
+ /* 21 */ "cmd ::= USE db_name",
+ /* 22 */ "cmd ::= CREATE TABLE exists_opt full_table_name NK_LP column_def_list NK_RP table_options",
+ /* 23 */ "full_table_name ::= NK_ID",
+ /* 24 */ "full_table_name ::= NK_ID NK_DOT NK_ID",
+ /* 25 */ "column_def_list ::= column_def",
+ /* 26 */ "column_def_list ::= column_def_list NK_COMMA column_def",
+ /* 27 */ "column_def ::= column_name type_name",
+ /* 28 */ "column_def ::= column_name type_name COMMENT NK_STRING",
+ /* 29 */ "type_name ::= BOOL",
+ /* 30 */ "type_name ::= TINYINT",
+ /* 31 */ "type_name ::= SMALLINT",
+ /* 32 */ "type_name ::= INT",
+ /* 33 */ "type_name ::= INTEGER",
+ /* 34 */ "type_name ::= BIGINT",
+ /* 35 */ "type_name ::= FLOAT",
+ /* 36 */ "type_name ::= DOUBLE",
+ /* 37 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP",
+ /* 38 */ "type_name ::= TIMESTAMP",
+ /* 39 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP",
+ /* 40 */ "type_name ::= TINYINT UNSIGNED",
+ /* 41 */ "type_name ::= SMALLINT UNSIGNED",
+ /* 42 */ "type_name ::= INT UNSIGNED",
+ /* 43 */ "type_name ::= BIGINT UNSIGNED",
+ /* 44 */ "type_name ::= JSON",
+ /* 45 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP",
+ /* 46 */ "type_name ::= MEDIUMBLOB",
+ /* 47 */ "type_name ::= BLOB",
+ /* 48 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP",
+ /* 49 */ "type_name ::= DECIMAL",
+ /* 50 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP",
+ /* 51 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP",
+ /* 52 */ "table_options ::=",
+ /* 53 */ "table_options ::= table_options COMMENT NK_INTEGER",
+ /* 54 */ "table_options ::= table_options KEEP NK_INTEGER",
+ /* 55 */ "table_options ::= table_options TTL NK_INTEGER",
+ /* 56 */ "cmd ::= SHOW DATABASES",
+ /* 57 */ "cmd ::= SHOW TABLES",
+ /* 58 */ "cmd ::= query_expression",
+ /* 59 */ "literal ::= NK_INTEGER",
+ /* 60 */ "literal ::= NK_FLOAT",
+ /* 61 */ "literal ::= NK_STRING",
+ /* 62 */ "literal ::= NK_BOOL",
+ /* 63 */ "literal ::= TIMESTAMP NK_STRING",
+ /* 64 */ "literal ::= duration_literal",
+ /* 65 */ "duration_literal ::= NK_VARIABLE",
+ /* 66 */ "literal_list ::= literal",
+ /* 67 */ "literal_list ::= literal_list NK_COMMA literal",
+ /* 68 */ "db_name ::= NK_ID",
+ /* 69 */ "table_name ::= NK_ID",
+ /* 70 */ "column_name ::= NK_ID",
+ /* 71 */ "function_name ::= NK_ID",
+ /* 72 */ "table_alias ::= NK_ID",
+ /* 73 */ "column_alias ::= NK_ID",
+ /* 74 */ "expression ::= literal",
+ /* 75 */ "expression ::= column_reference",
+ /* 76 */ "expression ::= function_name NK_LP expression_list NK_RP",
+ /* 77 */ "expression ::= function_name NK_LP NK_STAR NK_RP",
+ /* 78 */ "expression ::= subquery",
+ /* 79 */ "expression ::= NK_LP expression NK_RP",
+ /* 80 */ "expression ::= NK_PLUS expression",
+ /* 81 */ "expression ::= NK_MINUS expression",
+ /* 82 */ "expression ::= expression NK_PLUS expression",
+ /* 83 */ "expression ::= expression NK_MINUS expression",
+ /* 84 */ "expression ::= expression NK_STAR expression",
+ /* 85 */ "expression ::= expression NK_SLASH expression",
+ /* 86 */ "expression ::= expression NK_REM expression",
+ /* 87 */ "expression_list ::= expression",
+ /* 88 */ "expression_list ::= expression_list NK_COMMA expression",
+ /* 89 */ "column_reference ::= column_name",
+ /* 90 */ "column_reference ::= table_name NK_DOT column_name",
+ /* 91 */ "predicate ::= expression compare_op expression",
+ /* 92 */ "predicate ::= expression BETWEEN expression AND expression",
+ /* 93 */ "predicate ::= expression NOT BETWEEN expression AND expression",
+ /* 94 */ "predicate ::= expression IS NULL",
+ /* 95 */ "predicate ::= expression IS NOT NULL",
+ /* 96 */ "predicate ::= expression in_op in_predicate_value",
+ /* 97 */ "compare_op ::= NK_LT",
+ /* 98 */ "compare_op ::= NK_GT",
+ /* 99 */ "compare_op ::= NK_LE",
+ /* 100 */ "compare_op ::= NK_GE",
+ /* 101 */ "compare_op ::= NK_NE",
+ /* 102 */ "compare_op ::= NK_EQ",
+ /* 103 */ "compare_op ::= LIKE",
+ /* 104 */ "compare_op ::= NOT LIKE",
+ /* 105 */ "compare_op ::= MATCH",
+ /* 106 */ "compare_op ::= NMATCH",
+ /* 107 */ "in_op ::= IN",
+ /* 108 */ "in_op ::= NOT IN",
+ /* 109 */ "in_predicate_value ::= NK_LP expression_list NK_RP",
+ /* 110 */ "boolean_value_expression ::= boolean_primary",
+ /* 111 */ "boolean_value_expression ::= NOT boolean_primary",
+ /* 112 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
+ /* 113 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
+ /* 114 */ "boolean_primary ::= predicate",
+ /* 115 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
+ /* 116 */ "common_expression ::= expression",
+ /* 117 */ "common_expression ::= boolean_value_expression",
+ /* 118 */ "from_clause ::= FROM table_reference_list",
+ /* 119 */ "table_reference_list ::= table_reference",
+ /* 120 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
+ /* 121 */ "table_reference ::= table_primary",
+ /* 122 */ "table_reference ::= joined_table",
+ /* 123 */ "table_primary ::= table_name alias_opt",
+ /* 124 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
+ /* 125 */ "table_primary ::= subquery alias_opt",
+ /* 126 */ "table_primary ::= parenthesized_joined_table",
+ /* 127 */ "alias_opt ::=",
+ /* 128 */ "alias_opt ::= table_alias",
+ /* 129 */ "alias_opt ::= AS table_alias",
+ /* 130 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
+ /* 131 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
+ /* 132 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
+ /* 133 */ "join_type ::=",
+ /* 134 */ "join_type ::= INNER",
+ /* 135 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
+ /* 136 */ "set_quantifier_opt ::=",
+ /* 137 */ "set_quantifier_opt ::= DISTINCT",
+ /* 138 */ "set_quantifier_opt ::= ALL",
+ /* 139 */ "select_list ::= NK_STAR",
+ /* 140 */ "select_list ::= select_sublist",
+ /* 141 */ "select_sublist ::= select_item",
+ /* 142 */ "select_sublist ::= select_sublist NK_COMMA select_item",
+ /* 143 */ "select_item ::= common_expression",
+ /* 144 */ "select_item ::= common_expression column_alias",
+ /* 145 */ "select_item ::= common_expression AS column_alias",
+ /* 146 */ "select_item ::= table_name NK_DOT NK_STAR",
+ /* 147 */ "where_clause_opt ::=",
+ /* 148 */ "where_clause_opt ::= WHERE search_condition",
+ /* 149 */ "partition_by_clause_opt ::=",
+ /* 150 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
+ /* 151 */ "twindow_clause_opt ::=",
+ /* 152 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP",
+ /* 153 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP",
+ /* 154 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
+ /* 155 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
+ /* 156 */ "sliding_opt ::=",
+ /* 157 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
+ /* 158 */ "fill_opt ::=",
+ /* 159 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
+ /* 160 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
+ /* 161 */ "fill_mode ::= NONE",
+ /* 162 */ "fill_mode ::= PREV",
+ /* 163 */ "fill_mode ::= NULL",
+ /* 164 */ "fill_mode ::= LINEAR",
+ /* 165 */ "fill_mode ::= NEXT",
+ /* 166 */ "group_by_clause_opt ::=",
+ /* 167 */ "group_by_clause_opt ::= GROUP BY group_by_list",
+ /* 168 */ "group_by_list ::= expression",
+ /* 169 */ "group_by_list ::= group_by_list NK_COMMA expression",
+ /* 170 */ "having_clause_opt ::=",
+ /* 171 */ "having_clause_opt ::= HAVING search_condition",
+ /* 172 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
+ /* 173 */ "query_expression_body ::= query_primary",
+ /* 174 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
+ /* 175 */ "query_primary ::= query_specification",
+ /* 176 */ "order_by_clause_opt ::=",
+ /* 177 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
+ /* 178 */ "slimit_clause_opt ::=",
+ /* 179 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
+ /* 180 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
+ /* 181 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 182 */ "limit_clause_opt ::=",
+ /* 183 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
+ /* 184 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
+ /* 185 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 186 */ "subquery ::= NK_LP query_expression NK_RP",
+ /* 187 */ "search_condition ::= common_expression",
+ /* 188 */ "sort_specification_list ::= sort_specification",
+ /* 189 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
+ /* 190 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt",
+ /* 191 */ "ordering_specification_opt ::=",
+ /* 192 */ "ordering_specification_opt ::= ASC",
+ /* 193 */ "ordering_specification_opt ::= DESC",
+ /* 194 */ "null_ordering_opt ::=",
+ /* 195 */ "null_ordering_opt ::= NULLS FIRST",
+ /* 196 */ "null_ordering_opt ::= NULLS LAST",
};
#endif /* NDEBUG */
@@ -977,98 +1084,119 @@ static void yy_destructor(
*/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
- case 96: /* cmd */
- case 97: /* exists_opt */
- case 100: /* query_expression */
- case 101: /* literal */
- case 102: /* duration_literal */
- case 109: /* expression */
- case 110: /* column_reference */
- case 112: /* subquery */
- case 113: /* predicate */
- case 116: /* in_predicate_value */
- case 117: /* boolean_value_expression */
- case 118: /* boolean_primary */
- case 119: /* common_expression */
- case 120: /* from_clause */
- case 121: /* table_reference_list */
- case 122: /* table_reference */
- case 123: /* table_primary */
- case 124: /* joined_table */
- case 126: /* parenthesized_joined_table */
- case 128: /* search_condition */
- case 129: /* query_specification */
- case 132: /* where_clause_opt */
- case 134: /* twindow_clause_opt */
- case 136: /* having_clause_opt */
- case 138: /* select_item */
- case 139: /* sliding_opt */
- case 140: /* fill_opt */
- case 143: /* query_expression_body */
- case 145: /* slimit_clause_opt */
- case 146: /* limit_clause_opt */
- case 147: /* query_primary */
- case 149: /* sort_specification */
+ case 119: /* cmd */
+ case 120: /* exists_opt */
+ case 126: /* column_def */
+ case 129: /* query_expression */
+ case 130: /* literal */
+ case 131: /* duration_literal */
+ case 137: /* expression */
+ case 138: /* column_reference */
+ case 140: /* subquery */
+ case 141: /* predicate */
+ case 144: /* in_predicate_value */
+ case 145: /* boolean_value_expression */
+ case 146: /* boolean_primary */
+ case 147: /* common_expression */
+ case 148: /* from_clause */
+ case 149: /* table_reference_list */
+ case 150: /* table_reference */
+ case 151: /* table_primary */
+ case 152: /* joined_table */
+ case 154: /* parenthesized_joined_table */
+ case 156: /* search_condition */
+ case 157: /* query_specification */
+ case 160: /* where_clause_opt */
+ case 162: /* twindow_clause_opt */
+ case 164: /* having_clause_opt */
+ case 166: /* select_item */
+ case 167: /* sliding_opt */
+ case 168: /* fill_opt */
+ case 171: /* query_expression_body */
+ case 173: /* slimit_clause_opt */
+ case 174: /* limit_clause_opt */
+ case 175: /* query_primary */
+ case 177: /* sort_specification */
{
- PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy104));
+ PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy272));
}
break;
- case 98: /* db_name */
- case 104: /* table_name */
- case 105: /* column_name */
- case 106: /* function_name */
- case 107: /* table_alias */
- case 108: /* column_alias */
- case 125: /* alias_opt */
+ case 121: /* db_name */
+ case 127: /* column_name */
+ case 133: /* table_name */
+ case 134: /* function_name */
+ case 135: /* table_alias */
+ case 136: /* column_alias */
+ case 153: /* alias_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 99: /* db_options */
+ case 122: /* db_options */
{
- tfree((yypminor->yy87));
+ tfree((yypminor->yy199));
}
break;
- case 103: /* literal_list */
- case 111: /* expression_list */
- case 131: /* select_list */
- case 133: /* partition_by_clause_opt */
- case 135: /* group_by_clause_opt */
- case 137: /* select_sublist */
- case 142: /* group_by_list */
- case 144: /* order_by_clause_opt */
- case 148: /* sort_specification_list */
+ case 123: /* full_table_name */
{
- PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy8));
+
}
break;
- case 114: /* compare_op */
- case 115: /* in_op */
+ case 124: /* column_def_list */
+{
+ nodesDestroyList((yypminor->yy64));
+}
+ break;
+ case 125: /* table_options */
+{
+ tfree((yypminor->yy46));
+}
+ break;
+ case 128: /* type_name */
+{
+
+}
+ break;
+ case 132: /* literal_list */
+ case 139: /* expression_list */
+ case 159: /* select_list */
+ case 161: /* partition_by_clause_opt */
+ case 163: /* group_by_clause_opt */
+ case 165: /* select_sublist */
+ case 170: /* group_by_list */
+ case 172: /* order_by_clause_opt */
+ case 176: /* sort_specification_list */
+{
+ PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy64));
+}
+ break;
+ case 142: /* compare_op */
+ case 143: /* in_op */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 127: /* join_type */
+ case 155: /* join_type */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 130: /* set_quantifier_opt */
+ case 158: /* set_quantifier_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 141: /* fill_mode */
+ case 169: /* fill_mode */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 150: /* ordering_specification_opt */
+ case 178: /* ordering_specification_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
- case 151: /* null_ordering_opt */
+ case 179: /* null_ordering_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
@@ -1367,166 +1495,203 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 96, -5 }, /* (0) cmd ::= CREATE DATABASE exists_opt db_name db_options */
- { 97, -3 }, /* (1) exists_opt ::= IF NOT EXISTS */
- { 97, 0 }, /* (2) exists_opt ::= */
- { 99, 0 }, /* (3) db_options ::= */
- { 99, -3 }, /* (4) db_options ::= db_options BLOCKS NK_INTEGER */
- { 99, -3 }, /* (5) db_options ::= db_options CACHE NK_INTEGER */
- { 99, -3 }, /* (6) db_options ::= db_options CACHELAST NK_INTEGER */
- { 99, -3 }, /* (7) db_options ::= db_options COMP NK_INTEGER */
- { 99, -3 }, /* (8) db_options ::= db_options DAYS NK_INTEGER */
- { 99, -3 }, /* (9) db_options ::= db_options FSYNC NK_INTEGER */
- { 99, -3 }, /* (10) db_options ::= db_options MAXROWS NK_INTEGER */
- { 99, -3 }, /* (11) db_options ::= db_options MINROWS NK_INTEGER */
- { 99, -3 }, /* (12) db_options ::= db_options KEEP NK_INTEGER */
- { 99, -3 }, /* (13) db_options ::= db_options PRECISION NK_STRING */
- { 99, -3 }, /* (14) db_options ::= db_options QUORUM NK_INTEGER */
- { 99, -3 }, /* (15) db_options ::= db_options REPLICA NK_INTEGER */
- { 99, -3 }, /* (16) db_options ::= db_options TTL NK_INTEGER */
- { 99, -3 }, /* (17) db_options ::= db_options WAL NK_INTEGER */
- { 99, -3 }, /* (18) db_options ::= db_options VGROUPS NK_INTEGER */
- { 99, -3 }, /* (19) db_options ::= db_options SINGLESTABLE NK_INTEGER */
- { 99, -3 }, /* (20) db_options ::= db_options STREAMMODE NK_INTEGER */
- { 96, -1 }, /* (21) cmd ::= query_expression */
- { 101, -1 }, /* (22) literal ::= NK_INTEGER */
- { 101, -1 }, /* (23) literal ::= NK_FLOAT */
- { 101, -1 }, /* (24) literal ::= NK_STRING */
- { 101, -1 }, /* (25) literal ::= NK_BOOL */
- { 101, -2 }, /* (26) literal ::= TIMESTAMP NK_STRING */
- { 101, -1 }, /* (27) literal ::= duration_literal */
- { 102, -1 }, /* (28) duration_literal ::= NK_VARIABLE */
- { 103, -1 }, /* (29) literal_list ::= literal */
- { 103, -3 }, /* (30) literal_list ::= literal_list NK_COMMA literal */
- { 98, -1 }, /* (31) db_name ::= NK_ID */
- { 104, -1 }, /* (32) table_name ::= NK_ID */
- { 105, -1 }, /* (33) column_name ::= NK_ID */
- { 106, -1 }, /* (34) function_name ::= NK_ID */
- { 107, -1 }, /* (35) table_alias ::= NK_ID */
- { 108, -1 }, /* (36) column_alias ::= NK_ID */
- { 109, -1 }, /* (37) expression ::= literal */
- { 109, -1 }, /* (38) expression ::= column_reference */
- { 109, -4 }, /* (39) expression ::= function_name NK_LP expression_list NK_RP */
- { 109, -4 }, /* (40) expression ::= function_name NK_LP NK_STAR NK_RP */
- { 109, -1 }, /* (41) expression ::= subquery */
- { 109, -3 }, /* (42) expression ::= NK_LP expression NK_RP */
- { 109, -2 }, /* (43) expression ::= NK_PLUS expression */
- { 109, -2 }, /* (44) expression ::= NK_MINUS expression */
- { 109, -3 }, /* (45) expression ::= expression NK_PLUS expression */
- { 109, -3 }, /* (46) expression ::= expression NK_MINUS expression */
- { 109, -3 }, /* (47) expression ::= expression NK_STAR expression */
- { 109, -3 }, /* (48) expression ::= expression NK_SLASH expression */
- { 109, -3 }, /* (49) expression ::= expression NK_REM expression */
- { 111, -1 }, /* (50) expression_list ::= expression */
- { 111, -3 }, /* (51) expression_list ::= expression_list NK_COMMA expression */
- { 110, -1 }, /* (52) column_reference ::= column_name */
- { 110, -3 }, /* (53) column_reference ::= table_name NK_DOT column_name */
- { 113, -3 }, /* (54) predicate ::= expression compare_op expression */
- { 113, -5 }, /* (55) predicate ::= expression BETWEEN expression AND expression */
- { 113, -6 }, /* (56) predicate ::= expression NOT BETWEEN expression AND expression */
- { 113, -3 }, /* (57) predicate ::= expression IS NULL */
- { 113, -4 }, /* (58) predicate ::= expression IS NOT NULL */
- { 113, -3 }, /* (59) predicate ::= expression in_op in_predicate_value */
- { 114, -1 }, /* (60) compare_op ::= NK_LT */
- { 114, -1 }, /* (61) compare_op ::= NK_GT */
- { 114, -1 }, /* (62) compare_op ::= NK_LE */
- { 114, -1 }, /* (63) compare_op ::= NK_GE */
- { 114, -1 }, /* (64) compare_op ::= NK_NE */
- { 114, -1 }, /* (65) compare_op ::= NK_EQ */
- { 114, -1 }, /* (66) compare_op ::= LIKE */
- { 114, -2 }, /* (67) compare_op ::= NOT LIKE */
- { 114, -1 }, /* (68) compare_op ::= MATCH */
- { 114, -1 }, /* (69) compare_op ::= NMATCH */
- { 115, -1 }, /* (70) in_op ::= IN */
- { 115, -2 }, /* (71) in_op ::= NOT IN */
- { 116, -3 }, /* (72) in_predicate_value ::= NK_LP expression_list NK_RP */
- { 117, -1 }, /* (73) boolean_value_expression ::= boolean_primary */
- { 117, -2 }, /* (74) boolean_value_expression ::= NOT boolean_primary */
- { 117, -3 }, /* (75) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
- { 117, -3 }, /* (76) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
- { 118, -1 }, /* (77) boolean_primary ::= predicate */
- { 118, -3 }, /* (78) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
- { 119, -1 }, /* (79) common_expression ::= expression */
- { 119, -1 }, /* (80) common_expression ::= boolean_value_expression */
- { 120, -2 }, /* (81) from_clause ::= FROM table_reference_list */
- { 121, -1 }, /* (82) table_reference_list ::= table_reference */
- { 121, -3 }, /* (83) table_reference_list ::= table_reference_list NK_COMMA table_reference */
- { 122, -1 }, /* (84) table_reference ::= table_primary */
- { 122, -1 }, /* (85) table_reference ::= joined_table */
- { 123, -2 }, /* (86) table_primary ::= table_name alias_opt */
- { 123, -4 }, /* (87) table_primary ::= db_name NK_DOT table_name alias_opt */
- { 123, -2 }, /* (88) table_primary ::= subquery alias_opt */
- { 123, -1 }, /* (89) table_primary ::= parenthesized_joined_table */
- { 125, 0 }, /* (90) alias_opt ::= */
- { 125, -1 }, /* (91) alias_opt ::= table_alias */
- { 125, -2 }, /* (92) alias_opt ::= AS table_alias */
- { 126, -3 }, /* (93) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- { 126, -3 }, /* (94) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
- { 124, -6 }, /* (95) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
- { 127, 0 }, /* (96) join_type ::= */
- { 127, -1 }, /* (97) join_type ::= INNER */
- { 129, -9 }, /* (98) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
- { 130, 0 }, /* (99) set_quantifier_opt ::= */
- { 130, -1 }, /* (100) set_quantifier_opt ::= DISTINCT */
- { 130, -1 }, /* (101) set_quantifier_opt ::= ALL */
- { 131, -1 }, /* (102) select_list ::= NK_STAR */
- { 131, -1 }, /* (103) select_list ::= select_sublist */
- { 137, -1 }, /* (104) select_sublist ::= select_item */
- { 137, -3 }, /* (105) select_sublist ::= select_sublist NK_COMMA select_item */
- { 138, -1 }, /* (106) select_item ::= common_expression */
- { 138, -2 }, /* (107) select_item ::= common_expression column_alias */
- { 138, -3 }, /* (108) select_item ::= common_expression AS column_alias */
- { 138, -3 }, /* (109) select_item ::= table_name NK_DOT NK_STAR */
- { 132, 0 }, /* (110) where_clause_opt ::= */
- { 132, -2 }, /* (111) where_clause_opt ::= WHERE search_condition */
- { 133, 0 }, /* (112) partition_by_clause_opt ::= */
- { 133, -3 }, /* (113) partition_by_clause_opt ::= PARTITION BY expression_list */
- { 134, 0 }, /* (114) twindow_clause_opt ::= */
- { 134, -6 }, /* (115) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
- { 134, -4 }, /* (116) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
- { 134, -6 }, /* (117) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
- { 134, -8 }, /* (118) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
- { 139, 0 }, /* (119) sliding_opt ::= */
- { 139, -4 }, /* (120) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
- { 140, 0 }, /* (121) fill_opt ::= */
- { 140, -4 }, /* (122) fill_opt ::= FILL NK_LP fill_mode NK_RP */
- { 140, -6 }, /* (123) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
- { 141, -1 }, /* (124) fill_mode ::= NONE */
- { 141, -1 }, /* (125) fill_mode ::= PREV */
- { 141, -1 }, /* (126) fill_mode ::= NULL */
- { 141, -1 }, /* (127) fill_mode ::= LINEAR */
- { 141, -1 }, /* (128) fill_mode ::= NEXT */
- { 135, 0 }, /* (129) group_by_clause_opt ::= */
- { 135, -3 }, /* (130) group_by_clause_opt ::= GROUP BY group_by_list */
- { 142, -1 }, /* (131) group_by_list ::= expression */
- { 142, -3 }, /* (132) group_by_list ::= group_by_list NK_COMMA expression */
- { 136, 0 }, /* (133) having_clause_opt ::= */
- { 136, -2 }, /* (134) having_clause_opt ::= HAVING search_condition */
- { 100, -4 }, /* (135) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
- { 143, -1 }, /* (136) query_expression_body ::= query_primary */
- { 143, -4 }, /* (137) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
- { 147, -1 }, /* (138) query_primary ::= query_specification */
- { 144, 0 }, /* (139) order_by_clause_opt ::= */
- { 144, -3 }, /* (140) order_by_clause_opt ::= ORDER BY sort_specification_list */
- { 145, 0 }, /* (141) slimit_clause_opt ::= */
- { 145, -2 }, /* (142) slimit_clause_opt ::= SLIMIT NK_INTEGER */
- { 145, -4 }, /* (143) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- { 145, -4 }, /* (144) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 146, 0 }, /* (145) limit_clause_opt ::= */
- { 146, -2 }, /* (146) limit_clause_opt ::= LIMIT NK_INTEGER */
- { 146, -4 }, /* (147) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
- { 146, -4 }, /* (148) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 112, -3 }, /* (149) subquery ::= NK_LP query_expression NK_RP */
- { 128, -1 }, /* (150) search_condition ::= common_expression */
- { 148, -1 }, /* (151) sort_specification_list ::= sort_specification */
- { 148, -3 }, /* (152) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
- { 149, -3 }, /* (153) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
- { 150, 0 }, /* (154) ordering_specification_opt ::= */
- { 150, -1 }, /* (155) ordering_specification_opt ::= ASC */
- { 150, -1 }, /* (156) ordering_specification_opt ::= DESC */
- { 151, 0 }, /* (157) null_ordering_opt ::= */
- { 151, -2 }, /* (158) null_ordering_opt ::= NULLS FIRST */
- { 151, -2 }, /* (159) null_ordering_opt ::= NULLS LAST */
+ { 119, -5 }, /* (0) cmd ::= CREATE DATABASE exists_opt db_name db_options */
+ { 120, -3 }, /* (1) exists_opt ::= IF NOT EXISTS */
+ { 120, 0 }, /* (2) exists_opt ::= */
+ { 122, 0 }, /* (3) db_options ::= */
+ { 122, -3 }, /* (4) db_options ::= db_options BLOCKS NK_INTEGER */
+ { 122, -3 }, /* (5) db_options ::= db_options CACHE NK_INTEGER */
+ { 122, -3 }, /* (6) db_options ::= db_options CACHELAST NK_INTEGER */
+ { 122, -3 }, /* (7) db_options ::= db_options COMP NK_INTEGER */
+ { 122, -3 }, /* (8) db_options ::= db_options DAYS NK_INTEGER */
+ { 122, -3 }, /* (9) db_options ::= db_options FSYNC NK_INTEGER */
+ { 122, -3 }, /* (10) db_options ::= db_options MAXROWS NK_INTEGER */
+ { 122, -3 }, /* (11) db_options ::= db_options MINROWS NK_INTEGER */
+ { 122, -3 }, /* (12) db_options ::= db_options KEEP NK_INTEGER */
+ { 122, -3 }, /* (13) db_options ::= db_options PRECISION NK_STRING */
+ { 122, -3 }, /* (14) db_options ::= db_options QUORUM NK_INTEGER */
+ { 122, -3 }, /* (15) db_options ::= db_options REPLICA NK_INTEGER */
+ { 122, -3 }, /* (16) db_options ::= db_options TTL NK_INTEGER */
+ { 122, -3 }, /* (17) db_options ::= db_options WAL NK_INTEGER */
+ { 122, -3 }, /* (18) db_options ::= db_options VGROUPS NK_INTEGER */
+ { 122, -3 }, /* (19) db_options ::= db_options SINGLESTABLE NK_INTEGER */
+ { 122, -3 }, /* (20) db_options ::= db_options STREAMMODE NK_INTEGER */
+ { 119, -2 }, /* (21) cmd ::= USE db_name */
+ { 119, -8 }, /* (22) cmd ::= CREATE TABLE exists_opt full_table_name NK_LP column_def_list NK_RP table_options */
+ { 123, -1 }, /* (23) full_table_name ::= NK_ID */
+ { 123, -3 }, /* (24) full_table_name ::= NK_ID NK_DOT NK_ID */
+ { 124, -1 }, /* (25) column_def_list ::= column_def */
+ { 124, -3 }, /* (26) column_def_list ::= column_def_list NK_COMMA column_def */
+ { 126, -2 }, /* (27) column_def ::= column_name type_name */
+ { 126, -4 }, /* (28) column_def ::= column_name type_name COMMENT NK_STRING */
+ { 128, -1 }, /* (29) type_name ::= BOOL */
+ { 128, -1 }, /* (30) type_name ::= TINYINT */
+ { 128, -1 }, /* (31) type_name ::= SMALLINT */
+ { 128, -1 }, /* (32) type_name ::= INT */
+ { 128, -1 }, /* (33) type_name ::= INTEGER */
+ { 128, -1 }, /* (34) type_name ::= BIGINT */
+ { 128, -1 }, /* (35) type_name ::= FLOAT */
+ { 128, -1 }, /* (36) type_name ::= DOUBLE */
+ { 128, -4 }, /* (37) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+ { 128, -1 }, /* (38) type_name ::= TIMESTAMP */
+ { 128, -4 }, /* (39) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+ { 128, -2 }, /* (40) type_name ::= TINYINT UNSIGNED */
+ { 128, -2 }, /* (41) type_name ::= SMALLINT UNSIGNED */
+ { 128, -2 }, /* (42) type_name ::= INT UNSIGNED */
+ { 128, -2 }, /* (43) type_name ::= BIGINT UNSIGNED */
+ { 128, -1 }, /* (44) type_name ::= JSON */
+ { 128, -4 }, /* (45) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+ { 128, -1 }, /* (46) type_name ::= MEDIUMBLOB */
+ { 128, -1 }, /* (47) type_name ::= BLOB */
+ { 128, -4 }, /* (48) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+ { 128, -1 }, /* (49) type_name ::= DECIMAL */
+ { 128, -4 }, /* (50) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+ { 128, -6 }, /* (51) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+ { 125, 0 }, /* (52) table_options ::= */
+ { 125, -3 }, /* (53) table_options ::= table_options COMMENT NK_INTEGER */
+ { 125, -3 }, /* (54) table_options ::= table_options KEEP NK_INTEGER */
+ { 125, -3 }, /* (55) table_options ::= table_options TTL NK_INTEGER */
+ { 119, -2 }, /* (56) cmd ::= SHOW DATABASES */
+ { 119, -2 }, /* (57) cmd ::= SHOW TABLES */
+ { 119, -1 }, /* (58) cmd ::= query_expression */
+ { 130, -1 }, /* (59) literal ::= NK_INTEGER */
+ { 130, -1 }, /* (60) literal ::= NK_FLOAT */
+ { 130, -1 }, /* (61) literal ::= NK_STRING */
+ { 130, -1 }, /* (62) literal ::= NK_BOOL */
+ { 130, -2 }, /* (63) literal ::= TIMESTAMP NK_STRING */
+ { 130, -1 }, /* (64) literal ::= duration_literal */
+ { 131, -1 }, /* (65) duration_literal ::= NK_VARIABLE */
+ { 132, -1 }, /* (66) literal_list ::= literal */
+ { 132, -3 }, /* (67) literal_list ::= literal_list NK_COMMA literal */
+ { 121, -1 }, /* (68) db_name ::= NK_ID */
+ { 133, -1 }, /* (69) table_name ::= NK_ID */
+ { 127, -1 }, /* (70) column_name ::= NK_ID */
+ { 134, -1 }, /* (71) function_name ::= NK_ID */
+ { 135, -1 }, /* (72) table_alias ::= NK_ID */
+ { 136, -1 }, /* (73) column_alias ::= NK_ID */
+ { 137, -1 }, /* (74) expression ::= literal */
+ { 137, -1 }, /* (75) expression ::= column_reference */
+ { 137, -4 }, /* (76) expression ::= function_name NK_LP expression_list NK_RP */
+ { 137, -4 }, /* (77) expression ::= function_name NK_LP NK_STAR NK_RP */
+ { 137, -1 }, /* (78) expression ::= subquery */
+ { 137, -3 }, /* (79) expression ::= NK_LP expression NK_RP */
+ { 137, -2 }, /* (80) expression ::= NK_PLUS expression */
+ { 137, -2 }, /* (81) expression ::= NK_MINUS expression */
+ { 137, -3 }, /* (82) expression ::= expression NK_PLUS expression */
+ { 137, -3 }, /* (83) expression ::= expression NK_MINUS expression */
+ { 137, -3 }, /* (84) expression ::= expression NK_STAR expression */
+ { 137, -3 }, /* (85) expression ::= expression NK_SLASH expression */
+ { 137, -3 }, /* (86) expression ::= expression NK_REM expression */
+ { 139, -1 }, /* (87) expression_list ::= expression */
+ { 139, -3 }, /* (88) expression_list ::= expression_list NK_COMMA expression */
+ { 138, -1 }, /* (89) column_reference ::= column_name */
+ { 138, -3 }, /* (90) column_reference ::= table_name NK_DOT column_name */
+ { 141, -3 }, /* (91) predicate ::= expression compare_op expression */
+ { 141, -5 }, /* (92) predicate ::= expression BETWEEN expression AND expression */
+ { 141, -6 }, /* (93) predicate ::= expression NOT BETWEEN expression AND expression */
+ { 141, -3 }, /* (94) predicate ::= expression IS NULL */
+ { 141, -4 }, /* (95) predicate ::= expression IS NOT NULL */
+ { 141, -3 }, /* (96) predicate ::= expression in_op in_predicate_value */
+ { 142, -1 }, /* (97) compare_op ::= NK_LT */
+ { 142, -1 }, /* (98) compare_op ::= NK_GT */
+ { 142, -1 }, /* (99) compare_op ::= NK_LE */
+ { 142, -1 }, /* (100) compare_op ::= NK_GE */
+ { 142, -1 }, /* (101) compare_op ::= NK_NE */
+ { 142, -1 }, /* (102) compare_op ::= NK_EQ */
+ { 142, -1 }, /* (103) compare_op ::= LIKE */
+ { 142, -2 }, /* (104) compare_op ::= NOT LIKE */
+ { 142, -1 }, /* (105) compare_op ::= MATCH */
+ { 142, -1 }, /* (106) compare_op ::= NMATCH */
+ { 143, -1 }, /* (107) in_op ::= IN */
+ { 143, -2 }, /* (108) in_op ::= NOT IN */
+ { 144, -3 }, /* (109) in_predicate_value ::= NK_LP expression_list NK_RP */
+ { 145, -1 }, /* (110) boolean_value_expression ::= boolean_primary */
+ { 145, -2 }, /* (111) boolean_value_expression ::= NOT boolean_primary */
+ { 145, -3 }, /* (112) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ { 145, -3 }, /* (113) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ { 146, -1 }, /* (114) boolean_primary ::= predicate */
+ { 146, -3 }, /* (115) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
+ { 147, -1 }, /* (116) common_expression ::= expression */
+ { 147, -1 }, /* (117) common_expression ::= boolean_value_expression */
+ { 148, -2 }, /* (118) from_clause ::= FROM table_reference_list */
+ { 149, -1 }, /* (119) table_reference_list ::= table_reference */
+ { 149, -3 }, /* (120) table_reference_list ::= table_reference_list NK_COMMA table_reference */
+ { 150, -1 }, /* (121) table_reference ::= table_primary */
+ { 150, -1 }, /* (122) table_reference ::= joined_table */
+ { 151, -2 }, /* (123) table_primary ::= table_name alias_opt */
+ { 151, -4 }, /* (124) table_primary ::= db_name NK_DOT table_name alias_opt */
+ { 151, -2 }, /* (125) table_primary ::= subquery alias_opt */
+ { 151, -1 }, /* (126) table_primary ::= parenthesized_joined_table */
+ { 153, 0 }, /* (127) alias_opt ::= */
+ { 153, -1 }, /* (128) alias_opt ::= table_alias */
+ { 153, -2 }, /* (129) alias_opt ::= AS table_alias */
+ { 154, -3 }, /* (130) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ { 154, -3 }, /* (131) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
+ { 152, -6 }, /* (132) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+ { 155, 0 }, /* (133) join_type ::= */
+ { 155, -1 }, /* (134) join_type ::= INNER */
+ { 157, -9 }, /* (135) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ { 158, 0 }, /* (136) set_quantifier_opt ::= */
+ { 158, -1 }, /* (137) set_quantifier_opt ::= DISTINCT */
+ { 158, -1 }, /* (138) set_quantifier_opt ::= ALL */
+ { 159, -1 }, /* (139) select_list ::= NK_STAR */
+ { 159, -1 }, /* (140) select_list ::= select_sublist */
+ { 165, -1 }, /* (141) select_sublist ::= select_item */
+ { 165, -3 }, /* (142) select_sublist ::= select_sublist NK_COMMA select_item */
+ { 166, -1 }, /* (143) select_item ::= common_expression */
+ { 166, -2 }, /* (144) select_item ::= common_expression column_alias */
+ { 166, -3 }, /* (145) select_item ::= common_expression AS column_alias */
+ { 166, -3 }, /* (146) select_item ::= table_name NK_DOT NK_STAR */
+ { 160, 0 }, /* (147) where_clause_opt ::= */
+ { 160, -2 }, /* (148) where_clause_opt ::= WHERE search_condition */
+ { 161, 0 }, /* (149) partition_by_clause_opt ::= */
+ { 161, -3 }, /* (150) partition_by_clause_opt ::= PARTITION BY expression_list */
+ { 162, 0 }, /* (151) twindow_clause_opt ::= */
+ { 162, -6 }, /* (152) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
+ { 162, -4 }, /* (153) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
+ { 162, -6 }, /* (154) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+ { 162, -8 }, /* (155) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+ { 167, 0 }, /* (156) sliding_opt ::= */
+ { 167, -4 }, /* (157) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
+ { 168, 0 }, /* (158) fill_opt ::= */
+ { 168, -4 }, /* (159) fill_opt ::= FILL NK_LP fill_mode NK_RP */
+ { 168, -6 }, /* (160) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+ { 169, -1 }, /* (161) fill_mode ::= NONE */
+ { 169, -1 }, /* (162) fill_mode ::= PREV */
+ { 169, -1 }, /* (163) fill_mode ::= NULL */
+ { 169, -1 }, /* (164) fill_mode ::= LINEAR */
+ { 169, -1 }, /* (165) fill_mode ::= NEXT */
+ { 163, 0 }, /* (166) group_by_clause_opt ::= */
+ { 163, -3 }, /* (167) group_by_clause_opt ::= GROUP BY group_by_list */
+ { 170, -1 }, /* (168) group_by_list ::= expression */
+ { 170, -3 }, /* (169) group_by_list ::= group_by_list NK_COMMA expression */
+ { 164, 0 }, /* (170) having_clause_opt ::= */
+ { 164, -2 }, /* (171) having_clause_opt ::= HAVING search_condition */
+ { 129, -4 }, /* (172) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ { 171, -1 }, /* (173) query_expression_body ::= query_primary */
+ { 171, -4 }, /* (174) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
+ { 175, -1 }, /* (175) query_primary ::= query_specification */
+ { 172, 0 }, /* (176) order_by_clause_opt ::= */
+ { 172, -3 }, /* (177) order_by_clause_opt ::= ORDER BY sort_specification_list */
+ { 173, 0 }, /* (178) slimit_clause_opt ::= */
+ { 173, -2 }, /* (179) slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ { 173, -4 }, /* (180) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ { 173, -4 }, /* (181) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 174, 0 }, /* (182) limit_clause_opt ::= */
+ { 174, -2 }, /* (183) limit_clause_opt ::= LIMIT NK_INTEGER */
+ { 174, -4 }, /* (184) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
+ { 174, -4 }, /* (185) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 140, -3 }, /* (186) subquery ::= NK_LP query_expression NK_RP */
+ { 156, -1 }, /* (187) search_condition ::= common_expression */
+ { 176, -1 }, /* (188) sort_specification_list ::= sort_specification */
+ { 176, -3 }, /* (189) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
+ { 177, -3 }, /* (190) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
+ { 178, 0 }, /* (191) ordering_specification_opt ::= */
+ { 178, -1 }, /* (192) ordering_specification_opt ::= ASC */
+ { 178, -1 }, /* (193) ordering_specification_opt ::= DESC */
+ { 179, 0 }, /* (194) null_ordering_opt ::= */
+ { 179, -2 }, /* (195) null_ordering_opt ::= NULLS FIRST */
+ { 179, -2 }, /* (196) null_ordering_opt ::= NULLS LAST */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -1614,562 +1779,680 @@ static YYACTIONTYPE yy_reduce(
/********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor;
case 0: /* cmd ::= CREATE DATABASE exists_opt db_name db_options */
-{ PARSER_TRACE; pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy129, yymsp[0].minor.yy87);}
+{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy137, &yymsp[-1].minor.yy209, yymsp[0].minor.yy199);}
break;
case 1: /* exists_opt ::= IF NOT EXISTS */
-{ yymsp[-2].minor.yy185 = true; }
+{ yymsp[-2].minor.yy137 = true; }
break;
case 2: /* exists_opt ::= */
-{ yymsp[1].minor.yy185 = false; }
+{ yymsp[1].minor.yy137 = false; }
break;
case 3: /* db_options ::= */
-{ yymsp[1].minor.yy87 = createDefaultDatabaseOptions(pCxt);}
+{ yymsp[1].minor.yy199 = createDefaultDatabaseOptions(pCxt); }
break;
case 4: /* db_options ::= db_options BLOCKS NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 5: /* db_options ::= db_options CACHE NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_CACHE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_CACHE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 6: /* db_options ::= db_options CACHELAST NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 7: /* db_options ::= db_options COMP NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 8: /* db_options ::= db_options DAYS NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 9: /* db_options ::= db_options FSYNC NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 10: /* db_options ::= db_options MAXROWS NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 11: /* db_options ::= db_options MINROWS NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 12: /* db_options ::= db_options KEEP NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_KEEP, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_KEEP, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 13: /* db_options ::= db_options PRECISION NK_STRING */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 14: /* db_options ::= db_options QUORUM NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 15: /* db_options ::= db_options REPLICA NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 16: /* db_options ::= db_options TTL NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_TTL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_TTL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 17: /* db_options ::= db_options WAL NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 18: /* db_options ::= db_options VGROUPS NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 19: /* db_options ::= db_options SINGLESTABLE NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
case 20: /* db_options ::= db_options STREAMMODE NK_INTEGER */
-{ yylhsminor.yy87 = setDatabaseOption(pCxt, yymsp[-2].minor.yy87, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy87 = yylhsminor.yy87;
+{ yylhsminor.yy199 = setDatabaseOption(pCxt, yymsp[-2].minor.yy199, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy199 = yylhsminor.yy199;
break;
- case 21: /* cmd ::= query_expression */
-{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy104; }
+ case 21: /* cmd ::= USE db_name */
+{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209);}
break;
- case 22: /* literal ::= NK_INTEGER */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 22: /* cmd ::= CREATE TABLE exists_opt full_table_name NK_LP column_def_list NK_RP table_options */
+{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-5].minor.yy137, &yymsp[-4].minor.yy57, yymsp[-2].minor.yy64, yymsp[0].minor.yy46);}
break;
- case 23: /* literal ::= NK_FLOAT */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 23: /* full_table_name ::= NK_ID */
+{ STokenPair t = { .first = nil_token, .second = yymsp[0].minor.yy0 }; yylhsminor.yy57 = t; }
+ yymsp[0].minor.yy57 = yylhsminor.yy57;
break;
- case 24: /* literal ::= NK_STRING */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 24: /* full_table_name ::= NK_ID NK_DOT NK_ID */
+{ STokenPair t = { .first = yymsp[-2].minor.yy0, .second = yymsp[0].minor.yy0 }; yylhsminor.yy57 = t; }
+ yymsp[-2].minor.yy57 = yylhsminor.yy57;
break;
- case 25: /* literal ::= NK_BOOL */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 25: /* column_def_list ::= column_def */
+{ yylhsminor.yy64 = createNodeList(pCxt, yymsp[0].minor.yy272); }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 26: /* literal ::= TIMESTAMP NK_STRING */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ case 26: /* column_def_list ::= column_def_list NK_COMMA column_def */
+{ yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, yymsp[0].minor.yy272); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 27: /* literal ::= duration_literal */
- case 37: /* expression ::= literal */ yytestcase(yyruleno==37);
- case 38: /* expression ::= column_reference */ yytestcase(yyruleno==38);
- case 41: /* expression ::= subquery */ yytestcase(yyruleno==41);
- case 73: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==73);
- case 77: /* boolean_primary ::= predicate */ yytestcase(yyruleno==77);
- case 82: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==82);
- case 84: /* table_reference ::= table_primary */ yytestcase(yyruleno==84);
- case 85: /* table_reference ::= joined_table */ yytestcase(yyruleno==85);
- case 89: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==89);
- case 136: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==136);
- case 138: /* query_primary ::= query_specification */ yytestcase(yyruleno==138);
-{ PARSER_TRACE; yylhsminor.yy104 = yymsp[0].minor.yy104; }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 27: /* column_def ::= column_name type_name */
+{ yylhsminor.yy272 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); }
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 28: /* duration_literal ::= NK_VARIABLE */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 28: /* column_def ::= column_name type_name COMMENT NK_STRING */
+{ yylhsminor.yy272 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); }
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
break;
- case 29: /* literal_list ::= literal */
- case 50: /* expression_list ::= expression */ yytestcase(yyruleno==50);
-{ PARSER_TRACE; yylhsminor.yy8 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); }
- yymsp[0].minor.yy8 = yylhsminor.yy8;
+ case 29: /* type_name ::= BOOL */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); }
break;
- case 30: /* literal_list ::= literal_list NK_COMMA literal */
- case 51: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==51);
-{ PARSER_TRACE; yylhsminor.yy8 = addNodeToList(pCxt, yymsp[-2].minor.yy8, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); }
- yymsp[-2].minor.yy8 = yylhsminor.yy8;
+ case 30: /* type_name ::= TINYINT */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); }
break;
- case 31: /* db_name ::= NK_ID */
- case 32: /* table_name ::= NK_ID */ yytestcase(yyruleno==32);
- case 33: /* column_name ::= NK_ID */ yytestcase(yyruleno==33);
- case 34: /* function_name ::= NK_ID */ yytestcase(yyruleno==34);
- case 35: /* table_alias ::= NK_ID */ yytestcase(yyruleno==35);
- case 36: /* column_alias ::= NK_ID */ yytestcase(yyruleno==36);
-{ PARSER_TRACE; yylhsminor.yy129 = yymsp[0].minor.yy0; }
- yymsp[0].minor.yy129 = yylhsminor.yy129;
+ case 31: /* type_name ::= SMALLINT */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); }
break;
- case 39: /* expression ::= function_name NK_LP expression_list NK_RP */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy8)); }
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ case 32: /* type_name ::= INT */
+ case 33: /* type_name ::= INTEGER */ yytestcase(yyruleno==33);
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); }
break;
- case 40: /* expression ::= function_name NK_LP NK_STAR NK_RP */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); }
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ case 34: /* type_name ::= BIGINT */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); }
break;
- case 42: /* expression ::= NK_LP expression NK_RP */
- case 78: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==78);
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 35: /* type_name ::= FLOAT */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); }
break;
- case 43: /* expression ::= NK_PLUS expression */
+ case 36: /* type_name ::= DOUBLE */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); }
+ break;
+ case 37: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); }
+ break;
+ case 38: /* type_name ::= TIMESTAMP */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
+ break;
+ case 39: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); }
+ break;
+ case 40: /* type_name ::= TINYINT UNSIGNED */
+{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); }
+ break;
+ case 41: /* type_name ::= SMALLINT UNSIGNED */
+{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); }
+ break;
+ case 42: /* type_name ::= INT UNSIGNED */
+{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); }
+ break;
+ case 43: /* type_name ::= BIGINT UNSIGNED */
+{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); }
+ break;
+ case 44: /* type_name ::= JSON */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); }
+ break;
+ case 45: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); }
+ break;
+ case 46: /* type_name ::= MEDIUMBLOB */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
+ break;
+ case 47: /* type_name ::= BLOB */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); }
+ break;
+ case 48: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); }
+ break;
+ case 49: /* type_name ::= DECIMAL */
+{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ break;
+ case 50: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ break;
+ case 51: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ break;
+ case 52: /* table_options ::= */
+{ yymsp[1].minor.yy46 = createDefaultTableOptions(pCxt);}
+ break;
+ case 53: /* table_options ::= table_options COMMENT NK_INTEGER */
+{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy46 = yylhsminor.yy46;
+ break;
+ case 54: /* table_options ::= table_options KEEP NK_INTEGER */
+{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy46 = yylhsminor.yy46;
+ break;
+ case 55: /* table_options ::= table_options TTL NK_INTEGER */
+{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy46 = yylhsminor.yy46;
+ break;
+ case 56: /* cmd ::= SHOW DATABASES */
+{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
+ break;
+ case 57: /* cmd ::= SHOW TABLES */
+{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT); }
+ break;
+ case 58: /* cmd ::= query_expression */
+{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy272; }
+ break;
+ case 59: /* literal ::= NK_INTEGER */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 60: /* literal ::= NK_FLOAT */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 61: /* literal ::= NK_STRING */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 62: /* literal ::= NK_BOOL */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 63: /* literal ::= TIMESTAMP NK_STRING */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 64: /* literal ::= duration_literal */
+ case 74: /* expression ::= literal */ yytestcase(yyruleno==74);
+ case 75: /* expression ::= column_reference */ yytestcase(yyruleno==75);
+ case 78: /* expression ::= subquery */ yytestcase(yyruleno==78);
+ case 110: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==110);
+ case 114: /* boolean_primary ::= predicate */ yytestcase(yyruleno==114);
+ case 119: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==119);
+ case 121: /* table_reference ::= table_primary */ yytestcase(yyruleno==121);
+ case 122: /* table_reference ::= joined_table */ yytestcase(yyruleno==122);
+ case 126: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==126);
+ case 173: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==173);
+ case 175: /* query_primary ::= query_specification */ yytestcase(yyruleno==175);
+{ PARSER_TRACE; yylhsminor.yy272 = yymsp[0].minor.yy272; }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 65: /* duration_literal ::= NK_VARIABLE */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 66: /* literal_list ::= literal */
+ case 87: /* expression_list ::= expression */ yytestcase(yyruleno==87);
+{ PARSER_TRACE; yylhsminor.yy64 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272)); }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
+ break;
+ case 67: /* literal_list ::= literal_list NK_COMMA literal */
+ case 88: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==88);
+{ PARSER_TRACE; yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, releaseRawExprNode(pCxt, yymsp[0].minor.yy272)); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
+ break;
+ case 68: /* db_name ::= NK_ID */
+ case 69: /* table_name ::= NK_ID */ yytestcase(yyruleno==69);
+ case 70: /* column_name ::= NK_ID */ yytestcase(yyruleno==70);
+ case 71: /* function_name ::= NK_ID */ yytestcase(yyruleno==71);
+ case 72: /* table_alias ::= NK_ID */ yytestcase(yyruleno==72);
+ case 73: /* column_alias ::= NK_ID */ yytestcase(yyruleno==73);
+{ PARSER_TRACE; yylhsminor.yy209 = yymsp[0].minor.yy0; }
+ yymsp[0].minor.yy209 = yylhsminor.yy209;
+ break;
+ case 76: /* expression ::= function_name NK_LP expression_list NK_RP */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy64)); }
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 77: /* expression ::= function_name NK_LP NK_STAR NK_RP */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); }
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 79: /* expression ::= NK_LP expression NK_RP */
+ case 115: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==115);
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
+ break;
+ case 80: /* expression ::= NK_PLUS expression */
{
PARSER_TRACE;
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy104));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy272));
}
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 44: /* expression ::= NK_MINUS expression */
+ case 81: /* expression ::= NK_MINUS expression */
{
PARSER_TRACE;
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy272), NULL));
}
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 45: /* expression ::= expression NK_PLUS expression */
+ case 82: /* expression ::= expression NK_PLUS expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 46: /* expression ::= expression NK_MINUS expression */
+ case 83: /* expression ::= expression NK_MINUS expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 47: /* expression ::= expression NK_STAR expression */
+ case 84: /* expression ::= expression NK_STAR expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 48: /* expression ::= expression NK_SLASH expression */
+ case 85: /* expression ::= expression NK_SLASH expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 49: /* expression ::= expression NK_REM expression */
+ case 86: /* expression ::= expression NK_REM expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 52: /* column_reference ::= column_name */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 89: /* column_reference ::= column_name */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
break;
- case 53: /* column_reference ::= table_name NK_DOT column_name */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 90: /* column_reference ::= table_name NK_DOT column_name */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 54: /* predicate ::= expression compare_op expression */
- case 59: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==59);
+ case 91: /* predicate ::= expression compare_op expression */
+ case 96: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==96);
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy60, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy20, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 55: /* predicate ::= expression BETWEEN expression AND expression */
+ case 92: /* predicate ::= expression BETWEEN expression AND expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy104), releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy272), releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-4].minor.yy104 = yylhsminor.yy104;
+ yymsp[-4].minor.yy272 = yylhsminor.yy272;
break;
- case 56: /* predicate ::= expression NOT BETWEEN expression AND expression */
+ case 93: /* predicate ::= expression NOT BETWEEN expression AND expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[-5].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-5].minor.yy104 = yylhsminor.yy104;
+ yymsp[-5].minor.yy272 = yylhsminor.yy272;
break;
- case 57: /* predicate ::= expression IS NULL */
+ case 94: /* predicate ::= expression IS NULL */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), NULL));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 58: /* predicate ::= expression IS NOT NULL */
+ case 95: /* predicate ::= expression IS NOT NULL */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), NULL));
}
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
break;
- case 60: /* compare_op ::= NK_LT */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_LOWER_THAN; }
+ case 97: /* compare_op ::= NK_LT */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_LOWER_THAN; }
break;
- case 61: /* compare_op ::= NK_GT */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_GREATER_THAN; }
+ case 98: /* compare_op ::= NK_GT */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_GREATER_THAN; }
break;
- case 62: /* compare_op ::= NK_LE */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_LOWER_EQUAL; }
+ case 99: /* compare_op ::= NK_LE */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_LOWER_EQUAL; }
break;
- case 63: /* compare_op ::= NK_GE */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_GREATER_EQUAL; }
+ case 100: /* compare_op ::= NK_GE */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_GREATER_EQUAL; }
break;
- case 64: /* compare_op ::= NK_NE */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_NOT_EQUAL; }
+ case 101: /* compare_op ::= NK_NE */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_NOT_EQUAL; }
break;
- case 65: /* compare_op ::= NK_EQ */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_EQUAL; }
+ case 102: /* compare_op ::= NK_EQ */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_EQUAL; }
break;
- case 66: /* compare_op ::= LIKE */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_LIKE; }
+ case 103: /* compare_op ::= LIKE */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_LIKE; }
break;
- case 67: /* compare_op ::= NOT LIKE */
-{ PARSER_TRACE; yymsp[-1].minor.yy60 = OP_TYPE_NOT_LIKE; }
+ case 104: /* compare_op ::= NOT LIKE */
+{ PARSER_TRACE; yymsp[-1].minor.yy20 = OP_TYPE_NOT_LIKE; }
break;
- case 68: /* compare_op ::= MATCH */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_MATCH; }
+ case 105: /* compare_op ::= MATCH */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_MATCH; }
break;
- case 69: /* compare_op ::= NMATCH */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_NMATCH; }
+ case 106: /* compare_op ::= NMATCH */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_NMATCH; }
break;
- case 70: /* in_op ::= IN */
-{ PARSER_TRACE; yymsp[0].minor.yy60 = OP_TYPE_IN; }
+ case 107: /* in_op ::= IN */
+{ PARSER_TRACE; yymsp[0].minor.yy20 = OP_TYPE_IN; }
break;
- case 71: /* in_op ::= NOT IN */
-{ PARSER_TRACE; yymsp[-1].minor.yy60 = OP_TYPE_NOT_IN; }
+ case 108: /* in_op ::= NOT IN */
+{ PARSER_TRACE; yymsp[-1].minor.yy20 = OP_TYPE_NOT_IN; }
break;
- case 72: /* in_predicate_value ::= NK_LP expression_list NK_RP */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy8)); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 109: /* in_predicate_value ::= NK_LP expression_list NK_RP */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy64)); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 74: /* boolean_value_expression ::= NOT boolean_primary */
+ case 111: /* boolean_value_expression ::= NOT boolean_primary */
{
PARSER_TRACE;
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL));
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy272), NULL));
}
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 75: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ case 112: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 76: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ case 113: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
PARSER_TRACE;
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272)));
}
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 79: /* common_expression ::= expression */
- case 80: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==80);
-{ yylhsminor.yy104 = yymsp[0].minor.yy104; }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 116: /* common_expression ::= expression */
+ case 117: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==117);
+{ yylhsminor.yy272 = yymsp[0].minor.yy272; }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
break;
- case 81: /* from_clause ::= FROM table_reference_list */
- case 111: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==111);
- case 134: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==134);
-{ PARSER_TRACE; yymsp[-1].minor.yy104 = yymsp[0].minor.yy104; }
+ case 118: /* from_clause ::= FROM table_reference_list */
+ case 148: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==148);
+ case 171: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==171);
+{ PARSER_TRACE; yymsp[-1].minor.yy272 = yymsp[0].minor.yy272; }
break;
- case 83: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
-{ PARSER_TRACE; yylhsminor.yy104 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy104, yymsp[0].minor.yy104, NULL); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 120: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
+{ PARSER_TRACE; yylhsminor.yy272 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, NULL); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 86: /* table_primary ::= table_name alias_opt */
-{ PARSER_TRACE; yylhsminor.yy104 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); }
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ case 123: /* table_primary ::= table_name alias_opt */
+{ PARSER_TRACE; yylhsminor.yy272 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); }
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 87: /* table_primary ::= db_name NK_DOT table_name alias_opt */
-{ PARSER_TRACE; yylhsminor.yy104 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); }
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ case 124: /* table_primary ::= db_name NK_DOT table_name alias_opt */
+{ PARSER_TRACE; yylhsminor.yy272 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); }
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
break;
- case 88: /* table_primary ::= subquery alias_opt */
-{ PARSER_TRACE; yylhsminor.yy104 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy129); }
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ case 125: /* table_primary ::= subquery alias_opt */
+{ PARSER_TRACE; yylhsminor.yy272 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272), &yymsp[0].minor.yy209); }
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 90: /* alias_opt ::= */
-{ PARSER_TRACE; yymsp[1].minor.yy129 = nil_token; }
+ case 127: /* alias_opt ::= */
+{ PARSER_TRACE; yymsp[1].minor.yy209 = nil_token; }
break;
- case 91: /* alias_opt ::= table_alias */
-{ PARSER_TRACE; yylhsminor.yy129 = yymsp[0].minor.yy129; }
- yymsp[0].minor.yy129 = yylhsminor.yy129;
+ case 128: /* alias_opt ::= table_alias */
+{ PARSER_TRACE; yylhsminor.yy209 = yymsp[0].minor.yy209; }
+ yymsp[0].minor.yy209 = yylhsminor.yy209;
break;
- case 92: /* alias_opt ::= AS table_alias */
-{ PARSER_TRACE; yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; }
+ case 129: /* alias_opt ::= AS table_alias */
+{ PARSER_TRACE; yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; }
break;
- case 93: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- case 94: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==94);
-{ PARSER_TRACE; yymsp[-2].minor.yy104 = yymsp[-1].minor.yy104; }
+ case 130: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ case 131: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==131);
+{ PARSER_TRACE; yymsp[-2].minor.yy272 = yymsp[-1].minor.yy272; }
break;
- case 95: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
-{ PARSER_TRACE; yylhsminor.yy104 = createJoinTableNode(pCxt, yymsp[-4].minor.yy228, yymsp[-5].minor.yy104, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); }
- yymsp[-5].minor.yy104 = yylhsminor.yy104;
+ case 132: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+{ PARSER_TRACE; yylhsminor.yy272 = createJoinTableNode(pCxt, yymsp[-4].minor.yy252, yymsp[-5].minor.yy272, yymsp[-2].minor.yy272, yymsp[0].minor.yy272); }
+ yymsp[-5].minor.yy272 = yylhsminor.yy272;
break;
- case 96: /* join_type ::= */
-{ PARSER_TRACE; yymsp[1].minor.yy228 = JOIN_TYPE_INNER; }
+ case 133: /* join_type ::= */
+{ PARSER_TRACE; yymsp[1].minor.yy252 = JOIN_TYPE_INNER; }
break;
- case 97: /* join_type ::= INNER */
-{ PARSER_TRACE; yymsp[0].minor.yy228 = JOIN_TYPE_INNER; }
+ case 134: /* join_type ::= INNER */
+{ PARSER_TRACE; yymsp[0].minor.yy252 = JOIN_TYPE_INNER; }
break;
- case 98: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ case 135: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
PARSER_TRACE;
- yymsp[-8].minor.yy104 = createSelectStmt(pCxt, yymsp[-7].minor.yy185, yymsp[-6].minor.yy8, yymsp[-5].minor.yy104);
- yymsp[-8].minor.yy104 = addWhereClause(pCxt, yymsp[-8].minor.yy104, yymsp[-4].minor.yy104);
- yymsp[-8].minor.yy104 = addPartitionByClause(pCxt, yymsp[-8].minor.yy104, yymsp[-3].minor.yy8);
- yymsp[-8].minor.yy104 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy104, yymsp[-2].minor.yy104);
- yymsp[-8].minor.yy104 = addGroupByClause(pCxt, yymsp[-8].minor.yy104, yymsp[-1].minor.yy8);
- yymsp[-8].minor.yy104 = addHavingClause(pCxt, yymsp[-8].minor.yy104, yymsp[0].minor.yy104);
+ yymsp[-8].minor.yy272 = createSelectStmt(pCxt, yymsp[-7].minor.yy137, yymsp[-6].minor.yy64, yymsp[-5].minor.yy272);
+ yymsp[-8].minor.yy272 = addWhereClause(pCxt, yymsp[-8].minor.yy272, yymsp[-4].minor.yy272);
+ yymsp[-8].minor.yy272 = addPartitionByClause(pCxt, yymsp[-8].minor.yy272, yymsp[-3].minor.yy64);
+ yymsp[-8].minor.yy272 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy272, yymsp[-2].minor.yy272);
+ yymsp[-8].minor.yy272 = addGroupByClause(pCxt, yymsp[-8].minor.yy272, yymsp[-1].minor.yy64);
+ yymsp[-8].minor.yy272 = addHavingClause(pCxt, yymsp[-8].minor.yy272, yymsp[0].minor.yy272);
}
break;
- case 99: /* set_quantifier_opt ::= */
-{ PARSER_TRACE; yymsp[1].minor.yy185 = false; }
+ case 136: /* set_quantifier_opt ::= */
+{ PARSER_TRACE; yymsp[1].minor.yy137 = false; }
break;
- case 100: /* set_quantifier_opt ::= DISTINCT */
-{ PARSER_TRACE; yymsp[0].minor.yy185 = true; }
+ case 137: /* set_quantifier_opt ::= DISTINCT */
+{ PARSER_TRACE; yymsp[0].minor.yy137 = true; }
break;
- case 101: /* set_quantifier_opt ::= ALL */
-{ PARSER_TRACE; yymsp[0].minor.yy185 = false; }
+ case 138: /* set_quantifier_opt ::= ALL */
+{ PARSER_TRACE; yymsp[0].minor.yy137 = false; }
break;
- case 102: /* select_list ::= NK_STAR */
-{ PARSER_TRACE; yymsp[0].minor.yy8 = NULL; }
+ case 139: /* select_list ::= NK_STAR */
+{ PARSER_TRACE; yymsp[0].minor.yy64 = NULL; }
break;
- case 103: /* select_list ::= select_sublist */
-{ PARSER_TRACE; yylhsminor.yy8 = yymsp[0].minor.yy8; }
- yymsp[0].minor.yy8 = yylhsminor.yy8;
+ case 140: /* select_list ::= select_sublist */
+{ PARSER_TRACE; yylhsminor.yy64 = yymsp[0].minor.yy64; }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 104: /* select_sublist ::= select_item */
- case 151: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==151);
-{ PARSER_TRACE; yylhsminor.yy8 = createNodeList(pCxt, yymsp[0].minor.yy104); }
- yymsp[0].minor.yy8 = yylhsminor.yy8;
+ case 141: /* select_sublist ::= select_item */
+ case 188: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==188);
+{ PARSER_TRACE; yylhsminor.yy64 = createNodeList(pCxt, yymsp[0].minor.yy272); }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 105: /* select_sublist ::= select_sublist NK_COMMA select_item */
- case 152: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==152);
-{ PARSER_TRACE; yylhsminor.yy8 = addNodeToList(pCxt, yymsp[-2].minor.yy8, yymsp[0].minor.yy104); }
- yymsp[-2].minor.yy8 = yylhsminor.yy8;
+ case 142: /* select_sublist ::= select_sublist NK_COMMA select_item */
+ case 189: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==189);
+{ PARSER_TRACE; yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, yymsp[0].minor.yy272); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 106: /* select_item ::= common_expression */
+ case 143: /* select_item ::= common_expression */
{
PARSER_TRACE;
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104);
- yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), &t);
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272);
+ yylhsminor.yy272 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272), &t);
}
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
break;
- case 107: /* select_item ::= common_expression column_alias */
-{ PARSER_TRACE; yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy129); }
- yymsp[-1].minor.yy104 = yylhsminor.yy104;
+ case 144: /* select_item ::= common_expression column_alias */
+{ PARSER_TRACE; yylhsminor.yy272 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272), &yymsp[0].minor.yy209); }
+ yymsp[-1].minor.yy272 = yylhsminor.yy272;
break;
- case 108: /* select_item ::= common_expression AS column_alias */
-{ PARSER_TRACE; yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), &yymsp[0].minor.yy129); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 145: /* select_item ::= common_expression AS column_alias */
+{ PARSER_TRACE; yylhsminor.yy272 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), &yymsp[0].minor.yy209); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 109: /* select_item ::= table_name NK_DOT NK_STAR */
-{ PARSER_TRACE; yylhsminor.yy104 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 146: /* select_item ::= table_name NK_DOT NK_STAR */
+{ PARSER_TRACE; yylhsminor.yy272 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 110: /* where_clause_opt ::= */
- case 114: /* twindow_clause_opt ::= */ yytestcase(yyruleno==114);
- case 119: /* sliding_opt ::= */ yytestcase(yyruleno==119);
- case 121: /* fill_opt ::= */ yytestcase(yyruleno==121);
- case 133: /* having_clause_opt ::= */ yytestcase(yyruleno==133);
- case 141: /* slimit_clause_opt ::= */ yytestcase(yyruleno==141);
- case 145: /* limit_clause_opt ::= */ yytestcase(yyruleno==145);
-{ PARSER_TRACE; yymsp[1].minor.yy104 = NULL; }
+ case 147: /* where_clause_opt ::= */
+ case 151: /* twindow_clause_opt ::= */ yytestcase(yyruleno==151);
+ case 156: /* sliding_opt ::= */ yytestcase(yyruleno==156);
+ case 158: /* fill_opt ::= */ yytestcase(yyruleno==158);
+ case 170: /* having_clause_opt ::= */ yytestcase(yyruleno==170);
+ case 178: /* slimit_clause_opt ::= */ yytestcase(yyruleno==178);
+ case 182: /* limit_clause_opt ::= */ yytestcase(yyruleno==182);
+{ PARSER_TRACE; yymsp[1].minor.yy272 = NULL; }
break;
- case 112: /* partition_by_clause_opt ::= */
- case 129: /* group_by_clause_opt ::= */ yytestcase(yyruleno==129);
- case 139: /* order_by_clause_opt ::= */ yytestcase(yyruleno==139);
-{ PARSER_TRACE; yymsp[1].minor.yy8 = NULL; }
+ case 149: /* partition_by_clause_opt ::= */
+ case 166: /* group_by_clause_opt ::= */ yytestcase(yyruleno==166);
+ case 176: /* order_by_clause_opt ::= */ yytestcase(yyruleno==176);
+{ PARSER_TRACE; yymsp[1].minor.yy64 = NULL; }
break;
- case 113: /* partition_by_clause_opt ::= PARTITION BY expression_list */
- case 130: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==130);
- case 140: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==140);
-{ PARSER_TRACE; yymsp[-2].minor.yy8 = yymsp[0].minor.yy8; }
+ case 150: /* partition_by_clause_opt ::= PARTITION BY expression_list */
+ case 167: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==167);
+ case 177: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==177);
+{ PARSER_TRACE; yymsp[-2].minor.yy64 = yymsp[0].minor.yy64; }
break;
- case 115: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
-{ PARSER_TRACE; yymsp[-5].minor.yy104 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), &yymsp[-1].minor.yy0); }
+ case 152: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
+{ PARSER_TRACE; yymsp[-5].minor.yy272 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), &yymsp[-1].minor.yy0); }
break;
- case 116: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
-{ PARSER_TRACE; yymsp[-3].minor.yy104 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); }
+ case 153: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
+{ PARSER_TRACE; yymsp[-3].minor.yy272 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); }
break;
- case 117: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
-{ PARSER_TRACE; yymsp[-5].minor.yy104 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy104, NULL, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); }
+ case 154: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+{ PARSER_TRACE; yymsp[-5].minor.yy272 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy272, NULL, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); }
break;
- case 118: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
-{ PARSER_TRACE; yymsp[-7].minor.yy104 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy104, yymsp[-3].minor.yy104, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); }
+ case 155: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+{ PARSER_TRACE; yymsp[-7].minor.yy272 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy272, yymsp[-3].minor.yy272, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); }
break;
- case 120: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
-{ PARSER_TRACE; yymsp[-3].minor.yy104 = yymsp[-1].minor.yy104; }
+ case 157: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
+{ PARSER_TRACE; yymsp[-3].minor.yy272 = yymsp[-1].minor.yy272; }
break;
- case 122: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
-{ PARSER_TRACE; yymsp[-3].minor.yy104 = createFillNode(pCxt, yymsp[-1].minor.yy246, NULL); }
+ case 159: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
+{ PARSER_TRACE; yymsp[-3].minor.yy272 = createFillNode(pCxt, yymsp[-1].minor.yy54, NULL); }
break;
- case 123: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
-{ PARSER_TRACE; yymsp[-5].minor.yy104 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy8)); }
+ case 160: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+{ PARSER_TRACE; yymsp[-5].minor.yy272 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy64)); }
break;
- case 124: /* fill_mode ::= NONE */
-{ PARSER_TRACE; yymsp[0].minor.yy246 = FILL_MODE_NONE; }
+ case 161: /* fill_mode ::= NONE */
+{ PARSER_TRACE; yymsp[0].minor.yy54 = FILL_MODE_NONE; }
break;
- case 125: /* fill_mode ::= PREV */
-{ PARSER_TRACE; yymsp[0].minor.yy246 = FILL_MODE_PREV; }
+ case 162: /* fill_mode ::= PREV */
+{ PARSER_TRACE; yymsp[0].minor.yy54 = FILL_MODE_PREV; }
break;
- case 126: /* fill_mode ::= NULL */
-{ PARSER_TRACE; yymsp[0].minor.yy246 = FILL_MODE_NULL; }
+ case 163: /* fill_mode ::= NULL */
+{ PARSER_TRACE; yymsp[0].minor.yy54 = FILL_MODE_NULL; }
break;
- case 127: /* fill_mode ::= LINEAR */
-{ PARSER_TRACE; yymsp[0].minor.yy246 = FILL_MODE_LINEAR; }
+ case 164: /* fill_mode ::= LINEAR */
+{ PARSER_TRACE; yymsp[0].minor.yy54 = FILL_MODE_LINEAR; }
break;
- case 128: /* fill_mode ::= NEXT */
-{ PARSER_TRACE; yymsp[0].minor.yy246 = FILL_MODE_NEXT; }
+ case 165: /* fill_mode ::= NEXT */
+{ PARSER_TRACE; yymsp[0].minor.yy54 = FILL_MODE_NEXT; }
break;
- case 131: /* group_by_list ::= expression */
-{ PARSER_TRACE; yylhsminor.yy8 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); }
- yymsp[0].minor.yy8 = yylhsminor.yy8;
+ case 168: /* group_by_list ::= expression */
+{ PARSER_TRACE; yylhsminor.yy64 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 132: /* group_by_list ::= group_by_list NK_COMMA expression */
-{ PARSER_TRACE; yylhsminor.yy8 = addNodeToList(pCxt, yymsp[-2].minor.yy8, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); }
- yymsp[-2].minor.yy8 = yylhsminor.yy8;
+ case 169: /* group_by_list ::= group_by_list NK_COMMA expression */
+{ PARSER_TRACE; yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 135: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ case 172: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
PARSER_TRACE;
- yylhsminor.yy104 = addOrderByClause(pCxt, yymsp[-3].minor.yy104, yymsp[-2].minor.yy8);
- yylhsminor.yy104 = addSlimitClause(pCxt, yylhsminor.yy104, yymsp[-1].minor.yy104);
- yylhsminor.yy104 = addLimitClause(pCxt, yylhsminor.yy104, yymsp[0].minor.yy104);
+ yylhsminor.yy272 = addOrderByClause(pCxt, yymsp[-3].minor.yy272, yymsp[-2].minor.yy64);
+ yylhsminor.yy272 = addSlimitClause(pCxt, yylhsminor.yy272, yymsp[-1].minor.yy272);
+ yylhsminor.yy272 = addLimitClause(pCxt, yylhsminor.yy272, yymsp[0].minor.yy272);
}
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
break;
- case 137: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
-{ PARSER_TRACE; yylhsminor.yy104 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy104, yymsp[0].minor.yy104); }
- yymsp[-3].minor.yy104 = yylhsminor.yy104;
+ case 174: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
+{ PARSER_TRACE; yylhsminor.yy272 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy272, yymsp[0].minor.yy272); }
+ yymsp[-3].minor.yy272 = yylhsminor.yy272;
break;
- case 142: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
- case 146: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==146);
-{ PARSER_TRACE; yymsp[-1].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
+ case 179: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ case 183: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==183);
+{ PARSER_TRACE; yymsp[-1].minor.yy272 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
break;
- case 143: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- case 147: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==147);
-{ PARSER_TRACE; yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
+ case 180: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ case 184: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==184);
+{ PARSER_TRACE; yymsp[-3].minor.yy272 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
- case 144: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- case 148: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==148);
-{ PARSER_TRACE; yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
+ case 181: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ case 185: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==185);
+{ PARSER_TRACE; yymsp[-3].minor.yy272 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
break;
- case 149: /* subquery ::= NK_LP query_expression NK_RP */
-{ PARSER_TRACE; yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy104); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 186: /* subquery ::= NK_LP query_expression NK_RP */
+{ PARSER_TRACE; yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy272); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 150: /* search_condition ::= common_expression */
-{ PARSER_TRACE; yylhsminor.yy104 = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); }
- yymsp[0].minor.yy104 = yylhsminor.yy104;
+ case 187: /* search_condition ::= common_expression */
+{ PARSER_TRACE; yylhsminor.yy272 = releaseRawExprNode(pCxt, yymsp[0].minor.yy272); }
+ yymsp[0].minor.yy272 = yylhsminor.yy272;
break;
- case 153: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
-{ PARSER_TRACE; yylhsminor.yy104 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), yymsp[-1].minor.yy50, yymsp[0].minor.yy186); }
- yymsp[-2].minor.yy104 = yylhsminor.yy104;
+ case 190: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
+{ PARSER_TRACE; yylhsminor.yy272 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), yymsp[-1].minor.yy218, yymsp[0].minor.yy217); }
+ yymsp[-2].minor.yy272 = yylhsminor.yy272;
break;
- case 154: /* ordering_specification_opt ::= */
-{ PARSER_TRACE; yymsp[1].minor.yy50 = ORDER_ASC; }
+ case 191: /* ordering_specification_opt ::= */
+{ PARSER_TRACE; yymsp[1].minor.yy218 = ORDER_ASC; }
break;
- case 155: /* ordering_specification_opt ::= ASC */
-{ PARSER_TRACE; yymsp[0].minor.yy50 = ORDER_ASC; }
+ case 192: /* ordering_specification_opt ::= ASC */
+{ PARSER_TRACE; yymsp[0].minor.yy218 = ORDER_ASC; }
break;
- case 156: /* ordering_specification_opt ::= DESC */
-{ PARSER_TRACE; yymsp[0].minor.yy50 = ORDER_DESC; }
+ case 193: /* ordering_specification_opt ::= DESC */
+{ PARSER_TRACE; yymsp[0].minor.yy218 = ORDER_DESC; }
break;
- case 157: /* null_ordering_opt ::= */
-{ PARSER_TRACE; yymsp[1].minor.yy186 = NULL_ORDER_DEFAULT; }
+ case 194: /* null_ordering_opt ::= */
+{ PARSER_TRACE; yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; }
break;
- case 158: /* null_ordering_opt ::= NULLS FIRST */
-{ PARSER_TRACE; yymsp[-1].minor.yy186 = NULL_ORDER_FIRST; }
+ case 195: /* null_ordering_opt ::= NULLS FIRST */
+{ PARSER_TRACE; yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; }
break;
- case 159: /* null_ordering_opt ::= NULLS LAST */
-{ PARSER_TRACE; yymsp[-1].minor.yy186 = NULL_ORDER_LAST; }
+ case 196: /* null_ordering_opt ::= NULLS LAST */
+{ PARSER_TRACE; yymsp[-1].minor.yy217 = NULL_ORDER_LAST; }
break;
default:
break;
diff --git a/source/libs/parser/src/ttokenizer.c b/source/libs/parser/src/ttokenizer.c
index 873fda2515..b80763b757 100644
--- a/source/libs/parser/src/ttokenizer.c
+++ b/source/libs/parser/src/ttokenizer.c
@@ -30,18 +30,18 @@ typedef struct SKeyword {
// keywords in sql string
static SKeyword keywordTable[] = {
// {"ID", TK_ID},
- // {"BOOL", TK_BOOL},
-// {"TINYINT", TK_TINYINT},
-// {"SMALLINT", TK_SMALLINT},
- // {"INTEGER", TK_INTEGER},
- // {"INT", TK_INTEGER},
-// {"BIGINT", TK_BIGINT},
- // {"FLOAT", TK_FLOAT},
-// {"DOUBLE", TK_DOUBLE},
+ {"BOOL", TK_BOOL},
+ {"TINYINT", TK_TINYINT},
+ {"SMALLINT", TK_SMALLINT},
+ {"INTEGER", TK_INTEGER},
+ {"INT", TK_INTEGER},
+ {"BIGINT", TK_BIGINT},
+ {"FLOAT", TK_FLOAT},
+ {"DOUBLE", TK_DOUBLE},
// {"STRING", TK_STRING},
{"TIMESTAMP", TK_TIMESTAMP},
-// {"BINARY", TK_BINARY},
-// {"NCHAR", TK_NCHAR},
+ {"BINARY", TK_BINARY},
+ {"NCHAR", TK_NCHAR},
{"OR", TK_OR},
{"AND", TK_AND},
{"NOT", TK_NOT},
@@ -74,8 +74,8 @@ static SKeyword keywordTable[] = {
// {"UMINUS", TK_UMINUS},
// {"UPLUS", TK_UPLUS},
// {"BITNOT", TK_BITNOT},
- // {"SHOW", TK_SHOW},
- // {"DATABASES", TK_DATABASES},
+ {"SHOW", TK_SHOW},
+ {"DATABASES", TK_DATABASES},
// {"MNODES", TK_MNODES},
// {"DNODES", TK_DNODES},
// {"ACCOUNTS", TK_ACCOUNTS},
@@ -88,16 +88,16 @@ static SKeyword keywordTable[] = {
// {"SCORES", TK_SCORES},
// {"GRANTS", TK_GRANTS},
// {"DOT", TK_DOT},
- // {"TABLES", TK_TABLES},
+ {"TABLES", TK_TABLES},
// {"STABLES", TK_STABLES},
{"VGROUPS", TK_VGROUPS},
// {"DROP", TK_DROP},
- // {"TABLE", TK_TABLE},
+ {"TABLE", TK_TABLE},
{"DATABASE", TK_DATABASE},
// {"DNODE", TK_DNODE},
// {"USER", TK_USER},
// {"ACCOUNT", TK_ACCOUNT},
- // {"USE", TK_USE},
+ {"USE", TK_USE},
// {"DESCRIBE", TK_DESCRIBE},
// {"SYNCDB", TK_SYNCDB},
// {"ALTER", TK_ALTER},
@@ -309,7 +309,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
if (z[1] == '-') {
for (i = 2; z[i] && z[i] != '\n'; i++) {
}
- *tokenId = TK_COMMENT;
+ *tokenId = TK_NK_COMMENT;
return i;
}
*tokenId = TK_MINUS;
@@ -343,7 +343,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
for (i = 3; z[i] && (z[i] != '/' || z[i - 1] != '*'); i++) {
}
if (z[i]) i++;
- *tokenId = TK_COMMENT;
+ *tokenId = TK_NK_COMMENT;
return i;
}
case '%': {
diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp
index 457d586ea4..7415e95bdb 100644
--- a/source/libs/parser/test/mockCatalog.cpp
+++ b/source/libs/parser/test/mockCatalog.cpp
@@ -13,19 +13,17 @@
* along with this program. If not, see .
*/
-#include "mockCatalog.h"
-
#include
-
#include "stub.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
-#include "addr_any.h"
+#include
#pragma GCC diagnostic pop
+#include "mockCatalog.h"
namespace {
void generateTestT1(MockCatalogService* mcs) {
@@ -60,6 +58,10 @@ int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const
return mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo);
}
+int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) {
+ return mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList);
+}
+
void initMetaDataEnv() {
mockCatalogService.reset(new MockCatalogService());
@@ -67,6 +69,8 @@ void initMetaDataEnv() {
stub.set(catalogGetHandle, __catalogGetHandle);
stub.set(catalogGetTableMeta, __catalogGetTableMeta);
stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup);
+ stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo);
+
{
AddrAny any("libcatalog.so");
std::map result;
diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp
index 00d64bd12a..a1de7c47a7 100644
--- a/source/libs/parser/test/mockCatalogService.cpp
+++ b/source/libs/parser/test/mockCatalogService.cpp
@@ -126,6 +126,19 @@ public:
return 0;
}
+ int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const {
+ SVgroupInfo info = {0};
+ info.vgId = 1;
+ addEpIntoEpSet(&info.epset, "node1", 6030);
+
+ info.hashBegin = 0;
+ info.hashEnd = 1;
+ *pVgList = taosArrayInit(4, sizeof(SVgroupInfo));
+
+ taosArrayPush(*pVgList, &info);
+ return 0;
+ }
+
TableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
builder_ = TableBuilder::createTableBuilder(tableType, numOfColumns, numOfTags);
meta_[db][tbname] = builder_->table();
@@ -313,4 +326,8 @@ int32_t MockCatalogService::catalogGetTableMeta(const SName* pTableName, STableM
int32_t MockCatalogService::catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const {
return impl_->catalogGetTableHashVgroup(pTableName, vgInfo);
+}
+
+int32_t MockCatalogService::catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const {
+ return impl_->catalogGetTableDistVgInfo(pTableName, pVgList);
}
\ No newline at end of file
diff --git a/source/libs/parser/test/mockCatalogService.h b/source/libs/parser/test/mockCatalogService.h
index b971331635..1f7cd70ac2 100644
--- a/source/libs/parser/test/mockCatalogService.h
+++ b/source/libs/parser/test/mockCatalogService.h
@@ -59,6 +59,7 @@ public:
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const;
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const;
+ int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const;
private:
std::unique_ptr impl_;
diff --git a/source/libs/parser/test/parserTest.cpp b/source/libs/parser/test/parserTest.cpp
index 76edf60338..87c2496ebe 100644
--- a/source/libs/parser/test/parserTest.cpp
+++ b/source/libs/parser/test/parserTest.cpp
@@ -696,3 +696,23 @@ TEST_F(ParserTest, selectSemanticError) {
bind("SELECT DISTINCT c2 FROM t1 WHERE c1 > 0 ORDER BY count(c2)");
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION));
}
+
+TEST_F(ParserTest, createDatabase) {
+ bind("create database wxy_db");
+ ASSERT_TRUE(run());
+}
+
+TEST_F(ParserTest, showDatabase) {
+ bind("show databases");
+ ASSERT_TRUE(run());
+}
+
+TEST_F(ParserTest, useDatabase) {
+ bind("use wxy_db");
+ ASSERT_TRUE(run());
+}
+
+TEST_F(ParserTest, createTable) {
+ bind("create table t1(ts timestamp, c1 int)");
+ ASSERT_TRUE(run());
+}
diff --git a/source/libs/planner/inc/plannerInt.h b/source/libs/planner/inc/plannerInt.h
index a6117c9c9b..991ad72a31 100644
--- a/source/libs/planner/inc/plannerInt.h
+++ b/source/libs/planner/inc/plannerInt.h
@@ -39,9 +39,18 @@ extern "C" {
} \
} while (0)
+#define CHECK_CODE_EXT(exec) \
+ do { \
+ int32_t code = (exec); \
+ if (TSDB_CODE_SUCCESS != code) { \
+ pCxt->errCode = code; \
+ return code; \
+ } \
+ } while (0)
+
int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode);
int32_t optimize(SPlanContext* pCxt, SLogicNode* pLogicNode);
-int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan** pPlan);
+int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan** pPlan, SArray* pExecNodeList);
#ifdef __cplusplus
}
diff --git a/source/libs/planner/src/logicPlan.c b/source/libs/planner/src/logicPlan.c
index b97248e986..05526190e7 100644
--- a/source/libs/planner/src/logicPlan.c
+++ b/source/libs/planner/src/logicPlan.c
@@ -128,6 +128,7 @@ static SLogicNode* createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
pScan->node.id = pCxt->planNodeId++;
pScan->pMeta = pRealTable->pMeta;
+ pScan->pVgroupList = pRealTable->pVgroupList;
// set columns to scan
SNodeList* pCols = NULL;
@@ -348,10 +349,20 @@ static SLogicNode* createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
return pRoot;
}
+static SLogicNode* createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt) {
+ SVnodeModifLogicNode* pModif = (SVnodeModifLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIF);
+ CHECK_ALLOC(pModif, NULL);
+ pModif->pDataBlocks = pStmt->pDataBlocks;
+ pModif->msgType = (QUERY_NODE_CREATE_TABLE_STMT == pStmt->sqlNodeType ? TDMT_VND_CREATE_TABLE : TDMT_VND_SUBMIT);
+ return (SLogicNode*)pModif;
+}
+
static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) {
switch (nodeType(pStmt)) {
case QUERY_NODE_SELECT_STMT:
- return createSelectLogicNode(pCxt, (SSelectStmt*)pStmt);
+ return createSelectLogicNode(pCxt, (SSelectStmt*)pStmt);
+ case QUERY_NODE_VNODE_MODIF_STMT:
+ return createVnodeModifLogicNode(pCxt, (SVnodeModifOpStmt*)pStmt);
default:
break;
}
diff --git a/source/libs/planner/src/physicalPlan.c b/source/libs/planner/src/physicalPlan.c
index de35b3f2c9..fa8c51c731 100644
--- a/source/libs/planner/src/physicalPlan.c
+++ b/source/libs/planner/src/physicalPlan.c
@@ -27,6 +27,7 @@ typedef struct SPhysiPlanContext {
int32_t errCode;
int16_t nextDataBlockId;
SArray* pLocationHelper;
+ SArray* pExecNodeList;
} SPhysiPlanContext;
static int32_t getSlotKey(SNode* pNode, char* pKey) {
@@ -153,17 +154,20 @@ static SNodeList* setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, ENodeType type) {
SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type);
- if (NULL == pPhysiNode) {
+ CHECK_ALLOC(pPhysiNode, NULL);
+ pPhysiNode->pOutputDataBlockDesc = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC);
+ if (NULL == pPhysiNode->pOutputDataBlockDesc) {
+ nodesDestroyNode(pPhysiNode);
return NULL;
}
- pPhysiNode->outputDataBlockDesc.dataBlockId = pCxt->nextDataBlockId++;
- pPhysiNode->outputDataBlockDesc.type = QUERY_NODE_DATABLOCK_DESC;
+ pPhysiNode->pOutputDataBlockDesc->dataBlockId = pCxt->nextDataBlockId++;
+ pPhysiNode->pOutputDataBlockDesc->type = QUERY_NODE_DATABLOCK_DESC;
return pPhysiNode;
}
static int32_t setConditionsSlotId(SPhysiPlanContext* pCxt, const SLogicNode* pLogicNode, SPhysiNode* pPhysiNode) {
if (NULL != pLogicNode->pConditions) {
- pPhysiNode->pConditions = setNodeSlotId(pCxt, pPhysiNode->outputDataBlockDesc.dataBlockId, -1, pLogicNode->pConditions);
+ pPhysiNode->pConditions = setNodeSlotId(pCxt, pPhysiNode->pOutputDataBlockDesc->dataBlockId, -1, pLogicNode->pConditions);
CHECK_ALLOC(pPhysiNode->pConditions, TSDB_CODE_OUT_OF_MEMORY);
}
return TSDB_CODE_SUCCESS;
@@ -182,17 +186,47 @@ static int32_t setSlotOutput(SPhysiPlanContext* pCxt, SNodeList* pTargets, SData
return TSDB_CODE_SUCCESS;
}
+static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
+ SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
+ CHECK_ALLOC(pCol, NULL);
+ pCol->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
+ pCol->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
+ pCol->tableId = tableId;
+ pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
+ pCol->colType = COLUMN_TYPE_COLUMN;
+ return pCol;
+}
+
+static int32_t addPrimaryKeyCol(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhysiNode) {
+ if (NULL == pScanPhysiNode->pScanCols) {
+ pScanPhysiNode->pScanCols = nodesMakeList();
+ CHECK_ALLOC(pScanPhysiNode->pScanCols, TSDB_CODE_OUT_OF_MEMORY);
+ CHECK_CODE_EXT(nodesListStrictAppend(pScanPhysiNode->pScanCols, createPrimaryKeyCol(pCxt, pScanPhysiNode->uid)));
+ return TSDB_CODE_SUCCESS;
+ }
+ SNode* pNode;
+ FOREACH(pNode, pScanPhysiNode->pScanCols) {
+ if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pNode)->colId) {
+ return TSDB_CODE_SUCCESS;
+ }
+ }
+ CHECK_CODE_EXT(nodesListStrictAppend(pScanPhysiNode->pScanCols, createPrimaryKeyCol(pCxt, pScanPhysiNode->uid)));
+ return TSDB_CODE_SUCCESS;
+}
+
static int32_t initScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SScanPhysiNode* pScanPhysiNode) {
if (NULL != pScanLogicNode->pScanCols) {
pScanPhysiNode->pScanCols = nodesCloneList(pScanLogicNode->pScanCols);
CHECK_ALLOC(pScanPhysiNode->pScanCols, TSDB_CODE_OUT_OF_MEMORY);
}
+ CHECK_CODE(addPrimaryKeyCol(pCxt, pScanPhysiNode), TSDB_CODE_OUT_OF_MEMORY);
+
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
- CHECK_CODE(addDataBlockDesc(pCxt, pScanPhysiNode->pScanCols, &pScanPhysiNode->node.outputDataBlockDesc), TSDB_CODE_OUT_OF_MEMORY);
+ CHECK_CODE(addDataBlockDesc(pCxt, pScanPhysiNode->pScanCols, pScanPhysiNode->node.pOutputDataBlockDesc), TSDB_CODE_OUT_OF_MEMORY);
CHECK_CODE(setConditionsSlotId(pCxt, (const SLogicNode*)pScanLogicNode, (SPhysiNode*)pScanPhysiNode), TSDB_CODE_OUT_OF_MEMORY);
- CHECK_CODE(setSlotOutput(pCxt, pScanLogicNode->node.pTargets, &pScanPhysiNode->node.outputDataBlockDesc), TSDB_CODE_OUT_OF_MEMORY);
+ CHECK_CODE(setSlotOutput(pCxt, pScanLogicNode->node.pTargets, pScanPhysiNode->node.pOutputDataBlockDesc), TSDB_CODE_OUT_OF_MEMORY);
pScanPhysiNode->uid = pScanLogicNode->pMeta->uid;
pScanPhysiNode->tableType = pScanLogicNode->pMeta->tableType;
@@ -203,6 +237,11 @@ static int32_t initScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanL
return TSDB_CODE_SUCCESS;
}
+static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAddr) {
+ pNodeAddr->nodeId = vg->vgId;
+ pNodeAddr->epset = vg->epset;
+}
+
static SPhysiNode* createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode) {
STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
CHECK_ALLOC(pTagScan, NULL);
@@ -210,21 +249,23 @@ static SPhysiNode* createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNod
return (SPhysiNode*)pTagScan;
}
-static SPhysiNode* createTableScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode) {
+static SPhysiNode* createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode) {
STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
CHECK_ALLOC(pTableScan, NULL);
CHECK_CODE(initScanPhysiNode(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan), (SPhysiNode*)pTableScan);
pTableScan->scanFlag = pScanLogicNode->scanFlag;
pTableScan->scanRange = pScanLogicNode->scanRange;
+ vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
+ taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
return (SPhysiNode*)pTableScan;
}
-static SPhysiNode* createScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode) {
+static SPhysiNode* createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode) {
switch (pScanLogicNode->scanType) {
case SCAN_TYPE_TAG:
return createTagScanPhysiNode(pCxt, pScanLogicNode);
case SCAN_TYPE_TABLE:
- return createTableScanPhysiNode(pCxt, pScanLogicNode);
+ return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode);
case SCAN_TYPE_STABLE:
case SCAN_TYPE_STREAM:
break;
@@ -276,18 +317,18 @@ static SPhysiNode* createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_JOIN);
CHECK_ALLOC(pJoin, NULL);
- SDataBlockDescNode* pLeftDesc = &((SPhysiNode*)nodesListGetNode(pChildren, 0))->outputDataBlockDesc;
- SDataBlockDescNode* pRightDesc = &((SPhysiNode*)nodesListGetNode(pChildren, 1))->outputDataBlockDesc;
+ SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
+ SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
pJoin->pOnConditions = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions);
CHECK_ALLOC(pJoin->pOnConditions, (SPhysiNode*)pJoin);
pJoin->pTargets = createJoinOutputCols(pCxt, pLeftDesc, pRightDesc);
CHECK_ALLOC(pJoin->pTargets, (SPhysiNode*)pJoin);
- CHECK_CODE(addDataBlockDesc(pCxt, pJoin->pTargets, &pJoin->node.outputDataBlockDesc), (SPhysiNode*)pJoin);
+ CHECK_CODE(addDataBlockDesc(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc), (SPhysiNode*)pJoin);
CHECK_CODE(setConditionsSlotId(pCxt, (const SLogicNode*)pJoinLogicNode, (SPhysiNode*)pJoin), (SPhysiNode*)pJoin);
- CHECK_CODE(setSlotOutput(pCxt, pJoinLogicNode->node.pTargets, &pJoin->node.outputDataBlockDesc), (SPhysiNode*)pJoin);
+ CHECK_CODE(setSlotOutput(pCxt, pJoinLogicNode->node.pTargets, pJoin->node.pOutputDataBlockDesc), (SPhysiNode*)pJoin);
return (SPhysiNode*)pJoin;
}
@@ -385,8 +426,8 @@ static SPhysiNode* createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
CHECK_CODE(rewritePrecalcExprs(pCxt, pAggLogicNode->pGroupKeys, &pPrecalcExprs, &pGroupKeys), (SPhysiNode*)pAgg);
CHECK_CODE(rewritePrecalcExprs(pCxt, pAggLogicNode->pAggFuncs, &pPrecalcExprs, &pAggFuncs), (SPhysiNode*)pAgg);
- SDataBlockDescNode* pChildTupe = &(((SPhysiNode*)nodesListGetNode(pChildren, 0))->outputDataBlockDesc);
- // push down expression to outputDataBlockDesc of child node
+ SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc);
+ // push down expression to pOutputDataBlockDesc of child node
if (NULL != pPrecalcExprs) {
pAgg->pExprs = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPrecalcExprs);
CHECK_ALLOC(pAgg->pExprs, (SPhysiNode*)pAgg);
@@ -396,18 +437,18 @@ static SPhysiNode* createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
if (NULL != pGroupKeys) {
pAgg->pGroupKeys = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pGroupKeys);
CHECK_ALLOC(pAgg->pGroupKeys, (SPhysiNode*)pAgg);
- CHECK_CODE(addDataBlockDesc(pCxt, pAgg->pGroupKeys, &pAgg->node.outputDataBlockDesc), (SPhysiNode*)pAgg);
+ CHECK_CODE(addDataBlockDesc(pCxt, pAgg->pGroupKeys, pAgg->node.pOutputDataBlockDesc), (SPhysiNode*)pAgg);
}
if (NULL != pAggFuncs) {
pAgg->pAggFuncs = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pAggFuncs);
CHECK_ALLOC(pAgg->pAggFuncs, (SPhysiNode*)pAgg);
- CHECK_CODE(addDataBlockDesc(pCxt, pAgg->pAggFuncs, &pAgg->node.outputDataBlockDesc), (SPhysiNode*)pAgg);
+ CHECK_CODE(addDataBlockDesc(pCxt, pAgg->pAggFuncs, pAgg->node.pOutputDataBlockDesc), (SPhysiNode*)pAgg);
}
CHECK_CODE(setConditionsSlotId(pCxt, (const SLogicNode*)pAggLogicNode, (SPhysiNode*)pAgg), (SPhysiNode*)pAgg);
- CHECK_CODE(setSlotOutput(pCxt, pAggLogicNode->node.pTargets, &pAgg->node.outputDataBlockDesc), (SPhysiNode*)pAgg);
+ CHECK_CODE(setSlotOutput(pCxt, pAggLogicNode->node.pTargets, pAgg->node.pOutputDataBlockDesc), (SPhysiNode*)pAgg);
return (SPhysiNode*)pAgg;
}
@@ -416,22 +457,22 @@ static SPhysiNode* createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
CHECK_ALLOC(pProject, NULL);
- pProject->pProjections = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->outputDataBlockDesc.dataBlockId, -1, pProjectLogicNode->pProjections);
+ pProject->pProjections = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, -1, pProjectLogicNode->pProjections);
CHECK_ALLOC(pProject->pProjections, (SPhysiNode*)pProject);
- CHECK_CODE(addDataBlockDesc(pCxt, pProject->pProjections, &pProject->node.outputDataBlockDesc), (SPhysiNode*)pProject);
+ CHECK_CODE(addDataBlockDesc(pCxt, pProject->pProjections, pProject->node.pOutputDataBlockDesc), (SPhysiNode*)pProject);
CHECK_CODE(setConditionsSlotId(pCxt, (const SLogicNode*)pProjectLogicNode, (SPhysiNode*)pProject), (SPhysiNode*)pProject);
return (SPhysiNode*)pProject;
}
-static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicPlan) {
+static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SLogicNode* pLogicPlan) {
SNodeList* pChildren = nodesMakeList();
CHECK_ALLOC(pChildren, NULL);
SNode* pLogicChild;
FOREACH(pLogicChild, pLogicPlan->pChildren) {
- SNode* pChildPhyNode = (SNode*)createPhysiNode(pCxt, (SLogicNode*)pLogicChild);
+ SNode* pChildPhyNode = (SNode*)createPhysiNode(pCxt, pSubplan, (SLogicNode*)pLogicChild);
if (TSDB_CODE_SUCCESS != nodesListAppend(pChildren, pChildPhyNode)) {
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
nodesDestroyList(pChildren);
@@ -442,7 +483,7 @@ static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicPl
SPhysiNode* pPhyNode = NULL;
switch (nodeType(pLogicPlan)) {
case QUERY_NODE_LOGIC_PLAN_SCAN:
- pPhyNode = createScanPhysiNode(pCxt, (SScanLogicNode*)pLogicPlan);
+ pPhyNode = createScanPhysiNode(pCxt, pSubplan, (SScanLogicNode*)pLogicPlan);
break;
case QUERY_NODE_LOGIC_PLAN_JOIN:
pPhyNode = createJoinPhysiNode(pCxt, pChildren, (SJoinLogicNode*)pLogicPlan);
@@ -466,91 +507,184 @@ static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicPl
return pPhyNode;
}
+static SDataSinkNode* createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks) {
+ SDataInserterNode* pInserter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT);
+ CHECK_ALLOC(pInserter, NULL);
+ pInserter->numOfTables = pBlocks->numOfTables;
+ pInserter->size = pBlocks->size;
+ TSWAP(pInserter->pData, pBlocks->pData, char*);
+ return (SDataSinkNode*)pInserter;
+}
+
+static SDataSinkNode* createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot) {
+ SDataDispatcherNode* pDispatcher = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH);
+ CHECK_ALLOC(pDispatcher, NULL);
+ pDispatcher->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc);
+ CHECK_ALLOC(pDispatcher->sink.pInputDataBlockDesc, (SDataSinkNode*)pDispatcher);
+ return (SDataSinkNode*)pDispatcher;
+}
+
static SSubplan* createPhysiSubplan(SPhysiPlanContext* pCxt, SSubLogicPlan* pLogicSubplan) {
SSubplan* pSubplan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
CHECK_ALLOC(pSubplan, NULL);
- pSubplan->pNode = createPhysiNode(pCxt, pLogicSubplan->pNode);
+ if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) {
+ SVnodeModifLogicNode* pModif = (SVnodeModifLogicNode*)pLogicSubplan->pNode;
+ pSubplan->pDataSink = createDataInserter(pCxt, pModif->pVgDataBlocks);
+ pSubplan->msgType = pModif->msgType;
+ pSubplan->execNode.epset = pModif->pVgDataBlocks->vg.epset;
+ taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
+ } else {
+ pSubplan->pNode = createPhysiNode(pCxt, pSubplan, pLogicSubplan->pNode);
+ pSubplan->pDataSink = createDataDispatcher(pCxt, pSubplan->pNode);
+ pSubplan->msgType = TDMT_VND_QUERY;
+ }
+ pSubplan->subplanType = pLogicSubplan->subplanType;
return pSubplan;
}
-static int32_t strictListAppend(SNodeList* pList, SNodeptr pNode) {
- if (NULL == pNode) {
- return TSDB_CODE_OUT_OF_MEMORY;
+static int32_t splitLogicPlan(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubLogicPlan** pSubLogicPlan) {
+ *pSubLogicPlan = (SSubLogicPlan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
+ CHECK_ALLOC(*pSubLogicPlan, TSDB_CODE_OUT_OF_MEMORY);
+ // todo pSubplan->pNode = nodesCloneNode(pLogicNode);
+ (*pSubLogicPlan)->pNode = pLogicNode;
+ if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIF == nodeType(pLogicNode)) {
+ (*pSubLogicPlan)->subplanType = SUBPLAN_TYPE_MODIFY;
}
- int32_t code = nodesListAppend(pList, pNode);
- if (TSDB_CODE_SUCCESS != code) {
- nodesDestroyNode(pNode);
- }
- return code;
+ // todo split
+ return TSDB_CODE_SUCCESS;
}
-static SQueryLogicPlan* createRawQueryLogicPlan(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode) {
+static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t level, SNodeList* pSubplans) {
+ SNodeListNode* pGroup;
+ if (level >= LIST_LENGTH(pSubplans)) {
+ pGroup = nodesMakeNode(QUERY_NODE_NODE_LIST);
+ CHECK_ALLOC(pGroup, TSDB_CODE_OUT_OF_MEMORY);
+ CHECK_CODE(nodesListStrictAppend(pSubplans, pGroup), TSDB_CODE_OUT_OF_MEMORY);
+ } else {
+ pGroup = nodesListGetNode(pSubplans, level);
+ }
+ if (NULL == pGroup->pNodeList) {
+ pGroup->pNodeList = nodesMakeList();
+ CHECK_ALLOC(pGroup->pNodeList, TSDB_CODE_OUT_OF_MEMORY);
+ }
+ CHECK_CODE(nodesListStrictAppend(pGroup->pNodeList, pSubplan), TSDB_CODE_OUT_OF_MEMORY);
+}
+
+SSubLogicPlan* singleCloneSubLogicPlan(SPhysiPlanContext* pCxt, SSubLogicPlan* pSrc, int32_t level) {
+ SSubLogicPlan* pDst = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
+ CHECK_ALLOC(pDst, NULL);
+ // todo pDst->pNode = nodesCloneNode(pSrc->pNode);
+ pDst->pNode = pSrc->pNode;
+ if (NULL == pDst->pNode) {
+ nodesDestroyNode(pDst);
+ return NULL;
+ }
+ pDst->subplanType = pSrc->subplanType;
+ pDst->level = level;
+ return pDst;
+}
+
+static int32_t doScaleOut(SPhysiPlanContext* pCxt, SSubLogicPlan* pSubplan, int32_t level, SQueryLogicPlan* pLogicPlan) {
+ if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType) {
+ SVnodeModifLogicNode* pNode = (SVnodeModifLogicNode*)pSubplan->pNode;
+ size_t numOfVgroups = taosArrayGetSize(pNode->pDataBlocks);
+ for (int32_t i = 0; i < numOfVgroups; ++i) {
+ SSubLogicPlan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
+ CHECK_ALLOC(pNewSubplan, TSDB_CODE_OUT_OF_MEMORY);
+ SVgDataBlocks* blocks = (SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i);
+ ((SVnodeModifLogicNode*)pNewSubplan->pNode)->pVgDataBlocks = blocks;
+ CHECK_CODE_EXT(pushSubplan(pCxt, pNewSubplan, level, pLogicPlan->pSubplans));
+ }
+ } else {
+ SSubLogicPlan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
+ CHECK_ALLOC(pNewSubplan, TSDB_CODE_OUT_OF_MEMORY);
+ CHECK_CODE_EXT(pushSubplan(pCxt, pNewSubplan, level, pLogicPlan->pSubplans));
+ }
+
+ SNode* pChild;
+ FOREACH(pChild, pSubplan->pChildren) {
+ CHECK_CODE_EXT(doScaleOut(pCxt, (SSubLogicPlan*)pChild, level + 1, pLogicPlan));
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static SQueryLogicPlan* makeQueryLogicPlan(SPhysiPlanContext* pCxt) {
SQueryLogicPlan* pLogicPlan = (SQueryLogicPlan*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN);
CHECK_ALLOC(pLogicPlan, NULL);
pLogicPlan->pSubplans = nodesMakeList();
- CHECK_ALLOC(pLogicPlan->pSubplans, pLogicPlan);
- SNodeListNode* pTopSubplans = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
- CHECK_ALLOC(pTopSubplans, pLogicPlan);
- CHECK_CODE(strictListAppend(pLogicPlan->pSubplans, pTopSubplans), pLogicPlan);
- pTopSubplans->pNodeList = nodesMakeList();
- CHECK_ALLOC(pTopSubplans->pNodeList, pLogicPlan);
- SSubLogicPlan* pSubplan = (SSubLogicPlan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
- CHECK_ALLOC(pSubplan, pLogicPlan);
- CHECK_CODE(strictListAppend(pTopSubplans->pNodeList, pSubplan), pLogicPlan);
- pSubplan->pNode = pLogicNode;
- CHECK_ALLOC(pSubplan->pNode, pLogicPlan);
+ if (NULL == pLogicPlan->pSubplans) {
+ nodesDestroyNode(pLogicPlan);
+ return NULL;
+ }
return pLogicPlan;
}
-static int32_t splitLogicPlan(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SQueryLogicPlan** pLogicPlan) {
- SQueryLogicPlan* pPlan = createRawQueryLogicPlan(pCxt, pLogicNode);
- if (TSDB_CODE_SUCCESS != pCxt->errCode) {
- nodesDestroyNode((SNode*)pPlan);
- return pCxt->errCode;
+static int32_t scaleOutLogicPlan(SPhysiPlanContext* pCxt, SSubLogicPlan* pRootSubLogicPlan, SQueryLogicPlan** pLogicPlan) {
+ *pLogicPlan = makeQueryLogicPlan(pCxt);
+ CHECK_ALLOC(*pLogicPlan, TSDB_CODE_OUT_OF_MEMORY);
+ return doScaleOut(pCxt, pRootSubLogicPlan, 0, *pLogicPlan);
+}
+
+typedef struct SBuildPhysiSubplanCxt {
+ int32_t errCode;
+ SQueryPlan* pQueryPlan;
+ SPhysiPlanContext* pPhyCxt;
+} SBuildPhysiSubplanCxt;
+
+static EDealRes doBuildPhysiSubplan(SNode* pNode, void* pContext) {
+ SBuildPhysiSubplanCxt* pCxt = (SBuildPhysiSubplanCxt*)pContext;
+ if (QUERY_NODE_LOGIC_SUBPLAN == nodeType(pNode)) {
+ SSubplan* pSubplan = createPhysiSubplan(pCxt->pPhyCxt, (SSubLogicPlan*)pNode);
+ CHECK_ALLOC(pSubplan, DEAL_RES_ERROR);
+ CHECK_CODE(pushSubplan(pCxt->pPhyCxt, pSubplan, ((SSubLogicPlan*)pNode)->level, pCxt->pQueryPlan->pSubplans), DEAL_RES_ERROR);
+ ++(pCxt->pQueryPlan->numOfSubplans);
+ return DEAL_RES_IGNORE_CHILD;
}
- // todo split
- *pLogicPlan = pPlan;
- return TSDB_CODE_SUCCESS;
+ return DEAL_RES_CONTINUE;
+}
+
+static SQueryPlan* makeQueryPhysiPlan(SPhysiPlanContext* pCxt) {
+ SQueryPlan* pPlan = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
+ CHECK_ALLOC(pPlan, NULL);
+ pPlan->pSubplans = nodesMakeList();
+ if (NULL == pPlan->pSubplans) {
+ nodesDestroyNode(pPlan);
+ return NULL;
+ }
+ pPlan->queryId = pCxt->pPlanCxt->queryId;
+ return pPlan;
}
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan) {
- SQueryPlan* pQueryPlan = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
- CHECK_ALLOC(pQueryPlan, TSDB_CODE_OUT_OF_MEMORY);
- *pPlan = pQueryPlan;
- pQueryPlan->queryId = pCxt->pPlanCxt->queryId;
-
- pQueryPlan->pSubplans = nodesMakeList();
- CHECK_ALLOC(pQueryPlan->pSubplans, TSDB_CODE_OUT_OF_MEMORY);
- SNode* pNode;
- FOREACH(pNode, pLogicPlan->pSubplans) {
- SNodeListNode* pLevelSubplans = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
- CHECK_ALLOC(pLevelSubplans, TSDB_CODE_OUT_OF_MEMORY);
- CHECK_CODE(strictListAppend(pQueryPlan->pSubplans, pLevelSubplans), TSDB_CODE_OUT_OF_MEMORY);
- pLevelSubplans->pNodeList = nodesMakeList();
- CHECK_ALLOC(pLevelSubplans->pNodeList, TSDB_CODE_OUT_OF_MEMORY);
- SNode* pLogicSubplan;
- FOREACH(pLogicSubplan, ((SNodeListNode*)pNode)->pNodeList) {
- CHECK_CODE(strictListAppend(pLevelSubplans->pNodeList,
- createPhysiSubplan(pCxt, (SSubLogicPlan*)pLogicSubplan)), TSDB_CODE_OUT_OF_MEMORY);
- ++(pQueryPlan->numOfSubplans);
- }
+ SBuildPhysiSubplanCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pQueryPlan = makeQueryPhysiPlan(pCxt), .pPhyCxt = pCxt };
+ CHECK_ALLOC(cxt.pQueryPlan, TSDB_CODE_OUT_OF_MEMORY);
+ nodesWalkList(pLogicPlan->pSubplans, doBuildPhysiSubplan, &cxt);
+ if (TSDB_CODE_SUCCESS != cxt.errCode) {
+ nodesDestroyNode(cxt.pQueryPlan);
+ return cxt.errCode;
}
+ *pPlan = cxt.pQueryPlan;
return TSDB_CODE_SUCCESS;
}
-int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan** pPlan) {
+int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan** pPlan, SArray* pExecNodeList) {
SPhysiPlanContext cxt = {
.pPlanCxt = pCxt,
.errCode = TSDB_CODE_SUCCESS,
.nextDataBlockId = 0,
- .pLocationHelper = taosArrayInit(32, POINTER_BYTES)
+ .pLocationHelper = taosArrayInit(32, POINTER_BYTES),
+ .pExecNodeList = pExecNodeList
};
if (NULL == cxt.pLocationHelper) {
return TSDB_CODE_OUT_OF_MEMORY;
}
SQueryLogicPlan* pLogicPlan;
- int32_t code = splitLogicPlan(&cxt, pLogicNode, &pLogicPlan);
- // todo scale out
+ SSubLogicPlan* pSubLogicPlan;
+ int32_t code = splitLogicPlan(&cxt, pLogicNode, &pSubLogicPlan);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = scaleOutLogicPlan(&cxt, pSubLogicPlan, &pLogicPlan);
+ }
// todo maping
if (TSDB_CODE_SUCCESS == code) {
code = buildPhysiPlan(&cxt, pLogicPlan, pPlan);
diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c
index 6fc0b49fbd..3481cb3352 100644
--- a/source/libs/planner/src/planner.c
+++ b/source/libs/planner/src/planner.c
@@ -21,14 +21,14 @@ int32_t optimize(SPlanContext* pCxt, SLogicNode* pLogicNode) {
return TSDB_CODE_SUCCESS;
}
-int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan) {
+int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNodeList) {
SLogicNode* pLogicNode = NULL;
int32_t code = createLogicPlan(pCxt, &pLogicNode);
if (TSDB_CODE_SUCCESS == code) {
code = optimize(pCxt, pLogicNode);
}
if (TSDB_CODE_SUCCESS == code) {
- code = createPhysiPlan(pCxt, pLogicNode, pPlan);
+ code = createPhysiPlan(pCxt, pLogicNode, pPlan, pExecNodeList);
}
return code;
}
@@ -38,6 +38,13 @@ void qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SDownstrea
}
int32_t qSubPlanToString(const SSubplan* subplan, char** str, int32_t* len) {
+ if (SUBPLAN_TYPE_MODIFY == subplan->subplanType) {
+ SDataInserterNode* insert = (SDataInserterNode*)subplan->pDataSink;
+ *len = insert->size;
+ *str = insert->pData;
+ insert->pData = NULL;
+ return TSDB_CODE_SUCCESS;
+ }
return nodesNodeToString((const SNode*)subplan, false, str, len);
}
diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp
index d5a2ebbafc..8ba80d1ab9 100644
--- a/source/libs/planner/test/plannerTest.cpp
+++ b/source/libs/planner/test/plannerTest.cpp
@@ -71,7 +71,7 @@ protected:
if (TEST_PHYSICAL_PLAN == target) {
SQueryPlan* pPlan = nullptr;
- code = createPhysiPlan(&cxt, pLogicPlan, &pPlan);
+ code = createPhysiPlan(&cxt, pLogicPlan, &pPlan, NULL);
if (code != TSDB_CODE_SUCCESS) {
cout << "sql:[" << cxt_.pSql << "] physical plan code:" << code << ", strerror:" << tstrerror(code) << endl;
return false;
@@ -109,6 +109,14 @@ private:
cout << "sql:[" << cxt_.pSql << "] toString code:" << code << ", strerror:" << tstrerror(code) << endl;
return string();
}
+ SNode* pNode;
+ code = nodesStringToNode(pStr, &pNode);
+ if (code != TSDB_CODE_SUCCESS) {
+ tfree(pStr);
+ cout << "sql:[" << cxt_.pSql << "] toObject code:" << code << ", strerror:" << tstrerror(code) << endl;
+ return string();
+ }
+ nodesDestroyNode(pNode);
string str(pStr);
tfree(pStr);
return str;
diff --git a/source/libs/qworker/test/qworkerTests.cpp b/source/libs/qworker/test/qworkerTests.cpp
index 8ad5a76388..94d4260696 100644
--- a/source/libs/qworker/test/qworkerTests.cpp
+++ b/source/libs/qworker/test/qworkerTests.cpp
@@ -14,7 +14,6 @@
*/
#include
-#include
#include
#pragma GCC diagnostic push
@@ -26,9 +25,11 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
+#include
#include "os.h"
+#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
@@ -37,7 +38,6 @@
#include "planner.h"
#include "qworker.h"
#include "stub.h"
-#include "addr_any.h"
#include "executor.h"
#include "dataSinkMgt.h"
diff --git a/source/libs/scalar/test/filter/filterTests.cpp b/source/libs/scalar/test/filter/filterTests.cpp
index 0184923638..bde3ab4196 100644
--- a/source/libs/scalar/test/filter/filterTests.cpp
+++ b/source/libs/scalar/test/filter/filterTests.cpp
@@ -14,7 +14,6 @@
*/
#include
-#include
#include
#pragma GCC diagnostic push
@@ -26,15 +25,16 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
+#include
#include "os.h"
+#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
-#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp
index 5e72954321..13c5476a9f 100644
--- a/source/libs/scalar/test/scalar/scalarTests.cpp
+++ b/source/libs/scalar/test/scalar/scalarTests.cpp
@@ -14,7 +14,6 @@
*/
#include
-#include
#include
#pragma GCC diagnostic push
@@ -26,21 +25,30 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
+#include
#include "os.h"
+#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
-#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
namespace {
+SColumnInfo createColumnInfo(int32_t colId, int32_t type, int32_t bytes) {
+ SColumnInfo info = {0};
+ info.colId = colId;
+ info.type = type;
+ info.bytes = bytes;
+ return info;
+}
+
int64_t scltLeftV = 21, scltRightV = 10;
double scltLeftVd = 21.0, scltRightVd = 10.0;
@@ -914,7 +922,7 @@ TEST(columnTest, smallint_value_add_int_column) {
SArray *blockList = taosArrayInit(2, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -954,7 +962,7 @@ TEST(columnTest, bigint_column_multi_binary_column) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -992,7 +1000,7 @@ TEST(columnTest, smallint_column_and_binary_column) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BIGINT, .bytes = sizeof(int64_t)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1025,7 +1033,7 @@ TEST(columnTest, smallint_column_or_float_column) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BIGINT, .bytes = sizeof(int64_t)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1058,7 +1066,7 @@ TEST(columnTest, smallint_column_or_double_value) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BIGINT, .bytes = sizeof(int64_t)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1091,7 +1099,7 @@ TEST(columnTest, smallint_column_greater_double_value) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1131,7 +1139,7 @@ TEST(columnTest, int_column_in_double_list) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1190,7 +1198,7 @@ TEST(columnTest, binary_column_in_binary_list) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1234,7 +1242,7 @@ TEST(columnTest, binary_column_like_binary) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1276,7 +1284,7 @@ TEST(columnTest, binary_column_is_true) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1320,7 +1328,7 @@ TEST(columnTest, binary_column_is_null) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1363,7 +1371,7 @@ TEST(columnTest, binary_column_is_not_null) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode);
@@ -1405,7 +1413,7 @@ TEST(columnTest, greater_and_lower) {
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
taosArrayPush(blockList, &src);
- SColumnInfo colInfo = {.colId = 1, .type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
+ SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool));
int16_t dataBlockId = 0, slotId = 0;
scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo);
scltMakeTargetNode(&logicNode, dataBlockId, slotId, logicNode);
diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp
index 7771fbdf0b..73060fcf6c 100644
--- a/source/libs/scheduler/test/schedulerTests.cpp
+++ b/source/libs/scheduler/test/schedulerTests.cpp
@@ -14,19 +14,8 @@
*/
#include
-#include
#include
-#include "os.h"
-
-#include "taos.h"
-#include "tdef.h"
-#include "tvariant.h"
-#include "catalog.h"
-#include "scheduler.h"
-#include "tep.h"
-#include "trpc.h"
-
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
@@ -34,10 +23,21 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
+#include
+
+#include "os.h"
+
+#include "tglobal.h"
+#include "taos.h"
+#include "tdef.h"
+#include "tvariant.h"
+#include "catalog.h"
+#include "scheduler.h"
+#include "tep.h"
+#include "trpc.h"
#include "schedulerInt.h"
#include "stub.h"
-#include "addr_any.h"
#include "tref.h"
namespace {
@@ -542,6 +542,8 @@ TEST(queryTest, normalCase) {
int64_t job = 0;
SQueryPlan dag;
+ memset(&dag, 0, sizeof(dag));
+
SArray *qnodeList = taosArrayInit(1, sizeof(SEp));
SEp qnodeAddr = {0};
diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h
index 0901330488..aedb9662b1 100644
--- a/source/libs/sync/inc/syncInt.h
+++ b/source/libs/sync/inc/syncInt.h
@@ -25,6 +25,7 @@ extern "C" {
#include
#include "sync.h"
#include "taosdef.h"
+#include "tglobal.h"
#include "tlog.h"
#include "ttimer.h"
@@ -91,31 +92,61 @@ typedef struct SyncAppendEntriesReply SyncAppendEntriesReply;
struct SSyncEnv;
typedef struct SSyncEnv SSyncEnv;
+struct SRaftStore;
+typedef struct SRaftStore SRaftStore;
+
+struct SVotesGranted;
+typedef struct SVotesGranted SVotesGranted;
+
+struct SVotesResponded;
+typedef struct SVotesResponded SVotesResponded;
+
typedef struct SRaftId {
SyncNodeId addr; // typedef uint64_t SyncNodeId;
SyncGroupId vgId; // typedef int32_t SyncGroupId;
} SRaftId;
typedef struct SSyncNode {
+ // init by SSyncInfo
SyncGroupId vgId;
SSyncCfg syncCfg;
char path[TSDB_FILENAME_LEN];
- SSyncFSM* pFsm;
-
- // passed from outside
- void* rpcClient;
+ void* rpcClient;
int32_t (*FpSendMsg)(void* rpcClient, const SEpSet* pEpSet, SRpcMsg* pMsg);
+ // init internal
+ SNodeInfo me;
+ int32_t peersNum;
+ SNodeInfo peers[TSDB_MAX_REPLICA];
+
+ // raft algorithm
+ SSyncFSM* pFsm;
+ SRaftId raftId;
+ SRaftId peersId[TSDB_MAX_REPLICA];
+ int32_t replicaNum;
+ int32_t quorum;
+
+ // life cycle
int32_t refCount;
int64_t rid;
- SNodeInfo me;
- SNodeInfo peers[TSDB_MAX_REPLICA];
- int32_t peersNum;
+ // tla+ server vars
+ ESyncState state;
+ SRaftStore* pRaftStore;
- ESyncRole role;
- SRaftId raftId;
+ // tla+ candidate vars
+ SVotesGranted* pVotesGranted;
+ SVotesResponded* pVotesResponded;
+ // tla+ leader vars
+ SHashObj* pNextIndex;
+ SHashObj* pMatchIndex;
+
+ // tla+ log vars
+ SSyncLogStore* pLogStore;
+ SyncIndex commitIndex;
+
+ // timer
tmr_h pPingTimer;
int32_t pingTimerMS;
uint8_t pingTimerStart;
@@ -136,32 +167,21 @@ typedef struct SSyncNode {
// callback
int32_t (*FpOnPing)(SSyncNode* ths, SyncPing* pMsg);
-
int32_t (*FpOnPingReply)(SSyncNode* ths, SyncPingReply* pMsg);
-
int32_t (*FpOnRequestVote)(SSyncNode* ths, SyncRequestVote* pMsg);
-
int32_t (*FpOnRequestVoteReply)(SSyncNode* ths, SyncRequestVoteReply* pMsg);
-
int32_t (*FpOnAppendEntries)(SSyncNode* ths, SyncAppendEntries* pMsg);
-
int32_t (*FpOnAppendEntriesReply)(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
} SSyncNode;
SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo);
-
-void syncNodeClose(SSyncNode* pSyncNode);
-
-void syncNodePingAll(SSyncNode* pSyncNode);
-
-void syncNodePingPeers(SSyncNode* pSyncNode);
-
-void syncNodePingSelf(SSyncNode* pSyncNode);
-
-int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode);
-
-int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode);
+void syncNodeClose(SSyncNode* pSyncNode);
+void syncNodePingAll(SSyncNode* pSyncNode);
+void syncNodePingPeers(SSyncNode* pSyncNode);
+void syncNodePingSelf(SSyncNode* pSyncNode);
+int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode);
+int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode);
#ifdef __cplusplus
}
diff --git a/source/libs/sync/inc/syncMessage.h b/source/libs/sync/inc/syncMessage.h
index be53559e8a..3057e23bc2 100644
--- a/source/libs/sync/inc/syncMessage.h
+++ b/source/libs/sync/inc/syncMessage.h
@@ -28,30 +28,25 @@ extern "C" {
#include "syncRaftEntry.h"
#include "taosdef.h"
-// encode as uint64
+// encode as uint32
typedef enum ESyncMessageType {
SYNC_PING = 101,
SYNC_PING_REPLY = 103,
- SYNC_CLIENT_REQUEST,
- SYNC_CLIENT_REQUEST_REPLY,
- SYNC_REQUEST_VOTE,
- SYNC_REQUEST_VOTE_REPLY,
- SYNC_APPEND_ENTRIES,
- SYNC_APPEND_ENTRIES_REPLY,
+ SYNC_CLIENT_REQUEST = 105,
+ SYNC_CLIENT_REQUEST_REPLY = 107,
+ SYNC_REQUEST_VOTE = 109,
+ SYNC_REQUEST_VOTE_REPLY = 111,
+ SYNC_APPEND_ENTRIES = 113,
+ SYNC_APPEND_ENTRIES_REPLY = 115,
} ESyncMessageType;
-/*
-typedef struct SRaftId {
- SyncNodeId addr; // typedef uint64_t SyncNodeId;
- SyncGroupId vgId; // typedef int32_t SyncGroupId;
-} SRaftId;
-*/
-
+// ---------------------------------------------
typedef struct SyncPing {
uint32_t bytes;
uint32_t msgType;
SRaftId srcId;
SRaftId destId;
+ // private data
uint32_t dataLen;
char data[];
} SyncPing;
@@ -59,28 +54,22 @@ typedef struct SyncPing {
#define SYNC_PING_FIX_LEN (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(uint32_t))
SyncPing* syncPingBuild(uint32_t dataLen);
-
-void syncPingDestroy(SyncPing* pMsg);
-
-void syncPingSerialize(const SyncPing* pMsg, char* buf, uint32_t bufLen);
-
-void syncPingDeserialize(const char* buf, uint32_t len, SyncPing* pMsg);
-
-void syncPing2RpcMsg(const SyncPing* pMsg, SRpcMsg* pRpcMsg);
-
-void syncPingFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPing* pMsg);
-
-cJSON* syncPing2Json(const SyncPing* pMsg);
-
+void syncPingDestroy(SyncPing* pMsg);
+void syncPingSerialize(const SyncPing* pMsg, char* buf, uint32_t bufLen);
+void syncPingDeserialize(const char* buf, uint32_t len, SyncPing* pMsg);
+void syncPing2RpcMsg(const SyncPing* pMsg, SRpcMsg* pRpcMsg);
+void syncPingFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPing* pMsg);
+cJSON* syncPing2Json(const SyncPing* pMsg);
SyncPing* syncPingBuild2(const SRaftId* srcId, const SRaftId* destId, const char* str);
-
SyncPing* syncPingBuild3(const SRaftId* srcId, const SRaftId* destId);
+// ---------------------------------------------
typedef struct SyncPingReply {
uint32_t bytes;
uint32_t msgType;
SRaftId srcId;
SRaftId destId;
+ // private data
uint32_t dataLen;
char data[];
} SyncPingReply;
@@ -89,74 +78,117 @@ typedef struct SyncPingReply {
(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(uint32_t))
SyncPingReply* syncPingReplyBuild(uint32_t dataLen);
-
-void syncPingReplyDestroy(SyncPingReply* pMsg);
-
-void syncPingReplySerialize(const SyncPingReply* pMsg, char* buf, uint32_t bufLen);
-
-void syncPingReplyDeserialize(const char* buf, uint32_t len, SyncPingReply* pMsg);
-
-void syncPingReply2RpcMsg(const SyncPingReply* pMsg, SRpcMsg* pRpcMsg);
-
-void syncPingReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPingReply* pMsg);
-
-cJSON* syncPingReply2Json(const SyncPingReply* pMsg);
-
+void syncPingReplyDestroy(SyncPingReply* pMsg);
+void syncPingReplySerialize(const SyncPingReply* pMsg, char* buf, uint32_t bufLen);
+void syncPingReplyDeserialize(const char* buf, uint32_t len, SyncPingReply* pMsg);
+void syncPingReply2RpcMsg(const SyncPingReply* pMsg, SRpcMsg* pRpcMsg);
+void syncPingReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPingReply* pMsg);
+cJSON* syncPingReply2Json(const SyncPingReply* pMsg);
SyncPingReply* syncPingReplyBuild2(const SRaftId* srcId, const SRaftId* destId, const char* str);
-
SyncPingReply* syncPingReplyBuild3(const SRaftId* srcId, const SRaftId* destId);
+// ---------------------------------------------
typedef struct SyncClientRequest {
- ESyncMessageType msgType;
- char* data;
- uint32_t dataLen;
- int64_t seqNum;
- bool isWeak;
+ uint32_t bytes;
+ uint32_t msgType;
+ int64_t seqNum;
+ bool isWeak;
+ uint32_t dataLen;
+ char data[];
} SyncClientRequest;
+// ---------------------------------------------
typedef struct SyncClientRequestReply {
- ESyncMessageType msgType;
- int32_t errCode;
- SSyncBuffer* pErrMsg;
- SSyncBuffer* pLeaderHint;
+ uint32_t bytes;
+ uint32_t msgType;
+ int32_t errCode;
+ SRaftId leaderHint;
} SyncClientRequestReply;
+// ---------------------------------------------
typedef struct SyncRequestVote {
- ESyncMessageType msgType;
- SyncTerm currentTerm;
- SyncNodeId nodeId;
- SyncGroupId vgId;
- SyncIndex lastLogIndex;
- SyncTerm lastLogTerm;
+ uint32_t bytes;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+ // private data
+ SyncTerm currentTerm;
+ SyncIndex lastLogIndex;
+ SyncTerm lastLogTerm;
} SyncRequestVote;
+SyncRequestVote* syncRequestVoteBuild();
+void syncRequestVoteDestroy(SyncRequestVote* pMsg);
+void syncRequestVoteSerialize(const SyncRequestVote* pMsg, char* buf, uint32_t bufLen);
+void syncRequestVoteDeserialize(const char* buf, uint32_t len, SyncRequestVote* pMsg);
+void syncRequestVote2RpcMsg(const SyncRequestVote* pMsg, SRpcMsg* pRpcMsg);
+void syncRequestVoteFromRpcMsg(const SRpcMsg* pRpcMsg, SyncRequestVote* pMsg);
+cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg);
+
+// ---------------------------------------------
typedef struct SyncRequestVoteReply {
- ESyncMessageType msgType;
- SyncTerm currentTerm;
- SyncNodeId nodeId;
- SyncGroupId vgId;
- bool voteGranted;
+ uint32_t bytes;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+ // private data
+ SyncTerm term;
+ bool voteGranted;
} SyncRequestVoteReply;
+SyncRequestVoteReply* SyncRequestVoteReplyBuild();
+void syncRequestVoteReplyDestroy(SyncRequestVoteReply* pMsg);
+void syncRequestVoteReplySerialize(const SyncRequestVoteReply* pMsg, char* buf, uint32_t bufLen);
+void syncRequestVoteReplyDeserialize(const char* buf, uint32_t len, SyncRequestVoteReply* pMsg);
+void syncRequestVoteReply2RpcMsg(const SyncRequestVoteReply* pMsg, SRpcMsg* pRpcMsg);
+void syncRequestVoteReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncRequestVoteReply* pMsg);
+cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg);
+
+// ---------------------------------------------
typedef struct SyncAppendEntries {
- ESyncMessageType msgType;
- SyncTerm currentTerm;
- SyncNodeId nodeId;
- SyncIndex prevLogIndex;
- SyncTerm prevLogTerm;
- int32_t entryCount;
- SSyncRaftEntry* logEntries;
- SyncIndex commitIndex;
+ uint32_t bytes;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+ // private data
+ SyncIndex prevLogIndex;
+ SyncTerm prevLogTerm;
+ SyncIndex commitIndex;
+ uint32_t dataLen;
+ char data[];
} SyncAppendEntries;
+#define SYNC_APPEND_ENTRIES_FIX_LEN \
+ (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(SyncIndex) + sizeof(SyncTerm) + \
+ sizeof(SyncIndex) + sizeof(uint32_t))
+
+SyncAppendEntries* syncAppendEntriesBuild(uint32_t dataLen);
+void syncAppendEntriesDestroy(SyncAppendEntries* pMsg);
+void syncAppendEntriesSerialize(const SyncAppendEntries* pMsg, char* buf, uint32_t bufLen);
+void syncAppendEntriesDeserialize(const char* buf, uint32_t len, SyncAppendEntries* pMsg);
+void syncAppendEntries2RpcMsg(const SyncAppendEntries* pMsg, SRpcMsg* pRpcMsg);
+void syncAppendEntriesFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntries* pMsg);
+cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg);
+
+// ---------------------------------------------
typedef struct SyncAppendEntriesReply {
- ESyncMessageType msgType;
- SyncTerm currentTerm;
- SyncNodeId nodeId;
- bool success;
- SyncIndex matchIndex;
+ uint32_t bytes;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+ // private data
+ bool success;
+ SyncIndex matchIndex;
} SyncAppendEntriesReply;
+SyncAppendEntriesReply* syncAppendEntriesReplyBuild();
+void syncAppendEntriesReplyDestroy(SyncAppendEntriesReply* pMsg);
+void syncAppendEntriesReplySerialize(const SyncAppendEntriesReply* pMsg, char* buf, uint32_t bufLen);
+void syncAppendEntriesReplyDeserialize(const char* buf, uint32_t len, SyncAppendEntriesReply* pMsg);
+void syncAppendEntriesReply2RpcMsg(const SyncAppendEntriesReply* pMsg, SRpcMsg* pRpcMsg);
+void syncAppendEntriesReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntriesReply* pMsg);
+cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/libs/sync/inc/syncVoteMgr.h b/source/libs/sync/inc/syncVoteMgr.h
index cfcf58bee2..b841f2e316 100644
--- a/source/libs/sync/inc/syncVoteMgr.h
+++ b/source/libs/sync/inc/syncVoteMgr.h
@@ -26,6 +26,12 @@ extern "C" {
#include "syncInt.h"
#include "taosdef.h"
+typedef struct SVotesGranted {
+} SVotesGranted;
+
+typedef struct SVotesResponded {
+} SVotesResponded;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c
index 8d04b5bb26..3ba145a96b 100644
--- a/source/libs/sync/src/syncIO.c
+++ b/source/libs/sync/src/syncIO.c
@@ -211,23 +211,17 @@ static void *syncIOConsumerFunc(void *param) {
if (pRpcMsg->msgType == SYNC_PING) {
if (io->FpOnSyncPing != NULL) {
SyncPing *pSyncMsg;
-
- SRpcMsg tmpRpcMsg;
- memcpy(&tmpRpcMsg, pRpcMsg, sizeof(SRpcMsg));
- pSyncMsg = syncPingBuild(tmpRpcMsg.contLen);
-
+ pSyncMsg = syncPingBuild(pRpcMsg->contLen);
syncPingFromRpcMsg(pRpcMsg, pSyncMsg);
-
// memcpy(pSyncMsg, tmpRpcMsg.pCont, tmpRpcMsg.contLen);
-
io->FpOnSyncPing(io->pSyncNode, pSyncMsg);
}
} else if (pRpcMsg->msgType == SYNC_PING_REPLY) {
- SyncPingReply *pSyncMsg = syncPingReplyBuild(pRpcMsg->contLen);
- syncPingReplyFromRpcMsg(pRpcMsg, pSyncMsg);
-
if (io->FpOnSyncPingReply != NULL) {
+ SyncPingReply *pSyncMsg;
+ pSyncMsg = syncPingReplyBuild(pRpcMsg->contLen);
+ syncPingReplyFromRpcMsg(pRpcMsg, pSyncMsg);
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
}
} else {
diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c
index 49fac038da..7e01e7e81c 100644
--- a/source/libs/sync/src/syncMain.c
+++ b/source/libs/sync/src/syncMain.c
@@ -88,7 +88,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
}
}
- pSyncNode->role = TAOS_SYNC_STATE_FOLLOWER;
+ pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER;
syncUtilnodeInfo2raftId(&pSyncNode->me, pSyncNode->vgId, &pSyncNode->raftId);
pSyncNode->pPingTimer = NULL;
@@ -171,16 +171,6 @@ static int32_t syncNodePing(SSyncNode* pSyncNode, const SRaftId* destRaftId, Syn
SRpcMsg rpcMsg;
syncPing2RpcMsg(pMsg, &rpcMsg);
-
- /*
- SRpcMsg rpcMsg;
- rpcMsg.contLen = 64;
- rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
- snprintf((char*)rpcMsg.pCont, rpcMsg.contLen, "%s", "xxxxxxxxxxxxxx");
- rpcMsg.handle = NULL;
- rpcMsg.msgType = 1;
- */
-
syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg);
{
diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c
index a26c8401b2..4c44b4691c 100644
--- a/source/libs/sync/src/syncMessage.c
+++ b/source/libs/sync/src/syncMessage.c
@@ -60,12 +60,15 @@ void syncPingFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPing* pMsg) {
}
cJSON* syncPing2Json(const SyncPing* pMsg) {
+ char u64buf[128];
+
cJSON* pRoot = cJSON_CreateObject();
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
cJSON* pSrcId = cJSON_CreateObject();
- cJSON_AddNumberToObject(pSrcId, "addr", pMsg->srcId.addr);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
{
uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId;
@@ -79,7 +82,8 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
cJSON* pDestId = cJSON_CreateObject();
- cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
{
uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId;
@@ -154,12 +158,15 @@ void syncPingReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPingReply* pMsg) {
}
cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
+ char u64buf[128];
+
cJSON* pRoot = cJSON_CreateObject();
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
cJSON* pSrcId = cJSON_CreateObject();
- cJSON_AddNumberToObject(pSrcId, "addr", pMsg->srcId.addr);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
{
uint64_t u64 = pMsg->srcId.addr;
cJSON* pTmp = pSrcId;
@@ -173,7 +180,8 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
cJSON* pDestId = cJSON_CreateObject();
- cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
{
uint64_t u64 = pMsg->destId.addr;
cJSON* pTmp = pDestId;
@@ -208,72 +216,345 @@ SyncPingReply* syncPingReplyBuild3(const SRaftId* srcId, const SRaftId* destId)
return pMsg;
}
-#if 0
-void syncPingSerialize(const SyncPing* pMsg, char** ppBuf, uint32_t* bufLen) {
- *bufLen = sizeof(SyncPing) + pMsg->dataLen;
- *ppBuf = (char*)malloc(*bufLen);
- void* pStart = *ppBuf;
- uint32_t allBytes = *bufLen;
-
- int len = 0;
- len = taosEncodeFixedU32(&pStart, pMsg->msgType);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- len = taosEncodeFixedU64(&pStart, pMsg->srcId.addr);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- len = taosEncodeFixedI32(&pStart, pMsg->srcId.vgId);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- len = taosEncodeFixedU64(&pStart, pMsg->destId.addr);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- len = taosEncodeFixedI32(&pStart, pMsg->destId.vgId);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- len = taosEncodeFixedU32(&pStart, pMsg->dataLen);
- allBytes -= len;
- assert(len > 0);
- pStart += len;
-
- memcpy(pStart, pMsg->data, pMsg->dataLen);
- allBytes -= pMsg->dataLen;
- assert(allBytes == 0);
+// ---- message process SyncRequestVote----
+SyncRequestVote* syncRequestVoteBuild() {
+ uint32_t bytes = sizeof(SyncRequestVote);
+ SyncRequestVote* pMsg = malloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->msgType = SYNC_REQUEST_VOTE;
}
-
-void syncPingDeserialize(const char* buf, uint32_t len, SyncPing* pMsg) {
- void* pStart = (void*)buf;
- uint64_t u64;
- int32_t i32;
- uint32_t u32;
-
- pStart = taosDecodeFixedU64(pStart, &u64);
- pMsg->msgType = u64;
-
- pStart = taosDecodeFixedU64(pStart, &u64);
- pMsg->srcId.addr = u64;
-
- pStart = taosDecodeFixedI32(pStart, &i32);
- pMsg->srcId.vgId = i32;
-
- pStart = taosDecodeFixedU64(pStart, &u64);
- pMsg->destId.addr = u64;
-
- pStart = taosDecodeFixedI32(pStart, &i32);
- pMsg->destId.vgId = i32;
-
- pStart = taosDecodeFixedU32(pStart, &u32);
- pMsg->dataLen = u32;
+void syncRequestVoteDestroy(SyncRequestVote* pMsg) {
+ if (pMsg != NULL) {
+ free(pMsg);
+ }
}
-#endif
\ No newline at end of file
+
+void syncRequestVoteSerialize(const SyncRequestVote* pMsg, char* buf, uint32_t bufLen) {
+ assert(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncRequestVoteDeserialize(const char* buf, uint32_t len, SyncRequestVote* pMsg) {
+ memcpy(pMsg, buf, len);
+ assert(len == pMsg->bytes);
+}
+
+void syncRequestVote2RpcMsg(const SyncRequestVote* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncRequestVoteSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncRequestVoteFromRpcMsg(const SRpcMsg* pRpcMsg, SyncRequestVote* pMsg) {
+ syncRequestVoteDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
+ char u64buf[128];
+
+ cJSON* pRoot = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->currentTerm);
+ cJSON_AddStringToObject(pRoot, "currentTerm", u64buf);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex);
+ cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm);
+ cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf);
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncRequestVote", pRoot);
+ return pJson;
+}
+
+// ---- message process SyncRequestVoteReply----
+SyncRequestVoteReply* SyncRequestVoteReplyBuild() {
+ uint32_t bytes = sizeof(SyncRequestVoteReply);
+ SyncRequestVoteReply* pMsg = malloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->msgType = SYNC_REQUEST_VOTE_REPLY;
+}
+
+void syncRequestVoteReplyDestroy(SyncRequestVoteReply* pMsg) {
+ if (pMsg != NULL) {
+ free(pMsg);
+ }
+}
+
+void syncRequestVoteReplySerialize(const SyncRequestVoteReply* pMsg, char* buf, uint32_t bufLen) {
+ assert(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncRequestVoteReplyDeserialize(const char* buf, uint32_t len, SyncRequestVoteReply* pMsg) {
+ memcpy(pMsg, buf, len);
+ assert(len == pMsg->bytes);
+}
+
+void syncRequestVoteReply2RpcMsg(const SyncRequestVoteReply* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncRequestVoteReplySerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncRequestVoteReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncRequestVoteReply* pMsg) {
+ syncRequestVoteReplyDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) {
+ char u64buf[128];
+
+ cJSON* pRoot = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term);
+ cJSON_AddStringToObject(pRoot, "term", u64buf);
+ cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted);
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncRequestVoteReply", pRoot);
+ return pJson;
+}
+
+// ---- message process SyncAppendEntries----
+SyncAppendEntries* syncAppendEntriesBuild(uint32_t dataLen) {
+ uint32_t bytes = SYNC_APPEND_ENTRIES_FIX_LEN + dataLen;
+ SyncAppendEntries* pMsg = malloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->msgType = SYNC_APPEND_ENTRIES;
+ pMsg->dataLen = dataLen;
+}
+
+void syncAppendEntriesDestroy(SyncAppendEntries* pMsg) {
+ if (pMsg != NULL) {
+ free(pMsg);
+ }
+}
+
+void syncAppendEntriesSerialize(const SyncAppendEntries* pMsg, char* buf, uint32_t bufLen) {
+ assert(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncAppendEntriesDeserialize(const char* buf, uint32_t len, SyncAppendEntries* pMsg) {
+ memcpy(pMsg, buf, len);
+ assert(len == pMsg->bytes);
+ assert(pMsg->bytes == SYNC_APPEND_ENTRIES_FIX_LEN + pMsg->dataLen);
+}
+
+void syncAppendEntries2RpcMsg(const SyncAppendEntries* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncAppendEntriesSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncAppendEntriesFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntries* pMsg) {
+ syncAppendEntriesDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
+ char u64buf[128];
+
+ cJSON* pRoot = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex);
+ cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf);
+
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm);
+ cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf);
+
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex);
+ cJSON_AddStringToObject(pRoot, "commit_index", u64buf);
+
+ cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen);
+ cJSON_AddStringToObject(pRoot, "data", pMsg->data);
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncAppendEntries", pRoot);
+ return pJson;
+}
+
+// ---- message process SyncAppendEntriesReply----
+SyncAppendEntriesReply* syncAppendEntriesReplyBuild() {
+ uint32_t bytes = sizeof(SyncAppendEntriesReply);
+ SyncAppendEntriesReply* pMsg = malloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->msgType = SYNC_APPEND_ENTRIES_REPLY;
+}
+
+void syncAppendEntriesReplyDestroy(SyncAppendEntriesReply* pMsg) {
+ if (pMsg != NULL) {
+ free(pMsg);
+ }
+}
+
+void syncAppendEntriesReplySerialize(const SyncAppendEntriesReply* pMsg, char* buf, uint32_t bufLen) {
+ assert(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncAppendEntriesReplyDeserialize(const char* buf, uint32_t len, SyncAppendEntriesReply* pMsg) {
+ memcpy(pMsg, buf, len);
+ assert(len == pMsg->bytes);
+}
+
+void syncAppendEntriesReply2RpcMsg(const SyncAppendEntriesReply* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncAppendEntriesReplySerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncAppendEntriesReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntriesReply* pMsg) {
+ syncAppendEntriesReplyDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
+ char u64buf[128];
+
+ cJSON* pRoot = cJSON_CreateObject();
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128];
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ cJSON_AddNumberToObject(pRoot, "success", pMsg->success);
+ snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex);
+ cJSON_AddStringToObject(pRoot, "match_index", u64buf);
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncAppendEntriesReply", pRoot);
+ return pJson;
+}
\ No newline at end of file
diff --git a/source/libs/sync/test/syncEncodeTest.cpp b/source/libs/sync/test/syncEncodeTest.cpp
index 4deceb603e..6197621051 100644
--- a/source/libs/sync/test/syncEncodeTest.cpp
+++ b/source/libs/sync/test/syncEncodeTest.cpp
@@ -3,6 +3,7 @@
#include "syncIO.h"
#include "syncInt.h"
#include "syncMessage.h"
+#include "syncUtil.h"
void logTest() {
sTrace("--- sync log test: trace");
@@ -14,6 +15,7 @@ void logTest() {
}
#define PING_MSG_LEN 20
+#define APPEND_ENTRIES_VALUE_LEN 32
void test1() {
sTrace("test1: ---- syncPingSerialize, syncPingDeserialize");
@@ -21,16 +23,16 @@ void test1() {
char msg[PING_MSG_LEN];
snprintf(msg, sizeof(msg), "%s", "test ping");
SyncPing* pMsg = syncPingBuild(PING_MSG_LEN);
- pMsg->srcId.addr = 1;
- pMsg->srcId.vgId = 2;
- pMsg->destId.addr = 3;
- pMsg->destId.vgId = 4;
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1111);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 2222);
+ pMsg->destId.vgId = 100;
memcpy(pMsg->data, msg, PING_MSG_LEN);
{
cJSON* pJson = syncPing2Json(pMsg);
char* serialized = cJSON_Print(pJson);
- printf("SyncPing: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -45,7 +47,7 @@ void test1() {
{
cJSON* pJson = syncPing2Json(pMsg2);
char* serialized = cJSON_Print(pJson);
- printf("SyncPing2: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -61,16 +63,16 @@ void test2() {
char msg[PING_MSG_LEN];
snprintf(msg, sizeof(msg), "%s", "hello raft");
SyncPing* pMsg = syncPingBuild(PING_MSG_LEN);
- pMsg->srcId.addr = 100;
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 3333);
pMsg->srcId.vgId = 200;
- pMsg->destId.addr = 300;
- pMsg->destId.vgId = 400;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 4444);
+ pMsg->destId.vgId = 200;
memcpy(pMsg->data, msg, PING_MSG_LEN);
{
cJSON* pJson = syncPing2Json(pMsg);
char* serialized = cJSON_Print(pJson);
- printf("SyncPing: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -84,7 +86,7 @@ void test2() {
{
cJSON* pJson = syncPing2Json(pMsg2);
char* serialized = cJSON_Print(pJson);
- printf("SyncPing2: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -99,16 +101,16 @@ void test3() {
char msg[PING_MSG_LEN];
snprintf(msg, sizeof(msg), "%s", "test ping");
SyncPingReply* pMsg = syncPingReplyBuild(PING_MSG_LEN);
- pMsg->srcId.addr = 19;
- pMsg->srcId.vgId = 29;
- pMsg->destId.addr = 39;
- pMsg->destId.vgId = 49;
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 5555);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 6666);
+ pMsg->destId.vgId = 100;
memcpy(pMsg->data, msg, PING_MSG_LEN);
{
cJSON* pJson = syncPingReply2Json(pMsg);
char* serialized = cJSON_Print(pJson);
- printf("SyncPingReply: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -123,7 +125,7 @@ void test3() {
{
cJSON* pJson = syncPingReply2Json(pMsg2);
char* serialized = cJSON_Print(pJson);
- printf("SyncPingReply2: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -139,16 +141,16 @@ void test4() {
char msg[PING_MSG_LEN];
snprintf(msg, sizeof(msg), "%s", "hello raft");
SyncPingReply* pMsg = syncPingReplyBuild(PING_MSG_LEN);
- pMsg->srcId.addr = 66;
- pMsg->srcId.vgId = 77;
- pMsg->destId.addr = 88;
- pMsg->destId.vgId = 99;
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 7777);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 8888);
+ pMsg->destId.vgId = 100;
memcpy(pMsg->data, msg, PING_MSG_LEN);
{
cJSON* pJson = syncPingReply2Json(pMsg);
char* serialized = cJSON_Print(pJson);
- printf("SyncPingReply: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -162,7 +164,7 @@ void test4() {
{
cJSON* pJson = syncPingReply2Json(pMsg2);
char* serialized = cJSON_Print(pJson);
- printf("SyncPingReply2: \n%s\n\n", serialized);
+ printf("\n%s\n\n", serialized);
free(serialized);
cJSON_Delete(pJson);
}
@@ -170,6 +172,321 @@ void test4() {
syncPingReplyDestroy(pMsg);
syncPingReplyDestroy(pMsg2);
}
+
+void test5() {
+ sTrace("test5: ---- syncRequestVoteSerialize, syncRequestVoteDeserialize");
+
+ SyncRequestVote* pMsg = syncRequestVoteBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("8.8.8.8", 5678);
+ pMsg->destId.vgId = 100;
+ pMsg->currentTerm = 20;
+ pMsg->lastLogIndex = 21;
+ pMsg->lastLogTerm = 22;
+
+ {
+ cJSON* pJson = syncRequestVote2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ uint32_t bufLen = pMsg->bytes;
+ char* buf = (char*)malloc(bufLen);
+ syncRequestVoteSerialize(pMsg, buf, bufLen);
+
+ SyncRequestVote* pMsg2 = (SyncRequestVote*)malloc(pMsg->bytes);
+ syncRequestVoteDeserialize(buf, bufLen, pMsg2);
+
+ {
+ cJSON* pJson = syncRequestVote2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncRequestVoteDestroy(pMsg);
+ syncRequestVoteDestroy(pMsg2);
+ free(buf);
+}
+
+void test6() {
+ sTrace("test6: ---- syncRequestVote2RpcMsg, syncRequestVoteFromRpcMsg");
+
+ SyncRequestVote* pMsg = syncRequestVoteBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("8.8.8.8", 5678);
+ pMsg->destId.vgId = 100;
+ pMsg->currentTerm = 20;
+ pMsg->lastLogIndex = 21;
+ pMsg->lastLogTerm = 22;
+
+ {
+ cJSON* pJson = syncRequestVote2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ SRpcMsg rpcMsg;
+ syncRequestVote2RpcMsg(pMsg, &rpcMsg);
+ SyncRequestVote* pMsg2 = (SyncRequestVote*)malloc(pMsg->bytes);
+ syncRequestVoteFromRpcMsg(&rpcMsg, pMsg2);
+ rpcFreeCont(rpcMsg.pCont);
+
+ {
+ cJSON* pJson = syncRequestVote2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncRequestVoteDestroy(pMsg);
+ syncRequestVoteDestroy(pMsg2);
+}
+
+void test7() {
+ sTrace("test7: ---- syncRequestVoteReplySerialize, syncRequestVoteReplyDeserialize");
+
+ SyncRequestVoteReply* pMsg = SyncRequestVoteReplyBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("8.8.8.8", 5678);
+ pMsg->destId.vgId = 100;
+ pMsg->term = 20;
+ pMsg->voteGranted = 1;
+
+ {
+ cJSON* pJson = syncRequestVoteReply2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ uint32_t bufLen = pMsg->bytes;
+ char* buf = (char*)malloc(bufLen);
+ syncRequestVoteReplySerialize(pMsg, buf, bufLen);
+
+ SyncRequestVoteReply* pMsg2 = (SyncRequestVoteReply*)malloc(pMsg->bytes);
+ syncRequestVoteReplyDeserialize(buf, bufLen, pMsg2);
+
+ {
+ cJSON* pJson = syncRequestVoteReply2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncRequestVoteReplyDestroy(pMsg);
+ syncRequestVoteReplyDestroy(pMsg2);
+ free(buf);
+}
+
+void test8() {
+ sTrace("test8: ---- syncRequestVoteReply2RpcMsg, syncRequestVoteReplyFromRpcMsg");
+
+ SyncRequestVoteReply* pMsg = SyncRequestVoteReplyBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("8.8.8.8", 5678);
+ pMsg->destId.vgId = 100;
+ pMsg->term = 20;
+ pMsg->voteGranted = 1;
+
+ {
+ cJSON* pJson = syncRequestVoteReply2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ SRpcMsg rpcMsg;
+ syncRequestVoteReply2RpcMsg(pMsg, &rpcMsg);
+ SyncRequestVoteReply* pMsg2 = (SyncRequestVoteReply*)malloc(pMsg->bytes);
+ syncRequestVoteReplyFromRpcMsg(&rpcMsg, pMsg2);
+ rpcFreeCont(rpcMsg.pCont);
+
+ {
+ cJSON* pJson = syncRequestVoteReply2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncRequestVoteReplyDestroy(pMsg);
+ syncRequestVoteReplyDestroy(pMsg2);
+}
+
+void test9() {
+ sTrace("test9: ---- syncAppendEntriesSerialize, syncAppendEntriesDeserialize");
+
+ char msg[APPEND_ENTRIES_VALUE_LEN];
+ snprintf(msg, sizeof(msg), "%s", "test value");
+ SyncAppendEntries* pMsg = syncAppendEntriesBuild(APPEND_ENTRIES_VALUE_LEN);
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1111);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 2222);
+ pMsg->destId.vgId = 100;
+ pMsg->prevLogIndex = 55;
+ pMsg->prevLogTerm = 66;
+ pMsg->commitIndex = 77;
+ memcpy(pMsg->data, msg, APPEND_ENTRIES_VALUE_LEN);
+
+ {
+ cJSON* pJson = syncAppendEntries2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ uint32_t bufLen = pMsg->bytes;
+ char* buf = (char*)malloc(bufLen);
+ syncAppendEntriesSerialize(pMsg, buf, bufLen);
+
+ SyncAppendEntries* pMsg2 = (SyncAppendEntries*)malloc(pMsg->bytes);
+ syncAppendEntriesDeserialize(buf, bufLen, pMsg2);
+
+ {
+ cJSON* pJson = syncAppendEntries2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncAppendEntriesDestroy(pMsg);
+ syncAppendEntriesDestroy(pMsg2);
+ free(buf);
+}
+
+void test10() {
+ sTrace("test10: ---- syncAppendEntries2RpcMsg, syncAppendEntriesFromRpcMsg");
+
+ char msg[APPEND_ENTRIES_VALUE_LEN];
+ snprintf(msg, sizeof(msg), "%s", "test value");
+ SyncAppendEntries* pMsg = syncAppendEntriesBuild(APPEND_ENTRIES_VALUE_LEN);
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1111);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 2222);
+ pMsg->destId.vgId = 100;
+ pMsg->prevLogIndex = 55;
+ pMsg->prevLogTerm = 66;
+ pMsg->commitIndex = 77;
+ memcpy(pMsg->data, msg, APPEND_ENTRIES_VALUE_LEN);
+
+ {
+ cJSON* pJson = syncAppendEntries2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ SRpcMsg rpcMsg;
+ syncAppendEntries2RpcMsg(pMsg, &rpcMsg);
+ SyncAppendEntries* pMsg2 = (SyncAppendEntries*)malloc(pMsg->bytes);
+ syncAppendEntriesFromRpcMsg(&rpcMsg, pMsg2);
+ rpcFreeCont(rpcMsg.pCont);
+
+ {
+ cJSON* pJson = syncAppendEntries2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncAppendEntriesDestroy(pMsg);
+ syncAppendEntriesDestroy(pMsg2);
+}
+
+void test11() {
+ sTrace("test11: ---- syncAppendEntriesReplySerialize, syncAppendEntriesReplyDeserialize");
+
+ SyncAppendEntriesReply* pMsg = syncAppendEntriesReplyBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1111);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 2222);
+ pMsg->destId.vgId = 100;
+ pMsg->success = 1;
+ pMsg->matchIndex = 23;
+
+ {
+ cJSON* pJson = syncAppendEntriesReply2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ uint32_t bufLen = pMsg->bytes;
+ char* buf = (char*)malloc(bufLen);
+ syncAppendEntriesReplySerialize(pMsg, buf, bufLen);
+
+ SyncAppendEntriesReply* pMsg2 = (SyncAppendEntriesReply*)malloc(pMsg->bytes);
+ syncAppendEntriesReplyDeserialize(buf, bufLen, pMsg2);
+
+ {
+ cJSON* pJson = syncAppendEntriesReply2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncAppendEntriesReplyDestroy(pMsg);
+ syncAppendEntriesReplyDestroy(pMsg2);
+ free(buf);
+}
+
+void test12() {
+ sTrace("test12: ---- syncAppendEntriesReply2RpcMsg, syncAppendEntriesReplyFromRpcMsg");
+
+ SyncAppendEntriesReply* pMsg = syncAppendEntriesReplyBuild();
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1111);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 2222);
+ pMsg->destId.vgId = 100;
+ pMsg->success = 1;
+ pMsg->matchIndex = 23;
+
+ {
+ cJSON* pJson = syncAppendEntriesReply2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ SRpcMsg rpcMsg;
+ syncAppendEntriesReply2RpcMsg(pMsg, &rpcMsg);
+ SyncAppendEntriesReply* pMsg2 = (SyncAppendEntriesReply*)malloc(pMsg->bytes);
+ syncAppendEntriesReplyFromRpcMsg(&rpcMsg, pMsg2);
+ rpcFreeCont(rpcMsg.pCont);
+
+ {
+ cJSON* pJson = syncAppendEntriesReply2Json(pMsg2);
+ char* serialized = cJSON_Print(pJson);
+ printf("\n%s\n\n", serialized);
+ free(serialized);
+ cJSON_Delete(pJson);
+ }
+
+ syncAppendEntriesReplyDestroy(pMsg);
+ syncAppendEntriesReplyDestroy(pMsg2);
+}
+
int main() {
// taosInitLog((char*)"syncPingTest.log", 100000, 10);
tsAsyncLog = 0;
@@ -179,6 +496,14 @@ int main() {
test2();
test3();
test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
return 0;
}
diff --git a/source/libs/sync/test/syncIOSendMsgClientTest.cpp b/source/libs/sync/test/syncIOSendMsgClientTest.cpp
index 9e8c7c8b65..0d06c4f811 100644
--- a/source/libs/sync/test/syncIOSendMsgClientTest.cpp
+++ b/source/libs/sync/test/syncIOSendMsgClientTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/sync/test/syncIOSendMsgServerTest.cpp b/source/libs/sync/test/syncIOSendMsgServerTest.cpp
index 8af9344ed6..1582e097d3 100644
--- a/source/libs/sync/test/syncIOSendMsgServerTest.cpp
+++ b/source/libs/sync/test/syncIOSendMsgServerTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/sync/test/syncIOSendMsgTest.cpp b/source/libs/sync/test/syncIOSendMsgTest.cpp
index a297981ee5..9b2cfcf1d8 100644
--- a/source/libs/sync/test/syncIOSendMsgTest.cpp
+++ b/source/libs/sync/test/syncIOSendMsgTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/sync/test/syncIOTickPingTest.cpp b/source/libs/sync/test/syncIOTickPingTest.cpp
index 1559b57585..42b9a73432 100644
--- a/source/libs/sync/test/syncIOTickPingTest.cpp
+++ b/source/libs/sync/test/syncIOTickPingTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/sync/test/syncIOTickQTest.cpp b/source/libs/sync/test/syncIOTickQTest.cpp
index 90304079e3..3d31c596bf 100644
--- a/source/libs/sync/test/syncIOTickQTest.cpp
+++ b/source/libs/sync/test/syncIOTickQTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/sync/test/syncPingTest.cpp b/source/libs/sync/test/syncPingTest.cpp
index 24d9ead5e3..8268128347 100644
--- a/source/libs/sync/test/syncPingTest.cpp
+++ b/source/libs/sync/test/syncPingTest.cpp
@@ -13,7 +13,9 @@ void logTest() {
sFatal("--- sync log test: fatal");
}
-SSyncNode* doSync() {
+uint16_t ports[3] = {7010, 7110, 7210};
+
+SSyncNode* doSync(int myIndex) {
SSyncFSM* pFsm;
SSyncInfo syncInfo;
@@ -24,18 +26,18 @@ SSyncNode* doSync() {
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./test_sync_ping");
SSyncCfg* pCfg = &syncInfo.syncCfg;
- pCfg->myIndex = 0;
- pCfg->replicaNum = 2;
+ pCfg->myIndex = myIndex;
+ pCfg->replicaNum = 3;
- pCfg->nodeInfo[0].nodePort = 7010;
+ pCfg->nodeInfo[0].nodePort = ports[0];
snprintf(pCfg->nodeInfo[0].nodeFqdn, sizeof(pCfg->nodeInfo[0].nodeFqdn), "%s", "127.0.0.1");
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
- pCfg->nodeInfo[1].nodePort = 7110;
+ pCfg->nodeInfo[1].nodePort = ports[1];
snprintf(pCfg->nodeInfo[1].nodeFqdn, sizeof(pCfg->nodeInfo[1].nodeFqdn), "%s", "127.0.0.1");
// taosGetFqdn(pCfg->nodeInfo[1].nodeFqdn);
- pCfg->nodeInfo[2].nodePort = 7210;
+ pCfg->nodeInfo[2].nodePort = ports[2];
snprintf(pCfg->nodeInfo[2].nodeFqdn, sizeof(pCfg->nodeInfo[2].nodeFqdn), "%s", "127.0.0.1");
// taosGetFqdn(pCfg->nodeInfo[2].nodeFqdn);
@@ -53,20 +55,25 @@ void timerPingAll(void* param, void* tmrId) {
syncNodePingAll(pSyncNode);
}
-int main() {
+int main(int argc, char** argv) {
// taosInitLog((char*)"syncPingTest.log", 100000, 10);
tsAsyncLog = 0;
sDebugFlag = 143 + 64;
logTest();
- int32_t ret = syncIOStart((char*)"127.0.0.1", 7010);
+ int myIndex = 0;
+ if (argc >= 2) {
+ myIndex = atoi(argv[1]);
+ }
+
+ int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]);
assert(ret == 0);
ret = syncEnvStart();
assert(ret == 0);
- SSyncNode* pSyncNode = doSync();
+ SSyncNode* pSyncNode = doSync(myIndex);
gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing;
gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply;
@@ -74,9 +81,9 @@ int main() {
assert(ret == 0);
/*
- taosMsleep(10000);
- ret = syncNodeStopPingTimer(pSyncNode);
- assert(ret == 0);
+ taosMsleep(10000);
+ ret = syncNodeStopPingTimer(pSyncNode);
+ assert(ret == 0);
*/
while (1) {
diff --git a/source/libs/sync/test/syncRaftStoreTest.cpp b/source/libs/sync/test/syncRaftStoreTest.cpp
index e533b89a92..9cfbe5a4ea 100644
--- a/source/libs/sync/test/syncRaftStoreTest.cpp
+++ b/source/libs/sync/test/syncRaftStoreTest.cpp
@@ -1,6 +1,6 @@
-#include "syncRaftStore.h"
#include
-#include "gtest/gtest.h"
+#include
+#include "syncRaftStore.h"
#include "syncIO.h"
#include "syncInt.h"
diff --git a/source/libs/sync/test/syncTest.cpp b/source/libs/sync/test/syncTest.cpp
index 0b397ef921..c1c5658aba 100644
--- a/source/libs/sync/test/syncTest.cpp
+++ b/source/libs/sync/test/syncTest.cpp
@@ -1,5 +1,5 @@
#include
-#include "gtest/gtest.h"
+#include
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
diff --git a/source/libs/tdb/src/db/tdb.c b/source/libs/tdb/src/db/tdb.c
index cc3b7fa6b9..65d4cf80cc 100644
--- a/source/libs/tdb/src/db/tdb.c
+++ b/source/libs/tdb/src/db/tdb.c
@@ -90,7 +90,7 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
// get page file from the env, if not opened yet, open it
pPgFile = NULL;
snprintf(dbfname, 128, "%s/%s", tdbEnvGetRootDir(pEnv), fname);
- fileExist = (tdbCheckFileAccess(fname, TDB_F_OK) == 0);
+ fileExist = taosCheckExistFile(fname);
if (fileExist) {
tdbGnrtFileID(dbfname, fileid, false);
pPgFile = tdbEnvGetPageFile(pEnv, fileid);
diff --git a/source/libs/tdb/src/db/tdbUtil.c b/source/libs/tdb/src/db/tdbUtil.c
index fa9a3297da..fe0f3befd6 100644
--- a/source/libs/tdb/src/db/tdbUtil.c
+++ b/source/libs/tdb/src/db/tdbUtil.c
@@ -16,16 +16,16 @@
#include "tdbInt.h"
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
- struct stat statbuf;
+ int64_t stDev = 0, stIno = 0;
- if (stat(fname, &statbuf) < 0) {
+ if (taosDevInoFile(fname, &stDev, &stIno) < 0) {
return -1;
}
memset(fileid, 0, TDB_FILE_ID_LEN);
- ((uint64_t *)fileid)[0] = (uint64_t)statbuf.st_ino;
- ((uint64_t *)fileid)[1] = (uint64_t)statbuf.st_dev;
+ ((uint64_t *)fileid)[0] = stDev;
+ ((uint64_t *)fileid)[1] = stIno;
if (unique) {
((uint64_t *)fileid)[2] = rand();
}
@@ -33,35 +33,34 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
return 0;
}
-int tdbCheckFileAccess(const char *pathname, int mode) {
- int flags = 0;
+// int tdbCheckFileAccess(const char *pathname, int mode) {
+// int flags = 0;
- if (mode & TDB_F_OK) {
- flags |= F_OK;
- }
+// if (mode & TDB_F_OK) {
+// flags |= F_OK;
+// }
- if (mode & TDB_R_OK) {
- flags |= R_OK;
- }
+// if (mode & TDB_R_OK) {
+// flags |= R_OK;
+// }
- if (mode & TDB_W_OK) {
- flags |= W_OK;
- }
+// if (mode & TDB_W_OK) {
+// flags |= W_OK;
+// }
- return access(pathname, flags);
-}
+// return access(pathname, flags);
+// }
int tdbGetFileSize(const char *fname, pgsz_t pgSize, pgno_t *pSize) {
- struct stat st;
int ret;
-
- ret = stat(fname, &st);
+ int64_t file_size = 0;
+ ret = taosStatFile(fname, &file_size, NULL);
if (ret != 0) {
return -1;
}
- ASSERT(st.st_size % pgSize == 0);
+ ASSERT(file_size % pgSize == 0);
- *pSize = st.st_size / pgSize;
+ *pSize = file_size / pgSize;
return 0;
}
\ No newline at end of file
diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h
index 8108e5aba6..ca05790f77 100644
--- a/source/libs/tdb/src/inc/tdbUtil.h
+++ b/source/libs/tdb/src/inc/tdbUtil.h
@@ -30,10 +30,10 @@ extern "C" {
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
-#define TDB_F_OK 0x1
-#define TDB_R_OK 0x2
-#define TDB_W_OK 0x4
-int tdbCheckFileAccess(const char *pathname, int mode);
+// #define TDB_F_OK 0x1
+// #define TDB_R_OK 0x2
+// #define TDB_W_OK 0x4
+// int tdbCheckFileAccess(const char *pathname, int mode);
int tdbGetFileSize(const char *fname, pgsz_t pgSize, pgno_t *pSize);
diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp
index 5ab0b4c0f1..ad550c7804 100644
--- a/source/libs/tdb/test/tdbTest.cpp
+++ b/source/libs/tdb/test/tdbTest.cpp
@@ -1,4 +1,4 @@
-#include "gtest/gtest.h"
+#include
#include "tdb.h"
diff --git a/source/libs/tfs/CMakeLists.txt b/source/libs/tfs/CMakeLists.txt
index 607ccd4c48..97e02fc8a9 100644
--- a/source/libs/tfs/CMakeLists.txt
+++ b/source/libs/tfs/CMakeLists.txt
@@ -6,7 +6,7 @@ target_include_directories(
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
-target_link_libraries(tfs os util common)
+target_link_libraries(tfs os util common monitor)
if(${BUILD_TEST})
add_subdirectory(test)
diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c
index f686703643..26fa90bdef 100644
--- a/source/libs/tfs/src/tfs.c
+++ b/source/libs/tfs/src/tfs.c
@@ -389,7 +389,6 @@ static int32_t tfsMount(STfs *pTfs, SDiskCfg *pCfg) {
static int32_t tfsCheckAndFormatCfg(STfs *pTfs, SDiskCfg *pCfg) {
char dirName[TSDB_FILENAME_LEN] = "\0";
- struct stat pstat;
if (pCfg->level < 0 || pCfg->level >= TFS_MAX_TIERS) {
fError("failed to mount %s to FS since invalid level %d", pCfg->dir, pCfg->level);
@@ -422,19 +421,13 @@ static int32_t tfsCheckAndFormatCfg(STfs *pTfs, SDiskCfg *pCfg) {
return -1;
}
- if (access(dirName, W_OK | R_OK | F_OK) != 0) {
+ if (!taosCheckAccessFile(dirName, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) {
fError("failed to mount %s to FS since no R/W access rights", pCfg->dir);
terrno = TSDB_CODE_FS_INVLD_CFG;
return -1;
}
- if (stat(dirName, &pstat) < 0) {
- fError("failed to mount %s to FS since %s", pCfg->dir, strerror(errno));
- terrno = TAOS_SYSTEM_ERROR(errno);
- return -1;
- }
-
- if (!S_ISDIR(pstat.st_mode)) {
+ if (!taosIsDir(dirName)) {
fError("failed to mount %s to FS since not a directory", pCfg->dir);
terrno = TSDB_CODE_FS_INVLD_CFG;
return -1;
@@ -544,3 +537,24 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) {
return pDisk;
}
+
+int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {
+ pInfo->datadirs = taosArrayInit(32, sizeof(SMonDiskDesc));
+ if (pInfo->datadirs == NULL) return -1;
+
+ tfsUpdateSize(pTfs);
+
+ tfsLock(pTfs);
+ for (int32_t level = 0; level < pTfs->nlevel; level++) {
+ STfsTier *pTier = &pTfs->tiers[level];
+ for (int32_t disk = 0; disk < pTier->ndisk; ++disk) {
+ STfsDisk *pDisk = pTier->disks[disk];
+ SMonDiskDesc dinfo = {0};
+ dinfo.size = pDisk->size;
+ dinfo.level = pDisk->level;
+ tstrncpy(dinfo.name, pDisk->path, sizeof(dinfo.name));
+ taosArrayPush(pInfo->datadirs, &dinfo);
+ }
+ }
+ tfsUnLock(pTfs);
+}
\ No newline at end of file
diff --git a/source/libs/tfs/test/tfsTest.cpp b/source/libs/tfs/test/tfsTest.cpp
index af66304f84..9cb914a670 100644
--- a/source/libs/tfs/test/tfsTest.cpp
+++ b/source/libs/tfs/test/tfsTest.cpp
@@ -119,29 +119,29 @@ TEST_F(TfsTest, 03_Dir) {
char p1[] = "p1";
char ap1[128] = {0};
snprintf(ap1, 128, "%s%s%s", root, TD_DIRSEP, p1);
- EXPECT_NE(taosDirExist(ap1), 0);
+ EXPECT_NE(taosDirExist(ap1), 1);
EXPECT_EQ(tfsMkdir(pTfs, p1), 0);
- EXPECT_EQ(taosDirExist(ap1), 0);
+ EXPECT_EQ(taosDirExist(ap1), 1);
char p2[] = "p2";
char ap2[128] = {0};
snprintf(ap2, 128, "%s%s%s", root, TD_DIRSEP, p2);
SDiskID did = {0};
- EXPECT_NE(taosDirExist(ap2), 0);
+ EXPECT_NE(taosDirExist(ap2), 1);
EXPECT_EQ(tfsMkdirAt(pTfs, p2, did), 0);
- EXPECT_EQ(taosDirExist(ap2), 0);
+ EXPECT_EQ(taosDirExist(ap2), 1);
char p3[] = "p3/p2/p1/p0";
char ap3[128] = {0};
snprintf(ap3, 128, "%s%s%s", root, TD_DIRSEP, p3);
- EXPECT_NE(taosDirExist(ap3), 0);
+ EXPECT_NE(taosDirExist(ap3), 1);
EXPECT_NE(tfsMkdir(pTfs, p3), 0);
EXPECT_NE(tfsMkdirAt(pTfs, p3, did), 0);
EXPECT_EQ(tfsMkdirRecurAt(pTfs, p3, did), 0);
- EXPECT_EQ(taosDirExist(ap3), 0);
+ EXPECT_EQ(taosDirExist(ap3), 1);
EXPECT_EQ(tfsRmdir(pTfs, p3), 0);
- EXPECT_NE(taosDirExist(ap3), 0);
+ EXPECT_NE(taosDirExist(ap3), 1);
char p45[] = "p5";
char p44[] = "p4";
@@ -149,12 +149,12 @@ TEST_F(TfsTest, 03_Dir) {
char ap4[128] = {0};
snprintf(ap4, 128, "%s%s%s", root, TD_DIRSEP, p4);
- EXPECT_NE(taosDirExist(ap4), 0);
+ EXPECT_NE(taosDirExist(ap4), 1);
EXPECT_EQ(tfsMkdirRecurAt(pTfs, p4, did), 0);
- EXPECT_EQ(taosDirExist(ap4), 0);
+ EXPECT_EQ(taosDirExist(ap4), 1);
EXPECT_EQ(tfsRename(pTfs, p44, p45), 0);
EXPECT_EQ(tfsRmdir(pTfs, p4), 0);
- EXPECT_NE(taosDirExist(ap4), 0);
+ EXPECT_NE(taosDirExist(ap4), 1);
tfsClose(pTfs);
}
@@ -251,9 +251,9 @@ TEST_F(TfsTest, 04_File) {
char af2[128] = {0};
snprintf(af2, 128, "%s%s%s", root, TD_DIRSEP, n2);
- EXPECT_EQ(taosDirExist(af2), 0);
+ EXPECT_EQ(taosDirExist(af2), 1);
tfsRemoveFile(&f2);
- EXPECT_NE(taosDirExist(af2), 0);
+ EXPECT_NE(taosDirExist(af2), 1);
{
STfsDir *pDir = tfsOpendir(pTfs, "t3");
@@ -529,35 +529,35 @@ TEST_F(TfsTest, 05_MultiDisk) {
snprintf(ap22, 128, "%s%s%s", root22, TD_DIRSEP, p1);
char ap23[128] = {0};
snprintf(ap23, 128, "%s%s%s", root23, TD_DIRSEP, p1);
- EXPECT_NE(taosDirExist(ap00), 0);
- EXPECT_NE(taosDirExist(ap01), 0);
- EXPECT_NE(taosDirExist(ap10), 0);
- EXPECT_NE(taosDirExist(ap11), 0);
- EXPECT_NE(taosDirExist(ap12), 0);
- EXPECT_NE(taosDirExist(ap20), 0);
- EXPECT_NE(taosDirExist(ap21), 0);
- EXPECT_NE(taosDirExist(ap22), 0);
- EXPECT_NE(taosDirExist(ap23), 0);
+ EXPECT_NE(taosDirExist(ap00), 1);
+ EXPECT_NE(taosDirExist(ap01), 1);
+ EXPECT_NE(taosDirExist(ap10), 1);
+ EXPECT_NE(taosDirExist(ap11), 1);
+ EXPECT_NE(taosDirExist(ap12), 1);
+ EXPECT_NE(taosDirExist(ap20), 1);
+ EXPECT_NE(taosDirExist(ap21), 1);
+ EXPECT_NE(taosDirExist(ap22), 1);
+ EXPECT_NE(taosDirExist(ap23), 1);
EXPECT_EQ(tfsMkdir(pTfs, p1), 0);
- EXPECT_EQ(taosDirExist(ap00), 0);
- EXPECT_EQ(taosDirExist(ap01), 0);
- EXPECT_EQ(taosDirExist(ap10), 0);
- EXPECT_EQ(taosDirExist(ap11), 0);
- EXPECT_EQ(taosDirExist(ap12), 0);
- EXPECT_EQ(taosDirExist(ap20), 0);
- EXPECT_EQ(taosDirExist(ap21), 0);
- EXPECT_EQ(taosDirExist(ap22), 0);
- EXPECT_EQ(taosDirExist(ap23), 0);
+ EXPECT_EQ(taosDirExist(ap00), 1);
+ EXPECT_EQ(taosDirExist(ap01), 1);
+ EXPECT_EQ(taosDirExist(ap10), 1);
+ EXPECT_EQ(taosDirExist(ap11), 1);
+ EXPECT_EQ(taosDirExist(ap12), 1);
+ EXPECT_EQ(taosDirExist(ap20), 1);
+ EXPECT_EQ(taosDirExist(ap21), 1);
+ EXPECT_EQ(taosDirExist(ap22), 1);
+ EXPECT_EQ(taosDirExist(ap23), 1);
EXPECT_EQ(tfsRmdir(pTfs, p1), 0);
- EXPECT_NE(taosDirExist(ap00), 0);
- EXPECT_NE(taosDirExist(ap01), 0);
- EXPECT_NE(taosDirExist(ap10), 0);
- EXPECT_NE(taosDirExist(ap11), 0);
- EXPECT_NE(taosDirExist(ap12), 0);
- EXPECT_NE(taosDirExist(ap20), 0);
- EXPECT_NE(taosDirExist(ap21), 0);
- EXPECT_NE(taosDirExist(ap22), 0);
- EXPECT_NE(taosDirExist(ap23), 0);
+ EXPECT_NE(taosDirExist(ap00), 1);
+ EXPECT_NE(taosDirExist(ap01), 1);
+ EXPECT_NE(taosDirExist(ap10), 1);
+ EXPECT_NE(taosDirExist(ap11), 1);
+ EXPECT_NE(taosDirExist(ap12), 1);
+ EXPECT_NE(taosDirExist(ap20), 1);
+ EXPECT_NE(taosDirExist(ap21), 1);
+ EXPECT_NE(taosDirExist(ap22), 1);
+ EXPECT_NE(taosDirExist(ap23), 1);
char p2[] = "p2";
char _ap21[128] = {0};
@@ -565,22 +565,22 @@ TEST_F(TfsTest, 05_MultiDisk) {
SDiskID did = {0};
did.level = 2;
did.id = 1;
- EXPECT_NE(taosDirExist(_ap21), 0);
+ EXPECT_NE(taosDirExist(_ap21), 1);
EXPECT_EQ(tfsMkdirAt(pTfs, p2, did), 0);
- EXPECT_EQ(taosDirExist(_ap21), 0);
+ EXPECT_EQ(taosDirExist(_ap21), 1);
char p3[] = "p3/p2/p1/p0";
char _ap12[128] = {0};
snprintf(_ap12, 128, "%s%s%s", root12, TD_DIRSEP, p3);
did.level = 1;
did.id = 2;
- EXPECT_NE(taosDirExist(_ap12), 0);
+ EXPECT_NE(taosDirExist(_ap12), 1);
EXPECT_NE(tfsMkdir(pTfs, p3), 0);
EXPECT_NE(tfsMkdirAt(pTfs, p3, did), 0);
EXPECT_EQ(tfsMkdirRecurAt(pTfs, p3, did), 0);
- EXPECT_EQ(taosDirExist(_ap12), 0);
+ EXPECT_EQ(taosDirExist(_ap12), 1);
EXPECT_EQ(tfsRmdir(pTfs, p3), 0);
- EXPECT_NE(taosDirExist(_ap12), 0);
+ EXPECT_NE(taosDirExist(_ap12), 1);
char p45[] = "p5";
char p44[] = "p4";
@@ -590,12 +590,12 @@ TEST_F(TfsTest, 05_MultiDisk) {
did.level = 2;
did.id = 2;
- EXPECT_NE(taosDirExist(_ap22), 0);
+ EXPECT_NE(taosDirExist(_ap22), 1);
EXPECT_EQ(tfsMkdirRecurAt(pTfs, p4, did), 0);
- EXPECT_EQ(taosDirExist(_ap22), 0);
+ EXPECT_EQ(taosDirExist(_ap22), 1);
EXPECT_EQ(tfsRename(pTfs, p44, p45), 0);
EXPECT_EQ(tfsRmdir(pTfs, p4), 0);
- EXPECT_NE(taosDirExist(_ap22), 0);
+ EXPECT_NE(taosDirExist(_ap22), 1);
}
//------------- File -----------------//
@@ -660,7 +660,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
char af2[128] = {0};
snprintf(af2, 128, "%s%s%s", root23, TD_DIRSEP, n2);
- EXPECT_EQ(taosDirExist(af2), 0);
+ EXPECT_EQ(taosDirExist(af2), 1);
tfsRemoveFile(&f2);
{
@@ -678,7 +678,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
tfsClosedir(pDir);
}
- EXPECT_NE(taosDirExist(af2), 0);
+ EXPECT_NE(taosDirExist(af2), 1);
EXPECT_GT(tfsCopyFile(&f1, &f2), 0);
{
diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c
index f0db054797..c7b6ca2a2c 100644
--- a/source/libs/transport/src/transSrv.c
+++ b/source/libs/transport/src/transSrv.c
@@ -286,15 +286,17 @@ void uvOnWriteCb(uv_write_t* req, int status) {
transClearBuffer(&conn->readBuf);
if (status == 0) {
tTrace("server conn %p data already was written on stream", conn);
- assert(taosArrayGetSize(conn->srvMsgs) >= 1);
- SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, 0);
- taosArrayRemove(conn->srvMsgs, 0);
- destroySmsg(msg);
+ if (conn->srvMsgs != NULL) {
+ assert(taosArrayGetSize(conn->srvMsgs) >= 1);
+ SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, 0);
+ taosArrayRemove(conn->srvMsgs, 0);
+ destroySmsg(msg);
- // send second data, just use for push
- if (taosArrayGetSize(conn->srvMsgs) > 0) {
- msg = (SSrvMsg*)taosArrayGetP(conn->srvMsgs, 0);
- uvStartSendRespInternal(msg);
+ // send second data, just use for push
+ if (taosArrayGetSize(conn->srvMsgs) > 0) {
+ msg = (SSrvMsg*)taosArrayGetP(conn->srvMsgs, 0);
+ uvStartSendRespInternal(msg);
+ }
}
} else {
tError("server conn %p failed to write data, %s", conn, uv_err_name(status));
@@ -615,7 +617,7 @@ static void destroyConn(SSrvConn* conn, bool clear) {
SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, i);
destroySmsg(msg);
}
- taosArrayDestroy(conn->srvMsgs);
+ conn->srvMsgs = taosArrayDestroy(conn->srvMsgs);
QUEUE_REMOVE(&conn->queue);
if (clear) {
diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c
index ae0b0bd849..e64260c541 100644
--- a/source/libs/wal/src/walMeta.c
+++ b/source/libs/wal/src/walMeta.c
@@ -64,10 +64,10 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
char fnameStr[WAL_FILE_LEN];
walBuildLogName(pWal, pLastFileInfo->firstVer, fnameStr);
- struct stat statbuf;
- stat(fnameStr, &statbuf);
- int readSize = TMIN(WAL_MAX_SIZE + 2, statbuf.st_size);
- pLastFileInfo->fileSize = statbuf.st_size;
+ int64_t file_size = 0;
+ taosStatFile(fnameStr, &file_size, NULL);
+ int readSize = TMIN(WAL_MAX_SIZE + 2, file_size);
+ pLastFileInfo->fileSize = file_size;
TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ);
if (pFile == NULL) {
@@ -177,11 +177,11 @@ int walCheckAndRepairMeta(SWal* pWal) {
SWalFileInfo *pLastFileInfo = taosArrayGet(pWal->fileInfoSet, newSz-1);
char fnameStr[WAL_FILE_LEN];
walBuildLogName(pWal, pLastFileInfo->firstVer, fnameStr);
- struct stat statbuf;
- stat(fnameStr, &statbuf);
+ int64_t file_size = 0;
+ taosStatFile(fnameStr, &file_size, NULL);
- if (oldSz != newSz || pLastFileInfo->fileSize != statbuf.st_size) {
- pLastFileInfo->fileSize = statbuf.st_size;
+ if (oldSz != newSz || pLastFileInfo->fileSize != file_size) {
+ pLastFileInfo->fileSize = file_size;
pWal->vers.lastVer = walScanLogGetLastVer(pWal);
((SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet))->lastVer = pWal->vers.lastVer;
ASSERT(pWal->vers.lastVer != -1);
@@ -395,9 +395,9 @@ int walLoadMeta(SWal* pWal) {
char fnameStr[WAL_FILE_LEN];
walBuildMetaName(pWal, metaVer, fnameStr);
// read metafile
- struct stat statbuf;
- stat(fnameStr, &statbuf);
- int size = statbuf.st_size;
+ int64_t file_size = 0;
+ taosStatFile(fnameStr, &file_size, NULL);
+ int size = (int)file_size;
char* buf = malloc(size + 5);
if (buf == NULL) {
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c
index 91ef97e66b..e0f5f80dab 100644
--- a/source/os/src/osDir.c
+++ b/source/os/src/osDir.c
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
//printf("dir:%s is removed\n", dirname);
}
-int32_t taosDirExist(char *dirname) { return access(dirname, F_OK); }
+bool taosDirExist(char *dirname) { return taosCheckExistFile(dirname); }
int32_t taosMkDir(const char *dirname) {
int32_t code = mkdir(dirname, 0755);
diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c
index 4c368fe895..0b2fe904b3 100644
--- a/source/os/src/osEnv.c
+++ b/source/os/src/osEnv.c
@@ -31,11 +31,11 @@ char tsLocale[TD_LOCALE_LEN] = {0};
char tsCharset[TD_CHARSET_LEN] = {0};
int8_t tsDaylight = 0;
bool tsEnableCoreFile = 0;
-int64_t tsPageSize = 0;
+int64_t tsPageSizeKB = 0;
int64_t tsOpenMax = 0;
int64_t tsStreamMax = 0;
-int32_t tsNumOfCores = 0;
-int32_t tsTotalMemoryMB = 0;
+float tsNumOfCores = 0;
+int64_t tsTotalMemoryKB = 0;
void osInit() {
srand(taosSafeRand());
@@ -44,6 +44,11 @@ void osInit() {
taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight);
taosGetSystemInfo();
+ // deadlock in query
+ if (tsNumOfCores < 2) {
+ tsNumOfCores = 2;
+ }
+
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
taosWinSocketInit();
diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c
index c2e9b52f88..37004e9d70 100644
--- a/source/os/src/osFile.c
+++ b/source/os/src/osFile.c
@@ -186,6 +186,27 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
return 0;
#endif
}
+int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
+#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
+ return 0;
+#else
+ struct stat fileStat;
+ int32_t code = stat(path, &fileStat);
+ if (code < 0) {
+ return code;
+ }
+
+ if (stDev != NULL) {
+ *stDev = fileStat.st_dev;
+ }
+
+ if (stIno != NULL) {
+ *stIno = fileStat.st_ino;
+ }
+
+ return 0;
+#endif
+}
void autoDelFileListAdd(const char *path) { return; }
@@ -733,3 +754,21 @@ int32_t taosEOFFile(TdFilePtr pFile) {
return feof(pFile->fp);
}
+bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) {
+ int flags = 0;
+
+ if (tdFileAccessOptions & TD_FILE_ACCESS_EXIST_OK) {
+ flags |= F_OK;
+ }
+
+ if (tdFileAccessOptions & TD_FILE_ACCESS_READ_OK) {
+ flags |= R_OK;
+ }
+
+ if (tdFileAccessOptions & TD_FILE_ACCESS_WRITE_OK) {
+ flags |= W_OK;
+ }
+
+ return access(pathname, flags) == 0;
+}
+bool taosCheckExistFile(const char *pathname) { return taosCheckAccessFile(pathname, TD_FILE_ACCESS_EXIST_OK); };
\ No newline at end of file
diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c
index 3e761c6d91..c674aeaca2 100644
--- a/source/os/src/osSysinfo.c
+++ b/source/os/src/osSysinfo.c
@@ -39,32 +39,32 @@
#include
#pragma warning(pop)
-static int32_t taosGetTotalMemory() {
+int32_t taosGetTotalMemory(int64_t *totalKB) {
MEMORYSTATUSEX memsStat;
memsStat.dwLength = sizeof(memsStat);
if (!GlobalMemoryStatusEx(&memsStat)) {
- return 0;
+ return -1;
}
- float nMemTotal = memsStat.ullTotalPhys / (1024.0f * 1024.0f);
- return (int32_t)nMemTotal;
+ *totalKB = memsStat.ullTotalPhys / 1024;
+ return 0;
}
-bool taosGetSysMemory(float *memoryUsedMB) {
+int32_t taosGetSysMemory(int64_t *usedKB) {
MEMORYSTATUSEX memsStat;
memsStat.dwLength = sizeof(memsStat);
if (!GlobalMemoryStatusEx(&memsStat)) {
- return false;
+ return -1;
}
- float nMemFree = memsStat.ullAvailPhys / (1024.0f * 1024.0f);
- float nMemTotal = memsStat.ullTotalPhys / (1024.0f * 1024.0f);
+ int64_t nMemFree = memsStat.ullAvailPhys / 1024;
+ int64_t nMemTotal = memsStat.ullTotalPhys / 1024.0;
- *memoryUsedMB = nMemTotal - nMemFree;
- return true;
+ *usedKB = nMemTotal - nMemFree;
+ return 0;
}
-bool taosGetProcMemory(float *memoryUsedMB) {
+int32_t taosGetProcMemory(int64_t *usedKB) {
unsigned bytes_used = 0;
#if defined(_WIN64) && defined(_MSC_VER)
@@ -76,21 +76,21 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
#endif
- *memoryUsedMB = (float)bytes_used / 1024 / 1024;
- return true;
+ *usedKB = bytes_used / 1024;
+ return 0;
}
-
-int32_t taosGetCpuCores() {
+int32_t taosGetCpuCores(float *numOfCores) {
SYSTEM_INFO info;
GetSystemInfo(&info);
- return (int32_t)info.dwNumberOfProcessors;
+ *numOfCores = info.dwNumberOfProcessors;
+ return 0;
}
-bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
+int32_t taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
*sysCpuUsage = 0;
*procCpuUsage = 0;
- return true;
+ return 0;
}
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
@@ -106,49 +106,49 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
return 0;
} else {
- //printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
+ // printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
}
-bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
+int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
if (bytes) *bytes = 0;
if (rbytes) *rbytes = 0;
if (tbytes) *tbytes = 0;
- return true;
+ return 0;
}
-bool taosGetBandSpeed(float *bandSpeedKb) {
+int32_t taosGetBandSpeed(float *bandSpeedKb) {
*bandSpeedKb = 0;
- return true;
+ return 0;
}
-bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
+int32_t taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
IO_COUNTERS io_counter;
if (GetProcessIoCounters(GetCurrentProcess(), &io_counter)) {
if (readbyte) *readbyte = io_counter.ReadTransferCount;
if (writebyte) *writebyte = io_counter.WriteTransferCount;
- return true;
+ return 0;
}
- return false;
+ return -1;
}
-bool taosGetProcIO(float *readKB, float *writeKB) {
+int32_t taosGetProcIO(float *readKB, float *writeKB) {
static int64_t lastReadbyte = -1;
static int64_t lastWritebyte = -1;
int64_t curReadbyte = 0;
int64_t curWritebyte = 0;
- if (!taosReadProcIO(&curReadbyte, &curWritebyte)) {
- return false;
+ if (taosReadProcIO(&curReadbyte, &curWritebyte) != 0) {
+ return -1;
}
if (lastReadbyte == -1 || lastWritebyte == -1) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
- return false;
+ return -1;
}
*readKB = (float)((double)(curReadbyte - lastReadbyte) / 1024);
@@ -159,12 +159,12 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
- return true;
+ return 0;
}
void taosGetSystemInfo() {
- tsNumOfCores = taosGetCpuCores();
- tsTotalMemoryMB = taosGetTotalMemory();
+ taosGetCpuCores(&tsNumOfCores);
+ taosGetTotalMemory(&tsTotalMemoryKB);
float tmp1, tmp2;
taosGetBandSpeed(&tmp1);
@@ -173,12 +173,12 @@ void taosGetSystemInfo() {
}
void taosKillSystem() {
- //printf("function taosKillSystem, exit!");
+ // printf("function taosKillSystem, exit!");
exit(0);
}
int taosSystem(const char *cmd) {
- //printf("taosSystem not support");
+ // printf("taosSystem not support");
return -1;
}
@@ -241,66 +241,66 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
#include
#include
-
void taosKillSystem() {
- //printf("function taosKillSystem, exit!");
+ // printf("function taosKillSystem, exit!");
exit(0);
}
-int32_t taosGetCpuCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
+int32_t taosGetCpuCores(float *numOfCores) {
+ *numOfCores = sysconf(_SC_NPROCESSORS_ONLN);
+ return 0;
+}
void taosGetSystemInfo() {
- // taosGetProcInfos();
-
- tsNumOfCores = sysconf(_SC_NPROCESSORS_ONLN);
long physical_pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGESIZE);
- tsTotalMemoryMB = physical_pages * page_size / (1024 * 1024);
- tsPageSize = page_size;
+ tsTotalMemoryKB = physical_pages * page_size / 1024;
+ tsPageSizeKB = page_size / 1024;
+ tsNumOfCores = sysconf(_SC_NPROCESSORS_ONLN);
}
-bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
+int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if (rchars) *rchars = 0;
if (wchars) *wchars = 0;
- return true;
+ return 0;
}
-bool taosGetProcIO(float *readKB, float *writeKB) {
+int32_t taosGetProcIO(float *readKB, float *writeKB) {
*readKB = 0;
*writeKB = 0;
- return true;
+ return 0;
}
-bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
+int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
if (bytes) *bytes = 0;
if (rbytes) *rbytes = 0;
if (tbytes) *tbytes = 0;
- return true;
+ return 0;
}
-bool taosGetBandSpeed(float *bandSpeedKb) {
+int32_t taosGetBandSpeed(float *bandSpeedKb) {
*bandSpeedKb = 0;
- return true;
+ return 0;
}
-bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
+int32_t taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
*sysCpuUsage = 0;
*procCpuUsage = 0;
- return true;
+ return 0;
}
-bool taosGetProcMemory(float *memoryUsedMB) {
- *memoryUsedMB = 0;
- return true;
+int32_t taosGetProcMemory(int64_t *usedKB) {
+ *usedKB = 0;
+ return 0;
}
-bool taosGetSysMemory(float *memoryUsedMB) {
- *memoryUsedMB = 0;
- return true;
+int32_t taosGetSysMemory(int64_t *usedKB) {
+ *usedKB = 0;
+ return 0;
}
int taosSystem(const char *cmd) {
- //printf("un support funtion");
+ // printf("un support funtion");
return -1;
}
@@ -309,7 +309,7 @@ void taosSetCoreDump() {}
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
struct statvfs info;
if (statvfs(dataDir, &info)) {
- //printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
+ // printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
} else {
@@ -377,39 +377,38 @@ static char tsSysCpuFile[] = "/proc/stat";
static char tsProcCpuFile[25] = {0};
static char tsProcMemFile[25] = {0};
static char tsProcIOFile[25] = {0};
-static float tsPageSizeKB = 0;
static void taosGetProcInfos() {
- tsPageSize = sysconf(_SC_PAGESIZE);
+ tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024;
tsOpenMax = sysconf(_SC_OPEN_MAX);
tsStreamMax = sysconf(_SC_STREAM_MAX);
-
tsProcId = (pid_t)syscall(SYS_gettid);
- tsPageSizeKB = (float)(sysconf(_SC_PAGESIZE)) / 1024;
- snprintf(tsProcMemFile, 25, "/proc/%d/status", tsProcId);
- snprintf(tsProcCpuFile, 25, "/proc/%d/stat", tsProcId);
- snprintf(tsProcIOFile, 25, "/proc/%d/io", tsProcId);
+ snprintf(tsProcMemFile, sizeof(tsProcMemFile), "/proc/%d/status", tsProcId);
+ snprintf(tsProcCpuFile, sizeof(tsProcCpuFile), "/proc/%d/stat", tsProcId);
+ snprintf(tsProcIOFile, sizeof(tsProcIOFile), "/proc/%d/io", tsProcId);
}
-static int32_t taosGetTotalMemory() { return (int32_t)((float)sysconf(_SC_PHYS_PAGES) * tsPageSizeKB / 1024); }
-
-bool taosGetSysMemory(float *memoryUsedMB) {
- float memoryAvailMB = (float)sysconf(_SC_AVPHYS_PAGES) * tsPageSizeKB / 1024;
- *memoryUsedMB = (float)tsTotalMemoryMB - memoryAvailMB;
- return true;
+int32_t taosGetTotalMemory(int64_t *totalKB) {
+ *totalKB = (int64_t)(sysconf(_SC_PHYS_PAGES) * tsPageSizeKB);
+ return 0;
}
-bool taosGetProcMemory(float *memoryUsedMB) {
+int32_t taosGetSysMemory(int64_t *usedKB) {
+ *usedKB = sysconf(_SC_AVPHYS_PAGES) * tsPageSizeKB;
+ return 0;
+}
+
+int32_t taosGetProcMemory(int64_t *usedKB) {
// FILE *fp = fopen(tsProcMemFile, "r");
TdFilePtr pFile = taosOpenFile(tsProcMemFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
- //printf("open file:%s failed", tsProcMemFile);
- return false;
+ // printf("open file:%s failed", tsProcMemFile);
+ return -1;
}
ssize_t _bytes = 0;
- char * line = NULL;
+ char *line = NULL;
while (!taosEOFFile(pFile)) {
_bytes = taosGetLineFile(pFile, &line);
if ((_bytes < 0) || (line == NULL)) {
@@ -421,60 +420,58 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
if (line == NULL) {
- //printf("read file:%s failed", tsProcMemFile);
+ // printf("read file:%s failed", tsProcMemFile);
taosCloseFile(&pFile);
- return false;
+ return -1;
}
- int64_t memKB = 0;
- char tmp[10];
- sscanf(line, "%s %" PRId64, tmp, &memKB);
- *memoryUsedMB = (float)((double)memKB / 1024);
+ char tmp[10];
+ sscanf(line, "%s %" PRId64, tmp, usedKB);
- if(line != NULL) tfree(line);
+ if (line != NULL) tfree(line);
taosCloseFile(&pFile);
- return true;
+ return 0;
}
-static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
+static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
// FILE *fp = fopen(tsSysCpuFile, "r");
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
- //printf("open file:%s failed", tsSysCpuFile);
- return false;
+ // printf("open file:%s failed", tsSysCpuFile);
+ return -1;
}
- char * line = NULL;
+ char *line = NULL;
ssize_t _bytes = taosGetLineFile(pFile, &line);
if ((_bytes < 0) || (line == NULL)) {
- //printf("read file:%s failed", tsSysCpuFile);
+ // printf("read file:%s failed", tsSysCpuFile);
taosCloseFile(&pFile);
- return false;
+ return -1;
}
char cpu[10] = {0};
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system,
&cpuInfo->idle);
- if(line != NULL) tfree(line);
+ if (line != NULL) tfree(line);
taosCloseFile(&pFile);
- return true;
+ return 0;
}
-static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
+static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
// FILE *fp = fopen(tsProcCpuFile, "r");
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
- //printf("open file:%s failed", tsProcCpuFile);
- return false;
+ // printf("open file:%s failed", tsProcCpuFile);
+ return -1;
}
- char * line = NULL;
+ char *line = NULL;
ssize_t _bytes = taosGetLineFile(pFile, &line);
if ((_bytes < 0) || (line == NULL)) {
- //printf("read file:%s failed", tsProcCpuFile);
+ // printf("read file:%s failed", tsProcCpuFile);
taosCloseFile(&pFile);
- return false;
+ return -1;
}
for (int i = 0, blank = 0; line[i] != 0; ++i) {
@@ -486,26 +483,28 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
}
}
- if(line != NULL) tfree(line);
+ if (line != NULL) tfree(line);
taosCloseFile(&pFile);
- return true;
+ return 0;
}
+int32_t taosGetCpuCores(float *numOfCores) {
+ *numOfCores = sysconf(_SC_NPROCESSORS_ONLN);
+ return 0;
+}
-int32_t taosGetCpuCores() { return (int32_t)sysconf(_SC_NPROCESSORS_ONLN); }
-
-bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
+int32_t taosGetCpuUsage(float *cpu_system, float *cpu_engine) {
static uint64_t lastSysUsed = 0;
static uint64_t lastSysTotal = 0;
static uint64_t lastProcTotal = 0;
SysCpuInfo sysCpu;
ProcCpuInfo procCpu;
- if (!taosGetSysCpuInfo(&sysCpu)) {
- return false;
+ if (taosGetSysCpuInfo(&sysCpu) != 0) {
+ return -1;
}
- if (!taosGetProcCpuInfo(&procCpu)) {
- return false;
+ if (taosGetProcCpuInfo(&procCpu) != 0) {
+ return -1;
}
uint64_t curSysUsed = sysCpu.user + sysCpu.nice + sysCpu.system;
@@ -516,21 +515,21 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
lastSysUsed = curSysUsed > 1 ? curSysUsed : 1;
lastSysTotal = curSysTotal > 1 ? curSysTotal : 1;
lastProcTotal = curProcTotal > 1 ? curProcTotal : 1;
- return false;
+ return -1;
}
if (curSysTotal == lastSysTotal) {
- return false;
+ return -1;
}
- *sysCpuUsage = (float)((double)(curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100);
- *procCpuUsage = (float)((double)(curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100);
+ *cpu_engine = (float)((double)(curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100);
+ *cpu_system = (float)((double)(curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100);
lastSysUsed = curSysUsed;
lastSysTotal = curSysTotal;
lastProcTotal = curProcTotal;
- return true;
+ return 0;
}
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
@@ -545,17 +544,17 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
}
}
-bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
- *bytes = 0;
+int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
+ if (bytes) *bytes = 0;
// FILE *fp = fopen(tsSysNetFile, "r");
TdFilePtr pFile = taosOpenFile(tsSysNetFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
- //printf("open file:%s failed", tsSysNetFile);
- return false;
+ // printf("open file:%s failed", tsSysNetFile);
+ return -1;
}
ssize_t _bytes = 0;
- char * line = NULL;
+ char *line = NULL;
while (!taosEOFFile(pFile)) {
int64_t o_rbytes = 0;
@@ -587,37 +586,37 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
nouse0, &o_rbytes, &rpackts, &nouse1, &nouse2, &nouse3, &nouse4, &nouse5, &nouse6, &o_tbytes, &tpackets);
if (rbytes) *rbytes = o_rbytes;
if (tbytes) *tbytes = o_tbytes;
- *bytes += (o_rbytes + o_tbytes);
+ if (bytes) *bytes += (o_rbytes + o_tbytes);
}
- if(line != NULL) tfree(line);
+ if (line != NULL) tfree(line);
taosCloseFile(&pFile);
- return true;
+ return 0;
}
-bool taosGetBandSpeed(float *bandSpeedKb) {
+int32_t taosGetBandSpeed(float *bandSpeedKb) {
static int64_t lastBytes = 0;
static time_t lastTime = 0;
int64_t curBytes = 0;
time_t curTime = time(NULL);
- if (!taosGetCardInfo(&curBytes, NULL, NULL)) {
- return false;
+ if (taosGetCardInfo(&curBytes, NULL, NULL) != 0) {
+ return -1;
}
if (lastTime == 0 || lastBytes == 0) {
lastTime = curTime;
lastBytes = curBytes;
*bandSpeedKb = 0;
- return true;
+ return 0;
}
if (lastTime >= curTime || lastBytes > curBytes) {
lastTime = curTime;
lastBytes = curBytes;
*bandSpeedKb = 0;
- return true;
+ return 0;
}
double totalBytes = (double)(curBytes - lastBytes) / 1024 * 8; // Kb
@@ -629,19 +628,19 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
lastTime = curTime;
lastBytes = curBytes;
- return true;
+ return 0;
}
-bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
+int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
// FILE *fp = fopen(tsProcIOFile, "r");
TdFilePtr pFile = taosOpenFile(tsProcIOFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
- //printf("open file:%s failed", tsProcIOFile);
- return false;
+ // printf("open file:%s failed", tsProcIOFile);
+ return -1;
}
ssize_t _bytes = 0;
- char * line = NULL;
+ char *line = NULL;
char tmp[10];
int readIndex = 0;
@@ -662,32 +661,32 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if (readIndex >= 2) break;
}
- if(line != NULL) tfree(line);
+ if (line != NULL) tfree(line);
taosCloseFile(&pFile);
if (readIndex < 2) {
- //printf("read file:%s failed", tsProcIOFile);
- return false;
+ // printf("read file:%s failed", tsProcIOFile);
+ return -1;
}
- return true;
+ return 0;
}
-bool taosGetProcIO(float *readKB, float *writeKB) {
+int32_t taosGetProcIO(float *readKB, float *writeKB) {
static int64_t lastReadbyte = -1;
static int64_t lastWritebyte = -1;
int64_t curReadbyte = 0;
int64_t curWritebyte = 0;
- if (!taosReadProcIO(&curReadbyte, &curWritebyte)) {
- return false;
+ if (taosReadProcIO(&curReadbyte, &curWritebyte) != 0) {
+ return -1;
}
if (lastReadbyte == -1 || lastWritebyte == -1) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
- return false;
+ return -1;
}
*readKB = (float)((double)(curReadbyte - lastReadbyte) / 1024);
@@ -698,27 +697,23 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
- return true;
+ return 0;
}
void taosGetSystemInfo() {
taosGetProcInfos();
-
- tsNumOfCores = taosGetCpuCores();
- tsTotalMemoryMB = taosGetTotalMemory();
+ taosGetCpuCores(&tsNumOfCores);
+ taosGetTotalMemory(&tsTotalMemoryKB);
float tmp1, tmp2;
- taosGetSysMemory(&tmp1);
- taosGetProcMemory(&tmp2);
taosGetBandSpeed(&tmp1);
taosGetCpuUsage(&tmp1, &tmp2);
taosGetProcIO(&tmp1, &tmp2);
-
}
void taosKillSystem() {
// SIGINT
- //printf("taosd will shut down soon");
+ // printf("taosd will shut down soon");
kill(tsProcId, 2);
}
@@ -727,22 +722,22 @@ int taosSystem(const char *cmd) {
int res;
char buf[1024];
if (cmd == NULL) {
- //printf("taosSystem cmd is NULL!");
+ // printf("taosSystem cmd is NULL!");
return -1;
}
if ((fp = popen(cmd, "r")) == NULL) {
- //printf("popen cmd:%s error: %s", cmd, strerror(errno));
+ // printf("popen cmd:%s error: %s", cmd, strerror(errno));
return -1;
} else {
while (fgets(buf, sizeof(buf), fp)) {
- //printf("popen result:%s", buf);
+ // printf("popen result:%s", buf);
}
if ((res = pclose(fp)) == -1) {
- //printf("close popen file pointer fp error!");
+ // printf("close popen file pointer fp error!");
} else {
- //printf("popen res is :%d", res);
+ // printf("popen res is :%d", res);
}
return res;
@@ -757,14 +752,14 @@ void taosSetCoreDump(bool enable) {
struct rlimit rlim_new;
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
#ifndef _ALPINE
- //printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
+ // printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
- //printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
+ // printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
rlim_new.rlim_cur = RLIM_INFINITY;
rlim_new.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
- //printf("set unlimited fail, error: %s", strerror(errno));
+ // printf("set unlimited fail, error: %s", strerror(errno));
rlim_new.rlim_cur = rlim.rlim_max;
rlim_new.rlim_max = rlim.rlim_max;
(void)setrlimit(RLIMIT_CORE, &rlim_new);
@@ -773,9 +768,9 @@ void taosSetCoreDump(bool enable) {
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
#ifndef _ALPINE
- //printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
+ // printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
- //printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
+ // printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
}
@@ -801,10 +796,10 @@ void taosSetCoreDump(bool enable) {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
- //printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
+ // printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
- //printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
+ // printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
old_usespid = 0;
old_len = 0;
@@ -817,10 +812,10 @@ void taosSetCoreDump(bool enable) {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
- //printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
+ // printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
- //printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
+ // printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
}
@@ -885,7 +880,7 @@ SysNameInfo taosGetSysNameInfo() {
return info;
}
-bool taosGetEmail(char *email, int32_t maxLen) {
+int32_t taosGetEmail(char *email, int32_t maxLen) {
const char *filepath = "/usr/local/taos/email";
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ);
@@ -893,17 +888,17 @@ bool taosGetEmail(char *email, int32_t maxLen) {
if (taosReadFile(pFile, (void *)email, maxLen) < 0) {
taosCloseFile(&pFile);
- return false;
+ return -1;
}
taosCloseFile(&pFile);
- return true;
+ return 0;
}
-bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
- char *line = NULL;
- size_t size = 0;
- bool ret = false;
+int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
+ char *line = NULL;
+ size_t size = 0;
+ int32_t code = -1;
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return false;
@@ -917,21 +912,21 @@ bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
line[size - 2] = 0;
}
tstrncpy(releaseName, p, maxLen);
- ret = true;
+ code = 0;
break;
}
}
if (line != NULL) free(line);
taosCloseFile(&pFile);
- return ret;
+ return code;
}
-bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
+int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
char *line = NULL;
size_t size = 0;
int32_t done = 0;
- bool ret = false;
+ int32_t code = -1;
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return false;
@@ -941,11 +936,11 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) {
const char *v = strchr(line, ':') + 2;
tstrncpy(cpuModel, v, maxLen);
- ret = true;
+ code = 0;
done |= 1;
} else if (((done & 2) == 0) && strncmp(line, "cpu cores", 9) == 0) {
const char *v = strchr(line, ':') + 2;
- *numOfCores = atoi(v);
+ *numOfCores = atof(v);
done |= 2;
}
}
@@ -953,31 +948,7 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if (line != NULL) free(line);
taosCloseFile(&pFile);
- return ret;
-}
-
-bool taosGetTotalSysMemoryKB(uint64_t *kb) {
- char *line = NULL;
- size_t size = 0;
- bool ret = false;
-
- TdFilePtr pFile = taosOpenFile("/proc/meminfo", TD_FILE_READ | TD_FILE_STREAM);
- if (pFile == NULL) return false;
-
- while ((size = taosGetLineFile(pFile, &line)) != -1) {
- line[size - 1] = '\0';
- if (strncmp(line, "MemTotal", 8) == 0) {
- const char *p = strchr(line, ':') + 1;
- while (*p == ' ') p++;
- ret = true;
- *kb = atoll(p);
- break;
- }
- }
-
- if (line != NULL) free(line);
- taosCloseFile(&pFile);
- return ret;
+ return code;
}
#endif
diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c
index a8649f1ea7..634cfcb026 100644
--- a/source/util/src/tjson.c
+++ b/source/util/src/tjson.c
@@ -98,7 +98,6 @@ int32_t tjsonAddObject(SJson* pJson, const char* pName, FToJson func, const void
SJson* pJobj = tjsonCreateObject();
if (NULL == pJobj || TSDB_CODE_SUCCESS != func(pObj, pJobj)) {
- printf("%s:%d code = %d\n", __FUNCTION__, __LINE__, TSDB_CODE_FAILED);
tjsonDelete(pJobj);
return TSDB_CODE_FAILED;
}
@@ -159,9 +158,9 @@ int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal
if (NULL == p) {
return TSDB_CODE_FAILED;
}
- char* pEnd = NULL;
- *pVal = strtol(p, &pEnd, 10);
- return (NULL == pEnd ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED);
+
+ *pVal = strtol(p, NULL, 10);
+ return (errno == EINVAL || errno == ERANGE) ? TSDB_CODE_FAILED:TSDB_CODE_SUCCESS;
}
int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal) {
@@ -190,9 +189,9 @@ int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pV
if (NULL == p) {
return TSDB_CODE_FAILED;
}
- char* pEnd = NULL;
- *pVal = strtoul(p, &pEnd, 10);
- return (NULL == pEnd ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED);
+
+ *pVal = strtoul(p, NULL, 10);
+ return (errno == ERANGE||errno == EINVAL) ? TSDB_CODE_FAILED:TSDB_CODE_SUCCESS;
}
int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal) {
@@ -204,7 +203,7 @@ int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pV
int32_t tjsonGetBoolValue(const SJson* pJson, const char* pName, bool* pVal) {
const SJson* pObject = tjsonGetObjectItem(pJson, pName);
- if (cJSON_IsBool(pObject)) {
+ if (!cJSON_IsBool(pObject)) {
return TSDB_CODE_FAILED;
}
*pVal = cJSON_IsTrue(pObject) ? true : false;
diff --git a/source/util/test/cacheTest.cpp b/source/util/test/cacheTest.cpp
index 970f1c23a9..4dde374bdd 100644
--- a/source/util/test/cacheTest.cpp
+++ b/source/util/test/cacheTest.cpp
@@ -1,7 +1,7 @@
-#include "os.h"
#include
#include
+#include "os.h"
#include "taos.h"
#include "tcache.h"
diff --git a/source/util/test/encodeTest.cpp b/source/util/test/encodeTest.cpp
index 5505a6207f..7b993ebf35 100644
--- a/source/util/test/encodeTest.cpp
+++ b/source/util/test/encodeTest.cpp
@@ -1,6 +1,6 @@
#include
-#include "gtest/gtest.h"
+#include
#include "tencode.h"
diff --git a/source/util/test/freelistTest.cpp b/source/util/test/freelistTest.cpp
index cf11d6b5bf..7fd3d693fb 100644
--- a/source/util/test/freelistTest.cpp
+++ b/source/util/test/freelistTest.cpp
@@ -1,4 +1,4 @@
-#include "gtest/gtest.h"
+#include
#include "tfreelist.h"
diff --git a/source/util/test/hashTest.cpp b/source/util/test/hashTest.cpp
index ac1bae2434..4c6ee8d10c 100644
--- a/source/util/test/hashTest.cpp
+++ b/source/util/test/hashTest.cpp
@@ -1,9 +1,9 @@
-#include "os.h"
#include
#include
-#include
#include
+#include "os.h"
+#include "taosdef.h"
#include "thash.h"
#include "taos.h"
diff --git a/tools/shell/src/backup/shellImport.c b/tools/shell/src/backup/shellImport.c
index c0ab7ef461..36489a448b 100644
--- a/tools/shell/src/backup/shellImport.c
+++ b/tools/shell/src/backup/shellImport.c
@@ -93,8 +93,7 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{
sprintf(shellTablesSQLFile, "%s/tables.sql", directoryName);
- struct stat fstat;
- if (stat(shellTablesSQLFile, &fstat) < 0) {
+ if (taosFStatFile(shellTablesSQLFile, NULL, NULL) < 0) {
shellTablesSQLFile[0] = 0;
}
}
@@ -109,13 +108,12 @@ static void shellMallocSQLFiles()
static void shellGetDirectoryFileList(char *inputDir)
{
- struct stat fileStat;
- if (stat(inputDir, &fileStat) < 0) {
+ if (!taosDirExist(inputDir)) {
fprintf(stderr, "ERROR: %s not exist\n", inputDir);
exit(0);
}
- if (fileStat.st_mode & S_IFDIR) {
+ if (taosIsDir(inputDir)) {
shellCheckTablesSQLFile(inputDir);
shellSQLFileNum = shellGetFilesNum(inputDir, "sql");
int totalSQLFileNum = shellSQLFileNum;