diff --git a/example/src/tmq.c b/example/src/tmq.c index 8757104ad9..efb4d1830e 100644 --- a/example/src/tmq.c +++ b/example/src/tmq.c @@ -28,7 +28,7 @@ int32_t init_env() { return -1; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return -1; @@ -42,25 +42,33 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, k int) tags(a int)"); + pRes = + taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)"); if (taos_errno(pRes) != 0) { printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists tu1 using st1 tags(1)"); + pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists tu2 using st1 tags(2)"); + pRes = taos_query(pConn, "create table if not exists ct1 using st1 tags(2000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table tu2, reason:%s\n", taos_errstr(pRes)); return -1; } + + pRes = taos_query(pConn, "create table if not exists ct3 using st1 tags(3000)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table tu3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); return 0; } @@ -82,12 +90,40 @@ int32_t create_topic() { /*const char* sql = "select * from tu1";*/ /*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/ - pRes = taos_query(pConn, "create topic test_stb_topic_1 as select * from tu1"); + pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1 from ct1"); if (taos_errno(pRes) != 0) { - printf("failed to create topic test_stb_topic_1, reason:%s\n", taos_errstr(pRes)); + printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); + +#if 0 + pRes = taos_query(pConn, "insert into tu1 values(now, 1, 1.0, 'bi1')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + pRes = taos_query(pConn, "insert into tu1 values(now+1d, 1, 1.0, 'bi1')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + pRes = taos_query(pConn, "insert into tu2 values(now, 2, 2.0, 'bi2')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + pRes = taos_query(pConn, "insert into tu2 values(now+1d, 2, 2.0, 'bi2')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); +#endif + taos_close(pConn); return 0; } @@ -115,7 +151,7 @@ tmq_t* build_consumer() { tmq_list_t* build_topic_list() { tmq_list_t* topic_list = tmq_list_new(); - tmq_list_append(topic_list, "test_stb_topic_1"); + tmq_list_append(topic_list, "topic_ctb_column"); return topic_list; } @@ -215,8 +251,8 @@ int main(int argc, char* argv[]) { if (argc > 1) { printf("env init\n"); code = init_env(); + create_topic(); } - create_topic(); tmq_t* tmq = build_consumer(); tmq_list_t* topic_list = build_topic_list(); /*perf_loop(tmq, topic_list);*/ diff --git a/example/src/tstream.c b/example/src/tstream.c index 40d8ff9b0b..8ffa932bd2 100644 --- a/example/src/tstream.c +++ b/example/src/tstream.c @@ -20,7 +20,7 @@ #include "taos.h" int32_t init_env() { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 7010); + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { return -1; } @@ -65,7 +65,7 @@ int32_t init_env() { int32_t create_stream() { printf("create stream\n"); TAOS_RES* pRes; - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 7010); + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { return -1; } diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 51eabb7d61..8332e9d09a 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -37,6 +37,14 @@ enum { TMQ_MSG_TYPE__EP_RSP, }; +enum { + STREAM_TRIGGER__AT_ONCE = 1, + STREAM_TRIGGER__WINDOW_CLOSE, + STREAM_TRIGGER__BY_COUNT, + STREAM_TRIGGER__BY_BATCH_COUNT, + STREAM_TRIGGER__BY_EVENT_TIME, +}; + typedef struct { uint32_t numOfTables; SArray* pGroupList; @@ -54,13 +62,16 @@ typedef struct SColumnDataAgg { } SColumnDataAgg; typedef struct SDataBlockInfo { - STimeWindow window; - int32_t rows; - int32_t rowSize; - int16_t numOfCols; - int16_t hasVarCol; - union {int64_t uid; int64_t blockId;}; - int64_t groupId; // no need to serialize + STimeWindow window; + int32_t rows; + int32_t rowSize; + int16_t numOfCols; + int16_t hasVarCol; + union { + int64_t uid; + int64_t blockId; + }; + int64_t groupId; // no need to serialize } SDataBlockInfo; typedef struct SSDataBlock { @@ -93,7 +104,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock); int32_t tEncodeDataBlocks(void** buf, const SArray* blocks); void* tDecodeDataBlocks(const void* buf, SArray** blocks); -void colDataDestroy(SColumnInfoData* pColData) ; +void colDataDestroy(SColumnInfoData* pColData); static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) { // WARNING: do not use info.numOfCols, @@ -198,8 +209,8 @@ typedef struct SGroupbyExpr { } SGroupbyExpr; enum { - FUNC_PARAM_TYPE_VALUE = 0, - FUNC_PARAM_TYPE_COLUMN, + FUNC_PARAM_TYPE_VALUE = 0x1, + FUNC_PARAM_TYPE_COLUMN= 0x2, }; typedef struct SFunctParam { @@ -239,7 +250,7 @@ typedef struct SSessionWindow { SColumn col; } SSessionWindow; -#define QUERY_ASC_FORWARD_STEP 1 +#define QUERY_ASC_FORWARD_STEP 1 #define QUERY_DESC_FORWARD_STEP -1 #define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index cd16bbf862..31b316861b 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -524,6 +524,7 @@ typedef struct { int8_t walLevel; int8_t quorum; int8_t cacheLastRow; + int8_t replications; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); diff --git a/include/common/trow.h b/include/common/trow.h index df28bc9962..01f4076382 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -47,21 +47,21 @@ extern "C" { #define TD_VTYPE_NONE 0x0U // none or unknown/undefined #define TD_VTYPE_NULL 0x01U // null val #define TD_VTYPE_NORM 0x02U // normal val: not none, not null -#define TD_VTYPE_MAX 0x03U // +#define TD_VTYPE_MAX 0x03U // #define TD_VTYPE_NONE_BYTE 0x0U #define TD_VTYPE_NULL_BYTE 0x55U #define TD_VTYPE_NORM_BYTE 0xAAU -#define TD_ROWS_ALL_NORM 0x01U +#define TD_ROWS_ALL_NORM 0x01U #define TD_ROWS_NULL_NORM 0x0U -#define TD_COL_ROWS_NORM(c) ((c)->bitmap == TD_ROWS_ALL_NORM) // all rows of SDataCol/SBlockCol is NORM +#define TD_COL_ROWS_NORM(c) ((c)->bitmap == TD_ROWS_ALL_NORM) // all rows of SDataCol/SBlockCol is NORM #define TD_SET_COL_ROWS_BTIMAP(c, v) ((c)->bitmap = (v)) -#define TD_SET_COL_ROWS_NORM(c) TD_SET_COL_ROWS_BTIMAP((c), TD_ROWS_ALL_NORM) -#define TD_SET_COL_ROWS_MISC(c) TD_SET_COL_ROWS_BTIMAP((c), TD_ROWS_NULL_NORM) +#define TD_SET_COL_ROWS_NORM(c) TD_SET_COL_ROWS_BTIMAP((c), TD_ROWS_ALL_NORM) +#define TD_SET_COL_ROWS_MISC(c) TD_SET_COL_ROWS_BTIMAP((c), TD_ROWS_NULL_NORM) -#define KvConvertRatio (0.9f) +#define KvConvertRatio (0.9f) #define isSelectKVRow(klen, tlen) ((klen) < ((tlen)*KvConvertRatio)) #ifdef TD_SUPPORT_BITMAP @@ -98,7 +98,7 @@ typedef void *SRow; typedef struct { TDRowValT valType; - void * val; + void *val; } SCellVal; typedef struct { @@ -158,43 +158,43 @@ typedef struct { int16_t nBitmaps; int16_t nBoundBitmaps; int32_t offset; - void * pBitmap; - void * pOffset; + void *pBitmap; + void *pOffset; int32_t extendedRowSize; } SRowBuilder; -#define TD_ROW_HEAD_LEN (sizeof(STSRow)) +#define TD_ROW_HEAD_LEN (sizeof(STSRow)) #define TD_ROW_NCOLS_LEN (sizeof(col_id_t)) -#define TD_ROW_INFO(r) ((r)->info) -#define TD_ROW_TYPE(r) ((r)->type) -#define TD_ROW_DELETE(r) ((r)->del) -#define TD_ROW_ENDIAN(r) ((r)->endian) -#define TD_ROW_SVER(r) ((r)->sver) -#define TD_ROW_NCOLS(r) ((r)->data) // only valid for SKvRow -#define TD_ROW_DATA(r) ((r)->data) -#define TD_ROW_LEN(r) ((r)->len) -#define TD_ROW_KEY(r) ((r)->ts) +#define TD_ROW_INFO(r) ((r)->info) +#define TD_ROW_TYPE(r) ((r)->type) +#define TD_ROW_DELETE(r) ((r)->del) +#define TD_ROW_ENDIAN(r) ((r)->endian) +#define TD_ROW_SVER(r) ((r)->sver) +#define TD_ROW_NCOLS(r) ((r)->data) // only valid for SKvRow +#define TD_ROW_DATA(r) ((r)->data) +#define TD_ROW_LEN(r) ((r)->len) +#define TD_ROW_KEY(r) ((r)->ts) #define TD_ROW_KEY_ADDR(r) (r) // N.B. If without STSchema, getExtendedRowSize() is used to get the rowMaxBytes and // (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined. #define TD_ROW_MAX_BYTES_FROM_SCHEMA(s) (schemaTLen(s) + TD_ROW_HEAD_LEN) -#define TD_ROW_SET_INFO(r, i) (TD_ROW_INFO(r) = (i)) -#define TD_ROW_SET_TYPE(r, t) (TD_ROW_TYPE(r) = (t)) -#define TD_ROW_SET_DELETE(r) (TD_ROW_DELETE(r) = 1) -#define TD_ROW_SET_SVER(r, v) (TD_ROW_SVER(r) = (v)) -#define TD_ROW_SET_LEN(r, l) (TD_ROW_LEN(r) = (l)) +#define TD_ROW_SET_INFO(r, i) (TD_ROW_INFO(r) = (i)) +#define TD_ROW_SET_TYPE(r, t) (TD_ROW_TYPE(r) = (t)) +#define TD_ROW_SET_DELETE(r) (TD_ROW_DELETE(r) = 1) +#define TD_ROW_SET_SVER(r, v) (TD_ROW_SVER(r) = (v)) +#define TD_ROW_SET_LEN(r, l) (TD_ROW_LEN(r) = (l)) #define TD_ROW_SET_NCOLS(r, n) (*(col_id_t *)TD_ROW_NCOLS(r) = (n)) #define TD_ROW_IS_DELETED(r) (TD_ROW_DELETE(r) == 1) -#define TD_IS_TP_ROW(r) (TD_ROW_TYPE(r) == TD_ROW_TP) -#define TD_IS_KV_ROW(r) (TD_ROW_TYPE(r) == TD_ROW_KV) -#define TD_IS_TP_ROW_T(t) ((t) == TD_ROW_TP) -#define TD_IS_KV_ROW_T(t) ((t) == TD_ROW_KV) +#define TD_IS_TP_ROW(r) (TD_ROW_TYPE(r) == TD_ROW_TP) +#define TD_IS_KV_ROW(r) (TD_ROW_TYPE(r) == TD_ROW_KV) +#define TD_IS_TP_ROW_T(t) ((t) == TD_ROW_TP) +#define TD_IS_KV_ROW_T(t) ((t) == TD_ROW_KV) -#define TD_BOOL_STR(b) ((b) ? "true" : "false") +#define TD_BOOL_STR(b) ((b) ? "true" : "false") #define isUtilizeKVRow(k, d) ((k) < ((d)*KVRatioConvert)) #define TD_ROW_COL_IDX(r) POINTER_SHIFT(TD_ROW_DATA(r), sizeof(col_id_t)) @@ -275,7 +275,7 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6); @@ -313,7 +313,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pValType = (((*pDestByte) & 0xC0) >> 6); @@ -620,7 +620,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa if (tdValIsNorm(valType, val, colType)) { // ts key stored in STSRow.ts SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN @@ -638,7 +638,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa // NULL/None value else { SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN const void *nullVal = getNullValue(colType); @@ -775,8 +775,8 @@ static FORCE_INLINE int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, v typedef struct { STSchema *pSchema; - STSRow * pRow; - void * pBitmap; + STSRow *pRow; + void *pBitmap; uint32_t offset; col_id_t maxColId; col_id_t colIdx; // [PRIMARYKEY_TIMESTAMP_COL_ID, nSchemaCols], PRIMARYKEY_TIMESTAMP_COL_ID equals 1 @@ -881,7 +881,7 @@ static FORCE_INLINE bool tdGetTpRowDataOfCol(STSRowIter *pIter, col_type_t colTy // internal static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, col_type_t colType, col_id_t *nIdx, SCellVal *pVal) { - STSRow * pRow = pIter->pRow; + STSRow *pRow = pIter->pRow; SKvRowIdx *pKvIdx = NULL; bool colFound = false; col_id_t kvNCols = tdRowGetNCols(pRow); @@ -937,9 +937,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col STColumn *pCol = NULL; STSchema *pSchema = pIter->pSchema; while (pIter->colIdx <= pSchema->numOfCols) { - pCol = &pSchema->columns[pIter->colIdx]; + pCol = &pSchema->columns[pIter->colIdx]; // 1st column of schema is primary TS key if (colId == pCol->colId) { - ++pIter->colIdx; break; } else if (colId < pCol->colId) { ++pIter->colIdx; @@ -948,7 +947,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col return false; } } - return tdGetTpRowDataOfCol(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal); + tdGetTpRowDataOfCol(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal); + ++pIter->colIdx; } else if (TD_IS_KV_ROW(pIter->pRow)) { return tdGetKvRowValOfColEx(pIter, colId, colType, &pIter->kvIdx, pVal); } else { @@ -1076,7 +1076,7 @@ typedef struct { typedef struct { STSchema *pSchema; - STSRow * pRow; + STSRow *pRow; } STSRowReader; typedef struct { diff --git a/include/common/ttime.h b/include/common/ttime.h index 57af24e635..306f54bedb 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -60,8 +60,10 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati int32_t taosParseTime(const char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth); void deltaToUtcInitOnce(); +char getPrecisionUnit(int32_t precision); int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision); +int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit); void taosFormatUtcTime(char *buf, int32_t bufLen, int64_t time, int32_t precision); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 73c15d508c..07ca829bf0 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -82,21 +82,21 @@ #define TK_SINGLE_STABLE 64 #define TK_STREAM_MODE 65 #define TK_RETENTIONS 66 -#define TK_TABLE 67 -#define TK_NK_LP 68 -#define TK_NK_RP 69 -#define TK_STABLE 70 -#define TK_ADD 71 -#define TK_COLUMN 72 -#define TK_MODIFY 73 -#define TK_RENAME 74 -#define TK_TAG 75 -#define TK_SET 76 -#define TK_NK_EQ 77 -#define TK_USING 78 -#define TK_TAGS 79 -#define TK_NK_DOT 80 -#define TK_NK_COMMA 81 +#define TK_NK_COMMA 67 +#define TK_TABLE 68 +#define TK_NK_LP 69 +#define TK_NK_RP 70 +#define TK_STABLE 71 +#define TK_ADD 72 +#define TK_COLUMN 73 +#define TK_MODIFY 74 +#define TK_RENAME 75 +#define TK_TAG 76 +#define TK_SET 77 +#define TK_NK_EQ 78 +#define TK_USING 79 +#define TK_TAGS 80 +#define TK_NK_DOT 81 #define TK_COMMENT 82 #define TK_BOOL 83 #define TK_TINYINT 84 @@ -138,59 +138,62 @@ #define TK_INTERVAL 120 #define TK_TOPIC 121 #define TK_AS 122 -#define TK_EXPLAIN 123 -#define TK_ANALYZE 124 -#define TK_VERBOSE 125 -#define TK_NK_BOOL 126 -#define TK_RATIO 127 -#define TK_NULL 128 -#define TK_NK_VARIABLE 129 -#define TK_NK_UNDERLINE 130 -#define TK_ROWTS 131 -#define TK_TBNAME 132 -#define TK_QSTARTTS 133 -#define TK_QENDTS 134 -#define TK_WSTARTTS 135 -#define TK_WENDTS 136 -#define TK_WDURATION 137 -#define TK_BETWEEN 138 -#define TK_IS 139 -#define TK_NK_LT 140 -#define TK_NK_GT 141 -#define TK_NK_LE 142 -#define TK_NK_GE 143 -#define TK_NK_NE 144 -#define TK_MATCH 145 -#define TK_NMATCH 146 -#define TK_IN 147 -#define TK_JOIN 148 -#define TK_INNER 149 -#define TK_SELECT 150 -#define TK_DISTINCT 151 -#define TK_WHERE 152 -#define TK_PARTITION 153 -#define TK_BY 154 -#define TK_SESSION 155 -#define TK_STATE_WINDOW 156 -#define TK_SLIDING 157 -#define TK_FILL 158 -#define TK_VALUE 159 -#define TK_NONE 160 -#define TK_PREV 161 -#define TK_LINEAR 162 -#define TK_NEXT 163 -#define TK_GROUP 164 -#define TK_HAVING 165 -#define TK_ORDER 166 -#define TK_SLIMIT 167 -#define TK_SOFFSET 168 -#define TK_LIMIT 169 -#define TK_OFFSET 170 -#define TK_ASC 171 -#define TK_DESC 172 -#define TK_NULLS 173 -#define TK_FIRST 174 -#define TK_LAST 175 +#define TK_DESC 123 +#define TK_DESCRIBE 124 +#define TK_RESET 125 +#define TK_QUERY 126 +#define TK_EXPLAIN 127 +#define TK_ANALYZE 128 +#define TK_VERBOSE 129 +#define TK_NK_BOOL 130 +#define TK_RATIO 131 +#define TK_NULL 132 +#define TK_NK_VARIABLE 133 +#define TK_NK_UNDERLINE 134 +#define TK_ROWTS 135 +#define TK_TBNAME 136 +#define TK_QSTARTTS 137 +#define TK_QENDTS 138 +#define TK_WSTARTTS 139 +#define TK_WENDTS 140 +#define TK_WDURATION 141 +#define TK_BETWEEN 142 +#define TK_IS 143 +#define TK_NK_LT 144 +#define TK_NK_GT 145 +#define TK_NK_LE 146 +#define TK_NK_GE 147 +#define TK_NK_NE 148 +#define TK_MATCH 149 +#define TK_NMATCH 150 +#define TK_IN 151 +#define TK_JOIN 152 +#define TK_INNER 153 +#define TK_SELECT 154 +#define TK_DISTINCT 155 +#define TK_WHERE 156 +#define TK_PARTITION 157 +#define TK_BY 158 +#define TK_SESSION 159 +#define TK_STATE_WINDOW 160 +#define TK_SLIDING 161 +#define TK_FILL 162 +#define TK_VALUE 163 +#define TK_NONE 164 +#define TK_PREV 165 +#define TK_LINEAR 166 +#define TK_NEXT 167 +#define TK_GROUP 168 +#define TK_HAVING 169 +#define TK_ORDER 170 +#define TK_SLIMIT 171 +#define TK_SOFFSET 172 +#define TK_LIMIT 173 +#define TK_OFFSET 174 +#define TK_ASC 175 +#define TK_NULLS 176 +#define TK_FIRST 177 +#define TK_LAST 178 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/command/command.h b/include/libs/command/command.h new file mode 100644 index 0000000000..7e58d39692 --- /dev/null +++ b/include/libs/command/command.h @@ -0,0 +1,24 @@ +/* + * 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 "cmdnodes.h" +#include "tmsg.h" +#include "plannodes.h" + +int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp); + +int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp); + + diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index a03c496b4f..b7131716f3 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -20,8 +20,14 @@ extern "C" { #endif +#include "query.h" #include "querynodes.h" +#define DESCRIBE_RESULT_COLS 4 +#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE) +#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE) +#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE) + typedef struct SDatabaseOptions { ENodeType type; int32_t numOfBlocks; @@ -32,7 +38,9 @@ typedef struct SDatabaseOptions { int32_t fsyncPeriod; int32_t maxRowsPerBlock; int32_t minRowsPerBlock; - int32_t keep; + int32_t keep0; + int32_t keep1; + int32_t keep2; int32_t precision; int32_t quorum; int32_t replica; @@ -70,7 +78,9 @@ typedef struct SAlterDatabaseStmt { typedef struct STableOptions { ENodeType type; - int32_t keep; + int32_t keep0; + int32_t keep1; + int32_t keep2; int32_t ttl; char comments[TSDB_STB_COMMENT_LEN]; SNodeList* pSma; @@ -247,6 +257,13 @@ typedef struct SAlterLocalStmt { char value[TSDB_DNODE_VALUE_LEN]; } SAlterLocalStmt; +typedef struct SDescribeStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + STableMeta* pMeta; +} SDescribeStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 83c0bccaaf..9849dfca39 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -101,6 +101,8 @@ typedef enum ENodeType { QUERY_NODE_DROP_TOPIC_STMT, QUERY_NODE_ALTER_LOCAL_STMT, QUERY_NODE_EXPLAIN_STMT, + QUERY_NODE_DESCRIBE_STMT, + QUERY_NODE_RESET_QUERY_CACHE_STMT, QUERY_NODE_SHOW_DATABASES_STMT, QUERY_NODE_SHOW_TABLES_STMT, QUERY_NODE_SHOW_STABLES_STMT, @@ -213,6 +215,8 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode); int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen); int32_t nodesStringToList(const char* pStr, SNodeList** pList); +int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index f41e049196..37163f60dd 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -253,7 +253,7 @@ typedef struct SIntervalPhysiNode { int64_t sliding; int8_t intervalUnit; int8_t slidingUnit; - uint8_t precision; + uint8_t precision; SFillNode* pFill; } SIntervalPhysiNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 23a63c1a0b..ddcbaa0bee 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -314,6 +314,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery); bool nodesIsTimelineQuery(const SNode* pQuery); void* nodesGetValueFromNode(SValueNode *pNode); +char* nodesGetStrValueFromNode(SValueNode *pNode); #ifdef __cplusplus } diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 0747534721..f10185c44f 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -55,6 +55,7 @@ typedef struct SQuery { SArray* pDbList; SArray* pTableList; bool showRewrite; + bool localCmd; } SQuery; int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery); diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index f487e5ae22..bb550e75e8 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -53,6 +53,7 @@ typedef struct SIndexMeta { } SIndexMeta; + /* * ASSERT(sizeof(SCTableMeta) == 24) * ASSERT(tableType == TSDB_CHILD_TABLE) @@ -235,6 +236,11 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t } \ } while (0) +#define QRY_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define QRY_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define QRY_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + + #ifdef __cplusplus } #endif diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 8b1ac3ed8d..e635227eaa 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -61,16 +61,16 @@ extern "C" { } \ } -#define WAL_HEAD_VER 0 +#define WAL_HEAD_VER 0 #define WAL_NOSUFFIX_LEN 20 -#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1) -#define WAL_LOG_SUFFIX "log" +#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1) +#define WAL_LOG_SUFFIX "log" #define WAL_INDEX_SUFFIX "idx" -#define WAL_REFRESH_MS 1000 -#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead)) -#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12) -#define WAL_FILE_LEN (WAL_PATH_LEN + 32) -#define WAL_MAGIC 0xFAFBFCFDULL +#define WAL_REFRESH_MS 1000 +#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead)) +#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12) +#define WAL_FILE_LEN (WAL_PATH_LEN + 32) +#define WAL_MAGIC 0xFAFBFCFDULL #define WAL_CUR_FAILED 1 @@ -150,14 +150,15 @@ typedef struct SWal { } SWal; // WAL HANDLE typedef struct SWalReadHandle { - SWal *pWal; - TdFilePtr pReadLogTFile; - TdFilePtr pReadIdxTFile; - int64_t curFileFirstVer; - int64_t curVersion; - int64_t capacity; - int64_t status; // if cursor valid - SWalHead *pHead; + SWal *pWal; + TdFilePtr pReadLogTFile; + TdFilePtr pReadIdxTFile; + int64_t curFileFirstVer; + int64_t curVersion; + int64_t capacity; + int64_t status; // if cursor valid + TdThreadMutex mutex; + SWalHead *pHead; } SWalReadHandle; #pragma pack(pop) @@ -191,6 +192,7 @@ int32_t walEndSnapshot(SWal *); SWalReadHandle *walOpenReadHandle(SWal *); void walCloseReadHandle(SWalReadHandle *); int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver); +int32_t walReadWithHandle_s(SWalReadHandle *pRead, int64_t ver, SWalReadHead **ppHead); // deprecated #if 0 diff --git a/include/os/os.h b/include/os/os.h index 0d0c308134..3ea94d0094 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -82,6 +82,7 @@ extern "C" { #include "osLz4.h" #include "osMath.h" #include "osMemory.h" +#include "osProc.h" #include "osRand.h" #include "osThread.h" #include "osSemaphore.h" diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 62ac82782c..34e2422167 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -32,6 +32,7 @@ extern "C" { void *taosMemoryMalloc(int32_t size); void *taosMemoryCalloc(int32_t num, int32_t size); void *taosMemoryRealloc(void *ptr, int32_t size); +void *taosMemoryStrDup(void *ptr); void taosMemoryFree(const void *ptr); int32_t taosMemorySize(void *ptr); diff --git a/include/os/osProc.h b/include/os/osProc.h new file mode 100644 index 0000000000..f09b695ef4 --- /dev/null +++ b/include/os/osProc.h @@ -0,0 +1,34 @@ +/* + * 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_OS_PROC_H_ +#define _TD_OS_PROC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t taosNewProc(char **args); +void taosWaitProc(int32_t pid); +void taosKillProc(int32_t pid); +bool taosProcExist(int32_t pid); +void taosSetProcName(int32_t argc, char **argv, const char *name); +void taosSetProcPath(int32_t argc, char **argv); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_OS_PROC_H_*/ diff --git a/include/os/osShm.h b/include/os/osShm.h index 82ee2339f2..d26a99e277 100644 --- a/include/os/osShm.h +++ b/include/os/osShm.h @@ -29,7 +29,6 @@ typedef struct { int32_t taosCreateShm(SShm *pShm, int32_t shmsize) ; void taosDropShm(SShm *pShm); int32_t taosAttachShm(SShm *pShm); -void taosDetachShm(SShm *pShm); #ifdef __cplusplus } diff --git a/include/os/osSignal.h b/include/os/osSignal.h index ab4b6fa242..e22c43684c 100644 --- a/include/os/osSignal.h +++ b/include/os/osSignal.h @@ -49,6 +49,8 @@ void taosSetSignal(int32_t signum, FSignalHandler sigfp); void taosIgnSignal(int32_t signum); void taosDflSignal(int32_t signum); +void taosKillChildOnParentStopped(); + #ifdef __cplusplus } #endif diff --git a/include/os/osThread.h b/include/os/osThread.h index cca25f4fa4..a145b0da07 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -42,103 +42,103 @@ typedef pthread_barrierattr_t TdThreadBarrierAttr; // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - // #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID - // #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID - // #define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID - // #define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID - // #define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID - // #define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID - // #define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID - // #define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID - // #define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID - // #define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID - // #define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID - // #define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID - // #define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID - // #define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID - // #define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID - // #define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID - // #define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID - // #define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID - // #define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID - // #define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID - // #define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID - // #define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID - // #define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID - // #define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID - // #define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID - // #define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID - // #define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID - // #define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID - // #define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID - // #define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID - // #define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID - // #define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID - // #define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID - // #define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID - // #define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID - // #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID - // #define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID - // #define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID - // #define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID - // #define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID - // #define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID - // #define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID - // #define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID - // #define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID - // #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID - // #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID - // #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID - // #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID - // #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID - // #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID - // #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID - // #define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID - // #define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID - // #define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID - // #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID - // #define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID - // #define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID - // #define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID - // #define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID - // #define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID - // #define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID - // #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID - // #define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID - // #define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID - // #define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID - // #define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID - // #define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID - // #define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID - // #define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID - // #define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID - // #define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID - // #define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID - // #define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID - // #define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID - // #define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID - // #define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID - // #define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID - // #define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID - // #define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID - // #define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID - // #define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID - // #define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID - // #define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID - // #define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID - // #define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID - // #define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID - // #define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID - // #define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID - // #define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID - // #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID - // #define sigwait SIGWAIT_FUNC_TAOS_FORBID + #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID + #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID + #define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID + #define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID + #define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID + #define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID + #define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID + #define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID + #define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID + #define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID + #define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID + #define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID + #define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID + #define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID + #define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID + #define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID + #define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID + #define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID + #define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID + #define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID + #define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID + #define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID + #define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID + #define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID + #define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID + #define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID + #define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID + #define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID + #define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID + #define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID + #define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID + #define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID + #define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID + #define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID + #define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID + #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID + #define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID + #define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID + #define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID + #define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID + #define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID + #define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID + #define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID + #define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID + #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID + #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID + #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID + #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID + #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID + #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID + #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID + #define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID + #define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID + #define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID + #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID + #define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID + #define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID + #define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID + #define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID + #define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID + #define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID + #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID + #define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID + #define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID + #define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID + #define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID + #define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID + #define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID + #define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID + #define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID + #define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID + #define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID + #define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID + #define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID + #define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID + #define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID + #define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID + #define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID + #define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID + #define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID + #define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID + #define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID + #define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID + #define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID + #define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID + #define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID + #define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID + #define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID + #define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID + #define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID + #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID + #define sigwait SIGWAIT_FUNC_TAOS_FORBID #endif int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg); diff --git a/include/os/osTime.h b/include/os/osTime.h index 9e426455dc..766fec0fbd 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -46,6 +46,14 @@ extern "C" { #define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24) #define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7) +#define NANOSECOND_PER_USEC (1000L) +#define NANOSECOND_PER_MSEC (1000000L) +#define NANOSECOND_PER_SEC (1000000000L) +#define NANOSECOND_PER_MINUTE (NANOSECOND_PER_SEC * 60) +#define NANOSECOND_PER_HOUR (NANOSECOND_PER_MINUTE * 60) +#define NANOSECOND_PER_DAY (NANOSECOND_PER_HOUR * 24) +#define NANOSECOND_PER_WEEK (NANOSECOND_PER_DAY * 7) + int32_t taosGetTimeOfDay(struct timeval *tv); //@return timestamp in second diff --git a/include/util/taoserror.h b/include/util/taoserror.h index d49e83b012..4e2cb7944a 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -78,6 +78,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x010C) #define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x010D) #define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x010E) +#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x010F) #define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0110) #define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0111) #define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0112) @@ -478,6 +479,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613) #define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614) #define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615) +#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616) +#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617) +#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618) #ifdef __cplusplus } diff --git a/include/util/tdef.h b/include/util/tdef.h index 43981adea2..517cb8baee 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -224,6 +224,7 @@ typedef enum ELogicConditionType { #define TSDB_APP_NAME_LEN TSDB_UNI_LEN #define TSDB_STB_COMMENT_LEN 1024 + /** * In some scenarios uint16_t (0~65535) is used to store the row len. * - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header. @@ -303,13 +304,13 @@ typedef enum ELogicConditionType { #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 6 -#define TSDB_MIN_DAYS_PER_FILE 1 -#define TSDB_MAX_DAYS_PER_FILE 3650 -#define TSDB_DEFAULT_DAYS_PER_FILE 10 +#define TSDB_MIN_DAYS_PER_FILE (1 * 1440) // unit minute +#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) +#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) -#define TSDB_MIN_KEEP 1 // data in db to be reserved. -#define TSDB_MAX_KEEP 365000 // data in db to be reserved. -#define TSDB_DEFAULT_KEEP 3650 // ten years +#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute +#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. +#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MIN_ROW_FBLOCK 10 #define TSDB_MAX_MIN_ROW_FBLOCK 1000 @@ -327,7 +328,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond #define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second -#define TSDB_MIN_WAL_LEVEL 0 +#define TSDB_MIN_WAL_LEVEL 1 #define TSDB_MAX_WAL_LEVEL 2 #define TSDB_DEFAULT_WAL_LEVEL 1 @@ -388,6 +389,7 @@ typedef enum ELogicConditionType { #define TSDB_DEFAULT_EXPLAIN_RATIO 0.001 #define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024 +#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN" #define TSDB_MAX_JOIN_TABLE_NUM 10 #define TSDB_MAX_UNION_CLAUSE 5 @@ -479,6 +481,9 @@ enum { #define QND_VGID 1 #define VND_VGID 0 +#define MAX_NUM_STR_SIZE 40 + + #ifdef __cplusplus } #endif diff --git a/include/util/tprocess.h b/include/util/tprocess.h index 51ce0243b7..3a47450eec 100644 --- a/include/util/tprocess.h +++ b/include/util/tprocess.h @@ -32,29 +32,25 @@ typedef void *(*ProcConsumeFp)(void *pParent, void *pHead, int16_t headLen, void ProcFuncType ftype); typedef struct { - int32_t childQueueSize; ProcConsumeFp childConsumeFp; ProcMallocFp childMallocHeadFp; ProcFreeFp childFreeHeadFp; ProcMallocFp childMallocBodyFp; ProcFreeFp childFreeBodyFp; - int32_t parentQueueSize; ProcConsumeFp parentConsumeFp; - ProcMallocFp parentdMallocHeadFp; + ProcMallocFp parentMallocHeadFp; ProcFreeFp parentFreeHeadFp; ProcMallocFp parentMallocBodyFp; ProcFreeFp parentFreeBodyFp; - bool testFlag; + SShm shm; void *pParent; const char *name; + bool isChild; } SProcCfg; SProcObj *taosProcInit(const SProcCfg *pCfg); void taosProcCleanup(SProcObj *pProc); int32_t taosProcRun(SProcObj *pProc); -void taosProcStop(SProcObj *pProc); -bool taosProcIsChild(SProcObj *pProc); -int32_t taosProcChildId(SProcObj *pProc); int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, ProcFuncType ftype); int32_t taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index a632337d4a..8ee6c31ba1 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( taos INTERFACE api - PRIVATE os util common transport nodes parser planner catalog scheduler function qcom + PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom ) if(${BUILD_TEST}) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index d8017a8727..8cd53f18b0 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1,6 +1,7 @@ #include "clientInt.h" #include "clientLog.h" +#include "command.h" #include "scheduler.h" #include "tdatablock.h" #include "tdef.h" @@ -170,7 +171,21 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery) { return code; } +int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { + SRetrieveTableRsp* pRsp = NULL; + int32_t code = qExecCommand(pQuery->pRoot, &pRsp); + if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp); + } + return code; +} + int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { + // drop table if exists not_exists_table + if (NULL == pQuery->pCmdMsg) { + return TSDB_CODE_SUCCESS; + } + SCmdMsgInfo* pMsgInfo = pQuery->pCmdMsg; pRequest->type = pMsgInfo->msgType; pRequest->body.requestMsg = (SDataBuf){.pData = pMsgInfo->pMsg, .len = pMsgInfo->msgLen, .handle = NULL}; @@ -259,7 +274,9 @@ SRequestObj* execQueryImpl(STscObj* pTscObj, const char* sql, int sqlLen) { CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, false, &pQuery), _return); - if (pQuery->directRpc) { + if (pQuery->localCmd) { + CHECK_CODE_GOTO(execLocalCmd(pRequest, pQuery), _return); + } else if (pQuery->directRpc) { CHECK_CODE_GOTO(execDdlQuery(pRequest, pQuery), _return); } else { CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList), _return); @@ -464,9 +481,11 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { taosMemoryFreeClear(pMsgBody->msgInfo.pData); taosMemoryFreeClear(pMsgBody); } + bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) { return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP || msgType == TDMT_VND_QUERY_HEARTBEAT_RSP; } + void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->ahandle; assert(pMsg->ahandle != NULL); @@ -647,6 +666,11 @@ void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { } } + if (pResultInfo->completed) { + pResultInfo->numOfRows = 0; + return NULL; + } + SMsgSendInfo* body = buildMsgInfoImpl(pRequest); int64_t transporterId = 0; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 1fa267ae7e..5d1e95be7c 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -255,6 +255,7 @@ void tmqClearUnhandleMsg(tmq_t* tmq) { break; } + msg = NULL; taosReadAllQitems(tmq->mqueue, tmq->qall); while (1) { taosGetQitem(tmq->qall, (void**)&msg); @@ -787,7 +788,7 @@ void tmqShowMsg(tmq_message_t* tmq_message) { static bool noPrintSchema; char pBuf[128]; SMqPollRsp* pRsp = &tmq_message->msg; - int32_t colNum = pRsp->schema->nCols; + int32_t colNum = 2; if (!noPrintSchema) { printf("|"); for (int32_t i = 0; i < colNum; i++) { @@ -838,6 +839,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { int32_t msgEpoch = ((SMqRspHead*)pMsg->pData)->epoch; int32_t tmqEpoch = atomic_load_32(&tmq->epoch); if (msgEpoch < tmqEpoch) { + /*printf("discard rsp epoch %d, current epoch %d\n", msgEpoch, tmqEpoch);*/ tsem_post(&tmq->rspSem); tscWarn("discard rsp epoch %d, current epoch %d", msgEpoch, tmqEpoch); return 0; @@ -886,6 +888,9 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { goto WRITE_QUEUE_FAIL; } + tscError("tmq recv poll: vg %d, req offset %ld, rsp offset %ld", pParam->pVg->vgId, pRsp->msg.reqOffset, + pRsp->msg.rspOffset); + pRsp->vg = pParam->pVg; taosWriteQitem(tmq->mqueue, pRsp); atomic_add_fetch_32(&tmq->readyRequest, 1); @@ -902,6 +907,7 @@ WRITE_QUEUE_FAIL: bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) { /*printf("call update ep %d\n", epoch);*/ + /*printf("tmq update ep epoch %d to epoch %d\n", tmq->epoch, epoch);*/ bool set = false; int32_t topicNumGet = taosArrayGetSize(pRsp->topics); char vgKey[TSDB_TOPIC_FNAME_LEN + 22]; @@ -932,6 +938,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) { for (int32_t k = 0; k < vgNumCur; k++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, k); sprintf(vgKey, "%s:%d", topic.topicName, pVgCur->vgId); + /*printf("epoch %d vg %d build %s\n", epoch, pVgCur->vgId, vgKey);*/ taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(int64_t)); } break; @@ -945,9 +952,12 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) { sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId); int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); int64_t offset = pVgEp->offset; + /*printf("epoch %d vg %d offset og to %ld\n", epoch, pVgEp->vgId, offset);*/ if (pOffset != NULL) { offset = *pOffset; + /*printf("epoch %d vg %d found %s\n", epoch, pVgEp->vgId, vgKey);*/ } + /*printf("epoch %d vg %d offset set to %ld\n", epoch, pVgEp->vgId, offset);*/ SMqClientVg clientVg = { .pollCnt = 0, .currentOffset = offset, @@ -1195,6 +1205,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); if (vgStatus != TMQ_VG_STATUS__IDLE) { + /*printf("skip vg %d\n", pVg->vgId);*/ continue; } SMqPollReq* pReq = tmqBuildConsumeReqImpl(tmq, blockingTime, pTopic, pVg); @@ -1238,6 +1249,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) { int64_t transporterId = 0; /*printf("send poll\n");*/ atomic_add_fetch_32(&tmq->waitingRequest, 1); + /*tscDebug("tmq send poll: vg %d, req offset %ld", pVg->vgId, pVg->currentOffset);*/ + /*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/ asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); pVg->pollCnt++; tmq->pollCnt++; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c85184ffba..06dd2906be 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1629,6 +1629,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; + if (tEncodeI8(&encoder, pReq->replications) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1650,6 +1651,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 510a2809e7..a65352f2b9 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -361,6 +361,18 @@ int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) { return 0; } +char getPrecisionUnit(int32_t precision) { + static char units[3] = {TIME_UNIT_MILLISECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_NANOSECOND}; + switch (precision) { + case TSDB_TIME_PRECISION_MILLI: + case TSDB_TIME_PRECISION_MICRO: + case TSDB_TIME_PRECISION_NANO: + return units[precision]; + default: + return 0; + } +} + int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_NANO); @@ -370,6 +382,33 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec return (int64_t)((double)time * factors[fromPrecision][toPrecision]); } +int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) { + assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || + fromPrecision == TSDB_TIME_PRECISION_NANO); + static double factors[3] = {1000000., 1000., 1.}; + switch (toUnit) { + case 's': + return time * factors[fromPrecision] / NANOSECOND_PER_SEC; + case 'm': + return time * factors[fromPrecision] / NANOSECOND_PER_MINUTE; + case 'h': + return time * factors[fromPrecision] / NANOSECOND_PER_HOUR; + case 'd': + return time * factors[fromPrecision] / NANOSECOND_PER_DAY; + case 'w': + return time * factors[fromPrecision] / NANOSECOND_PER_WEEK; + case 'a': + return time * factors[fromPrecision] / NANOSECOND_PER_MSEC; + case 'u': + return time * factors[fromPrecision] / NANOSECOND_PER_USEC; + case 'b': + return time * factors[fromPrecision]; + default: { + return -1; + } + } +} + static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { switch (unit) { case 's': @@ -688,4 +727,4 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm); tstrncpy(buf, ts, bufLen); -} \ No newline at end of file +} diff --git a/source/dnode/mgmt/dm/src/dmFile.c b/source/dnode/mgmt/dm/src/dmFile.c index d44b1222a3..d5105bcb1b 100644 --- a/source/dnode/mgmt/dm/src/dmFile.c +++ b/source/dnode/mgmt/dm/src/dmFile.c @@ -130,7 +130,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) { } code = 0; - dInfo("succcessed to read file %s", file); + dDebug("succcessed to read file %s", file); dmPrintDnodes(pMgmt); PRASE_DNODE_OVER: @@ -200,7 +200,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) { taosMemoryFree(content); char realfile[PATH_MAX]; - snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP); + snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pMgmt->path, TD_DIRSEP); if (taosRenameFile(file, realfile) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/source/dnode/mgmt/dm/src/dmInt.c b/source/dnode/mgmt/dm/src/dmInt.c index b729888a72..3c5f394d5e 100644 --- a/source/dnode/mgmt/dm/src/dmInt.c +++ b/source/dnode/mgmt/dm/src/dmInt.c @@ -112,6 +112,16 @@ int32_t dmInit(SMgmtWrapper *pWrapper) { return -1; } + if (dndInitServer(pDnode) != 0) { + dError("failed to init trans server since %s", terrstr()); + return -1; + } + + if (dndInitClient(pDnode) != 0) { + dError("failed to init trans client since %s", terrstr()); + return -1; + } + pWrapper->pMgmt = pMgmt; dInfo("dnode-mgmt is initialized"); return 0; @@ -122,6 +132,7 @@ void dmCleanup(SMgmtWrapper *pWrapper) { if (pMgmt == NULL) return; dInfo("dnode-mgmt start to clean up"); + SDnode *pDnode = pMgmt->pDnode; dmStopWorker(pMgmt); taosWLockLatch(&pMgmt->latch); @@ -140,6 +151,9 @@ void dmCleanup(SMgmtWrapper *pWrapper) { taosMemoryFree(pMgmt); pWrapper->pMgmt = NULL; + dndCleanupServer(pDnode); + dndCleanupClient(pDnode); + dInfo("dnode-mgmt is cleaned up"); } diff --git a/source/dnode/mgmt/dm/src/dmMsg.c b/source/dnode/mgmt/dm/src/dmMsg.c index b301ef478b..3795cffbfa 100644 --- a/source/dnode/mgmt/dm/src/dmMsg.c +++ b/source/dnode/mgmt/dm/src/dmMsg.c @@ -53,7 +53,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { tSerializeSStatusReq(pHead, contLen, &req); taosArrayDestroy(req.pVloads); - SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .ahandle = (void *)9527}; + SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .ahandle = (void *)0x9527}; pMgmt->statusSent = 1; dTrace("send req:%s to mnode, app:%p", TMSG_INFO(rpcMsg.msgType), rpcMsg.ahandle); diff --git a/source/dnode/mgmt/main/exe/dndMain.c b/source/dnode/mgmt/main/exe/dndMain.c index 525b26d967..0d2ddbfbbc 100644 --- a/source/dnode/mgmt/main/exe/dndMain.c +++ b/source/dnode/mgmt/main/exe/dndMain.c @@ -30,18 +30,13 @@ static struct { } global = {0}; static void dndStopDnode(int signum, void *info, void *ctx) { - dInfo("signal:%d is received", signum); + dInfo("system signal:%d received", signum); SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode); if (pDnode != NULL) { dndHandleEvent(pDnode, DND_EVENT_STOP); } } -static void dndHandleChild(int signum, void *info, void *ctx) { - dInfo("signal:%d is received", signum); - dndHandleEvent(global.pDnode, DND_EVENT_CHILD); -} - static void dndSetSignalHandle() { taosSetSignal(SIGTERM, dndStopDnode); taosSetSignal(SIGHUP, dndStopDnode); @@ -50,15 +45,10 @@ static void dndSetSignalHandle() { taosSetSignal(SIGBREAK, dndStopDnode); if (!tsMultiProcess) { - // Set the single process signal - } else if (global.ntype == DNODE) { - // Set the parent process signal - // When the child process exits, the parent process receives a signal - taosSetSignal(SIGCHLD, dndHandleChild); + } else if (global.ntype == DNODE || global.ntype == NODE_MAX) { + taosIgnSignal(SIGCHLD); } else { - // Set child process signal - // When the parent process exits, the child process will receive the SIGKILL signal - prctl(PR_SET_PDEATHSIG, SIGKILL); + taosKillChildOnParentStopped(); } } @@ -79,10 +69,14 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) { tstrncpy(global.apolloUrl, argv[++i], PATH_MAX); } else if (strcmp(argv[i], "-e") == 0) { tstrncpy(global.envFile, argv[++i], PATH_MAX); - } else if (strcmp(argv[i], "-k") == 0) { - global.generateGrant = true; } else if (strcmp(argv[i], "-n") == 0) { global.ntype = atoi(argv[++i]); + if (global.ntype <= DNODE || global.ntype > NODE_MAX) { + printf("'-n' range is [1-5], default is 0\n"); + return -1; + } + } else if (strcmp(argv[i], "-k") == 0) { + global.generateGrant = true; } else if (strcmp(argv[i], "-C") == 0) { global.dumpConfig = true; } else if (strcmp(argv[i], "-V") == 0) { @@ -138,24 +132,24 @@ static int32_t dndInitLog() { return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0); } -static void dndSetProcName(char **argv) { - if (global.ntype != DNODE) { +static void dndSetProcInfo(int32_t argc, char **argv) { + taosSetProcPath(argc, argv); + if (global.ntype != DNODE && global.ntype != NODE_MAX) { const char *name = dndNodeProcStr(global.ntype); - prctl(PR_SET_NAME, name); - strcpy(argv[0], name); + taosSetProcName(argc, argv, name); } } static int32_t dndRunDnode() { if (dndInit() != 0) { - dError("failed to initialize environment since %s", terrstr()); + dError("failed to init environment since %s", terrstr()); return -1; } SDnodeOpt option = dndGetOpt(); SDnode *pDnode = dndCreate(&option); if (pDnode == NULL) { - dError("failed to to create dnode object since %s", terrstr()); + dError("failed to to create dnode since %s", terrstr()); return -1; } else { global.pDnode = pDnode; @@ -212,6 +206,6 @@ int main(int argc, char const *argv[]) { return 0; } - dndSetProcName((char **)argv); + dndSetProcInfo(argc, (char **)argv); return dndRunDnode(); } diff --git a/source/dnode/mgmt/main/inc/dnd.h b/source/dnode/mgmt/main/inc/dnd.h index b416ee4f7a..b9c760c980 100644 --- a/source/dnode/mgmt/main/inc/dnd.h +++ b/source/dnode/mgmt/main/inc/dnd.h @@ -95,13 +95,14 @@ typedef struct SMgmtWrapper { bool deployed; bool required; EProcType procType; + int32_t procId; SProcObj *pProc; SShm shm; void *pMgmt; SDnode *pDnode; - NodeMsgFp msgFps[TDMT_MAX]; - int8_t msgVgIds[TDMT_MAX]; // Handle the case where the same message type is distributed to qnode or vnode SMgmtFp fp; + int8_t msgVgIds[TDMT_MAX]; // Handle the case where the same message type is distributed to qnode or vnode + NodeMsgFp msgFps[TDMT_MAX]; } SMgmtWrapper; typedef struct { @@ -128,26 +129,31 @@ typedef struct SDnode { EDndStatus status; EDndEvent event; SStartupReq startup; - TdFilePtr runtimeFile; + TdFilePtr lockfile; STransMgmt trans; SMgmtWrapper wrappers[NODE_MAX]; } SDnode; const char *dndNodeLogStr(ENodeType ntype); const char *dndNodeProcStr(ENodeType ntype); +const char *dndEventStr(EDndEvent ev); EDndStatus dndGetStatus(SDnode *pDnode); void dndSetStatus(SDnode *pDnode, EDndStatus stat); void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId); void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); void dndSendMonitorReport(SDnode *pDnode); +int32_t dndInitServer(SDnode *pDnode); +void dndCleanupServer(SDnode *pDnode); +int32_t dndInitClient(SDnode *pDnode); +void dndCleanupClient(SDnode *pDnode); +int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg); int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg); void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp); void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper); -int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg); int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed); int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed); diff --git a/source/dnode/mgmt/main/inc/dndInt.h b/source/dnode/mgmt/main/inc/dndInt.h index 56782f872b..612d35d513 100644 --- a/source/dnode/mgmt/main/inc/dndInt.h +++ b/source/dnode/mgmt/main/inc/dndInt.h @@ -50,17 +50,13 @@ void dndClose(SDnode *pDnode); void dndHandleEvent(SDnode *pDnode, EDndEvent event); // dndTransport.c -int32_t dndInitServer(SDnode *pDnode); -void dndCleanupServer(SDnode *pDnode); -int32_t dndInitClient(SDnode *pDnode); -void dndCleanupClient(SDnode *pDnode); int32_t dndInitMsgHandle(SDnode *pDnode); void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp); // dndFile.c -int32_t dndOpenRuntimeFile(SDnode *pDnode); -int32_t dndWriteRuntimeFile(SDnode *pDnode); -void dndCloseRuntimeFile(SDnode *pDnode); +TdFilePtr dndCheckRunning(const char *dataDir); +int32_t dndReadShmFile(SDnode *pDnode); +int32_t dndWriteShmFile(SDnode *pDnode); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/main/src/dndEnv.c b/source/dnode/mgmt/main/src/dndEnv.c new file mode 100644 index 0000000000..8792147822 --- /dev/null +++ b/source/dnode/mgmt/main/src/dndEnv.c @@ -0,0 +1,96 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "dndInt.h" +#include "wal.h" + +static int8_t once = DND_ENV_INIT; + +int32_t dndInit() { + dDebug("start to init dnode env"); + if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) { + terrno = TSDB_CODE_REPEAT_INIT; + dError("failed to init dnode env since %s", terrstr()); + return -1; + } + + taosIgnSIGPIPE(); + taosBlockSIGPIPE(); + taosResolveCRC(); + + SMonCfg monCfg = {0}; + monCfg.maxLogs = tsMonitorMaxLogs; + monCfg.port = tsMonitorPort; + monCfg.server = tsMonitorFqdn; + monCfg.comp = tsMonitorComp; + if (monInit(&monCfg) != 0) { + dError("failed to init monitor since %s", terrstr()); + return -1; + } + + dInfo("dnode env is initialized"); + return 0; +} + +void dndCleanup() { + dDebug("start to cleanup dnode env"); + if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) { + dError("dnode env is already cleaned up"); + return; + } + + monCleanup(); + walCleanUp(); + taosStopCacheRefreshWorker(); + dInfo("dnode env is cleaned up"); +} + +void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) { + pWrapper->msgFps[TMSG_INDEX(msgType)] = nodeMsgFp; + pWrapper->msgVgIds[TMSG_INDEX(msgType)] = vgId; +} + +EDndStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; } + +void dndSetStatus(SDnode *pDnode, EDndStatus status) { + if (pDnode->status != status) { + dDebug("dnode status set from %s to %s", dndStatStr(pDnode->status), dndStatStr(status)); + pDnode->status = status; + } +} + +void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { + SStartupReq *pStartup = &pDnode->startup; + tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN); + tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN); + pStartup->finished = 0; +} + +void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) { + memcpy(pStartup, &pDnode->startup, sizeof(SStartupReq)); + pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING); +} + +void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { + dDebug("startup req is received"); + SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq)); + dndGetStartup(pDnode, pStartup); + + dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished); + SRpcMsg rpcRsp = { + .handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq), .ahandle = pReq->ahandle}; + rpcSendResponse(&rpcRsp); +} diff --git a/source/dnode/mgmt/main/src/dndExec.c b/source/dnode/mgmt/main/src/dndExec.c index c41d4f28e4..b37893aa6f 100644 --- a/source/dnode/mgmt/main/src/dndExec.c +++ b/source/dnode/mgmt/main/src/dndExec.c @@ -16,35 +16,30 @@ #define _DEFAULT_SOURCE #include "dndInt.h" -static void dndResetLog(SMgmtWrapper *pMgmt) { - char logname[24] = {0}; - snprintf(logname, sizeof(logname), "%slog", pMgmt->name); - - dInfo("node:%s, reset log to %s in child process", pMgmt->name, logname); - taosCloseLog(); - taosInitLog(logname, 1); -} - static bool dndRequireNode(SMgmtWrapper *pWrapper) { - bool required = false; - int32_t code =(*pWrapper->fp.requiredFp)(pWrapper, &required); + bool required = false; + int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required); if (!required) { - dDebug("node:%s, no need to start", pWrapper->name); + dDebug("node:%s, does not require startup", pWrapper->name); } else { - dDebug("node:%s, need to start", pWrapper->name); + dDebug("node:%s, needs to be started", pWrapper->name); } return required; } int32_t dndOpenNode(SMgmtWrapper *pWrapper) { - int32_t code = (*pWrapper->fp.openFp)(pWrapper); - if (code != 0) { - dError("node:%s, failed to open since %s", pWrapper->name, terrstr()); + if (taosMkDir(pWrapper->path) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr()); return -1; - } else { - dDebug("node:%s, has been opened", pWrapper->name); } + if ((*pWrapper->fp.openFp)(pWrapper) != 0) { + dError("node:%s, failed to open since %s", pWrapper->name, terrstr()); + return -1; + } + + dDebug("node:%s, has been opened", pWrapper->name); pWrapper->deployed = true; return 0; } @@ -70,54 +65,6 @@ void dndCloseNode(SMgmtWrapper *pWrapper) { dDebug("node:%s, has been closed", pWrapper->name); } -static int32_t dndRunInSingleProcess(SDnode *pDnode) { - dInfo("dnode run in single process mode"); - - for (ENodeType n = 0; n < NODE_MAX; ++n) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - pWrapper->required = dndRequireNode(pWrapper); - if (!pWrapper->required) continue; - SMsgCb msgCb = dndCreateMsgcb(pWrapper); - tmsgSetDefaultMsgCb(&msgCb); - - if (taosMkDir(pWrapper->path) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to create dir:%s since %s", pWrapper->path, terrstr()); - return -1; - } - - dInfo("node:%s, will start in single process", pWrapper->name); - pWrapper->procType = PROC_SINGLE; - if (dndOpenNode(pWrapper) != 0) { - dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); - return -1; - } - } - - dndSetStatus(pDnode, DND_STAT_RUNNING); - - for (ENodeType n = 0; n < NODE_MAX; ++n) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - if (!pWrapper->required) continue; - if (pWrapper->fp.startFp == NULL) continue; - if ((*pWrapper->fp.startFp)(pWrapper) != 0) { - dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); - return -1; - } - } - - return 0; -} - -static void dndClearNodesExecpt(SDnode *pDnode, ENodeType except) { - // dndCleanupServer(pDnode); - for (ENodeType n = 0; n < NODE_MAX; ++n) { - if (except == n) continue; - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - pWrapper->required = false; - } -} - static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, ProcFuncType ftype) { SRpcMsg *pRpc = &pMsg->rpcMsg; @@ -163,82 +110,57 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t taosMemoryFree(pMsg); } -static int32_t dndRunInMultiProcess(SDnode *pDnode) { - dInfo("dnode run in multi process mode"); +static int32_t dndNewProc(SMgmtWrapper *pWrapper, ENodeType n) { + char tstr[8] = {0}; + char *args[6] = {0}; + snprintf(tstr, sizeof(tstr), "%d", n); + args[1] = "-c"; + args[2] = configDir; + args[3] = "-n"; + args[4] = tstr; + args[5] = NULL; - for (ENodeType n = 0; n < NODE_MAX; ++n) { + int32_t pid = taosNewProc(args); + if (pid <= 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + dError("node:%s, failed to exec in new process since %s", pWrapper->name, terrstr()); + return -1; + } + + pWrapper->procId = pid; + dInfo("node:%s, continue running in new process:%d", pWrapper->name, pid); + return 0; +} + +static SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) { + SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)dndConsumeChildQueue, + .childMallocHeadFp = (ProcMallocFp)taosAllocateQitem, + .childFreeHeadFp = (ProcFreeFp)taosFreeQitem, + .childMallocBodyFp = (ProcMallocFp)rpcMallocCont, + .childFreeBodyFp = (ProcFreeFp)rpcFreeCont, + .parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue, + .parentMallocHeadFp = (ProcMallocFp)taosMemoryMalloc, + .parentFreeHeadFp = (ProcFreeFp)taosMemoryFree, + .parentMallocBodyFp = (ProcMallocFp)rpcMallocCont, + .parentFreeBodyFp = (ProcFreeFp)rpcFreeCont, + .shm = pWrapper->shm, + .pParent = pWrapper, + .name = pWrapper->name}; + return cfg; +} + +static int32_t dndRunInSingleProcess(SDnode *pDnode) { + dInfo("dnode run in single process"); + + for (ENodeType n = DNODE; n < NODE_MAX; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; pWrapper->required = dndRequireNode(pWrapper); if (!pWrapper->required) continue; - SMsgCb msgCb = dndCreateMsgcb(pWrapper); - tmsgSetDefaultMsgCb(&msgCb); - - if (taosMkDir(pWrapper->path) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to create dir:%s since %s", pWrapper->path, terrstr()); + if (dndOpenNode(pWrapper) != 0) { + dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } - - if (n == DNODE) { - dInfo("node:%s, will start in parent process", pWrapper->name); - pWrapper->procType = PROC_SINGLE; - if (dndOpenNode(pWrapper) != 0) { - dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); - return -1; - } - continue; - } - - SProcCfg cfg = {.childQueueSize = 1024 * 1024 * 2, // size will be a configuration item - .childConsumeFp = (ProcConsumeFp)dndConsumeChildQueue, - .childMallocHeadFp = (ProcMallocFp)taosAllocateQitem, - .childFreeHeadFp = (ProcFreeFp)taosFreeQitem, - .childMallocBodyFp = (ProcMallocFp)rpcMallocCont, - .childFreeBodyFp = (ProcFreeFp)rpcFreeCont, - .parentQueueSize = 1024 * 1024 * 2, // size will be a configuration item - .parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue, - .parentdMallocHeadFp = (ProcMallocFp)taosMemoryMalloc, - .parentFreeHeadFp = (ProcFreeFp)taosMemoryFree, - .parentMallocBodyFp = (ProcMallocFp)rpcMallocCont, - .parentFreeBodyFp = (ProcFreeFp)rpcFreeCont, - .pParent = pWrapper, - .name = pWrapper->name}; - SProcObj *pProc = taosProcInit(&cfg); - if (pProc == NULL) { - dError("node:%s, failed to fork since %s", pWrapper->name, terrstr()); - return -1; - } - - pWrapper->pProc = pProc; - - if (taosProcIsChild(pProc)) { - dInfo("node:%s, will start in child process", pWrapper->name); - pWrapper->procType = PROC_CHILD; - dndResetLog(pWrapper); - - dInfo("node:%s, clean up resources inherited from parent", pWrapper->name); - dndClearNodesExecpt(pDnode, n); - - dInfo("node:%s, will be initialized in child process", pWrapper->name); - if (dndOpenNode(pWrapper) != 0) { - dInfo("node:%s, failed to init in child process since %s", pWrapper->name, terrstr()); - return -1; - } - - if (taosProcRun(pProc) != 0) { - dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr()); - return -1; - } - break; - } else { - dInfo("node:%s, will not start in parent process, child pid:%d", pWrapper->name, taosProcChildId(pProc)); - pWrapper->procType = PROC_PARENT; - if (taosProcRun(pProc) != 0) { - dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr()); - return -1; - } - } } dndSetStatus(pDnode, DND_STAT_RUNNING); @@ -247,32 +169,14 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; if (!pWrapper->required) continue; if (pWrapper->fp.startFp == NULL) continue; - if (pWrapper->procType == PROC_PARENT && n != DNODE) continue; - if (pWrapper->procType == PROC_CHILD && n == DNODE) continue; if ((*pWrapper->fp.startFp)(pWrapper) != 0) { dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } } - return 0; -} - -int32_t dndRun(SDnode *pDnode) { - if (!tsMultiProcess) { - if (dndRunInSingleProcess(pDnode) != 0) { - dError("failed to run dnode in single process mode since %s", terrstr()); - return -1; - } - } else { - if (dndRunInMultiProcess(pDnode) != 0) { - dError("failed to run dnode in multi process mode since %s", terrstr()); - return -1; - } - } - + dInfo("TDengine initialized successfully"); dndReportStartup(pDnode, "TDengine", "initialized successfully"); - while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); @@ -283,3 +187,174 @@ int32_t dndRun(SDnode *pDnode) { return 0; } + +static int32_t dndRunInParentProcess(SDnode *pDnode) { + dInfo("dnode run in parent process"); + SMgmtWrapper *pDWrapper = &pDnode->wrappers[DNODE]; + if (dndOpenNode(pDWrapper) != 0) { + dError("node:%s, failed to start since %s", pDWrapper->name, terrstr()); + return -1; + } + + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + pWrapper->required = dndRequireNode(pWrapper); + if (!pWrapper->required) continue; + + int32_t shmsize = 1024 * 1024 * 2; // size will be a configuration item + if (taosCreateShm(&pWrapper->shm, shmsize) != 0) { + terrno = TAOS_SYSTEM_ERROR(terrno); + dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr()); + return -1; + } + dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->shm.id, shmsize); + + SProcCfg cfg = dndGenProcCfg(pWrapper); + cfg.isChild = false; + pWrapper->procType = PROC_PARENT; + pWrapper->pProc = taosProcInit(&cfg); + if (pWrapper->pProc == NULL) { + dError("node:%s, failed to create proc since %s", pWrapper->name, terrstr()); + return -1; + } + } + + if (dndWriteShmFile(pDnode) != 0) { + dError("failed to write runtime file since %s", terrstr()); + return -1; + } + + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + + if (pDnode->ntype == NODE_MAX) { + dInfo("node:%s, should be started manually", pWrapper->name); + } else { + if (dndNewProc(pWrapper, n) != 0) { + return -1; + } + } + + if (taosProcRun(pWrapper->pProc) != 0) { + dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr()); + return -1; + } + } + + dndSetStatus(pDnode, DND_STAT_RUNNING); + + if ((*pDWrapper->fp.startFp)(pDWrapper) != 0) { + dError("node:%s, failed to start since %s", pDWrapper->name, terrstr()); + return -1; + } + + dInfo("TDengine initialized successfully"); + dndReportStartup(pDnode, "TDengine", "initialized successfully"); + + while (1) { + if (pDnode->event == DND_EVENT_STOP) { + dInfo("dnode is about to stop"); + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; + + if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { + dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId); + taosKillProc(pWrapper->procId); + } + } + + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; + + if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { + dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId); + taosWaitProc(pWrapper->procId); + dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId); + } + } + break; + } else { + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; + + if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) { + dInfo("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId); + dndNewProc(pWrapper, n); + } + } + } + + taosMsleep(100); + } + + return 0; +} + +static int32_t dndRunInChildProcess(SDnode *pDnode) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; + dInfo("%s run in child process", pWrapper->name); + + pWrapper->required = dndRequireNode(pWrapper); + if (!pWrapper->required) { + dError("%s does not require startup", pWrapper->name); + return -1; + } + + SMsgCb msgCb = dndCreateMsgcb(pWrapper); + tmsgSetDefaultMsgCb(&msgCb); + pWrapper->procType = PROC_CHILD; + + if (dndOpenNode(pWrapper) != 0) { + dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); + return -1; + } + + SProcCfg cfg = dndGenProcCfg(pWrapper); + cfg.isChild = true; + pWrapper->pProc = taosProcInit(&cfg); + if (pWrapper->pProc == NULL) { + dError("node:%s, failed to create proc since %s", pWrapper->name, terrstr()); + return -1; + } + + if (pWrapper->fp.startFp != NULL) { + if ((*pWrapper->fp.startFp)(pWrapper) != 0) { + dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); + return -1; + } + } + + if (taosProcRun(pWrapper->pProc) != 0) { + dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr()); + return -1; + } + + dInfo("TDengine initialized successfully"); + dndReportStartup(pDnode, "TDengine", "initialized successfully"); + while (1) { + if (pDnode->event == DND_EVENT_STOP) { + dInfo("dnode is about to stop"); + break; + } + taosMsleep(100); + } +} + +int32_t dndRun(SDnode *pDnode) { + if (!tsMultiProcess) { + return dndRunInSingleProcess(pDnode); + } else if (pDnode->ntype == DNODE || pDnode->ntype == NODE_MAX) { + return dndRunInParentProcess(pDnode); + } else { + return dndRunInChildProcess(pDnode); + } + + return 0; +} diff --git a/source/dnode/mgmt/main/src/dndFile.c b/source/dnode/mgmt/main/src/dndFile.c index 51d4ff3902..92e6cea3e1 100644 --- a/source/dnode/mgmt/main/src/dndFile.c +++ b/source/dnode/mgmt/main/src/dndFile.c @@ -117,7 +117,30 @@ _OVER: return code; } -int32_t dndOpenRuntimeFile(SDnode *pDnode) { +TdFilePtr dndCheckRunning(const char *dataDir) { + char filepath[PATH_MAX] = {0}; + snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP); + + TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + dError("failed to lock file:%s since %s", filepath, terrstr()); + return NULL; + } + + int32_t ret = taosLockFile(pFile); + if (ret != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + dError("failed to lock file:%s since %s", filepath, terrstr()); + taosCloseFile(&pFile); + return NULL; + } + + dDebug("file:%s is locked", filepath); + return pFile; +} + +int32_t dndReadShmFile(SDnode *pDnode) { int32_t code = -1; char itemName[24] = {0}; char content[MAXLEN + 1] = {0}; @@ -125,17 +148,11 @@ int32_t dndOpenRuntimeFile(SDnode *pDnode) { cJSON *root = NULL; TdFilePtr pFile = NULL; - snprintf(file, sizeof(file), "%s%s.running", pDnode->dataDir, TD_DIRSEP); - pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); + snprintf(file, sizeof(file), "%s%s.shmfile", pDnode->dataDir, TD_DIRSEP); + pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to open file:%s since %s", file, terrstr()); - goto _OVER; - } - - if (taosLockFile(pFile) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to lock file:%s since %s", file, terrstr()); + dDebug("file %s not exist", file); + code = 0; goto _OVER; } @@ -162,10 +179,10 @@ int32_t dndOpenRuntimeFile(SDnode *pDnode) { } } - if (tsMultiProcess || pDnode->ntype == DNODE) { + if (!tsMultiProcess || pDnode->ntype == DNODE || pDnode->ntype == NODE_MAX) { for (ENodeType ntype = DNODE; ntype < NODE_MAX; ++ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; - if (pWrapper->shm.id > 0) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; + if (pWrapper->shm.id >= 0) { dDebug("shmid:%d, is closed, size:%d", pWrapper->shm.id, pWrapper->shm.size); taosDropShm(&pWrapper->shm); } @@ -174,27 +191,23 @@ int32_t dndOpenRuntimeFile(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; if (taosAttachShm(&pWrapper->shm) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); - dError("shmid:%d, failed to attach since %s", pWrapper->shm.id, terrstr()); + dError("shmid:%d, failed to attach shm since %s", pWrapper->shm.id, terrstr()); goto _OVER; } - dDebug("shmid:%d, is attached, size:%d", pWrapper->shm.id, pWrapper->shm.size); + dInfo("node:%s, shmid:%d is attached, size:%d", pWrapper->name, pWrapper->shm.id, pWrapper->shm.size); } - dDebug("successed to open %s", file); + dDebug("successed to load %s", file); code = 0; _OVER: if (root != NULL) cJSON_Delete(root); - if (code != 0) { - if (pFile != NULL) taosCloseFile(&pFile); - } else { - pDnode->runtimeFile = pFile; - } + if (pFile != NULL) taosCloseFile(&pFile); return code; } -int32_t dndWriteRuntimeFile(SDnode *pDnode) { +int32_t dndWriteShmFile(SDnode *pDnode) { int32_t code = -1; int32_t len = 0; char content[MAXLEN + 1] = {0}; @@ -202,8 +215,8 @@ int32_t dndWriteRuntimeFile(SDnode *pDnode) { char realfile[PATH_MAX] = {0}; TdFilePtr pFile = NULL; - snprintf(file, sizeof(file), "%s%s.running.bak", pDnode->dataDir, TD_DIRSEP); - snprintf(realfile, sizeof(realfile), "%s%s.running", pDnode->dataDir, TD_DIRSEP); + snprintf(file, sizeof(file), "%s%s.shmfile.bak", pDnode->dataDir, TD_DIRSEP); + snprintf(realfile, sizeof(realfile), "%s%s.shmfile", pDnode->dataDir, TD_DIRSEP); pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { @@ -214,12 +227,12 @@ int32_t dndWriteRuntimeFile(SDnode *pDnode) { len += snprintf(content + len, MAXLEN - len, "{\n"); for (ENodeType ntype = DNODE + 1; ntype < NODE_MAX; ++ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; - len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\": %d,\n", dndNodeProcStr(ntype), pWrapper->shm.id); + SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; + len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndNodeProcStr(ntype), pWrapper->shm.id); if (ntype == NODE_MAX - 1) { - len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\": %d\n", dndNodeProcStr(ntype), pWrapper->shm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndNodeProcStr(ntype), pWrapper->shm.size); } else { - len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\": %d,\n", dndNodeProcStr(ntype), pWrapper->shm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndNodeProcStr(ntype), pWrapper->shm.size); } } len += snprintf(content + len, MAXLEN - len, "}\n"); @@ -244,7 +257,7 @@ int32_t dndWriteRuntimeFile(SDnode *pDnode) { return -1; } - dDebug("successed to write %s", realfile); + dInfo("successed to write %s", realfile); code = 0; _OVER: @@ -254,11 +267,3 @@ _OVER: return code; } - -void dndCloseRuntimeFile(SDnode *pDnode) { - if (pDnode->runtimeFile) { - taosUnLockFile(pDnode->runtimeFile); - taosCloseFile(&pDnode->runtimeFile); - pDnode->runtimeFile = NULL; - } -} \ No newline at end of file diff --git a/source/dnode/mgmt/main/src/dndInt.c b/source/dnode/mgmt/main/src/dndInt.c index 7dde3561fb..602ebc6b3c 100644 --- a/source/dnode/mgmt/main/src/dndInt.c +++ b/source/dnode/mgmt/main/src/dndInt.c @@ -15,82 +15,186 @@ #define _DEFAULT_SOURCE #include "dndInt.h" -#include "wal.h" -static int8_t once = DND_ENV_INIT; +static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { + pDnode->numOfSupportVnodes = pOption->numOfSupportVnodes; + pDnode->serverPort = pOption->serverPort; + pDnode->dataDir = strdup(pOption->dataDir); + pDnode->localEp = strdup(pOption->localEp); + pDnode->localFqdn = strdup(pOption->localFqdn); + pDnode->firstEp = strdup(pOption->firstEp); + pDnode->secondEp = strdup(pOption->secondEp); + pDnode->disks = pOption->disks; + pDnode->numOfDisks = pOption->numOfDisks; + pDnode->ntype = pOption->ntype; + pDnode->rebootTime = taosGetTimestampMs(); -int32_t dndInit() { - dDebug("start to init dnode env"); - if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) { - terrno = TSDB_CODE_REPEAT_INIT; - dError("failed to init dnode env since %s", terrstr()); + if (pDnode->dataDir == NULL || pDnode->localEp == NULL || pDnode->localFqdn == NULL || pDnode->firstEp == NULL || + pDnode->secondEp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - taosIgnSIGPIPE(); - taosBlockSIGPIPE(); - taosResolveCRC(); - - SMonCfg monCfg = {0}; - monCfg.maxLogs = tsMonitorMaxLogs; - monCfg.port = tsMonitorPort; - monCfg.server = tsMonitorFqdn; - monCfg.comp = tsMonitorComp; - if (monInit(&monCfg) != 0) { - dError("failed to init monitor since %s", terrstr()); - return -1; + if (!tsMultiProcess || pDnode->ntype == DNODE || pDnode->ntype == NODE_MAX) { + pDnode->lockfile = dndCheckRunning(pDnode->dataDir); + if (pDnode->lockfile == NULL) { + return -1; + } } - dDebug("dnode env is initialized"); return 0; } -void dndCleanup() { - dDebug("start to cleanup dnode env"); - if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) { - dError("dnode env is already cleaned up"); +static void dndClearVars(SDnode *pDnode) { + for (ENodeType n = 0; n < NODE_MAX; ++n) { + SMgmtWrapper *pMgmt = &pDnode->wrappers[n]; + taosMemoryFreeClear(pMgmt->path); + } + if (pDnode->lockfile != NULL) { + taosUnLockFile(pDnode->lockfile); + taosCloseFile(&pDnode->lockfile); + pDnode->lockfile = NULL; + } + taosMemoryFreeClear(pDnode->localEp); + taosMemoryFreeClear(pDnode->localFqdn); + taosMemoryFreeClear(pDnode->firstEp); + taosMemoryFreeClear(pDnode->secondEp); + taosMemoryFreeClear(pDnode->dataDir); + taosMemoryFree(pDnode); + dDebug("dnode memory is cleared, data:%p", pDnode); +} + +SDnode *dndCreate(const SDnodeOpt *pOption) { + dDebug("start to create dnode object"); + int32_t code = -1; + char path[PATH_MAX] = {0}; + SDnode *pDnode = NULL; + + pDnode = taosMemoryCalloc(1, sizeof(SDnode)); + if (pDnode == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + if (dndInitVars(pDnode, pOption) != 0) { + dError("failed to init variables since %s", terrstr()); + goto _OVER; + } + + dndSetStatus(pDnode, DND_STAT_INIT); + dmGetMgmtFp(&pDnode->wrappers[DNODE]); + mmGetMgmtFp(&pDnode->wrappers[MNODE]); + vmGetMgmtFp(&pDnode->wrappers[VNODES]); + qmGetMgmtFp(&pDnode->wrappers[QNODE]); + smGetMgmtFp(&pDnode->wrappers[SNODE]); + bmGetMgmtFp(&pDnode->wrappers[BNODE]); + + for (ENodeType n = 0; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + snprintf(path, sizeof(path), "%s%s%s", pDnode->dataDir, TD_DIRSEP, pWrapper->name); + pWrapper->path = strdup(path); + pWrapper->shm.id = -1; + pWrapper->pDnode = pDnode; + if (pWrapper->path == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + pWrapper->procType = PROC_SINGLE; + taosInitRWLatch(&pWrapper->latch); + } + + if (dndInitMsgHandle(pDnode) != 0) { + dError("failed to msg handles since %s", terrstr()); + goto _OVER; + } + + if (dndReadShmFile(pDnode) != 0) { + dError("failed to read shm file since %s", terrstr()); + goto _OVER; + } + + SMsgCb msgCb = dndCreateMsgcb(&pDnode->wrappers[0]); + tmsgSetDefaultMsgCb(&msgCb); + + dInfo("dnode is created, data:%p", pDnode); + code = 0; + +_OVER: + if (code != 0 && pDnode) { + dndClearVars(pDnode); + pDnode = NULL; + dError("failed to create dnode since %s", terrstr()); + } + + return pDnode; +} + +void dndClose(SDnode *pDnode) { + if (pDnode == NULL) return; + + if (dndGetStatus(pDnode) == DND_STAT_STOPPED) { + dError("dnode is shutting down, data:%p", pDnode); return; } - monCleanup(); - walCleanUp(); - taosStopCacheRefreshWorker(); - dDebug("dnode env is cleaned up"); + dInfo("start to close dnode, data:%p", pDnode); + dndSetStatus(pDnode, DND_STAT_STOPPED); + + for (ENodeType n = 0; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + dndCloseNode(pWrapper); + } + + dndClearVars(pDnode); + dInfo("dnode is closed, data:%p", pDnode); } -void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) { - pWrapper->msgFps[TMSG_INDEX(msgType)] = nodeMsgFp; - pWrapper->msgVgIds[TMSG_INDEX(msgType)] = vgId; -} - -EDndStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; } - -void dndSetStatus(SDnode *pDnode, EDndStatus status) { - if (pDnode->status != status) { - dDebug("dnode status set from %s to %s", dndStatStr(pDnode->status), dndStatStr(status)); - pDnode->status = status; +void dndHandleEvent(SDnode *pDnode, EDndEvent event) { + dInfo("dnode receive %s event, data:%p", dndEventStr(event), pDnode); + if (event == DND_EVENT_STOP) { + pDnode->event = event; } } -void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { - SStartupReq *pStartup = &pDnode->startup; - tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN); - tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN); - pStartup->finished = 0; +SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType ntype) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; + SMgmtWrapper *pRetWrapper = pWrapper; + + taosRLockLatch(&pWrapper->latch); + if (pWrapper->deployed) { + int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); + dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); + } else { + terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + pRetWrapper = NULL; + } + taosRUnLockLatch(&pWrapper->latch); + + return pRetWrapper; } -void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) { - memcpy(pStartup, &pDnode->startup, sizeof(SStartupReq)); - pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING); +int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { + int32_t code = 0; + + taosRLockLatch(&pWrapper->latch); + if (pWrapper->deployed || (pWrapper->procType == PROC_PARENT && pWrapper->required)) { + int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); + dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); + } else { + terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + code = -1; + } + taosRUnLockLatch(&pWrapper->latch); + + return code; } -void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { - dDebug("startup req is received"); - SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq)); - dndGetStartup(pDnode, pStartup); +void dndReleaseWrapper(SMgmtWrapper *pWrapper) { + if (pWrapper == NULL) return; - dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished); - SRpcMsg rpcRsp = { - .handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq), .ahandle = pReq->ahandle}; - rpcSendResponse(&rpcRsp); -} + taosRLockLatch(&pWrapper->latch); + int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1); + taosRUnLockLatch(&pWrapper->latch); + dTrace("node:%s, is released, refCount:%d", pWrapper->name, refCount); +} \ No newline at end of file diff --git a/source/dnode/mgmt/main/src/dndMsg.c b/source/dnode/mgmt/main/src/dndMsg.c index 3aafa5a5e3..2ab1e401c7 100644 --- a/source/dnode/mgmt/main/src/dndMsg.c +++ b/source/dnode/mgmt/main/src/dndMsg.c @@ -66,7 +66,7 @@ void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) { dTrace("msg:%p, is created, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle, pMsg->user); code = (*msgFp)(pWrapper, pMsg); } else if (pWrapper->procType == PROC_PARENT) { - dTrace("msg:%p, is created and will put into child queue, handle:%p app:%p user:%s", pMsg, pRpc->handle, + dTrace("msg:%p, is created and put into child queue, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle, pMsg->user); code = taosProcPutToChildQ(pWrapper->pProc, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen, PROC_REQ); } else { diff --git a/source/dnode/mgmt/main/src/dndObj.c b/source/dnode/mgmt/main/src/dndObj.c deleted file mode 100644 index 99dc782a9b..0000000000 --- a/source/dnode/mgmt/main/src/dndObj.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 . - */ - -#define _DEFAULT_SOURCE -#include "dndInt.h" - -static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { - pDnode->numOfSupportVnodes = pOption->numOfSupportVnodes; - pDnode->serverPort = pOption->serverPort; - pDnode->dataDir = strdup(pOption->dataDir); - pDnode->localEp = strdup(pOption->localEp); - pDnode->localFqdn = strdup(pOption->localFqdn); - pDnode->firstEp = strdup(pOption->firstEp); - pDnode->secondEp = strdup(pOption->secondEp); - pDnode->disks = pOption->disks; - pDnode->numOfDisks = pOption->numOfDisks; - pDnode->ntype = pOption->ntype; - pDnode->rebootTime = taosGetTimestampMs(); - - if (pDnode->dataDir == NULL || pDnode->localEp == NULL || pDnode->localFqdn == NULL || pDnode->firstEp == NULL || - pDnode->secondEp == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - return 0; -} - -static void dndClearVars(SDnode *pDnode) { - for (ENodeType n = 0; n < NODE_MAX; ++n) { - SMgmtWrapper *pMgmt = &pDnode->wrappers[n]; - taosMemoryFreeClear(pMgmt->path); - } - dndCloseRuntimeFile(pDnode); - taosMemoryFreeClear(pDnode->localEp); - taosMemoryFreeClear(pDnode->localFqdn); - taosMemoryFreeClear(pDnode->firstEp); - taosMemoryFreeClear(pDnode->secondEp); - taosMemoryFreeClear(pDnode->dataDir); - taosMemoryFree(pDnode); - dDebug("dnode object memory is cleared, data:%p", pDnode); -} - -SDnode *dndCreate(const SDnodeOpt *pOption) { - dInfo("start to create dnode object"); - int32_t code = -1; - char path[PATH_MAX] = {0}; - SDnode *pDnode = NULL; - - pDnode = taosMemoryCalloc(1, sizeof(SDnode)); - if (pDnode == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _OVER; - } - - if (dndInitVars(pDnode, pOption) != 0) { - dError("failed to init variables since %s", terrstr()); - goto _OVER; - } - - dndSetStatus(pDnode, DND_STAT_INIT); - dmGetMgmtFp(&pDnode->wrappers[DNODE]); - mmGetMgmtFp(&pDnode->wrappers[MNODE]); - vmGetMgmtFp(&pDnode->wrappers[VNODES]); - qmGetMgmtFp(&pDnode->wrappers[QNODE]); - smGetMgmtFp(&pDnode->wrappers[SNODE]); - bmGetMgmtFp(&pDnode->wrappers[BNODE]); - - if (dndOpenRuntimeFile(pDnode) != 0) { - dError("failed to open runtime file since %s", terrstr()); - goto _OVER; - } - - if (dndInitServer(pDnode) != 0) { - dError("failed to init trans server since %s", terrstr()); - goto _OVER; - } - - if (dndInitClient(pDnode) != 0) { - dError("failed to init trans client since %s", terrstr()); - goto _OVER; - } - - if (dndInitMsgHandle(pDnode) != 0) { - goto _OVER; - } - - for (ENodeType n = 0; n < NODE_MAX; ++n) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - snprintf(path, sizeof(path), "%s%s%s", pDnode->dataDir, TD_DIRSEP, pWrapper->name); - pWrapper->path = strdup(path); - pWrapper->pDnode = pDnode; - if (pWrapper->path == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _OVER; - } - - pWrapper->procType = PROC_SINGLE; - taosInitRWLatch(&pWrapper->latch); - } - - code = 0; - -_OVER: - if (code != 0 && pDnode) { - dndClearVars(pDnode); - pDnode = NULL; - dError("failed to create dnode object since %s", terrstr()); - } else { - dInfo("dnode object is created, data:%p", pDnode); - } - - return pDnode; -} - -void dndClose(SDnode *pDnode) { - if (pDnode == NULL) return; - - if (dndGetStatus(pDnode) == DND_STAT_STOPPED) { - dError("dnode is shutting down, data:%p", pDnode); - return; - } - - dInfo("start to close dnode, data:%p", pDnode); - dndSetStatus(pDnode, DND_STAT_STOPPED); - - dndCleanupServer(pDnode); - dndCleanupClient(pDnode); - - for (ENodeType n = 0; n < NODE_MAX; ++n) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - dndCloseNode(pWrapper); - } - - dndClearVars(pDnode); - dInfo("dnode object is closed, data:%p", pDnode); -} - -void dndHandleEvent(SDnode *pDnode, EDndEvent event) { - dInfo("dnode object receive event %d, data:%p", event, pDnode); - pDnode->event = event; -} - -SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - SMgmtWrapper *pRetWrapper = pWrapper; - - taosRLockLatch(&pWrapper->latch); - if (pWrapper->deployed) { - int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); - dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); - } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; - pRetWrapper = NULL; - } - taosRUnLockLatch(&pWrapper->latch); - - return pRetWrapper; -} - -int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { - int32_t code = 0; - - taosRLockLatch(&pWrapper->latch); - if (pWrapper->deployed || (pWrapper->procType == PROC_PARENT && pWrapper->required)) { - int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); - dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); - } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; - code = -1; - } - taosRUnLockLatch(&pWrapper->latch); - - return code; -} - -void dndReleaseWrapper(SMgmtWrapper *pWrapper) { - if (pWrapper == NULL) return; - - taosRLockLatch(&pWrapper->latch); - int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1); - taosRUnLockLatch(&pWrapper->latch); - dTrace("node:%s, is released, refCount:%d", pWrapper->name, refCount); -} \ No newline at end of file diff --git a/source/dnode/mgmt/main/src/dndStr.c b/source/dnode/mgmt/main/src/dndStr.c index 00d8b0d6e0..8a5af68b4f 100644 --- a/source/dnode/mgmt/main/src/dndStr.c +++ b/source/dnode/mgmt/main/src/dndStr.c @@ -62,3 +62,16 @@ const char *dndNodeProcStr(ENodeType ntype) { return "taosd"; } } + +const char *dndEventStr(EDndEvent ev) { + switch (ev) { + case DND_EVENT_START: + return "start"; + case DND_EVENT_STOP: + return "stop"; + case DND_EVENT_CHILD: + return "child"; + default: + return "UNKNOWN"; + } +} \ No newline at end of file diff --git a/source/dnode/mgmt/vm/src/vmWorker.c b/source/dnode/mgmt/vm/src/vmWorker.c index 9d62624756..4be6311cf8 100644 --- a/source/dnode/mgmt/vm/src/vmWorker.c +++ b/source/dnode/mgmt/vm/src/vmWorker.c @@ -187,7 +187,7 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) { dError("vgId:%d, failed to write msg:%p to vnode-queue since %s", pHead->vgId, pMsg, terrstr()); - return -1; + return terrno; } int32_t code = 0; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 6976d83abd..7891c690e3 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -735,6 +735,9 @@ typedef struct { int8_t createdBy; // STREAM_CREATED_BY__USER or SMA int32_t fixedSinkVgId; // 0 for shuffle int64_t smaId; // 0 for unused + int8_t trigger; + int32_t triggerParam; + int64_t waterMark; char* sql; char* logicalPlan; char* physicalPlan; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index bd66bdeae9..462f0eb85a 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1309,7 +1309,7 @@ static int32_t mndGetDbMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMet cols++; pShow->bytes[cols] = 2; - pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; + pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "days"); pSchema[cols].bytes = pShow->bytes[cols]; cols++; @@ -1444,7 +1444,7 @@ static void dumpDbInfoToPayload(char *data, SDbObj *pDb, SShowObj *pShow, int32_ cols++; pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); - *(int16_t *)pWrite = pDb->cfg.daysPerFile; + *(int32_t *)pWrite = pDb->cfg.daysPerFile; cols++; pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index ce08dfaaa3..92b854157b 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -53,7 +53,7 @@ static const SInfosTableSchema userDBSchema[] = { {.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, {.name = "quorum", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, - {.name = "days", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, + {.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, @@ -89,7 +89,6 @@ static const SInfosTableSchema userStbsSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT}, }; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index dff918f135..5c3167dd79 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -310,6 +310,8 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { mError("failed to process show-retrieve req:%p since %s", pShow, terrstr()); return -1; } + + pShow->numOfReads = 0; } ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type]; @@ -374,7 +376,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { pReq->pRsp = pRsp; pReq->rspLen = size; - if (rowsRead == 0 || rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) { + if (rowsRead == 0 || rowsToRead == 0 || (rowsRead < rowsToRead)) { pRsp->completed = 1; mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id); mndReleaseShowObj((SShowObj*) pShow, true); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 7799ac7562..196767462e 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1608,7 +1608,6 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32 SStbObj *pStb = NULL; int32_t cols = 0; char *pWrite; - char prefix[TSDB_DB_FNAME_LEN] = {0}; SDbObj* pDb = NULL; if (strlen(pShow->db) > 0) { @@ -1653,10 +1652,6 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32 *(int32_t *)pWrite = pStb->numOfTags; cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = 0; // number of tables - cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int64_t *)pWrite = pStb->updateTime; // number of tables cols++; diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index 85f6a86183..4b0e33a323 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -42,10 +42,10 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 73eefd875d..5d603ab5b2 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -35,10 +35,10 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 61b99beeb7..97a144fdee 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -324,10 +324,10 @@ TEST_F(MndTestUser, 03_Alter_User) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/dnode/vnode/src/inc/tsdbCommit.h b/source/dnode/vnode/src/inc/tsdbCommit.h index 699aeaa133..2c6dd75e03 100644 --- a/source/dnode/vnode/src/inc/tsdbCommit.h +++ b/source/dnode/vnode/src/inc/tsdbCommit.h @@ -74,4 +74,4 @@ int tsdbApplyRtn(STsdbRepo *pRepo); } #endif -#endif /* _TD_TSDB_COMMIT_H_ */ \ No newline at end of file +#endif /* _TD_TSDB_COMMIT_H_ */ diff --git a/source/dnode/vnode/src/inc/tsdbDef.h b/source/dnode/vnode/src/inc/tsdbDef.h index 02aba95517..3e42cb627a 100644 --- a/source/dnode/vnode/src/inc/tsdbDef.h +++ b/source/dnode/vnode/src/inc/tsdbDef.h @@ -79,4 +79,4 @@ static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STable *pTable, bool lock, } #endif -#endif /*_TD_TSDB_DEF_H_*/ \ No newline at end of file +#endif /*_TD_TSDB_DEF_H_*/ diff --git a/source/dnode/vnode/src/inc/tsdbSma.h b/source/dnode/vnode/src/inc/tsdbSma.h index ffb9869914..da0a6856ab 100644 --- a/source/dnode/vnode/src/inc/tsdbSma.h +++ b/source/dnode/vnode/src/inc/tsdbSma.h @@ -51,7 +51,7 @@ static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void return len; } -static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) { +static FORCE_INLINE int32_t tsdbRLockSma(SSmaEnv *pEnv) { int code = taosThreadRwlockRdlock(&(pEnv->lock)); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(code); @@ -60,7 +60,7 @@ static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) { return 0; } -static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) { +static FORCE_INLINE int32_t tsdbWLockSma(SSmaEnv *pEnv) { int code = taosThreadRwlockWrlock(&(pEnv->lock)); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(code); @@ -69,7 +69,7 @@ static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) { return 0; } -static FORCE_INLINE int tsdbUnLockSma(SSmaEnv *pEnv) { +static FORCE_INLINE int32_t tsdbUnLockSma(SSmaEnv *pEnv) { int code = taosThreadRwlockUnlock(&(pEnv->lock)); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(code); diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index e5d1f952a8..aa4a9fc1de 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -194,7 +194,7 @@ void tqClose(STQ*); int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version); int tqCommit(STQ*); -int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg); +int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId); int32_t tqProcessSetConnReq(STQ* pTq, char* msg); int32_t tqProcessRebReq(STQ* pTq, char* msg); int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen, int32_t workerId); diff --git a/source/dnode/vnode/src/meta/metaTbUid.c b/source/dnode/vnode/src/meta/metaTbUid.c index cad1eba134..1f57d1396a 100644 --- a/source/dnode/vnode/src/meta/metaTbUid.c +++ b/source/dnode/vnode/src/meta/metaTbUid.c @@ -27,5 +27,5 @@ void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */ tb_uid_t metaGenerateUid(SMeta *pMeta) { // Generate a new table UID - return ++(pMeta->uidGnrt.nextUid); + return tGenIdPI32(); } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 06a2350aab..82300f82cb 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -250,7 +250,7 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu return 0; } -int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { +int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { SMqPollReq* pReq = pMsg->pCont; int64_t consumerId = pReq->consumerId; int64_t fetchOffset; @@ -264,6 +264,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { fetchOffset = pReq->currentOffset + 1; } + /*printf("tmq poll vg %d req %ld %ld\n", pTq->pVnode->vgId, pReq->currentOffset, fetchOffset);*/ + SMqPollRsp rsp = { /*.consumerId = consumerId,*/ .numOfTopics = 0, @@ -288,62 +290,77 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { rsp.reqOffset = pReq->currentOffset; rsp.skipLogNum = 0; - SWalHead* pHead; while (1) { /*if (fetchOffset > walGetLastVer(pTq->pWal) || walReadWithHandle(pTopic->pReadhandle, fetchOffset) < 0) {*/ - if (walReadWithHandle(pTopic->pReadhandle, fetchOffset) < 0) { + SWalReadHead* pHead; + if (walReadWithHandle_s(pTopic->pReadhandle, fetchOffset, &pHead) < 0) { // TODO: no more log, set timer to wait blocking time // if data inserted during waiting, launch query and // response to user break; } - int8_t pos = fetchOffset % TQ_BUFFER_SIZE; - pHead = pTopic->pReadhandle->pHead; - if (pHead->head.msgType == TDMT_VND_SUBMIT) { - SSubmitReq* pCont = (SSubmitReq*)&pHead->head.body; - qTaskInfo_t task = pTopic->buffer.output[pos].task; + /*printf("vg %d offset %ld msgType %d from epoch %d\n", pTq->pVnode->vgId, fetchOffset, pHead->msgType, + * pReq->epoch);*/ + /*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/ + /*pHead = pTopic->pReadhandle->pHead;*/ + if (pHead->msgType == TDMT_VND_SUBMIT) { + SSubmitReq* pCont = (SSubmitReq*)&pHead->body; + /*printf("from topic %s from consumer\n", pTopic->topicName, consumerId);*/ + qTaskInfo_t task = pTopic->buffer.output[workerId].task; + ASSERT(task); qSetStreamInput(task, pCont, STREAM_DATA_TYPE_SUBMIT_BLOCK); SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); while (1) { - SSDataBlock* pDataBlock; + SSDataBlock* pDataBlock = NULL; uint64_t ts; if (qExecTask(task, &pDataBlock, &ts) < 0) { ASSERT(false); } if (pDataBlock == NULL) { - fetchOffset++; - pos = fetchOffset % TQ_BUFFER_SIZE; - rsp.skipLogNum++; + /*pos = fetchOffset % TQ_BUFFER_SIZE;*/ break; } taosArrayPush(pRes, pDataBlock); - rsp.schema = pTopic->buffer.output[pos].pReadHandle->pSchemaWrapper; - rsp.rspOffset = fetchOffset; - - rsp.numOfTopics = 1; - rsp.pBlockData = pRes; - - int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqPollRsp(NULL, &rsp); - void* buf = rpcMallocCont(tlen); - if (buf == NULL) { - pMsg->code = -1; - return -1; - } - ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_RSP; - ((SMqRspHead*)buf)->epoch = pReq->epoch; - ((SMqRspHead*)buf)->consumerId = consumerId; - - void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - tEncodeSMqPollRsp(&abuf, &rsp); - /*taosArrayDestroyEx(rsp.pBlockData, (void (*)(void*))tDeleteSSDataBlock);*/ - pMsg->pCont = buf; - pMsg->contLen = tlen; - pMsg->code = 0; - tmsgSendRsp(pMsg); - return 0; } + + if (taosArrayGetSize(pRes) == 0) { + fetchOffset++; + rsp.skipLogNum++; + taosArrayDestroy(pRes); + continue; + } + rsp.schema = pTopic->buffer.output[workerId].pReadHandle->pSchemaWrapper; + rsp.rspOffset = fetchOffset; + + rsp.numOfTopics = 1; + rsp.pBlockData = pRes; + + int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqPollRsp(NULL, &rsp); + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + pMsg->code = -1; + taosMemoryFree(pHead); + return -1; + } + ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_RSP; + ((SMqRspHead*)buf)->epoch = pReq->epoch; + ((SMqRspHead*)buf)->consumerId = consumerId; + + void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + tEncodeSMqPollRsp(&abuf, &rsp); + /*taosArrayDestroyEx(rsp.pBlockData, (void (*)(void*))tDeleteSSDataBlock);*/ + pMsg->pCont = buf; + pMsg->contLen = tlen; + pMsg->code = 0; + /*printf("vg %d offset %ld msgType %d from epoch %d actual rsp\n", pTq->pVnode->vgId, fetchOffset, + * pHead->msgType,*/ + /*pReq->epoch);*/ + tmsgSendRsp(pMsg); + taosMemoryFree(pHead); + return 0; } else { + taosMemoryFree(pHead); fetchOffset++; rsp.skipLogNum++; } @@ -368,6 +385,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { pMsg->contLen = tlen; pMsg->code = 0; tmsgSendRsp(pMsg); + /*printf("vg %d offset %ld from epoch %d not rsp\n", pTq->pVnode->vgId, fetchOffset, pReq->epoch);*/ /*}*/ return 0; @@ -432,7 +450,9 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { }; pTopic->buffer.output[i].pReadHandle = pReadHandle; pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle); + ASSERT(pTopic->buffer.output[i].task); } + printf("set topic %s to consumer %ld\n", pTopic->topicName, req.consumerId); taosArrayPush(pConsumer->topics, pTopic); tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer); tqHandleCommit(pTq->tqMeta, req.consumerId); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 9c0b0802ab..61538055f2 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -167,7 +167,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) { if (!tdSTSRowIterNext(&iter, pColData->info.colId, pColData->info.type, &sVal)) { break; } - if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) { + if (colDataAppend(pColData, curRow, sVal.val, false) < 0) { + /*if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {*/ taosArrayDestroyEx(pArray, (void (*)(void*))tDeleteSSDataBlock); return NULL; } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 3e0b03f331..d5e9b55a71 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -1394,7 +1394,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF tsdbDebug("vgId:%d uid:%" PRId64 " a block of data is written to file %s, offset %" PRId64 " numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64, - REPO_ID(pRepo), TABLE_TID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len, + REPO_ID(pRepo), TABLE_UID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len, pBlock->numOfCols, pBlock->keyFirst, pBlock->keyLast); return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index bac5255d17..cae6d5ec1a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -4068,4 +4068,4 @@ void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *re //apply the hierarchical filter expression to every node in skiplist to find the qualified nodes applyFilterToSkipListNode(pSkipList, pExpr, result, param); } -#endif \ No newline at end of file +#endif diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 91b4e83dd0..f04f4791b5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -651,9 +651,8 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { */ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen) { SDBFile *pDBFile = &pSmaH->dFile; - tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d", - REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); + printf("\nvgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 "\n", + REPO_ID(pSmaH->pTsdb), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen); // TODO: insert sma data blocks into B+Tree(TDB) if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) { @@ -874,7 +873,6 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char // key: skey + groupId char smaKey[SMA_KEY_LEN] = {0}; - void *pSmaKey = &smaKey; char dataBuf[512] = {0}; void *pDataBuf = &dataBuf; int32_t sz = taosArrayGetSize(pDataBlocks); @@ -887,6 +885,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char for (int32_t j = 0; j < rows; ++j) { printf("|"); TSKEY skey = TSKEY_INITIAL_VAL; // the start key of TS window by interval + void *pSmaKey = &smaKey; int32_t tlen = 0; for (int32_t k = 0; k < colNum; ++k) { SColumnInfoData *pColInfoData = *(SColumnInfoData **)taosArrayGet(pDataBlock->pDataBlock, k); @@ -894,7 +893,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char switch (pColInfoData->info.type) { case TSDB_DATA_TYPE_TIMESTAMP: skey = *(TSKEY *)var; - printf(" skey = %" PRIi64 " groupId = %" PRId64 "|", skey, groupId); + printf("==> skey = %" PRIi64 " groupId = %" PRId64 "|", skey, groupId); tsdbEncodeTSmaKey(groupId, skey, &pSmaKey); break; case TSDB_DATA_TYPE_BOOL: @@ -976,7 +975,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char } } - if (tsdbInsertTSmaBlocks(&tSmaH, pSmaKey, SMA_KEY_LEN, pDataBuf, tlen) != 0) { + if (tsdbInsertTSmaBlocks(&tSmaH, &smaKey, SMA_KEY_LEN, pDataBuf, tlen) != 0) { tsdbWarn("vgId:%d insert tSma data blocks failed for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64 " since %s", REPO_ID(pTsdb), indexUid, skey, groupId, tstrerror(terrno)); @@ -1308,22 +1307,19 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid, return TSDB_CODE_FAILED; } - char smaKey[SMA_KEY_LEN] = {0}; - void *pSmaKey = &smaKey; + char smaKey[SMA_KEY_LEN] = {0}; + void *pSmaKey = &smaKey; int64_t queryGroupId = 1; tsdbEncodeTSmaKey(queryGroupId, querySKey, (void **)&pSmaKey); - tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), - tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); + tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), + tReadH.dFile.path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), SMA_KEY_LEN); void *result = NULL; uint32_t valueSize = 0; if ((result = tsdbGetSmaDataByKey(&tReadH.dFile, smaKey, SMA_KEY_LEN, &valueSize)) == NULL) { - tsdbWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 - " since %s", - REPO_ID(pTsdb), indexUid, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), tstrerror(terrno)); + tsdbWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIx64 " since %s", + REPO_ID(pTsdb), indexUid, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), tstrerror(terrno)); tsdbCloseDBF(&tReadH.dFile); return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 598647f797..30c2fe84bf 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -66,12 +66,12 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { case TDMT_VND_TABLE_META: return vnodeGetTableMeta(pVnode, pMsg); case TDMT_VND_CONSUME: - return tqProcessPollReq(pVnode->pTq, pMsg); + return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId); case TDMT_VND_TASK_PIPE_EXEC: case TDMT_VND_TASK_MERGE_EXEC: - return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, pInfo->workerId); + return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, 0); case TDMT_VND_STREAM_TRIGGER: - return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, pInfo->workerId); + return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, 0); case TDMT_VND_QUERY_HEARTBEAT: return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg); default: diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index d6f9f0da0b..38eed46c9d 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -165,6 +165,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { // } break; case TDMT_VND_SUBMIT: + /*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/ if (pVnode->config.streamMode == 0) { if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) { // TODO: handle error diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 4c8ddd9ead..db31b9f4a3 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -59,20 +59,21 @@ TEST(testCase, unionEncodeDecodeTest) { void *buf = taosMemoryMalloc(1024); void *pBuf = buf; + void *qBuf = buf; int32_t tlen = 0; - tlen += taosEncodeFixedU8(&buf, sut.info); - tlen += taosEncodeFixedI16(&buf, sut.nBSmaCols); + tlen += taosEncodeFixedU8(&pBuf, sut.info); + tlen += taosEncodeFixedI16(&pBuf, sut.nBSmaCols); for (col_id_t i = 0; i < sut.nBSmaCols; ++i) { - tlen += taosEncodeFixedI16(&buf, sut.pBSmaCols[i]); + tlen += taosEncodeFixedI16(&pBuf, sut.pBSmaCols[i]); } SUnionTest dut = {0}; - pBuf = taosDecodeFixedU8(pBuf, &dut.info); - pBuf = taosDecodeFixedI16(pBuf, &dut.nBSmaCols); + qBuf = taosDecodeFixedU8(qBuf, &dut.info); + qBuf = taosDecodeFixedI16(qBuf, &dut.nBSmaCols); if (dut.nBSmaCols > 0) { dut.pBSmaCols = (col_id_t *)taosMemoryMalloc(dut.nBSmaCols * sizeof(col_id_t)); for (col_id_t i = 0; i < dut.nBSmaCols; ++i) { - pBuf = taosDecodeFixedI16(pBuf, dut.pBSmaCols + i); + qBuf = taosDecodeFixedI16(qBuf, dut.pBSmaCols + i); } } else { dut.pBSmaCols = NULL; @@ -81,13 +82,17 @@ TEST(testCase, unionEncodeDecodeTest) { printf("sut.rollup=%" PRIu8 ", type=%" PRIu8 ", info=%" PRIu8 "\n", sut.rollup, sut.type, sut.info); printf("dut.rollup=%" PRIu8 ", type=%" PRIu8 ", info=%" PRIu8 "\n", dut.rollup, dut.type, dut.info); - ASSERT_EQ(sut.rollup, dut.rollup); - ASSERT_EQ(sut.type, dut.type); - ASSERT_EQ(sut.nBSmaCols, dut.nBSmaCols); + EXPECT_EQ(sut.rollup, dut.rollup); + EXPECT_EQ(sut.type, dut.type); + EXPECT_EQ(sut.nBSmaCols, dut.nBSmaCols); for (col_id_t i = 0; i < sut.nBSmaCols; ++i) { - ASSERT_EQ(*(col_id_t *)(sut.pBSmaCols + i), sut.pBSmaCols[i]); - ASSERT_EQ(*(col_id_t *)(sut.pBSmaCols + i), dut.pBSmaCols[i]); + EXPECT_EQ(*(col_id_t *)(sut.pBSmaCols + i), sut.pBSmaCols[i]); + EXPECT_EQ(*(col_id_t *)(sut.pBSmaCols + i), dut.pBSmaCols[i]); } + + taosMemoryFreeClear(buf); + taosMemoryFreeClear(dut.pBSmaCols); + taosMemoryFreeClear(sut.pBSmaCols); } #if 1 TEST(testCase, tSma_Meta_Encode_Decode_Test) { @@ -107,37 +112,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper); void *buf = taosMemoryCalloc(1, bufLen); - ASSERT_NE(buf, nullptr); + EXPECT_NE(buf, nullptr); STSmaWrapper *pSW = (STSmaWrapper *)buf; uint32_t len = tEncodeTSmaWrapper(&buf, &tSmaWrapper); - ASSERT_EQ(len, bufLen); + EXPECT_EQ(len, bufLen); // decode STSmaWrapper dstTSmaWrapper = {0}; void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper); - ASSERT_NE(result, nullptr); + EXPECT_NE(result, nullptr); - ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); + EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); for (int i = 0; i < tSmaWrapper.number; ++i) { STSma *pSma = tSmaWrapper.tSma + i; STSma *qSma = dstTSmaWrapper.tSma + i; - ASSERT_EQ(pSma->version, qSma->version); - ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit); - ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit); - ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName); - ASSERT_EQ(pSma->timezoneInt, qSma->timezoneInt); - ASSERT_EQ(pSma->indexUid, qSma->indexUid); - ASSERT_EQ(pSma->tableUid, qSma->tableUid); - ASSERT_EQ(pSma->interval, qSma->interval); - ASSERT_EQ(pSma->sliding, qSma->sliding); - ASSERT_EQ(pSma->exprLen, qSma->exprLen); - ASSERT_STRCASEEQ(pSma->expr, qSma->expr); - ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); - ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); + EXPECT_EQ(pSma->version, qSma->version); + EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit); + EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit); + EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName); + EXPECT_EQ(pSma->timezoneInt, qSma->timezoneInt); + EXPECT_EQ(pSma->indexUid, qSma->indexUid); + EXPECT_EQ(pSma->tableUid, qSma->tableUid); + EXPECT_EQ(pSma->interval, qSma->interval); + EXPECT_EQ(pSma->sliding, qSma->sliding); + EXPECT_EQ(pSma->exprLen, qSma->exprLen); + EXPECT_STRCASEEQ(pSma->expr, qSma->expr); + EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); + EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); } // resource release @@ -173,12 +178,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)taosMemoryCalloc(1, tSma.exprLen + 1); - ASSERT_NE(tSma.expr, nullptr); + EXPECT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)taosMemoryCalloc(tSma.tagsFilterLen + 1, 1); - ASSERT_NE(tSma.tagsFilter, nullptr); + EXPECT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta *pMeta = NULL; @@ -190,7 +195,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); pSmaCfg->indexUid = indexUid2; tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN); @@ -201,7 +206,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { pSmaCfg->sliding = 5; // save index 2 - ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // get value by indexName STSma *qSmaCfg = NULL; @@ -211,8 +216,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone1 = %" PRIi8 "\n", qSmaCfg->timezoneInt); printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); - ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid); + EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); + EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid); tdDestroyTSma(qSmaCfg); taosMemoryFreeClear(qSmaCfg); @@ -222,8 +227,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone2 = %" PRIi8 "\n", qSmaCfg->timezoneInt); printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); - ASSERT_EQ(qSmaCfg->interval, tSma.interval); + EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); + EXPECT_EQ(qSmaCfg->interval, tSma.interval); tdDestroyTSma(qSmaCfg); taosMemoryFreeClear(qSmaCfg); @@ -239,25 +244,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("indexName = %s\n", indexName); ++indexCnt; } - ASSERT_EQ(indexCnt, nCntTSma); + EXPECT_EQ(indexCnt, nCntTSma); metaCloseSmaCurosr(pSmaCur); // get wrapper by table uid STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid); assert(pSW != NULL); - ASSERT_EQ(pSW->number, nCntTSma); - ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); - ASSERT_EQ(pSW->tSma->timezoneInt, timezone); - ASSERT_STRCASEEQ(pSW->tSma->expr, expr); - ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); - ASSERT_EQ(pSW->tSma->indexUid, indexUid1); - ASSERT_EQ(pSW->tSma->tableUid, tbUid); - ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); - ASSERT_EQ((pSW->tSma + 1)->timezoneInt, timezone); - ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr); - ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); - ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2); - ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid); + EXPECT_EQ(pSW->number, nCntTSma); + EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); + EXPECT_EQ(pSW->tSma->timezoneInt, timezone); + EXPECT_STRCASEEQ(pSW->tSma->expr, expr); + EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); + EXPECT_EQ(pSW->tSma->indexUid, indexUid1); + EXPECT_EQ(pSW->tSma->tableUid, tbUid); + EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); + EXPECT_EQ((pSW->tSma + 1)->timezoneInt, timezone); + EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr); + EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); + EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2); + EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid); tdDestroyTSmaWrapper(pSW); taosMemoryFreeClear(pSW); @@ -269,7 +274,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i)); // printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i)); } - ASSERT_EQ(taosArrayGetSize(pUids), 1); + EXPECT_EQ(taosArrayGetSize(pUids), 1); taosArrayDestroy(pUids); // resource release @@ -311,12 +316,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)taosMemoryCalloc(1, tSma.exprLen + 1); - ASSERT_NE(tSma.expr, nullptr); + EXPECT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)taosMemoryCalloc(1, tSma.tagsFilterLen + 1); - ASSERT_NE(tSma.tagsFilter, nullptr); + EXPECT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta *pMeta = NULL; @@ -328,7 +333,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // step 2: insert data STsdb *pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb)); @@ -365,7 +370,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { strncpy(pDisks.dir, "/var/lib/taos", TSDB_FILENAME_LEN); int32_t numOfDisks = 1; pTsdb->pTfs = tfsOpen(&pDisks, numOfDisks); - ASSERT_NE(pTsdb->pTfs, nullptr); + EXPECT_NE(pTsdb->pTfs, nullptr); // generate SSubmitReq msg and update expired window int16_t schemaVer = 0; @@ -375,7 +380,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { uint32_t msgLen = sizeof(SSubmitReq) + mockBlkNum * sizeof(SSubmitBlk) + mockBlkNum * mockRowNum * mockRowLen; SSubmitReq *pMsg = (SSubmitReq *)taosMemoryCalloc(1, msgLen); - ASSERT_NE(pMsg, nullptr); + EXPECT_NE(pMsg, nullptr); pMsg->version = htobe64(schemaVer); pMsg->numOfBlocks = htonl(mockBlkNum); pMsg->length = htonl(msgLen); @@ -401,9 +406,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } } - ASSERT_EQ(tdScanAndConvertSubmitMsg(pMsg), TSDB_CODE_SUCCESS); + EXPECT_EQ(tdScanAndConvertSubmitMsg(pMsg), TSDB_CODE_SUCCESS); - ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, (const char *)pMsg), 0); + EXPECT_EQ(tsdbUpdateSmaWindow(pTsdb, (const char *)pMsg), 0); // init const int32_t tSmaGroupSize = 4; @@ -413,7 +418,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { const int32_t tSmaNumOfRows = 2; SArray *pDataBlocks = taosArrayInit(tSmaGroupSize, sizeof(SSDataBlock *)); - ASSERT_NE(pDataBlocks, nullptr); + EXPECT_NE(pDataBlocks, nullptr); int32_t tSmaTypeArray[tSmaNumOfCols] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_VARCHAR, TSDB_DATA_TYPE_NCHAR}; @@ -427,18 +432,18 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { for (int32_t g = 0; g < tSmaGroupSize; ++g) { SSDataBlock *pDataBlock = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock)); - ASSERT_NE(pDataBlock, nullptr); + EXPECT_NE(pDataBlock, nullptr); pDataBlock->pBlockAgg = NULL; pDataBlock->info.numOfCols = tSmaNumOfCols; pDataBlock->info.rows = tSmaNumOfRows; pDataBlock->info.groupId = tSmaGroupId + g; pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *)); - ASSERT_NE(pDataBlock->pDataBlock, nullptr); + EXPECT_NE(pDataBlock->pDataBlock, nullptr); for (int32_t c = 0; c < tSmaNumOfCols; ++c) { SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData)); - ASSERT_NE(pColInfoData, nullptr); + EXPECT_NE(pColInfoData, nullptr); pColInfoData->info.type = tSmaTypeArray[c]; if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { @@ -481,7 +486,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { memcpy(varDataVal(pCellData), tSmaGroupbyTags[g * 2 + 1], varDataLen(pCellData)); break; default: - ASSERT_EQ(0, 1); // add definition + EXPECT_EQ(0, 1); // add definition break; } } @@ -493,7 +498,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } // execute - ASSERT_EQ(tsdbInsertTSmaData(pTsdb, tSma.indexUid, (const char *)pDataBlocks), TSDB_CODE_SUCCESS); + EXPECT_EQ(tsdbInsertTSmaData(pTsdb, tSma.indexUid, (const char *)pDataBlocks), TSDB_CODE_SUCCESS); #if 0 STSmaDataWrapper *pSmaData = NULL; @@ -512,7 +517,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { int32_t tableDataLen = sizeof(STSmaTbData); for (col_id_t c = 0; c < numOfCols; ++c) { if (bufSize - len - tableDataLen < buffer) { - ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); + EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); pSmaData = (STSmaDataWrapper *)buf; pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len); bufSize = taosTSizeof(buf); @@ -539,14 +544,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } pSmaData->dataLen = (len - sizeof(STSmaDataWrapper)); - ASSERT_GE(bufSize, pSmaData->dataLen); + EXPECT_GE(bufSize, pSmaData->dataLen); // execute - ASSERT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); + EXPECT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); #endif // step 3: query uint32_t checkDataCnt = 0; - ASSERT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, skey1, 1), TSDB_CODE_SUCCESS); + EXPECT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, skey1, 1), TSDB_CODE_SUCCESS); ++checkDataCnt; printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt); @@ -555,11 +560,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { taosMemoryFreeClear(pMsg); for (int32_t i = 0; i < taosArrayGetSize(pDataBlocks); ++i) { - SSDataBlock *pDataBlock = (SSDataBlock *)taosArrayGet(pDataBlocks, i); + SSDataBlock *pDataBlock = *(SSDataBlock **)taosArrayGet(pDataBlocks, i); int32_t numOfOutput = taosArrayGetSize(pDataBlock->pDataBlock); for (int32_t j = 0; j < numOfOutput; ++j) { - SColumnInfoData *pColInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock->pDataBlock, j); + SColumnInfoData *pColInfoData = *(SColumnInfoData **)taosArrayGet(pDataBlock->pDataBlock, j); colDataDestroy(pColInfoData); + taosMemoryFreeClear(pColInfoData); } taosArrayDestroy(pDataBlock->pDataBlock); diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt index a1b9337fa8..b1e8be6528 100644 --- a/source/libs/CMakeLists.txt +++ b/source/libs/CMakeLists.txt @@ -17,3 +17,4 @@ add_subdirectory(tfs) add_subdirectory(monitor) add_subdirectory(nodes) add_subdirectory(scalar) +add_subdirectory(command) diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 9bd5c1c016..09f51dc03e 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -112,7 +112,14 @@ typedef struct SCtgRuntimeStat { } SCtgRuntimeStat; typedef struct SCtgCacheStat { - + uint64_t clusterNum; + uint64_t dbNum; + uint64_t tblNum; + uint64_t stblNum; + uint64_t vgHitNum; + uint64_t vgMissNum; + uint64_t tblHitNum; + uint64_t tblMissNum; } SCtgCacheStat; typedef struct SCatalogStat { @@ -186,7 +193,7 @@ typedef struct SCatalogMgmt { bool exit; SRWLatch lock; SCtgQueue queue; - TdThread updateThread; + TdThread updateThread; SHashObj *pCluster; //key: clusterId, value: SCatalog* SCatalogStat stat; SCatalogCfg cfg; @@ -204,8 +211,13 @@ typedef struct SCtgAction { #define CTG_QUEUE_ADD() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1) #define CTG_QUEUE_SUB() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1) -#define CTG_STAT_ADD(n) atomic_add_fetch_64(&(n), 1) -#define CTG_STAT_SUB(n) atomic_sub_fetch_64(&(n), 1) +#define CTG_STAT_ADD(_item, _n) atomic_add_fetch_64(&(_item), _n) +#define CTG_STAT_SUB(_item, _n) atomic_sub_fetch_64(&(_item), _n) +#define CTG_STAT_GET(_item) atomic_load_64(&(_item)) + +#define CTG_RUNTIME_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.runtime.item, n)) +#define CTG_CACHE_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.cache.item, n)) +#define CTG_CACHE_STAT_SUB(item, n) (CTG_STAT_SUB(gCtgMgmt.stat.cache.item, n)) #define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE) #define CTG_IS_META_CTABLE(type) ((type) == META_TYPE_CTABLE) @@ -291,6 +303,9 @@ typedef struct SCtgAction { #define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0) +extern void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p); +extern void ctgdShowClusterCache(SCatalog* pCtg); +extern int32_t ctgdShowCacheInfo(void); #ifdef __cplusplus } diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e87fdba71d..e1f5332899 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -24,8 +24,8 @@ int32_t ctgActRemoveDB(SCtgMetaAction *action); int32_t ctgActRemoveStb(SCtgMetaAction *action); int32_t ctgActRemoveTbl(SCtgMetaAction *action); +extern SCtgDebug gCTGDebug; SCatalogMgmt gCtgMgmt = {0}; -SCtgDebug gCTGDebug = {0}; SCtgAction gCtgAction[CTG_ACT_MAX] = {{ CTG_ACT_UPDATE_VG, "update vgInfo", @@ -53,182 +53,6 @@ SCtgAction gCtgAction[CTG_ACT_MAX] = {{ } }; -int32_t ctgDbgEnableDebug(char *option) { - if (0 == strcasecmp(option, "lock")) { - gCTGDebug.lockEnable = true; - qDebug("lock debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "cache")) { - gCTGDebug.cacheEnable = true; - qDebug("cache debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "api")) { - gCTGDebug.apiEnable = true; - qDebug("api debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "meta")) { - gCTGDebug.metaEnable = true; - qDebug("api debug enabled"); - return TSDB_CODE_SUCCESS; - } - - qError("invalid debug option:%s", option); - - return TSDB_CODE_CTG_INTERNAL_ERROR; -} - -int32_t ctgDbgGetStatNum(char *option, void *res) { - if (0 == strcasecmp(option, "runtime.qDoneNum")) { - *(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.qDoneNum); - return TSDB_CODE_SUCCESS; - } - - qError("invalid stat option:%s", option); - - return TSDB_CODE_CTG_INTERNAL_ERROR; -} - -int32_t ctgDbgGetTbMetaNum(SCtgDBCache *dbCache) { - return dbCache->tbCache.metaCache ? (int32_t)taosHashGetSize(dbCache->tbCache.metaCache) : 0; -} - -int32_t ctgDbgGetStbNum(SCtgDBCache *dbCache) { - return dbCache->tbCache.stbCache ? (int32_t)taosHashGetSize(dbCache->tbCache.stbCache) : 0; -} - -int32_t ctgDbgGetRentNum(SCtgRentMgmt *rent) { - int32_t num = 0; - for (uint16_t i = 0; i < rent->slotNum; ++i) { - SCtgRentSlot *slot = &rent->slots[i]; - if (NULL == slot->meta) { - continue; - } - - num += taosArrayGetSize(slot->meta); - } - - return num; -} - -int32_t ctgDbgGetClusterCacheNum(SCatalog* pCtg, int32_t type) { - if (NULL == pCtg || NULL == pCtg->dbCache) { - return 0; - } - - switch (type) { - case CTG_DBG_DB_NUM: - return (int32_t)taosHashGetSize(pCtg->dbCache); - case CTG_DBG_DB_RENT_NUM: - return ctgDbgGetRentNum(&pCtg->dbRent); - case CTG_DBG_STB_RENT_NUM: - return ctgDbgGetRentNum(&pCtg->stbRent); - default: - break; - } - - SCtgDBCache *dbCache = NULL; - int32_t num = 0; - void *pIter = taosHashIterate(pCtg->dbCache, NULL); - while (pIter) { - dbCache = (SCtgDBCache *)pIter; - switch (type) { - case CTG_DBG_META_NUM: - num += ctgDbgGetTbMetaNum(dbCache); - break; - case CTG_DBG_STB_NUM: - num += ctgDbgGetStbNum(dbCache); - break; - default: - ctgError("invalid type:%d", type); - break; - } - pIter = taosHashIterate(pCtg->dbCache, pIter); - } - - return num; -} - -void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { - if (!gCTGDebug.metaEnable) { - return; - } - - STableComInfo *c = &p->tableInfo; - - if (TSDB_CHILD_TABLE == p->tableType) { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, tbName, p->tableType, p->vgId, p->uid, p->suid); - return; - } else { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", - tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); - } - - int32_t colNum = c->numOfColumns + c->numOfTags; - for (int32_t i = 0; i < colNum; ++i) { - SSchema *s = &p->schema[i]; - ctgDebug("[%d] name:%s, type:%d, colId:%" PRIi16 ", bytes:%d", i, s->name, s->type, s->colId, s->bytes); - } -} - -void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { - if (NULL == dbHash || !gCTGDebug.cacheEnable) { - return; - } - - int32_t i = 0; - SCtgDBCache *dbCache = NULL; - void *pIter = taosHashIterate(dbHash, NULL); - while (pIter) { - char *dbFName = NULL; - size_t len = 0; - - dbCache = (SCtgDBCache *)pIter; - - dbFName = taosHashGetKey(pIter, &len); - - int32_t metaNum = dbCache->tbCache.metaCache ? taosHashGetSize(dbCache->tbCache.metaCache) : 0; - int32_t stbNum = dbCache->tbCache.stbCache ? taosHashGetSize(dbCache->tbCache.stbCache) : 0; - int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION; - int32_t hashMethod = -1; - int32_t vgNum = 0; - - if (dbCache->vgInfo) { - vgVersion = dbCache->vgInfo->vgVersion; - hashMethod = dbCache->vgInfo->hashMethod; - if (dbCache->vgInfo->vgHash) { - vgNum = taosHashGetSize(dbCache->vgInfo->vgHash); - } - } - - ctgDebug("[%d] db [%.*s][%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d", - i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, vgNum); - - pIter = taosHashIterate(dbHash, pIter); - } -} - - - - -void ctgDbgShowClusterCache(SCatalog* pCtg) { - if (!gCTGDebug.cacheEnable || NULL == pCtg) { - return; - } - - ctgDebug("## cluster %"PRIx64" %p cache Info ##", pCtg->clusterId, pCtg); - ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), - ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); - - ctgDbgShowDBCache(pCtg, pCtg->dbCache); -} - - void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { if (NULL == mgmt->slots) { return; @@ -249,15 +73,19 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { void ctgFreeTableMetaCache(SCtgTbMetaCache *cache) { CTG_LOCK(CTG_WRITE, &cache->stbLock); if (cache->stbCache) { + int32_t stblNum = taosHashGetSize(cache->stbCache); taosHashCleanup(cache->stbCache); cache->stbCache = NULL; + CTG_CACHE_STAT_SUB(stblNum, stblNum); } CTG_UNLOCK(CTG_WRITE, &cache->stbLock); CTG_LOCK(CTG_WRITE, &cache->metaLock); if (cache->metaCache) { + int32_t tblNum = taosHashGetSize(cache->metaCache); taosHashCleanup(cache->metaCache); cache->metaCache = NULL; + CTG_CACHE_STAT_SUB(tblNum, tblNum); } CTG_UNLOCK(CTG_WRITE, &cache->metaLock); } @@ -293,6 +121,8 @@ void ctgFreeHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->stbRent); if (pCtg->dbCache) { + int32_t dbNum = taosHashGetSize(pCtg->dbCache); + void *pIter = taosHashIterate(pCtg->dbCache, NULL); while (pIter) { SCtgDBCache *dbCache = pIter; @@ -305,6 +135,8 @@ void ctgFreeHandle(SCatalog* pCtg) { } taosHashCleanup(pCtg->dbCache); + + CTG_CACHE_STAT_SUB(dbNum, dbNum); } taosMemoryFree(pCtg); @@ -361,7 +193,7 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) { CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.queue.qlock); CTG_QUEUE_ADD(); - CTG_STAT_ADD(gCtgMgmt.stat.runtime.qNum); + CTG_RUNTIME_STAT_ADD(qNum, 1); tsem_post(&gCtgMgmt.queue.reqSem); @@ -620,34 +452,45 @@ int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache) int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool *inCache) { + SCtgDBCache *dbCache = NULL; + if (NULL == pCtg->dbCache) { - *pCache = NULL; - *inCache = false; - ctgWarn("empty db cache, dbFName:%s", dbFName); - return TSDB_CODE_SUCCESS; + ctgDebug("empty db cache, dbFName:%s", dbFName); + goto _return; } - SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { - *pCache = NULL; - *inCache = false; - return TSDB_CODE_SUCCESS; + ctgDebug("db %s not in cache", dbFName); + goto _return; } ctgAcquireVgInfo(pCtg, dbCache, inCache); if (!(*inCache)) { - ctgReleaseDBCache(pCtg, dbCache); - - *pCache = NULL; - return TSDB_CODE_SUCCESS; + ctgDebug("vgInfo of db %s not in cache", dbFName); + goto _return; } *pCache = dbCache; *inCache = true; + CTG_CACHE_STAT_ADD(vgHitNum, 1); + ctgDebug("Got db vgInfo from cache, dbFName:%s", dbFName); + return TSDB_CODE_SUCCESS; + +_return: + + if (dbCache) { + ctgReleaseDBCache(pCtg, dbCache); + } + + *pCache = NULL; + *inCache = false; + + CTG_CACHE_STAT_ADD(vgMissNum, 1); + return TSDB_CODE_SUCCESS; } @@ -763,11 +606,10 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, } -int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, int32_t *exist, int32_t flag, uint64_t *dbId) { +int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, bool *inCache, int32_t flag, uint64_t *dbId) { if (NULL == pCtg->dbCache) { - *exist = 0; - ctgWarn("empty tbmeta cache, tbName:%s", pTableName->tname); - return TSDB_CODE_SUCCESS; + ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname); + goto _return; } char dbFName[TSDB_DB_FNAME_LEN] = {0}; @@ -782,8 +624,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { - *exist = 0; - return TSDB_CODE_SUCCESS; + ctgDebug("db %s not in cache", pTableName->tname); + goto _return; } int32_t sz = 0; @@ -792,13 +634,11 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); if (NULL == *pTableMeta) { - *exist = 0; ctgReleaseDBCache(pCtg, dbCache); ctgDebug("tbl not in cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname); - return TSDB_CODE_SUCCESS; + goto _return; } - *exist = 1; if (dbId) { *dbId = dbCache->dbId; } @@ -808,6 +648,10 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable if (tbMeta->tableType != TSDB_CHILD_TABLE) { ctgReleaseDBCache(pCtg, dbCache); ctgDebug("Got meta from cache, type:%d, dbFName:%s, tbName:%s", tbMeta->tableType, dbFName, pTableName->tname); + + *inCache = true; + CTG_CACHE_STAT_ADD(tblHitNum, 1); + return TSDB_CODE_SUCCESS; } @@ -819,8 +663,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ctgReleaseDBCache(pCtg, dbCache); ctgError("stb not in stbCache, suid:%"PRIx64, tbMeta->suid); taosMemoryFreeClear(*pTableMeta); - *exist = 0; - return TSDB_CODE_SUCCESS; + goto _return; } if ((*stbMeta)->suid != tbMeta->suid) { @@ -846,8 +689,18 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ctgReleaseDBCache(pCtg, dbCache); + *inCache = true; + CTG_CACHE_STAT_ADD(tblHitNum, 1); + ctgDebug("Got tbmeta from cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname); + return TSDB_CODE_SUCCESS; + +_return: + + *inCache = false; + CTG_CACHE_STAT_ADD(tblMissNum, 1); + return TSDB_CODE_SUCCESS; } @@ -1377,6 +1230,8 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { ctgError("taosHashPut db to cache failed, dbFName:%s", dbFName); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } + + CTG_CACHE_STAT_ADD(dbNum, 1); SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1}; strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName)); @@ -1436,6 +1291,8 @@ int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) { CTG_ERR_RET(TSDB_CODE_CTG_DB_DROPPED); } + CTG_CACHE_STAT_SUB(dbNum, 1); + ctgInfo("db removed from cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbId); return TSDB_CODE_SUCCESS; @@ -1568,6 +1425,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui CTG_LOCK(CTG_WRITE, &tbCache->stbLock); if (taosHashRemove(tbCache->stbCache, &orig->suid, sizeof(orig->suid))) { ctgError("stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"PRIx64, dbFName, tbName, orig->suid); + } else { + CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); @@ -1594,8 +1453,12 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } + if (NULL == orig) { + CTG_CACHE_STAT_ADD(tblNum, 1); + } + ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType); - ctgDbgShowTableMeta(pCtg, tbName, meta); + ctgdShowTableMeta(pCtg, tbName, meta); if (!isStb) { CTG_UNLOCK(CTG_READ, &tbCache->metaLock); @@ -1615,6 +1478,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ctgError("taosHashPut stable to stable cache failed, suid:%"PRIx64, meta->suid); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } + + CTG_CACHE_STAT_ADD(stblNum, 1); CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); @@ -1874,7 +1739,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - int32_t exist = 0; + bool inCache = false; int32_t code = 0; uint64_t dbId = 0; uint64_t suid = 0; @@ -1884,11 +1749,11 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_FLAG_SET_INF_DB(flag); } - CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &exist, flag, &dbId)); + CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId)); int32_t tbType = 0; - if (exist) { + if (inCache) { if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) { goto _return; } @@ -1930,8 +1795,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons SName stbName = *pTableName; strcpy(stbName.tname, output->tbName); - CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &exist, flag, NULL)); - if (0 == exist) { + CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &inCache, flag, NULL)); + if (!inCache) { ctgDebug("stb no longer exist, dbFName:%s, tbName:%s", output->dbFName, pTableName->tname); continue; } @@ -1943,7 +1808,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons _return: - if (CTG_TABLE_NOT_EXIST(code) && exist) { + if (CTG_TABLE_NOT_EXIST(code) && inCache) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; if (CTG_FLAG_IS_INF_DB(flag)) { strcpy(dbFName, pTableName->dbname); @@ -1962,7 +1827,7 @@ _return: if (*pTableMeta) { ctgDebug("tbmeta returned, tbName:%s, tbType:%d", pTableName->tname, (*pTableMeta)->tableType); - ctgDbgShowTableMeta(pCtg, pTableName->tname, *pTableMeta); + ctgdShowTableMeta(pCtg, pTableName->tname, *pTableMeta); } CTG_RET(code); @@ -2075,12 +1940,16 @@ int32_t ctgActRemoveStb(SCtgMetaAction *action) { CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock); if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) { ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); + } else { + CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) { ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); - } + } else { + CTG_CACHE_STAT_SUB(tblNum, 1); + } CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); CTG_UNLOCK(CTG_WRITE, &dbCache->tbCache.stbLock); @@ -2119,6 +1988,8 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); ctgError("stb not exist in cache, dbFName:%s, tbName:%s", msg->dbFName, msg->tbName); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); + } else { + CTG_CACHE_STAT_SUB(tblNum, 1); } CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); @@ -2140,7 +2011,9 @@ void* ctgUpdateThreadFunc(void* param) { CTG_LOCK(CTG_READ, &gCtgMgmt.lock); while (true) { - tsem_wait(&gCtgMgmt.queue.reqSem); + if (tsem_wait(&gCtgMgmt.queue.reqSem)) { + qError("ctg tsem_wait failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { tsem_post(&gCtgMgmt.queue.rspSem); @@ -2161,9 +2034,9 @@ void* ctgUpdateThreadFunc(void* param) { tsem_post(&gCtgMgmt.queue.rspSem); } - CTG_STAT_ADD(gCtgMgmt.stat.runtime.qDoneNum); + CTG_RUNTIME_STAT_ADD(qDoneNum, 1); - ctgDbgShowClusterCache(pCtg); + ctgdShowClusterCache(pCtg); } CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); @@ -2304,10 +2177,15 @@ int32_t catalogInit(SCatalogCfg *cfg) { CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } - CTG_ERR_RET(ctgStartUpdateThread()); - - tsem_init(&gCtgMgmt.queue.reqSem, 0, 0); - tsem_init(&gCtgMgmt.queue.rspSem, 0, 0); + if (tsem_init(&gCtgMgmt.queue.reqSem, 0, 0)) { + qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); + } + + if (tsem_init(&gCtgMgmt.queue.rspSem, 0, 0)) { + qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); + } gCtgMgmt.queue.head = taosMemoryCalloc(1, sizeof(SCtgQNode)); if (NULL == gCtgMgmt.queue.head) { @@ -2316,6 +2194,8 @@ int32_t catalogInit(SCatalogCfg *cfg) { } gCtgMgmt.queue.tail = gCtgMgmt.queue.head; + CTG_ERR_RET(ctgStartUpdateThread()); + qDebug("catalog initialized, maxDb:%u, maxTbl:%u, dbRentSec:%u, stbRentSec:%u", gCtgMgmt.cfg.maxDBCacheNum, gCtgMgmt.cfg.maxTblCacheNum, gCtgMgmt.cfg.dbRentSec, gCtgMgmt.cfg.stbRentSec); return TSDB_CODE_SUCCESS; @@ -2383,6 +2263,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { } *catalogHandle = clusterCtg; + + CTG_CACHE_STAT_ADD(clusterNum, 1); return TSDB_CODE_SUCCESS; @@ -2403,10 +2285,12 @@ void catalogFreeHandle(SCatalog* pCtg) { return; } + CTG_CACHE_STAT_SUB(clusterNum, 1); + uint64_t clusterId = pCtg->clusterId; ctgFreeHandle(pCtg); - + ctgInfo("handle freed, culsterId:%"PRIx64, clusterId); } @@ -2417,24 +2301,12 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - if (NULL == pCtg->dbCache) { - *version = CTG_DEFAULT_INVALID_VERSION; - ctgInfo("empty db cache, dbFName:%s", dbFName); - CTG_API_LEAVE(TSDB_CODE_SUCCESS); - } - SCtgDBCache *dbCache = NULL; - ctgAcquireDBCache(pCtg, dbFName, &dbCache); - if (NULL == dbCache) { - *version = CTG_DEFAULT_INVALID_VERSION; - CTG_API_LEAVE(TSDB_CODE_SUCCESS); - } - bool inCache = false; - ctgAcquireVgInfo(pCtg, dbCache, &inCache); - if (!inCache) { - ctgReleaseDBCache(pCtg, dbCache); + int32_t code = 0; + CTG_ERR_JRET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache, &inCache)); + if (!inCache) { *version = CTG_DEFAULT_INVALID_VERSION; CTG_API_LEAVE(TSDB_CODE_SUCCESS); } @@ -2449,6 +2321,10 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers ctgDebug("Got db vgVersion from cache, dbFName:%s, vgVersion:%d", dbFName, *version); CTG_API_LEAVE(TSDB_CODE_SUCCESS); + +_return: + + CTG_API_LEAVE(code); } int32_t catalogGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SArray** vgroupList) { @@ -2549,11 +2425,11 @@ int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { } STableMeta *tblMeta = NULL; - int32_t exist = 0; + bool inCache = false; uint64_t dbId = 0; - CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &exist, 0, &dbId)); + CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &inCache, 0, &dbId)); - if (0 == exist) { + if (!inCache) { ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); goto _return; } @@ -2851,8 +2727,13 @@ void catalogDestroy(void) { atomic_store_8((int8_t*)&gCtgMgmt.exit, true); - tsem_post(&gCtgMgmt.queue.reqSem); - tsem_post(&gCtgMgmt.queue.rspSem); + if (tsem_post(&gCtgMgmt.queue.reqSem)) { + qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } + + if (tsem_post(&gCtgMgmt.queue.rspSem)) { + qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } while (CTG_IS_LOCKED(&gCtgMgmt.lock)) { taosUsleep(1); diff --git a/source/libs/catalog/src/catalogDbg.c b/source/libs/catalog/src/catalogDbg.c new file mode 100644 index 0000000000..1d4ad0082c --- /dev/null +++ b/source/libs/catalog/src/catalogDbg.c @@ -0,0 +1,222 @@ +/* + * 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 "trpc.h" +#include "query.h" +#include "tname.h" +#include "catalogInt.h" + +extern SCatalogMgmt gCtgMgmt; +SCtgDebug gCTGDebug = {0}; + +int32_t ctgdEnableDebug(char *option) { + if (0 == strcasecmp(option, "lock")) { + gCTGDebug.lockEnable = true; + qDebug("lock debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "cache")) { + gCTGDebug.cacheEnable = true; + qDebug("cache debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "api")) { + gCTGDebug.apiEnable = true; + qDebug("api debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "meta")) { + gCTGDebug.metaEnable = true; + qDebug("api debug enabled"); + return TSDB_CODE_SUCCESS; + } + + qError("invalid debug option:%s", option); + + return TSDB_CODE_CTG_INTERNAL_ERROR; +} + +int32_t ctgdGetStatNum(char *option, void *res) { + if (0 == strcasecmp(option, "runtime.qDoneNum")) { + *(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.qDoneNum); + return TSDB_CODE_SUCCESS; + } + + qError("invalid stat option:%s", option); + + return TSDB_CODE_CTG_INTERNAL_ERROR; +} + +int32_t ctgdGetTbMetaNum(SCtgDBCache *dbCache) { + return dbCache->tbCache.metaCache ? (int32_t)taosHashGetSize(dbCache->tbCache.metaCache) : 0; +} + +int32_t ctgdGetStbNum(SCtgDBCache *dbCache) { + return dbCache->tbCache.stbCache ? (int32_t)taosHashGetSize(dbCache->tbCache.stbCache) : 0; +} + +int32_t ctgdGetRentNum(SCtgRentMgmt *rent) { + int32_t num = 0; + for (uint16_t i = 0; i < rent->slotNum; ++i) { + SCtgRentSlot *slot = &rent->slots[i]; + if (NULL == slot->meta) { + continue; + } + + num += taosArrayGetSize(slot->meta); + } + + return num; +} + +int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) { + if (NULL == pCtg || NULL == pCtg->dbCache) { + return 0; + } + + switch (type) { + case CTG_DBG_DB_NUM: + return (int32_t)taosHashGetSize(pCtg->dbCache); + case CTG_DBG_DB_RENT_NUM: + return ctgdGetRentNum(&pCtg->dbRent); + case CTG_DBG_STB_RENT_NUM: + return ctgdGetRentNum(&pCtg->stbRent); + default: + break; + } + + SCtgDBCache *dbCache = NULL; + int32_t num = 0; + void *pIter = taosHashIterate(pCtg->dbCache, NULL); + while (pIter) { + dbCache = (SCtgDBCache *)pIter; + switch (type) { + case CTG_DBG_META_NUM: + num += ctgdGetTbMetaNum(dbCache); + break; + case CTG_DBG_STB_NUM: + num += ctgdGetStbNum(dbCache); + break; + default: + ctgError("invalid type:%d", type); + break; + } + pIter = taosHashIterate(pCtg->dbCache, pIter); + } + + return num; +} + +void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { + if (!gCTGDebug.metaEnable) { + return; + } + + STableComInfo *c = &p->tableInfo; + + if (TSDB_CHILD_TABLE == p->tableType) { + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, tbName, p->tableType, p->vgId, p->uid, p->suid); + return; + } else { + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); + } + + int32_t colNum = c->numOfColumns + c->numOfTags; + for (int32_t i = 0; i < colNum; ++i) { + SSchema *s = &p->schema[i]; + ctgDebug("[%d] name:%s, type:%d, colId:%d, bytes:%d", i, s->name, s->type, s->colId, s->bytes); + } +} + +void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { + if (NULL == dbHash || !gCTGDebug.cacheEnable) { + return; + } + + int32_t i = 0; + SCtgDBCache *dbCache = NULL; + void *pIter = taosHashIterate(dbHash, NULL); + while (pIter) { + char *dbFName = NULL; + size_t len = 0; + + dbCache = (SCtgDBCache *)pIter; + + dbFName = taosHashGetKey(pIter, &len); + + int32_t metaNum = dbCache->tbCache.metaCache ? taosHashGetSize(dbCache->tbCache.metaCache) : 0; + int32_t stbNum = dbCache->tbCache.stbCache ? taosHashGetSize(dbCache->tbCache.stbCache) : 0; + int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION; + int32_t hashMethod = -1; + int32_t vgNum = 0; + + if (dbCache->vgInfo) { + vgVersion = dbCache->vgInfo->vgVersion; + hashMethod = dbCache->vgInfo->hashMethod; + if (dbCache->vgInfo->vgHash) { + vgNum = taosHashGetSize(dbCache->vgInfo->vgHash); + } + } + + ctgDebug("[%d] db [%.*s][%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d", + i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, vgNum); + + pIter = taosHashIterate(dbHash, pIter); + } +} + + + + +void ctgdShowClusterCache(SCatalog* pCtg) { + if (!gCTGDebug.cacheEnable || NULL == pCtg) { + return; + } + + ctgDebug("## cluster %"PRIx64" %p cache Info BEGIN ##", pCtg->clusterId, pCtg); + ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); + + ctgdShowDBCache(pCtg, pCtg->dbCache); + + ctgDebug("## cluster %"PRIx64" %p cache Info END ##", pCtg->clusterId, pCtg); +} + +int32_t ctgdShowCacheInfo(void) { + if (!gCTGDebug.cacheEnable) { + return TSDB_CODE_CTG_OUT_OF_SERVICE; + } + + CTG_API_ENTER(); + + SCatalog *pCtg = NULL; + void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); + while (pIter) { + pCtg = *(SCatalog **)pIter; + + if (pCtg) { + ctgdShowClusterCache(pCtg); + } + + pIter = taosHashIterate(gCtgMgmt.pCluster, pIter); + } + + CTG_API_LEAVE(TSDB_CODE_SUCCESS); +} + diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index e62819b078..73d0dc2011 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -38,11 +38,11 @@ namespace { extern "C" int32_t ctgGetTableMetaFromCache(struct SCatalog *pCatalog, const SName *pTableName, STableMeta **pTableMeta, - int32_t *exist, int32_t flag, uint64_t *dbId); -extern "C" int32_t ctgDbgGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type); + bool *inCache, int32_t flag, uint64_t *dbId); +extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type); extern "C" int32_t ctgActUpdateTbl(SCtgMetaAction *action); -extern "C" int32_t ctgDbgEnableDebug(char *option); -extern "C" int32_t ctgDbgGetStatNum(char *option, void *res); +extern "C" int32_t ctgdEnableDebug(char *option); +extern "C" int32_t ctgdGetStatNum(char *option, void *res); void ctgTestSetRspTableMeta(); void ctgTestSetRspCTableMeta(); @@ -140,9 +140,9 @@ void ctgTestInitLogFile() { qDebugFlag = 159; strcpy(tsLogDir, "/var/log/taos"); - ctgDbgEnableDebug("api"); - ctgDbgEnableDebug("meta"); - ctgDbgEnableDebug("cache"); + ctgdEnableDebug("api"); + ctgdEnableDebug("meta"); + ctgdEnableDebug("cache"); if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); @@ -786,15 +786,15 @@ void *ctgTestGetCtableMetaThread(void *param) { int32_t code = 0; int32_t n = 0; STableMeta *tbMeta = NULL; - int32_t exist = 0; + bool inCache = false; SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1}; strcpy(cn.dbname, "db1"); strcpy(cn.tname, ctgTestCTablename); while (!ctgTestStop) { - code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &exist, 0, NULL); - if (code || 0 == exist) { + code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &inCache, 0, NULL); + if (code || !inCache) { assert(0); } @@ -879,7 +879,7 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(vgInfo.vgId, 8); ASSERT_EQ(vgInfo.epSet.numOfEps, 3); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) { taosMsleep(50); } @@ -899,7 +899,7 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -994,7 +994,7 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1103,7 +1103,7 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1130,7 +1130,7 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (2 != n) { taosMsleep(50); } else { @@ -1228,7 +1228,7 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1241,8 +1241,8 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(code, 0); while (true) { - int32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); - int32_t m = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM); + int32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + int32_t m = ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM); if (n || m) { taosMsleep(50); } else { @@ -1251,11 +1251,11 @@ TEST(tableMeta, rmStbMeta) { } - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 0); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 0); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 0); catalogDestroy(); memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); @@ -1298,7 +1298,7 @@ TEST(tableMeta, updateStbMeta) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1318,7 +1318,7 @@ TEST(tableMeta, updateStbMeta) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n != 3) { taosMsleep(50); } else { @@ -1326,11 +1326,11 @@ TEST(tableMeta, updateStbMeta) { } } - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 1); code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); @@ -1388,7 +1388,7 @@ TEST(refreshGetMeta, normal2normal) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1409,7 +1409,7 @@ TEST(refreshGetMeta, normal2normal) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1467,7 +1467,7 @@ TEST(refreshGetMeta, normal2notexist) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1488,7 +1488,7 @@ TEST(refreshGetMeta, normal2notexist) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1541,7 +1541,7 @@ TEST(refreshGetMeta, normal2child) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1562,7 +1562,7 @@ TEST(refreshGetMeta, normal2child) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1625,7 +1625,7 @@ TEST(refreshGetMeta, stable2child) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1647,7 +1647,7 @@ TEST(refreshGetMeta, stable2child) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1710,7 +1710,7 @@ TEST(refreshGetMeta, stable2stable) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1732,7 +1732,7 @@ TEST(refreshGetMeta, stable2stable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1798,7 +1798,7 @@ TEST(refreshGetMeta, child2stable) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1818,7 +1818,7 @@ TEST(refreshGetMeta, child2stable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (2 != ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (2 != ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -2015,7 +2015,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -2041,7 +2041,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n != 3) { taosMsleep(50); } else { @@ -2266,7 +2266,7 @@ TEST(rentTest, allRent) { ASSERT_EQ(tableMeta->tableInfo.precision, 1); ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); - while (ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM) < i) { + while (ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM) < i) { taosMsleep(50); } diff --git a/source/libs/command/CMakeLists.txt b/source/libs/command/CMakeLists.txt new file mode 100644 index 0000000000..db3766d145 --- /dev/null +++ b/source/libs/command/CMakeLists.txt @@ -0,0 +1,16 @@ +aux_source_directory(src COMMAND_SRC) +add_library(command STATIC ${COMMAND_SRC}) +target_include_directories( + command + PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/command" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) + +target_link_libraries( + command + PRIVATE os util nodes catalog function transport qcom +) + +if(${BUILD_TEST}) + ADD_SUBDIRECTORY(test) +endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h new file mode 100644 index 0000000000..771baca2ab --- /dev/null +++ b/source/libs/command/inc/commandInt.h @@ -0,0 +1,99 @@ +/* + * 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_QUERY_INT_H_ +#define _TD_QUERY_INT_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "nodes.h" +#include "plannodes.h" +#include "ttime.h" + +#define EXPLAIN_MAX_GROUP_NUM 100 + +//newline area +#define EXPLAIN_TAG_SCAN_FORMAT "Tag Scan on %s columns=%d width=%d" +#define EXPLAIN_TBL_SCAN_FORMAT "Table Scan on %s columns=%d width=%d" +#define EXPLAIN_SYSTBL_SCAN_FORMAT "System Table Scan on %s columns=%d width=%d" +#define EXPLAIN_PROJECTION_FORMAT "Projection columns=%d width=%d" +#define EXPLAIN_JOIN_FORMAT "%s between %d tables width=%d" +#define EXPLAIN_AGG_FORMAT "Aggragate functions=%d" +#define EXPLAIN_EXCHANGE_FORMAT "Data Exchange %d:1 width=%d" +#define EXPLAIN_SORT_FORMAT "Sort on %d Column(s) width=%d" +#define EXPLAIN_INTERVAL_FORMAT "Interval on Column %s functions=%d interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c width=%d" +#define EXPLAIN_SESSION_FORMAT "Session gap=%" PRId64 " functions=%d width=%d" +#define EXPLAIN_ORDER_FORMAT "Order: %s" +#define EXPLAIN_FILTER_FORMAT "Filter: " +#define EXPLAIN_FILL_FORMAT "Fill: %s" +#define EXPLAIN_ON_CONDITIONS_FORMAT "Join Cond: " +#define EXPLAIN_TIMERANGE_FORMAT "Time Range: [%" PRId64 ", %" PRId64 "]" + +//append area +#define EXPLAIN_GROUPS_FORMAT " groups=%d" +#define EXPLAIN_WIDTH_FORMAT " width=%d" +#define EXPLAIN_LOOPS_FORMAT " loops=%d" +#define EXPLAIN_REVERSE_FORMAT " reverse=%d" + +typedef struct SExplainGroup { + int32_t nodeNum; + SSubplan *plan; + void *execInfo; //TODO +} SExplainGroup; + +typedef struct SExplainResNode { + SNodeList* pChildren; + SPhysiNode* pNode; + void* pExecInfo; +} SExplainResNode; + +typedef struct SQueryExplainRowInfo { + int32_t level; + int32_t len; + char *buf; +} SQueryExplainRowInfo; + +typedef struct SExplainCtx { + int32_t totalSize; + bool verbose; + char *tbuf; + SArray *rows; + SHashObj *groupHash; +} SExplainCtx; + +#define EXPLAIN_ORDER_STRING(_order) ((TSDB_ORDER_ASC == _order) ? "Ascending" : "Descending") +#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join") + +#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u))) + +#define EXPLAIN_ROW_NEW(level, ...) \ + do { \ + if (isVerboseLine) { \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \ + } else { \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \ + } \ + tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \ + } while (0) + +#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__) +#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_QUERY_INT_H_*/ diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c new file mode 100644 index 0000000000..7ffbd4f80a --- /dev/null +++ b/source/libs/command/src/command.c @@ -0,0 +1,115 @@ +/* + * 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 "command.h" +#include "tdatablock.h" + +// #define SET_VARSTR(pData, val, pOffset) + +static void buildRspData(const STableMeta* pMeta, char* pData) { + int32_t* pColSizes = (int32_t*)pData; + pData += DESCRIBE_RESULT_COLS * sizeof(int32_t); + int32_t numOfRows = TABLE_TOTAL_COL_NUM(pMeta); + + // Field + int32_t* pOffset = (int32_t*)pData; + pData += numOfRows * sizeof(int32_t); + for (int32_t i = 0; i < numOfRows; ++i) { + STR_TO_VARSTR(pData, pMeta->schema[i].name); + int16_t len = varDataTLen(pData); + pData += len; + *pOffset = pColSizes[0]; + pOffset += 1; + pColSizes[0] += len; + } + + // Type + pOffset = (int32_t*)pData; + pData += numOfRows * sizeof(int32_t); + for (int32_t i = 0; i < numOfRows; ++i) { + STR_TO_VARSTR(pData, tDataTypes[pMeta->schema[i].type].name); + int16_t len = varDataTLen(pData); + pData += len; + *pOffset = pColSizes[1]; + pOffset += 1; + pColSizes[1] += len; + } + + // Length + pData += BitmapLen(numOfRows); + for (int32_t i = 0; i < numOfRows; ++i) { + *(int32_t*)pData = pMeta->schema[i].bytes; + pData += sizeof(int32_t); + } + pColSizes[2] = sizeof(int32_t) * numOfRows; + + // Note + pOffset = (int32_t*)pData; + pData += numOfRows * sizeof(int32_t); + for (int32_t i = 0; i < numOfRows; ++i) { + STR_TO_VARSTR(pData, i >= pMeta->tableInfo.numOfColumns ? "TAG" : ""); + int16_t len = varDataTLen(pData); + pData += len; + *pOffset = pColSizes[3]; + pOffset += 1; + pColSizes[3] += len; + } + + for (int32_t i = 0; i < DESCRIBE_RESULT_COLS; ++i) { + pColSizes[i] = htonl(pColSizes[i]); + } +} + +static int32_t calcRspSize(const STableMeta* pMeta) { + int32_t numOfRows = TABLE_TOTAL_COL_NUM(pMeta); + return sizeof(SRetrieveTableRsp) + + (numOfRows * sizeof(int32_t) + numOfRows * DESCRIBE_RESULT_FIELD_LEN) + + (numOfRows * sizeof(int32_t) + numOfRows * DESCRIBE_RESULT_TYPE_LEN) + + (BitmapLen(numOfRows) + numOfRows * sizeof(int32_t)) + + (numOfRows * sizeof(int32_t) + numOfRows * DESCRIBE_RESULT_NOTE_LEN); +} + +static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) { + SDescribeStmt* pDesc = (SDescribeStmt*)pStmt; + *pRsp = taosMemoryCalloc(1, calcRspSize(pDesc->pMeta)); + if (NULL == *pRsp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htonl(TABLE_TOTAL_COL_NUM(pDesc->pMeta)); + buildRspData(pDesc->pMeta, (*pRsp)->data); + return TSDB_CODE_SUCCESS; +} + +static int32_t execResetQueryCache() { + // todo + return TSDB_CODE_SUCCESS; +} + +int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) { + switch (nodeType(pStmt)) { + case QUERY_NODE_DESCRIBE_STMT: + return execDescribe(pStmt, pRsp); + case QUERY_NODE_RESET_QUERY_CACHE_STMT: + return execResetQueryCache(); + default: + break; + } + return TSDB_CODE_FAILED; +} diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c new file mode 100644 index 0000000000..847a863e76 --- /dev/null +++ b/source/libs/command/src/explain.c @@ -0,0 +1,687 @@ +/* + * 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 "query.h" +#include "plannodes.h" +#include "commandInt.h" + +int32_t qGenerateExplainResNode(SPhysiNode *pNode, void *pExecInfo, SExplainResNode **pRes); +int32_t qAppendTaskExplainResRows(void *pCtx, int32_t groupId, int32_t level); + + +void qFreeExplainResTree(SExplainResNode *res) { + if (NULL == res) { + return; + } + + taosMemoryFreeClear(res->pExecInfo); + + SNode* node = NULL; + FOREACH(node, res->pChildren) { + qFreeExplainResTree((SExplainResNode *)node); + } + nodesClearList(res->pChildren); + + taosMemoryFreeClear(res); +} + +void qFreeExplainCtx(void *ctx) { + if (NULL == ctx) { + return; + } + + SExplainCtx *pCtx = (SExplainCtx *)ctx; + int32_t rowSize = taosArrayGetSize(pCtx->rows); + for (int32_t i = 0; i < rowSize; ++i) { + SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i); + taosMemoryFreeClear(row->buf); + } + + taosHashCleanup(pCtx->groupHash); + taosArrayDestroy(pCtx->rows); + taosMemoryFree(pCtx); +} + +int32_t qInitExplainCtx(void **pCtx, SHashObj *groupHash, bool verbose) { + int32_t code = 0; + SExplainCtx *ctx = taosMemoryCalloc(1, sizeof(SExplainCtx)); + if (NULL == ctx) { + qError("calloc SExplainCtx failed"); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + SArray *rows = taosArrayInit(10, sizeof(SQueryExplainRowInfo)); + if (NULL == rows) { + qError("taosArrayInit SQueryExplainRowInfo failed"); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + char *tbuf = taosMemoryMalloc(TSDB_EXPLAIN_RESULT_ROW_SIZE); + if (NULL == tbuf) { + qError("malloc size %d failed", TSDB_EXPLAIN_RESULT_ROW_SIZE); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + ctx->verbose = verbose; + ctx->tbuf = tbuf; + ctx->rows = rows; + ctx->groupHash = groupHash; + + *pCtx = ctx; + + return TSDB_CODE_SUCCESS; + +_return: + + taosArrayDestroy(rows); + taosHashCleanup(groupHash); + taosMemoryFree(ctx); + + QRY_RET(code); +} + + +char *qFillModeString(EFillMode mode) { + switch (mode) { + case FILL_MODE_NONE: + return "none"; + case FILL_MODE_VALUE: + return "value"; + case FILL_MODE_PREV: + return "prev"; + case FILL_MODE_NULL: + return "null"; + case FILL_MODE_LINEAR: + return "linear"; + case FILL_MODE_NEXT: + return "next"; + default: + return "unknown"; + } +} + +char *qGetNameFromColumnNode(SNode *pNode) { + if (NULL == pNode || QUERY_NODE_COLUMN != pNode->type) { + return "NULL"; + } + + return ((SColumnNode *)pNode)->colName; +} + +int32_t qGenerateExplainResChildren(SPhysiNode *pNode, void *pExecInfo, SNodeList **pChildren) { + int32_t tlen = 0; + SNodeList *pPhysiChildren = NULL; + + switch (pNode->type) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: { + STagScanPhysiNode *pTagScanNode = (STagScanPhysiNode *)pNode; + pPhysiChildren = pTagScanNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{ + STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode; + pPhysiChildren = pTblScanNode->scan.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{ + SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode; + pPhysiChildren = pSTblScanNode->scan.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{ + SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode; + pPhysiChildren = pPrjNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_JOIN:{ + SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode; + pPhysiChildren = pJoinNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode; + pPhysiChildren = pAggNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{ + SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode; + pPhysiChildren = pExchNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SORT:{ + SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode; + pPhysiChildren = pSortNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; + pPhysiChildren = pIntNode->window.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{ + SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode; + pPhysiChildren = pSessNode->window.node.pChildren; + break; + } + default: + qError("not supported physical node type %d", pNode->type); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (pPhysiChildren) { + *pChildren = nodesMakeList(); + if (NULL == *pChildren) { + qError("nodesMakeList failed"); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + } + + SNode* node = NULL; + SExplainResNode *pResNode = NULL; + FOREACH(node, pPhysiChildren) { + QRY_ERR_RET(qGenerateExplainResNode((SPhysiNode *)node, pExecInfo, &pResNode)); + QRY_ERR_RET(nodesListAppend(*pChildren, pResNode)); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t qGenerateExplainResNode(SPhysiNode *pNode, void *pExecInfo, SExplainResNode **pRes) { + if (NULL == pNode) { + *pRes = NULL; + qError("physical node is NULL"); + return TSDB_CODE_QRY_APP_ERROR; + } + + SExplainResNode *res = taosMemoryCalloc(1, sizeof(SExplainResNode)); + if (NULL == res) { + qError("calloc SPhysiNodeExplainRes failed"); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + int32_t code = 0; + res->pNode = pNode; + res->pExecInfo = pExecInfo; + QRY_ERR_JRET(qGenerateExplainResChildren(pNode, pExecInfo, &res->pChildren)); + + *pRes = res; + + return TSDB_CODE_SUCCESS; + +_return: + + qFreeExplainResTree(res); + + QRY_RET(code); +} + +int32_t qExplainBufAppendExecInfo(void *pExecInfo, char *tbuf, int32_t *len) { + int32_t tlen = *len; + + EXPLAIN_ROW_APPEND("(exec info here)"); + + *len = tlen; + + return TSDB_CODE_SUCCESS; +} + +int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t level) { + SQueryExplainRowInfo row = {0}; + row.buf = taosMemoryMalloc(len); + if (NULL == row.buf) { + qError("taosMemoryMalloc %d failed", len); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + memcpy(row.buf, tbuf, len); + row.level = level; + row.len = len; + ctx->totalSize += len; + + if (NULL == taosArrayPush(ctx->rows, &row)) { + qError("taosArrayPush row to explain res rows failed"); + taosMemoryFree(row.buf); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { + int32_t tlen = 0; + bool isVerboseLine = false; + char *tbuf = ctx->tbuf; + bool verbose = ctx->verbose; + SPhysiNode* pNode = pResNode->pNode; + if (NULL == pNode) { + qError("pyhsical node in explain res node is NULL"); + return TSDB_CODE_QRY_APP_ERROR; + } + + switch (pNode->type) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: { + STagScanPhysiNode *pTagScanNode = (STagScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_TAG_SCAN_FORMAT, pTagScanNode->tableName.tname, pTagScanNode->pScanCols->length, pTagScanNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pTagScanNode->count); + if (pTagScanNode->reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pTagScanNode->reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pTagScanNode->order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{ + STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_TBL_SCAN_FORMAT, pTblScanNode->scan.tableName.tname, pTblScanNode->scan.pScanCols->length, pTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pTblScanNode->scan.count); + if (pTblScanNode->scan.reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pTblScanNode->scan.reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pTblScanNode->scan.order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey, pTblScanNode->scanRange.ekey); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + if (pTblScanNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{ + SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SYSTBL_SCAN_FORMAT, pSTblScanNode->scan.tableName.tname, pSTblScanNode->scan.pScanCols->length, pSTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pSTblScanNode->scan.count); + if (pSTblScanNode->scan.reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pSTblScanNode->scan.reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pSTblScanNode->scan.order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + if (pSTblScanNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pSTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{ + SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_PROJECTION_FORMAT, pPrjNode->pProjections->length, pPrjNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pPrjNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pPrjNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_JOIN:{ + SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_JOIN_FORMAT, EXPLAIN_JOIN_STRING(pJoinNode->joinType), pJoinNode->pTargets->length, pJoinNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pJoinNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pJoinNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ON_CONDITIONS_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_AGG_FORMAT, pAggNode->pAggFuncs->length); + if (pAggNode->pGroupKeys) { + EXPLAIN_ROW_APPEND(EXPLAIN_GROUPS_FORMAT, pAggNode->pGroupKeys->length); + } + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pAggNode->node.pOutputDataBlockDesc->outputRowSize); + + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pAggNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pAggNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{ + SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode; + SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcGroupId, sizeof(pExchNode->srcGroupId)); + if (NULL == group) { + qError("exchange src group %d not in groupHash", pExchNode->srcGroupId); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + EXPLAIN_ROW_NEW(level, EXPLAIN_EXCHANGE_FORMAT, group->nodeNum, pExchNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pExchNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pExchNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + + QRY_ERR_RET(qAppendTaskExplainResRows(ctx, pExchNode->srcGroupId, level + 1)); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SORT:{ + SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SORT_FORMAT, pSortNode->pSortKeys->length, pSortNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pSortNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pSortNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, qGetNameFromColumnNode(pIntNode->pTspk), pIntNode->window.pFuncs->length, + INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, pIntNode->precision), pIntNode->intervalUnit, + pIntNode->offset, getPrecisionUnit(pIntNode->precision), + INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, pIntNode->precision), pIntNode->slidingUnit, + pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pIntNode->pFill) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILL_FORMAT, qFillModeString(pIntNode->pFill->mode)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + if (pIntNode->window.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{ + SSessionWinodwPhysiNode *pIntNode = (SSessionWinodwPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SESSION_FORMAT, pIntNode->gap, pIntNode->window.pFuncs->length, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pIntNode->window.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + default: + qError("not supported physical node type %d", pNode->type); + return TSDB_CODE_QRY_APP_ERROR; + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { + if (NULL == pResNode) { + qError("explain res node is NULL"); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + int32_t code = 0; + QRY_ERR_RET(qExplainResNodeToRowsImpl(pResNode, ctx, level)); + + SNode* pNode = NULL; + FOREACH(pNode, pResNode->pChildren) { + QRY_ERR_RET(qExplainResNodeToRows((SExplainResNode *)pNode, ctx, level + 1)); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t qAppendTaskExplainResRows(void *pCtx, int32_t groupId, int32_t level) { + SExplainResNode *node = NULL; + int32_t code = 0; + SExplainCtx *ctx = (SExplainCtx *)pCtx; + + SExplainGroup *group = taosHashGet(ctx->groupHash, &groupId, sizeof(groupId)); + if (NULL == group) { + qError("group %d not in groupHash", groupId); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + QRY_ERR_RET(qGenerateExplainResNode(group->plan->pNode, group->execInfo, &node)); + + QRY_ERR_JRET(qExplainResNodeToRows(node, ctx, level)); + +_return: + + qFreeExplainResTree(node); + + QRY_RET(code); +} + + +int32_t qGetExplainRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { + SExplainCtx *pCtx = (SExplainCtx *)ctx; + int32_t rowNum = taosArrayGetSize(pCtx->rows); + if (rowNum <= 0) { + qError("empty explain res rows"); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + int32_t colNum = 1; + int32_t rspSize = sizeof(SRetrieveTableRsp) + sizeof(int32_t) * colNum + sizeof(int32_t) * rowNum + pCtx->totalSize; + SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, rspSize); + if (NULL == rsp) { + qError("malloc SRetrieveTableRsp failed, size:%d", rspSize); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + rsp->completed = 1; + rsp->numOfRows = htonl(rowNum); + + *(int32_t *)rsp->data = htonl(pCtx->totalSize); + + int32_t *offset = (int32_t *)((char *)rsp->data + sizeof(int32_t)); + char *data = (char *)(offset + rowNum); + int32_t tOffset = 0; + + for (int32_t i = 0; i < rowNum; ++i) { + SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i); + *offset = tOffset; + tOffset += row->len; + + memcpy(data, row->buf, row->len); + + ++offset; + data += row->len; + } + + *pRsp = rsp; + + return TSDB_CODE_SUCCESS; +} + +int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) { + int32_t code = 0; + SNodeListNode *plans = NULL; + int32_t taskNum = 0; + SExplainGroup *pGroup = NULL; + void *pCtx = NULL; + int32_t rootGroupId = 0; + + if (pDag->numOfSubplans <= 0) { + qError("invalid subplan num:%d", pDag->numOfSubplans); + QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + int32_t levelNum = (int32_t)LIST_LENGTH(pDag->pSubplans); + if (levelNum <= 0) { + qError("invalid level num:%d", levelNum); + QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + SHashObj *groupHash = taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == groupHash) { + qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + QRY_ERR_JRET(qInitExplainCtx(&pCtx, groupHash, pDag->explainInfo.verbose)); + + for (int32_t i = 0; i < levelNum; ++i) { + plans = (SNodeListNode *)nodesListGetNode(pDag->pSubplans, i); + if (NULL == plans) { + qError("empty level plan, level:%d", i); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + taskNum = (int32_t)LIST_LENGTH(plans->pNodeList); + if (taskNum <= 0) { + qError("invalid level plan number:%d, level:%d", taskNum, i); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + SSubplan *plan = NULL; + for (int32_t n = 0; n < taskNum; ++n) { + plan = (SSubplan *)nodesListGetNode(plans->pNodeList, n); + pGroup = taosHashGet(groupHash, &plan->id.groupId, sizeof(plan->id.groupId)); + if (pGroup) { + ++pGroup->nodeNum; + continue; + } + + SExplainGroup group = {.nodeNum = 1, .plan = plan, .execInfo = NULL}; + if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) { + qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + } + + if (0 == i) { + if (taskNum > 1) { + qError("invalid taskNum %d for level 0", taskNum); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + rootGroupId = plan->id.groupId; + } + + qDebug("level %d group handled, taskNum:%d", i, taskNum); + } + + QRY_ERR_JRET(qAppendTaskExplainResRows(pCtx, rootGroupId, 0)); + + QRY_ERR_JRET(qGetExplainRspFromCtx(pCtx, pRsp)); + +_return: + + qFreeExplainCtx(pCtx); + + QRY_RET(code); +} + + + diff --git a/source/libs/command/test/CMakeLists.txt b/source/libs/command/test/CMakeLists.txt new file mode 100644 index 0000000000..6d2335d2e3 --- /dev/null +++ b/source/libs/command/test/CMakeLists.txt @@ -0,0 +1,18 @@ +MESSAGE(STATUS "build command unit test") + +# GoogleTest requires at least C++11 +SET(CMAKE_CXX_STANDARD 11) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) + +ADD_EXECUTABLE(commandTest ${SOURCE_LIST}) + +TARGET_INCLUDE_DIRECTORIES( + commandTest + PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/command/" + PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/command/inc" +) + +TARGET_LINK_LIBRARIES( + commandTest + PUBLIC os util common nodes parser catalog transport gtest function qcom +) \ No newline at end of file diff --git a/source/libs/command/test/commandTest.cpp b/source/libs/command/test/commandTest.cpp new file mode 100644 index 0000000000..59118c501a --- /dev/null +++ b/source/libs/command/test/commandTest.cpp @@ -0,0 +1,21 @@ +/* + * 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 + +int main(int argc, char* argv[]) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index bcbfeb7015..3faf208c0e 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -73,27 +73,12 @@ typedef struct SResultRowPosition { } SResultRowPosition; typedef struct SResultRowInfo { - SList *pRows; SResultRowPosition *pPosition; - SResultRow **pResult; // result list int32_t size; // number of result set int32_t capacity; // max capacity int32_t curPos; // current active result row index of pResult list } SResultRowInfo; -typedef struct SResultRowPool { - int32_t elemSize; - int32_t blockSize; - int32_t numOfElemPerBlock; - - struct { - int32_t blockIndex; - int32_t pos; - } position; - - SArray* pData; // SArray -} SResultRowPool; - struct STaskAttr; struct STaskRuntimeEnv; struct SUdfInfo; @@ -109,25 +94,33 @@ void resetResultRowInfo(struct STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* int32_t numOfClosedResultRows(SResultRowInfo* pResultRowInfo); void closeAllResultRows(SResultRowInfo* pResultRowInfo); -int32_t initResultRow(SResultRow *pResultRow); -void closeResultRow(SResultRowInfo* pResultRowInfo, int32_t slot); -bool isResultRowClosed(SResultRowInfo *pResultRowInfo, int32_t slot); -void clearResultRow(struct STaskRuntimeEnv* pRuntimeEnv, SResultRow* pResultRow); +void initResultRow(SResultRow *pResultRow); +void closeResultRow(SResultRow* pResultRow); +bool isResultRowClosed(SResultRow* pResultRow); struct SResultRowEntryInfo* getResultCell(const SResultRow* pRow, int32_t index, int32_t* offset); -void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr); int32_t getRowNumForMultioutput(struct STaskAttr* pQueryAttr, bool topBottomQuery, bool stable); -static FORCE_INLINE SResultRow *getResultRow(SResultRowInfo *pResultRowInfo, int32_t slot) { - assert(pResultRowInfo != NULL && slot >= 0 && slot < pResultRowInfo->size); - return pResultRowInfo->pResult[slot]; +static FORCE_INLINE SResultRow *getResultRow(SDiskbasedBuf* pBuf, SResultRowInfo *pResultRowInfo, int32_t slot) { + ASSERT(pResultRowInfo != NULL && slot >= 0 && slot < pResultRowInfo->size); + SResultRowPosition* pos = &pResultRowInfo->pPosition[slot]; + + SFilePage* bufPage = (SFilePage*) getBufPage(pBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset); + return pRow; +} + +static FORCE_INLINE SResultRow *getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos) { + SFilePage* bufPage = (SFilePage*) getBufPage(pBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset); + return pRow; } static FORCE_INLINE char* getPosInResultPage(struct STaskAttr* pQueryAttr, SFilePage* page, int32_t rowOffset, int32_t offset) { assert(rowOffset >= 0 && pQueryAttr != NULL); - + ASSERT(0); // int32_t numOfRows = (int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery); // return ((char *)page->data) + rowOffset + offset * numOfRows; } @@ -139,23 +132,14 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs return (char*) page + rowOffset + offset * numOfRows; } -//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); -//bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); - -__filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr); - -SResultRow* getNewResultRow(SResultRowPool* p); - typedef struct { SArray* pResult; // SArray int32_t colId; } SStddevInterResult; -void interResToBinary(SBufferWriter* bw, SArray* pRes, int32_t tagLen); -SArray* interResFromBinary(const char* data, int32_t len); -void freeInterResult(void* param); - void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo); +void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); + void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo); bool hasRemainDataInCurrentGroup(SGroupResInfo* pGroupResInfo); bool hasRemainData(SGroupResInfo* pGroupResInfo); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 1d7023930d..287cb094a6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -69,7 +69,7 @@ enum { typedef struct SResultRowCell { uint64_t groupId; - SResultRow* pRow; + SResultRowPosition pos; } SResultRowCell; /** @@ -277,8 +277,6 @@ typedef struct STaskRuntimeEnv { char* keyBuf; // window key buffer // The window result objects pool, all the resultRow Objects are allocated and managed by this object. char** prevRow; - SResultRowPool* pool; - SArray* prevResult; // intermediate result, SArray STSBuf* pTsBuf; // timestamp filter list STSCursor cur; @@ -364,6 +362,7 @@ typedef struct SSourceDataInfo { int32_t index; SRetrieveTableRsp *pRsp; uint64_t totalRows; + int32_t code; EX_SOURCE_STATUS status; } SSourceDataInfo; @@ -422,6 +421,7 @@ typedef struct SStreamBlockScanInfo { uint64_t numOfRows; // total scanned rows uint64_t numOfExec; // execution times void* readerHandle; // stream block reader handle + SArray* pColMatchInfo; // } SStreamBlockScanInfo; typedef struct SSysTableScanInfo { diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 2c6468a13f..40e86c7840 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -53,15 +53,13 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) { int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) { pResultRowInfo->size = 0; - pResultRowInfo->curPos = -1; + pResultRowInfo->curPos = -1; pResultRowInfo->capacity = size; - - pResultRowInfo->pResult = taosMemoryCalloc(pResultRowInfo->capacity, POINTER_BYTES); pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition)); - if (pResultRowInfo->pResult == NULL || pResultRowInfo->pPosition == NULL) { + + if (pResultRowInfo->pPosition == NULL) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } - return TSDB_CODE_SUCCESS; } @@ -71,17 +69,17 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) { } if (pResultRowInfo->capacity == 0) { - assert(pResultRowInfo->pResult == NULL); +// assert(pResultRowInfo->pResult == NULL); return; } for(int32_t i = 0; i < pResultRowInfo->size; ++i) { - if (pResultRowInfo->pResult[i]) { - taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); - } +// if (pResultRowInfo->pResult[i]) { +// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); +// } } - taosMemoryFreeClear(pResultRowInfo->pResult); + taosMemoryFreeClear(pResultRowInfo->pPosition); } void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo) { @@ -90,8 +88,8 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow } for (int32_t i = 0; i < pResultRowInfo->size; ++i) { - SResultRow *pWindowRes = pResultRowInfo->pResult[i]; - clearResultRow(pRuntimeEnv, pWindowRes); +// SResultRow *pWindowRes = pResultRowInfo->pResult[i]; +// clearResultRow(pRuntimeEnv, pWindowRes); int32_t groupIndex = 0; int64_t uid = 0; @@ -101,14 +99,13 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow } pResultRowInfo->size = 0; - pResultRowInfo->curPos = -1; } int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) { int32_t i = 0; - while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) { - ++i; - } +// while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) { +// ++i; +// } return i; } @@ -117,21 +114,22 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) { assert(pResultRowInfo->size >= 0 && pResultRowInfo->capacity >= pResultRowInfo->size); for (int32_t i = 0; i < pResultRowInfo->size; ++i) { - SResultRow* pRow = pResultRowInfo->pResult[i]; - if (pRow->closed) { - continue; - } +// ASSERT(0); +// SResultRow* pRow = pResultRowInfo->pResult[i]; +// if (pRow->closed) { +// continue; +// } - pRow->closed = true; +// pRow->closed = true; } } -bool isResultRowClosed(SResultRowInfo *pResultRowInfo, int32_t slot) { - return (getResultRow(pResultRowInfo, slot)->closed == true); +bool isResultRowClosed(SResultRow* pRow) { + return (pRow->closed == true); } -void closeResultRow(SResultRowInfo *pResultRowInfo, int32_t slot) { - getResultRow(pResultRowInfo, slot)->closed = true; +void closeResultRow(SResultRow* pResultRow) { + pResultRow->closed = true; } void clearResultRow(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow) { @@ -181,29 +179,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { return rowSize; } -SResultRow* getNewResultRow(SResultRowPool* p) { - if (p == NULL) { - return NULL; - } - - void* ptr = NULL; - if (p->position.pos == 0) { - ptr = taosMemoryCalloc(1, p->blockSize); - taosArrayPush(p->pData, &ptr); - - } else { - size_t last = taosArrayGetSize(p->pData); - - void** pBlock = taosArrayGet(p->pData, last - 1); - ptr = ((char*) (*pBlock)) + p->elemSize * p->position.pos; - } - - p->position.pos = (p->position.pos + 1)%p->numOfElemPerBlock; - initResultRow(ptr); - - return ptr; -} - void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { assert(pGroupResInfo != NULL); @@ -222,6 +197,16 @@ void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo) assert(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); } +void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) { + if (pGroupResInfo->pRows != NULL) { + taosArrayDestroy(pGroupResInfo->pRows); + } + + pGroupResInfo->pRows = pArrayList; + pGroupResInfo->index = 0; + ASSERT(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); +} + bool hasRemainDataInCurrentGroup(SGroupResInfo* pGroupResInfo) { if (pGroupResInfo->pRows == NULL) { return false; @@ -251,8 +236,9 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { return (int32_t) taosArrayGetSize(pGroupResInfo->pRows); } -static int64_t getNumOfResultWindowRes(STaskRuntimeEnv* pRuntimeEnv, SResultRow *pResultRow, int32_t* rowCellInfoOffset) { +static int64_t getNumOfResultWindowRes(STaskRuntimeEnv* pRuntimeEnv, SResultRowPosition *pos, int32_t* rowCellInfoOffset) { STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; + ASSERT(0); for (int32_t j = 0; j < pQueryAttr->numOfOutput; ++j) { int32_t functionId = 0;//pQueryAttr->pExpr1[j].base.functionId; @@ -295,25 +281,26 @@ static int32_t tableResultComparFn(const void *pLeft, const void *pRight, void * return -1; } + ASSERT(0); STableQueryInfo** pList = supporter->pTableQueryInfo; - SResultRow* pWindowRes1 = pList[left]->resInfo.pResult[leftPos]; +// SResultRow* pWindowRes1 = pList[left]->resInfo.pResult[leftPos]; // SResultRow * pWindowRes1 = getResultRow(&(pList[left]->resInfo), leftPos); - TSKEY leftTimestamp = pWindowRes1->win.skey; +// TSKEY leftTimestamp = pWindowRes1->win.skey; // SResultRowInfo *pWindowResInfo2 = &(pList[right]->resInfo); // SResultRow * pWindowRes2 = getResultRow(pWindowResInfo2, rightPos); - SResultRow* pWindowRes2 = pList[right]->resInfo.pResult[rightPos]; - TSKEY rightTimestamp = pWindowRes2->win.skey; +// SResultRow* pWindowRes2 = pList[right]->resInfo.pResult[rightPos]; +// TSKEY rightTimestamp = pWindowRes2->win.skey; - if (leftTimestamp == rightTimestamp) { +// if (leftTimestamp == rightTimestamp) { return 0; - } +// } - if (supporter->order == TSDB_ORDER_ASC) { - return (leftTimestamp > rightTimestamp)? 1:-1; - } else { - return (leftTimestamp < rightTimestamp)? 1:-1; - } +// if (supporter->order == TSDB_ORDER_ASC) { +// return (leftTimestamp > rightTimestamp)? 1:-1; +// } else { +// return (leftTimestamp < rightTimestamp)? 1:-1; +// } } int32_t tsAscOrder(const void* p1, const void* p2) { @@ -321,11 +308,12 @@ int32_t tsAscOrder(const void* p1, const void* p2) { SResultRowCell* pc2 = (SResultRowCell*) p2; if (pc1->groupId == pc2->groupId) { - if (pc1->pRow->win.skey == pc2->pRow->win.skey) { - return 0; - } else { - return (pc1->pRow->win.skey < pc2->pRow->win.skey)? -1:1; - } + ASSERT(0); +// if (pc1->pRow->win.skey == pc2->pRow->win.skey) { +// return 0; +// } else { +// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? -1:1; +// } } else { return (pc1->groupId < pc2->groupId)? -1:1; } @@ -336,11 +324,12 @@ int32_t tsDescOrder(const void* p1, const void* p2) { SResultRowCell* pc2 = (SResultRowCell*) p2; if (pc1->groupId == pc2->groupId) { - if (pc1->pRow->win.skey == pc2->pRow->win.skey) { - return 0; - } else { - return (pc1->pRow->win.skey < pc2->pRow->win.skey)? 1:-1; - } + ASSERT(0); +// if (pc1->pRow->win.skey == pc2->pRow->win.skey) { +// return 0; +// } else { +// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? 1:-1; +// } } else { return (pc1->groupId < pc2->groupId)? -1:1; } @@ -374,13 +363,13 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe break; } - int64_t num = getNumOfResultWindowRes(pRuntimeEnv, pResultRowCell->pRow, rowCellInfoOffset); + int64_t num = getNumOfResultWindowRes(pRuntimeEnv, &pResultRowCell->pos, rowCellInfoOffset); if (num <= 0) { continue; } - taosArrayPush(pGroupResInfo->pRows, &pResultRowCell->pRow); - pResultRowCell->pRow->numOfRows = (uint32_t) num; + taosArrayPush(pGroupResInfo->pRows, &pResultRowCell->pos); +// pResultRowCell->pRow->numOfRows = (uint32_t) num; } return TSDB_CODE_SUCCESS; @@ -439,9 +428,10 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv int32_t tableIndex = tMergeTreeGetChosenIndex(pTree); SResultRowInfo *pWindowResInfo = &pTableQueryInfoList[tableIndex]->resInfo; - SResultRow *pWindowRes = getResultRow(pWindowResInfo, cs.rowIndex[tableIndex]); + ASSERT(0); + SResultRow *pWindowRes = NULL;//getResultRow(pBuf, pWindowResInfo, cs.rowIndex[tableIndex]); - int64_t num = getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset); + int64_t num = 0;//getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset); if (num <= 0) { cs.rowIndex[tableIndex] += 1; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2df18f135c..54a75d9c7e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -352,7 +352,7 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) { continue; } - idata.info.type = pDescNode->dataType.type; + idata.info.type = pDescNode->dataType.type; idata.info.bytes = pDescNode->dataType.bytes; idata.info.scale = pDescNode->dataType.scale; idata.info.slotId = pDescNode->slotId; @@ -426,18 +426,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, jmp_buf env) newCapacity += 4; } - char* t = taosMemoryRealloc(pResultRowInfo->pResult, (size_t)(newCapacity * POINTER_BYTES)); - if (t == NULL) { - longjmp(env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - pResultRowInfo->pPosition = taosMemoryRealloc(pResultRowInfo->pPosition, newCapacity * sizeof(SResultRowPosition)); - pResultRowInfo->pResult = (SResultRow**)t; int32_t inc = (int32_t)newCapacity - pResultRowInfo->capacity; - memset(&pResultRowInfo->pResult[pResultRowInfo->capacity], 0, POINTER_BYTES * inc); memset(&pResultRowInfo->pPosition[pResultRowInfo->capacity], 0, sizeof(SResultRowPosition)); - pResultRowInfo->capacity = (int32_t)newCapacity; } @@ -458,9 +450,8 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR if (p1 != NULL) { if (pResultRowInfo->size == 0) { existed = false; - assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); +// existed = (pResultRowInfo->pResult[0] == (*p1)); } else { // check if current pResultRowInfo contains the existed pResultRow SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid, pResultRowInfo); int64_t* index = @@ -479,6 +470,7 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR return p1 != NULL; } +#if 0 static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) { bool existed = false; @@ -496,16 +488,16 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR if (p1 != NULL) { if (pResultRowInfo->size == 0) { existed = false; - assert(pResultRowInfo->curPos == -1); +// assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); - pResultRowInfo->curPos = 0; +// existed = (pResultRowInfo->pResult[0] == (*p1)); +// pResultRowInfo->curPos = 0; } else { // check if current pResultRowInfo contains the existed pResultRow SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo); int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); if (index != NULL) { - pResultRowInfo->curPos = (int32_t)*index; +// pResultRowInfo->curPos = (int32_t)*index; existed = true; } else { existed = false; @@ -555,6 +547,7 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR return pResultRowInfo->pResult[pResultRowInfo->curPos]; } +#endif SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize) { SFilePage* pData = NULL; @@ -599,65 +592,75 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) { - bool existed = false; + bool existInCurrentResusltRowInfo = false; SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, tableGroupId); - SResultRow** p1 = (SResultRow**)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); + SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); // in case of repeat scan/reverse scan, no new time window added. if (isIntervalQuery) { if (!masterscan) { // the *p1 may be NULL in case of sliding+offset exists. - return (p1 != NULL) ? *p1 : NULL; + if (p1 != NULL) { + return getResultRowByPos(pResultBuf, p1); + } else { + return NULL; + } } if (p1 != NULL) { if (pResultRowInfo->size == 0) { - existed = false; + existInCurrentResusltRowInfo = false; // this time window created by other timestamp that does not belongs to current table. assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); - pResultRowInfo->curPos = 0; - } else { // check if current pResultRowInfo contains the existed pResultRow + ASSERT(0); +// existInCurrentResusltRowInfo = (pResultRowInfo->pResult[0] == (*p1)); + } else { // check if current pResultRowInfo contains the existInCurrentResusltRowInfo pResultRow SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); int64_t* index = taosHashGet(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); if (index != NULL) { - pResultRowInfo->curPos = (int32_t)*index; - existed = true; + // TODO check the scan order for current opened time window +// pResultRowInfo->curPos = (int32_t)*index; + existInCurrentResusltRowInfo = true; } else { - existed = false; + existInCurrentResusltRowInfo = false; } } } } else { - // In case of group by column query, the required SResultRow object must be existed in the pResultRowInfo object. + // In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the pResultRowInfo object. if (p1 != NULL) { - return *p1; + return getResultRowByPos(pResultBuf, p1); } } - if (!existed) { - prepareResultListBuffer(pResultRowInfo, pTaskInfo->env); - - SResultRow* pResult = NULL; - if (p1 == NULL) { - pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); - int32_t ret = initResultRow(pResult); - if (ret != TSDB_CODE_SUCCESS) { - longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - // add a new result set for a new group - taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pResult, POINTER_BYTES); - SResultRowCell cell = {.groupId = tableGroupId, .pRow = pResult}; - taosArrayPush(pSup->pResultRowArrayList, &cell); - } else { - pResult = *p1; + SResultRow* pResult = NULL; + if (!existInCurrentResusltRowInfo) { + // 1. close current opened time window + if (pResultRowInfo->curPos != -1) { // todo extract function + SResultRowPosition* pos = &pResultRowInfo->pPosition[pResultRowInfo->curPos]; + SFilePage* pPage = getBufPage(pResultBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); + closeResultRow(pRow); + releaseBufPage(pResultBuf, pPage); } + prepareResultListBuffer(pResultRowInfo, pTaskInfo->env); + if (p1 == NULL) { + pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); + initResultRow(pResult); + + // add a new result set for a new group + SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; + taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, POINTER_BYTES); + SResultRowCell cell = {.groupId = tableGroupId, .pos = pos}; + taosArrayPush(pSup->pResultRowArrayList, &cell); + } else { + pResult = getResultRowByPos(pResultBuf, p1); + } + + // 2. set the new time window to be the new active time window pResultRowInfo->curPos = pResultRowInfo->size; - pResultRowInfo->pPosition[pResultRowInfo->size] = - (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; - pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; + pResultRowInfo->pPosition[pResultRowInfo->size++] = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; int64_t index = pResultRowInfo->curPos; SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); @@ -669,7 +672,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); } - return pResultRowInfo->pResult[pResultRowInfo->curPos]; + return pResult; } static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, TSKEY ts, STimeWindow* w, TSKEY ekey, @@ -693,7 +696,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T } // get the correct time window according to the handled timestamp -static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, +static STimeWindow getActiveTimeWindow(SDiskbasedBuf * pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, int32_t precision, STimeWindow* win) { STimeWindow w = {0}; @@ -701,7 +704,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true); w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; } else { - w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win; + w = getResultRow(pBuf, pResultRowInfo, pResultRowInfo->curPos)->win; } if (w.skey > ts || w.ekey < ts) { @@ -730,7 +733,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t // get the correct time window according to the handled timestamp static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t ts, STaskAttr* pQueryAttr) { STimeWindow w = {0}; - +#if 0 if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value // getInitialStartTimeWindow(pQueryAttr, ts, &w); @@ -742,7 +745,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in w.ekey = w.skey + pQueryAttr->interval.interval - 1; } } else { - w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win; + w = pRow->win; } /* @@ -752,6 +755,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in if (w.ekey > pQueryAttr->window.ekey && QUERY_IS_ASC_QUERY(pQueryAttr)) { w.ekey = pQueryAttr->window.ekey; } +#endif return w; } @@ -816,8 +820,8 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI assert(win->skey <= win->ekey); SDiskbasedBuf* pResultBuf = pRuntimeEnv->pResultBuf; - SResultRow* pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&win->skey, TSDB_KEYSIZE, - masterscan, tableGroupId); + SResultRow* pResultRow = NULL;//doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&win->skey, TSDB_KEYSIZE, +// masterscan, tableGroupId); if (pResultRow == NULL) { *pResult = NULL; return TSDB_CODE_SUCCESS; @@ -840,8 +844,7 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI return TSDB_CODE_SUCCESS; } -static void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowCellInfoOffset); +static void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset); static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_t id, STimeWindow* win, bool masterscan, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, @@ -859,7 +862,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_ // set time window for current result pResultRow->win = (*win); *pResult = pResultRow; - setResultRowOutputBufInitCtx_rv(pAggSup->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset); return TSDB_CODE_SUCCESS; } @@ -909,9 +912,9 @@ static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_se return forwardStep; } -static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey, bool ascQuery, - bool timeWindowInterpo) { +static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey, bool ascQuery, bool timeWindowInterpo) { int64_t skey = TSKEY_INITIAL_VAL; +#if 0 int32_t i = 0; for (i = pResultRowInfo->size - 1; i >= 0; --i) { SResultRow* pResult = pResultRowInfo->pResult[i]; @@ -963,6 +966,7 @@ static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey pResultRowInfo->curPos = i + 1; // current not closed result object } } +#endif } static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey, @@ -1041,7 +1045,9 @@ static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin) { static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order) { SScalarParam intervalParam = {.numOfRows = 5, .columnData = pTimeWindowData}; //TODO move out of this function - updateTimeWindowInfo(pTimeWindowData, pWin); + if (pTimeWindowData != NULL) { + updateTimeWindowInfo(pTimeWindowData, pWin); + } for (int32_t k = 0; k < numOfOutput; ++k) { pCtx[k].startTs = pWin->skey; @@ -1253,8 +1259,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, ASSERT(pCtx[i].input.pData[j] != NULL); } } - // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); + // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); // uint32_t flag = pOperator->pExpr[i].base.pParam[0].pCol->flag; // if (TSDB_COL_IS_NORMAL_COL(flag) /*|| (pCtx[i].functionId == FUNCTION_BLKINFO) || // (TSDB_COL_IS_TAG(flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)*/) { @@ -1551,14 +1557,14 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe if (pSDataBlock->pDataBlock != NULL) { SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, 0); tsCols = (int64_t*)pColDataInfo->pData; - assert(tsCols[0] == pSDataBlock->info.window.skey && - tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); +// assert(tsCols[0] == pSDataBlock->info.window.skey && tsCols[pSDataBlock->info.rows - 1] == +// pSDataBlock->info.window.ekey); } int32_t startPos = ascScan? 0 : (pSDataBlock->info.rows - 1); TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascScan); - STimeWindow win = getActiveTimeWindow(pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); + STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); bool masterScan = true; SResultRow* pResult = NULL; @@ -1581,6 +1587,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe // prev time window not interpolation yet. int32_t curIndex = pResultRowInfo->curPos; + +#if 0 if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) { for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. SResultRow* pRes = getResultRow(pResultRowInfo, j); @@ -1615,6 +1623,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } } +#endif // window start key interpolation doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, forwardStep, @@ -1886,9 +1895,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { } /*int32_t ret = */ generatedHashKey(pInfo->keyBuf, &len, pInfo->pGroupColVals); - int32_t ret = - setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, - 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup); + int32_t ret = setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -2010,12 +2017,11 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCo SqlFunctionCtx* pCtx = binfo->pCtx; SResultRow* pResultRow = doSetResultOutBufByKey_rv(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId, - pTaskInfo, true, pAggSup); + pTaskInfo, false, pAggSup); assert(pResultRow != NULL); setResultRowKey(pResultRow, pData, type); - - setResultRowOutputBufInitCtx_rv(pBuf, pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset); return TSDB_CODE_SUCCESS; } @@ -2170,8 +2176,8 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num } } pCtx->resDataInfo.interBufSize = env.calcMemSize; - } else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) { - } else if (pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) { + } else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN || pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) { + pCtx->resDataInfo.interBufSize = pFunct->resSchema.bytes; // for simple column, the intermediate buffer needs to hold one element. } pCtx->input.numOfInputCols = pFunct->numOfParams; @@ -3430,10 +3436,8 @@ void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) { } } -// TODO fix this bug. -int32_t initResultRow(SResultRow* pResultRow) { +void initResultRow(SResultRow* pResultRow) { pResultRow->pEntryInfo = (struct SResultRowEntryInfo*)((char*)pResultRow + sizeof(SResultRow)); - return TSDB_CODE_SUCCESS; } /* @@ -3449,7 +3453,9 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t SqlFunctionCtx* pCtx = pInfo->pCtx; SSDataBlock* pDataBlock = pInfo->pRes; int32_t* rowCellInfoOffset = pInfo->rowCellInfoOffset; + SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo; + initResultRowInfo(pResultRowInfo, 16); int64_t tid = 0; int64_t groupId = 0; @@ -3610,9 +3616,11 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD SFilePage* bufPage = getBufPage(pBuf, pPos->pageId); SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->offset); - if (!isResultRowClosed(pResultRowInfo, i)) { - continue; - } + + // TODO ignore the close status anyway. +// if (!isResultRowClosed(pRow)) { +// continue; +// } for (int32_t j = 0; j < numOfOutput; ++j) { pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); @@ -3622,7 +3630,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD continue; } - if (pCtx[j].fpSet.process) { // TODO set the dummy function. + if (pCtx[j].fpSet.process) { // TODO set the dummy function, to avoid the check for null ptr. pCtx[j].fpSet.finalize(&pCtx[j]); } @@ -3660,6 +3668,7 @@ void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbased if (pCtx[j].fpSet.process) { // TODO set the dummy function. pCtx[j].fpSet.finalize(&pCtx[j]); + pResInfo->initialized = true; } if (pRow->numOfRows < pResInfo->numOfRes) { @@ -3764,8 +3773,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv* pRuntimeEnv, SResultRow* pRes } } -void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowCellInfoOffset) { +void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) { for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); @@ -3778,22 +3786,13 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, S continue; } - // int32_t functionId = pCtx[i].functionId; - // if (functionId < 0) { - // continue; - // } - // if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) { - // if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput; - // } - if (!pResInfo->initialized && pCtx[i].functionId != -1) { pCtx[i].fpSet.init(&pCtx[i], pResInfo); } } } -void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, - SExecTaskInfo* pTaskInfo) { +void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, SExecTaskInfo* pTaskInfo) { // for simple group by query without interval, all the tables belong to one group result. int64_t uid = 0; int64_t tid = 0; @@ -3812,14 +3811,13 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i * all group belong to one result set, and each group result has different group id so set the id to be one */ if (pResultRow->pageId == -1) { - int32_t ret = - addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize); + int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize); if (ret != TSDB_CODE_SUCCESS) { return; } } - setResultRowOutputBufInitCtx_rv(pAggInfo->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset); } void setExecutionContext(int32_t numOfOutput, int32_t tableGroupId, TSKEY nextKey, SExecTaskInfo* pTaskInfo, @@ -4135,7 +4133,7 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu // if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { // return; // } - +#if 0 for (int32_t i = 0; i < pResultRowInfo->size; ++i) { SResultRow* pResult = pResultRowInfo->pResult[i]; @@ -4149,6 +4147,8 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu pResult->numOfRows = (uint16_t)(TMAX(pResult->numOfRows, pCell->numOfRes)); } } +#endif + } static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows, char* data, int8_t compressed) { @@ -4971,7 +4971,20 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup) return NULL; } - pInfo->pRes->pDataBlock = tqRetrieveDataBlock(pInfo->readerHandle); + SArray* pCols = tqRetrieveDataBlock(pInfo->readerHandle); + + int32_t numOfCols = pInfo->pRes->info.numOfCols; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* p = taosArrayGet(pCols, i); + SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); + if (!pColMatchInfo->output) { + continue; + } + + ASSERT(pColMatchInfo->colId == p->info.colId); + taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, p); + } + if (pInfo->pRes->pDataBlock == NULL) { // TODO add log pTaskInfo->code = terrno; @@ -4991,12 +5004,16 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup) int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) { SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param; - pSourceDataInfo->pRsp = pMsg->pData; + if (code == TSDB_CODE_SUCCESS) { + pSourceDataInfo->pRsp = pMsg->pData; - SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp; - pRsp->numOfRows = htonl(pRsp->numOfRows); - pRsp->useconds = htobe64(pRsp->useconds); - pRsp->compLen = htonl(pRsp->compLen); + SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp; + pRsp->numOfRows = htonl(pRsp->numOfRows); + pRsp->compLen = htonl(pRsp->compLen); + pRsp->useconds = htobe64(pRsp->useconds); + } else { + pSourceDataInfo->code = code; + } pSourceDataInfo->status = EX_SOURCE_DATA_READY; tsem_post(&pSourceDataInfo->pEx->ready); @@ -5252,7 +5269,6 @@ static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo* pOperator) { totalSources, endTs - startTs); tsem_wait(&pExchangeInfo->ready); - pOperator->status = OP_RES_TO_RETURN; return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo); } @@ -5296,18 +5312,22 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) { } doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current); - tsem_wait(&pExchangeInfo->ready); - SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current); + SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current); SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); + if (pDataInfo->code != TSDB_CODE_SUCCESS) { + qError("%s vgId:%d, taskID:0x%" PRIx64 " error happens, code:%s", + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, tstrerror(pDataInfo->code)); + pOperator->pTaskInfo->code = pDataInfo->code; + return NULL; + } + SRetrieveTableRsp* pRsp = pDataInfo->pRsp; SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo; - if (pRsp->numOfRows == 0) { - qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 - " try next", + qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 " try next", GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1, pDataInfo->totalRows, pLoadInfo->totalRows); @@ -5625,8 +5645,18 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* return NULL; } + int32_t numOfOutput = taosArrayGetSize(pColList); + + SArray* pColIds = taosArrayInit(4, sizeof(int16_t)); + for(int32_t i = 0; i < numOfOutput; ++i) { + int16_t* id = taosArrayGet(pColList, i); + taosArrayPush(pColIds, id); + } + + pInfo->pColMatchInfo = pColList; + // set the extract column id to streamHandle - tqReadHandleSetColIdList((STqReadHandle*)streamReadHandle, pColList); + tqReadHandleSetColIdList((STqReadHandle*)streamReadHandle, pColIds); int32_t code = tqReadHandleSetTbUidList(streamReadHandle, pTableIdList); if (code != 0) { taosMemoryFreeClear(pInfo); @@ -5665,9 +5695,9 @@ static int32_t loadSysTableContentCb(void* param, const SDataBuf* pMsg, int32_t SRetrieveMetaTableRsp* pRsp = pScanResInfo->pRsp; pRsp->numOfRows = htonl(pRsp->numOfRows); - pRsp->useconds = htobe64(pRsp->useconds); - pRsp->handle = htobe64(pRsp->handle); - pRsp->compLen = htonl(pRsp->compLen); + pRsp->useconds = htobe64(pRsp->useconds); + pRsp->handle = htobe64(pRsp->handle); + pRsp->compLen = htonl(pRsp->compLen); } else { operator->pTaskInfo->code = code; } @@ -5824,6 +5854,10 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) { // pInfo->totalBytes; return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; } else { // load the meta from mnode of the given epset + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + int64_t startTs = taosGetTimestampUs(); pInfo->req.type = pInfo->type; @@ -5863,6 +5897,10 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) { SRetrieveMetaTableRsp* pRsp = pInfo->pRsp; pInfo->req.showId = pRsp->handle; + if (pRsp->numOfRows == 0 || pRsp->completed) { + pOperator->status = OP_EXEC_DONE; + } + if (pRsp->numOfRows == 0) { // qDebug("%s vgId:%d, taskID:0x%"PRIx64" %d of total completed, rowsOfSource:%"PRIu64", totalRows:%"PRIu64" // try next", @@ -6964,7 +7002,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; } - return pInfo->binfo.pRes; + return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } // STimeWindow win = {0}; @@ -6993,6 +7031,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup finalizeUpdatedResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset); + initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset); @@ -7556,10 +7595,10 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, const char* pKey) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); - pAggSup->keyBuf = taosMemoryCalloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); + pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); + pAggSup->keyBuf = taosMemoryCalloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); - pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); + pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL || @@ -8732,8 +8771,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr; - pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; - pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); +// pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; +// pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); } else { ASSERT(0); } @@ -8792,10 +8831,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SArray* tableIdList = extractTableIdList(pTableGroupInfo); SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); - SArray* colList = extractScanColumnId(pScanPhyNode->pScanCols); - SOperatorInfo* pOperator = - createStreamScanOperatorInfo(pHandle->reader, pResBlock, colList, tableIdList, pTaskInfo); + int32_t numOfCols = 0; + SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); + SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pResBlock, pColList, tableIdList, pTaskInfo); taosArrayDestroy(tableIdList); return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == nodeType(pPhyNode)) { diff --git a/source/libs/index/inc/indexFstDfa.h b/source/libs/index/inc/indexFstDfa.h new file mode 100644 index 0000000000..f6c220bcb7 --- /dev/null +++ b/source/libs/index/inc/indexFstDfa.h @@ -0,0 +1,74 @@ +/* + * 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 __INDEX_FST_DFA_H__ +#define __INDEX_FST_DFA_H__ + +#include "indexFstRegex.h" +#include "indexFstSparse.h" +#include "tarray.h" +#include "thash.h" + +#ifdef __cplusplus + +extern "C" { +#endif + +typedef struct FstDfa FstDfa; + +typedef struct { + SArray * insts; + uint32_t next[256]; + bool isMatch; +} State; + +/* + * dfa builder related func + **/ +typedef struct FstDfaBuilder { + FstDfa * dfa; + SHashObj *cache; +} FstDfaBuilder; + +FstDfaBuilder *dfaBuilderCreate(SArray *insts); + +void dfaBuilderDestroy(FstDfaBuilder *builder); + +FstDfa *dfaBuilderBuild(FstDfaBuilder *builder); + +bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t bytes, + uint32_t *result); + +bool dfaBuilderCachedState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result); + +/* + * dfa related func + **/ +typedef struct FstDfa { + SArray *insts; + SArray *states; +} FstDfa; + +FstDfa *dfaCreate(SArray *insts, SArray *states); +bool dfaIsMatch(FstDfa *dfa, uint32_t si); +bool dfaAccept(FstDfa *dfa, uint32_t si, uint8_t byte, uint32_t *result); +void dfaAdd(FstDfa *dfa, FstSparseSet *set, uint32_t ip); +bool dfaRun(FstDfa *dfa, FstSparseSet *from, FstSparseSet *to, uint8_t byte); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/libs/index/inc/indexFstRegex.h b/source/libs/index/inc/indexFstRegex.h new file mode 100644 index 0000000000..8fb5455336 --- /dev/null +++ b/source/libs/index/inc/indexFstRegex.h @@ -0,0 +1,75 @@ +/* + * 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_FST_REGEX_H_ +#define _TD_INDEX_FST_REGEX_H_ + +//#include "indexFstDfa.h" +#include "taos.h" +#include "tarray.h" +#include "tchecksum.h" +#include "thash.h" +#include "tlog.h" +#include "tutil.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { MATCH, JUMP, SPLIT, RANGE } InstType; + +typedef struct MatchValue { +} MatchValue; +typedef struct JumpValue { + uint32_t step; +} JumpValue; + +typedef struct SplitValue { + uint32_t len1; + uint32_t len2; +} SplitValue; + +typedef struct RangeValue { + uint8_t start; + uint8_t end; +} RangeValue; + +typedef struct { + InstType ty; + union { + MatchValue mv; + JumpValue jv; + SplitValue sv; + RangeValue rv; + }; +} Inst; + +typedef struct { + char *orig; + void *dfa; +} FstRegex; + +FstRegex *regexCreate(const char *str); + +uint32_t regexAutomStart(FstRegex *regex); +bool regexAutomIsMatch(FstRegex *regex, uint32_t state); +bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null); +bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/libs/index/inc/indexSparse.h b/source/libs/index/inc/indexFstSparse.h similarity index 90% rename from source/libs/index/inc/indexSparse.h rename to source/libs/index/inc/indexFstSparse.h index 8035f6e08d..665fb2ba5c 100644 --- a/source/libs/index/inc/indexSparse.h +++ b/source/libs/index/inc/indexFstSparse.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_INDEX_SPARSE_H_ -#define _TD_INDEX_SPARSE_H_ +#ifndef _TD_INDEX_FST_SPARSE_H_ +#define _TD_INDEX_FST_SPARSE_H_ #include "tarray.h" @@ -23,9 +23,9 @@ extern "C" { #endif typedef struct FstSparseSet { - SArray *dense; - SArray *sparse; - int32_t size; + uint32_t *dense; + uint32_t *sparse; + int32_t size; } FstSparseSet; FstSparseSet *sparSetCreate(int32_t sz); diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index d3ca3a1acf..7d52abcd1b 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -27,7 +27,7 @@ #endif #define INDEX_NUM_OF_THREADS 4 -#define INDEX_QUEUE_SIZE 200 +#define INDEX_QUEUE_SIZE 200 void* indexQhandle = NULL; diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index ca26cf38e5..df3c0b6e7b 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -21,8 +21,8 @@ #define MAX_INDEX_KEY_LEN 256 // test only, change later -#define MEM_TERM_LIMIT 10 * 10000 -#define MEM_THRESHOLD 1024 * 1024 +#define MEM_TERM_LIMIT 10 * 10000 +#define MEM_THRESHOLD 1024 * 1024 #define MEM_ESTIMATE_RADIO 1.5 static void indexMemRef(MemTable* tbl); diff --git a/source/libs/index/src/indexFstCommon.c b/source/libs/index/src/indexFstCommon.c index e2544c7ac3..902e68ce09 100644 --- a/source/libs/index/src/indexFstCommon.c +++ b/source/libs/index/src/indexFstCommon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 TAOS Data, Inc. +YAML:9:25: error: unknown key 'AlignConsecutiveMacros' * 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 diff --git a/source/libs/index/src/indexFstDfa.c b/source/libs/index/src/indexFstDfa.c new file mode 100644 index 0000000000..ff6b154c54 --- /dev/null +++ b/source/libs/index/src/indexFstDfa.c @@ -0,0 +1,218 @@ +/* + * 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 "indexFstDfa.h" +#include "thash.h" + +const static uint32_t STATE_LIMIT = 1000; + +static int dfaInstsEqual(const void *a, const void *b, size_t size) { + SArray *ar = (SArray *)a; + SArray *br = (SArray *)b; + size_t al = ar != NULL ? taosArrayGetSize(ar) : 0; + size_t bl = br != NULL ? taosArrayGetSize(br) : 0; + if (al != bl) { + return -1; + } + for (int i = 0; i < al; i++) { + uint32_t v1 = *(uint32_t *)taosArrayGet(ar, i); + uint32_t v2 = *(uint32_t *)taosArrayGet(br, i); + if (v1 != v2) { + return -1; + } + } + return 0; +} +FstDfaBuilder *dfaBuilderCreate(SArray *insts) { + FstDfaBuilder *builder = taosMemoryCalloc(1, sizeof(FstDfaBuilder)); + if (builder == NULL) { + return NULL; + } + + SArray *states = taosArrayInit(4, sizeof(State)); + + builder->dfa = dfaCreate(insts, states); + builder->cache = taosHashInit( + 4, taosGetDefaultHashFunction(POINTER_BYTES == sizeof(int64_t) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_INT), + false, HASH_NO_LOCK); + taosHashSetEqualFp(builder->cache, dfaInstsEqual); + return builder; +} +void dfaBuilderDestroy(FstDfaBuilder *builder) { + if (builder == NULL) { + return; + } + void *pIter = builder->cache != NULL ? taosHashIterate(builder->cache, NULL) : NULL; + while (pIter) { + SArray **key = pIter; + taosArrayDestroy(*key); + pIter = taosHashIterate(builder->cache, pIter); + } + taosHashCleanup(builder->cache); +} + +FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) { + uint32_t sz = taosArrayGetSize(builder->dfa->insts); + FstSparseSet *cur = sparSetCreate(sz); + FstSparseSet *nxt = sparSetCreate(sz); + + dfaAdd(builder->dfa, cur, 0); + + SArray * states = taosArrayInit(0, sizeof(uint32_t)); + uint32_t result; + if (dfaBuilderCachedState(builder, cur, &result)) { + taosArrayPush(states, &result); + } + SHashObj *seen = taosHashInit(12, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + while (taosArrayGetSize(states) != 0) { + result = *(uint32_t *)taosArrayPop(states); + for (int i = 0; i < 256; i++) { + uint32_t ns, dummpy = 0; + if (dfaBuilderRunState(builder, cur, nxt, result, i, &ns)) { + if (taosHashGet(seen, &ns, sizeof(ns)) == NULL) { + taosHashPut(seen, &ns, sizeof(ns), &dummpy, sizeof(dummpy)); + taosArrayPush(states, &ns); + } + } + if (taosArrayGetSize(builder->dfa->states) > STATE_LIMIT) { + // Too many state; + // + } + } + } + taosArrayDestroy(states); + taosHashCleanup(seen); + return builder->dfa; +} + +bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t byte, + uint32_t *result) { + sparSetClear(cur); + State *t = taosArrayGet(builder->dfa->states, state); + for (int i = 0; i < taosArrayGetSize(t->insts); i++) { + uint32_t ip = *(int32_t *)taosArrayGet(t->insts, i); + sparSetAdd(cur, ip); + } + dfaRun(builder->dfa, cur, next, byte); + + t = taosArrayGet(builder->dfa->states, state); + + uint32_t nxtState; + if (dfaBuilderCachedState(builder, next, &nxtState)) { + t->next[byte] = nxtState; + *result = nxtState; + return true; + } + return false; +} + +bool dfaBuilderCachedState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result) { + SArray *tinsts = taosArrayInit(4, sizeof(uint32_t)); + bool isMatch = false; + + for (int i = 0; i < sparSetLen(set); i++) { + uint32_t ip = sparSetGet(set, i); + + Inst *inst = taosArrayGet(builder->dfa->insts, ip); + if (inst->ty == JUMP || inst->ty == SPLIT) { + continue; + } else if (inst->ty == RANGE) { + taosArrayPush(tinsts, &ip); + } else if (inst->ty == MATCH) { + isMatch = true; + taosArrayPush(tinsts, &ip); + } + } + if (taosArrayGetSize(tinsts) == 0) { + return false; + } + uint32_t *v = taosHashGet(builder->cache, &tinsts, sizeof(POINTER_BYTES)); + if (v != NULL) { + *result = *v; + taosArrayDestroy(tinsts); + } else { + State st; + st.insts = tinsts; + st.isMatch = isMatch; + taosArrayPush(builder->dfa->states, &st); + int32_t sz = taosArrayGetSize(builder->dfa->states) - 1; + taosHashPut(builder->cache, &tinsts, sizeof(POINTER_BYTES), &sz, sizeof(sz)); + *result = sz; + } + return true; +} + +FstDfa *dfaCreate(SArray *insts, SArray *states) { + FstDfa *dfa = taosMemoryCalloc(1, sizeof(FstDfa)); + if (dfa == NULL) { + return NULL; + } + + dfa->insts = insts; + dfa->states = states; + return dfa; +} +bool dfaIsMatch(FstDfa *dfa, uint32_t si) { + if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) { + return false; + } + State *st = taosArrayGet(dfa->states, si); + return st != NULL ? st->isMatch : false; +} +bool dfaAccept(FstDfa *dfa, uint32_t si, uint8_t byte, uint32_t *result) { + if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) { + return false; + } + State *st = taosArrayGet(dfa->states, si); + *result = st->next[byte]; + return true; +} +void dfaAdd(FstDfa *dfa, FstSparseSet *set, uint32_t ip) { + if (sparSetContains(set, ip)) { + return; + } + sparSetAdd(set, ip); + Inst *inst = taosArrayGet(dfa->insts, ip); + if (inst->ty == MATCH || inst->ty == RANGE) { + // do nothing + } else if (inst->ty == JUMP) { + dfaAdd(dfa, set, inst->jv.step); + } else if (inst->ty == SPLIT) { + dfaAdd(dfa, set, inst->sv.len1); + dfaAdd(dfa, set, inst->sv.len2); + } + + return; +} +bool dfaRun(FstDfa *dfa, FstSparseSet *from, FstSparseSet *to, uint8_t byte) { + bool isMatch = false; + sparSetClear(to); + for (int i = 0; i < sparSetLen(from); i++) { + uint32_t ip = sparSetGet(from, i); + + Inst *inst = taosArrayGet(dfa->insts, ip); + if (inst->ty == JUMP || inst->ty == SPLIT) { + continue; + } else if (inst->ty == MATCH) { + isMatch = true; + } else if (inst->ty == RANGE) { + if (inst->rv.start <= byte && byte <= inst->rv.end) { + dfaAdd(dfa, to, ip + 1); + } + } + } + + return isMatch; +} diff --git a/source/libs/index/src/indexFstRegex.c b/source/libs/index/src/indexFstRegex.c new file mode 100644 index 0000000000..33eeae802e --- /dev/null +++ b/source/libs/index/src/indexFstRegex.c @@ -0,0 +1,61 @@ +/* + * 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 "indexFstRegex.h" +#include "indexFstDfa.h" +#include "indexFstSparse.h" + +FstRegex *regexCreate(const char *str) { + FstRegex *regex = taosMemoryCalloc(1, sizeof(FstRegex)); + if (regex == NULL) { + return NULL; + } + int32_t sz = (int32_t)strlen(str); + char * orig = taosMemoryCalloc(1, sz); + memcpy(orig, str, sz); + + regex->orig = orig; + + // construct insts based on str + SArray *insts = NULL; + + FstDfaBuilder *builder = dfaBuilderCreate(insts); + regex->dfa = dfaBuilderBuild(builder); + return regex; +} + +uint32_t regexAutomStart(FstRegex *regex) { + ///// no nothing + return 0; +} +bool regexAutomIsMatch(FstRegex *regex, uint32_t state) { + if (regex->dfa != NULL && dfaIsMatch(regex->dfa, state)) { + return true; + } else { + return false; + } +} + +bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null) { + // make frame happy + return null; +} + +bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result) { + if (regex->dfa == NULL) { + return false; + } + return dfaAccept(regex->dfa, state, byte, result); +} diff --git a/source/libs/index/src/indexSparse.c b/source/libs/index/src/indexFstSparse.c similarity index 63% rename from source/libs/index/src/indexSparse.c rename to source/libs/index/src/indexFstSparse.c index 8bcf04602f..e8ab3be2fe 100644 --- a/source/libs/index/src/indexSparse.c +++ b/source/libs/index/src/indexFstSparse.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "indexSparse.h" +#include "indexFstSparse.h" FstSparseSet *sparSetCreate(int32_t sz) { FstSparseSet *ss = taosMemoryCalloc(1, sizeof(FstSparseSet)); @@ -21,47 +21,44 @@ FstSparseSet *sparSetCreate(int32_t sz) { return NULL; } - ss->dense = taosArrayInit(sz, sizeof(uint32_t)); - ss->sparse = taosArrayInit(sz, sizeof(uint32_t)); - ss->size = sz; + ss->dense = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); + ss->sparse = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); + ss->size = 0; return ss; } void sparSetDestroy(FstSparseSet *ss) { if (ss == NULL) { return; } - taosArrayDestroy(ss->dense); - taosArrayDestroy(ss->sparse); + taosMemoryFree(ss->dense); + taosMemoryFree(ss->sparse); taosMemoryFree(ss); } -uint32_t sparSetLen(FstSparseSet *ss) { return ss == NULL ? 0 : ss->size; } +uint32_t sparSetLen(FstSparseSet *ss) { + // Get occupied size + return ss == NULL ? 0 : ss->size; +} uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip) { if (ss == NULL) { return 0; } uint32_t i = ss->size; - taosArraySet(ss->dense, i, &ip); - taosArraySet(ss->sparse, ip, &i); + ss->dense[i] = ip; + ss->sparse[ip] = i; ss->size += 1; return i; } uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) { - if (i >= taosArrayGetSize(ss->dense)) { - return 0; - } - uint32_t *v = taosArrayGet(ss->dense, i); - return *v; + // check later + return ss->dense[i]; } bool sparSetContains(FstSparseSet *ss, uint32_t ip) { - if (ip >= taosArrayGetSize(ss->sparse)) { + uint32_t i = ss->sparse[ip]; + if (i < ss->size && ss->dense[i] == ip) { + return true; + } else { return false; } - uint32_t i = *(uint32_t *)taosArrayGet(ss->sparse, ip); - if (i >= taosArrayGetSize(ss->dense)) { - return false; - } - uint32_t v = *(uint32_t *)taosArrayGet(ss->dense, i); - return v == ip; } void sparSetClear(FstSparseSet *ss) { if (ss == NULL) { diff --git a/source/libs/nodes/inc/nodesUtil.h b/source/libs/nodes/inc/nodesUtil.h index de00b6bca4..976044c16f 100644 --- a/source/libs/nodes/inc/nodesUtil.h +++ b/source/libs/nodes/inc/nodesUtil.h @@ -20,12 +20,16 @@ extern "C" { #endif -#define nodesFatal(param, ...) qFatal("NODES: " param, __VA_ARGS__) -#define nodesError(param, ...) qError("NODES: " param, __VA_ARGS__) -#define nodesWarn(param, ...) qWarn("NODES: " param, __VA_ARGS__) -#define nodesInfo(param, ...) qInfo("NODES: " param, __VA_ARGS__) -#define nodesDebug(param, ...) qDebug("NODES: " param, __VA_ARGS__) -#define nodesTrace(param, ...) qTrace("NODES: " param, __VA_ARGS__) +#define nodesFatal(...) qFatal("NODES: " __VA_ARGS__) +#define nodesError(...) qError("NODES: " __VA_ARGS__) +#define nodesWarn(...) qWarn("NODES: " __VA_ARGS__) +#define nodesInfo(...) qInfo("NODES: " __VA_ARGS__) +#define nodesDebug(...) qDebug("NODES: " __VA_ARGS__) +#define nodesTrace(...) qTrace("NODES: " __VA_ARGS__) + +#define NODES_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define NODES_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define NODES_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #ifdef __cplusplus } diff --git a/source/libs/nodes/src/nodesToSQLFuncs.c b/source/libs/nodes/src/nodesToSQLFuncs.c new file mode 100644 index 0000000000..68f38bb6a7 --- /dev/null +++ b/source/libs/nodes/src/nodesToSQLFuncs.c @@ -0,0 +1,145 @@ +/* + * 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 "cmdnodes.h" +#include "nodesUtil.h" +#include "plannodes.h" +#include "querynodes.h" +#include "taos.h" +#include "taoserror.h" +#include "thash.h" + +char *gOperatorStr[] = {NULL, "+", "-", "*", "/", "%", "&", "|", ">", ">=", "<", "<=", "=", "<>", + "IN", "NOT IN", "LIKE", "NOT LIKE", "MATCH", "NMATCH", "IS NULL", "IS NOT NULL", + "IS TRUE", "IS FALSE", "IS UNKNOWN", "IS NOT TRUE", "IS NOT FALSE", "IS NOT UNKNOWN"}; +char *gLogicConditionStr[] = {"AND", "OR", "NOT"}; + +int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { + switch (pNode->type) { + case QUERY_NODE_COLUMN: { + SColumnNode *colNode = (SColumnNode *)pNode; + if (colNode->dbName[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName); + } + + if (colNode->tableAlias[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias); + } else if (colNode->tableName[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName); + } + + *len += snprintf(buf + *len, bufSize - *len, "`%s`", colNode->colName); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_VALUE:{ + SValueNode *colNode = (SValueNode *)pNode; + char *t = nodesGetStrValueFromNode(colNode); + if (NULL == t) { + nodesError("fail to get str value from valueNode"); + NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + *len += snprintf(buf + *len, bufSize - *len, "%s", t); + taosMemoryFree(t); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_OPERATOR: { + SOperatorNode* pOpNode = (SOperatorNode*)pNode; + *len += snprintf(buf + *len, bufSize - *len, "("); + if (pOpNode->pLeft) { + NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len)); + } + + if (pOpNode->opType >= (sizeof(gOperatorStr) / sizeof(gOperatorStr[0]))) { + nodesError("unknown operation type:%d", pOpNode->opType); + NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + *len += snprintf(buf + *len, bufSize - *len, " %s ", gOperatorStr[pOpNode->opType]); + + if (pOpNode->pRight) { + NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len)); + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_LOGIC_CONDITION:{ + SLogicConditionNode* pLogicNode = (SLogicConditionNode*)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "("); + + FOREACH(node, pLogicNode->pParameterList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, " %s ", gLogicConditionStr[pLogicNode->condType]); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_FUNCTION:{ + SFunctionNode* pFuncNode = (SFunctionNode*)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName); + + FOREACH(node, pFuncNode->pParameterList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, ", "); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_NODE_LIST:{ + SNodeListNode* pListNode = (SNodeListNode *)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "("); + + FOREACH(node, pListNode->pNodeList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, ", "); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + default: + break; + } + + nodesError("nodesNodeToSQL unknown node = %s", nodesNodeName(pNode->type)); + NODES_RET(TSDB_CODE_QRY_APP_ERROR); +} diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 7eaa049946..bbd0473edd 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -17,7 +17,8 @@ typedef enum ETraversalOrder { TRAVERSAL_PREORDER = 1, - TRAVERSAL_POSTORDER + TRAVERSAL_INORDER, + TRAVERSAL_POSTORDER, } ETraversalOrder; static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 89b4476899..732d9acfbe 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -136,6 +136,10 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SDropTopicStmt)); case QUERY_NODE_EXPLAIN_STMT: return makeNode(type, sizeof(SExplainStmt)); + case QUERY_NODE_DESCRIBE_STMT: + return makeNode(type, sizeof(SDescribeStmt)); + case QUERY_NODE_RESET_QUERY_CACHE_STMT: + return makeNode(type, sizeof(SNode)); case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_TABLES_STMT: case QUERY_NODE_SHOW_STABLES_STMT: @@ -786,6 +790,71 @@ void* nodesGetValueFromNode(SValueNode *pNode) { return NULL; } +char* nodesGetStrValueFromNode(SValueNode *pNode) { + switch (pNode->node.resType.type) { + case TSDB_DATA_TYPE_BOOL: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%s", pNode->datum.b ? "true" : "false"); + return buf; + } + 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: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%" PRId64, pNode->datum.i); + return buf; + } + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_UBIGINT: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%" PRIu64, pNode->datum.u); + return buf; + } + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%e", pNode->datum.d); + return buf; + } + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_VARBINARY: { + int32_t bufSize = varDataLen(pNode->datum.p) + 2 + 1; + void *buf = taosMemoryMalloc(bufSize); + if (NULL == buf) { + return NULL; + } + + snprintf(buf, bufSize, "'%s'", varDataVal(pNode->datum.p)); + return buf; + } + default: + break; + } + + return NULL; +} + bool nodesIsExprNode(const SNode* pNode) { ENodeType type = nodeType(pNode); return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 029ae7e91f..f8880eac72 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -71,6 +71,7 @@ typedef enum ETableOptionType { typedef struct SAlterOption { int32_t type; SToken val; + SNodeList* pKeep; } SAlterOption; extern SToken nil_token; @@ -121,6 +122,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); +SNode* setDatabaseKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep); +SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pDbName); SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions); @@ -129,6 +132,8 @@ SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pFuncs); +SNode* setTableKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep); +SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption); 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); @@ -163,6 +168,8 @@ SNode* createDefaultExplainOptions(SAstCreateContext* pCxt); SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal); SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal); SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery); +SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable); +SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index af0d78717e..9bad3e9eb9 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -25,6 +25,7 @@ extern "C" { int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery); int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery); int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery); +int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 5e2f8e4241..e2b96b4a50 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -137,7 +137,7 @@ db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); } db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); } db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); } -db_options(A) ::= db_options(B) KEEP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, &C); } +db_options(A) ::= db_options(B) KEEP integer_list(C). { A = setDatabaseKeepOption(pCxt, B, C); } db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); } db_options(A) ::= db_options(B) QUORUM NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_QUORUM, &C); } db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); } @@ -148,17 +148,23 @@ db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAM_MODE, &C); } db_options(A) ::= db_options(B) RETENTIONS NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, &C); } -alter_db_options(A) ::= alter_db_option(B). { A = createDefaultAlterDatabaseOptions(pCxt); A = setDatabaseOption(pCxt, A, B.type, &B.val); } -alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseOption(pCxt, B, C.type, &C.val); } +alter_db_options(A) ::= alter_db_option(B). { A = createDefaultAlterDatabaseOptions(pCxt); A = setDatabaseAlterOption(pCxt, A, &B); } +alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseAlterOption(pCxt, B, &C); } %type alter_db_option { SAlterOption } %destructor alter_db_option { } alter_db_option(A) ::= BLOCKS NK_INTEGER(B). { A.type = DB_OPTION_BLOCKS; A.val = B; } alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } -alter_db_option(A) ::= KEEP NK_INTEGER(B). { A.type = DB_OPTION_KEEP; A.val = B; } +alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pKeep = B; } alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } alter_db_option(A) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.val = B; } alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; } +alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; } + +%type integer_list { SNodeList* } +%destructor integer_list { nodesDestroyList($$); } +integer_list(A) ::= NK_INTEGER(B). { A = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); } +integer_list(A) ::= integer_list(B) NK_COMMA NK_INTEGER(C). { A = addNodeToList(pCxt, B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C)); } /************************************************ create/drop table/stable ********************************************/ cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B) @@ -259,20 +265,20 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. table_options(A) ::= . { A = createDefaultTableOptions(pCxt); } table_options(A) ::= table_options(B) COMMENT NK_STRING(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) KEEP integer_list(C). { A = setTableKeepOption(pCxt, B, C); } table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); } table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableSmaOption(pCxt, B, C); } table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableRollupOption(pCxt, B, C); } table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); } table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); } -alter_table_options(A) ::= alter_table_option(B). { A = createDefaultAlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val); } -alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableOption(pCxt, B, C.type, &C.val); } +alter_table_options(A) ::= alter_table_option(B). { A = createDefaultAlterTableOptions(pCxt); A = setTableAlterOption(pCxt, A, &B); } +alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableAlterOption(pCxt, B, &C); } %type alter_table_option { SAlterOption } %destructor alter_table_option { } alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; } -alter_table_option(A) ::= KEEP NK_INTEGER(B). { A.type = TABLE_OPTION_KEEP; A.val = B; } +alter_table_option(A) ::= KEEP integer_list(B). { A.type = TABLE_OPTION_KEEP; A.pKeep = B; } alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; } %type col_name_list { SNodeList* } @@ -339,7 +345,14 @@ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); } cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } -/************************************************ select **************************************************************/ +/************************************************ desc/describe *******************************************************/ +cmd ::= DESC full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); } +cmd ::= DESCRIBE full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); } + +/************************************************ reset query cache ***************************************************/ +cmd ::= RESET QUERY CACHE. { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } + +/************************************************ explain *************************************************************/ cmd ::= EXPLAIN analyze_opt(A) explain_options(B) query_expression(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); } %type analyze_opt { bool } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 8783872ad8..028238ab60 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -138,18 +138,6 @@ static SDatabaseOptions* setDbMinRows(SAstCreateContext* pCxt, SDatabaseOptions* return pOptions; } -static SDatabaseOptions* setDbKeep(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { - 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); - pCxt->valid = false; - return pOptions; - } - pOptions->keep = val; - return pOptions; -} - static SDatabaseOptions* setDbPrecision(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { char val[10] = {0}; trimString(pVal->z, pVal->n, val, sizeof(val)); @@ -180,9 +168,9 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions* static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { int64_t val = strtol(pVal->z, NULL, 10); - if (val < TSDB_MIN_DB_REPLICA_OPTION || val > TSDB_MAX_DB_REPLICA_OPTION) { + 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", only 1, 3 allowed", val); pCxt->valid = false; return pOptions; } @@ -291,7 +279,6 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_FSYNC] = setDbFsync; setDbOptionFuncs[DB_OPTION_MAXROWS] = setDbMaxRows; setDbOptionFuncs[DB_OPTION_MINROWS] = setDbMinRows; - setDbOptionFuncs[DB_OPTION_KEEP] = setDbKeep; setDbOptionFuncs[DB_OPTION_PRECISION] = setDbPrecision; setDbOptionFuncs[DB_OPTION_QUORUM] = setDbQuorum; setDbOptionFuncs[DB_OPTION_REPLICA] = setDbReplica; @@ -303,18 +290,6 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_RETENTIONS] = setDbRetentions; } -static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { - 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); - pCxt->valid = false; - return pOptions; - } - pOptions->keep = val; - return pOptions; -} - static STableOptions* setTableTtl(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { int64_t val = strtol(pVal->z, NULL, 10); if (val < TSDB_MIN_DB_TTL_OPTION) { @@ -363,7 +338,6 @@ static STableOptions* setTableDelay(SAstCreateContext* pCxt, STableOptions* pOpt } static void initSetTableOptionFp() { - setTableOptionFuncs[TABLE_OPTION_KEEP] = setTableKeep; setTableOptionFuncs[TABLE_OPTION_TTL] = setTableTtl; setTableOptionFuncs[TABLE_OPTION_COMMENT] = setTableComment; setTableOptionFuncs[TABLE_OPTION_FILE_FACTOR] = setTableFileFactor; @@ -397,7 +371,9 @@ static bool checkUserName(SAstCreateContext* pCxt, SToken* pUserName) { pCxt->valid = false; } } - trimEscape(pUserName); + if (pCxt->valid) { + trimEscape(pUserName); + } return pCxt->valid; } @@ -472,42 +448,50 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) { if (NULL == pDbName) { - pCxt->valid = (query ? NULL != pCxt->pQueryCxt->db : true); + if (query && NULL == pCxt->pQueryCxt->db) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED); + pCxt->valid = false; + } } else { - pCxt->valid = pDbName->n < TSDB_DB_NAME_LEN ? true : false; + if (pDbName->n >= TSDB_DB_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pDbName->z); + pCxt->valid = false; + } + } + if (pCxt->valid) { + trimEscape(pDbName); } - trimEscape(pDbName); return pCxt->valid; } static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) { - if (NULL == pTableName) { - pCxt->valid = true; - } else { - pCxt->valid = pTableName->n < TSDB_TABLE_NAME_LEN ? true : false; + if (NULL != pTableName && pTableName->n >= TSDB_TABLE_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z); + pCxt->valid = false; + return false; } trimEscape(pTableName); - return pCxt->valid; + return true; } static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) { - if (NULL == pColumnName) { - pCxt->valid = true; - } else { - pCxt->valid = pColumnName->n < TSDB_COL_NAME_LEN ? true : false; + if (NULL != pColumnName && pColumnName->n >= TSDB_COL_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z); + pCxt->valid = false; + return false; } trimEscape(pColumnName); - return pCxt->valid; + return true; } static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) { - if (NULL == pIndexName) { + if (NULL != pIndexName && pIndexName->n >= TSDB_INDEX_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pIndexName->z); pCxt->valid = false; - } else { - pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false; + return false; } trimEscape(pIndexName); - return pCxt->valid; + return true; } SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { @@ -882,7 +866,9 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; pOptions->maxRowsPerBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK; pOptions->minRowsPerBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK; - pOptions->keep = TSDB_DEFAULT_KEEP; + pOptions->keep0 = TSDB_DEFAULT_KEEP; + pOptions->keep1 = TSDB_DEFAULT_KEEP; + pOptions->keep2 = TSDB_DEFAULT_KEEP; pOptions->precision = TSDB_TIME_PRECISION_MILLI; pOptions->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION; pOptions->replica = TSDB_DEFAULT_DB_REPLICA_OPTION; @@ -905,7 +891,9 @@ SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->fsyncPeriod = -1; pOptions->maxRowsPerBlock = -1; pOptions->minRowsPerBlock = -1; - pOptions->keep = -1; + pOptions->keep0 = -1; + pOptions->keep1 = -1; + pOptions->keep2= -1; pOptions->precision = -1; pOptions->quorum = -1; pOptions->replica = -1; @@ -921,6 +909,48 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal); } +static bool checkAndSetKeepOption(SAstCreateContext* pCxt, SNodeList* pKeep, int32_t* pKeep0, int32_t* pKeep1, int32_t* pKeep2) { + int32_t numOfKeep = LIST_LENGTH(pKeep); + if (numOfKeep > 3 || numOfKeep < 1) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid number of keep options"); + return false; + } + + int32_t daysToKeep0 = strtol(((SValueNode*)nodesListGetNode(pKeep, 0))->literal, NULL, 10); + int32_t daysToKeep1 = numOfKeep > 1 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 1))->literal, NULL, 10) : daysToKeep0; + int32_t daysToKeep2 = numOfKeep > 2 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 2))->literal, NULL, 10) : daysToKeep1; + if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP || + daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, + "invalid option keep: %d, %d, %d valid range: [%d, %d]", daysToKeep0, daysToKeep1, daysToKeep2, TSDB_MIN_KEEP, TSDB_MAX_KEEP); + return false; + } + + if (!((daysToKeep0 <= daysToKeep1) && (daysToKeep1 <= daysToKeep2))) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid keep value, should be keep0 <= keep1 <= keep2"); + return false; + } + + *pKeep0 = daysToKeep0; + *pKeep1 = daysToKeep1; + *pKeep2 = daysToKeep2; + return true; +} + +SNode* setDatabaseKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep) { + SDatabaseOptions* pOp = (SDatabaseOptions*)pOptions; + pCxt->valid = checkAndSetKeepOption(pCxt, pKeep, &pOp->keep0, &pOp->keep1, &pOp->keep2); + return pOptions; +} + +SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { + if (DB_OPTION_KEEP == pAlterOption->type) { + return setDatabaseKeepOption(pCxt, pOptions, pAlterOption->pKeep); + } else { + return setDatabaseOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val); + } +} + SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) { if (!checkDbName(pCxt, pDbName, false)) { return NULL; @@ -958,7 +988,9 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); - pOptions->keep = TSDB_DEFAULT_KEEP; + pOptions->keep0 = TSDB_DEFAULT_KEEP; + pOptions->keep1 = TSDB_DEFAULT_KEEP; + pOptions->keep2 = TSDB_DEFAULT_KEEP; pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION; pOptions->filesFactor = TSDB_DEFAULT_DB_FILE_FACTOR; pOptions->delay = TSDB_DEFAULT_DB_DELAY; @@ -968,7 +1000,9 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); - pOptions->keep = -1; + pOptions->keep0 = -1; + pOptions->keep1 = -1; + pOptions->keep2 = -1; pOptions->ttl = -1; pOptions->filesFactor = -1; pOptions->delay = -1; @@ -994,6 +1028,20 @@ SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* return pOptions; } +SNode* setTableKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep) { + STableOptions* pOp = (STableOptions*)pOptions; + pCxt->valid = checkAndSetKeepOption(pCxt, pKeep, &pOp->keep0, &pOp->keep1, &pOp->keep2); + return pOptions; +} + +SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { + if (TABLE_OPTION_KEEP == pAlterOption->type) { + return setTableKeepOption(pCxt, pOptions, pAlterOption->pKeep); + } else { + return setTableOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val); + } +} + SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment) { SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF); CHECK_OUT_OF_MEM(pCol); @@ -1017,6 +1065,9 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) { SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) { + if (NULL == pRealTable) { + return NULL; + } SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -1031,6 +1082,9 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags) { + if (NULL == pRealTable) { + return NULL; + } SCreateSubTableClause* pStmt = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -1053,6 +1107,9 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables } SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { + if (NULL == pRealTable) { + return NULL; + } SDropTableClause* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -1080,6 +1137,9 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S } SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { + if (NULL == pRealTable) { + return NULL; + } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS; @@ -1088,6 +1148,9 @@ SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* } SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType) { + if (NULL == pRealTable) { + return NULL; + } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; @@ -1097,6 +1160,9 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, } SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName) { + if (NULL == pRealTable) { + return NULL; + } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; @@ -1105,6 +1171,9 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_ } SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName) { + if (NULL == pRealTable) { + return NULL; + } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; @@ -1114,6 +1183,9 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int } SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal) { + if (NULL == pRealTable) { + return NULL; + } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; @@ -1343,3 +1415,21 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, pStmt->pQuery = pQuery; return (SNode*)pStmt; } + +SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) { + if (NULL == pRealTable) { + return NULL; + } + SDescribeStmt* pStmt = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); + CHECK_OUT_OF_MEM(pStmt); + strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); + strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); + nodesDestroyNode(pRealTable); + return (SNode*)pStmt; +} + +SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_RESET_QUERY_CACHE_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index ed67de17e0..e94dfd9e0a 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -65,7 +65,7 @@ typedef struct SInsertParseContext { SVnodeModifOpStmt* pOutput; } SInsertParseContext; -typedef int32_t (*_row_append_fn_t)(const void *value, int32_t len, void *param); +typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void *value, int32_t len, void *param); static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; @@ -444,26 +444,26 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int if (isNullStr(pToken)) { if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { int64_t tmpVal = 0; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } - return func(NULL, 0, param); + return func(pMsgBuf, NULL, 0, param); } switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { if (strncmp(pToken->z, "true", pToken->n) == 0) { - return func(&TRUE_VALUE, pSchema->bytes, param); + return func(pMsgBuf, &TRUE_VALUE, pSchema->bytes, param); } else if (strncmp(pToken->z, "false", pToken->n) == 0) { - return func(&FALSE_VALUE, pSchema->bytes, param); + return func(pMsgBuf, &FALSE_VALUE, pSchema->bytes, param); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } } else if (pToken->type == TK_NK_INTEGER) { - return func(((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); + return func(pMsgBuf, ((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); } else if (pToken->type == TK_NK_FLOAT) { - return func(((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); + return func(pMsgBuf, ((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } @@ -477,7 +477,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int } uint8_t tmpVal = (uint8_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_UTINYINT:{ @@ -487,7 +487,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "unsigned tinyint data overflow", pToken->z); } uint8_t tmpVal = (uint8_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_SMALLINT: { @@ -497,7 +497,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "smallint data overflow", pToken->z); } int16_t tmpVal = (int16_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_USMALLINT: { @@ -507,7 +507,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "unsigned smallint data overflow", pToken->z); } uint16_t tmpVal = (uint16_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_INT: { @@ -517,7 +517,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "int data overflow", pToken->z); } int32_t tmpVal = (int32_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_UINT: { @@ -527,7 +527,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "unsigned int data overflow", pToken->z); } uint32_t tmpVal = (uint32_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_BIGINT: { @@ -536,7 +536,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int } else if (!IS_VALID_BIGINT(iv)) { return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z); } - return func(&iv, pSchema->bytes, param); + return func(pMsgBuf, &iv, pSchema->bytes, param); } case TSDB_DATA_TYPE_UBIGINT: { @@ -546,7 +546,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "unsigned bigint data overflow", pToken->z); } uint64_t tmpVal = (uint64_t)iv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_FLOAT: { @@ -558,7 +558,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "illegal float data", pToken->z); } float tmpVal = (float)dv; - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } case TSDB_DATA_TYPE_DOUBLE: { @@ -569,7 +569,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) { return buildSyntaxErrMsg(pMsgBuf, "illegal double data", pToken->z); } - return func(&dv, pSchema->bytes, param); + return func(pMsgBuf, &dv, pSchema->bytes, param); } case TSDB_DATA_TYPE_BINARY: { @@ -578,11 +578,11 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "string data overflow", pToken->z); } - return func(pToken->z, pToken->n, param); + return func(pMsgBuf, pToken->z, pToken->n, param); } case TSDB_DATA_TYPE_NCHAR: { - return func(pToken->z, pToken->n, param); + return func(pMsgBuf, pToken->z, pToken->n, param); } case TSDB_DATA_TYPE_TIMESTAMP: { @@ -591,7 +591,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp", pToken->z); } - return func(&tmpVal, pSchema->bytes, param); + return func(pMsgBuf, &tmpVal, pSchema->bytes, param); } } @@ -605,7 +605,7 @@ typedef struct SMemParam { col_id_t colIdx; } SMemParam; -static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* param) { +static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) { SMemParam* pa = (SMemParam*)param; SRowBuilder* rb = pa->rb; if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { @@ -617,7 +617,9 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p int32_t output = 0; const char* rowEnd = tdRowEnd(rb->pBuf); if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { - return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + char buf[512] = {0}; + snprintf(buf, tListLen(buf), "%s", strerror(errno)); + return buildSyntaxErrMsg(pMsgBuf, buf, value); } varDataSetLen(rowEnd, output); tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); @@ -714,7 +716,7 @@ typedef struct SKvParam { char buf[TSDB_MAX_TAGS_LEN]; } SKvParam; -static int32_t KvRowAppend(const void *value, int32_t len, void *param) { +static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, void *param) { SKvParam* pa = (SKvParam*) param; int8_t type = pa->schema->type; @@ -727,7 +729,9 @@ static int32_t KvRowAppend(const void *value, int32_t len, void *param) { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { - return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + char buf[512] = {0}; + snprintf(buf, tListLen(buf), "%s", strerror(errno)); + return buildSyntaxErrMsg(pMsgBuf, buf, value);; } varDataSetLen(pa->buf, output); diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 213b14ae5d..817db3592d 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -51,6 +51,7 @@ static SKeyword keywordTable[] = { {"DAYS", TK_DAYS}, {"DELAY", TK_DELAY}, {"DESC", TK_DESC}, + {"DESCRIBE", TK_DESCRIBE}, {"DISTINCT", TK_DISTINCT}, {"DNODE", TK_DNODE}, {"DNODES", TK_DNODES}, @@ -111,9 +112,11 @@ static SKeyword keywordTable[] = { {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, {"QSTARTTS", TK_QSTARTTS}, + {"QUERY", TK_QUERY}, {"QUORUM", TK_QUORUM}, {"RATIO", TK_RATIO}, {"REPLICA", TK_REPLICA}, + {"RESET", TK_RESET}, {"RETENTIONS", TK_RETENTIONS}, {"ROLLUP", TK_ROLLUP}, {"ROWTS", TK_ROWTS}, @@ -186,7 +189,6 @@ static SKeyword keywordTable[] = { // {"SCORES", TK_SCORES}, // {"GRANTS", TK_GRANTS}, // {"DOT", TK_DOT}, - // {"DESCRIBE", TK_DESCRIBE}, // {"SYNCDB", TK_SYNCDB}, // {"LOCAL", TK_LOCAL}, // {"PPS", TK_PPS}, @@ -203,8 +205,6 @@ static SKeyword keywordTable[] = { // {"EVERY", TK_EVERY}, // {"VARIABLE", TK_VARIABLE}, // {"UPDATE", TK_UPDATE}, - // {"RESET", TK_RESET}, - // {"QUERY", TK_QUERY}, // {"ADD", TK_ADD}, // {"COLUMN", TK_COLUMN}, // {"TAG", TK_TAG}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d453193d0f..f8bd51ded6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -956,9 +956,9 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->cacheBlockSize = pStmt->pOptions->cacheBlockSize; pReq->totalBlocks = pStmt->pOptions->numOfBlocks; pReq->daysPerFile = pStmt->pOptions->daysPerFile; - pReq->daysToKeep0 = pStmt->pOptions->keep; - pReq->daysToKeep1 = -1; - pReq->daysToKeep2 = -1; + pReq->daysToKeep0 = pStmt->pOptions->keep0; + pReq->daysToKeep1 = pStmt->pOptions->keep1; + pReq->daysToKeep2 = pStmt->pOptions->keep2; pReq->minRows = pStmt->pOptions->minRowsPerBlock; pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; pReq->commitTime = -1; @@ -1041,13 +1041,14 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, pReq->db); pReq->totalBlocks = pStmt->pOptions->numOfBlocks; - pReq->daysToKeep0 = pStmt->pOptions->keep; - pReq->daysToKeep1 = -1; - pReq->daysToKeep2 = -1; + pReq->daysToKeep0 = pStmt->pOptions->keep0; + pReq->daysToKeep1 = pStmt->pOptions->keep1; + pReq->daysToKeep2 = pStmt->pOptions->keep2; pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->walLevel = pStmt->pOptions->walLevel; pReq->quorum = pStmt->pOptions->quorum; pReq->cacheLastRow = pStmt->pOptions->cachelast; + pReq->replications = pStmt->pOptions->replica; return; } @@ -1119,7 +1120,7 @@ static const SColumnDefNode* findColDef(const SNodeList* pCols, const SColumnNod return NULL; } -static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { +static int32_t checkCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { if (NULL != pStmt->pOptions->pSma) { SNode* pNode = NULL; FOREACH(pNode, pStmt->pOptions->pSma) { @@ -1148,7 +1149,7 @@ static int32_t getAggregationMethod(SNodeList* pFuncs) { } static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { - int32_t code = checkCreateTable(pCxt, pStmt); + int32_t code = checkCreateSuperTable(pCxt, pStmt); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -1217,6 +1218,9 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt SName tableName; int32_t code = getTableMetaImpl( pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); + if ((TSDB_CODE_TDB_INVALID_TABLE_ID == code || TSDB_CODE_VND_TB_NOT_EXIST == code) && pClause->ignoreNotExists) { + return TSDB_CODE_SUCCESS; + } if (TSDB_CODE_SUCCESS == code) { if (TSDB_SUPER_TABLE == pTableMeta->tableType) { code = doTranslateDropSuperTable(pCxt, &tableName, pClause->ignoreNotExists); @@ -1812,6 +1816,10 @@ static int32_t translateExplain(STranslateContext* pCxt, SExplainStmt* pStmt) { return translateQuery(pCxt, pStmt->pQuery); } +static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) { + return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1896,6 +1904,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_EXPLAIN_STMT: code = translateExplain(pCxt, (SExplainStmt*)pNode); break; + case QUERY_NODE_DESCRIBE_STMT: + code = translateDescribe(pCxt, (SDescribeStmt*)pNode); + break; default: break; } @@ -1913,40 +1924,82 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { return code; } -int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { +static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = LIST_LENGTH(pSelect->pProjectionList); + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SNode* pNode; + int32_t index = 0; + FOREACH(pNode, pSelect->pProjectionList) { + SExprNode* pExpr = (SExprNode*)pNode; + (*pSchema)[index].type = pExpr->resType.type; + (*pSchema)[index].bytes = pExpr->resType.bytes; + (*pSchema)[index].colId = index + 1; + strcpy((*pSchema)[index].name, pExpr->aliasName); + index +=1; + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = 1; + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; + strcpy((*pSchema)[0].name, TSDB_EXPLAIN_RESULT_COLUMN_NAME); + return TSDB_CODE_SUCCESS; +} + +static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = DESCRIBE_RESULT_COLS; + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[0].bytes = DESCRIBE_RESULT_FIELD_LEN; + strcpy((*pSchema)[0].name, "Field"); + + (*pSchema)[1].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[1].bytes = DESCRIBE_RESULT_TYPE_LEN; + strcpy((*pSchema)[1].name, "Type"); + + (*pSchema)[2].type = TSDB_DATA_TYPE_INT; + (*pSchema)[2].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + strcpy((*pSchema)[2].name, "Length"); + + (*pSchema)[3].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN; + strcpy((*pSchema)[3].name, "Note"); + + return TSDB_CODE_SUCCESS; +} + +int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { if (NULL == pRoot) { return TSDB_CODE_SUCCESS; } - if (QUERY_NODE_SELECT_STMT == nodeType(pRoot)) { - SSelectStmt* pSelect = (SSelectStmt*) pRoot; - *numOfCols = LIST_LENGTH(pSelect->pProjectionList); - *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); - if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - SNode* pNode; - int32_t index = 0; - FOREACH(pNode, pSelect->pProjectionList) { - SExprNode* pExpr = (SExprNode*)pNode; - (*pSchema)[index].type = pExpr->resType.type; - (*pSchema)[index].bytes = pExpr->resType.bytes; - (*pSchema)[index].colId = index + 1; - strcpy((*pSchema)[index].name, pExpr->aliasName); - index +=1; - } - } else if (QUERY_NODE_EXPLAIN_STMT == nodeType(pRoot)) { - *numOfCols = 1; - *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); - if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; - } - (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; - (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; + switch (nodeType(pRoot)) { + case QUERY_NODE_SELECT_STMT: + return extractSelectResultSchema((SSelectStmt*)pRoot, numOfCols, pSchema); + case QUERY_NODE_EXPLAIN_STMT: + return extractExplainResultSchema(numOfCols, pSchema); + case QUERY_NODE_DESCRIBE_STMT: + return extractDescribeResultSchema(numOfCols, pSchema); + default: + break; } - return TSDB_CODE_SUCCESS; + return TSDB_CODE_FAILED; } static void destroyTranslateContext(STranslateContext* pCxt) { @@ -2119,7 +2172,7 @@ typedef struct SVgroupTablesBatch { static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchema) { pSchema->colId = colId; pSchema->type = pCol->dataType.type; - pSchema->bytes = pCol->dataType.bytes; + pSchema->bytes = calcTypeBytes(pCol->dataType); strcpy(pSchema->name, pCol->colName); } @@ -2396,9 +2449,19 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau return TSDB_CODE_SUCCESS; } +static int32_t checkCreateSubTable(STranslateContext* pCxt, SCreateSubTableClause* pStmt) { + if (0 != strcmp(pStmt->dbName, pStmt->useDbName)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR);; + } + return TSDB_CODE_SUCCESS; +} static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableClause* pStmt, SHashObj* pVgroupHashmap) { + int32_t code = checkCreateSubTable(pCxt, pStmt); + STableMeta* pSuperTableMeta = NULL; - int32_t code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta); + if (TSDB_CODE_SUCCESS == code) { + code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta); + } SKVRowBuilder kvRowBuilder = {0}; if (TSDB_CODE_SUCCESS == code) { @@ -2530,24 +2593,31 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SELECT_STMT: case QUERY_NODE_EXPLAIN_STMT: pQuery->haveResultSet = true; - pQuery->directRpc = false; pQuery->msgType = TDMT_VND_QUERY; - if (TSDB_CODE_SUCCESS != qExtractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; - } break; case QUERY_NODE_VNODE_MODIF_STMT: - pQuery->haveResultSet = false; - pQuery->directRpc = false; pQuery->msgType = TDMT_VND_CREATE_TABLE; break; - default: - pQuery->haveResultSet = false; - pQuery->directRpc = true; - pQuery->pCmdMsg = pCxt->pCmdMsg; - pCxt->pCmdMsg = NULL; - pQuery->msgType = pQuery->pCmdMsg->msgType; + case QUERY_NODE_DESCRIBE_STMT: + pQuery->localCmd = true; + pQuery->haveResultSet = true; break; + case QUERY_NODE_RESET_QUERY_CACHE_STMT: + pQuery->localCmd = true; + break; + default: + pQuery->directRpc = true; + if (NULL != pCxt->pCmdMsg) { + TSWAP(pQuery->pCmdMsg, pCxt->pCmdMsg, SCmdMsgInfo*); + pQuery->msgType = pQuery->pCmdMsg->msgType; + } + break; + } + + if (pQuery->haveResultSet) { + if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } } if (NULL != pCxt->pDbs) { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 80d04c5ee4..aeed7719f3 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -61,6 +61,12 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "This statement is no longer supported"; case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL: return "This interval value is too small : %s"; + case TSDB_CODE_PAR_DB_NOT_SPECIFIED: + return "db not specified"; + case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME: + return "Invalid identifier name : %s"; + case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR: + return "corresponding super table not in this db"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index d9bff4b9ef..d410aa2e17 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -62,3 +62,7 @@ void qDestroyQuery(SQuery* pQueryNode) { taosArrayDestroy(pQueryNode->pTableList); taosMemoryFreeClear(pQueryNode); } + +int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { + return extractResultSchema(pRoot, numOfCols, pSchema); +} \ No newline at end of file diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 154b87ba4b..1252943f6e 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 274 +#define YYNOCODE 278 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SAlterOption yy29; - SNodeList* yy40; - ENullOrder yy177; - EOrder yy210; - EOperatorType yy328; - SNode* yy364; - EJoinType yy392; - SDataType yy420; - SToken yy437; - int32_t yy460; - EFillMode yy478; - bool yy493; + SNode* yy24; + EOperatorType yy36; + ENullOrder yy45; + int32_t yy104; + SDataType yy212; + bool yy265; + EJoinType yy320; + SToken yy337; + EOrder yy346; + SNodeList* yy504; + EFillMode yy550; + SAlterOption yy553; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,17 +132,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 438 -#define YYNRULE 354 -#define YYNTOKEN 176 -#define YY_MAX_SHIFT 437 -#define YY_MIN_SHIFTREDUCE 684 -#define YY_MAX_SHIFTREDUCE 1037 -#define YY_ERROR_ACTION 1038 -#define YY_ACCEPT_ACTION 1039 -#define YY_NO_ACTION 1040 -#define YY_MIN_REDUCE 1041 -#define YY_MAX_REDUCE 1394 +#define YYNSTATE 451 +#define YYNRULE 360 +#define YYNTOKEN 179 +#define YY_MAX_SHIFT 450 +#define YY_MIN_SHIFTREDUCE 696 +#define YY_MAX_SHIFTREDUCE 1055 +#define YY_ERROR_ACTION 1056 +#define YY_ACCEPT_ACTION 1057 +#define YY_NO_ACTION 1058 +#define YY_MIN_REDUCE 1059 +#define YY_MAX_REDUCE 1418 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -209,408 +209,417 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1305) +#define YY_ACTTAB_COUNT (1316) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1251, 337, 24, 172, 356, 356, 256, 241, 1247, 1254, - /* 10 */ 1220, 1221, 31, 29, 27, 26, 25, 1264, 369, 369, - /* 20 */ 9, 8, 93, 67, 67, 31, 29, 27, 26, 25, - /* 30 */ 286, 292, 337, 1373, 106, 60, 1053, 1280, 369, 1144, - /* 40 */ 1144, 341, 1135, 276, 353, 94, 118, 215, 1084, 249, - /* 50 */ 1371, 91, 1136, 93, 355, 979, 1211, 1213, 1238, 1144, - /* 60 */ 215, 165, 1319, 336, 110, 335, 1087, 44, 1373, 913, - /* 70 */ 63, 1265, 1266, 1269, 1312, 1184, 90, 943, 231, 1308, - /* 80 */ 1385, 118, 91, 1238, 1139, 1371, 107, 1111, 956, 1346, - /* 90 */ 943, 339, 114, 1319, 1320, 257, 1324, 422, 421, 420, - /* 100 */ 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, - /* 110 */ 409, 408, 407, 406, 405, 298, 944, 293, 105, 242, - /* 120 */ 297, 213, 898, 296, 368, 294, 1147, 105, 295, 944, - /* 130 */ 31, 29, 27, 26, 25, 1146, 368, 1122, 23, 236, - /* 140 */ 938, 939, 940, 941, 942, 946, 947, 948, 27, 26, - /* 150 */ 25, 23, 236, 938, 939, 940, 941, 942, 946, 947, - /* 160 */ 948, 793, 392, 391, 390, 797, 389, 799, 800, 388, - /* 170 */ 802, 385, 1264, 808, 382, 810, 811, 379, 376, 229, - /* 180 */ 30, 28, 337, 277, 12, 30, 28, 980, 238, 277, - /* 190 */ 878, 246, 1280, 238, 1264, 878, 1251, 310, 255, 353, - /* 200 */ 254, 1191, 978, 93, 1247, 1253, 876, 228, 1251, 355, - /* 210 */ 308, 876, 1189, 1238, 1280, 11, 1247, 1253, 341, 369, - /* 220 */ 11, 340, 248, 119, 1141, 62, 1265, 1266, 1269, 1312, - /* 230 */ 105, 355, 91, 214, 1308, 1238, 1, 265, 1146, 1120, - /* 240 */ 1144, 1, 115, 1319, 1320, 1373, 1324, 63, 1265, 1266, - /* 250 */ 1269, 1312, 119, 1191, 720, 231, 1308, 113, 118, 243, - /* 260 */ 434, 6, 1371, 902, 1189, 434, 119, 430, 429, 168, - /* 270 */ 284, 312, 877, 1280, 1280, 319, 1339, 877, 30, 28, - /* 280 */ 353, 353, 124, 123, 222, 404, 238, 1264, 878, 1033, - /* 290 */ 1034, 326, 1331, 975, 879, 53, 882, 883, 204, 879, - /* 300 */ 926, 882, 883, 204, 876, 926, 290, 1280, 327, 330, - /* 310 */ 289, 313, 1137, 11, 340, 721, 1373, 720, 119, 1264, - /* 320 */ 223, 1191, 221, 220, 355, 288, 332, 328, 1238, 1372, - /* 330 */ 1064, 291, 1212, 1371, 1, 722, 119, 368, 1373, 1280, - /* 340 */ 63, 1265, 1266, 1269, 1312, 404, 353, 369, 231, 1308, - /* 350 */ 113, 118, 366, 30, 28, 1371, 355, 369, 434, 900, - /* 360 */ 1238, 238, 367, 878, 395, 167, 1264, 975, 1144, 1340, - /* 370 */ 877, 1238, 63, 1265, 1266, 1269, 1312, 1191, 1144, 876, - /* 380 */ 231, 1308, 1385, 250, 1063, 12, 1280, 192, 1189, 331, - /* 390 */ 1174, 1369, 879, 353, 882, 883, 204, 337, 926, 139, - /* 400 */ 251, 1062, 137, 355, 30, 28, 354, 1238, 105, 7, - /* 410 */ 369, 303, 238, 348, 878, 186, 1146, 44, 93, 63, - /* 420 */ 1265, 1266, 1269, 1312, 1061, 1238, 311, 231, 1308, 1385, - /* 430 */ 876, 1144, 945, 434, 1140, 987, 30, 28, 1330, 345, - /* 440 */ 147, 900, 1238, 306, 238, 877, 878, 91, 300, 1060, - /* 450 */ 1326, 146, 1264, 1059, 21, 1191, 901, 116, 1319, 1320, - /* 460 */ 7, 1324, 876, 949, 899, 1238, 1190, 879, 1323, 882, - /* 470 */ 883, 204, 1280, 926, 41, 30, 28, 40, 1004, 353, - /* 480 */ 1121, 1326, 369, 238, 434, 878, 1058, 252, 1208, 355, - /* 490 */ 1238, 119, 7, 1238, 1238, 122, 877, 1039, 341, 1322, - /* 500 */ 344, 876, 349, 1144, 1057, 205, 1265, 1266, 1269, 323, - /* 510 */ 1002, 1003, 1005, 1006, 1326, 290, 434, 1056, 879, 289, - /* 520 */ 882, 883, 204, 1055, 926, 1373, 346, 1238, 877, 898, - /* 530 */ 1052, 1, 1321, 9, 8, 903, 258, 401, 118, 270, - /* 540 */ 291, 400, 1371, 1264, 141, 1238, 253, 140, 271, 1133, - /* 550 */ 879, 352, 882, 883, 204, 434, 926, 143, 1238, 886, - /* 560 */ 142, 1051, 402, 1280, 1238, 20, 1050, 877, 1049, 1112, - /* 570 */ 353, 1238, 1129, 1373, 1264, 31, 29, 27, 26, 25, - /* 580 */ 355, 399, 398, 397, 1238, 396, 118, 1036, 1037, 879, - /* 590 */ 1371, 882, 883, 204, 1280, 926, 64, 1265, 1266, 1269, - /* 600 */ 1312, 353, 1238, 145, 1311, 1308, 144, 1238, 1131, 1238, - /* 610 */ 1048, 355, 1047, 1264, 315, 1238, 269, 1046, 1264, 264, - /* 620 */ 263, 262, 261, 260, 1045, 889, 99, 64, 1265, 1266, - /* 630 */ 1269, 1312, 935, 1280, 1001, 351, 1308, 153, 1280, 298, - /* 640 */ 353, 293, 1080, 1127, 297, 353, 42, 296, 1075, 294, - /* 650 */ 355, 1238, 295, 1238, 1238, 355, 1264, 1119, 1238, 1238, - /* 660 */ 1042, 885, 1044, 343, 299, 1238, 108, 1265, 1266, 1269, - /* 670 */ 301, 64, 1265, 1266, 1269, 1312, 1280, 169, 394, 1054, - /* 680 */ 1309, 78, 158, 353, 77, 76, 75, 74, 73, 72, - /* 690 */ 71, 70, 69, 355, 156, 324, 1264, 1238, 1073, 878, - /* 700 */ 237, 1264, 1185, 1238, 342, 1386, 162, 950, 283, 209, - /* 710 */ 1265, 1266, 1269, 1258, 401, 876, 1280, 1342, 400, 32, - /* 720 */ 304, 1280, 910, 353, 865, 1256, 338, 888, 353, 1281, - /* 730 */ 171, 871, 177, 355, 32, 361, 32, 1238, 355, 402, - /* 740 */ 320, 183, 1238, 1264, 175, 2, 190, 96, 898, 209, - /* 750 */ 1265, 1266, 1269, 97, 208, 1265, 1266, 1269, 399, 398, - /* 760 */ 397, 1210, 396, 1280, 121, 22, 259, 267, 266, 434, - /* 770 */ 353, 786, 268, 1264, 272, 31, 29, 27, 26, 25, - /* 780 */ 355, 877, 781, 99, 1238, 906, 333, 126, 31, 29, - /* 790 */ 27, 26, 25, 1280, 42, 1264, 108, 1265, 1266, 1269, - /* 800 */ 353, 273, 274, 879, 814, 882, 883, 818, 905, 824, - /* 810 */ 355, 823, 100, 129, 1238, 1280, 374, 235, 275, 97, - /* 820 */ 437, 98, 353, 99, 97, 278, 209, 1265, 1266, 1269, - /* 830 */ 43, 132, 355, 904, 189, 1387, 1238, 89, 287, 239, - /* 840 */ 285, 314, 227, 426, 317, 188, 59, 88, 209, 1265, - /* 850 */ 1266, 1269, 1041, 1134, 78, 136, 55, 77, 76, 75, - /* 860 */ 74, 73, 72, 71, 70, 69, 1130, 138, 61, 101, - /* 870 */ 1264, 184, 102, 1132, 1128, 103, 87, 86, 85, 84, - /* 880 */ 83, 82, 81, 80, 79, 104, 316, 148, 151, 925, - /* 890 */ 1280, 927, 928, 929, 930, 931, 903, 353, 1353, 325, - /* 900 */ 197, 1264, 365, 359, 154, 199, 883, 355, 322, 1343, - /* 910 */ 157, 1238, 1352, 230, 329, 5, 161, 198, 334, 318, - /* 920 */ 321, 1280, 149, 207, 1265, 1266, 1269, 125, 353, 975, - /* 930 */ 1333, 1264, 31, 29, 27, 26, 25, 111, 355, 4, - /* 940 */ 163, 902, 1238, 92, 1327, 33, 232, 17, 164, 347, - /* 950 */ 350, 1280, 1388, 1264, 210, 1265, 1266, 1269, 353, 1294, - /* 960 */ 1370, 362, 170, 179, 191, 1219, 1218, 357, 355, 358, - /* 970 */ 364, 240, 1238, 1280, 363, 1264, 181, 52, 1145, 54, - /* 980 */ 353, 372, 193, 187, 202, 1265, 1266, 1269, 65, 913, - /* 990 */ 355, 433, 195, 39, 1238, 1280, 200, 1264, 201, 196, - /* 1000 */ 1232, 874, 353, 873, 1226, 120, 211, 1265, 1266, 1269, - /* 1010 */ 848, 1203, 355, 1202, 95, 1201, 1238, 1280, 1200, 1264, - /* 1020 */ 1199, 1198, 1197, 1196, 353, 850, 1195, 1194, 203, 1265, - /* 1030 */ 1266, 1269, 119, 1193, 355, 1192, 1086, 1225, 1238, 1280, - /* 1040 */ 1216, 1264, 128, 1123, 733, 1085, 353, 1083, 279, 281, - /* 1050 */ 212, 1265, 1266, 1269, 1072, 280, 355, 1071, 1068, 1125, - /* 1060 */ 1238, 1280, 68, 1264, 135, 1124, 831, 830, 353, 761, - /* 1070 */ 829, 1081, 1277, 1265, 1266, 1269, 760, 759, 355, 758, - /* 1080 */ 757, 1076, 1238, 1280, 756, 224, 225, 1264, 302, 1074, - /* 1090 */ 353, 226, 1067, 305, 1276, 1265, 1266, 1269, 307, 1066, - /* 1100 */ 355, 309, 66, 1224, 1238, 1223, 36, 1280, 152, 150, - /* 1110 */ 14, 1264, 1215, 3, 353, 32, 1275, 1265, 1266, 1269, - /* 1120 */ 245, 244, 155, 15, 355, 37, 34, 10, 1238, 46, - /* 1130 */ 891, 1280, 160, 1264, 49, 1022, 1000, 994, 353, 993, - /* 1140 */ 218, 1265, 1266, 1269, 972, 109, 884, 1021, 355, 233, - /* 1150 */ 8, 159, 1238, 1280, 47, 1264, 48, 1026, 1256, 971, - /* 1160 */ 353, 19, 1025, 1027, 217, 1265, 1266, 1269, 35, 234, - /* 1170 */ 355, 166, 13, 117, 1238, 1280, 16, 1264, 936, 911, - /* 1180 */ 173, 18, 353, 174, 998, 176, 219, 1265, 1266, 1269, - /* 1190 */ 178, 50, 355, 360, 1214, 180, 1238, 1280, 55, 893, - /* 1200 */ 370, 182, 51, 38, 353, 1255, 185, 371, 216, 1265, - /* 1210 */ 1266, 1269, 887, 815, 355, 375, 134, 373, 1238, 112, - /* 1220 */ 247, 807, 812, 377, 378, 282, 809, 133, 380, 381, - /* 1230 */ 206, 1265, 1266, 1269, 892, 803, 895, 883, 383, 384, - /* 1240 */ 386, 801, 387, 806, 805, 804, 792, 393, 56, 826, - /* 1250 */ 45, 822, 57, 131, 58, 821, 820, 731, 825, 403, - /* 1260 */ 753, 752, 745, 751, 750, 749, 748, 747, 746, 744, - /* 1270 */ 743, 742, 1082, 741, 740, 739, 1070, 738, 1069, 737, - /* 1280 */ 736, 423, 424, 427, 428, 1065, 431, 425, 432, 1040, - /* 1290 */ 880, 194, 435, 436, 1040, 1040, 1040, 1040, 1040, 1040, - /* 1300 */ 130, 1040, 1040, 1040, 127, + /* 0 */ 1275, 368, 1288, 1154, 247, 1397, 46, 1241, 1271, 1278, + /* 10 */ 1304, 1288, 31, 29, 27, 26, 25, 365, 1396, 108, + /* 20 */ 349, 1071, 1395, 1304, 1161, 31, 29, 27, 26, 25, + /* 30 */ 365, 380, 1304, 31, 29, 27, 26, 25, 235, 352, + /* 40 */ 367, 1150, 95, 380, 1262, 339, 732, 221, 1102, 367, + /* 50 */ 27, 26, 25, 1262, 1304, 1275, 214, 1289, 1290, 1293, + /* 60 */ 221, 365, 295, 1271, 1277, 65, 1289, 1290, 1293, 1336, + /* 70 */ 931, 93, 920, 237, 1332, 115, 24, 176, 961, 1105, + /* 80 */ 351, 116, 1343, 1344, 1212, 1348, 61, 172, 345, 342, + /* 90 */ 234, 961, 12, 331, 1363, 1210, 57, 435, 434, 433, + /* 100 */ 432, 431, 430, 429, 428, 192, 425, 424, 423, 422, + /* 110 */ 421, 420, 419, 418, 417, 81, 962, 46, 80, 79, + /* 120 */ 78, 77, 76, 75, 74, 73, 72, 92, 310, 962, + /* 130 */ 305, 381, 733, 309, 732, 1160, 149, 266, 306, 304, + /* 140 */ 268, 307, 23, 242, 956, 957, 958, 959, 960, 964, + /* 150 */ 965, 966, 734, 1165, 1156, 23, 242, 956, 957, 958, + /* 160 */ 959, 960, 964, 965, 966, 1288, 916, 219, 1057, 31, + /* 170 */ 29, 27, 26, 25, 171, 808, 404, 403, 402, 812, + /* 180 */ 401, 814, 815, 400, 817, 397, 1304, 823, 394, 825, + /* 190 */ 826, 391, 388, 365, 112, 1143, 1262, 380, 30, 28, + /* 200 */ 261, 1082, 260, 367, 381, 1205, 244, 1262, 896, 1288, + /* 210 */ 267, 943, 353, 945, 946, 947, 948, 949, 259, 64, + /* 220 */ 1289, 1290, 1293, 1336, 894, 121, 1165, 220, 1332, 109, + /* 230 */ 1304, 1129, 248, 11, 30, 28, 998, 352, 918, 1397, + /* 240 */ 107, 288, 244, 1262, 896, 1397, 12, 367, 1167, 30, + /* 250 */ 28, 1262, 120, 107, 1022, 1, 1395, 244, 120, 896, + /* 260 */ 894, 1168, 1395, 65, 1289, 1290, 1293, 1336, 1212, 11, + /* 270 */ 1212, 237, 1332, 115, 249, 894, 256, 1350, 447, 1210, + /* 280 */ 1052, 1210, 252, 349, 11, 335, 1020, 1021, 1023, 1024, + /* 290 */ 895, 1, 1364, 1081, 916, 1347, 315, 1355, 993, 1275, + /* 300 */ 121, 269, 255, 262, 281, 95, 1, 1271, 1277, 1232, + /* 310 */ 1234, 323, 6, 282, 447, 381, 897, 381, 900, 901, + /* 320 */ 210, 287, 944, 1162, 353, 151, 895, 963, 318, 447, + /* 330 */ 1397, 121, 1051, 312, 93, 1262, 150, 1165, 1288, 1165, + /* 340 */ 121, 895, 288, 120, 169, 1343, 348, 1395, 347, 254, + /* 350 */ 921, 1397, 897, 21, 900, 901, 210, 107, 944, 1304, + /* 360 */ 41, 1288, 967, 40, 120, 1167, 365, 897, 1395, 900, + /* 370 */ 901, 210, 324, 944, 343, 257, 367, 9, 8, 62, + /* 380 */ 1262, 280, 1304, 107, 275, 274, 273, 272, 271, 365, + /* 390 */ 96, 1167, 65, 1289, 1290, 1293, 1336, 1157, 381, 367, + /* 400 */ 237, 1332, 1409, 1262, 378, 1288, 148, 357, 381, 1080, + /* 410 */ 300, 1370, 1141, 325, 69, 65, 1289, 1290, 1293, 1336, + /* 420 */ 1165, 297, 993, 237, 1332, 1409, 1304, 1350, 30, 28, + /* 430 */ 1165, 302, 338, 365, 1393, 368, 244, 1079, 896, 121, + /* 440 */ 1397, 1242, 1078, 367, 381, 1346, 974, 1262, 1077, 1288, + /* 450 */ 379, 1262, 157, 120, 894, 1076, 276, 1395, 416, 65, + /* 460 */ 1289, 1290, 1293, 1336, 349, 1075, 1165, 237, 1332, 1409, + /* 470 */ 1304, 344, 340, 30, 28, 366, 381, 365, 1354, 1262, + /* 480 */ 356, 244, 69, 896, 1262, 7, 95, 367, 1229, 303, + /* 490 */ 1262, 1262, 443, 442, 381, 124, 353, 1262, 1165, 894, + /* 500 */ 190, 126, 125, 211, 1289, 1290, 1293, 1262, 447, 30, + /* 510 */ 28, 997, 358, 1074, 1073, 93, 1165, 244, 1070, 896, + /* 520 */ 895, 1069, 349, 1397, 1350, 117, 1343, 1344, 416, 1348, + /* 530 */ 7, 919, 1068, 30, 28, 894, 120, 1067, 1066, 55, + /* 540 */ 1395, 244, 1345, 896, 95, 381, 897, 1212, 900, 901, + /* 550 */ 210, 258, 944, 447, 1288, 1262, 1262, 1158, 1233, 894, + /* 560 */ 1262, 1065, 1064, 1262, 1063, 895, 7, 1165, 917, 198, + /* 570 */ 121, 203, 1195, 93, 1262, 1304, 205, 1062, 141, 1262, + /* 580 */ 1262, 139, 365, 118, 1343, 1344, 1288, 1348, 204, 447, + /* 590 */ 1, 897, 367, 900, 901, 210, 1262, 944, 127, 1005, + /* 600 */ 1098, 895, 407, 1262, 1262, 918, 1262, 1304, 66, 1289, + /* 610 */ 1290, 1293, 1336, 447, 365, 143, 1335, 1332, 142, 1262, + /* 620 */ 145, 1212, 311, 144, 367, 895, 360, 897, 1262, 900, + /* 630 */ 901, 210, 1211, 944, 1093, 147, 1152, 1288, 146, 1091, + /* 640 */ 66, 1289, 1290, 1293, 1336, 1288, 1148, 355, 363, 1332, + /* 650 */ 322, 897, 364, 900, 901, 210, 313, 944, 1304, 67, + /* 660 */ 406, 316, 996, 320, 101, 365, 1304, 327, 896, 42, + /* 670 */ 904, 160, 1019, 365, 162, 367, 44, 43, 265, 1262, + /* 680 */ 122, 9, 8, 367, 894, 1054, 1055, 1262, 1060, 903, + /* 690 */ 173, 110, 1289, 1290, 1293, 32, 1072, 1130, 968, 66, + /* 700 */ 1289, 1290, 1293, 1336, 336, 1206, 1288, 121, 1333, 81, + /* 710 */ 166, 20, 80, 79, 78, 77, 76, 75, 74, 73, + /* 720 */ 72, 31, 29, 27, 26, 25, 1288, 1304, 294, 354, + /* 730 */ 1410, 1288, 32, 361, 365, 928, 907, 953, 447, 31, + /* 740 */ 29, 27, 26, 25, 367, 1282, 32, 1304, 1262, 880, + /* 750 */ 895, 243, 1304, 179, 365, 906, 181, 1280, 1366, 365, + /* 760 */ 215, 1289, 1290, 1293, 367, 251, 250, 98, 1262, 367, + /* 770 */ 373, 332, 1288, 1262, 350, 909, 897, 1288, 900, 901, + /* 780 */ 215, 1289, 1290, 1293, 1305, 110, 1289, 1290, 1293, 99, + /* 790 */ 2, 902, 187, 1304, 889, 175, 196, 931, 1304, 101, + /* 800 */ 365, 42, 801, 386, 796, 365, 829, 916, 1231, 99, + /* 810 */ 367, 1059, 833, 100, 1262, 367, 839, 241, 101, 1262, + /* 820 */ 123, 838, 245, 278, 1411, 270, 215, 1289, 1290, 1293, + /* 830 */ 277, 215, 1289, 1290, 1293, 90, 89, 88, 87, 86, + /* 840 */ 85, 84, 83, 82, 450, 382, 279, 99, 283, 1288, + /* 850 */ 102, 924, 22, 284, 128, 285, 923, 905, 195, 286, + /* 860 */ 1288, 91, 31, 29, 27, 26, 25, 439, 922, 194, + /* 870 */ 1304, 131, 45, 289, 134, 296, 298, 365, 1155, 775, + /* 880 */ 138, 1304, 301, 910, 326, 913, 901, 367, 365, 71, + /* 890 */ 1151, 1262, 140, 63, 308, 103, 188, 1288, 367, 104, + /* 900 */ 1153, 1149, 1262, 213, 1289, 1290, 1293, 105, 233, 106, + /* 910 */ 152, 921, 155, 328, 216, 1289, 1290, 1293, 1304, 228, + /* 920 */ 329, 337, 371, 1377, 901, 365, 377, 1288, 1367, 1376, + /* 930 */ 165, 5, 1357, 158, 334, 367, 161, 236, 341, 1262, + /* 940 */ 346, 148, 333, 330, 920, 300, 153, 1288, 1304, 4, + /* 950 */ 993, 208, 1289, 1290, 1293, 365, 229, 94, 227, 226, + /* 960 */ 1351, 299, 1142, 168, 33, 367, 302, 362, 1304, 1262, + /* 970 */ 1288, 238, 113, 359, 17, 365, 167, 1240, 1318, 369, + /* 980 */ 370, 217, 1289, 1290, 1293, 367, 374, 183, 1239, 1262, + /* 990 */ 174, 1304, 1394, 246, 1288, 1412, 375, 376, 365, 197, + /* 1000 */ 1288, 209, 1289, 1290, 1293, 56, 185, 54, 367, 1166, + /* 1010 */ 384, 199, 1262, 413, 427, 1304, 193, 446, 202, 191, + /* 1020 */ 39, 1304, 365, 412, 218, 1289, 1290, 1293, 365, 206, + /* 1030 */ 1256, 207, 367, 201, 892, 1250, 1262, 1249, 367, 891, + /* 1040 */ 263, 1288, 1262, 264, 414, 1248, 1247, 863, 1301, 1289, + /* 1050 */ 1290, 1293, 1288, 1224, 1300, 1289, 1290, 1293, 1140, 1223, + /* 1060 */ 97, 1222, 1304, 411, 410, 409, 1221, 408, 1220, 365, + /* 1070 */ 1219, 1218, 1217, 1304, 865, 1216, 1215, 1214, 1213, 367, + /* 1080 */ 365, 1104, 1246, 1262, 1237, 130, 1144, 745, 1103, 1288, + /* 1090 */ 367, 1101, 290, 291, 1262, 1299, 1289, 1290, 1293, 292, + /* 1100 */ 1288, 1090, 1089, 1086, 1146, 70, 224, 1289, 1290, 1293, + /* 1110 */ 1304, 846, 137, 1145, 426, 191, 844, 365, 774, 412, + /* 1120 */ 1099, 1304, 230, 773, 1094, 772, 1092, 367, 365, 231, + /* 1130 */ 1288, 1262, 314, 771, 769, 768, 232, 317, 367, 1085, + /* 1140 */ 414, 319, 1262, 223, 1289, 1290, 1293, 1084, 68, 321, + /* 1150 */ 1245, 1304, 1288, 1244, 225, 1289, 1290, 1293, 365, 411, + /* 1160 */ 410, 409, 36, 408, 1236, 154, 156, 48, 367, 14, + /* 1170 */ 1280, 15, 1262, 1304, 111, 3, 32, 37, 34, 10, + /* 1180 */ 365, 159, 1018, 164, 222, 1289, 1290, 1293, 136, 51, + /* 1190 */ 367, 114, 163, 8, 1262, 1012, 170, 293, 49, 135, + /* 1200 */ 1011, 50, 19, 990, 989, 35, 212, 1289, 1290, 1293, + /* 1210 */ 1045, 310, 119, 305, 1040, 16, 309, 1039, 239, 149, + /* 1220 */ 1044, 306, 304, 47, 307, 1043, 133, 240, 929, 13, + /* 1230 */ 177, 178, 18, 1235, 186, 1016, 180, 182, 954, 52, + /* 1240 */ 184, 372, 53, 911, 38, 57, 385, 830, 253, 389, + /* 1250 */ 1279, 827, 189, 387, 383, 390, 392, 395, 824, 393, + /* 1260 */ 398, 807, 818, 396, 841, 816, 822, 399, 837, 58, + /* 1270 */ 59, 60, 132, 835, 765, 743, 129, 821, 415, 764, + /* 1280 */ 763, 405, 840, 762, 761, 760, 759, 820, 758, 757, + /* 1290 */ 819, 776, 755, 754, 753, 752, 751, 750, 749, 748, + /* 1300 */ 1100, 436, 437, 1088, 1087, 438, 440, 441, 1083, 444, + /* 1310 */ 445, 1058, 898, 200, 448, 449, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 220, 185, 237, 238, 216, 216, 225, 219, 228, 229, - /* 10 */ 222, 222, 12, 13, 14, 15, 16, 179, 185, 185, - /* 20 */ 1, 2, 206, 190, 190, 12, 13, 14, 15, 16, - /* 30 */ 197, 197, 185, 252, 178, 184, 180, 199, 185, 206, - /* 40 */ 206, 225, 179, 190, 206, 194, 265, 47, 0, 208, - /* 50 */ 269, 235, 201, 206, 216, 4, 215, 216, 220, 206, - /* 60 */ 47, 245, 246, 247, 198, 249, 0, 187, 252, 69, - /* 70 */ 232, 233, 234, 235, 236, 209, 196, 77, 240, 241, - /* 80 */ 242, 265, 235, 220, 204, 269, 188, 189, 69, 251, - /* 90 */ 77, 244, 245, 246, 247, 185, 249, 49, 50, 51, + /* 0 */ 224, 220, 182, 204, 223, 256, 190, 226, 232, 233, + /* 10 */ 203, 182, 12, 13, 14, 15, 16, 210, 269, 181, + /* 20 */ 188, 183, 273, 203, 208, 12, 13, 14, 15, 16, + /* 30 */ 210, 20, 203, 12, 13, 14, 15, 16, 207, 210, + /* 40 */ 220, 204, 210, 20, 224, 238, 22, 47, 0, 220, + /* 50 */ 14, 15, 16, 224, 203, 224, 236, 237, 238, 239, + /* 60 */ 47, 210, 38, 232, 233, 236, 237, 238, 239, 240, + /* 70 */ 70, 239, 20, 244, 245, 246, 241, 242, 78, 0, + /* 80 */ 248, 249, 250, 251, 203, 253, 69, 258, 268, 238, + /* 90 */ 209, 78, 69, 264, 265, 214, 79, 49, 50, 51, /* 100 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - /* 110 */ 62, 63, 64, 65, 66, 49, 116, 51, 199, 191, - /* 120 */ 54, 211, 20, 57, 20, 59, 207, 199, 62, 116, - /* 130 */ 12, 13, 14, 15, 16, 207, 20, 0, 138, 139, - /* 140 */ 140, 141, 142, 143, 144, 145, 146, 147, 14, 15, - /* 150 */ 16, 138, 139, 140, 141, 142, 143, 144, 145, 146, - /* 160 */ 147, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 170 */ 92, 93, 179, 95, 96, 97, 98, 99, 100, 203, - /* 180 */ 12, 13, 185, 46, 68, 12, 13, 14, 20, 46, - /* 190 */ 22, 203, 199, 20, 179, 22, 220, 21, 125, 206, - /* 200 */ 127, 199, 151, 206, 228, 229, 38, 205, 220, 216, - /* 210 */ 34, 38, 210, 220, 199, 47, 228, 229, 225, 185, - /* 220 */ 47, 206, 191, 150, 190, 232, 233, 234, 235, 236, - /* 230 */ 199, 216, 235, 240, 241, 220, 68, 63, 207, 0, - /* 240 */ 206, 68, 245, 246, 247, 252, 249, 232, 233, 234, - /* 250 */ 235, 236, 150, 199, 22, 240, 241, 242, 265, 205, - /* 260 */ 92, 43, 269, 20, 210, 92, 150, 182, 183, 254, - /* 270 */ 38, 185, 104, 199, 199, 260, 261, 104, 12, 13, - /* 280 */ 206, 206, 108, 109, 35, 46, 20, 179, 22, 171, - /* 290 */ 172, 120, 148, 149, 126, 184, 128, 129, 130, 126, - /* 300 */ 132, 128, 129, 130, 38, 132, 57, 199, 234, 234, - /* 310 */ 61, 225, 201, 47, 206, 20, 252, 22, 150, 179, - /* 320 */ 71, 199, 73, 74, 216, 76, 155, 156, 220, 265, - /* 330 */ 179, 82, 210, 269, 68, 40, 150, 20, 252, 199, - /* 340 */ 232, 233, 234, 235, 236, 46, 206, 185, 240, 241, - /* 350 */ 242, 265, 190, 12, 13, 269, 216, 185, 92, 20, - /* 360 */ 220, 20, 190, 22, 79, 122, 179, 149, 206, 261, - /* 370 */ 104, 220, 232, 233, 234, 235, 236, 199, 206, 38, - /* 380 */ 240, 241, 242, 205, 179, 68, 199, 192, 210, 20, - /* 390 */ 195, 251, 126, 206, 128, 129, 130, 185, 132, 72, - /* 400 */ 191, 179, 75, 216, 12, 13, 14, 220, 199, 68, - /* 410 */ 185, 4, 20, 81, 22, 190, 207, 187, 206, 232, - /* 420 */ 233, 234, 235, 236, 179, 220, 19, 240, 241, 242, - /* 430 */ 38, 206, 116, 92, 204, 14, 12, 13, 251, 81, - /* 440 */ 33, 20, 220, 36, 20, 104, 22, 235, 41, 179, - /* 450 */ 230, 44, 179, 179, 138, 199, 20, 245, 246, 247, - /* 460 */ 68, 249, 38, 147, 20, 220, 210, 126, 248, 128, - /* 470 */ 129, 130, 199, 132, 67, 12, 13, 70, 128, 206, - /* 480 */ 0, 230, 185, 20, 92, 22, 179, 190, 206, 216, - /* 490 */ 220, 150, 68, 220, 220, 213, 104, 176, 225, 248, - /* 500 */ 3, 38, 170, 206, 179, 232, 233, 234, 235, 159, - /* 510 */ 160, 161, 162, 163, 230, 57, 92, 179, 126, 61, - /* 520 */ 128, 129, 130, 179, 132, 252, 168, 220, 104, 20, - /* 530 */ 179, 68, 248, 1, 2, 20, 27, 57, 265, 30, - /* 540 */ 82, 61, 269, 179, 72, 220, 225, 75, 39, 200, - /* 550 */ 126, 47, 128, 129, 130, 92, 132, 72, 220, 38, - /* 560 */ 75, 179, 82, 199, 220, 2, 179, 104, 179, 189, - /* 570 */ 206, 220, 200, 252, 179, 12, 13, 14, 15, 16, - /* 580 */ 216, 101, 102, 103, 220, 105, 265, 174, 175, 126, - /* 590 */ 269, 128, 129, 130, 199, 132, 232, 233, 234, 235, - /* 600 */ 236, 206, 220, 72, 240, 241, 75, 220, 200, 220, - /* 610 */ 179, 216, 179, 179, 69, 220, 107, 179, 179, 110, - /* 620 */ 111, 112, 113, 114, 179, 104, 81, 232, 233, 234, - /* 630 */ 235, 236, 128, 199, 69, 240, 241, 122, 199, 49, - /* 640 */ 206, 51, 0, 200, 54, 206, 81, 57, 0, 59, - /* 650 */ 216, 220, 62, 220, 220, 216, 179, 0, 220, 220, - /* 660 */ 0, 38, 179, 166, 22, 220, 232, 233, 234, 235, - /* 670 */ 22, 232, 233, 234, 235, 236, 199, 272, 200, 180, - /* 680 */ 241, 21, 69, 206, 24, 25, 26, 27, 28, 29, - /* 690 */ 30, 31, 32, 216, 81, 263, 179, 220, 0, 22, - /* 700 */ 223, 179, 209, 220, 270, 271, 257, 69, 182, 232, - /* 710 */ 233, 234, 235, 68, 57, 38, 199, 231, 61, 81, - /* 720 */ 22, 199, 69, 206, 69, 80, 250, 104, 206, 199, - /* 730 */ 266, 124, 69, 216, 81, 69, 81, 220, 216, 82, - /* 740 */ 223, 69, 220, 179, 81, 253, 226, 81, 20, 232, - /* 750 */ 233, 234, 235, 81, 232, 233, 234, 235, 101, 102, - /* 760 */ 103, 185, 105, 199, 115, 2, 214, 116, 212, 92, - /* 770 */ 206, 69, 212, 179, 185, 12, 13, 14, 15, 16, - /* 780 */ 216, 104, 69, 81, 220, 20, 264, 187, 12, 13, - /* 790 */ 14, 15, 16, 199, 81, 179, 232, 233, 234, 235, - /* 800 */ 206, 224, 206, 126, 69, 128, 129, 69, 20, 69, - /* 810 */ 216, 69, 69, 187, 220, 199, 81, 223, 217, 81, - /* 820 */ 19, 81, 206, 81, 81, 185, 232, 233, 234, 235, - /* 830 */ 187, 187, 216, 20, 33, 271, 220, 36, 199, 223, - /* 840 */ 181, 224, 181, 42, 217, 44, 68, 185, 232, 233, - /* 850 */ 234, 235, 0, 199, 21, 199, 78, 24, 25, 26, - /* 860 */ 27, 28, 29, 30, 31, 32, 199, 199, 67, 199, - /* 870 */ 179, 70, 199, 199, 199, 199, 24, 25, 26, 27, - /* 880 */ 28, 29, 30, 31, 32, 199, 206, 184, 184, 131, - /* 890 */ 199, 133, 134, 135, 136, 137, 20, 206, 262, 158, - /* 900 */ 18, 179, 101, 157, 221, 23, 129, 216, 220, 231, - /* 910 */ 221, 220, 262, 220, 220, 165, 258, 35, 164, 118, - /* 920 */ 153, 199, 121, 232, 233, 234, 235, 45, 206, 149, - /* 930 */ 259, 179, 12, 13, 14, 15, 16, 256, 216, 152, - /* 940 */ 255, 20, 220, 206, 230, 115, 173, 68, 243, 167, - /* 950 */ 169, 199, 273, 179, 232, 233, 234, 235, 206, 239, - /* 960 */ 268, 119, 267, 206, 195, 221, 221, 220, 216, 220, - /* 970 */ 217, 220, 220, 199, 218, 179, 184, 184, 206, 68, - /* 980 */ 206, 202, 185, 184, 232, 233, 234, 235, 106, 69, - /* 990 */ 216, 181, 186, 227, 220, 199, 193, 179, 193, 177, - /* 1000 */ 0, 104, 206, 126, 0, 123, 232, 233, 234, 235, - /* 1010 */ 80, 0, 216, 0, 115, 0, 220, 199, 0, 179, - /* 1020 */ 0, 0, 0, 0, 206, 22, 0, 0, 232, 233, - /* 1030 */ 234, 235, 150, 0, 216, 0, 0, 0, 220, 199, - /* 1040 */ 0, 179, 43, 0, 48, 0, 206, 0, 38, 43, - /* 1050 */ 232, 233, 234, 235, 0, 36, 216, 0, 0, 0, - /* 1060 */ 220, 199, 77, 179, 75, 0, 38, 38, 206, 38, - /* 1070 */ 22, 0, 232, 233, 234, 235, 38, 38, 216, 38, - /* 1080 */ 38, 0, 220, 199, 38, 22, 22, 179, 39, 0, - /* 1090 */ 206, 22, 0, 38, 232, 233, 234, 235, 22, 0, - /* 1100 */ 216, 22, 20, 0, 220, 0, 122, 199, 117, 43, - /* 1110 */ 154, 179, 0, 81, 206, 81, 232, 233, 234, 235, - /* 1120 */ 12, 13, 69, 154, 216, 81, 148, 154, 220, 68, - /* 1130 */ 22, 199, 81, 179, 4, 38, 69, 69, 206, 69, - /* 1140 */ 232, 233, 234, 235, 69, 68, 38, 38, 216, 38, - /* 1150 */ 2, 68, 220, 199, 68, 179, 68, 38, 80, 69, - /* 1160 */ 206, 81, 38, 69, 232, 233, 234, 235, 81, 38, - /* 1170 */ 216, 80, 68, 80, 220, 199, 81, 179, 128, 69, - /* 1180 */ 80, 68, 206, 69, 69, 68, 232, 233, 234, 235, - /* 1190 */ 68, 68, 216, 120, 0, 43, 220, 199, 78, 22, - /* 1200 */ 92, 117, 68, 68, 206, 80, 80, 79, 232, 233, - /* 1210 */ 234, 235, 104, 69, 216, 68, 33, 38, 220, 36, - /* 1220 */ 38, 94, 69, 38, 68, 42, 69, 44, 38, 68, - /* 1230 */ 232, 233, 234, 235, 126, 69, 128, 129, 38, 68, - /* 1240 */ 38, 69, 68, 94, 94, 94, 22, 82, 68, 38, - /* 1250 */ 67, 38, 68, 70, 68, 38, 22, 48, 104, 47, - /* 1260 */ 22, 38, 22, 38, 38, 38, 38, 38, 38, 38, - /* 1270 */ 38, 38, 0, 38, 38, 38, 0, 38, 0, 38, - /* 1280 */ 38, 38, 36, 38, 37, 0, 22, 43, 21, 274, - /* 1290 */ 22, 22, 21, 20, 274, 274, 274, 274, 274, 274, - /* 1300 */ 117, 274, 274, 274, 121, 274, 274, 274, 274, 274, - /* 1310 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1320 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1330 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1340 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1350 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1360 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1370 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1380 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1390 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1400 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1410 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1420 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1430 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1440 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1450 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - /* 1460 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 110 */ 62, 63, 64, 65, 66, 21, 116, 190, 24, 25, + /* 120 */ 26, 27, 28, 29, 30, 31, 32, 200, 49, 116, + /* 130 */ 51, 188, 20, 54, 22, 208, 57, 194, 59, 60, + /* 140 */ 188, 62, 142, 143, 144, 145, 146, 147, 148, 149, + /* 150 */ 150, 151, 40, 210, 182, 142, 143, 144, 145, 146, + /* 160 */ 147, 148, 149, 150, 151, 182, 20, 215, 179, 12, + /* 170 */ 13, 14, 15, 16, 122, 83, 84, 85, 86, 87, + /* 180 */ 88, 89, 90, 91, 92, 93, 203, 95, 96, 97, + /* 190 */ 98, 99, 100, 210, 202, 0, 224, 20, 12, 13, + /* 200 */ 129, 182, 131, 220, 188, 213, 20, 224, 22, 182, + /* 210 */ 194, 135, 229, 137, 138, 139, 140, 141, 229, 236, + /* 220 */ 237, 238, 239, 240, 38, 154, 210, 244, 245, 191, + /* 230 */ 203, 193, 195, 47, 12, 13, 14, 210, 20, 256, + /* 240 */ 203, 46, 20, 224, 22, 256, 69, 220, 211, 12, + /* 250 */ 13, 224, 269, 203, 132, 69, 273, 20, 269, 22, + /* 260 */ 38, 211, 273, 236, 237, 238, 239, 240, 203, 47, + /* 270 */ 203, 244, 245, 246, 209, 38, 209, 234, 92, 214, + /* 280 */ 123, 214, 207, 188, 47, 163, 164, 165, 166, 167, + /* 290 */ 104, 69, 265, 182, 20, 252, 4, 152, 153, 224, + /* 300 */ 154, 27, 212, 229, 30, 210, 69, 232, 233, 219, + /* 310 */ 220, 19, 43, 39, 92, 188, 130, 188, 132, 133, + /* 320 */ 134, 194, 136, 194, 229, 33, 104, 116, 36, 92, + /* 330 */ 256, 154, 175, 41, 239, 224, 44, 210, 182, 210, + /* 340 */ 154, 104, 46, 269, 249, 250, 251, 273, 253, 195, + /* 350 */ 20, 256, 130, 142, 132, 133, 134, 203, 136, 203, + /* 360 */ 68, 182, 151, 71, 269, 211, 210, 130, 273, 132, + /* 370 */ 133, 134, 188, 136, 20, 195, 220, 1, 2, 187, + /* 380 */ 224, 107, 203, 203, 110, 111, 112, 113, 114, 210, + /* 390 */ 198, 211, 236, 237, 238, 239, 240, 205, 188, 220, + /* 400 */ 244, 245, 246, 224, 194, 182, 57, 67, 188, 182, + /* 410 */ 61, 255, 0, 229, 194, 236, 237, 238, 239, 240, + /* 420 */ 210, 201, 153, 244, 245, 246, 203, 234, 12, 13, + /* 430 */ 210, 82, 120, 210, 255, 220, 20, 182, 22, 154, + /* 440 */ 256, 226, 182, 220, 188, 252, 70, 224, 182, 182, + /* 450 */ 194, 224, 122, 269, 38, 182, 63, 273, 46, 236, + /* 460 */ 237, 238, 239, 240, 188, 182, 210, 244, 245, 246, + /* 470 */ 203, 159, 160, 12, 13, 14, 188, 210, 255, 224, + /* 480 */ 3, 20, 194, 22, 224, 69, 210, 220, 210, 201, + /* 490 */ 224, 224, 185, 186, 188, 217, 229, 224, 210, 38, + /* 500 */ 194, 108, 109, 236, 237, 238, 239, 224, 92, 12, + /* 510 */ 13, 4, 172, 182, 182, 239, 210, 20, 182, 22, + /* 520 */ 104, 182, 188, 256, 234, 249, 250, 251, 46, 253, + /* 530 */ 69, 20, 182, 12, 13, 38, 269, 182, 182, 187, + /* 540 */ 273, 20, 252, 22, 210, 188, 130, 203, 132, 133, + /* 550 */ 134, 194, 136, 92, 182, 224, 224, 205, 214, 38, + /* 560 */ 224, 182, 182, 224, 182, 104, 69, 210, 20, 196, + /* 570 */ 154, 18, 199, 239, 224, 203, 23, 182, 73, 224, + /* 580 */ 224, 76, 210, 249, 250, 251, 182, 253, 35, 92, + /* 590 */ 69, 130, 220, 132, 133, 134, 224, 136, 45, 14, + /* 600 */ 0, 104, 80, 224, 224, 20, 224, 203, 236, 237, + /* 610 */ 238, 239, 240, 92, 210, 73, 244, 245, 76, 224, + /* 620 */ 73, 203, 22, 76, 220, 104, 67, 130, 224, 132, + /* 630 */ 133, 134, 214, 136, 0, 73, 204, 182, 76, 0, + /* 640 */ 236, 237, 238, 239, 240, 182, 204, 170, 244, 245, + /* 650 */ 21, 130, 47, 132, 133, 134, 22, 136, 203, 106, + /* 660 */ 204, 22, 155, 34, 67, 210, 203, 70, 22, 67, + /* 670 */ 38, 67, 70, 210, 70, 220, 123, 124, 125, 224, + /* 680 */ 127, 1, 2, 220, 38, 177, 178, 224, 0, 38, + /* 690 */ 276, 236, 237, 238, 239, 67, 183, 193, 70, 236, + /* 700 */ 237, 238, 239, 240, 267, 213, 182, 154, 245, 21, + /* 710 */ 261, 2, 24, 25, 26, 27, 28, 29, 30, 31, + /* 720 */ 32, 12, 13, 14, 15, 16, 182, 203, 185, 274, + /* 730 */ 275, 182, 67, 174, 210, 70, 104, 132, 92, 12, + /* 740 */ 13, 14, 15, 16, 220, 69, 67, 203, 224, 70, + /* 750 */ 104, 227, 203, 67, 210, 104, 70, 81, 235, 210, + /* 760 */ 236, 237, 238, 239, 220, 12, 13, 67, 224, 220, + /* 770 */ 70, 227, 182, 224, 254, 22, 130, 182, 132, 133, + /* 780 */ 236, 237, 238, 239, 203, 236, 237, 238, 239, 67, + /* 790 */ 257, 38, 70, 203, 128, 270, 230, 70, 203, 67, + /* 800 */ 210, 67, 70, 67, 70, 210, 70, 20, 188, 67, + /* 810 */ 220, 0, 70, 67, 224, 220, 70, 227, 67, 224, + /* 820 */ 115, 70, 227, 116, 275, 218, 236, 237, 238, 239, + /* 830 */ 216, 236, 237, 238, 239, 24, 25, 26, 27, 28, + /* 840 */ 29, 30, 31, 32, 19, 92, 216, 67, 188, 182, + /* 850 */ 70, 20, 2, 228, 190, 210, 20, 104, 33, 221, + /* 860 */ 182, 36, 12, 13, 14, 15, 16, 42, 20, 44, + /* 870 */ 203, 190, 190, 188, 190, 184, 203, 210, 203, 38, + /* 880 */ 203, 203, 192, 130, 228, 132, 133, 220, 210, 188, + /* 890 */ 203, 224, 203, 68, 192, 203, 71, 182, 220, 203, + /* 900 */ 203, 203, 224, 236, 237, 238, 239, 203, 184, 203, + /* 910 */ 187, 20, 187, 210, 236, 237, 238, 239, 203, 35, + /* 920 */ 221, 162, 161, 266, 133, 210, 101, 182, 235, 266, + /* 930 */ 262, 169, 263, 225, 224, 220, 225, 224, 224, 224, + /* 940 */ 168, 57, 157, 118, 20, 61, 121, 182, 203, 156, + /* 950 */ 153, 236, 237, 238, 239, 210, 72, 210, 74, 75, + /* 960 */ 234, 77, 0, 247, 115, 220, 82, 173, 203, 224, + /* 970 */ 182, 176, 260, 171, 69, 210, 259, 225, 243, 224, + /* 980 */ 224, 236, 237, 238, 239, 220, 119, 210, 225, 224, + /* 990 */ 271, 203, 272, 224, 182, 277, 222, 221, 210, 199, + /* 1000 */ 182, 236, 237, 238, 239, 69, 187, 187, 220, 210, + /* 1010 */ 206, 188, 224, 192, 192, 203, 187, 184, 180, 57, + /* 1020 */ 231, 203, 210, 61, 236, 237, 238, 239, 210, 197, + /* 1030 */ 0, 197, 220, 189, 104, 0, 224, 0, 220, 130, + /* 1040 */ 50, 182, 224, 126, 82, 0, 0, 81, 236, 237, + /* 1050 */ 238, 239, 182, 0, 236, 237, 238, 239, 0, 0, + /* 1060 */ 115, 0, 203, 101, 102, 103, 0, 105, 0, 210, + /* 1070 */ 0, 0, 0, 203, 22, 0, 0, 0, 0, 220, + /* 1080 */ 210, 0, 0, 224, 0, 43, 0, 48, 0, 182, + /* 1090 */ 220, 0, 38, 36, 224, 236, 237, 238, 239, 43, + /* 1100 */ 182, 0, 0, 0, 0, 78, 236, 237, 238, 239, + /* 1110 */ 203, 38, 76, 0, 67, 57, 22, 210, 38, 61, + /* 1120 */ 0, 203, 22, 38, 0, 38, 0, 220, 210, 22, + /* 1130 */ 182, 224, 39, 38, 38, 38, 22, 38, 220, 0, + /* 1140 */ 82, 22, 224, 236, 237, 238, 239, 0, 20, 22, + /* 1150 */ 0, 203, 182, 0, 236, 237, 238, 239, 210, 101, + /* 1160 */ 102, 103, 122, 105, 0, 43, 117, 69, 220, 158, + /* 1170 */ 81, 158, 224, 203, 69, 67, 67, 67, 152, 158, + /* 1180 */ 210, 70, 70, 67, 236, 237, 238, 239, 33, 4, + /* 1190 */ 220, 36, 69, 2, 224, 70, 81, 42, 69, 44, + /* 1200 */ 70, 69, 67, 70, 70, 67, 236, 237, 238, 239, + /* 1210 */ 70, 49, 81, 51, 38, 67, 54, 38, 38, 57, + /* 1220 */ 38, 59, 60, 68, 62, 38, 71, 38, 70, 69, + /* 1230 */ 81, 70, 69, 0, 117, 70, 69, 69, 132, 69, + /* 1240 */ 43, 120, 69, 22, 69, 79, 38, 70, 38, 38, + /* 1250 */ 81, 70, 81, 69, 80, 69, 38, 38, 70, 69, + /* 1260 */ 38, 22, 70, 69, 38, 70, 94, 69, 38, 69, + /* 1270 */ 69, 69, 117, 22, 22, 48, 121, 94, 47, 38, + /* 1280 */ 38, 82, 104, 38, 38, 38, 38, 94, 38, 22, + /* 1290 */ 94, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 1300 */ 0, 38, 36, 0, 0, 43, 38, 37, 0, 22, + /* 1310 */ 21, 278, 22, 22, 21, 20, 278, 278, 278, 278, + /* 1320 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1330 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1340 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1350 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1360 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1370 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1380 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1390 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1400 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1410 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1420 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1430 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1440 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1450 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1460 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1470 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1480 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 1490 */ 278, 278, 278, 278, 278, }; -#define YY_SHIFT_COUNT (437) +#define YY_SHIFT_COUNT (450) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1285) +#define YY_SHIFT_MAX (1308) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 882, 168, 173, 266, 266, 266, 266, 341, 266, 266, - /* 10 */ 424, 463, 116, 392, 424, 424, 424, 424, 424, 424, - /* 20 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424, - /* 30 */ 424, 424, 424, 317, 317, 317, 102, 1108, 1108, 73, - /* 40 */ 104, 104, 1108, 104, 104, 143, 339, 369, 369, 186, - /* 50 */ 436, 339, 104, 104, 339, 104, 339, 436, 339, 339, - /* 60 */ 104, 299, 0, 13, 13, 509, 833, 249, 677, 677, - /* 70 */ 677, 677, 677, 677, 677, 677, 677, 677, 677, 677, - /* 80 */ 677, 677, 677, 677, 677, 677, 677, 677, 590, 295, - /* 90 */ 137, 243, 243, 243, 239, 444, 436, 339, 339, 339, - /* 100 */ 285, 78, 78, 78, 78, 78, 660, 66, 118, 350, - /* 110 */ 458, 171, 232, 515, 144, 218, 144, 421, 497, 51, - /* 120 */ 607, 728, 649, 651, 651, 728, 765, 143, 444, 788, - /* 130 */ 143, 143, 728, 143, 813, 339, 339, 339, 339, 339, - /* 140 */ 339, 339, 339, 339, 339, 339, 728, 813, 765, 299, - /* 150 */ 444, 788, 299, 876, 741, 746, 777, 741, 746, 777, - /* 160 */ 777, 750, 754, 767, 787, 780, 444, 921, 830, 773, - /* 170 */ 781, 782, 879, 339, 746, 777, 777, 746, 777, 842, - /* 180 */ 444, 788, 299, 285, 299, 444, 911, 728, 299, 813, - /* 190 */ 1305, 1305, 1305, 1305, 1305, 48, 852, 801, 1183, 407, - /* 200 */ 480, 657, 563, 763, 758, 920, 776, 776, 776, 776, - /* 210 */ 776, 776, 776, 174, 19, 316, 134, 134, 134, 134, - /* 220 */ 327, 472, 485, 531, 642, 648, 698, 176, 545, 565, - /* 230 */ 613, 532, 413, 358, 332, 638, 504, 653, 645, 655, - /* 240 */ 663, 666, 672, 702, 521, 623, 713, 735, 738, 740, - /* 250 */ 742, 743, 778, 1000, 897, 877, 1004, 930, 1011, 1013, - /* 260 */ 899, 1015, 1018, 1020, 1021, 1022, 1023, 1003, 1026, 1027, - /* 270 */ 1033, 1035, 1036, 1037, 1040, 999, 1043, 996, 1045, 1047, - /* 280 */ 1010, 1019, 1006, 1054, 1057, 1058, 1059, 985, 989, 1028, - /* 290 */ 1029, 1048, 1065, 1031, 1038, 1039, 1041, 1042, 1046, 1071, - /* 300 */ 1063, 1081, 1064, 1049, 1089, 1069, 1055, 1092, 1076, 1099, - /* 310 */ 1079, 1082, 1103, 1105, 984, 1112, 1061, 1066, 991, 1032, - /* 320 */ 1034, 956, 1053, 1044, 1067, 1077, 1083, 1068, 1086, 1070, - /* 330 */ 1051, 1078, 1088, 1080, 969, 1075, 1090, 1091, 978, 1087, - /* 340 */ 1093, 1094, 1095, 973, 1130, 1097, 1109, 1111, 1119, 1124, - /* 350 */ 1131, 1148, 1050, 1100, 1110, 1104, 1113, 1114, 1115, 1117, - /* 360 */ 1122, 1073, 1123, 1194, 1152, 1084, 1134, 1120, 1125, 1126, - /* 370 */ 1177, 1135, 1128, 1144, 1179, 1182, 1147, 1153, 1185, 1156, - /* 380 */ 1157, 1190, 1161, 1166, 1200, 1171, 1172, 1202, 1174, 1127, - /* 390 */ 1149, 1150, 1151, 1224, 1165, 1180, 1211, 1154, 1184, 1186, - /* 400 */ 1213, 1217, 1234, 1209, 1212, 1238, 1223, 1225, 1226, 1227, - /* 410 */ 1228, 1229, 1230, 1240, 1231, 1232, 1233, 1235, 1236, 1237, - /* 420 */ 1239, 1241, 1242, 1272, 1243, 1246, 1244, 1276, 1245, 1247, - /* 430 */ 1278, 1285, 1264, 1267, 1268, 1269, 1271, 1273, + /* 0 */ 553, 186, 222, 237, 237, 237, 237, 416, 237, 237, + /* 10 */ 497, 521, 177, 461, 497, 497, 497, 497, 497, 497, + /* 20 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, + /* 30 */ 497, 497, 497, 23, 23, 23, 146, 753, 753, 71, + /* 40 */ 11, 11, 753, 11, 11, 11, 11, 296, 218, 354, + /* 50 */ 354, 285, 511, 218, 11, 11, 218, 11, 218, 511, + /* 60 */ 218, 218, 11, 482, 0, 13, 13, 274, 94, 884, + /* 70 */ 646, 1162, 646, 646, 646, 646, 646, 646, 646, 646, + /* 80 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 90 */ 646, 112, 195, 52, 52, 52, 412, 548, 511, 218, + /* 100 */ 218, 218, 522, 92, 92, 92, 92, 92, 688, 79, + /* 110 */ 157, 122, 349, 312, 24, 330, 145, 269, 145, 585, + /* 120 */ 477, 507, 666, 787, 705, 707, 707, 787, 831, 296, + /* 130 */ 548, 836, 296, 296, 787, 296, 848, 218, 218, 218, + /* 140 */ 218, 218, 218, 218, 218, 218, 218, 218, 841, 841, + /* 150 */ 787, 848, 831, 482, 548, 836, 482, 891, 759, 761, + /* 160 */ 791, 759, 761, 791, 791, 762, 772, 785, 793, 797, + /* 170 */ 548, 924, 849, 795, 794, 802, 905, 218, 761, 791, + /* 180 */ 791, 761, 791, 867, 548, 836, 482, 522, 482, 548, + /* 190 */ 936, 841, 841, 787, 482, 848, 1316, 1316, 1316, 1316, + /* 200 */ 1316, 48, 811, 825, 1155, 292, 962, 1058, 709, 850, + /* 210 */ 76, 727, 21, 21, 21, 21, 21, 21, 21, 393, + /* 220 */ 376, 211, 36, 36, 36, 36, 505, 542, 547, 562, + /* 230 */ 600, 634, 639, 629, 597, 602, 604, 680, 508, 340, + /* 240 */ 559, 628, 605, 665, 676, 679, 686, 700, 722, 732, + /* 250 */ 632, 651, 734, 736, 742, 746, 751, 780, 17, 1030, + /* 260 */ 930, 909, 1035, 1037, 990, 917, 1045, 1046, 966, 1053, + /* 270 */ 1059, 945, 1061, 1066, 1068, 1070, 1071, 1072, 1052, 1075, + /* 280 */ 1076, 1077, 1078, 1081, 1082, 1084, 1042, 1086, 1039, 1088, + /* 290 */ 1091, 1054, 1057, 1056, 1101, 1102, 1103, 1104, 1027, 1036, + /* 300 */ 1073, 1047, 1094, 1113, 1080, 1085, 1087, 1095, 1047, 1096, + /* 310 */ 1097, 1120, 1100, 1124, 1107, 1093, 1126, 1114, 1099, 1139, + /* 320 */ 1119, 1147, 1127, 1128, 1150, 1153, 1040, 1164, 1098, 1122, + /* 330 */ 1049, 1108, 1109, 1011, 1111, 1110, 1112, 1105, 1123, 1125, + /* 340 */ 1129, 1130, 1116, 1089, 1132, 1135, 1013, 1133, 1134, 1115, + /* 350 */ 1026, 1138, 1131, 1140, 1148, 1021, 1185, 1176, 1179, 1180, + /* 360 */ 1182, 1187, 1189, 1191, 1106, 1149, 1158, 1160, 1163, 1161, + /* 370 */ 1165, 1167, 1168, 1121, 1170, 1233, 1197, 1117, 1173, 1166, + /* 380 */ 1169, 1171, 1221, 1175, 1174, 1177, 1208, 1210, 1184, 1181, + /* 390 */ 1211, 1186, 1188, 1218, 1190, 1192, 1219, 1194, 1195, 1222, + /* 400 */ 1198, 1172, 1183, 1193, 1196, 1239, 1199, 1200, 1226, 1178, + /* 410 */ 1201, 1202, 1230, 1047, 1251, 1227, 1231, 1252, 1241, 1242, + /* 420 */ 1245, 1246, 1247, 1248, 1250, 1267, 1253, 1047, 1254, 1255, + /* 430 */ 1256, 1257, 1258, 1259, 1260, 1261, 1300, 1263, 1266, 1262, + /* 440 */ 1303, 1268, 1270, 1304, 1308, 1287, 1289, 1290, 1291, 1293, + /* 450 */ 1295, }; -#define YY_REDUCE_COUNT (194) -#define YY_REDUCE_MIN (-235) -#define YY_REDUCE_MAX (998) +#define YY_REDUCE_COUNT (200) +#define YY_REDUCE_MIN (-251) +#define YY_REDUCE_MAX (970) static const short yy_reduce_ofst[] = { - /* 0 */ 321, -7, 15, 108, -162, 140, 187, 273, 364, 395, - /* 10 */ 434, 439, -184, 477, 517, 522, 564, 594, 616, 691, - /* 20 */ 722, 752, 774, 796, 818, 840, 862, 884, 908, 932, - /* 30 */ 954, 976, 998, -153, -3, 212, 86, -24, -12, -219, - /* 40 */ -167, -166, -220, -147, 34, -120, 2, 74, 75, 64, - /* 50 */ -212, -72, 162, 172, 54, 225, 31, -159, 178, 209, - /* 60 */ 297, -149, -235, -235, -235, -90, -144, -134, -137, 151, - /* 70 */ 205, 222, 245, 270, 274, 307, 325, 338, 344, 351, - /* 80 */ 382, 387, 389, 431, 433, 438, 445, 483, -102, 85, - /* 90 */ 230, 220, 251, 284, 111, 282, -211, -81, 122, 256, - /* 100 */ 195, 349, 372, 408, 443, 478, 499, 380, 405, 432, - /* 110 */ 493, 449, 526, 486, 476, 476, 476, 530, 464, 492, - /* 120 */ 520, 576, 552, 556, 560, 589, 577, 600, 596, 601, - /* 130 */ 626, 643, 640, 644, 659, 639, 654, 656, 667, 668, - /* 140 */ 670, 673, 674, 675, 676, 686, 662, 661, 617, 703, - /* 150 */ 680, 627, 704, 678, 636, 683, 688, 650, 689, 693, - /* 160 */ 694, 671, 658, 681, 685, 476, 737, 714, 705, 679, - /* 170 */ 692, 695, 720, 530, 744, 747, 749, 745, 751, 756, - /* 180 */ 757, 753, 792, 769, 793, 772, 779, 797, 799, 810, - /* 190 */ 766, 803, 805, 806, 822, + /* 0 */ -11, -17, -171, 27, 156, 179, 223, 267, 372, 404, + /* 10 */ 455, 463, 95, 524, 544, -180, 549, 590, 595, 667, + /* 20 */ 678, 715, 745, 765, 788, 812, 818, 859, 870, 907, + /* 30 */ 918, 948, 970, -168, 276, 334, 184, -169, 75, 74, + /* 40 */ 220, 288, -224, -57, 16, 127, 129, -73, -119, -193, + /* 50 */ -149, -251, -219, 37, 210, 256, 65, 306, 154, 90, + /* 60 */ 67, 180, 357, 192, -165, -165, -165, -48, -162, -8, + /* 70 */ -28, 38, 19, 111, 227, 255, 260, 266, 273, 283, + /* 80 */ 331, 332, 336, 339, 350, 355, 356, 379, 380, 382, + /* 90 */ 395, 307, -184, 43, 193, 290, 352, 278, 215, 50, + /* 100 */ 344, 418, 373, -201, -163, 432, 442, 456, 513, 504, + /* 110 */ 414, 437, 492, 449, 543, 523, 520, 520, 520, 581, + /* 120 */ 525, 533, 566, 620, 607, 614, 630, 660, 625, 664, + /* 130 */ 645, 638, 681, 682, 685, 684, 691, 673, 675, 677, + /* 140 */ 687, 689, 692, 696, 697, 698, 704, 706, 690, 702, + /* 150 */ 701, 724, 656, 723, 703, 699, 725, 693, 657, 708, + /* 160 */ 710, 663, 711, 713, 714, 669, 668, 712, 717, 520, + /* 170 */ 747, 726, 716, 718, 720, 719, 735, 581, 752, 755, + /* 180 */ 756, 763, 769, 774, 777, 776, 819, 800, 820, 799, + /* 190 */ 804, 821, 822, 823, 829, 833, 789, 832, 834, 844, + /* 200 */ 838, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 10 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 20 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 30 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 40 */ 1038, 1038, 1038, 1038, 1038, 1091, 1038, 1038, 1038, 1038, - /* 50 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 60 */ 1038, 1089, 1038, 1314, 1038, 1204, 1038, 1038, 1038, 1038, - /* 70 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 80 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 90 */ 1091, 1325, 1325, 1325, 1089, 1038, 1038, 1038, 1038, 1038, - /* 100 */ 1173, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1389, 1038, - /* 110 */ 1126, 1349, 1038, 1341, 1317, 1331, 1318, 1038, 1374, 1334, - /* 120 */ 1227, 1038, 1209, 1206, 1206, 1038, 1038, 1091, 1038, 1038, - /* 130 */ 1091, 1091, 1038, 1091, 1038, 1038, 1038, 1038, 1038, 1038, - /* 140 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1089, - /* 150 */ 1038, 1038, 1089, 1038, 1356, 1354, 1038, 1356, 1354, 1038, - /* 160 */ 1038, 1368, 1364, 1347, 1345, 1331, 1038, 1038, 1038, 1392, - /* 170 */ 1380, 1376, 1038, 1038, 1354, 1038, 1038, 1354, 1038, 1217, - /* 180 */ 1038, 1038, 1089, 1038, 1089, 1038, 1142, 1038, 1089, 1038, - /* 190 */ 1229, 1176, 1176, 1092, 1043, 1038, 1038, 1038, 1038, 1038, - /* 200 */ 1038, 1038, 1038, 1038, 1038, 1038, 1279, 1367, 1366, 1278, - /* 210 */ 1291, 1290, 1289, 1038, 1038, 1038, 1273, 1274, 1272, 1271, - /* 220 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 230 */ 1038, 1315, 1038, 1377, 1381, 1038, 1038, 1038, 1257, 1038, - /* 240 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 250 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 260 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 270 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 280 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 290 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 300 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 310 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1338, - /* 320 */ 1348, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 330 */ 1038, 1257, 1038, 1365, 1038, 1324, 1320, 1038, 1038, 1316, - /* 340 */ 1038, 1038, 1375, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 350 */ 1038, 1310, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 360 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1256, 1038, - /* 370 */ 1038, 1038, 1038, 1038, 1038, 1038, 1170, 1038, 1038, 1038, - /* 380 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1155, - /* 390 */ 1153, 1152, 1151, 1038, 1148, 1038, 1038, 1038, 1038, 1038, - /* 400 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 410 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 420 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, - /* 430 */ 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, + /* 0 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 10 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 20 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 30 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 40 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1109, 1056, 1056, + /* 50 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 60 */ 1056, 1056, 1056, 1107, 1056, 1338, 1056, 1225, 1056, 1056, + /* 70 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 80 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 90 */ 1056, 1056, 1109, 1349, 1349, 1349, 1107, 1056, 1056, 1056, + /* 100 */ 1056, 1056, 1194, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 110 */ 1413, 1056, 1147, 1373, 1056, 1365, 1341, 1355, 1342, 1056, + /* 120 */ 1398, 1358, 1251, 1056, 1230, 1227, 1227, 1056, 1056, 1109, + /* 130 */ 1056, 1056, 1109, 1109, 1056, 1109, 1056, 1056, 1056, 1056, + /* 140 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 150 */ 1056, 1056, 1056, 1107, 1056, 1056, 1107, 1056, 1380, 1378, + /* 160 */ 1056, 1380, 1378, 1056, 1056, 1392, 1388, 1371, 1369, 1355, + /* 170 */ 1056, 1056, 1056, 1416, 1404, 1400, 1056, 1056, 1378, 1056, + /* 180 */ 1056, 1378, 1056, 1238, 1056, 1056, 1107, 1056, 1107, 1056, + /* 190 */ 1163, 1056, 1056, 1056, 1107, 1056, 1253, 1197, 1197, 1110, + /* 200 */ 1061, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 210 */ 1056, 1056, 1303, 1391, 1390, 1302, 1315, 1314, 1313, 1056, + /* 220 */ 1056, 1056, 1297, 1298, 1296, 1295, 1056, 1056, 1056, 1056, + /* 230 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1339, 1056, 1401, + /* 240 */ 1405, 1056, 1056, 1056, 1281, 1056, 1056, 1056, 1056, 1056, + /* 250 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 260 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 270 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 280 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 290 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 300 */ 1056, 1208, 1056, 1056, 1056, 1056, 1056, 1056, 1133, 1056, + /* 310 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 320 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 330 */ 1056, 1362, 1372, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 340 */ 1056, 1056, 1056, 1281, 1056, 1389, 1056, 1348, 1344, 1056, + /* 350 */ 1056, 1340, 1056, 1056, 1399, 1056, 1056, 1056, 1056, 1056, + /* 360 */ 1056, 1056, 1056, 1334, 1056, 1056, 1056, 1056, 1056, 1056, + /* 370 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 380 */ 1280, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1191, 1056, + /* 390 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 400 */ 1056, 1176, 1174, 1173, 1172, 1056, 1169, 1056, 1056, 1056, + /* 410 */ 1056, 1056, 1056, 1199, 1056, 1056, 1056, 1056, 1056, 1056, + /* 420 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1119, 1056, 1056, + /* 430 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 440 */ 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1056, + /* 450 */ 1056, }; /********** End of lemon-generated parsing tables *****************************/ @@ -784,21 +793,21 @@ static const char *const yyTokenName[] = { /* 64 */ "SINGLE_STABLE", /* 65 */ "STREAM_MODE", /* 66 */ "RETENTIONS", - /* 67 */ "TABLE", - /* 68 */ "NK_LP", - /* 69 */ "NK_RP", - /* 70 */ "STABLE", - /* 71 */ "ADD", - /* 72 */ "COLUMN", - /* 73 */ "MODIFY", - /* 74 */ "RENAME", - /* 75 */ "TAG", - /* 76 */ "SET", - /* 77 */ "NK_EQ", - /* 78 */ "USING", - /* 79 */ "TAGS", - /* 80 */ "NK_DOT", - /* 81 */ "NK_COMMA", + /* 67 */ "NK_COMMA", + /* 68 */ "TABLE", + /* 69 */ "NK_LP", + /* 70 */ "NK_RP", + /* 71 */ "STABLE", + /* 72 */ "ADD", + /* 73 */ "COLUMN", + /* 74 */ "MODIFY", + /* 75 */ "RENAME", + /* 76 */ "TAG", + /* 77 */ "SET", + /* 78 */ "NK_EQ", + /* 79 */ "USING", + /* 80 */ "TAGS", + /* 81 */ "NK_DOT", /* 82 */ "COMMENT", /* 83 */ "BOOL", /* 84 */ "TINYINT", @@ -840,157 +849,161 @@ static const char *const yyTokenName[] = { /* 120 */ "INTERVAL", /* 121 */ "TOPIC", /* 122 */ "AS", - /* 123 */ "EXPLAIN", - /* 124 */ "ANALYZE", - /* 125 */ "VERBOSE", - /* 126 */ "NK_BOOL", - /* 127 */ "RATIO", - /* 128 */ "NULL", - /* 129 */ "NK_VARIABLE", - /* 130 */ "NK_UNDERLINE", - /* 131 */ "ROWTS", - /* 132 */ "TBNAME", - /* 133 */ "QSTARTTS", - /* 134 */ "QENDTS", - /* 135 */ "WSTARTTS", - /* 136 */ "WENDTS", - /* 137 */ "WDURATION", - /* 138 */ "BETWEEN", - /* 139 */ "IS", - /* 140 */ "NK_LT", - /* 141 */ "NK_GT", - /* 142 */ "NK_LE", - /* 143 */ "NK_GE", - /* 144 */ "NK_NE", - /* 145 */ "MATCH", - /* 146 */ "NMATCH", - /* 147 */ "IN", - /* 148 */ "JOIN", - /* 149 */ "INNER", - /* 150 */ "SELECT", - /* 151 */ "DISTINCT", - /* 152 */ "WHERE", - /* 153 */ "PARTITION", - /* 154 */ "BY", - /* 155 */ "SESSION", - /* 156 */ "STATE_WINDOW", - /* 157 */ "SLIDING", - /* 158 */ "FILL", - /* 159 */ "VALUE", - /* 160 */ "NONE", - /* 161 */ "PREV", - /* 162 */ "LINEAR", - /* 163 */ "NEXT", - /* 164 */ "GROUP", - /* 165 */ "HAVING", - /* 166 */ "ORDER", - /* 167 */ "SLIMIT", - /* 168 */ "SOFFSET", - /* 169 */ "LIMIT", - /* 170 */ "OFFSET", - /* 171 */ "ASC", - /* 172 */ "DESC", - /* 173 */ "NULLS", - /* 174 */ "FIRST", - /* 175 */ "LAST", - /* 176 */ "cmd", - /* 177 */ "account_options", - /* 178 */ "alter_account_options", - /* 179 */ "literal", - /* 180 */ "alter_account_option", - /* 181 */ "user_name", - /* 182 */ "dnode_endpoint", - /* 183 */ "dnode_host_name", - /* 184 */ "not_exists_opt", - /* 185 */ "db_name", - /* 186 */ "db_options", - /* 187 */ "exists_opt", - /* 188 */ "alter_db_options", - /* 189 */ "alter_db_option", - /* 190 */ "full_table_name", - /* 191 */ "column_def_list", - /* 192 */ "tags_def_opt", - /* 193 */ "table_options", - /* 194 */ "multi_create_clause", - /* 195 */ "tags_def", - /* 196 */ "multi_drop_clause", - /* 197 */ "alter_table_clause", - /* 198 */ "alter_table_options", - /* 199 */ "column_name", - /* 200 */ "type_name", - /* 201 */ "create_subtable_clause", - /* 202 */ "specific_tags_opt", - /* 203 */ "literal_list", - /* 204 */ "drop_table_clause", - /* 205 */ "col_name_list", - /* 206 */ "table_name", - /* 207 */ "column_def", - /* 208 */ "func_name_list", - /* 209 */ "alter_table_option", - /* 210 */ "col_name", - /* 211 */ "db_name_cond_opt", - /* 212 */ "like_pattern_opt", - /* 213 */ "table_name_cond", - /* 214 */ "from_db_opt", - /* 215 */ "func_name", - /* 216 */ "function_name", - /* 217 */ "index_name", - /* 218 */ "index_options", - /* 219 */ "func_list", - /* 220 */ "duration_literal", - /* 221 */ "sliding_opt", - /* 222 */ "func", - /* 223 */ "expression_list", - /* 224 */ "topic_name", - /* 225 */ "query_expression", - /* 226 */ "analyze_opt", - /* 227 */ "explain_options", - /* 228 */ "signed", - /* 229 */ "signed_literal", - /* 230 */ "table_alias", - /* 231 */ "column_alias", - /* 232 */ "expression", - /* 233 */ "pseudo_column", - /* 234 */ "column_reference", - /* 235 */ "subquery", - /* 236 */ "predicate", - /* 237 */ "compare_op", - /* 238 */ "in_op", - /* 239 */ "in_predicate_value", - /* 240 */ "boolean_value_expression", - /* 241 */ "boolean_primary", - /* 242 */ "common_expression", - /* 243 */ "from_clause", - /* 244 */ "table_reference_list", - /* 245 */ "table_reference", - /* 246 */ "table_primary", - /* 247 */ "joined_table", - /* 248 */ "alias_opt", - /* 249 */ "parenthesized_joined_table", - /* 250 */ "join_type", - /* 251 */ "search_condition", - /* 252 */ "query_specification", - /* 253 */ "set_quantifier_opt", - /* 254 */ "select_list", - /* 255 */ "where_clause_opt", - /* 256 */ "partition_by_clause_opt", - /* 257 */ "twindow_clause_opt", - /* 258 */ "group_by_clause_opt", - /* 259 */ "having_clause_opt", - /* 260 */ "select_sublist", - /* 261 */ "select_item", - /* 262 */ "fill_opt", - /* 263 */ "fill_mode", - /* 264 */ "group_by_list", - /* 265 */ "query_expression_body", - /* 266 */ "order_by_clause_opt", - /* 267 */ "slimit_clause_opt", - /* 268 */ "limit_clause_opt", - /* 269 */ "query_primary", - /* 270 */ "sort_specification_list", - /* 271 */ "sort_specification", - /* 272 */ "ordering_specification_opt", - /* 273 */ "null_ordering_opt", + /* 123 */ "DESC", + /* 124 */ "DESCRIBE", + /* 125 */ "RESET", + /* 126 */ "QUERY", + /* 127 */ "EXPLAIN", + /* 128 */ "ANALYZE", + /* 129 */ "VERBOSE", + /* 130 */ "NK_BOOL", + /* 131 */ "RATIO", + /* 132 */ "NULL", + /* 133 */ "NK_VARIABLE", + /* 134 */ "NK_UNDERLINE", + /* 135 */ "ROWTS", + /* 136 */ "TBNAME", + /* 137 */ "QSTARTTS", + /* 138 */ "QENDTS", + /* 139 */ "WSTARTTS", + /* 140 */ "WENDTS", + /* 141 */ "WDURATION", + /* 142 */ "BETWEEN", + /* 143 */ "IS", + /* 144 */ "NK_LT", + /* 145 */ "NK_GT", + /* 146 */ "NK_LE", + /* 147 */ "NK_GE", + /* 148 */ "NK_NE", + /* 149 */ "MATCH", + /* 150 */ "NMATCH", + /* 151 */ "IN", + /* 152 */ "JOIN", + /* 153 */ "INNER", + /* 154 */ "SELECT", + /* 155 */ "DISTINCT", + /* 156 */ "WHERE", + /* 157 */ "PARTITION", + /* 158 */ "BY", + /* 159 */ "SESSION", + /* 160 */ "STATE_WINDOW", + /* 161 */ "SLIDING", + /* 162 */ "FILL", + /* 163 */ "VALUE", + /* 164 */ "NONE", + /* 165 */ "PREV", + /* 166 */ "LINEAR", + /* 167 */ "NEXT", + /* 168 */ "GROUP", + /* 169 */ "HAVING", + /* 170 */ "ORDER", + /* 171 */ "SLIMIT", + /* 172 */ "SOFFSET", + /* 173 */ "LIMIT", + /* 174 */ "OFFSET", + /* 175 */ "ASC", + /* 176 */ "NULLS", + /* 177 */ "FIRST", + /* 178 */ "LAST", + /* 179 */ "cmd", + /* 180 */ "account_options", + /* 181 */ "alter_account_options", + /* 182 */ "literal", + /* 183 */ "alter_account_option", + /* 184 */ "user_name", + /* 185 */ "dnode_endpoint", + /* 186 */ "dnode_host_name", + /* 187 */ "not_exists_opt", + /* 188 */ "db_name", + /* 189 */ "db_options", + /* 190 */ "exists_opt", + /* 191 */ "alter_db_options", + /* 192 */ "integer_list", + /* 193 */ "alter_db_option", + /* 194 */ "full_table_name", + /* 195 */ "column_def_list", + /* 196 */ "tags_def_opt", + /* 197 */ "table_options", + /* 198 */ "multi_create_clause", + /* 199 */ "tags_def", + /* 200 */ "multi_drop_clause", + /* 201 */ "alter_table_clause", + /* 202 */ "alter_table_options", + /* 203 */ "column_name", + /* 204 */ "type_name", + /* 205 */ "create_subtable_clause", + /* 206 */ "specific_tags_opt", + /* 207 */ "literal_list", + /* 208 */ "drop_table_clause", + /* 209 */ "col_name_list", + /* 210 */ "table_name", + /* 211 */ "column_def", + /* 212 */ "func_name_list", + /* 213 */ "alter_table_option", + /* 214 */ "col_name", + /* 215 */ "db_name_cond_opt", + /* 216 */ "like_pattern_opt", + /* 217 */ "table_name_cond", + /* 218 */ "from_db_opt", + /* 219 */ "func_name", + /* 220 */ "function_name", + /* 221 */ "index_name", + /* 222 */ "index_options", + /* 223 */ "func_list", + /* 224 */ "duration_literal", + /* 225 */ "sliding_opt", + /* 226 */ "func", + /* 227 */ "expression_list", + /* 228 */ "topic_name", + /* 229 */ "query_expression", + /* 230 */ "analyze_opt", + /* 231 */ "explain_options", + /* 232 */ "signed", + /* 233 */ "signed_literal", + /* 234 */ "table_alias", + /* 235 */ "column_alias", + /* 236 */ "expression", + /* 237 */ "pseudo_column", + /* 238 */ "column_reference", + /* 239 */ "subquery", + /* 240 */ "predicate", + /* 241 */ "compare_op", + /* 242 */ "in_op", + /* 243 */ "in_predicate_value", + /* 244 */ "boolean_value_expression", + /* 245 */ "boolean_primary", + /* 246 */ "common_expression", + /* 247 */ "from_clause", + /* 248 */ "table_reference_list", + /* 249 */ "table_reference", + /* 250 */ "table_primary", + /* 251 */ "joined_table", + /* 252 */ "alias_opt", + /* 253 */ "parenthesized_joined_table", + /* 254 */ "join_type", + /* 255 */ "search_condition", + /* 256 */ "query_specification", + /* 257 */ "set_quantifier_opt", + /* 258 */ "select_list", + /* 259 */ "where_clause_opt", + /* 260 */ "partition_by_clause_opt", + /* 261 */ "twindow_clause_opt", + /* 262 */ "group_by_clause_opt", + /* 263 */ "having_clause_opt", + /* 264 */ "select_sublist", + /* 265 */ "select_item", + /* 266 */ "fill_opt", + /* 267 */ "fill_mode", + /* 268 */ "group_by_list", + /* 269 */ "query_expression_body", + /* 270 */ "order_by_clause_opt", + /* 271 */ "slimit_clause_opt", + /* 272 */ "limit_clause_opt", + /* 273 */ "query_primary", + /* 274 */ "sort_specification_list", + /* 275 */ "sort_specification", + /* 276 */ "ordering_specification_opt", + /* 277 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1058,7 +1071,7 @@ static const char *const yyRuleName[] = { /* 57 */ "db_options ::= db_options FSYNC NK_INTEGER", /* 58 */ "db_options ::= db_options MAXROWS NK_INTEGER", /* 59 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 60 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 60 */ "db_options ::= db_options KEEP integer_list", /* 61 */ "db_options ::= db_options PRECISION NK_STRING", /* 62 */ "db_options ::= db_options QUORUM NK_INTEGER", /* 63 */ "db_options ::= db_options REPLICA NK_INTEGER", @@ -1072,286 +1085,292 @@ static const char *const yyRuleName[] = { /* 71 */ "alter_db_options ::= alter_db_options alter_db_option", /* 72 */ "alter_db_option ::= BLOCKS NK_INTEGER", /* 73 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 74 */ "alter_db_option ::= KEEP NK_INTEGER", + /* 74 */ "alter_db_option ::= KEEP integer_list", /* 75 */ "alter_db_option ::= WAL NK_INTEGER", /* 76 */ "alter_db_option ::= QUORUM NK_INTEGER", /* 77 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 78 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 79 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 80 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 81 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 82 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 83 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 84 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 85 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 86 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 87 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 88 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 89 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 90 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 91 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 92 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 93 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 94 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", - /* 95 */ "multi_create_clause ::= create_subtable_clause", - /* 96 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 97 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 98 */ "multi_drop_clause ::= drop_table_clause", - /* 99 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 100 */ "drop_table_clause ::= exists_opt full_table_name", - /* 101 */ "specific_tags_opt ::=", - /* 102 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 103 */ "full_table_name ::= table_name", - /* 104 */ "full_table_name ::= db_name NK_DOT table_name", - /* 105 */ "column_def_list ::= column_def", - /* 106 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 107 */ "column_def ::= column_name type_name", - /* 108 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 109 */ "type_name ::= BOOL", - /* 110 */ "type_name ::= TINYINT", - /* 111 */ "type_name ::= SMALLINT", - /* 112 */ "type_name ::= INT", - /* 113 */ "type_name ::= INTEGER", - /* 114 */ "type_name ::= BIGINT", - /* 115 */ "type_name ::= FLOAT", - /* 116 */ "type_name ::= DOUBLE", - /* 117 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 118 */ "type_name ::= TIMESTAMP", - /* 119 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 120 */ "type_name ::= TINYINT UNSIGNED", - /* 121 */ "type_name ::= SMALLINT UNSIGNED", - /* 122 */ "type_name ::= INT UNSIGNED", - /* 123 */ "type_name ::= BIGINT UNSIGNED", - /* 124 */ "type_name ::= JSON", - /* 125 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 126 */ "type_name ::= MEDIUMBLOB", - /* 127 */ "type_name ::= BLOB", - /* 128 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 129 */ "type_name ::= DECIMAL", - /* 130 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 131 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 132 */ "tags_def_opt ::=", - /* 133 */ "tags_def_opt ::= tags_def", - /* 134 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 135 */ "table_options ::=", - /* 136 */ "table_options ::= table_options COMMENT NK_STRING", - /* 137 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 138 */ "table_options ::= table_options TTL NK_INTEGER", - /* 139 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 140 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 141 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", - /* 142 */ "table_options ::= table_options DELAY NK_INTEGER", - /* 143 */ "alter_table_options ::= alter_table_option", - /* 144 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 145 */ "alter_table_option ::= COMMENT NK_STRING", - /* 146 */ "alter_table_option ::= KEEP NK_INTEGER", - /* 147 */ "alter_table_option ::= TTL NK_INTEGER", - /* 148 */ "col_name_list ::= col_name", - /* 149 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 150 */ "col_name ::= column_name", - /* 151 */ "cmd ::= SHOW DNODES", - /* 152 */ "cmd ::= SHOW USERS", - /* 153 */ "cmd ::= SHOW DATABASES", - /* 154 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 155 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 156 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 157 */ "cmd ::= SHOW MNODES", - /* 158 */ "cmd ::= SHOW MODULES", - /* 159 */ "cmd ::= SHOW QNODES", - /* 160 */ "cmd ::= SHOW FUNCTIONS", - /* 161 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 162 */ "cmd ::= SHOW STREAMS", - /* 163 */ "db_name_cond_opt ::=", - /* 164 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 165 */ "like_pattern_opt ::=", - /* 166 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 167 */ "table_name_cond ::= table_name", - /* 168 */ "from_db_opt ::=", - /* 169 */ "from_db_opt ::= FROM db_name", - /* 170 */ "func_name_list ::= func_name", - /* 171 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 172 */ "func_name ::= function_name", - /* 173 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 174 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 175 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 176 */ "index_options ::=", - /* 177 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 178 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 179 */ "func_list ::= func", - /* 180 */ "func_list ::= func_list NK_COMMA func", - /* 181 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 182 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 183 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 184 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 185 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 186 */ "analyze_opt ::=", - /* 187 */ "analyze_opt ::= ANALYZE", - /* 188 */ "explain_options ::=", - /* 189 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 190 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 191 */ "cmd ::= query_expression", - /* 192 */ "literal ::= NK_INTEGER", - /* 193 */ "literal ::= NK_FLOAT", - /* 194 */ "literal ::= NK_STRING", - /* 195 */ "literal ::= NK_BOOL", - /* 196 */ "literal ::= TIMESTAMP NK_STRING", - /* 197 */ "literal ::= duration_literal", - /* 198 */ "literal ::= NULL", - /* 199 */ "duration_literal ::= NK_VARIABLE", - /* 200 */ "signed ::= NK_INTEGER", - /* 201 */ "signed ::= NK_PLUS NK_INTEGER", - /* 202 */ "signed ::= NK_MINUS NK_INTEGER", - /* 203 */ "signed ::= NK_FLOAT", - /* 204 */ "signed ::= NK_PLUS NK_FLOAT", - /* 205 */ "signed ::= NK_MINUS NK_FLOAT", - /* 206 */ "signed_literal ::= signed", - /* 207 */ "signed_literal ::= NK_STRING", - /* 208 */ "signed_literal ::= NK_BOOL", - /* 209 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 210 */ "signed_literal ::= duration_literal", - /* 211 */ "signed_literal ::= NULL", - /* 212 */ "literal_list ::= signed_literal", - /* 213 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 214 */ "db_name ::= NK_ID", - /* 215 */ "table_name ::= NK_ID", - /* 216 */ "column_name ::= NK_ID", - /* 217 */ "function_name ::= NK_ID", - /* 218 */ "table_alias ::= NK_ID", - /* 219 */ "column_alias ::= NK_ID", - /* 220 */ "user_name ::= NK_ID", - /* 221 */ "index_name ::= NK_ID", - /* 222 */ "topic_name ::= NK_ID", - /* 223 */ "expression ::= literal", - /* 224 */ "expression ::= pseudo_column", - /* 225 */ "expression ::= column_reference", - /* 226 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 227 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 228 */ "expression ::= subquery", - /* 229 */ "expression ::= NK_LP expression NK_RP", - /* 230 */ "expression ::= NK_PLUS expression", - /* 231 */ "expression ::= NK_MINUS expression", - /* 232 */ "expression ::= expression NK_PLUS expression", - /* 233 */ "expression ::= expression NK_MINUS expression", - /* 234 */ "expression ::= expression NK_STAR expression", - /* 235 */ "expression ::= expression NK_SLASH expression", - /* 236 */ "expression ::= expression NK_REM expression", - /* 237 */ "expression_list ::= expression", - /* 238 */ "expression_list ::= expression_list NK_COMMA expression", - /* 239 */ "column_reference ::= column_name", - /* 240 */ "column_reference ::= table_name NK_DOT column_name", - /* 241 */ "pseudo_column ::= NK_UNDERLINE ROWTS", - /* 242 */ "pseudo_column ::= TBNAME", - /* 243 */ "pseudo_column ::= NK_UNDERLINE QSTARTTS", - /* 244 */ "pseudo_column ::= NK_UNDERLINE QENDTS", - /* 245 */ "pseudo_column ::= NK_UNDERLINE WSTARTTS", - /* 246 */ "pseudo_column ::= NK_UNDERLINE WENDTS", - /* 247 */ "pseudo_column ::= NK_UNDERLINE WDURATION", - /* 248 */ "predicate ::= expression compare_op expression", - /* 249 */ "predicate ::= expression BETWEEN expression AND expression", - /* 250 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 251 */ "predicate ::= expression IS NULL", - /* 252 */ "predicate ::= expression IS NOT NULL", - /* 253 */ "predicate ::= expression in_op in_predicate_value", - /* 254 */ "compare_op ::= NK_LT", - /* 255 */ "compare_op ::= NK_GT", - /* 256 */ "compare_op ::= NK_LE", - /* 257 */ "compare_op ::= NK_GE", - /* 258 */ "compare_op ::= NK_NE", - /* 259 */ "compare_op ::= NK_EQ", - /* 260 */ "compare_op ::= LIKE", - /* 261 */ "compare_op ::= NOT LIKE", - /* 262 */ "compare_op ::= MATCH", - /* 263 */ "compare_op ::= NMATCH", - /* 264 */ "in_op ::= IN", - /* 265 */ "in_op ::= NOT IN", - /* 266 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 267 */ "boolean_value_expression ::= boolean_primary", - /* 268 */ "boolean_value_expression ::= NOT boolean_primary", - /* 269 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 270 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 271 */ "boolean_primary ::= predicate", - /* 272 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 273 */ "common_expression ::= expression", - /* 274 */ "common_expression ::= boolean_value_expression", - /* 275 */ "from_clause ::= FROM table_reference_list", - /* 276 */ "table_reference_list ::= table_reference", - /* 277 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 278 */ "table_reference ::= table_primary", - /* 279 */ "table_reference ::= joined_table", - /* 280 */ "table_primary ::= table_name alias_opt", - /* 281 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 282 */ "table_primary ::= subquery alias_opt", - /* 283 */ "table_primary ::= parenthesized_joined_table", - /* 284 */ "alias_opt ::=", - /* 285 */ "alias_opt ::= table_alias", - /* 286 */ "alias_opt ::= AS table_alias", - /* 287 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 288 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 289 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 290 */ "join_type ::=", - /* 291 */ "join_type ::= INNER", - /* 292 */ "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", - /* 293 */ "set_quantifier_opt ::=", - /* 294 */ "set_quantifier_opt ::= DISTINCT", - /* 295 */ "set_quantifier_opt ::= ALL", - /* 296 */ "select_list ::= NK_STAR", - /* 297 */ "select_list ::= select_sublist", - /* 298 */ "select_sublist ::= select_item", - /* 299 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 300 */ "select_item ::= common_expression", - /* 301 */ "select_item ::= common_expression column_alias", - /* 302 */ "select_item ::= common_expression AS column_alias", - /* 303 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 304 */ "where_clause_opt ::=", - /* 305 */ "where_clause_opt ::= WHERE search_condition", - /* 306 */ "partition_by_clause_opt ::=", - /* 307 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 308 */ "twindow_clause_opt ::=", - /* 309 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 310 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 311 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 312 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 313 */ "sliding_opt ::=", - /* 314 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 315 */ "fill_opt ::=", - /* 316 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 317 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 318 */ "fill_mode ::= NONE", - /* 319 */ "fill_mode ::= PREV", - /* 320 */ "fill_mode ::= NULL", - /* 321 */ "fill_mode ::= LINEAR", - /* 322 */ "fill_mode ::= NEXT", - /* 323 */ "group_by_clause_opt ::=", - /* 324 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 325 */ "group_by_list ::= expression", - /* 326 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 327 */ "having_clause_opt ::=", - /* 328 */ "having_clause_opt ::= HAVING search_condition", - /* 329 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 330 */ "query_expression_body ::= query_primary", - /* 331 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 332 */ "query_primary ::= query_specification", - /* 333 */ "order_by_clause_opt ::=", - /* 334 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 335 */ "slimit_clause_opt ::=", - /* 336 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 337 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 338 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 339 */ "limit_clause_opt ::=", - /* 340 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 341 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 342 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 343 */ "subquery ::= NK_LP query_expression NK_RP", - /* 344 */ "search_condition ::= common_expression", - /* 345 */ "sort_specification_list ::= sort_specification", - /* 346 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 347 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 348 */ "ordering_specification_opt ::=", - /* 349 */ "ordering_specification_opt ::= ASC", - /* 350 */ "ordering_specification_opt ::= DESC", - /* 351 */ "null_ordering_opt ::=", - /* 352 */ "null_ordering_opt ::= NULLS FIRST", - /* 353 */ "null_ordering_opt ::= NULLS LAST", + /* 78 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 79 */ "integer_list ::= NK_INTEGER", + /* 80 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 81 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 82 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 83 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 84 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 85 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 86 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 87 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 88 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 89 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 90 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 91 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 92 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 93 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 94 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 95 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 96 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 97 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", + /* 98 */ "multi_create_clause ::= create_subtable_clause", + /* 99 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 100 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 101 */ "multi_drop_clause ::= drop_table_clause", + /* 102 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 103 */ "drop_table_clause ::= exists_opt full_table_name", + /* 104 */ "specific_tags_opt ::=", + /* 105 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 106 */ "full_table_name ::= table_name", + /* 107 */ "full_table_name ::= db_name NK_DOT table_name", + /* 108 */ "column_def_list ::= column_def", + /* 109 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 110 */ "column_def ::= column_name type_name", + /* 111 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 112 */ "type_name ::= BOOL", + /* 113 */ "type_name ::= TINYINT", + /* 114 */ "type_name ::= SMALLINT", + /* 115 */ "type_name ::= INT", + /* 116 */ "type_name ::= INTEGER", + /* 117 */ "type_name ::= BIGINT", + /* 118 */ "type_name ::= FLOAT", + /* 119 */ "type_name ::= DOUBLE", + /* 120 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 121 */ "type_name ::= TIMESTAMP", + /* 122 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 123 */ "type_name ::= TINYINT UNSIGNED", + /* 124 */ "type_name ::= SMALLINT UNSIGNED", + /* 125 */ "type_name ::= INT UNSIGNED", + /* 126 */ "type_name ::= BIGINT UNSIGNED", + /* 127 */ "type_name ::= JSON", + /* 128 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 129 */ "type_name ::= MEDIUMBLOB", + /* 130 */ "type_name ::= BLOB", + /* 131 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 132 */ "type_name ::= DECIMAL", + /* 133 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 134 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 135 */ "tags_def_opt ::=", + /* 136 */ "tags_def_opt ::= tags_def", + /* 137 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 138 */ "table_options ::=", + /* 139 */ "table_options ::= table_options COMMENT NK_STRING", + /* 140 */ "table_options ::= table_options KEEP integer_list", + /* 141 */ "table_options ::= table_options TTL NK_INTEGER", + /* 142 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 143 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 144 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", + /* 145 */ "table_options ::= table_options DELAY NK_INTEGER", + /* 146 */ "alter_table_options ::= alter_table_option", + /* 147 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 148 */ "alter_table_option ::= COMMENT NK_STRING", + /* 149 */ "alter_table_option ::= KEEP integer_list", + /* 150 */ "alter_table_option ::= TTL NK_INTEGER", + /* 151 */ "col_name_list ::= col_name", + /* 152 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 153 */ "col_name ::= column_name", + /* 154 */ "cmd ::= SHOW DNODES", + /* 155 */ "cmd ::= SHOW USERS", + /* 156 */ "cmd ::= SHOW DATABASES", + /* 157 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 158 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 159 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 160 */ "cmd ::= SHOW MNODES", + /* 161 */ "cmd ::= SHOW MODULES", + /* 162 */ "cmd ::= SHOW QNODES", + /* 163 */ "cmd ::= SHOW FUNCTIONS", + /* 164 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 165 */ "cmd ::= SHOW STREAMS", + /* 166 */ "db_name_cond_opt ::=", + /* 167 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 168 */ "like_pattern_opt ::=", + /* 169 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 170 */ "table_name_cond ::= table_name", + /* 171 */ "from_db_opt ::=", + /* 172 */ "from_db_opt ::= FROM db_name", + /* 173 */ "func_name_list ::= func_name", + /* 174 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 175 */ "func_name ::= function_name", + /* 176 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 177 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", + /* 178 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", + /* 179 */ "index_options ::=", + /* 180 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 181 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 182 */ "func_list ::= func", + /* 183 */ "func_list ::= func_list NK_COMMA func", + /* 184 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 185 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 186 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 187 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 188 */ "cmd ::= DESC full_table_name", + /* 189 */ "cmd ::= DESCRIBE full_table_name", + /* 190 */ "cmd ::= RESET QUERY CACHE", + /* 191 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 192 */ "analyze_opt ::=", + /* 193 */ "analyze_opt ::= ANALYZE", + /* 194 */ "explain_options ::=", + /* 195 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 196 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 197 */ "cmd ::= query_expression", + /* 198 */ "literal ::= NK_INTEGER", + /* 199 */ "literal ::= NK_FLOAT", + /* 200 */ "literal ::= NK_STRING", + /* 201 */ "literal ::= NK_BOOL", + /* 202 */ "literal ::= TIMESTAMP NK_STRING", + /* 203 */ "literal ::= duration_literal", + /* 204 */ "literal ::= NULL", + /* 205 */ "duration_literal ::= NK_VARIABLE", + /* 206 */ "signed ::= NK_INTEGER", + /* 207 */ "signed ::= NK_PLUS NK_INTEGER", + /* 208 */ "signed ::= NK_MINUS NK_INTEGER", + /* 209 */ "signed ::= NK_FLOAT", + /* 210 */ "signed ::= NK_PLUS NK_FLOAT", + /* 211 */ "signed ::= NK_MINUS NK_FLOAT", + /* 212 */ "signed_literal ::= signed", + /* 213 */ "signed_literal ::= NK_STRING", + /* 214 */ "signed_literal ::= NK_BOOL", + /* 215 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 216 */ "signed_literal ::= duration_literal", + /* 217 */ "signed_literal ::= NULL", + /* 218 */ "literal_list ::= signed_literal", + /* 219 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 220 */ "db_name ::= NK_ID", + /* 221 */ "table_name ::= NK_ID", + /* 222 */ "column_name ::= NK_ID", + /* 223 */ "function_name ::= NK_ID", + /* 224 */ "table_alias ::= NK_ID", + /* 225 */ "column_alias ::= NK_ID", + /* 226 */ "user_name ::= NK_ID", + /* 227 */ "index_name ::= NK_ID", + /* 228 */ "topic_name ::= NK_ID", + /* 229 */ "expression ::= literal", + /* 230 */ "expression ::= pseudo_column", + /* 231 */ "expression ::= column_reference", + /* 232 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 233 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 234 */ "expression ::= subquery", + /* 235 */ "expression ::= NK_LP expression NK_RP", + /* 236 */ "expression ::= NK_PLUS expression", + /* 237 */ "expression ::= NK_MINUS expression", + /* 238 */ "expression ::= expression NK_PLUS expression", + /* 239 */ "expression ::= expression NK_MINUS expression", + /* 240 */ "expression ::= expression NK_STAR expression", + /* 241 */ "expression ::= expression NK_SLASH expression", + /* 242 */ "expression ::= expression NK_REM expression", + /* 243 */ "expression_list ::= expression", + /* 244 */ "expression_list ::= expression_list NK_COMMA expression", + /* 245 */ "column_reference ::= column_name", + /* 246 */ "column_reference ::= table_name NK_DOT column_name", + /* 247 */ "pseudo_column ::= NK_UNDERLINE ROWTS", + /* 248 */ "pseudo_column ::= TBNAME", + /* 249 */ "pseudo_column ::= NK_UNDERLINE QSTARTTS", + /* 250 */ "pseudo_column ::= NK_UNDERLINE QENDTS", + /* 251 */ "pseudo_column ::= NK_UNDERLINE WSTARTTS", + /* 252 */ "pseudo_column ::= NK_UNDERLINE WENDTS", + /* 253 */ "pseudo_column ::= NK_UNDERLINE WDURATION", + /* 254 */ "predicate ::= expression compare_op expression", + /* 255 */ "predicate ::= expression BETWEEN expression AND expression", + /* 256 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 257 */ "predicate ::= expression IS NULL", + /* 258 */ "predicate ::= expression IS NOT NULL", + /* 259 */ "predicate ::= expression in_op in_predicate_value", + /* 260 */ "compare_op ::= NK_LT", + /* 261 */ "compare_op ::= NK_GT", + /* 262 */ "compare_op ::= NK_LE", + /* 263 */ "compare_op ::= NK_GE", + /* 264 */ "compare_op ::= NK_NE", + /* 265 */ "compare_op ::= NK_EQ", + /* 266 */ "compare_op ::= LIKE", + /* 267 */ "compare_op ::= NOT LIKE", + /* 268 */ "compare_op ::= MATCH", + /* 269 */ "compare_op ::= NMATCH", + /* 270 */ "in_op ::= IN", + /* 271 */ "in_op ::= NOT IN", + /* 272 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 273 */ "boolean_value_expression ::= boolean_primary", + /* 274 */ "boolean_value_expression ::= NOT boolean_primary", + /* 275 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 276 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 277 */ "boolean_primary ::= predicate", + /* 278 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 279 */ "common_expression ::= expression", + /* 280 */ "common_expression ::= boolean_value_expression", + /* 281 */ "from_clause ::= FROM table_reference_list", + /* 282 */ "table_reference_list ::= table_reference", + /* 283 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 284 */ "table_reference ::= table_primary", + /* 285 */ "table_reference ::= joined_table", + /* 286 */ "table_primary ::= table_name alias_opt", + /* 287 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 288 */ "table_primary ::= subquery alias_opt", + /* 289 */ "table_primary ::= parenthesized_joined_table", + /* 290 */ "alias_opt ::=", + /* 291 */ "alias_opt ::= table_alias", + /* 292 */ "alias_opt ::= AS table_alias", + /* 293 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 294 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 295 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 296 */ "join_type ::=", + /* 297 */ "join_type ::= INNER", + /* 298 */ "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", + /* 299 */ "set_quantifier_opt ::=", + /* 300 */ "set_quantifier_opt ::= DISTINCT", + /* 301 */ "set_quantifier_opt ::= ALL", + /* 302 */ "select_list ::= NK_STAR", + /* 303 */ "select_list ::= select_sublist", + /* 304 */ "select_sublist ::= select_item", + /* 305 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 306 */ "select_item ::= common_expression", + /* 307 */ "select_item ::= common_expression column_alias", + /* 308 */ "select_item ::= common_expression AS column_alias", + /* 309 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 310 */ "where_clause_opt ::=", + /* 311 */ "where_clause_opt ::= WHERE search_condition", + /* 312 */ "partition_by_clause_opt ::=", + /* 313 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 314 */ "twindow_clause_opt ::=", + /* 315 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 316 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 317 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 318 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 319 */ "sliding_opt ::=", + /* 320 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 321 */ "fill_opt ::=", + /* 322 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 323 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 324 */ "fill_mode ::= NONE", + /* 325 */ "fill_mode ::= PREV", + /* 326 */ "fill_mode ::= NULL", + /* 327 */ "fill_mode ::= LINEAR", + /* 328 */ "fill_mode ::= NEXT", + /* 329 */ "group_by_clause_opt ::=", + /* 330 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 331 */ "group_by_list ::= expression", + /* 332 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 333 */ "having_clause_opt ::=", + /* 334 */ "having_clause_opt ::= HAVING search_condition", + /* 335 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 336 */ "query_expression_body ::= query_primary", + /* 337 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 338 */ "query_primary ::= query_specification", + /* 339 */ "order_by_clause_opt ::=", + /* 340 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 341 */ "slimit_clause_opt ::=", + /* 342 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 343 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 344 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 345 */ "limit_clause_opt ::=", + /* 346 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 347 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 348 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 349 */ "subquery ::= NK_LP query_expression NK_RP", + /* 350 */ "search_condition ::= common_expression", + /* 351 */ "sort_specification_list ::= sort_specification", + /* 352 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 353 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 354 */ "ordering_specification_opt ::=", + /* 355 */ "ordering_specification_opt ::= ASC", + /* 356 */ "ordering_specification_opt ::= DESC", + /* 357 */ "null_ordering_opt ::=", + /* 358 */ "null_ordering_opt ::= NULLS FIRST", + /* 359 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1478,148 +1497,149 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 176: /* cmd */ - case 179: /* literal */ - case 186: /* db_options */ - case 188: /* alter_db_options */ - case 190: /* full_table_name */ - case 193: /* table_options */ - case 197: /* alter_table_clause */ - case 198: /* alter_table_options */ - case 201: /* create_subtable_clause */ - case 204: /* drop_table_clause */ - case 207: /* column_def */ - case 210: /* col_name */ - case 211: /* db_name_cond_opt */ - case 212: /* like_pattern_opt */ - case 213: /* table_name_cond */ - case 214: /* from_db_opt */ - case 215: /* func_name */ - case 218: /* index_options */ - case 220: /* duration_literal */ - case 221: /* sliding_opt */ - case 222: /* func */ - case 225: /* query_expression */ - case 227: /* explain_options */ - case 228: /* signed */ - case 229: /* signed_literal */ - case 232: /* expression */ - case 233: /* pseudo_column */ - case 234: /* column_reference */ - case 235: /* subquery */ - case 236: /* predicate */ - case 239: /* in_predicate_value */ - case 240: /* boolean_value_expression */ - case 241: /* boolean_primary */ - case 242: /* common_expression */ - case 243: /* from_clause */ - case 244: /* table_reference_list */ - case 245: /* table_reference */ - case 246: /* table_primary */ - case 247: /* joined_table */ - case 249: /* parenthesized_joined_table */ - case 251: /* search_condition */ - case 252: /* query_specification */ - case 255: /* where_clause_opt */ - case 257: /* twindow_clause_opt */ - case 259: /* having_clause_opt */ - case 261: /* select_item */ - case 262: /* fill_opt */ - case 265: /* query_expression_body */ - case 267: /* slimit_clause_opt */ - case 268: /* limit_clause_opt */ - case 269: /* query_primary */ - case 271: /* sort_specification */ + case 179: /* cmd */ + case 182: /* literal */ + case 189: /* db_options */ + case 191: /* alter_db_options */ + case 194: /* full_table_name */ + case 197: /* table_options */ + case 201: /* alter_table_clause */ + case 202: /* alter_table_options */ + case 205: /* create_subtable_clause */ + case 208: /* drop_table_clause */ + case 211: /* column_def */ + case 214: /* col_name */ + case 215: /* db_name_cond_opt */ + case 216: /* like_pattern_opt */ + case 217: /* table_name_cond */ + case 218: /* from_db_opt */ + case 219: /* func_name */ + case 222: /* index_options */ + case 224: /* duration_literal */ + case 225: /* sliding_opt */ + case 226: /* func */ + case 229: /* query_expression */ + case 231: /* explain_options */ + case 232: /* signed */ + case 233: /* signed_literal */ + case 236: /* expression */ + case 237: /* pseudo_column */ + case 238: /* column_reference */ + case 239: /* subquery */ + case 240: /* predicate */ + case 243: /* in_predicate_value */ + case 244: /* boolean_value_expression */ + case 245: /* boolean_primary */ + case 246: /* common_expression */ + case 247: /* from_clause */ + case 248: /* table_reference_list */ + case 249: /* table_reference */ + case 250: /* table_primary */ + case 251: /* joined_table */ + case 253: /* parenthesized_joined_table */ + case 255: /* search_condition */ + case 256: /* query_specification */ + case 259: /* where_clause_opt */ + case 261: /* twindow_clause_opt */ + case 263: /* having_clause_opt */ + case 265: /* select_item */ + case 266: /* fill_opt */ + case 269: /* query_expression_body */ + case 271: /* slimit_clause_opt */ + case 272: /* limit_clause_opt */ + case 273: /* query_primary */ + case 275: /* sort_specification */ { - nodesDestroyNode((yypminor->yy364)); + nodesDestroyNode((yypminor->yy24)); } break; - case 177: /* account_options */ - case 178: /* alter_account_options */ - case 180: /* alter_account_option */ + case 180: /* account_options */ + case 181: /* alter_account_options */ + case 183: /* alter_account_option */ { } break; - case 181: /* user_name */ - case 182: /* dnode_endpoint */ - case 183: /* dnode_host_name */ - case 185: /* db_name */ - case 199: /* column_name */ - case 206: /* table_name */ - case 216: /* function_name */ - case 217: /* index_name */ - case 224: /* topic_name */ - case 230: /* table_alias */ - case 231: /* column_alias */ - case 248: /* alias_opt */ + case 184: /* user_name */ + case 185: /* dnode_endpoint */ + case 186: /* dnode_host_name */ + case 188: /* db_name */ + case 203: /* column_name */ + case 210: /* table_name */ + case 220: /* function_name */ + case 221: /* index_name */ + case 228: /* topic_name */ + case 234: /* table_alias */ + case 235: /* column_alias */ + case 252: /* alias_opt */ { } break; - case 184: /* not_exists_opt */ - case 187: /* exists_opt */ - case 226: /* analyze_opt */ - case 253: /* set_quantifier_opt */ + case 187: /* not_exists_opt */ + case 190: /* exists_opt */ + case 230: /* analyze_opt */ + case 257: /* set_quantifier_opt */ { } break; - case 189: /* alter_db_option */ - case 209: /* alter_table_option */ + case 192: /* integer_list */ + case 195: /* column_def_list */ + case 196: /* tags_def_opt */ + case 198: /* multi_create_clause */ + case 199: /* tags_def */ + case 200: /* multi_drop_clause */ + case 206: /* specific_tags_opt */ + case 207: /* literal_list */ + case 209: /* col_name_list */ + case 212: /* func_name_list */ + case 223: /* func_list */ + case 227: /* expression_list */ + case 258: /* select_list */ + case 260: /* partition_by_clause_opt */ + case 262: /* group_by_clause_opt */ + case 264: /* select_sublist */ + case 268: /* group_by_list */ + case 270: /* order_by_clause_opt */ + case 274: /* sort_specification_list */ +{ + nodesDestroyList((yypminor->yy504)); +} + break; + case 193: /* alter_db_option */ + case 213: /* alter_table_option */ { } break; - case 191: /* column_def_list */ - case 192: /* tags_def_opt */ - case 194: /* multi_create_clause */ - case 195: /* tags_def */ - case 196: /* multi_drop_clause */ - case 202: /* specific_tags_opt */ - case 203: /* literal_list */ - case 205: /* col_name_list */ - case 208: /* func_name_list */ - case 219: /* func_list */ - case 223: /* expression_list */ - case 254: /* select_list */ - case 256: /* partition_by_clause_opt */ - case 258: /* group_by_clause_opt */ - case 260: /* select_sublist */ - case 264: /* group_by_list */ - case 266: /* order_by_clause_opt */ - case 270: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy40)); -} - break; - case 200: /* type_name */ + case 204: /* type_name */ { } break; - case 237: /* compare_op */ - case 238: /* in_op */ + case 241: /* compare_op */ + case 242: /* in_op */ { } break; - case 250: /* join_type */ + case 254: /* join_type */ { } break; - case 263: /* fill_mode */ + case 267: /* fill_mode */ { } break; - case 272: /* ordering_specification_opt */ + case 276: /* ordering_specification_opt */ { } break; - case 273: /* null_ordering_opt */ + case 277: /* null_ordering_opt */ { } @@ -1918,360 +1938,366 @@ 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[] = { - { 176, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 176, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 177, 0 }, /* (2) account_options ::= */ - { 177, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 177, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 177, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 177, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 177, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 177, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 177, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 177, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 177, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 178, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 178, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 180, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 180, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 180, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 180, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 180, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 180, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 180, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 180, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 180, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 180, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 176, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 176, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 176, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 176, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 176, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - { 176, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 176, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - { 176, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - { 176, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 176, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 176, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - { 176, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 182, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ - { 183, -1 }, /* (37) dnode_host_name ::= NK_ID */ - { 183, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ - { 176, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - { 176, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 176, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 176, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 176, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 176, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ - { 176, -2 }, /* (45) cmd ::= USE db_name */ - { 176, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 184, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ - { 184, 0 }, /* (48) not_exists_opt ::= */ - { 187, -2 }, /* (49) exists_opt ::= IF EXISTS */ - { 187, 0 }, /* (50) exists_opt ::= */ - { 186, 0 }, /* (51) db_options ::= */ - { 186, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ - { 186, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ - { 186, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ - { 186, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ - { 186, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ - { 186, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ - { 186, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ - { 186, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ - { 186, -3 }, /* (60) db_options ::= db_options KEEP NK_INTEGER */ - { 186, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ - { 186, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ - { 186, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ - { 186, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ - { 186, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ - { 186, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ - { 186, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 186, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 186, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ - { 188, -1 }, /* (70) alter_db_options ::= alter_db_option */ - { 188, -2 }, /* (71) alter_db_options ::= alter_db_options alter_db_option */ - { 189, -2 }, /* (72) alter_db_option ::= BLOCKS NK_INTEGER */ - { 189, -2 }, /* (73) alter_db_option ::= FSYNC NK_INTEGER */ - { 189, -2 }, /* (74) alter_db_option ::= KEEP NK_INTEGER */ - { 189, -2 }, /* (75) alter_db_option ::= WAL NK_INTEGER */ - { 189, -2 }, /* (76) alter_db_option ::= QUORUM NK_INTEGER */ - { 189, -2 }, /* (77) alter_db_option ::= CACHELAST NK_INTEGER */ - { 176, -9 }, /* (78) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 176, -3 }, /* (79) cmd ::= CREATE TABLE multi_create_clause */ - { 176, -9 }, /* (80) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 176, -3 }, /* (81) cmd ::= DROP TABLE multi_drop_clause */ - { 176, -4 }, /* (82) cmd ::= DROP STABLE exists_opt full_table_name */ - { 176, -3 }, /* (83) cmd ::= ALTER TABLE alter_table_clause */ - { 176, -3 }, /* (84) cmd ::= ALTER STABLE alter_table_clause */ - { 197, -2 }, /* (85) alter_table_clause ::= full_table_name alter_table_options */ - { 197, -5 }, /* (86) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 197, -4 }, /* (87) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 197, -5 }, /* (88) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 197, -5 }, /* (89) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 197, -5 }, /* (90) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 197, -4 }, /* (91) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 197, -5 }, /* (92) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 197, -5 }, /* (93) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 197, -6 }, /* (94) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - { 194, -1 }, /* (95) multi_create_clause ::= create_subtable_clause */ - { 194, -2 }, /* (96) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 201, -9 }, /* (97) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 196, -1 }, /* (98) multi_drop_clause ::= drop_table_clause */ - { 196, -2 }, /* (99) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 204, -2 }, /* (100) drop_table_clause ::= exists_opt full_table_name */ - { 202, 0 }, /* (101) specific_tags_opt ::= */ - { 202, -3 }, /* (102) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 190, -1 }, /* (103) full_table_name ::= table_name */ - { 190, -3 }, /* (104) full_table_name ::= db_name NK_DOT table_name */ - { 191, -1 }, /* (105) column_def_list ::= column_def */ - { 191, -3 }, /* (106) column_def_list ::= column_def_list NK_COMMA column_def */ - { 207, -2 }, /* (107) column_def ::= column_name type_name */ - { 207, -4 }, /* (108) column_def ::= column_name type_name COMMENT NK_STRING */ - { 200, -1 }, /* (109) type_name ::= BOOL */ - { 200, -1 }, /* (110) type_name ::= TINYINT */ - { 200, -1 }, /* (111) type_name ::= SMALLINT */ - { 200, -1 }, /* (112) type_name ::= INT */ - { 200, -1 }, /* (113) type_name ::= INTEGER */ - { 200, -1 }, /* (114) type_name ::= BIGINT */ - { 200, -1 }, /* (115) type_name ::= FLOAT */ - { 200, -1 }, /* (116) type_name ::= DOUBLE */ - { 200, -4 }, /* (117) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 200, -1 }, /* (118) type_name ::= TIMESTAMP */ - { 200, -4 }, /* (119) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 200, -2 }, /* (120) type_name ::= TINYINT UNSIGNED */ - { 200, -2 }, /* (121) type_name ::= SMALLINT UNSIGNED */ - { 200, -2 }, /* (122) type_name ::= INT UNSIGNED */ - { 200, -2 }, /* (123) type_name ::= BIGINT UNSIGNED */ - { 200, -1 }, /* (124) type_name ::= JSON */ - { 200, -4 }, /* (125) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 200, -1 }, /* (126) type_name ::= MEDIUMBLOB */ - { 200, -1 }, /* (127) type_name ::= BLOB */ - { 200, -4 }, /* (128) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 200, -1 }, /* (129) type_name ::= DECIMAL */ - { 200, -4 }, /* (130) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 200, -6 }, /* (131) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 192, 0 }, /* (132) tags_def_opt ::= */ - { 192, -1 }, /* (133) tags_def_opt ::= tags_def */ - { 195, -4 }, /* (134) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 193, 0 }, /* (135) table_options ::= */ - { 193, -3 }, /* (136) table_options ::= table_options COMMENT NK_STRING */ - { 193, -3 }, /* (137) table_options ::= table_options KEEP NK_INTEGER */ - { 193, -3 }, /* (138) table_options ::= table_options TTL NK_INTEGER */ - { 193, -5 }, /* (139) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 193, -5 }, /* (140) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 193, -3 }, /* (141) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 193, -3 }, /* (142) table_options ::= table_options DELAY NK_INTEGER */ - { 198, -1 }, /* (143) alter_table_options ::= alter_table_option */ - { 198, -2 }, /* (144) alter_table_options ::= alter_table_options alter_table_option */ - { 209, -2 }, /* (145) alter_table_option ::= COMMENT NK_STRING */ - { 209, -2 }, /* (146) alter_table_option ::= KEEP NK_INTEGER */ - { 209, -2 }, /* (147) alter_table_option ::= TTL NK_INTEGER */ - { 205, -1 }, /* (148) col_name_list ::= col_name */ - { 205, -3 }, /* (149) col_name_list ::= col_name_list NK_COMMA col_name */ - { 210, -1 }, /* (150) col_name ::= column_name */ - { 176, -2 }, /* (151) cmd ::= SHOW DNODES */ - { 176, -2 }, /* (152) cmd ::= SHOW USERS */ - { 176, -2 }, /* (153) cmd ::= SHOW DATABASES */ - { 176, -4 }, /* (154) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 176, -4 }, /* (155) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 176, -3 }, /* (156) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 176, -2 }, /* (157) cmd ::= SHOW MNODES */ - { 176, -2 }, /* (158) cmd ::= SHOW MODULES */ - { 176, -2 }, /* (159) cmd ::= SHOW QNODES */ - { 176, -2 }, /* (160) cmd ::= SHOW FUNCTIONS */ - { 176, -5 }, /* (161) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 176, -2 }, /* (162) cmd ::= SHOW STREAMS */ - { 211, 0 }, /* (163) db_name_cond_opt ::= */ - { 211, -2 }, /* (164) db_name_cond_opt ::= db_name NK_DOT */ - { 212, 0 }, /* (165) like_pattern_opt ::= */ - { 212, -2 }, /* (166) like_pattern_opt ::= LIKE NK_STRING */ - { 213, -1 }, /* (167) table_name_cond ::= table_name */ - { 214, 0 }, /* (168) from_db_opt ::= */ - { 214, -2 }, /* (169) from_db_opt ::= FROM db_name */ - { 208, -1 }, /* (170) func_name_list ::= func_name */ - { 208, -3 }, /* (171) func_name_list ::= func_name_list NK_COMMA col_name */ - { 215, -1 }, /* (172) func_name ::= function_name */ - { 176, -8 }, /* (173) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 176, -10 }, /* (174) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 176, -6 }, /* (175) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 218, 0 }, /* (176) index_options ::= */ - { 218, -9 }, /* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 218, -11 }, /* (178) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 219, -1 }, /* (179) func_list ::= func */ - { 219, -3 }, /* (180) func_list ::= func_list NK_COMMA func */ - { 222, -4 }, /* (181) func ::= function_name NK_LP expression_list NK_RP */ - { 176, -6 }, /* (182) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 176, -6 }, /* (183) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 176, -4 }, /* (184) cmd ::= DROP TOPIC exists_opt topic_name */ - { 176, -4 }, /* (185) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 226, 0 }, /* (186) analyze_opt ::= */ - { 226, -1 }, /* (187) analyze_opt ::= ANALYZE */ - { 227, 0 }, /* (188) explain_options ::= */ - { 227, -3 }, /* (189) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 227, -3 }, /* (190) explain_options ::= explain_options RATIO NK_FLOAT */ - { 176, -1 }, /* (191) cmd ::= query_expression */ - { 179, -1 }, /* (192) literal ::= NK_INTEGER */ - { 179, -1 }, /* (193) literal ::= NK_FLOAT */ - { 179, -1 }, /* (194) literal ::= NK_STRING */ - { 179, -1 }, /* (195) literal ::= NK_BOOL */ - { 179, -2 }, /* (196) literal ::= TIMESTAMP NK_STRING */ - { 179, -1 }, /* (197) literal ::= duration_literal */ - { 179, -1 }, /* (198) literal ::= NULL */ - { 220, -1 }, /* (199) duration_literal ::= NK_VARIABLE */ - { 228, -1 }, /* (200) signed ::= NK_INTEGER */ - { 228, -2 }, /* (201) signed ::= NK_PLUS NK_INTEGER */ - { 228, -2 }, /* (202) signed ::= NK_MINUS NK_INTEGER */ - { 228, -1 }, /* (203) signed ::= NK_FLOAT */ - { 228, -2 }, /* (204) signed ::= NK_PLUS NK_FLOAT */ - { 228, -2 }, /* (205) signed ::= NK_MINUS NK_FLOAT */ - { 229, -1 }, /* (206) signed_literal ::= signed */ - { 229, -1 }, /* (207) signed_literal ::= NK_STRING */ - { 229, -1 }, /* (208) signed_literal ::= NK_BOOL */ - { 229, -2 }, /* (209) signed_literal ::= TIMESTAMP NK_STRING */ - { 229, -1 }, /* (210) signed_literal ::= duration_literal */ - { 229, -1 }, /* (211) signed_literal ::= NULL */ - { 203, -1 }, /* (212) literal_list ::= signed_literal */ - { 203, -3 }, /* (213) literal_list ::= literal_list NK_COMMA signed_literal */ - { 185, -1 }, /* (214) db_name ::= NK_ID */ - { 206, -1 }, /* (215) table_name ::= NK_ID */ - { 199, -1 }, /* (216) column_name ::= NK_ID */ - { 216, -1 }, /* (217) function_name ::= NK_ID */ - { 230, -1 }, /* (218) table_alias ::= NK_ID */ - { 231, -1 }, /* (219) column_alias ::= NK_ID */ - { 181, -1 }, /* (220) user_name ::= NK_ID */ - { 217, -1 }, /* (221) index_name ::= NK_ID */ - { 224, -1 }, /* (222) topic_name ::= NK_ID */ - { 232, -1 }, /* (223) expression ::= literal */ - { 232, -1 }, /* (224) expression ::= pseudo_column */ - { 232, -1 }, /* (225) expression ::= column_reference */ - { 232, -4 }, /* (226) expression ::= function_name NK_LP expression_list NK_RP */ - { 232, -4 }, /* (227) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 232, -1 }, /* (228) expression ::= subquery */ - { 232, -3 }, /* (229) expression ::= NK_LP expression NK_RP */ - { 232, -2 }, /* (230) expression ::= NK_PLUS expression */ - { 232, -2 }, /* (231) expression ::= NK_MINUS expression */ - { 232, -3 }, /* (232) expression ::= expression NK_PLUS expression */ - { 232, -3 }, /* (233) expression ::= expression NK_MINUS expression */ - { 232, -3 }, /* (234) expression ::= expression NK_STAR expression */ - { 232, -3 }, /* (235) expression ::= expression NK_SLASH expression */ - { 232, -3 }, /* (236) expression ::= expression NK_REM expression */ - { 223, -1 }, /* (237) expression_list ::= expression */ - { 223, -3 }, /* (238) expression_list ::= expression_list NK_COMMA expression */ - { 234, -1 }, /* (239) column_reference ::= column_name */ - { 234, -3 }, /* (240) column_reference ::= table_name NK_DOT column_name */ - { 233, -2 }, /* (241) pseudo_column ::= NK_UNDERLINE ROWTS */ - { 233, -1 }, /* (242) pseudo_column ::= TBNAME */ - { 233, -2 }, /* (243) pseudo_column ::= NK_UNDERLINE QSTARTTS */ - { 233, -2 }, /* (244) pseudo_column ::= NK_UNDERLINE QENDTS */ - { 233, -2 }, /* (245) pseudo_column ::= NK_UNDERLINE WSTARTTS */ - { 233, -2 }, /* (246) pseudo_column ::= NK_UNDERLINE WENDTS */ - { 233, -2 }, /* (247) pseudo_column ::= NK_UNDERLINE WDURATION */ - { 236, -3 }, /* (248) predicate ::= expression compare_op expression */ - { 236, -5 }, /* (249) predicate ::= expression BETWEEN expression AND expression */ - { 236, -6 }, /* (250) predicate ::= expression NOT BETWEEN expression AND expression */ - { 236, -3 }, /* (251) predicate ::= expression IS NULL */ - { 236, -4 }, /* (252) predicate ::= expression IS NOT NULL */ - { 236, -3 }, /* (253) predicate ::= expression in_op in_predicate_value */ - { 237, -1 }, /* (254) compare_op ::= NK_LT */ - { 237, -1 }, /* (255) compare_op ::= NK_GT */ - { 237, -1 }, /* (256) compare_op ::= NK_LE */ - { 237, -1 }, /* (257) compare_op ::= NK_GE */ - { 237, -1 }, /* (258) compare_op ::= NK_NE */ - { 237, -1 }, /* (259) compare_op ::= NK_EQ */ - { 237, -1 }, /* (260) compare_op ::= LIKE */ - { 237, -2 }, /* (261) compare_op ::= NOT LIKE */ - { 237, -1 }, /* (262) compare_op ::= MATCH */ - { 237, -1 }, /* (263) compare_op ::= NMATCH */ - { 238, -1 }, /* (264) in_op ::= IN */ - { 238, -2 }, /* (265) in_op ::= NOT IN */ - { 239, -3 }, /* (266) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 240, -1 }, /* (267) boolean_value_expression ::= boolean_primary */ - { 240, -2 }, /* (268) boolean_value_expression ::= NOT boolean_primary */ - { 240, -3 }, /* (269) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 240, -3 }, /* (270) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 241, -1 }, /* (271) boolean_primary ::= predicate */ - { 241, -3 }, /* (272) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 242, -1 }, /* (273) common_expression ::= expression */ - { 242, -1 }, /* (274) common_expression ::= boolean_value_expression */ - { 243, -2 }, /* (275) from_clause ::= FROM table_reference_list */ - { 244, -1 }, /* (276) table_reference_list ::= table_reference */ - { 244, -3 }, /* (277) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 245, -1 }, /* (278) table_reference ::= table_primary */ - { 245, -1 }, /* (279) table_reference ::= joined_table */ - { 246, -2 }, /* (280) table_primary ::= table_name alias_opt */ - { 246, -4 }, /* (281) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 246, -2 }, /* (282) table_primary ::= subquery alias_opt */ - { 246, -1 }, /* (283) table_primary ::= parenthesized_joined_table */ - { 248, 0 }, /* (284) alias_opt ::= */ - { 248, -1 }, /* (285) alias_opt ::= table_alias */ - { 248, -2 }, /* (286) alias_opt ::= AS table_alias */ - { 249, -3 }, /* (287) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 249, -3 }, /* (288) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 247, -6 }, /* (289) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 250, 0 }, /* (290) join_type ::= */ - { 250, -1 }, /* (291) join_type ::= INNER */ - { 252, -9 }, /* (292) 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 */ - { 253, 0 }, /* (293) set_quantifier_opt ::= */ - { 253, -1 }, /* (294) set_quantifier_opt ::= DISTINCT */ - { 253, -1 }, /* (295) set_quantifier_opt ::= ALL */ - { 254, -1 }, /* (296) select_list ::= NK_STAR */ - { 254, -1 }, /* (297) select_list ::= select_sublist */ - { 260, -1 }, /* (298) select_sublist ::= select_item */ - { 260, -3 }, /* (299) select_sublist ::= select_sublist NK_COMMA select_item */ - { 261, -1 }, /* (300) select_item ::= common_expression */ - { 261, -2 }, /* (301) select_item ::= common_expression column_alias */ - { 261, -3 }, /* (302) select_item ::= common_expression AS column_alias */ - { 261, -3 }, /* (303) select_item ::= table_name NK_DOT NK_STAR */ - { 255, 0 }, /* (304) where_clause_opt ::= */ - { 255, -2 }, /* (305) where_clause_opt ::= WHERE search_condition */ - { 256, 0 }, /* (306) partition_by_clause_opt ::= */ - { 256, -3 }, /* (307) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 257, 0 }, /* (308) twindow_clause_opt ::= */ - { 257, -6 }, /* (309) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 257, -4 }, /* (310) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 257, -6 }, /* (311) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 257, -8 }, /* (312) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 221, 0 }, /* (313) sliding_opt ::= */ - { 221, -4 }, /* (314) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 262, 0 }, /* (315) fill_opt ::= */ - { 262, -4 }, /* (316) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 262, -6 }, /* (317) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 263, -1 }, /* (318) fill_mode ::= NONE */ - { 263, -1 }, /* (319) fill_mode ::= PREV */ - { 263, -1 }, /* (320) fill_mode ::= NULL */ - { 263, -1 }, /* (321) fill_mode ::= LINEAR */ - { 263, -1 }, /* (322) fill_mode ::= NEXT */ - { 258, 0 }, /* (323) group_by_clause_opt ::= */ - { 258, -3 }, /* (324) group_by_clause_opt ::= GROUP BY group_by_list */ - { 264, -1 }, /* (325) group_by_list ::= expression */ - { 264, -3 }, /* (326) group_by_list ::= group_by_list NK_COMMA expression */ - { 259, 0 }, /* (327) having_clause_opt ::= */ - { 259, -2 }, /* (328) having_clause_opt ::= HAVING search_condition */ - { 225, -4 }, /* (329) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 265, -1 }, /* (330) query_expression_body ::= query_primary */ - { 265, -4 }, /* (331) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 269, -1 }, /* (332) query_primary ::= query_specification */ - { 266, 0 }, /* (333) order_by_clause_opt ::= */ - { 266, -3 }, /* (334) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 267, 0 }, /* (335) slimit_clause_opt ::= */ - { 267, -2 }, /* (336) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 267, -4 }, /* (337) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 267, -4 }, /* (338) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 268, 0 }, /* (339) limit_clause_opt ::= */ - { 268, -2 }, /* (340) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 268, -4 }, /* (341) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 268, -4 }, /* (342) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 235, -3 }, /* (343) subquery ::= NK_LP query_expression NK_RP */ - { 251, -1 }, /* (344) search_condition ::= common_expression */ - { 270, -1 }, /* (345) sort_specification_list ::= sort_specification */ - { 270, -3 }, /* (346) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 271, -3 }, /* (347) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 272, 0 }, /* (348) ordering_specification_opt ::= */ - { 272, -1 }, /* (349) ordering_specification_opt ::= ASC */ - { 272, -1 }, /* (350) ordering_specification_opt ::= DESC */ - { 273, 0 }, /* (351) null_ordering_opt ::= */ - { 273, -2 }, /* (352) null_ordering_opt ::= NULLS FIRST */ - { 273, -2 }, /* (353) null_ordering_opt ::= NULLS LAST */ + { 179, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 179, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 180, 0 }, /* (2) account_options ::= */ + { 180, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 180, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 180, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 180, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 180, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 180, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 180, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 180, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 180, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 181, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 181, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 183, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 183, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 183, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 183, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 183, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 183, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 183, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 183, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 183, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 183, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 179, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 179, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 179, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 179, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 179, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + { 179, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 179, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + { 179, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + { 179, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 179, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 179, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + { 179, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 185, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ + { 186, -1 }, /* (37) dnode_host_name ::= NK_ID */ + { 186, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ + { 179, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + { 179, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 179, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 179, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 179, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 179, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ + { 179, -2 }, /* (45) cmd ::= USE db_name */ + { 179, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 187, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ + { 187, 0 }, /* (48) not_exists_opt ::= */ + { 190, -2 }, /* (49) exists_opt ::= IF EXISTS */ + { 190, 0 }, /* (50) exists_opt ::= */ + { 189, 0 }, /* (51) db_options ::= */ + { 189, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ + { 189, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ + { 189, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ + { 189, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ + { 189, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ + { 189, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ + { 189, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ + { 189, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ + { 189, -3 }, /* (60) db_options ::= db_options KEEP integer_list */ + { 189, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ + { 189, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ + { 189, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ + { 189, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ + { 189, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ + { 189, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ + { 189, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 189, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 189, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ + { 191, -1 }, /* (70) alter_db_options ::= alter_db_option */ + { 191, -2 }, /* (71) alter_db_options ::= alter_db_options alter_db_option */ + { 193, -2 }, /* (72) alter_db_option ::= BLOCKS NK_INTEGER */ + { 193, -2 }, /* (73) alter_db_option ::= FSYNC NK_INTEGER */ + { 193, -2 }, /* (74) alter_db_option ::= KEEP integer_list */ + { 193, -2 }, /* (75) alter_db_option ::= WAL NK_INTEGER */ + { 193, -2 }, /* (76) alter_db_option ::= QUORUM NK_INTEGER */ + { 193, -2 }, /* (77) alter_db_option ::= CACHELAST NK_INTEGER */ + { 193, -2 }, /* (78) alter_db_option ::= REPLICA NK_INTEGER */ + { 192, -1 }, /* (79) integer_list ::= NK_INTEGER */ + { 192, -3 }, /* (80) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 179, -9 }, /* (81) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 179, -3 }, /* (82) cmd ::= CREATE TABLE multi_create_clause */ + { 179, -9 }, /* (83) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 179, -3 }, /* (84) cmd ::= DROP TABLE multi_drop_clause */ + { 179, -4 }, /* (85) cmd ::= DROP STABLE exists_opt full_table_name */ + { 179, -3 }, /* (86) cmd ::= ALTER TABLE alter_table_clause */ + { 179, -3 }, /* (87) cmd ::= ALTER STABLE alter_table_clause */ + { 201, -2 }, /* (88) alter_table_clause ::= full_table_name alter_table_options */ + { 201, -5 }, /* (89) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 201, -4 }, /* (90) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 201, -5 }, /* (91) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 201, -5 }, /* (92) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 201, -5 }, /* (93) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 201, -4 }, /* (94) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 201, -5 }, /* (95) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 201, -5 }, /* (96) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 201, -6 }, /* (97) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 198, -1 }, /* (98) multi_create_clause ::= create_subtable_clause */ + { 198, -2 }, /* (99) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 205, -9 }, /* (100) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 200, -1 }, /* (101) multi_drop_clause ::= drop_table_clause */ + { 200, -2 }, /* (102) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 208, -2 }, /* (103) drop_table_clause ::= exists_opt full_table_name */ + { 206, 0 }, /* (104) specific_tags_opt ::= */ + { 206, -3 }, /* (105) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 194, -1 }, /* (106) full_table_name ::= table_name */ + { 194, -3 }, /* (107) full_table_name ::= db_name NK_DOT table_name */ + { 195, -1 }, /* (108) column_def_list ::= column_def */ + { 195, -3 }, /* (109) column_def_list ::= column_def_list NK_COMMA column_def */ + { 211, -2 }, /* (110) column_def ::= column_name type_name */ + { 211, -4 }, /* (111) column_def ::= column_name type_name COMMENT NK_STRING */ + { 204, -1 }, /* (112) type_name ::= BOOL */ + { 204, -1 }, /* (113) type_name ::= TINYINT */ + { 204, -1 }, /* (114) type_name ::= SMALLINT */ + { 204, -1 }, /* (115) type_name ::= INT */ + { 204, -1 }, /* (116) type_name ::= INTEGER */ + { 204, -1 }, /* (117) type_name ::= BIGINT */ + { 204, -1 }, /* (118) type_name ::= FLOAT */ + { 204, -1 }, /* (119) type_name ::= DOUBLE */ + { 204, -4 }, /* (120) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 204, -1 }, /* (121) type_name ::= TIMESTAMP */ + { 204, -4 }, /* (122) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 204, -2 }, /* (123) type_name ::= TINYINT UNSIGNED */ + { 204, -2 }, /* (124) type_name ::= SMALLINT UNSIGNED */ + { 204, -2 }, /* (125) type_name ::= INT UNSIGNED */ + { 204, -2 }, /* (126) type_name ::= BIGINT UNSIGNED */ + { 204, -1 }, /* (127) type_name ::= JSON */ + { 204, -4 }, /* (128) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 204, -1 }, /* (129) type_name ::= MEDIUMBLOB */ + { 204, -1 }, /* (130) type_name ::= BLOB */ + { 204, -4 }, /* (131) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 204, -1 }, /* (132) type_name ::= DECIMAL */ + { 204, -4 }, /* (133) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 204, -6 }, /* (134) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 196, 0 }, /* (135) tags_def_opt ::= */ + { 196, -1 }, /* (136) tags_def_opt ::= tags_def */ + { 199, -4 }, /* (137) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 197, 0 }, /* (138) table_options ::= */ + { 197, -3 }, /* (139) table_options ::= table_options COMMENT NK_STRING */ + { 197, -3 }, /* (140) table_options ::= table_options KEEP integer_list */ + { 197, -3 }, /* (141) table_options ::= table_options TTL NK_INTEGER */ + { 197, -5 }, /* (142) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 197, -5 }, /* (143) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 197, -3 }, /* (144) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 197, -3 }, /* (145) table_options ::= table_options DELAY NK_INTEGER */ + { 202, -1 }, /* (146) alter_table_options ::= alter_table_option */ + { 202, -2 }, /* (147) alter_table_options ::= alter_table_options alter_table_option */ + { 213, -2 }, /* (148) alter_table_option ::= COMMENT NK_STRING */ + { 213, -2 }, /* (149) alter_table_option ::= KEEP integer_list */ + { 213, -2 }, /* (150) alter_table_option ::= TTL NK_INTEGER */ + { 209, -1 }, /* (151) col_name_list ::= col_name */ + { 209, -3 }, /* (152) col_name_list ::= col_name_list NK_COMMA col_name */ + { 214, -1 }, /* (153) col_name ::= column_name */ + { 179, -2 }, /* (154) cmd ::= SHOW DNODES */ + { 179, -2 }, /* (155) cmd ::= SHOW USERS */ + { 179, -2 }, /* (156) cmd ::= SHOW DATABASES */ + { 179, -4 }, /* (157) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 179, -4 }, /* (158) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 179, -3 }, /* (159) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 179, -2 }, /* (160) cmd ::= SHOW MNODES */ + { 179, -2 }, /* (161) cmd ::= SHOW MODULES */ + { 179, -2 }, /* (162) cmd ::= SHOW QNODES */ + { 179, -2 }, /* (163) cmd ::= SHOW FUNCTIONS */ + { 179, -5 }, /* (164) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 179, -2 }, /* (165) cmd ::= SHOW STREAMS */ + { 215, 0 }, /* (166) db_name_cond_opt ::= */ + { 215, -2 }, /* (167) db_name_cond_opt ::= db_name NK_DOT */ + { 216, 0 }, /* (168) like_pattern_opt ::= */ + { 216, -2 }, /* (169) like_pattern_opt ::= LIKE NK_STRING */ + { 217, -1 }, /* (170) table_name_cond ::= table_name */ + { 218, 0 }, /* (171) from_db_opt ::= */ + { 218, -2 }, /* (172) from_db_opt ::= FROM db_name */ + { 212, -1 }, /* (173) func_name_list ::= func_name */ + { 212, -3 }, /* (174) func_name_list ::= func_name_list NK_COMMA col_name */ + { 219, -1 }, /* (175) func_name ::= function_name */ + { 179, -8 }, /* (176) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 179, -10 }, /* (177) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 179, -6 }, /* (178) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 222, 0 }, /* (179) index_options ::= */ + { 222, -9 }, /* (180) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 222, -11 }, /* (181) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 223, -1 }, /* (182) func_list ::= func */ + { 223, -3 }, /* (183) func_list ::= func_list NK_COMMA func */ + { 226, -4 }, /* (184) func ::= function_name NK_LP expression_list NK_RP */ + { 179, -6 }, /* (185) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 179, -6 }, /* (186) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 179, -4 }, /* (187) cmd ::= DROP TOPIC exists_opt topic_name */ + { 179, -2 }, /* (188) cmd ::= DESC full_table_name */ + { 179, -2 }, /* (189) cmd ::= DESCRIBE full_table_name */ + { 179, -3 }, /* (190) cmd ::= RESET QUERY CACHE */ + { 179, -4 }, /* (191) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 230, 0 }, /* (192) analyze_opt ::= */ + { 230, -1 }, /* (193) analyze_opt ::= ANALYZE */ + { 231, 0 }, /* (194) explain_options ::= */ + { 231, -3 }, /* (195) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 231, -3 }, /* (196) explain_options ::= explain_options RATIO NK_FLOAT */ + { 179, -1 }, /* (197) cmd ::= query_expression */ + { 182, -1 }, /* (198) literal ::= NK_INTEGER */ + { 182, -1 }, /* (199) literal ::= NK_FLOAT */ + { 182, -1 }, /* (200) literal ::= NK_STRING */ + { 182, -1 }, /* (201) literal ::= NK_BOOL */ + { 182, -2 }, /* (202) literal ::= TIMESTAMP NK_STRING */ + { 182, -1 }, /* (203) literal ::= duration_literal */ + { 182, -1 }, /* (204) literal ::= NULL */ + { 224, -1 }, /* (205) duration_literal ::= NK_VARIABLE */ + { 232, -1 }, /* (206) signed ::= NK_INTEGER */ + { 232, -2 }, /* (207) signed ::= NK_PLUS NK_INTEGER */ + { 232, -2 }, /* (208) signed ::= NK_MINUS NK_INTEGER */ + { 232, -1 }, /* (209) signed ::= NK_FLOAT */ + { 232, -2 }, /* (210) signed ::= NK_PLUS NK_FLOAT */ + { 232, -2 }, /* (211) signed ::= NK_MINUS NK_FLOAT */ + { 233, -1 }, /* (212) signed_literal ::= signed */ + { 233, -1 }, /* (213) signed_literal ::= NK_STRING */ + { 233, -1 }, /* (214) signed_literal ::= NK_BOOL */ + { 233, -2 }, /* (215) signed_literal ::= TIMESTAMP NK_STRING */ + { 233, -1 }, /* (216) signed_literal ::= duration_literal */ + { 233, -1 }, /* (217) signed_literal ::= NULL */ + { 207, -1 }, /* (218) literal_list ::= signed_literal */ + { 207, -3 }, /* (219) literal_list ::= literal_list NK_COMMA signed_literal */ + { 188, -1 }, /* (220) db_name ::= NK_ID */ + { 210, -1 }, /* (221) table_name ::= NK_ID */ + { 203, -1 }, /* (222) column_name ::= NK_ID */ + { 220, -1 }, /* (223) function_name ::= NK_ID */ + { 234, -1 }, /* (224) table_alias ::= NK_ID */ + { 235, -1 }, /* (225) column_alias ::= NK_ID */ + { 184, -1 }, /* (226) user_name ::= NK_ID */ + { 221, -1 }, /* (227) index_name ::= NK_ID */ + { 228, -1 }, /* (228) topic_name ::= NK_ID */ + { 236, -1 }, /* (229) expression ::= literal */ + { 236, -1 }, /* (230) expression ::= pseudo_column */ + { 236, -1 }, /* (231) expression ::= column_reference */ + { 236, -4 }, /* (232) expression ::= function_name NK_LP expression_list NK_RP */ + { 236, -4 }, /* (233) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 236, -1 }, /* (234) expression ::= subquery */ + { 236, -3 }, /* (235) expression ::= NK_LP expression NK_RP */ + { 236, -2 }, /* (236) expression ::= NK_PLUS expression */ + { 236, -2 }, /* (237) expression ::= NK_MINUS expression */ + { 236, -3 }, /* (238) expression ::= expression NK_PLUS expression */ + { 236, -3 }, /* (239) expression ::= expression NK_MINUS expression */ + { 236, -3 }, /* (240) expression ::= expression NK_STAR expression */ + { 236, -3 }, /* (241) expression ::= expression NK_SLASH expression */ + { 236, -3 }, /* (242) expression ::= expression NK_REM expression */ + { 227, -1 }, /* (243) expression_list ::= expression */ + { 227, -3 }, /* (244) expression_list ::= expression_list NK_COMMA expression */ + { 238, -1 }, /* (245) column_reference ::= column_name */ + { 238, -3 }, /* (246) column_reference ::= table_name NK_DOT column_name */ + { 237, -2 }, /* (247) pseudo_column ::= NK_UNDERLINE ROWTS */ + { 237, -1 }, /* (248) pseudo_column ::= TBNAME */ + { 237, -2 }, /* (249) pseudo_column ::= NK_UNDERLINE QSTARTTS */ + { 237, -2 }, /* (250) pseudo_column ::= NK_UNDERLINE QENDTS */ + { 237, -2 }, /* (251) pseudo_column ::= NK_UNDERLINE WSTARTTS */ + { 237, -2 }, /* (252) pseudo_column ::= NK_UNDERLINE WENDTS */ + { 237, -2 }, /* (253) pseudo_column ::= NK_UNDERLINE WDURATION */ + { 240, -3 }, /* (254) predicate ::= expression compare_op expression */ + { 240, -5 }, /* (255) predicate ::= expression BETWEEN expression AND expression */ + { 240, -6 }, /* (256) predicate ::= expression NOT BETWEEN expression AND expression */ + { 240, -3 }, /* (257) predicate ::= expression IS NULL */ + { 240, -4 }, /* (258) predicate ::= expression IS NOT NULL */ + { 240, -3 }, /* (259) predicate ::= expression in_op in_predicate_value */ + { 241, -1 }, /* (260) compare_op ::= NK_LT */ + { 241, -1 }, /* (261) compare_op ::= NK_GT */ + { 241, -1 }, /* (262) compare_op ::= NK_LE */ + { 241, -1 }, /* (263) compare_op ::= NK_GE */ + { 241, -1 }, /* (264) compare_op ::= NK_NE */ + { 241, -1 }, /* (265) compare_op ::= NK_EQ */ + { 241, -1 }, /* (266) compare_op ::= LIKE */ + { 241, -2 }, /* (267) compare_op ::= NOT LIKE */ + { 241, -1 }, /* (268) compare_op ::= MATCH */ + { 241, -1 }, /* (269) compare_op ::= NMATCH */ + { 242, -1 }, /* (270) in_op ::= IN */ + { 242, -2 }, /* (271) in_op ::= NOT IN */ + { 243, -3 }, /* (272) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 244, -1 }, /* (273) boolean_value_expression ::= boolean_primary */ + { 244, -2 }, /* (274) boolean_value_expression ::= NOT boolean_primary */ + { 244, -3 }, /* (275) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 244, -3 }, /* (276) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 245, -1 }, /* (277) boolean_primary ::= predicate */ + { 245, -3 }, /* (278) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 246, -1 }, /* (279) common_expression ::= expression */ + { 246, -1 }, /* (280) common_expression ::= boolean_value_expression */ + { 247, -2 }, /* (281) from_clause ::= FROM table_reference_list */ + { 248, -1 }, /* (282) table_reference_list ::= table_reference */ + { 248, -3 }, /* (283) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 249, -1 }, /* (284) table_reference ::= table_primary */ + { 249, -1 }, /* (285) table_reference ::= joined_table */ + { 250, -2 }, /* (286) table_primary ::= table_name alias_opt */ + { 250, -4 }, /* (287) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 250, -2 }, /* (288) table_primary ::= subquery alias_opt */ + { 250, -1 }, /* (289) table_primary ::= parenthesized_joined_table */ + { 252, 0 }, /* (290) alias_opt ::= */ + { 252, -1 }, /* (291) alias_opt ::= table_alias */ + { 252, -2 }, /* (292) alias_opt ::= AS table_alias */ + { 253, -3 }, /* (293) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 253, -3 }, /* (294) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 251, -6 }, /* (295) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 254, 0 }, /* (296) join_type ::= */ + { 254, -1 }, /* (297) join_type ::= INNER */ + { 256, -9 }, /* (298) 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 */ + { 257, 0 }, /* (299) set_quantifier_opt ::= */ + { 257, -1 }, /* (300) set_quantifier_opt ::= DISTINCT */ + { 257, -1 }, /* (301) set_quantifier_opt ::= ALL */ + { 258, -1 }, /* (302) select_list ::= NK_STAR */ + { 258, -1 }, /* (303) select_list ::= select_sublist */ + { 264, -1 }, /* (304) select_sublist ::= select_item */ + { 264, -3 }, /* (305) select_sublist ::= select_sublist NK_COMMA select_item */ + { 265, -1 }, /* (306) select_item ::= common_expression */ + { 265, -2 }, /* (307) select_item ::= common_expression column_alias */ + { 265, -3 }, /* (308) select_item ::= common_expression AS column_alias */ + { 265, -3 }, /* (309) select_item ::= table_name NK_DOT NK_STAR */ + { 259, 0 }, /* (310) where_clause_opt ::= */ + { 259, -2 }, /* (311) where_clause_opt ::= WHERE search_condition */ + { 260, 0 }, /* (312) partition_by_clause_opt ::= */ + { 260, -3 }, /* (313) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 261, 0 }, /* (314) twindow_clause_opt ::= */ + { 261, -6 }, /* (315) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 261, -4 }, /* (316) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 261, -6 }, /* (317) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 261, -8 }, /* (318) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 225, 0 }, /* (319) sliding_opt ::= */ + { 225, -4 }, /* (320) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 266, 0 }, /* (321) fill_opt ::= */ + { 266, -4 }, /* (322) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 266, -6 }, /* (323) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 267, -1 }, /* (324) fill_mode ::= NONE */ + { 267, -1 }, /* (325) fill_mode ::= PREV */ + { 267, -1 }, /* (326) fill_mode ::= NULL */ + { 267, -1 }, /* (327) fill_mode ::= LINEAR */ + { 267, -1 }, /* (328) fill_mode ::= NEXT */ + { 262, 0 }, /* (329) group_by_clause_opt ::= */ + { 262, -3 }, /* (330) group_by_clause_opt ::= GROUP BY group_by_list */ + { 268, -1 }, /* (331) group_by_list ::= expression */ + { 268, -3 }, /* (332) group_by_list ::= group_by_list NK_COMMA expression */ + { 263, 0 }, /* (333) having_clause_opt ::= */ + { 263, -2 }, /* (334) having_clause_opt ::= HAVING search_condition */ + { 229, -4 }, /* (335) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 269, -1 }, /* (336) query_expression_body ::= query_primary */ + { 269, -4 }, /* (337) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 273, -1 }, /* (338) query_primary ::= query_specification */ + { 270, 0 }, /* (339) order_by_clause_opt ::= */ + { 270, -3 }, /* (340) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 271, 0 }, /* (341) slimit_clause_opt ::= */ + { 271, -2 }, /* (342) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 271, -4 }, /* (343) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 271, -4 }, /* (344) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 272, 0 }, /* (345) limit_clause_opt ::= */ + { 272, -2 }, /* (346) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 272, -4 }, /* (347) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 272, -4 }, /* (348) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 239, -3 }, /* (349) subquery ::= NK_LP query_expression NK_RP */ + { 255, -1 }, /* (350) search_condition ::= common_expression */ + { 274, -1 }, /* (351) sort_specification_list ::= sort_specification */ + { 274, -3 }, /* (352) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 275, -3 }, /* (353) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 276, 0 }, /* (354) ordering_specification_opt ::= */ + { 276, -1 }, /* (355) ordering_specification_opt ::= ASC */ + { 276, -1 }, /* (356) ordering_specification_opt ::= DESC */ + { 277, 0 }, /* (357) null_ordering_opt ::= */ + { 277, -2 }, /* (358) null_ordering_opt ::= NULLS FIRST */ + { 277, -2 }, /* (359) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2360,11 +2386,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,177,&yymsp[0].minor); + yy_destructor(yypParser,180,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,178,&yymsp[0].minor); + yy_destructor(yypParser,181,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -2378,20 +2404,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,177,&yymsp[-2].minor); +{ yy_destructor(yypParser,180,&yymsp[-2].minor); { } - yy_destructor(yypParser,179,&yymsp[0].minor); + yy_destructor(yypParser,182,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,180,&yymsp[0].minor); +{ yy_destructor(yypParser,183,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,178,&yymsp[-1].minor); +{ yy_destructor(yypParser,181,&yymsp[-1].minor); { } - yy_destructor(yypParser,180,&yymsp[0].minor); + yy_destructor(yypParser,183,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -2405,31 +2431,31 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,179,&yymsp[0].minor); + yy_destructor(yypParser,182,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy437, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy337, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy437, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy337, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy437); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy337); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy437, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy337, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy0); } break; case 30: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy437); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy337); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -2446,17 +2472,17 @@ static YYACTIONTYPE yy_reduce( case 36: /* dnode_endpoint ::= NK_STRING */ case 37: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==37); case 38: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==38); - case 214: /* db_name ::= NK_ID */ yytestcase(yyruleno==214); - case 215: /* table_name ::= NK_ID */ yytestcase(yyruleno==215); - case 216: /* column_name ::= NK_ID */ yytestcase(yyruleno==216); - case 217: /* function_name ::= NK_ID */ yytestcase(yyruleno==217); - case 218: /* table_alias ::= NK_ID */ yytestcase(yyruleno==218); - case 219: /* column_alias ::= NK_ID */ yytestcase(yyruleno==219); - case 220: /* user_name ::= NK_ID */ yytestcase(yyruleno==220); - case 221: /* index_name ::= NK_ID */ yytestcase(yyruleno==221); - case 222: /* topic_name ::= NK_ID */ yytestcase(yyruleno==222); -{ yylhsminor.yy437 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy437 = yylhsminor.yy437; + case 220: /* db_name ::= NK_ID */ yytestcase(yyruleno==220); + case 221: /* table_name ::= NK_ID */ yytestcase(yyruleno==221); + case 222: /* column_name ::= NK_ID */ yytestcase(yyruleno==222); + case 223: /* function_name ::= NK_ID */ yytestcase(yyruleno==223); + case 224: /* table_alias ::= NK_ID */ yytestcase(yyruleno==224); + case 225: /* column_alias ::= NK_ID */ yytestcase(yyruleno==225); + case 226: /* user_name ::= NK_ID */ yytestcase(yyruleno==226); + case 227: /* index_name ::= NK_ID */ yytestcase(yyruleno==227); + case 228: /* topic_name ::= NK_ID */ yytestcase(yyruleno==228); +{ yylhsminor.yy337 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy337 = yylhsminor.yy337; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -2471,967 +2497,985 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy493, &yymsp[-1].minor.yy437, yymsp[0].minor.yy364); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy265, &yymsp[-1].minor.yy337, yymsp[0].minor.yy24); } break; case 44: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy493, &yymsp[0].minor.yy437); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy265, &yymsp[0].minor.yy337); } break; case 45: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy437); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy337); } break; case 46: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy437, yymsp[0].minor.yy364); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy337, yymsp[0].minor.yy24); } break; case 47: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy493 = true; } +{ yymsp[-2].minor.yy265 = true; } break; case 48: /* not_exists_opt ::= */ case 50: /* exists_opt ::= */ yytestcase(yyruleno==50); - case 186: /* analyze_opt ::= */ yytestcase(yyruleno==186); - case 293: /* set_quantifier_opt ::= */ yytestcase(yyruleno==293); -{ yymsp[1].minor.yy493 = false; } + case 192: /* analyze_opt ::= */ yytestcase(yyruleno==192); + case 299: /* set_quantifier_opt ::= */ yytestcase(yyruleno==299); +{ yymsp[1].minor.yy265 = false; } break; case 49: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy493 = true; } +{ yymsp[-1].minor.yy265 = true; } break; case 51: /* db_options ::= */ -{ yymsp[1].minor.yy364 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy24 = createDefaultDatabaseOptions(pCxt); } break; case 52: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 53: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 54: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 55: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 56: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 57: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 58: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 59: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 60: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 60: /* db_options ::= db_options KEEP integer_list */ +{ yylhsminor.yy24 = setDatabaseKeepOption(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy504); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 61: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 62: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 63: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 64: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 65: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 66: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 67: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 68: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 69: /* db_options ::= db_options RETENTIONS NK_STRING */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-2].minor.yy364, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseOption(pCxt, yymsp[-2].minor.yy24, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 70: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy364 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy364 = setDatabaseOption(pCxt, yylhsminor.yy364, yymsp[0].minor.yy29.type, &yymsp[0].minor.yy29.val); } - yymsp[0].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy24 = setDatabaseAlterOption(pCxt, yylhsminor.yy24, &yymsp[0].minor.yy553); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 71: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy364 = setDatabaseOption(pCxt, yymsp[-1].minor.yy364, yymsp[0].minor.yy29.type, &yymsp[0].minor.yy29.val); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; +{ yylhsminor.yy24 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy24, &yymsp[0].minor.yy553); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; case 72: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy553.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } break; case 73: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy553.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } break; - case 74: /* alter_db_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_KEEP; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } + case 74: /* alter_db_option ::= KEEP integer_list */ +{ yymsp[-1].minor.yy553.type = DB_OPTION_KEEP; yymsp[-1].minor.yy553.pKeep = yymsp[0].minor.yy504; } break; case 75: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_WAL; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy553.type = DB_OPTION_WAL; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } break; case 76: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy553.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } break; case 77: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } - break; - case 78: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 80: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==80); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy493, yymsp[-5].minor.yy364, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy364); } - break; - case 79: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40); } - break; - case 81: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } - break; - case 82: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy493, yymsp[0].minor.yy364); } - break; - case 83: /* cmd ::= ALTER TABLE alter_table_clause */ - case 84: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==84); - case 191: /* cmd ::= query_expression */ yytestcase(yyruleno==191); -{ pCxt->pRootNode = yymsp[0].minor.yy364; } - break; - case 85: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy364 = createAlterTableOption(pCxt, yymsp[-1].minor.yy364, yymsp[0].minor.yy364); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; - break; - case 86: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy364 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy437, yymsp[0].minor.yy420); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 87: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy364 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy364, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy437); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; - break; - case 88: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy364 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy437, yymsp[0].minor.yy420); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 89: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy364 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy437, &yymsp[0].minor.yy437); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 90: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy364 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy437, yymsp[0].minor.yy420); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 91: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy364 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy364, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy437); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; - break; - case 92: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy364 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy437, yymsp[0].minor.yy420); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 93: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy364 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy364, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy437, &yymsp[0].minor.yy437); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; - break; - case 94: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy364 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy364, &yymsp[-2].minor.yy437, yymsp[0].minor.yy364); } - yymsp[-5].minor.yy364 = yylhsminor.yy364; - break; - case 95: /* multi_create_clause ::= create_subtable_clause */ - case 98: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==98); - case 105: /* column_def_list ::= column_def */ yytestcase(yyruleno==105); - case 148: /* col_name_list ::= col_name */ yytestcase(yyruleno==148); - case 170: /* func_name_list ::= func_name */ yytestcase(yyruleno==170); - case 179: /* func_list ::= func */ yytestcase(yyruleno==179); - case 212: /* literal_list ::= signed_literal */ yytestcase(yyruleno==212); - case 298: /* select_sublist ::= select_item */ yytestcase(yyruleno==298); - case 345: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==345); -{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy364); } - yymsp[0].minor.yy40 = yylhsminor.yy40; +{ yymsp[-1].minor.yy553.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } + break; + case 78: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy553.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } + break; + case 79: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy504 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; + break; + case 80: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ +{ yylhsminor.yy504 = addNodeToList(pCxt, yymsp[-2].minor.yy504, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; + break; + case 81: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 83: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==83); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy265, yymsp[-5].minor.yy24, yymsp[-3].minor.yy504, yymsp[-1].minor.yy504, yymsp[0].minor.yy24); } + break; + case 82: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy504); } + break; + case 84: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy504); } + break; + case 85: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy265, yymsp[0].minor.yy24); } + break; + case 86: /* cmd ::= ALTER TABLE alter_table_clause */ + case 87: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==87); + case 197: /* cmd ::= query_expression */ yytestcase(yyruleno==197); +{ pCxt->pRootNode = yymsp[0].minor.yy24; } + break; + case 88: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy24 = createAlterTableOption(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy24); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; + break; + case 89: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy24 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy337, yymsp[0].minor.yy212); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; + break; + case 90: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy24 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy24, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy337); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; + break; + case 91: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy24 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy337, yymsp[0].minor.yy212); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; + break; + case 92: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy24 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy337, &yymsp[0].minor.yy337); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; + break; + case 93: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy24 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy337, yymsp[0].minor.yy212); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; + break; + case 94: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy24 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy24, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy337); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; + break; + case 95: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy24 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy337, yymsp[0].minor.yy212); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; break; - case 96: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 99: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==99); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy364); } - yymsp[-1].minor.yy40 = yylhsminor.yy40; + case 96: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy24 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy24, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy337, &yymsp[0].minor.yy337); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; break; - case 97: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy364 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy493, yymsp[-7].minor.yy364, yymsp[-5].minor.yy364, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } - yymsp[-8].minor.yy364 = yylhsminor.yy364; + case 97: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ +{ yylhsminor.yy24 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy24, &yymsp[-2].minor.yy337, yymsp[0].minor.yy24); } + yymsp[-5].minor.yy24 = yylhsminor.yy24; break; - case 100: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy364 = createDropTableClause(pCxt, yymsp[-1].minor.yy493, yymsp[0].minor.yy364); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 98: /* multi_create_clause ::= create_subtable_clause */ + case 101: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==101); + case 108: /* column_def_list ::= column_def */ yytestcase(yyruleno==108); + case 151: /* col_name_list ::= col_name */ yytestcase(yyruleno==151); + case 173: /* func_name_list ::= func_name */ yytestcase(yyruleno==173); + case 182: /* func_list ::= func */ yytestcase(yyruleno==182); + case 218: /* literal_list ::= signed_literal */ yytestcase(yyruleno==218); + case 304: /* select_sublist ::= select_item */ yytestcase(yyruleno==304); + case 351: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==351); +{ yylhsminor.yy504 = createNodeList(pCxt, yymsp[0].minor.yy24); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; - case 101: /* specific_tags_opt ::= */ - case 132: /* tags_def_opt ::= */ yytestcase(yyruleno==132); - case 306: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==306); - case 323: /* group_by_clause_opt ::= */ yytestcase(yyruleno==323); - case 333: /* order_by_clause_opt ::= */ yytestcase(yyruleno==333); -{ yymsp[1].minor.yy40 = NULL; } + case 99: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 102: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==102); +{ yylhsminor.yy504 = addNodeToList(pCxt, yymsp[-1].minor.yy504, yymsp[0].minor.yy24); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 102: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } + case 100: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy24 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy265, yymsp[-7].minor.yy24, yymsp[-5].minor.yy24, yymsp[-4].minor.yy504, yymsp[-1].minor.yy504); } + yymsp[-8].minor.yy24 = yylhsminor.yy24; break; - case 103: /* full_table_name ::= table_name */ -{ yylhsminor.yy364 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy437, NULL); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 103: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy24 = createDropTableClause(pCxt, yymsp[-1].minor.yy265, yymsp[0].minor.yy24); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 104: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy364 = createRealTableNode(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy437, NULL); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 104: /* specific_tags_opt ::= */ + case 135: /* tags_def_opt ::= */ yytestcase(yyruleno==135); + case 312: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==312); + case 329: /* group_by_clause_opt ::= */ yytestcase(yyruleno==329); + case 339: /* order_by_clause_opt ::= */ yytestcase(yyruleno==339); +{ yymsp[1].minor.yy504 = NULL; } break; - case 106: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 149: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==149); - case 171: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==171); - case 180: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==180); - case 213: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==213); - case 299: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==299); - case 346: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==346); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy364); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 105: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy504 = yymsp[-1].minor.yy504; } break; - case 107: /* column_def ::= column_name type_name */ -{ yylhsminor.yy364 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy437, yymsp[0].minor.yy420, NULL); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 106: /* full_table_name ::= table_name */ +{ yylhsminor.yy24 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy337, NULL); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 108: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy364 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy437, yymsp[-2].minor.yy420, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 107: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy24 = createRealTableNode(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy337, NULL); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 109: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 109: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 152: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==152); + case 174: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==174); + case 183: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==183); + case 219: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==219); + case 305: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==305); + case 352: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==352); +{ yylhsminor.yy504 = addNodeToList(pCxt, yymsp[-2].minor.yy504, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 110: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 110: /* column_def ::= column_name type_name */ +{ yylhsminor.yy24 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy337, yymsp[0].minor.yy212, NULL); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 111: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 111: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy24 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy337, yymsp[-2].minor.yy212, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 112: /* type_name ::= INT */ - case 113: /* type_name ::= INTEGER */ yytestcase(yyruleno==113); -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_INT); } + case 112: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 114: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 113: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 115: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 114: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 116: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 115: /* type_name ::= INT */ + case 116: /* type_name ::= INTEGER */ yytestcase(yyruleno==116); +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 117: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy420 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 117: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 118: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 118: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 119: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy420 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 119: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 120: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy420 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 120: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy212 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 121: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy420 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 121: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 122: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy420 = createDataType(TSDB_DATA_TYPE_UINT); } + case 122: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy212 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 123: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy420 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 123: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy212 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 124: /* type_name ::= JSON */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_JSON); } + case 124: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy212 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 125: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy420 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 125: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy212 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 126: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 126: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy212 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 127: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 127: /* type_name ::= JSON */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 128: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy420 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 128: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy212 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 129: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy420 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 129: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 130: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy420 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 130: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 131: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy420 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 131: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy212 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 133: /* tags_def_opt ::= tags_def */ - case 297: /* select_list ::= select_sublist */ yytestcase(yyruleno==297); -{ yylhsminor.yy40 = yymsp[0].minor.yy40; } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 132: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy212 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 134: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } + case 133: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy212 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 135: /* table_options ::= */ -{ yymsp[1].minor.yy364 = createDefaultTableOptions(pCxt); } + case 134: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy212 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 136: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-2].minor.yy364, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 136: /* tags_def_opt ::= tags_def */ + case 303: /* select_list ::= select_sublist */ yytestcase(yyruleno==303); +{ yylhsminor.yy504 = yymsp[0].minor.yy504; } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; - case 137: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-2].minor.yy364, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 137: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy504 = yymsp[-1].minor.yy504; } break; - case 138: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-2].minor.yy364, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 138: /* table_options ::= */ +{ yymsp[1].minor.yy24 = createDefaultTableOptions(pCxt); } break; - case 139: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy364 = setTableSmaOption(pCxt, yymsp[-4].minor.yy364, yymsp[-1].minor.yy40); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; + case 139: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy24 = setTableOption(pCxt, yymsp[-2].minor.yy24, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 140: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy364 = setTableRollupOption(pCxt, yymsp[-4].minor.yy364, yymsp[-1].minor.yy40); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; + case 140: /* table_options ::= table_options KEEP integer_list */ +{ yylhsminor.yy24 = setTableKeepOption(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy504); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 141: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-2].minor.yy364, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 141: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy24 = setTableOption(pCxt, yymsp[-2].minor.yy24, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 142: /* table_options ::= table_options DELAY NK_INTEGER */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-2].minor.yy364, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 142: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy24 = setTableSmaOption(pCxt, yymsp[-4].minor.yy24, yymsp[-1].minor.yy504); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; break; - case 143: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy364 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy364 = setTableOption(pCxt, yylhsminor.yy364, yymsp[0].minor.yy29.type, &yymsp[0].minor.yy29.val); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 143: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy24 = setTableRollupOption(pCxt, yymsp[-4].minor.yy24, yymsp[-1].minor.yy504); } + yymsp[-4].minor.yy24 = yylhsminor.yy24; break; - case 144: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy364 = setTableOption(pCxt, yymsp[-1].minor.yy364, yymsp[0].minor.yy29.type, &yymsp[0].minor.yy29.val); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 144: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy24 = setTableOption(pCxt, yymsp[-2].minor.yy24, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 145: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy29.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } + case 145: /* table_options ::= table_options DELAY NK_INTEGER */ +{ yylhsminor.yy24 = setTableOption(pCxt, yymsp[-2].minor.yy24, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 146: /* alter_table_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } + case 146: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy24 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy24 = setTableAlterOption(pCxt, yylhsminor.yy24, &yymsp[0].minor.yy553); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 147: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy29.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy29.val = yymsp[0].minor.yy0; } + case 147: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy24 = setTableAlterOption(pCxt, yymsp[-1].minor.yy24, &yymsp[0].minor.yy553); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 150: /* col_name ::= column_name */ -{ yylhsminor.yy364 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy437); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 148: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy553.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } break; - case 151: /* cmd ::= SHOW DNODES */ + case 149: /* alter_table_option ::= KEEP integer_list */ +{ yymsp[-1].minor.yy553.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy553.pKeep = yymsp[0].minor.yy504; } + break; + case 150: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy553.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy553.val = yymsp[0].minor.yy0; } + break; + case 153: /* col_name ::= column_name */ +{ yylhsminor.yy24 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy337); } + yymsp[0].minor.yy24 = yylhsminor.yy24; + break; + case 154: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } break; - case 152: /* cmd ::= SHOW USERS */ + case 155: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); } break; - case 153: /* cmd ::= SHOW DATABASES */ + case 156: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; - case 154: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy364, yymsp[0].minor.yy364); } + case 157: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy24, yymsp[0].minor.yy24); } break; - case 155: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy364, yymsp[0].minor.yy364); } + case 158: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy24, yymsp[0].minor.yy24); } break; - case 156: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy364, NULL); } + case 159: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy24, NULL); } break; - case 157: /* cmd ::= SHOW MNODES */ + case 160: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } break; - case 158: /* cmd ::= SHOW MODULES */ + case 161: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); } break; - case 159: /* cmd ::= SHOW QNODES */ + case 162: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); } break; - case 160: /* cmd ::= SHOW FUNCTIONS */ + case 163: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; - case 161: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy364, yymsp[0].minor.yy364); } + case 164: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy24, yymsp[0].minor.yy24); } break; - case 162: /* cmd ::= SHOW STREAMS */ + case 165: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; - case 163: /* db_name_cond_opt ::= */ - case 168: /* from_db_opt ::= */ yytestcase(yyruleno==168); -{ yymsp[1].minor.yy364 = createDefaultDatabaseCondValue(pCxt); } + case 166: /* db_name_cond_opt ::= */ + case 171: /* from_db_opt ::= */ yytestcase(yyruleno==171); +{ yymsp[1].minor.yy24 = createDefaultDatabaseCondValue(pCxt); } break; - case 164: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy437); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 167: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy337); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 165: /* like_pattern_opt ::= */ - case 176: /* index_options ::= */ yytestcase(yyruleno==176); - case 304: /* where_clause_opt ::= */ yytestcase(yyruleno==304); - case 308: /* twindow_clause_opt ::= */ yytestcase(yyruleno==308); - case 313: /* sliding_opt ::= */ yytestcase(yyruleno==313); - case 315: /* fill_opt ::= */ yytestcase(yyruleno==315); - case 327: /* having_clause_opt ::= */ yytestcase(yyruleno==327); - case 335: /* slimit_clause_opt ::= */ yytestcase(yyruleno==335); - case 339: /* limit_clause_opt ::= */ yytestcase(yyruleno==339); -{ yymsp[1].minor.yy364 = NULL; } + case 168: /* like_pattern_opt ::= */ + case 179: /* index_options ::= */ yytestcase(yyruleno==179); + case 310: /* where_clause_opt ::= */ yytestcase(yyruleno==310); + case 314: /* twindow_clause_opt ::= */ yytestcase(yyruleno==314); + case 319: /* sliding_opt ::= */ yytestcase(yyruleno==319); + case 321: /* fill_opt ::= */ yytestcase(yyruleno==321); + case 333: /* having_clause_opt ::= */ yytestcase(yyruleno==333); + case 341: /* slimit_clause_opt ::= */ yytestcase(yyruleno==341); + case 345: /* limit_clause_opt ::= */ yytestcase(yyruleno==345); +{ yymsp[1].minor.yy24 = NULL; } break; - case 166: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 169: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 167: /* table_name_cond ::= table_name */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy437); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 170: /* table_name_cond ::= table_name */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy337); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 169: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy437); } + case 172: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy337); } break; - case 172: /* func_name ::= function_name */ -{ yylhsminor.yy364 = createFunctionNode(pCxt, &yymsp[0].minor.yy437, NULL); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 175: /* func_name ::= function_name */ +{ yylhsminor.yy24 = createFunctionNode(pCxt, &yymsp[0].minor.yy337, NULL); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 173: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy493, &yymsp[-3].minor.yy437, &yymsp[-1].minor.yy437, NULL, yymsp[0].minor.yy364); } + case 176: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy265, &yymsp[-3].minor.yy337, &yymsp[-1].minor.yy337, NULL, yymsp[0].minor.yy24); } break; - case 174: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy493, &yymsp[-5].minor.yy437, &yymsp[-3].minor.yy437, yymsp[-1].minor.yy40, NULL); } + case 177: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy265, &yymsp[-5].minor.yy337, &yymsp[-3].minor.yy337, yymsp[-1].minor.yy504, NULL); } break; - case 175: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy493, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy437); } + case 178: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy265, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy337); } break; - case 177: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy364 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), NULL, yymsp[0].minor.yy364); } + case 180: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy24 = createIndexOption(pCxt, yymsp[-6].minor.yy504, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), NULL, yymsp[0].minor.yy24); } break; - case 178: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy364 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy364), releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), yymsp[0].minor.yy364); } + case 181: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy24 = createIndexOption(pCxt, yymsp[-8].minor.yy504, releaseRawExprNode(pCxt, yymsp[-4].minor.yy24), releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), yymsp[0].minor.yy24); } break; - case 181: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy364 = createFunctionNode(pCxt, &yymsp[-3].minor.yy437, yymsp[-1].minor.yy40); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 184: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy24 = createFunctionNode(pCxt, &yymsp[-3].minor.yy337, yymsp[-1].minor.yy504); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 182: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy493, &yymsp[-2].minor.yy437, yymsp[0].minor.yy364, NULL); } + case 185: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy265, &yymsp[-2].minor.yy337, yymsp[0].minor.yy24, NULL); } break; - case 183: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy493, &yymsp[-2].minor.yy437, NULL, &yymsp[0].minor.yy437); } + case 186: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy265, &yymsp[-2].minor.yy337, NULL, &yymsp[0].minor.yy337); } break; - case 184: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy493, &yymsp[0].minor.yy437); } + case 187: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy265, &yymsp[0].minor.yy337); } break; - case 185: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy493, yymsp[-1].minor.yy364, yymsp[0].minor.yy364); } + case 188: /* cmd ::= DESC full_table_name */ + case 189: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==189); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy24); } break; - case 187: /* analyze_opt ::= ANALYZE */ - case 294: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==294); -{ yymsp[0].minor.yy493 = true; } + case 190: /* cmd ::= RESET QUERY CACHE */ +{ pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 188: /* explain_options ::= */ -{ yymsp[1].minor.yy364 = createDefaultExplainOptions(pCxt); } + case 191: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy265, yymsp[-1].minor.yy24, yymsp[0].minor.yy24); } break; - case 189: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy364 = setExplainVerbose(pCxt, yymsp[-2].minor.yy364, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 193: /* analyze_opt ::= ANALYZE */ + case 300: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==300); +{ yymsp[0].minor.yy265 = true; } break; - case 190: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy364 = setExplainRatio(pCxt, yymsp[-2].minor.yy364, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 194: /* explain_options ::= */ +{ yymsp[1].minor.yy24 = createDefaultExplainOptions(pCxt); } break; - case 192: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 195: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy24 = setExplainVerbose(pCxt, yymsp[-2].minor.yy24, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 193: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 196: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy24 = setExplainRatio(pCxt, yymsp[-2].minor.yy24, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 194: /* literal ::= NK_STRING */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 198: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 195: /* literal ::= NK_BOOL */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 199: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 196: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 200: /* literal ::= NK_STRING */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 197: /* literal ::= duration_literal */ - case 206: /* signed_literal ::= signed */ yytestcase(yyruleno==206); - case 223: /* expression ::= literal */ yytestcase(yyruleno==223); - case 224: /* expression ::= pseudo_column */ yytestcase(yyruleno==224); - case 225: /* expression ::= column_reference */ yytestcase(yyruleno==225); - case 228: /* expression ::= subquery */ yytestcase(yyruleno==228); - case 267: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==267); - case 271: /* boolean_primary ::= predicate */ yytestcase(yyruleno==271); - case 273: /* common_expression ::= expression */ yytestcase(yyruleno==273); - case 274: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==274); - case 276: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==276); - case 278: /* table_reference ::= table_primary */ yytestcase(yyruleno==278); - case 279: /* table_reference ::= joined_table */ yytestcase(yyruleno==279); - case 283: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==283); - case 330: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==330); - case 332: /* query_primary ::= query_specification */ yytestcase(yyruleno==332); -{ yylhsminor.yy364 = yymsp[0].minor.yy364; } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 201: /* literal ::= NK_BOOL */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 198: /* literal ::= NULL */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 202: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 199: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 203: /* literal ::= duration_literal */ + case 212: /* signed_literal ::= signed */ yytestcase(yyruleno==212); + case 229: /* expression ::= literal */ yytestcase(yyruleno==229); + case 230: /* expression ::= pseudo_column */ yytestcase(yyruleno==230); + case 231: /* expression ::= column_reference */ yytestcase(yyruleno==231); + case 234: /* expression ::= subquery */ yytestcase(yyruleno==234); + case 273: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==273); + case 277: /* boolean_primary ::= predicate */ yytestcase(yyruleno==277); + case 279: /* common_expression ::= expression */ yytestcase(yyruleno==279); + case 280: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==280); + case 282: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==282); + case 284: /* table_reference ::= table_primary */ yytestcase(yyruleno==284); + case 285: /* table_reference ::= joined_table */ yytestcase(yyruleno==285); + case 289: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==289); + case 336: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==336); + case 338: /* query_primary ::= query_specification */ yytestcase(yyruleno==338); +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 200: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 204: /* literal ::= NULL */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 201: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 205: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 202: /* signed ::= NK_MINUS NK_INTEGER */ + case 206: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy24 = yylhsminor.yy24; + break; + case 207: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 208: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 203: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 209: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 204: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 210: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 205: /* signed ::= NK_MINUS NK_FLOAT */ + case 211: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 207: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 213: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 208: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 214: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 209: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 215: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 210: /* signed_literal ::= duration_literal */ - case 344: /* search_condition ::= common_expression */ yytestcase(yyruleno==344); -{ yylhsminor.yy364 = releaseRawExprNode(pCxt, yymsp[0].minor.yy364); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 216: /* signed_literal ::= duration_literal */ + case 350: /* search_condition ::= common_expression */ yytestcase(yyruleno==350); +{ yylhsminor.yy24 = releaseRawExprNode(pCxt, yymsp[0].minor.yy24); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 211: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy364 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } + case 217: /* signed_literal ::= NULL */ +{ yymsp[0].minor.yy24 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 226: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy437, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy437, yymsp[-1].minor.yy40)); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 232: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy337, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy337, yymsp[-1].minor.yy504)); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 227: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy437, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy437, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 233: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy337, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy337, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 229: /* expression ::= NK_LP expression NK_RP */ - case 272: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==272); -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy364)); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 235: /* expression ::= NK_LP expression NK_RP */ + case 278: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==278); +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy24)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 230: /* expression ::= NK_PLUS expression */ + case 236: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy364)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy24)); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 231: /* expression ::= NK_MINUS expression */ + case 237: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy364), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy24), NULL)); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 232: /* expression ::= expression NK_PLUS expression */ + case 238: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 233: /* expression ::= expression NK_MINUS expression */ + case 239: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 234: /* expression ::= expression NK_STAR expression */ + case 240: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 235: /* expression ::= expression NK_SLASH expression */ + case 241: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 236: /* expression ::= expression NK_REM expression */ + case 242: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 237: /* expression_list ::= expression */ -{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy364)); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 243: /* expression_list ::= expression */ +{ yylhsminor.yy504 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy24)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; - case 238: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy364)); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 244: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy504 = addNodeToList(pCxt, yymsp[-2].minor.yy504, releaseRawExprNode(pCxt, yymsp[0].minor.yy24)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 239: /* column_reference ::= column_name */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy437, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy437)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 245: /* column_reference ::= column_name */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy337, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy337)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 240: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy437, createColumnNode(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy437)); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 246: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy337, createColumnNode(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy337)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 241: /* pseudo_column ::= NK_UNDERLINE ROWTS */ - case 243: /* pseudo_column ::= NK_UNDERLINE QSTARTTS */ yytestcase(yyruleno==243); - case 244: /* pseudo_column ::= NK_UNDERLINE QENDTS */ yytestcase(yyruleno==244); - case 245: /* pseudo_column ::= NK_UNDERLINE WSTARTTS */ yytestcase(yyruleno==245); - case 246: /* pseudo_column ::= NK_UNDERLINE WENDTS */ yytestcase(yyruleno==246); - case 247: /* pseudo_column ::= NK_UNDERLINE WDURATION */ yytestcase(yyruleno==247); + case 247: /* pseudo_column ::= NK_UNDERLINE ROWTS */ + case 249: /* pseudo_column ::= NK_UNDERLINE QSTARTTS */ yytestcase(yyruleno==249); + case 250: /* pseudo_column ::= NK_UNDERLINE QENDTS */ yytestcase(yyruleno==250); + case 251: /* pseudo_column ::= NK_UNDERLINE WSTARTTS */ yytestcase(yyruleno==251); + case 252: /* pseudo_column ::= NK_UNDERLINE WENDTS */ yytestcase(yyruleno==252); + case 253: /* pseudo_column ::= NK_UNDERLINE WDURATION */ yytestcase(yyruleno==253); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy364 = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + yylhsminor.yy24 = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 242: /* pseudo_column ::= TBNAME */ -{ yylhsminor.yy364 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + case 248: /* pseudo_column ::= TBNAME */ +{ yylhsminor.yy24 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 248: /* predicate ::= expression compare_op expression */ - case 253: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==253); + case 254: /* predicate ::= expression compare_op expression */ + case 259: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==259); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy328, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy36, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 249: /* predicate ::= expression BETWEEN expression AND expression */ + case 255: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy364), releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy24), releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-4].minor.yy364 = yylhsminor.yy364; + yymsp[-4].minor.yy24 = yylhsminor.yy24; break; - case 250: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 256: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[-5].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[-5].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-5].minor.yy364 = yylhsminor.yy364; + yymsp[-5].minor.yy24 = yylhsminor.yy24; break; - case 251: /* predicate ::= expression IS NULL */ + case 257: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), NULL)); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 252: /* predicate ::= expression IS NOT NULL */ + case 258: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy364), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy24), NULL)); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 254: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy328 = OP_TYPE_LOWER_THAN; } + case 260: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy36 = OP_TYPE_LOWER_THAN; } break; - case 255: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy328 = OP_TYPE_GREATER_THAN; } + case 261: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy36 = OP_TYPE_GREATER_THAN; } break; - case 256: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy328 = OP_TYPE_LOWER_EQUAL; } + case 262: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy36 = OP_TYPE_LOWER_EQUAL; } break; - case 257: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy328 = OP_TYPE_GREATER_EQUAL; } + case 263: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy36 = OP_TYPE_GREATER_EQUAL; } break; - case 258: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy328 = OP_TYPE_NOT_EQUAL; } + case 264: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy36 = OP_TYPE_NOT_EQUAL; } break; - case 259: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy328 = OP_TYPE_EQUAL; } + case 265: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy36 = OP_TYPE_EQUAL; } break; - case 260: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy328 = OP_TYPE_LIKE; } + case 266: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy36 = OP_TYPE_LIKE; } break; - case 261: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy328 = OP_TYPE_NOT_LIKE; } + case 267: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy36 = OP_TYPE_NOT_LIKE; } break; - case 262: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy328 = OP_TYPE_MATCH; } + case 268: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy36 = OP_TYPE_MATCH; } break; - case 263: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy328 = OP_TYPE_NMATCH; } + case 269: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy36 = OP_TYPE_NMATCH; } break; - case 264: /* in_op ::= IN */ -{ yymsp[0].minor.yy328 = OP_TYPE_IN; } + case 270: /* in_op ::= IN */ +{ yymsp[0].minor.yy36 = OP_TYPE_IN; } break; - case 265: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy328 = OP_TYPE_NOT_IN; } + case 271: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy36 = OP_TYPE_NOT_IN; } break; - case 266: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 272: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy504)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 268: /* boolean_value_expression ::= NOT boolean_primary */ + case 274: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy364), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy24), NULL)); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 269: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 275: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 270: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 276: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy364); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy24); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 275: /* from_clause ::= FROM table_reference_list */ - case 305: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==305); - case 328: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==328); -{ yymsp[-1].minor.yy364 = yymsp[0].minor.yy364; } + case 281: /* from_clause ::= FROM table_reference_list */ + case 311: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==311); + case 334: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==334); +{ yymsp[-1].minor.yy24 = yymsp[0].minor.yy24; } break; - case 277: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy364 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy364, yymsp[0].minor.yy364, NULL); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 283: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy24 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy24, yymsp[0].minor.yy24, NULL); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 280: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy364 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy437, &yymsp[0].minor.yy437); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 286: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy24 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy337, &yymsp[0].minor.yy337); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 281: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy364 = createRealTableNode(pCxt, &yymsp[-3].minor.yy437, &yymsp[-1].minor.yy437, &yymsp[0].minor.yy437); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 287: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy24 = createRealTableNode(pCxt, &yymsp[-3].minor.yy337, &yymsp[-1].minor.yy337, &yymsp[0].minor.yy337); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 282: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy364 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy364), &yymsp[0].minor.yy437); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 288: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy24 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy24), &yymsp[0].minor.yy337); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 284: /* alias_opt ::= */ -{ yymsp[1].minor.yy437 = nil_token; } + case 290: /* alias_opt ::= */ +{ yymsp[1].minor.yy337 = nil_token; } break; - case 285: /* alias_opt ::= table_alias */ -{ yylhsminor.yy437 = yymsp[0].minor.yy437; } - yymsp[0].minor.yy437 = yylhsminor.yy437; + case 291: /* alias_opt ::= table_alias */ +{ yylhsminor.yy337 = yymsp[0].minor.yy337; } + yymsp[0].minor.yy337 = yylhsminor.yy337; break; - case 286: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy437 = yymsp[0].minor.yy437; } + case 292: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy337 = yymsp[0].minor.yy337; } break; - case 287: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 288: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==288); -{ yymsp[-2].minor.yy364 = yymsp[-1].minor.yy364; } + case 293: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 294: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==294); +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 289: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy364 = createJoinTableNode(pCxt, yymsp[-4].minor.yy392, yymsp[-5].minor.yy364, yymsp[-2].minor.yy364, yymsp[0].minor.yy364); } - yymsp[-5].minor.yy364 = yylhsminor.yy364; + case 295: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy24 = createJoinTableNode(pCxt, yymsp[-4].minor.yy320, yymsp[-5].minor.yy24, yymsp[-2].minor.yy24, yymsp[0].minor.yy24); } + yymsp[-5].minor.yy24 = yylhsminor.yy24; break; - case 290: /* join_type ::= */ -{ yymsp[1].minor.yy392 = JOIN_TYPE_INNER; } + case 296: /* join_type ::= */ +{ yymsp[1].minor.yy320 = JOIN_TYPE_INNER; } break; - case 291: /* join_type ::= INNER */ -{ yymsp[0].minor.yy392 = JOIN_TYPE_INNER; } + case 297: /* join_type ::= INNER */ +{ yymsp[0].minor.yy320 = JOIN_TYPE_INNER; } break; - case 292: /* 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 298: /* 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 */ { - yymsp[-8].minor.yy364 = createSelectStmt(pCxt, yymsp[-7].minor.yy493, yymsp[-6].minor.yy40, yymsp[-5].minor.yy364); - yymsp[-8].minor.yy364 = addWhereClause(pCxt, yymsp[-8].minor.yy364, yymsp[-4].minor.yy364); - yymsp[-8].minor.yy364 = addPartitionByClause(pCxt, yymsp[-8].minor.yy364, yymsp[-3].minor.yy40); - yymsp[-8].minor.yy364 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy364, yymsp[-2].minor.yy364); - yymsp[-8].minor.yy364 = addGroupByClause(pCxt, yymsp[-8].minor.yy364, yymsp[-1].minor.yy40); - yymsp[-8].minor.yy364 = addHavingClause(pCxt, yymsp[-8].minor.yy364, yymsp[0].minor.yy364); + yymsp[-8].minor.yy24 = createSelectStmt(pCxt, yymsp[-7].minor.yy265, yymsp[-6].minor.yy504, yymsp[-5].minor.yy24); + yymsp[-8].minor.yy24 = addWhereClause(pCxt, yymsp[-8].minor.yy24, yymsp[-4].minor.yy24); + yymsp[-8].minor.yy24 = addPartitionByClause(pCxt, yymsp[-8].minor.yy24, yymsp[-3].minor.yy504); + yymsp[-8].minor.yy24 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy24, yymsp[-2].minor.yy24); + yymsp[-8].minor.yy24 = addGroupByClause(pCxt, yymsp[-8].minor.yy24, yymsp[-1].minor.yy504); + yymsp[-8].minor.yy24 = addHavingClause(pCxt, yymsp[-8].minor.yy24, yymsp[0].minor.yy24); } break; - case 295: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy493 = false; } + case 301: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy265 = false; } break; - case 296: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy40 = NULL; } + case 302: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy504 = NULL; } break; - case 300: /* select_item ::= common_expression */ + case 306: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy364); - yylhsminor.yy364 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy364), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy24); + yylhsminor.yy24 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy24), &t); } - yymsp[0].minor.yy364 = yylhsminor.yy364; + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 301: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy364 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy364), &yymsp[0].minor.yy437); } - yymsp[-1].minor.yy364 = yylhsminor.yy364; + case 307: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy24 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy24), &yymsp[0].minor.yy337); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 302: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy364 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), &yymsp[0].minor.yy437); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 308: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy24 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), &yymsp[0].minor.yy337); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 303: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy364 = createColumnNode(pCxt, &yymsp[-2].minor.yy437, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 309: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy24 = createColumnNode(pCxt, &yymsp[-2].minor.yy337, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 307: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 324: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==324); - case 334: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==334); -{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } + case 313: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 330: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==330); + case 340: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==340); +{ yymsp[-2].minor.yy504 = yymsp[0].minor.yy504; } break; - case 309: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy364 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy364), releaseRawExprNode(pCxt, yymsp[-1].minor.yy364)); } + case 315: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy24 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy24), releaseRawExprNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 310: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy364 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy364)); } + case 316: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy24 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 311: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy364 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy364), NULL, yymsp[-1].minor.yy364, yymsp[0].minor.yy364); } + case 317: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy24 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy24), NULL, yymsp[-1].minor.yy24, yymsp[0].minor.yy24); } break; - case 312: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy364 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy364), releaseRawExprNode(pCxt, yymsp[-3].minor.yy364), yymsp[-1].minor.yy364, yymsp[0].minor.yy364); } + case 318: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy24 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy24), releaseRawExprNode(pCxt, yymsp[-3].minor.yy24), yymsp[-1].minor.yy24, yymsp[0].minor.yy24); } break; - case 314: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy364 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy364); } + case 320: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy24 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy24); } break; - case 316: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy364 = createFillNode(pCxt, yymsp[-1].minor.yy478, NULL); } + case 322: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy24 = createFillNode(pCxt, yymsp[-1].minor.yy550, NULL); } break; - case 317: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy364 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + case 323: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy24 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy504)); } break; - case 318: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy478 = FILL_MODE_NONE; } + case 324: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy550 = FILL_MODE_NONE; } break; - case 319: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy478 = FILL_MODE_PREV; } + case 325: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy550 = FILL_MODE_PREV; } break; - case 320: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy478 = FILL_MODE_NULL; } + case 326: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy550 = FILL_MODE_NULL; } break; - case 321: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy478 = FILL_MODE_LINEAR; } + case 327: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy550 = FILL_MODE_LINEAR; } break; - case 322: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy478 = FILL_MODE_NEXT; } + case 328: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy550 = FILL_MODE_NEXT; } break; - case 325: /* group_by_list ::= expression */ -{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 331: /* group_by_list ::= expression */ +{ yylhsminor.yy504 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; - case 326: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy364))); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 332: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy504 = addNodeToList(pCxt, yymsp[-2].minor.yy504, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy24))); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 329: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 335: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy364 = addOrderByClause(pCxt, yymsp[-3].minor.yy364, yymsp[-2].minor.yy40); - yylhsminor.yy364 = addSlimitClause(pCxt, yylhsminor.yy364, yymsp[-1].minor.yy364); - yylhsminor.yy364 = addLimitClause(pCxt, yylhsminor.yy364, yymsp[0].minor.yy364); + yylhsminor.yy24 = addOrderByClause(pCxt, yymsp[-3].minor.yy24, yymsp[-2].minor.yy504); + yylhsminor.yy24 = addSlimitClause(pCxt, yylhsminor.yy24, yymsp[-1].minor.yy24); + yylhsminor.yy24 = addLimitClause(pCxt, yylhsminor.yy24, yymsp[0].minor.yy24); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 331: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy364 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy364, yymsp[0].minor.yy364); } - yymsp[-3].minor.yy364 = yylhsminor.yy364; + case 337: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy24 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy24, yymsp[0].minor.yy24); } + yymsp[-3].minor.yy24 = yylhsminor.yy24; break; - case 336: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 340: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==340); -{ yymsp[-1].minor.yy364 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 342: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 346: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==346); +{ yymsp[-1].minor.yy24 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 337: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 341: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==341); -{ yymsp[-3].minor.yy364 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 343: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 347: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==347); +{ yymsp[-3].minor.yy24 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 338: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 342: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==342); -{ yymsp[-3].minor.yy364 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 344: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 348: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==348); +{ yymsp[-3].minor.yy24 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 343: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy364 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy364); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 349: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy24 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy24); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 347: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy364 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy364), yymsp[-1].minor.yy210, yymsp[0].minor.yy177); } - yymsp[-2].minor.yy364 = yylhsminor.yy364; + case 353: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy24 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy24), yymsp[-1].minor.yy346, yymsp[0].minor.yy45); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 348: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy210 = ORDER_ASC; } + case 354: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy346 = ORDER_ASC; } break; - case 349: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy210 = ORDER_ASC; } + case 355: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy346 = ORDER_ASC; } break; - case 350: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy210 = ORDER_DESC; } + case 356: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy346 = ORDER_DESC; } break; - case 351: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy177 = NULL_ORDER_DEFAULT; } + case 357: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy45 = NULL_ORDER_DEFAULT; } break; - case 352: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy177 = NULL_ORDER_FIRST; } + case 358: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy45 = NULL_ORDER_FIRST; } break; - case 353: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy177 = NULL_ORDER_LAST; } + case 359: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy45 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 7f6d8826e6..f57f476d51 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -288,7 +288,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect // set the output if (TSDB_CODE_SUCCESS == code) { pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); - if (NULL == pJoin->pOnConditions) { + if (NULL == pJoin->node.pTargets) { code = TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 9ef1c01cd1..11baeff04a 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -719,6 +719,14 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc if (NULL == pScan->pScanCols) { code = TSDB_CODE_OUT_OF_MEMORY; } + + if (TSDB_CODE_SUCCESS == code) { + code = sortScanCols(pScan->pScanCols); + } + + if (TSDB_CODE_SUCCESS == code) { + code = sortScanCols(pScan->pScanCols); + } if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlots(pCxt, pScan->pScanCols, pScan->node.pOutputDataBlockDesc); } diff --git a/source/libs/qcom/CMakeLists.txt b/source/libs/qcom/CMakeLists.txt index a9bf0f5594..d50047e592 100644 --- a/source/libs/qcom/CMakeLists.txt +++ b/source/libs/qcom/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( qcom - PRIVATE os util transport + PRIVATE os util transport nodes ) if(${BUILD_TEST}) diff --git a/source/libs/qcom/inc/queryInt.h b/source/libs/qcom/inc/queryInt.h index 75c1e134cd..f120bf26ce 100644 --- a/source/libs/qcom/inc/queryInt.h +++ b/source/libs/qcom/inc/queryInt.h @@ -21,7 +21,6 @@ extern "C" { #endif - #ifdef __cplusplus } #endif diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index 834a722bd8..3e04e7b30a 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -36,8 +36,6 @@ extern "C" { #define FILTER_DUMMY_EMPTY_OPTR 127 -#define MAX_NUM_STR_SIZE 40 - #define FILTER_RM_UNIT_MIN_ROWS 100 enum { diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f22f9a5c3c..33be65832c 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -720,7 +720,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -729,7 +729,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pLeft->numOfRows == 1) { double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0); - if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pLeftCol->nullbitmap, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { @@ -739,7 +739,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -749,17 +749,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pRight->numOfRows == 1) { double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0); - if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pRightCol->nullbitmap, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) { - if (colDataIsNull_f(pRightCol->nullbitmap, i)) { + if (colDataIsNull_f(pLeftCol->nullbitmap, i)) { colDataAppend(pOutputCol, i, NULL, true); continue; } - double lx = getVectorDoubleValueFnLeft(pRightCol->pData, i); - if (compareDoubleVal(&zero, &lx)) { + double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); + if (isnan(lx) || isinf(lx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } diff --git a/source/libs/scheduler/CMakeLists.txt b/source/libs/scheduler/CMakeLists.txt index a4a299317c..1a62c7d89d 100644 --- a/source/libs/scheduler/CMakeLists.txt +++ b/source/libs/scheduler/CMakeLists.txt @@ -9,7 +9,7 @@ target_include_directories( target_link_libraries( scheduler - PUBLIC os util nodes planner qcom common catalog transport + PUBLIC os util nodes planner qcom common catalog transport command ) if(${BUILD_TEST}) diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 518da6e2b8..22bd039219 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -142,10 +142,10 @@ typedef struct SSchTask { } SSchTask; typedef struct SSchJobAttr { - bool needFetch; - bool syncSchedule; - bool queryJob; - bool needFlowCtrl; + EExplainMode explainMode; + bool syncSchedule; + bool queryJob; + bool needFlowCtrl; } SSchJobAttr; typedef struct SSchJob { diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 5af13d97ca..9c5019aedc 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -19,6 +19,7 @@ #include "tmsg.h" #include "tref.h" #include "trpc.h" +#include "command.h" SSchedulerMgmt schMgmt = {0}; @@ -75,10 +76,10 @@ void schFreeRpcCtx(SRpcCtx *pCtx) { SRpcCtxVal *ctxVal = (SRpcCtxVal *)pIter; (*ctxVal->freeFunc)(ctxVal->val); - + pIter = taosHashIterate(pCtx->args, pIter); } - + taosHashCleanup(pCtx->args); if (pCtx->brokenVal.freeFunc) { @@ -86,7 +87,7 @@ void schFreeRpcCtx(SRpcCtx *pCtx) { } } -void schFreeTask(SSchTask* pTask) { +void schFreeTask(SSchTask *pTask) { if (pTask->candidateAddrs) { taosArrayDestroy(pTask->candidateAddrs); } @@ -125,41 +126,47 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m case TDMT_SCH_LINK_BROKEN: return TSDB_CODE_SUCCESS; case TDMT_VND_QUERY_RSP: // query_rsp may be processed later than ready_rsp - if (lastMsgType != reqMsgType && -1 != lastMsgType && TDMT_VND_FETCH != lastMsgType) { - SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); + if (lastMsgType != reqMsgType && -1 != lastMsgType && TDMT_VND_FETCH != lastMsgType) { + SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), + TMSG_INFO(msgType)); } - + if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_TASK_DLOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); + SCH_TASK_DLOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), + TMSG_INFO(msgType)); } - + SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; case TDMT_VND_RES_READY_RSP: reqMsgType = TDMT_VND_QUERY; if (lastMsgType != reqMsgType && -1 != lastMsgType) { - SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", (lastMsgType > 0 ? TMSG_INFO(lastMsgType) : "null"), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", + (lastMsgType > 0 ? TMSG_INFO(lastMsgType) : "null"), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; case TDMT_VND_FETCH_RSP: - if (lastMsgType != reqMsgType && -1 != lastMsgType) { - SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); + if (lastMsgType != reqMsgType && -1 != lastMsgType) { + SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; case TDMT_VND_CREATE_TABLE_RSP: @@ -171,12 +178,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m } if (lastMsgType != reqMsgType) { - SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } @@ -357,7 +366,7 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, void *handle) { SSchNodeInfo nodeInfo = {.addr = *addr, .handle = handle}; - + if (NULL == taosArrayPush(pTask->execNodes, &nodeInfo)) { SCH_TASK_ELOG("taosArrayPush nodeInfo to execNodes list failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -587,7 +596,7 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != code) { if (HASH_NODE_EXIST(code)) { *moved = true; - + SCH_TASK_WLOG("task already in failTask list, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } @@ -612,7 +621,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != code) { if (HASH_NODE_EXIST(code)) { *moved = true; - + SCH_TASK_ELOG("task already in execTask list, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } @@ -631,7 +640,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) { int8_t status = 0; ++pTask->tryTimes; - + if (schJobNeedToStop(pJob, &status)) { *needRetry = false; SCH_TASK_DLOG("task no more retry cause of job status, job status:%s", jobTaskStatusStr(status)); @@ -643,7 +652,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo SCH_TASK_DLOG("task no more retry since reach max try times, tryTimes:%d", pTask->tryTimes); return TSDB_CODE_SUCCESS; } - + if (!NEED_SCHEDULER_RETRY_ERROR(errCode)) { *needRetry = false; SCH_TASK_DLOG("task no more retry cause of errCode, errCode:%x - %s", errCode, tstrerror(errCode)); @@ -654,7 +663,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo if (SCH_IS_DATA_SRC_TASK(pTask)) { if (pTask->tryTimes >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) { *needRetry = false; - SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes, SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)); + SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes, + SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)); return TSDB_CODE_SUCCESS; } } else { @@ -662,14 +672,15 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo if ((pTask->candidateIdx + 1) >= candidateNum) { *needRetry = false; - SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d", pTask->candidateIdx, candidateNum); + SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d", + pTask->candidateIdx, candidateNum); return TSDB_CODE_SUCCESS; } } *needRetry = true; SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->tryTimes, errCode, tstrerror(errCode)); - + return TSDB_CODE_SUCCESS; } @@ -706,9 +717,8 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) { memcpy(&hb->trans, trans, sizeof(*trans)); SCH_UNLOCK(SCH_WRITE, &hb->lock); - qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p", - schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->transInst, - trans->transHandle); + qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p", schMgmt.sId, + epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->transInst, trans->transHandle); return TSDB_CODE_SUCCESS; } @@ -730,15 +740,15 @@ void schUpdateJobErrCode(SSchJob *pJob, int32_t errCode) { if (NEED_CLIENT_HANDLE_ERROR(origCode)) { return; } - + if (NEED_CLIENT_HANDLE_ERROR(errCode)) { atomic_store_32(&pJob->errCode, errCode); goto _return; } return; - -_return: + +_return: SCH_JOB_DLOG("job errCode updated to %x - %s", errCode, tstrerror(errCode)); } @@ -825,7 +835,7 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) } SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_FAILED); - + if (SCH_IS_WAIT_ALL_JOB(pJob)) { SCH_LOCK(SCH_WRITE, &pTask->level->lock); pTask->level->taskFailed++; @@ -833,9 +843,9 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) SCH_UNLOCK(SCH_WRITE, &pTask->level->lock); schUpdateJobErrCode(pJob, errCode); - + if (taskDone < pTask->level->taskNum) { - SCH_TASK_DLOG("need to wait other tasks, doneNum:%d, allNum:%d", taskDone, pTask->level->taskNum); + SCH_TASK_DLOG("need to wait other tasks, doneNum:%d, allNum:%d", taskDone, pTask->level->taskNum); SCH_RET(errCode); } } @@ -867,7 +877,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { int32_t parentNum = pTask->parents ? (int32_t)taosArrayGetSize(pTask->parents) : 0; if (parentNum == 0) { - int32_t taskDone = 0; + int32_t taskDone = 0; if (SCH_IS_WAIT_ALL_JOB(pJob)) { SCH_LOCK(SCH_WRITE, &pTask->level->lock); pTask->level->taskSucceed++; @@ -965,7 +975,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch int8_t status = 0; if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode); + SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), + rspCode); SCH_RET(atomic_load_32(&pJob->errCode)); } @@ -985,11 +996,11 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch SCH_ERR_JRET(rsp->code); } } - + taosArrayDestroy(batchRsp.rspList); } - } - + } + SCH_ERR_JRET(rspCode); SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); break; @@ -1011,21 +1022,21 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch break; } case TDMT_VND_QUERY_RSP: { - SQueryTableRsp rsp = {0}; - if (msg) { - tDeserializeSQueryTableRsp(msg, msgSize, &rsp); - SCH_ERR_JRET(rsp.code); - } - - SCH_ERR_JRET(rspCode); - - if (NULL == msg) { - SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); - } - - //SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY)); - - break; + SQueryTableRsp rsp = {0}; + if (msg) { + tDeserializeSQueryTableRsp(msg, msgSize, &rsp); + SCH_ERR_JRET(rsp.code); + } + + SCH_ERR_JRET(rspCode); + + if (NULL == msg) { + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + // SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY)); + + break; } case TDMT_VND_RES_READY_RSP: { SResReadyRsp *rsp = (SResReadyRsp *)msg; @@ -1088,14 +1099,14 @@ _return: } int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { - int32_t code = 0; + int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; - SSchTask *pTask = NULL; + SSchTask *pTask = NULL; SSchJob *pJob = schAcquireJob(pParam->refId); if (NULL == pJob) { qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "taosAcquireRef job failed, may be dropped, refId:%" PRIx64, - pParam->queryId, pParam->taskId, pParam->refId); + pParam->queryId, pParam->taskId, pParam->refId); SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED); } @@ -1114,7 +1125,7 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in pTask = *task; SCH_TASK_DLOG("rsp msg received, type:%s, handle:%p, code:%s", TMSG_INFO(msgType), pMsg->handle, tstrerror(rspCode)); - SCH_SET_TASK_HANDLE(pTask, pMsg->handle); + SCH_SET_TASK_HANDLE(pTask, pMsg->handle); SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode)); _return: @@ -1173,7 +1184,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { SCH_ERR_RET(schUpdateHbConnection(&rsp.epId, &trans)); int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus); - qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn, rsp.epId.ep.port); + qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn, + rsp.epId.ep.port); for (int32_t i = 0; i < taskNum; ++i) { STaskStatus *taskStatus = taosArrayGet(rsp.taskStatus, i); @@ -1187,8 +1199,9 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { } // TODO - - SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, jobTaskStatusStr(taskStatus->status)); + + SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, + jobTaskStatusStr(taskStatus->status)); schReleaseJob(taskStatus->refId); } @@ -1208,7 +1221,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c if (head->isHbParam) { SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param; - SSchTrans trans = {.transInst = hbParam->transport, .transHandle = NULL}; + SSchTrans trans = {.transInst = hbParam->transport, .transHandle = NULL}; SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans)); SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId)); @@ -1219,7 +1232,6 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c return TSDB_CODE_SUCCESS; } - int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { switch (msgType) { case TDMT_VND_CREATE_TABLE: @@ -1258,8 +1270,8 @@ void schFreeRpcCtxVal(const void *arg) { if (NULL == arg) { return; } - - SMsgSendInfo* pMsgSendInfo = (SMsgSendInfo *)arg; + + SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg; taosMemoryFreeClear(pMsgSendInfo->param); taosMemoryFreeClear(pMsgSendInfo); } @@ -1301,11 +1313,10 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { return TSDB_CODE_SUCCESS; } - int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb) { - int32_t code = 0; - SMsgSendInfo* pMsgSendInfo = NULL; - + int32_t code = 0; + SMsgSendInfo *pMsgSendInfo = NULL; + pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); @@ -1318,17 +1329,17 @@ int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal * SCH_ERR_JRET(schMakeTaskCallbackParam(pJob, pTask, &pMsgSendInfo->param)); } - int32_t msgType = TDMT_SCH_LINK_BROKEN; + int32_t msgType = TDMT_SCH_LINK_BROKEN; __async_send_cb_fn_t fp = NULL; SCH_ERR_JRET(schGetCallbackFp(msgType, &fp)); - + pMsgSendInfo->fp = fp; brokenVal->msgType = msgType; brokenVal->val = pMsgSendInfo; brokenVal->clone = schCloneSMsgSendInfo; brokenVal->freeFunc = schFreeRpcCtxVal; - + return TSDB_CODE_SUCCESS; _return: @@ -1340,16 +1351,16 @@ _return: } int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { - int32_t code = 0; + int32_t code = 0; SSchTaskCallbackParam *param = NULL; - SMsgSendInfo* pMsgSendInfo = NULL; + SMsgSendInfo *pMsgSendInfo = NULL; pCtx->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); if (NULL == pCtx->args) { SCH_TASK_ELOG("taosHashInit %d RpcCtx failed", 1); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); @@ -1362,7 +1373,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - int32_t msgType = TDMT_VND_RES_READY_RSP; + int32_t msgType = TDMT_VND_RES_READY_RSP; __async_send_cb_fn_t fp = NULL; SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_RES_READY, &fp)); @@ -1370,7 +1381,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { param->refId = pJob->refId; param->taskId = SCH_TASK_ID(pTask); param->transport = pJob->transport; - + pMsgSendInfo->param = param; pMsgSendInfo->fp = fp; @@ -1394,11 +1405,11 @@ _return: } int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { - int32_t code = 0; + int32_t code = 0; SSchHbCallbackParam *param = NULL; - SMsgSendInfo* pMsgSendInfo = NULL; - SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); - SQueryNodeEpId epId = {0}; + SMsgSendInfo *pMsgSendInfo = NULL; + SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); + SQueryNodeEpId epId = {0}; epId.nodeId = addr->nodeId; memcpy(&epId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp)); @@ -1408,7 +1419,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_TASK_ELOG("taosHashInit %d RpcCtx failed", 1); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); @@ -1421,13 +1432,13 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP; + int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP; __async_send_cb_fn_t fp = NULL; SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp)); param->nodeEpId = epId; param->transport = pJob->transport; - + pMsgSendInfo->param = param; pMsgSendInfo->fp = fp; @@ -1450,19 +1461,18 @@ _return: SCH_RET(code); } - int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId, bool *exist) { - int32_t code = 0; + int32_t code = 0; SSchHbTrans hb = {0}; hb.trans.transInst = pJob->transport; - + SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &hb.rpcCtx)); code = taosHashPut(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId), &hb, sizeof(SSchHbTrans)); if (code) { schFreeRpcCtx(&hb.rpcCtx); - + if (HASH_NODE_EXIST(code)) { *exist = true; return TSDB_CODE_SUCCESS; @@ -1475,8 +1485,6 @@ int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId * return TSDB_CODE_SUCCESS; } - - int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHeader **pDst) { if (pSrc->isHbParam) { SSchHbCallbackParam *dst = taosMemoryMalloc(sizeof(SSchHbCallbackParam)); @@ -1496,16 +1504,16 @@ int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHe qError("malloc SSchTaskCallbackParam failed"); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + memcpy(dst, pSrc, sizeof(*dst)); *pDst = (SSchCallbackParamHeader *)dst; - + return TSDB_CODE_SUCCESS; } int32_t schCloneSMsgSendInfo(void *src, void **dst) { SMsgSendInfo *pSrc = src; - int32_t code = 0; + int32_t code = 0; SMsgSendInfo *pDst = taosMemoryMalloc(sizeof(*pSrc)); if (NULL == pDst) { qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc)); @@ -1520,7 +1528,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { *dst = pDst; return TSDB_CODE_SUCCESS; - + _return: taosMemoryFreeClear(pDst); @@ -1531,7 +1539,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { int32_t code = 0; memcpy(&pDst->brokenVal, &pSrc->brokenVal, sizeof(pSrc->brokenVal)); pDst->brokenVal.val = NULL; - + SCH_ERR_RET(schCloneSMsgSendInfo(pSrc->brokenVal.val, &pDst->brokenVal.val)); pDst->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); @@ -1541,16 +1549,16 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { } SRpcCtxVal dst = {0}; - void *pIter = taosHashIterate(pSrc->args, NULL); + void *pIter = taosHashIterate(pSrc->args, NULL); while (pIter) { SRpcCtxVal *pVal = (SRpcCtxVal *)pIter; - int32_t *msgType = taosHashGetKey(pIter, NULL); + int32_t *msgType = taosHashGetKey(pIter, NULL); dst = *pVal; dst.val = NULL; - + SCH_ERR_JRET(schCloneSMsgSendInfo(pVal->val, &dst.val)); - + if (taosHashPut(pDst->args, msgType, sizeof(*msgType), &dst, sizeof(dst))) { qError("taosHashPut msg %d to rpcCtx failed", *msgType); (*dst.freeFunc)(dst.val); @@ -1568,8 +1576,8 @@ _return: SCH_RET(code); } - -int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* epSet, int32_t msgType, void *msg, uint32_t msgSize, bool persistHandle, SRpcCtx *ctx) { +int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet *epSet, int32_t msgType, void *msg, + uint32_t msgSize, bool persistHandle, SRpcCtx *ctx) { int32_t code = 0; SSchTrans *trans = (SSchTrans *)transport; @@ -1601,11 +1609,11 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* pMsgSendInfo->msgType = msgType; pMsgSendInfo->fp = fp; - qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "instance:%p, handle:%p", - TMSG_INFO(msgType), ntohl(((SMsgHead *)msg)->vgId), epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, - pJob->refId, trans->transInst, trans->transHandle); - - int64_t transporterId = 0; + qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "instance:%p, handle:%p", TMSG_INFO(msgType), + ntohl(((SMsgHead *)msg)->vgId), epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, pJob->refId, + trans->transInst, trans->transHandle); + + int64_t transporterId = 0; code = asyncSendMsgToServerExt(trans->transInst, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx); if (code) { SCH_ERR_JRET(code); @@ -1623,18 +1631,19 @@ _return: int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { SSchedulerHbReq req = {0}; - int32_t code = 0; - SRpcCtx rpcCtx = {0}; - SSchTrans trans = {0}; - int32_t msgType = TDMT_VND_QUERY_HEARTBEAT; + int32_t code = 0; + SRpcCtx rpcCtx = {0}; + SSchTrans trans = {0}; + int32_t msgType = TDMT_VND_QUERY_HEARTBEAT; - req.header.vgId = htonl(nodeEpId->nodeId); + req.header.vgId = nodeEpId->nodeId; req.sId = schMgmt.sId; memcpy(&req.epId, nodeEpId, sizeof(SQueryNodeEpId)); SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, nodeEpId, sizeof(SQueryNodeEpId)); if (NULL == hb) { - qError("taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d", nodeEpId->nodeId, nodeEpId->ep.fqdn, nodeEpId->ep.port); + qError("taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d", nodeEpId->nodeId, nodeEpId->ep.fqdn, + nodeEpId->ep.port); SCH_ERR_RET(code); } @@ -1642,9 +1651,9 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { code = schCloneHbRpcCtx(&hb->rpcCtx, &rpcCtx); memcpy(&trans, &hb->trans, sizeof(trans)); SCH_UNLOCK(SCH_WRITE, &hb->lock); - + SCH_ERR_RET(code); - + int32_t msgSize = tSerializeSSchedulerHbReq(NULL, 0, &req); if (msgSize < 0) { qError("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); @@ -1655,7 +1664,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { qError("calloc hb req %d failed", msgSize); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { qError("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1684,17 +1693,18 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { pMsgSendInfo->msgInfo.handle = trans.transHandle; pMsgSendInfo->msgType = msgType; pMsgSendInfo->fp = fp; - - int64_t transporterId = 0; - SEpSet epSet = {.inUse = 0, .numOfEps = 1}; + + int64_t transporterId = 0; + SEpSet epSet = {.inUse = 0, .numOfEps = 1}; memcpy(&epSet.eps[0], &nodeEpId->ep, sizeof(nodeEpId->ep)); - qDebug("start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d", trans.transInst, trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port); - + qDebug("start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d", trans.transInst, trans.transHandle, + nodeEpId->ep.fqdn, nodeEpId->ep.port); + code = asyncSendMsgToServerExt(trans.transInst, &epSet, &transporterId, pMsgSendInfo, true, &rpcCtx); if (code) { - qError("fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s", - trans.transInst, trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code)); + qError("fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s", trans.transInst, + trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code)); SCH_ERR_JRET(code); } @@ -1712,12 +1722,12 @@ _return: int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t msgType) { uint32_t msgSize = 0; - void *msg = NULL; - int32_t code = 0; - bool isCandidateAddr = false; - bool persistHandle = false; - SRpcCtx rpcCtx = {0}; - + void *msg = NULL; + int32_t code = 0; + bool isCandidateAddr = false; + bool persistHandle = false; + SRpcCtx rpcCtx = {0}; + if (NULL == addr) { addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); isCandidateAddr = true; @@ -1741,7 +1751,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, case TDMT_VND_QUERY: { SCH_ERR_RET(schMakeQueryRpcCtx(pJob, pTask, &rpcCtx)); - + uint32_t len = strlen(pJob->sql); msgSize = sizeof(SSubQueryMsg) + pTask->msgLen + len; msg = taosMemoryCalloc(1, msgSize); @@ -1822,7 +1832,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, } case TDMT_VND_QUERY_HEARTBEAT: { SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx)); - + SSchedulerHbReq req = {0}; req.sId = schMgmt.sId; req.header.vgId = addr->nodeId; @@ -1856,7 +1866,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType); SSchTrans trans = {.transInst = pJob->transport, .transHandle = SCH_GET_TASK_HANDLE(pTask)}; - SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL))); + SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle, + (rpcCtx.args ? &rpcCtx : NULL))); if (msgType == TDMT_VND_QUERY) { SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.transHandle)); @@ -1902,7 +1913,7 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { if (schJobNeedToStop(pJob, &status)) { SCH_TASK_DLOG("no need to launch task cause of job status, job status:%s", jobTaskStatusStr(status)); - + SCH_RET(atomic_load_32(&pJob->errCode)); } @@ -1911,7 +1922,7 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_RET(schPushTaskToExecList(pJob, pTask)); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_EXECUTING); } - + SSubplan *plan = pTask->plan; if (NULL == pTask->msg) { // TODO add more detailed reason for failure @@ -2071,7 +2082,7 @@ void schFreeJobImpl(void *job) { taosArrayDestroy(pJob->levels); taosArrayDestroy(pJob->nodeList); - + taosMemoryFreeClear(pJob->resData); taosMemoryFreeClear(pJob); @@ -2093,6 +2104,7 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } + pJob->attr.explainMode = pDag->explainInfo.mode; pJob->attr.syncSchedule = syncSchedule; pJob->transport = transport; pJob->sql = sql; @@ -2126,19 +2138,24 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD tsem_init(&pJob->rspSem, 0, 0); - pJob->refId = taosAddRef(schMgmt.jobRef, pJob); - if (pJob->refId < 0) { - SCH_JOB_ELOG("taosHashPut job failed, error:%s", tstrerror(terrno)); + int64_t refId = taosAddRef(schMgmt.jobRef, pJob); + if (refId < 0) { + SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno)); SCH_ERR_JRET(terrno); } + if (NULL == schAcquireJob(refId)) { + SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); + SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + pJob->refId = refId; + SCH_JOB_DLOG("job refId:%" PRIx64, pJob->refId); pJob->status = JOB_TASK_STATUS_NOT_START; SCH_ERR_JRET(schLaunchJob(pJob)); - schAcquireJob(pJob->refId); - *job = pJob->refId; if (syncSchedule) { @@ -2158,6 +2175,54 @@ _return: SCH_RET(code); } +int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + bool syncSchedule) { + qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); + + int32_t code = 0; + SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); + if (NULL == pJob) { + qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); + SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + pJob->sql = sql; + pJob->attr.queryJob = true; + pJob->attr.explainMode = pDag->explainInfo.mode; + pJob->queryId = pDag->queryId; + pJob->subPlans = pDag->pSubplans; + + SCH_ERR_JRET(qExecStaticExplain(pDag, (SRetrieveTableRsp **)&pJob->resData)); + + int64_t refId = taosAddRef(schMgmt.jobRef, pJob); + if (refId < 0) { + SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno)); + SCH_ERR_JRET(terrno); + } + + if (NULL == schAcquireJob(refId)) { + SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); + SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + pJob->refId = refId; + + SCH_JOB_DLOG("job refId:%" PRIx64, pJob->refId); + + pJob->status = JOB_TASK_STATUS_PARTIAL_SUCCEED; + *job = pJob->refId; + SCH_JOB_DLOG("job exec done, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); + + schReleaseJob(pJob->refId); + + return TSDB_CODE_SUCCESS; + +_return: + + schFreeJobImpl(pJob); + SCH_RET(code); +} + int32_t schedulerInit(SSchedulerCfg *cfg) { if (schMgmt.jobRef) { qError("scheduler already initialized"); @@ -2206,13 +2271,17 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, in SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SCH_ERR_RET(schExecJobImpl(transport, nodeList, pDag, pJob, sql, true)); + if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { + SCH_ERR_RET(schExecStaticExplain(transport, nodeList, pDag, pJob, sql, true)); + } else { + SCH_ERR_RET(schExecJobImpl(transport, nodeList, pDag, pJob, sql, true)); + } SSchJob *job = schAcquireJob(*pJob); pRes->code = atomic_load_32(&job->errCode); pRes->numOfRows = job->resNumOfRows; - + schReleaseJob(*pJob); return TSDB_CODE_SUCCESS; @@ -2389,18 +2458,22 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status)); goto _return; } else if (status == JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_ERR_JRET(schFetchFromRemote(pJob)); + if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { + SCH_ERR_JRET(schFetchFromRemote(pJob)); + tsem_wait(&pJob->rspSem); + } + } else { + SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); } - tsem_wait(&pJob->rspSem); - status = SCH_GET_JOB_STATUS(pJob); if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); } - + if (pJob->resData && ((SRetrieveTableRsp *)pJob->resData)->completed) { SCH_ERR_JRET(schCheckAndUpdateJobStatus(pJob, JOB_TASK_STATUS_SUCCEED)); } diff --git a/source/libs/stream/src/tstream.c b/source/libs/stream/src/tstream.c index fb6c0f6c12..8aaaa414ca 100644 --- a/source/libs/stream/src/tstream.c +++ b/source/libs/stream/src/tstream.c @@ -38,7 +38,7 @@ static int32_t streamBuildDispatchMsg(SStreamTask* pTask, SArray* data, SRpcMsg* req.taskId = pTask->fixedEpDispatcher.taskId; } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { - // TODO fix tbname issue + // TODO use general name rule of schemaless char ctbName[TSDB_TABLE_FNAME_LEN + 22]; // all groupId must be the same in an array SSDataBlock* pBlock = taosArrayGet(data, 0); @@ -152,6 +152,7 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in // sink if (pTask->sinkType == TASK_SINK__TABLE) { // + blockDebugShowData(pRes); } else if (pTask->sinkType == TASK_SINK__SMA) { pTask->smaSink.smaHandle(pTask->ahandle, pTask->smaSink.smaId, pRes); // diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 5296a16703..2545eeab4b 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -30,6 +30,9 @@ SWalReadHandle *walOpenReadHandle(SWal *pWal) { pRead->curFileFirstVer = -1; pRead->capacity = 0; pRead->status = 0; + + taosThreadMutexInit(&pRead->mutex, NULL); + pRead->pHead = taosMemoryMalloc(sizeof(SWalHead)); if (pRead->pHead == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; @@ -135,6 +138,22 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) { return 0; } +int32_t walReadWithHandle_s(SWalReadHandle *pRead, int64_t ver, SWalReadHead **ppHead) { + taosThreadMutexLock(&pRead->mutex); + if (walReadWithHandle(pRead, ver) < 0) { + taosThreadMutexUnlock(&pRead->mutex); + return -1; + } + *ppHead = taosMemoryMalloc(sizeof(SWalReadHead) + pRead->pHead->head.len); + if (*ppHead == NULL) { + taosThreadMutexUnlock(&pRead->mutex); + return -1; + } + memcpy(*ppHead, &pRead->pHead->head, sizeof(SWalReadHead) + pRead->pHead->head.len); + taosThreadMutexUnlock(&pRead->mutex); + return 0; +} + int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { int code; // TODO: check wal life @@ -145,7 +164,9 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } } - if (!taosValidFile(pRead->pReadLogTFile)) return -1; + if (!taosValidFile(pRead->pReadLogTFile)) { + return -1; + } code = taosReadFile(pRead->pReadLogTFile, pRead->pHead, sizeof(SWalHead)); if (code != sizeof(SWalHead)) { diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index ed93708c07..1b73f96896 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -294,7 +294,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile) { #if FILE_WITH_LOCK taosThreadRwlockWrlock(&((*ppFile)->rwlock)); #endif - if (ppFile == NULL || *ppFile == NULL || (*ppFile)->fd == -1) { + if (ppFile == NULL || *ppFile == NULL) { return 0; } if ((*ppFile)->fp != NULL) { diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 81ee259ff1..3545aabdca 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -17,19 +17,28 @@ #include #include "os.h" +#ifdef USE_TD_MEMORY + #define TD_MEMORY_SYMBOL ('T'<<24|'A'<<16|'O'<<8|'S') #define TD_MEMORY_STACK_TRACE_DEPTH 10 +typedef struct TdMemoryInfo *TdMemoryInfoPtr; + typedef struct TdMemoryInfo { int32_t symbol; int32_t memorySize; void *stackTrace[TD_MEMORY_STACK_TRACE_DEPTH]; // gdb: disassemble /m 0xXXX -} *TdMemoryInfoPtr , TdMemoryInfo; + // TdMemoryInfoPtr pNext; + // TdMemoryInfoPtr pPrev; +} TdMemoryInfo; + +// static TdMemoryInfoPtr GlobalMemoryPtr = NULL; #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) - + #define tstrdup(str) _strdup(str) #else + #define tstrdup(str) strdup(str) #include @@ -70,6 +79,8 @@ int32_t taosBackTrace(void **buffer, int32_t size) { // return backtrace_symbols(buffer, *size); // } +#endif + void *taosMemoryMalloc(int32_t size) { #ifdef USE_TD_MEMORY void *tmp = malloc(size + sizeof(TdMemoryInfo)); @@ -125,10 +136,30 @@ void *taosMemoryRealloc(void *ptr, int32_t size) { #endif } -void taosMemoryFree(const void *ptr) { +void *taosMemoryStrDup(void *ptr) { #ifdef USE_TD_MEMORY + if (ptr == NULL) return NULL; + + TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); + assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL); + + void *tmp = tstrdup((const char *)pTdMemoryInfo); + if (tmp == NULL) return NULL; + + memcpy(tmp, pTdMemoryInfo, sizeof(TdMemoryInfo)); + taosBackTrace(((TdMemoryInfoPtr)tmp)->stackTrace,TD_MEMORY_STACK_TRACE_DEPTH); + + return (char*)tmp + sizeof(TdMemoryInfo); +#else + return tstrdup((const char *)ptr); +#endif +} + + +void taosMemoryFree(const void *ptr) { if (ptr == NULL) return; +#ifdef USE_TD_MEMORY TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); if(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL) { pTdMemoryInfo->memorySize = 0; @@ -143,9 +174,9 @@ void taosMemoryFree(const void *ptr) { } int32_t taosMemorySize(void *ptr) { -#ifdef USE_TD_MEMORY if (ptr == NULL) return 0; - + +#ifdef USE_TD_MEMORY TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL); diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c new file mode 100644 index 0000000000..6b52fa30be --- /dev/null +++ b/source/os/src/osProc.c @@ -0,0 +1,62 @@ +/* + * 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 . + */ + +#define ALLOW_FORBID_FUNC +#define _DEFAULT_SOURCE +#include "os.h" + +static char *tsProcPath = NULL; + +int32_t taosNewProc(char **args) { + int32_t pid = fork(); + if (pid == 0) { + args[0] = tsProcPath; + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + return execvp(tsProcPath, args); + } else { + return pid; + } +} + +void taosWaitProc(int32_t pid) { + int32_t status = 0; + waitpid(pid, &status, 0); +} + +void taosKillProc(int32_t pid) { kill(pid, SIGINT); } + +bool taosProcExist(int32_t pid) { + int32_t p = getpgid(pid); + return p >= 0; +} + +// the length of the new name must be less than the original name to take effect +void taosSetProcName(int32_t argc, char **argv, const char *name) { + prctl(PR_SET_NAME, name); + + for (int32_t i = 0; i < argc; ++i) { + int32_t len = strlen(argv[i]); + for (int32_t j = 0; j < len; ++j) { + argv[i][j] = 0; + } + if (i == 0) { + tstrncpy(argv[0], name, len + 1); + } + } +} + +void taosSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; } diff --git a/source/os/src/osShm.c b/source/os/src/osShm.c index e7a22c3da1..ba184c1f5d 100644 --- a/source/os/src/osShm.c +++ b/source/os/src/osShm.c @@ -18,7 +18,9 @@ #include "os.h" int32_t taosCreateShm(SShm* pShm, int32_t shmsize) { - int32_t shmid = shmget(IPC_PRIVATE, shmsize, IPC_CREAT | 0600); + pShm->id = -1; + + int32_t shmid = shmget(0X95279527, shmsize, IPC_CREAT | 0600); if (shmid < 0) { return -1; } @@ -35,37 +37,23 @@ int32_t taosCreateShm(SShm* pShm, int32_t shmsize) { } void taosDropShm(SShm* pShm) { - if (pShm->id > 0) { + if (pShm->id >= 0) { if (pShm->ptr != NULL) { shmdt(pShm->ptr); } shmctl(pShm->id, IPC_RMID, NULL); } - pShm->id = 0; + pShm->id = -1; pShm->size = 0; pShm->ptr = NULL; } int32_t taosAttachShm(SShm* pShm) { - if (pShm->id > 0 && pShm->size > 0) { - pShm->ptr = shmat(pShm->id, NULL, 0); - if (pShm->ptr != NULL) { - return 0; - } + errno = 0; + + void* ptr = shmat(pShm->id, NULL, 0); + if (errno == 0) { + pShm->ptr = ptr; } - - return -1; -} - -void taosDetachShm(SShm* pShm) { - if (pShm->id > 0) { - if (pShm->ptr != NULL) { - shmdt(pShm->ptr); - pShm->ptr = NULL; - } - } - - pShm->id = 0; - pShm->size = 0; - pShm->ptr = NULL; + return errno; } diff --git a/source/os/src/osSignal.c b/source/os/src/osSignal.c index 12721a17f5..d4e6cb3318 100644 --- a/source/os/src/osSignal.c +++ b/source/os/src/osSignal.c @@ -71,4 +71,6 @@ void taosIgnSignal(int32_t signum) { signal(signum, SIG_IGN); } void taosDflSignal(int32_t signum) { signal(signum, SIG_DFL); } +void taosKillChildOnParentStopped() { prctl(PR_SET_PDEATHSIG, SIGKILL); } + #endif diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index c98f6eb9be..7f9a3ff593 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -173,6 +173,7 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight) { if (isnan(p2)) { return 1; } + if (FLT_EQUAL(p1, p2)) { return 0; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 96bb638b95..ce9ef5b1c0 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -590,12 +590,12 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } int32_t cfgLoadFromEnvVar(SConfig *pConfig) { - uInfo("load from global env variables"); + uInfo("load from env variables not implemented yet"); return 0; } int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) { - uInfo("load from env file %s", filepath); + uInfo("load from env file not implemented yet"); return 0; } @@ -654,6 +654,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { } int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { - uInfo("load from apoll url %s", url); + uInfo("load from apoll url not implemented yet"); return 0; } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 005995c8e2..90fa624a8d 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -85,7 +85,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REPEAT_INIT, "Repeat initialization TAOS_DEFINE_ERROR(TSDB_CODE_CFG_NOT_FOUND, "Config not found") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CFG, "Invalid config option") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_SHM_MEM, "Out of Share memory") - +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SHM_ID, "Invalid SHM ID") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NO_MEMORY, "Ref out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_REF_FULL, "too many Ref Objs") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, "Ref ID is removed") diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 0efcf517a9..93a843fee8 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -121,7 +121,8 @@ int32_t tjsonAddItem(SJson* pJson, FToJson func, const void* pObj) { return tjsonAddItemToArray(pJson, pJobj); } -int32_t tjsonAddArray(SJson* pJson, const char* pName, FToJson func, const void* pArray, int32_t itemSize, int32_t num) { +int32_t tjsonAddArray(SJson* pJson, const char* pName, FToJson func, const void* pArray, int32_t itemSize, + int32_t num) { if (num > 0) { SJson* pJsonArray = tjsonAddArrayToObject(pJson, pName); if (NULL == pJsonArray) { @@ -168,7 +169,7 @@ int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal } *pVal = strtol(p, NULL, 10); - return (errno == EINVAL || errno == ERANGE) ? TSDB_CODE_FAILED:TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal) { @@ -199,19 +200,19 @@ int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pV } *pVal = strtoul(p, NULL, 10); - return (errno == ERANGE||errno == EINVAL) ? TSDB_CODE_FAILED:TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } int32_t tjsonGetUIntValue(const SJson* pJson, const char* pName, uint32_t* pVal) { uint64_t val = 0; - int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); + int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); *pVal = val; return code; } int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal) { uint64_t val = 0; - int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); + int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); *pVal = val; return code; } @@ -264,7 +265,7 @@ int32_t tjsonMakeObject(const SJson* pJson, const char* pName, FToObject func, v int32_t tjsonToArray(const SJson* pJson, const char* pName, FToObject func, void* pArray, int32_t itemSize) { const cJSON* jArray = tjsonGetObjectItem(pJson, pName); - int32_t size = (NULL == jArray ? 0 : tjsonGetArraySize(jArray)); + int32_t size = (NULL == jArray ? 0 : tjsonGetArraySize(jArray)); for (int32_t i = 0; i < size; ++i) { int32_t code = func(tjsonGetArrayItem(jArray, i), (char*)pArray + itemSize * i); if (TSDB_CODE_SUCCESS != code) { diff --git a/source/util/src/tprocess.c b/source/util/src/tprocess.c index bfb55b4593..1d41bd4a48 100644 --- a/source/util/src/tprocess.c +++ b/source/util/src/tprocess.c @@ -23,34 +23,36 @@ typedef void *(*ProcThreadFp)(void *param); typedef struct SProcQueue { - int32_t head; - int32_t tail; - int32_t total; - int32_t avail; - int32_t items; - char *pBuffer; - ProcMallocFp mallocHeadFp; - ProcFreeFp freeHeadFp; - ProcMallocFp mallocBodyFp; - ProcFreeFp freeBodyFp; - ProcConsumeFp consumeFp; - void *pParent; - tsem_t sem; - TdThreadMutex *mutex; - int32_t mutexShmid; - int32_t bufferShmid; - const char *name; + int32_t head; + int32_t tail; + int32_t total; + int32_t avail; + int32_t items; + char name[8]; + TdThreadMutex mutex; + tsem_t sem; + char pBuffer[]; } SProcQueue; typedef struct SProcObj { - TdThread childThread; - SProcQueue *pChildQueue; - TdThread parentThread; - SProcQueue *pParentQueue; - const char *name; - int32_t pid; - bool isChild; - bool stopFlag; + TdThread thread; + SProcQueue *pChildQueue; + SProcQueue *pParentQueue; + ProcConsumeFp childConsumeFp; + ProcMallocFp childMallocHeadFp; + ProcFreeFp childFreeHeadFp; + ProcMallocFp childMallocBodyFp; + ProcFreeFp childFreeBodyFp; + ProcConsumeFp parentConsumeFp; + ProcMallocFp parentMallocHeadFp; + ProcFreeFp parentFreeHeadFp; + ProcMallocFp parentMallocBodyFp; + ProcFreeFp parentFreeBodyFp; + void *pParent; + const char *name; + int32_t pid; + bool isChild; + bool stopFlag; } SProcObj; static inline int32_t CEIL8(int32_t v) { @@ -58,160 +60,106 @@ static inline int32_t CEIL8(int32_t v) { return c < 8 ? 8 : c; } -static int32_t taosProcInitMutex(TdThreadMutex **ppMutex, int32_t *pShmid) { - TdThreadMutex *pMutex = NULL; +static int32_t taosProcInitMutex(SProcQueue *pQueue) { TdThreadMutexAttr mattr = {0}; - int32_t shmid = -1; - int32_t code = -1; if (taosThreadMutexAttrInit(&mattr) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); uError("failed to init mutex while init attr since %s", terrstr()); - goto _OVER; + return -1; } if (taosThreadMutexAttrSetPshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) { + taosThreadMutexAttrDestroy(&mattr); terrno = TAOS_SYSTEM_ERROR(errno); uError("failed to init mutex while set shared since %s", terrstr()); - goto _OVER; + return -1; } - shmid = shmget(IPC_PRIVATE, sizeof(TdThreadMutex), IPC_CREAT | 0600); - if (shmid <= 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to init mutex while shmget since %s", terrstr()); - goto _OVER; - } - - pMutex = (TdThreadMutex *)shmat(shmid, NULL, 0); - if (pMutex == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to init mutex while shmat since %s", terrstr()); - goto _OVER; - } - - if (taosThreadMutexInit(pMutex, &mattr) != 0) { + if (taosThreadMutexInit(&pQueue->mutex, &mattr) != 0) { + taosThreadMutexDestroy(&pQueue->mutex); terrno = TAOS_SYSTEM_ERROR(errno); uError("failed to init mutex since %s", terrstr()); - goto _OVER; - } - - code = 0; - -_OVER: - if (code != 0) { - if (pMutex != NULL) { - taosThreadMutexDestroy(pMutex); - shmdt(pMutex); - } - if (shmid >= 0) { - shmctl(shmid, IPC_RMID, NULL); - } - } else { - *ppMutex = pMutex; - *pShmid = shmid; + return -1; } taosThreadMutexAttrDestroy(&mattr); - return code; + return 0; } -static void taosProcDestroyMutex(TdThreadMutex *pMutex, int32_t shmid) { - if (pMutex != NULL) { - taosThreadMutexDestroy(pMutex); - } - if (shmid >= 0) { - shmctl(shmid, IPC_RMID, NULL); - } -} - -static int32_t taosProcInitBuffer(void **ppBuffer, int32_t size) { - int32_t shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600); - if (shmid <= 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to init buffer while shmget since %s", terrstr()); - return -1; - } - - void *shmptr = shmat(shmid, NULL, 0); - if (shmptr == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to init buffer while shmat since %s", terrstr()); - shmctl(shmid, IPC_RMID, NULL); - return -1; - } - - *ppBuffer = shmptr; - return shmid; -} - -static void taosProcDestroyBuffer(void *pBuffer, int32_t shmid) { - if (shmid > 0) { - shmdt(pBuffer); - shmctl(shmid, IPC_RMID, NULL); - } -} - -static SProcQueue *taosProcInitQueue(int32_t size) { - if (size <= 0) size = SHM_DEFAULT_SIZE; - - int32_t bufSize = CEIL8(size); - int32_t headSize = CEIL8(sizeof(SProcQueue)); - - SProcQueue *pQueue = NULL; - int32_t shmId = taosProcInitBuffer((void **)&pQueue, bufSize + headSize); - if (shmId < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - pQueue->bufferShmid = shmId; - - if (taosProcInitMutex(&pQueue->mutex, &pQueue->mutexShmid) != 0) { - taosProcDestroyBuffer(pQueue, pQueue->bufferShmid); - return NULL; - } - +static int32_t taosProcInitSem(SProcQueue *pQueue) { if (tsem_init(&pQueue->sem, 1, 0) != 0) { - taosProcDestroyMutex(pQueue->mutex, pQueue->mutexShmid); - taosProcDestroyBuffer(pQueue, pQueue->bufferShmid); + terrno = TAOS_SYSTEM_ERROR(errno); + uError("failed to init sem"); + return -1; + } + + return 0; +} + +static SProcQueue *taosProcInitQueue(const char *name, bool isChild, char *ptr, int32_t size) { + int32_t bufSize = size - CEIL8(sizeof(SProcQueue)); + if (bufSize <= 1024) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - if (taosProcInitMutex(&pQueue->mutex, &pQueue->mutexShmid) != 0) { - tsem_destroy(&pQueue->sem); - taosProcDestroyMutex(pQueue->mutex, pQueue->mutexShmid); - taosProcDestroyBuffer(pQueue, pQueue->bufferShmid); - return NULL; + SProcQueue *pQueue = (SProcQueue *)(ptr); + + if (!isChild) { + if (taosProcInitMutex(pQueue) != 0) { + return NULL; + } + + if (taosProcInitSem(pQueue) != 0) { + return NULL; + } + + tstrncpy(pQueue->name, name, sizeof(pQueue->name)); + pQueue->head = 0; + pQueue->tail = 0; + pQueue->total = bufSize; + pQueue->avail = bufSize; + pQueue->items = 0; } - pQueue->head = 0; - pQueue->tail = 0; - pQueue->total = bufSize; - pQueue->avail = bufSize; - pQueue->items = 0; - pQueue->pBuffer = (char *)pQueue + headSize; return pQueue; } -static void taosProcCleanupQueue(SProcQueue *pQueue) { - if (pQueue != NULL) { - uDebug("proc:%s, queue:%p clean up", pQueue->name, pQueue); - tsem_destroy(&pQueue->sem); - taosProcDestroyMutex(pQueue->mutex, pQueue->mutexShmid); - taosProcDestroyBuffer(pQueue, pQueue->bufferShmid); +#if 0 +static void taosProcDestroyMutex(SProcQueue *pQueue) { + if (pQueue->mutex != NULL) { + taosThreadMutexDestroy(pQueue->mutex); + pQueue->mutex = NULL; } } +static void taosProcDestroySem(SProcQueue *pQueue) { + if (pQueue->sem != NULL) { + tsem_destroy(pQueue->sem); + pQueue->sem = NULL; + } +} +#endif + +static void taosProcCleanupQueue(SProcQueue *pQueue) { +#if 0 + if (pQueue != NULL) { + taosProcDestroyMutex(pQueue); + taosProcDestroySem(pQueue); + } +#endif +} + static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t rawHeadLen, const char *pBody, int32_t rawBodyLen, ProcFuncType ftype) { const int32_t headLen = CEIL8(rawHeadLen); const int32_t bodyLen = CEIL8(rawBodyLen); const int32_t fullLen = headLen + bodyLen + 8; - taosThreadMutexLock(pQueue->mutex); + taosThreadMutexLock(&pQueue->mutex); if (fullLen > pQueue->avail) { - taosThreadMutexUnlock(pQueue->mutex); + taosThreadMutexUnlock(&pQueue->mutex); terrno = TSDB_CODE_OUT_OF_SHM_MEM; return -1; } @@ -260,7 +208,7 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t pQueue->avail -= fullLen; pQueue->items++; - taosThreadMutexUnlock(pQueue->mutex); + taosThreadMutexUnlock(&pQueue->mutex); tsem_post(&pQueue->sem); uTrace("proc:%s, push msg at pos:%d ftype:%d remain:%d, head:%d %p body:%d %p", pQueue->name, pos, ftype, @@ -268,14 +216,14 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t return 0; } -static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHeadLen, void **ppBody, - int32_t *pBodyLen, ProcFuncType *pFuncType) { +static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHeadLen, void **ppBody, int32_t *pBodyLen, + ProcFuncType *pFuncType, ProcMallocFp mallocHeadFp, ProcFreeFp freeHeadFp, + ProcMallocFp mallocBodyFp, ProcFreeFp freeBodyFp) { tsem_wait(&pQueue->sem); - taosThreadMutexLock(pQueue->mutex); + taosThreadMutexLock(&pQueue->mutex); if (pQueue->total - pQueue->avail <= 0) { - taosThreadMutexUnlock(pQueue->mutex); - tsem_post(&pQueue->sem); + taosThreadMutexUnlock(&pQueue->mutex); terrno = TSDB_CODE_OUT_OF_SHM_MEM; return 0; } @@ -293,13 +241,13 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea bodyLen = *(int32_t *)(pQueue->pBuffer + 4); } - void *pHead = (*pQueue->mallocHeadFp)(headLen); - void *pBody = (*pQueue->mallocBodyFp)(bodyLen); + void *pHead = (*mallocHeadFp)(headLen); + void *pBody = (*mallocBodyFp)(bodyLen); if (pHead == NULL || pBody == NULL) { - taosThreadMutexUnlock(pQueue->mutex); + taosThreadMutexUnlock(&pQueue->mutex); tsem_post(&pQueue->sem); - (*pQueue->freeHeadFp)(pHead); - (*pQueue->freeBodyFp)(pBody); + (*freeHeadFp)(pHead); + (*freeBodyFp)(pBody); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } @@ -338,7 +286,7 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea pQueue->avail = pQueue->avail + headLen + bodyLen + 8; pQueue->items--; - taosThreadMutexUnlock(pQueue->mutex); + taosThreadMutexUnlock(&pQueue->mutex); *ppHead = pHead; *ppBody = pBody; @@ -358,65 +306,85 @@ SProcObj *taosProcInit(const SProcCfg *pCfg) { return NULL; } + int32_t cstart = 0; + int32_t csize = CEIL8(pCfg->shm.size / 2); + int32_t pstart = csize; + int32_t psize = CEIL8(pCfg->shm.size - pstart); + if (pstart + psize > pCfg->shm.size) { + psize -= 8; + } + pProc->name = pCfg->name; - pProc->pChildQueue = taosProcInitQueue(pCfg->childQueueSize); - pProc->pParentQueue = taosProcInitQueue(pCfg->parentQueueSize); + pProc->pChildQueue = taosProcInitQueue(pCfg->name, pCfg->isChild, (char *)pCfg->shm.ptr + cstart, csize); + pProc->pParentQueue = taosProcInitQueue(pCfg->name, pCfg->isChild, (char *)pCfg->shm.ptr + pstart, psize); if (pProc->pChildQueue == NULL || pProc->pParentQueue == NULL) { taosProcCleanupQueue(pProc->pChildQueue); taosMemoryFree(pProc); return NULL; } - pProc->pChildQueue->name = pCfg->name; - pProc->pChildQueue->pParent = pCfg->pParent; - pProc->pChildQueue->mallocHeadFp = pCfg->childMallocHeadFp; - pProc->pChildQueue->freeHeadFp = pCfg->childFreeHeadFp; - pProc->pChildQueue->mallocBodyFp = pCfg->childMallocBodyFp; - pProc->pChildQueue->freeBodyFp = pCfg->childFreeBodyFp; - pProc->pChildQueue->consumeFp = pCfg->childConsumeFp; - pProc->pParentQueue->name = pCfg->name; - pProc->pParentQueue->pParent = pCfg->pParent; - pProc->pParentQueue->mallocHeadFp = pCfg->parentdMallocHeadFp; - pProc->pParentQueue->freeHeadFp = pCfg->parentFreeHeadFp; - pProc->pParentQueue->mallocBodyFp = pCfg->parentMallocBodyFp; - pProc->pParentQueue->freeBodyFp = pCfg->parentFreeBodyFp; - pProc->pParentQueue->consumeFp = pCfg->parentConsumeFp; + pProc->name = pCfg->name; + pProc->pParent = pCfg->pParent; + pProc->childMallocHeadFp = pCfg->childMallocHeadFp; + pProc->childFreeHeadFp = pCfg->childFreeHeadFp; + pProc->childMallocBodyFp = pCfg->childMallocBodyFp; + pProc->childFreeBodyFp = pCfg->childFreeBodyFp; + pProc->childConsumeFp = pCfg->childConsumeFp; + pProc->parentMallocHeadFp = pCfg->parentMallocHeadFp; + pProc->parentFreeHeadFp = pCfg->parentFreeHeadFp; + pProc->parentMallocBodyFp = pCfg->parentMallocBodyFp; + pProc->parentFreeBodyFp = pCfg->parentFreeBodyFp; + pProc->parentConsumeFp = pCfg->parentConsumeFp; + pProc->isChild = pCfg->isChild; - uDebug("proc:%s, is initialized, child queue:%p parent queue:%p", pProc->name, pProc->pChildQueue, pProc->pParentQueue); - - pProc->pid = fork(); - if (pProc->pid == 0) { - pProc->isChild = 1; - prctl(PR_SET_NAME, pProc->name, NULL, NULL, NULL); - } else { - pProc->isChild = 0; - uInfo("this is parent process, child pid:%d", pProc->pid); - } + uDebug("proc:%s, is initialized, isChild:%d child queue:%p parent queue:%p", pProc->name, pProc->isChild, + pProc->pChildQueue, pProc->pParentQueue); return pProc; } -static void taosProcThreadLoop(SProcQueue *pQueue) { - ProcConsumeFp consumeFp = pQueue->consumeFp; - void *pParent = pQueue->pParent; +static void taosProcThreadLoop(SProcObj *pProc) { void *pHead, *pBody; int16_t headLen; ProcFuncType ftype; int32_t bodyLen; + SProcQueue *pQueue; + ProcConsumeFp consumeFp; + ProcMallocFp mallocHeadFp; + ProcFreeFp freeHeadFp; + ProcMallocFp mallocBodyFp; + ProcFreeFp freeBodyFp; - uDebug("proc:%s, start to get msg from queue:%p", pQueue->name, pQueue); + if (pProc->isChild) { + pQueue = pProc->pChildQueue; + consumeFp = pProc->childConsumeFp; + mallocHeadFp = pProc->childMallocHeadFp; + freeHeadFp = pProc->childFreeHeadFp; + mallocBodyFp = pProc->childMallocBodyFp; + freeBodyFp = pProc->childFreeBodyFp; + } else { + pQueue = pProc->pParentQueue; + consumeFp = pProc->parentConsumeFp; + mallocHeadFp = pProc->parentMallocHeadFp; + freeHeadFp = pProc->parentFreeHeadFp; + mallocBodyFp = pProc->parentMallocBodyFp; + freeBodyFp = pProc->parentFreeBodyFp; + } + + uDebug("proc:%s, start to get msg from queue:%p", pProc->name, pQueue); while (1) { - int32_t numOfMsgs = taosProcQueuePop(pQueue, &pHead, &headLen, &pBody, &bodyLen, &ftype); + int32_t numOfMsgs = taosProcQueuePop(pQueue, &pHead, &headLen, &pBody, &bodyLen, &ftype, mallocHeadFp, freeHeadFp, + mallocBodyFp, freeBodyFp); if (numOfMsgs == 0) { - uDebug("proc:%s, get no msg from queue:%p and exit the proc thread", pQueue->name, pQueue); + uDebug("proc:%s, get no msg from queue:%p and exit the proc thread", pProc->name, pQueue); break; } else if (numOfMsgs < 0) { - uTrace("proc:%s, get no msg from queue:%p since %s", pQueue->name, pQueue, terrstr()); + uTrace("proc:%s, get no msg from queue:%p since %s", pProc->name, pQueue, terrstr()); taosMsleep(1); continue; } else { - (*consumeFp)(pParent, pHead, headLen, pBody, bodyLen, ftype); + (*consumeFp)(pProc->pParent, pHead, headLen, pBody, bodyLen, ftype); } } } @@ -426,40 +394,37 @@ int32_t taosProcRun(SProcObj *pProc) { taosThreadAttrInit(&thAttr); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); - if (pProc->isChild) { - if (taosThreadCreate(&pProc->childThread, &thAttr, (ProcThreadFp)taosProcThreadLoop, pProc->pChildQueue) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to create thread since %s", terrstr()); - return -1; - } - uDebug("proc:%s, child start to consume queue:%p", pProc->name, pProc->pChildQueue); - } else { - if (taosThreadCreate(&pProc->parentThread, &thAttr, (ProcThreadFp)taosProcThreadLoop, pProc->pParentQueue) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to create thread since %s", terrstr()); - return -1; - } - uDebug("proc:%s, parent start to consume queue:%p", pProc->name, pProc->pParentQueue); + if (taosThreadCreate(&pProc->thread, &thAttr, (ProcThreadFp)taosProcThreadLoop, pProc) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + uError("failed to create thread since %s", terrstr()); + return -1; } + uDebug("proc:%s, start to consume queue:%p, thread:%" PRId64, pProc->name, pProc->pChildQueue, pProc->thread); return 0; } -void taosProcStop(SProcObj *pProc) { - pProc->stopFlag = true; - // todo join +static void taosProcStop(SProcObj *pProc) { + if (!taosCheckPthreadValid(pProc->thread)) return; + + uDebug("proc:%s, start to join thread:%" PRId64, pProc->name, pProc->thread); + SProcQueue *pQueue; + if (pProc->isChild) { + pQueue = pProc->pChildQueue; + } else { + pQueue = pProc->pParentQueue; + } + tsem_post(&pQueue->sem); + taosThreadJoin(pProc->thread, NULL); } -bool taosProcIsChild(SProcObj *pProc) { return pProc->isChild; } - -int32_t taosProcChildId(SProcObj *pProc) { return pProc->pid; } - void taosProcCleanup(SProcObj *pProc) { if (pProc != NULL) { - uDebug("proc:%s, clean up", pProc->name); + uDebug("proc:%s, start to clean up", pProc->name); taosProcStop(pProc); taosProcCleanupQueue(pProc->pChildQueue); taosProcCleanupQueue(pProc->pParentQueue); + uDebug("proc:%s, is cleaned up", pProc->name); taosMemoryFree(pProc); } } diff --git a/source/util/test/queueTest.cpp b/source/util/test/queueTest.cpp index 0bc53ab85a..0c4bcf84ad 100644 --- a/source/util/test/queueTest.cpp +++ b/source/util/test/queueTest.cpp @@ -26,108 +26,3 @@ class UtilTestQueue : public ::testing::Test { static void SetUpTestSuite() {} static void TearDownTestSuite() {} }; - -#if 0 -TEST_F(UtilTestQueue, 01_fork) { - pid_t pid; - int shmid; - int* shmptr; - int* tmp; - - int err; - pthread_mutexattr_t mattr; - if ((err = taosThreadMutexAttrInit(&mattr)) < 0) { - printf("mutex addr init error:%s\n", strerror(err)); - exit(1); - } - - if ((err = taosThreadMutexAttrSetPshared(&mattr, PTHREAD_PROCESS_SHARED)) < 0) { - printf("mutex addr get shared error:%s\n", strerror(err)); - exit(1); - } - - pthread_mutex_t* m; - int mid = shmget(IPC_PRIVATE, sizeof(pthread_mutex_t), 0600); - m = (pthread_mutex_t*)shmat(mid, NULL, 0); - - if ((err = taosThreadMutexInit(m, &mattr)) < 0) { - printf("mutex mutex init error:%s\n", strerror(err)); - exit(1); - } - - if ((shmid = shmget(IPC_PRIVATE, 1000, IPC_CREAT | 0600)) < 0) { - perror("shmget error"); - exit(1); - } - - if ((shmptr = (int*)shmat(shmid, 0, 0)) == (void*)-1) { - perror("shmat error"); - exit(1); - } - - tmp = shmptr; - - int shmid2; - int** shmptr2; - if ((shmid2 = shmget(IPC_PRIVATE, 20, IPC_CREAT | 0600)) < 0) { - perror("shmget2 error"); - exit(1); - } - - if ((shmptr2 = (int**)shmat(shmid2, 0, 0)) == (void*)-1) { - perror("shmat2 error"); - exit(1); - } - - *shmptr2 = shmptr; - - if ((pid = fork()) < 0) { - perror("fork error"); - exit(1); - } else if (pid == 0) { - if ((err = taosThreadMutexLock(m)) < 0) { - printf("lock error:%s\n", strerror(err)); - exit(1); - } - for (int i = 0; i < 30; ++i) { - **shmptr2 = i; - (*shmptr2)++; - } - - if ((err = taosThreadMutexUnlock(m)) < 0) { - printf("unlock error:%s\n", strerror(err)); - exit(1); - } - exit(0); - - } else { - if ((err = taosThreadMutexLock(m)) < 0) { - printf("lock error:%s\n", strerror(err)); - exit(1); - } - for (int i = 10; i < 42; ++i) { - **shmptr2 = i; - (*shmptr2)++; - } - if ((err = taosThreadMutexUnlock(m)) < 0) { - printf("unlock error:%s\n", strerror(err)); - exit(1); - } - } - - wait(NULL); - - for (int i = 0; i < 70; ++i) { - printf("%d ", tmp[i]); - } - - printf("\n"); - - taosThreadAttrDestroy(&mattr); - //销毁mutex - taosThreadMutexDestroy(m); - - exit(0); -} - -#endif \ No newline at end of file diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 2b654a3793..9fe4ffa0d4 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -50,7 +50,10 @@ class TDSql: def prepare(self): tdLog.info("prepare database:db") s = 'reset query cache' - self.cursor.execute(s) + try: + self.cursor.execute(s) + except: + tdLog.notice("'reset query cache' is not supported") s = 'drop database if exists db' self.cursor.execute(s) s = 'create database db' @@ -341,4 +344,4 @@ class TDSql: tdLog.info("dir: %s is created" %dir) pass -tdSql = TDSql() \ No newline at end of file +tdSql = TDSql() diff --git a/tests/script/general/stable/disk.sim b/tests/script/general/stable/disk.sim deleted file mode 100644 index 1faae78e89..0000000000 --- a/tests/script/general/stable/disk.sim +++ /dev/null @@ -1,199 +0,0 @@ -system sh/stop_dnodes.sh - - -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect - -print ======================== dnode1 start - -$dbPrefix = d_db -$tbPrefix = d_tb -$mtPrefix = d_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $val = $x * 60000 - $ms = 1519833600000 + $val - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sql show vgroups -print vgroups ==> $rows -if $rows != 3 then - return -1 -endi - -sql select count(*) from $mt -print select count(*) from $mt ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -sleep 1000 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 -system sh/exec.sh -n dnode1 -s start -sleep 6000 - -sql use $db -sql show vgroups -print vgroups ==> $rows -if $rows != 3 then - return -1 -endi - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select count(*) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -sql select count(tbcol) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step3 -sql select count(tbcol) from $tb where ts <= 1519833840000 -print ===> $data00 -if $data00 != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol) as b from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step5 -sql select count(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi - -sql select count(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != $rowNum then - return -1 -endi - -print =============== step6 -sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select count(*) from $mt -print select count(*) from $mt ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -sql select count(tbcol) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -print =============== step8 -sql select count(tbcol) as c from $mt where ts <= 1519833840000 -print ===> $data00 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 -print ===> $data00 -if $data00 != 25 then - return -1 -endi - -print =============== step9 -sql select count(tbcol) as b from $mt interval(1m) -print select count(tbcol) as b from $mt interval(1m) ===> $data01 -if $data01 != 10 then - return -1 -endi - -sql select count(tbcol) as b from $mt interval(1d) -print ===> $data02 -if $data01 != 200 then - return -1 -endi - -print =============== step10 -print select count(tbcol) as b from $mt group by tgcol -sql select count(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/dnode3.sim b/tests/script/general/stable/dnode3.sim deleted file mode 100644 index 872cfb8d2e..0000000000 --- a/tests/script/general/stable/dnode3.sim +++ /dev/null @@ -1,212 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode2 -c walLevel -v 1 -system sh/cfg.sh -n dnode3 -c walLevel -v 1 -system sh/cfg.sh -n dnode4 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 -system sh/exec.sh -n dnode1 -s start - -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -$x = 0 -createDnode: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql show dnodes; -if $data4_2 == offline then - goto createDnode -endi -if $data4_3 == offline then - goto createDnode -endi -if $data4_4 == offline then - goto createDnode -endi - -print ======================== dnode1 start - -$dbPrefix = r3v3_db -$tbPrefix = r3v3_tb -$mtPrefix = r3v3_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $val = $x * 60000 - $ms = 1519833600000 + $val - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sql show vgroups -print vgroups ==> $rows -if $rows != 3 then - return -1 -endi - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select count(*) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -sql select count(tbcol) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step3 -sql select count(tbcol) from $tb where ts <= 1519833840000 -print ===> $data00 -if $data00 != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol) as b from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step5 -sql select count(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi - -sql select count(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != $rowNum then - return -1 -endi - -print =============== step6 -sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -print select count(*) from $mt -sql select count(*) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -sql select count(tbcol) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -print =============== step8 -sql select count(tbcol) as c from $mt where ts <= 1519833840000 -print ===> $data00 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 -print ===> $data00 -if $data00 != 25 then - return -1 -endi - -print =============== step9 -sql select count(tbcol) as b from $mt interval(1m) -print ===> $data01 -if $data01 != 10 then - return -1 -endi - -sql select count(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 200 then - return -1 -endi - -print =============== step10 -sql select count(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/values.sim b/tests/script/general/stable/values.sim deleted file mode 100644 index fb2c908da2..0000000000 --- a/tests/script/general/stable/values.sim +++ /dev/null @@ -1,113 +0,0 @@ -system sh/stop_dnodes.sh - - -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect - -print ======================== dnode1 start - -sql create database vdb0 -sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int) - -sql create table vdb0.vtb00 using vdb0.mt tags( 0 ) -sql create table vdb0.vtb01 using vdb0.mt tags( 0 ) - -sql create database vdb1 -sql create table vdb1.mt (ts timestamp, tbcol int) TAGS(tgcol int) -sql_error create table vdb1.vtb10 using vdb0.mt tags( 1 ) -sql_error create table vdb1.vtb11 using vdb0.mt tags( 1 ) -sql create table vdb1.vtb10 using vdb1.mt tags( 1 ) -sql create table vdb1.vtb11 using vdb1.mt tags( 1 ) - -sql create database vdb2 -sql create table vdb2.mt (ts timestamp, tbcol int) TAGS(tgcol int) -sql_error create table vdb2.vtb20 using vdb0.mt tags( 2 ) -sql_error create table vdb2.vtb21 using vdb0.mt tags( 2 ) -sql create table vdb2.vtb20 using vdb2.mt tags( 2 ) -sql create table vdb2.vtb21 using vdb2.mt tags( 2 ) - -sql create database vdb3 -sql create table vdb3.mt (ts timestamp, tbcol int) TAGS(tgcol int) -sql_error create table vdb3.vtb20 using vdb0.mt tags( 2 ) -sql_error create table vdb3.vtb21 using vdb0.mt tags( 2 ) -sql create table vdb3.vtb30 using vdb3.mt tags( 3 ) -sql create table vdb3.vtb31 using vdb3.mt tags( 3 ) - -print =============== step2 -sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) -sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) -sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) -sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) -sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) -sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) -sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) -sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) -sql select * from vdb0.mt - -if $rows != 6 then - return -1 -endi - -print =============== step3 -sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) -sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) -sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) -sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) -sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) -sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) -sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) -sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) -sql select * from vdb0.mt - -if $rows != 12 then - return -1 -endi - -print =============== step4 -sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70) -sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71) -sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72) -sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73) -sql select * from vdb0.mt - -if $rows != 16 then - return -1 -endi - -print =============== step5 -sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70) -sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71) -sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72) -sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73) -sql select * from vdb0.mt - -if $rows != 17 then - return -1 -endi - -print =============== step6 -sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100) -sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100) - -sql select * from vdb0.mt - -if $rows != 21 then - return -1 -endi - -print =============== step7 -sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110) -sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110) - -sql select * from vdb0.mt - -if $rows != 25 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/vnode3.sim b/tests/script/general/stable/vnode3.sim deleted file mode 100644 index 61948b5063..0000000000 --- a/tests/script/general/stable/vnode3.sim +++ /dev/null @@ -1,179 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect - -print ======================== dnode1 start - -$dbPrefix = v3_db -$tbPrefix = v3_tb -$mtPrefix = v3_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $val = $x * 60000 - $ms = 1519833600000 + $val - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sql show vgroups -print vgroups ==> $rows -if $rows != 3 then - return -1 -endi - - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select count(*) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -sql select count(tbcol) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step3 -sql select count(tbcol) from $tb where ts <= 1519833840000 -print ===> $data00 -if $data00 != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol) as b from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step5 -sql select count(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi - -sql select count(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != $rowNum then - return -1 -endi - -print =============== step6 -sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select count(*) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -sql select count(tbcol) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -print =============== step8 -sql select count(tbcol) as c from $mt where ts <= 1519833840000 -print ===> $data00 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 -print ===> $data00 -if $data00 != 25 then - return -1 -endi - -print =============== step9 -sql select count(tbcol) as b from $mt interval(1m) -print ===> $data01 -if $data01 != 10 then - return -1 -endi - -sql select count(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 200 then - return -1 -endi - -print =============== step10 -sql select count(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2cad518128..811c9941f7 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -2,9 +2,10 @@ #======================b1-start=============== # ---- user -./test.sh -f tsim/user/basic1.sim +./test.sh -f tsim/user/basic1.sim # ---- db +./test.sh -f tsim/db/alter_option.sim ./test.sh -f tsim/db/basic1.sim ./test.sh -f tsim/db/basic2.sim ./test.sh -f tsim/db/basic3.sim @@ -28,15 +29,25 @@ # ---- query ./test.sh -f tsim/query/interval.sim ./test.sh -f tsim/query/interval-offset.sim +./test.sh -f tsim/query/scalarFunction.sim # ---- show -./test.sh -f tsim/show/basic.sim +./test.sh -f tsim/show/basic.sim # ---- table -./test.sh -f tsim/table/basic1.sim +./test.sh -f tsim/table/basic1.sim # ---- tmq ./test.sh -f tsim/tmq/basic.sim ./test.sh -f tsim/tmq/basic1.sim +# --- stable +./test.sh -f tsim/stable/disk.sim +./test.sh -f tsim/stable/dnode3.sim +./test.sh -f tsim/stable/metrics.sim +./test.sh -f tsim/stable/refcount.sim +# ./test.sh -f tsim/stable/show.sim +./test.sh -f tsim/stable/values.sim +./test.sh -f tsim/stable/vnode3.sim + #======================b1-end=============== diff --git a/tests/script/runAllSimCases.sh b/tests/script/runAllSimCases.sh new file mode 100755 index 0000000000..e1eea1cc38 --- /dev/null +++ b/tests/script/runAllSimCases.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set -e +#set -x + +while read line +do + firstChar=`echo ${line:0:1}` + if [[ -n "$line" ]] && [[ $firstChar != "#" ]]; then + echo "======== $line ========" + $line + fi +done < ./jenkins/basic.txt + + diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim new file mode 100644 index 0000000000..f79bf88ad2 --- /dev/null +++ b/tests/script/tsim/db/alter_option.sim @@ -0,0 +1,353 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 + +$loop_cnt = 0 +check_dnode_ready_1: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> rows: $rows +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $data00 != 1 then + return -1 +endi +if $data01 != localhost:7100 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_1 +endi +if $data14 != ready then + goto check_dnode_ready_1 +endi +if $data24 != ready then + goto check_dnode_ready_1 +endi + +print ============= create database +#database_option: { +# BLOCKS value [3~1000, default: 6] +# | CACHELAST value [0, 1, 2, 3] +# | FSYNC value [0 ~ 180000 ms] +# | KEEP value [days, 365000] +# | QUORUM value [1 | 2] +# | REPLICA value [1 | 3] +# | WAL value [1 | 2] + +sql create database db BLOCKS 7 CACHE 3 CACHELAST 3 COMP 0 DAYS 345600 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1440000 PRECISION 'ns' QUORUM 1 REPLICA 3 TTL 7 WAL 2 VGROUPS 6 SINGLE_STABLE 1 STREAM_MODE 1 +sql show databases +print rows: $rows +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ====> dataX_db +print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db + +if $rows != 2 then + return -1 +endi +if $data0_db != db then # name + return -1 +endi +if $data2_db != 6 then # vgroups + return -1 +endi +if $data3_db != 0 then # ntables + return -1 +endi +if $data4_db != 3 then # replica + return -1 +endi +if $data5_db != 1 then # quorum + return -1 +endi +if $data6_db != 345600 then # days + return -1 +endi +if $data7_db != 1440000,1440000,1440000 then # keep + return -1 +endi +if $data8_db != 3 then # cache + return -1 +endi +if $data9_db != 7 then # blocks + return -1 +endi +if $data10_db != 10 then # minrows + return -1 +endi +if $data11_db != 8000 then # maxrows + return -1 +endi +if $data12_db != 2 then # wal + return -1 +endi +if $data13_db != 1000 then # fsync + return -1 +endi +if $data14_db != 0 then # comp + return -1 +endi +if $data15_db != 3 then # cachelast + return -1 +endi +if $data16_db != ns then # precision + return -1 +endi + +print ============== not support modify options: name, create_time, vgroups, ntables +sql_error alter database db name dba +sql_error alter database db create_time "2022-03-03 15:08:13.329" +sql_error alter database db vgroups -1 +sql_error alter database db vgroups 0 +sql_error alter database db vgroups 2 +sql_error alter database db vgroups 20 +sql_error alter database db ntables -1 +sql_error alter database db ntables 0 +sql_error alter database db ntables 1 +sql_error alter database db ntables 10 + +#print ============== modify replica # TD-14409 +sql_error alter database db replica 2 +sql_error alter database db replica 5 +sql_error alter database db replica -1 +sql_error alter database db replica 0 +#sql alter database db replica 1 +#sql show databases +#print replica: $data4_db +#if $data4_db != 1 then +# return -1 +#endi +#sql alter database db replica 3 +#sql show databases +#print replica: $data4_db +#if $data4_db != 3 then +# return -1 +#endi + +print ============== modify quorum +sql alter database db quorum 2 +sql show databases +print quorum $data5_db +if $data5_db != 2 then + return -1 +endi +sql alter database db quorum 1 +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter database db quorum -1 +sql_error alter database db quorum 0 +sql_error alter database db quorum 3 +sql_error alter database db quorum 4 +sql_error alter database db quorum 5 + +#print ============== modify days +sql_error alter database db days 480 +sql_error alter database db days 360 +sql_error alter database db days 0 +sql_error alter database db days 14400 # set over than keep + +print ============== modify keep +sql alter database db keep 2000 +sql show databases +print keep $data7_db +if $data7_db != 2000,2000,2000 then + return -1 +endi + +#sql alter database db keep 1000,2000 +#sql show databases +#print keep $data7_db +#if $data7_db != 500,500,500 then +# return -1 +#endi + +#sql alter database db keep 40,50 +#sql alter database db keep 30,31 +#sql alter database db keep 20 +#sql_error alter database db keep 10.0 +#sql_error alter database db keep 9 +#sql_error alter database db keep 1 +sql_error alter database db keep 0 +sql_error alter database db keep -1 +#sql_error alter database db keep 365001 + +print ============== modify cache +sql_error alter database db cache 12 +sql_error alter database db cache 1 +sql_error alter database db cache 60 +sql_error alter database db cache 50 +sql_error alter database db cache 20 +sql_error alter database db cache 3 +sql_error alter database db cache 129 +sql_error alter database db cache 300 +sql_error alter database db cache 0 +sql_error alter database db cache -1 + +print ============== modify blocks +sql alter database db blocks 3 +sql show databases +print blocks $data9_db +if $data9_db != 3 then + return -1 +endi +sql alter database db blocks 11 +sql show databases +print blocks $data9_db +if $data9_db != 11 then + return -1 +endi + +sql alter database db blocks 40 +sql alter database db blocks 30 +sql alter database db blocks 20 +sql alter database db blocks 10 +sql_error alter database db blocks 2 +sql_error alter database db blocks 1 +sql_error alter database db blocks 0 +sql_error alter database db blocks -1 +sql_error alter database db blocks 10001 + +print ============== modify minrows +sql_error alter database db minrows 8 +sql_error alter database db minrows 200 +sql_error alter database db minrows 11 +sql_error alter database db minrows 8000 +sql_error alter database db minrows 8001 + +print ============== modify maxrows +sql_error alter database db maxrows 1000 +sql_error alter database db maxrows 2000 +sql_error alter database db maxrows 11 # equal minrows +sql_error alter database db maxrows 10 # little than minrows + +print ============== step wal +sql alter database db wal 1 +sql show databases +print wal $data12_db +if $data12_db != 1 then + return -1 +endi +sql alter database db wal 2 +sql show databases +print wal $data12_db +if $data12_db != 2 then + return -1 +endi + +sql_error alter database db wal 0 # TD-14436 +sql_error alter database db wal 3 +sql_error alter database db wal 100 +sql_error alter database db wal -1 + +print ============== modify fsync +sql alter database db fsync 2000 +sql show databases +print fsync $data13_db +if $data13_db != 2000 then + return -1 +endi +sql alter database db fsync 500 +sql show databases +print fsync $data13_db +if $data13_db != 500 then + return -1 +endi +sql alter database db fsync 0 +sql show databases +print fsync $data13_db +if $data13_db != 0 then + return -1 +endi +sql_error alter database db fsync 180001 +sql_error alter database db fsync -1 + +print ============== modify comp +sql_error alter database db comp 1 +sql_error alter database db comp 2 +sql_error alter database db comp 1 +sql_error alter database db comp 0 +sql_error alter database db comp 3 +sql_error alter database db comp 4 +sql_error alter database db comp 5 +sql_error alter database db comp -1 + +print ============== modify cachelast [0, 1, 2, 3] +sql alter database db cachelast 2 +sql show databases +print cachelast $data15_db +if $data15_db != 2 then + return -1 +endi +sql alter database db cachelast 1 +sql show databases +print cachelast $data15_db +if $data15_db != 1 then + return -1 +endi +sql alter database db cachelast 0 +sql show databases +print cachelast $data15_db +if $data15_db != 0 then + return -1 +endi +sql alter database db cachelast 2 +sql show databases +print cachelast $data15_db +if $data15_db != 2 then + return -1 +endi +sql alter database db cachelast 3 +sql show databases +print cachelast $data15_db +if $data15_db != 3 then + return -1 +endi + +sql_error alter database db cachelast 4 +sql_error alter database db cachelast 10 +sql_error alter database db cachelast -1 + +print ============== modify precision +sql_error alter database db precision 'ms' +sql_error alter database db precision 'us' +sql_error alter database db precision 'ns' +sql_error alter database db precision 'ys' +sql_error alter database db prec 'xs' + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/db/basic6.sim b/tests/script/tsim/db/basic6.sim index 7e57fe8f1b..a768a0da38 100644 --- a/tests/script/tsim/db/basic6.sim +++ b/tests/script/tsim/db/basic6.sim @@ -15,7 +15,7 @@ $tb = $tbPrefix . $i print =============== step1 # quorum presicion -sql create database $db vgroups 8 replica 1 days 20 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' +sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' sql show databases print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -35,7 +35,7 @@ endi if $data04 != 1 then return -1 endi -if $data06 != 20 then +if $data06 != 2880 then return -1 endi if $data07 != 3650,3650,3650 then @@ -67,7 +67,7 @@ print =============== step4 sql_error drop database $db print =============== step5 -sql create database $db replica 1 days 15 keep 1500 +sql create database $db replica 1 days 21600 keep 2160000 sql show databases print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 if $data00 != $db then @@ -79,7 +79,7 @@ endi if $data04 != 1 then return -1 endi -if $data06 != 15 then +if $data06 != 21600 then return -1 endi diff --git a/tests/script/tsim/parser/groupby-basic.sim b/tests/script/tsim/parser/groupby-basic.sim index c0cbfa8aeb..601888f3c2 100644 --- a/tests/script/tsim/parser/groupby-basic.sim +++ b/tests/script/tsim/parser/groupby-basic.sim @@ -142,68 +142,68 @@ if $row != 10 then return -1 endi -if $data00 != @2022-01-01 00:00:00.000@ then +if $data00 != @22-01-01 00:00:00.000@ then return -1 endi if $data01 != 0 then return -1 endi -if $data90 != @2022-01-01 00:00:00.009@ then +if $data90 != @22-01-01 00:00:00.009@ then return -1 endi if $data91 != 9 then return -1 endi - -sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1; -if $row != 20 then - return -1 -endi - -if $data00 != 0 then - return -1 -endi - -if $data01 != 0 then - return -1 -endi - -print $data02 -if $data02 != 0.000000000 then - return -1 -endi - -if $data03 != 0 then - return -1 -endi - -print $data04 -if $data04 != 0.00000 then - return -1 -endi - -if $data10 != 100 then - return -1 -endi - -if $data11 != 1 then - return -1 -endi - -print $data12 -if $data12 != 1.000000000 then - return -1 -endi - -if $data13 != 1 then - return -1 -endi - -if $data14 != 1.00000 then - print expect 1.00000, actual:$data14 - return -1 -endi +print ============> filter not supported yet. +#sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1; +#if $row != 20 then +# return -1 +#endi +# +#if $data00 != 0 then +# return -1 +#endi +# +#if $data01 != 0 then +# return -1 +#endi +# +#print $data02 +#if $data02 != 0.000000000 then +# return -1 +#endi +# +#if $data03 != 0 then +# return -1 +#endi +# +#print $data04 +#if $data04 != 0.00000 then +# return -1 +#endi +# +#if $data10 != 100 then +# return -1 +#endi +# +#if $data11 != 1 then +# return -1 +#endi +# +#print $data12 +#if $data12 != 1.000000000 then +# return -1 +#endi +# +#if $data13 != 1 then +# return -1 +#endi +# +#if $data14 != 1.00000 then +# print expect 1.00000, actual:$data14 +# return -1 +#endi sql_error select sum(c1), ts, c1 from group_tb0 where c1<20 group by c1; sql_error select first(ts), ts, c2 from group_tb0 where c1 < 20 group by c1; diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index 4c4ebc6670..616ece99e0 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -7,7 +7,7 @@ sql connect print =============== create database sql create database d0 sql show databases -if $rows != 2 then +if $rows != 2 then return -1 endi @@ -17,7 +17,7 @@ print =============== create super table and child table sql create table stb (ts timestamp, tbcol int) tags (t1 int) sql show stables print $rows $data00 $data01 $data02 -if $rows != 1 then +if $rows != 1 then return -1 endi @@ -29,7 +29,7 @@ sql show tables print $rows $data00 $data10 $data20 if $rows != 4 then return -1 -endi +endi print =============== insert data into child table ct1 (s) sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1 ) @@ -73,41 +73,47 @@ sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 ) sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 ) print ================ start query ====================== -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) +sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) +print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 +print ===> rows0: $data00 $data01 $data02 $data05 +print ===> rows1: $data10 $data11 $data12 $data15 +print ===> rows2: $data20 $data21 $data22 $data25 +print ===> rows3: $data30 $data31 $data32 $data35 +print ===> rows4: $data40 $data41 $data42 $data45 if $rows != 5 then return -1 -endi -if $data00 != 1 then +endi +if $data00 != @22-01-01 01:00:52.000@ then return -1 -endi -if $data40 != 1 then +endi +if $data02 != 10000 then return -1 -endi +endi +if $data45 != 1 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(10s) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(10s) +sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) +print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 +print ===> rows0: $data00 $data01 $data02 $data05 +print ===> rows1: $data10 $data11 $data12 $data15 +print ===> rows2: $data20 $data21 $data22 $data25 +print ===> rows3: $data30 $data31 $data32 $data35 +print ===> rows4: $data40 $data41 $data42 $data45 if $rows != 5 then return -1 -endi -if $data00 != 1 then +endi +if $data00 != @22-01-01 01:00:52.000@ then return -1 -endi -if $data40 != 1 then +endi +if $data02 != 10000 then return -1 -endi +endi +if $data45 != 1 then + return -1 +endi sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(5s) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(5s) @@ -123,16 +129,16 @@ print ===> rows7: $data70 $data71 $data72 $data73 $data74 print ===> rows8: $data80 $data81 $data82 $data83 $data84 if $rows != 9 then return -1 -endi +endi if $data00 != 1 then return -1 -endi +endi if $data70 != 2 then return -1 -endi +endi if $data80 != 1 then return -1 -endi +endi sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) @@ -144,10 +150,10 @@ print ===> rows3: $data30 $data31 $data32 $data33 $data34 print ===> rows4: $data40 $data41 $data42 $data43 $data44 if $rows != 4 then return -1 -endi +endi if $data00 != 1 then return -1 -endi +endi if $data10 != 2 then return -1 endi @@ -155,101 +161,102 @@ endi sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h) print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75 +print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05 +print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15 +print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25 +print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35 +print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45 +print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55 +print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65 +print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75 if $rows != 8 then return -1 -endi +endi if $data00 != 1 then return -1 -endi +endi if $data10 != 2 then return -1 -endi +endi if $data70 != 1 then return -1 endi - -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) + +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 4 then + return -1 +endi +if $data00 != @21-12-08 00:00:00.000@ then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data34 != $data31 then + return -1 +endi +if $data02 != 2678400000 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 4 then + return -1 +endi +if $data00 != @21-11-30 08:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data31 != $data34 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 -#if $rows != 8 then -# return -1 -#endi -#if $data00 != 2 then -# return -1 -#endi -#if $data70 != 1 then -# return -1 -#endi +if $rows != 4 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data04 != 1 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) @@ -257,38 +264,31 @@ print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 -#if $rows != 8 then -# return -1 -#endi -#if $data00 != 2 then -# return -1 -#endi -#if $data70 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi #================================================= print =============== stop and restart taosd @@ -322,9 +322,4 @@ endi #sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d) - - - - - #system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim index 6dd0a9537e..384008c887 100644 --- a/tests/script/tsim/query/interval.sim +++ b/tests/script/tsim/query/interval.sim @@ -29,18 +29,18 @@ $i = 0 while $i < $tbNum $tb = $tbPrefix . $i sql create table $tb using $mt tags( $i ) - + $x = 0 while $x < $rowNum $cc = $x * 60000 $ms = 1601481600000 + $cc - sql insert into $tb values ($ms , $x ) + sql insert into $tb values ($ms , $x ) $x = $x + 1 - endw - + endw + $i = $i + 1 -endw +endw print =============== step2 $i = 1 @@ -49,51 +49,51 @@ $tb = $tbPrefix . $i sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) print ===> $rows $data01 $data05 -if $rows != $rowNum then +if $rows != $rowNum then return -1 endi -if $data00 != 1 then +if $data00 != 1 then return -1 endi -if $data04 != 1 then +if $data04 != 1 then return -1 endi -#print =============== step3 +print =============== step3 #$cc = 4 * 60000 #$ms = 1601481600000 + $cc #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) #print ===> $rows $data01 $data05 -#if $rows != 5 then +#if $rows != 5 then # return -1 #endi -#if $data00 != 1 then +#if $data00 != 1 then # return -1 #endi -#if $data04 != 1 then +#if $data04 != 1 then # return -1 #endi -#print =============== step4 +print =============== step4 #$cc = 40 * 60000 #$ms = 1601481600000 + $cc #$cc = 1 * 60000 #$ms2 = 1601481600000 - $cc -#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) -#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) -#print ===> $rows $data01 $data05 -#if $rows != 20 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data04 != 1 then -# return -1 -#endi +sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m) +print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m) +print ===> $rows $data01 $data05 +if $rows != $rowNum then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data02 != 60000 then + return -1 +endi #print =============== step5 #$cc = 40 * 60000 @@ -105,13 +105,13 @@ endi #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) #print ===> $rows $data21 $data25 -#if $rows != 42 then +#if $rows != 42 then # return -1 #endi -#if $data20 != 1 then +#if $data20 != 1 then # return -1 #endi -#if $data24 != 1 then +#if $data24 != 1 then # return -1 #endi @@ -119,10 +119,10 @@ endi #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) #print ===> $rows $data11 -#if $rows != 20 then +#if $rows != 20 then # return -1 #endi -#if $data11 != 10 then +#if $data11 != 10 then # return -1 #endi @@ -132,10 +132,10 @@ endi #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) #print ===> $rows $data11 -#if $rows != 5 then +#if $rows != 5 then # return -1 #endi -#if $data11 != 10 then +#if $data11 != 10 then # return -1 #endi @@ -149,10 +149,10 @@ endi #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) #print ===> $rows $data11 -#if $rows != 20 then +#if $rows != 20 then # return -1 #endi -#if $data11 != 10 then +#if $data11 != 10 then # return -1 #endi # @@ -166,18 +166,18 @@ endi #sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) #print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) #print ===> $rows $data11 -#if $rows != 42 then +#if $rows != 42 then # return -1 #endi -#if $data11 != 10 then +#if $data11 != 10 then # return -1 #endi print =============== clear #sql drop database $db #sql show databases -#if $rows != 0 then +#if $rows != 0 then # return -1 #endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/scalarFunction.sim b/tests/script/tsim/query/scalarFunction.sim new file mode 100644 index 0000000000..6a2a602703 --- /dev/null +++ b/tests/script/tsim/query/scalarFunction.sim @@ -0,0 +1,484 @@ +#### abs, log, pow, sqrt, sin, cos, tan, asin, acos, atan, ceil, floor, round + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +$vgroups = 4 +$dbNamme = d0 + +print =============== create database $dbNamme vgroups $vgroups +sql create database $dbNamme vgroups $vgroups +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +#print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +sql use $dbNamme + +print =============== create super table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) + +print =============== create child table +$tbPrefix = ct +$tbNum = 100 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $i = $i + 1 +endw + +print =============== create normal table +sql create table ntb (ts timestamp, c1 int, c2 float, c3 double) + +sql show tables +if $rows != 101 then + return -1 +endi + +print =============== insert data +$rowNum = 20 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + $c1 = 0 + while $x < $rowNum + $c2 = 0 - $c1 + $c3 = $c1 + 100 + + sql insert into $tb values ($tstart , $c1 , $c2 , $c3 ) + sql insert into ntb values ($tstart , $c1 , $c2 , $c3 ) + $tstart = $tstart + 1 + $c1 = $c1 + 5 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 1640966400000 +endw + +$totalRows = $rowNum * $tbNum +print ====> totalRows of stb: $totalRows + +$loop_test = 0 +loop_test_pos: + +print ====> abs +sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ct1 +print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from stb +sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ntb +sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> log +sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ct1 +print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from stb +sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ntb +sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> pow +sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ct1 +print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from stb +sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ntb +sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> sqrt +sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ct1 +print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from stb +sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ntb +sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> sin +#sql select c1, sin(c1), sin(c1) * 3.14159265 / 180 from ct1 # TD-14426 +sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1 +print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from stb +sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ntb +sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> cos +sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1 +print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from stb +sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ntb +sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> tan +sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ct1 +print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from stb +sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ntb +sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> asin +sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ct1 +print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from stb +sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ntb +sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> acos +sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ct1 +print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from stb +sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ntb +sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> atan +sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ct1 +print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from stb +sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ntb +sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> ceil +sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ct1 +print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from stb +sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ntb +sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +print ====> floor +sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ct1 +print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from stb +sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ntb +sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ntb +if $rows != $rowNum then + return -1 +endi + + +print ====> round +sql select c1, round(c1), c2, round(c2), c3, round(c3) from ct1 +print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from ct1 +print ====> rows: $rows +print ====> $data00 $data01 $data02 $data03 $data04 $data05 +print ====> $data10 $data11 $data12 $data13 $data14 $data15 +print ====> $data20 $data21 $data22 $data23 $data24 $data25 +print ====> $data30 $data31 $data32 $data33 $data34 $data35 +print ====> $data40 $data41 $data42 $data43 $data44 $data45 +print ====> $data50 $data51 $data52 $data53 $data54 $data55 +print ====> $data60 $data61 $data62 $data63 $data64 $data65 +print ====> $data70 $data71 $data72 $data73 $data74 $data75 +print ====> $data80 $data81 $data82 $data83 $data84 $data85 +print ====> $data90 $data91 $data92 $data93 $data94 $data95 +if $rows != $rowNum then + return -1 +endi +print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from stb +sql select c1, round(c1), c2, round(c2), c3, round(c3) from stb +if $rows != $totalRows then + return -1 +endi +print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from ntb +sql select c1, round(c1), c2, round(c2), c3, round(c3) from ntb +if $rows != $rowNum then + return -1 +endi + +if $loop_test == 0 then + print =============== stop and restart taosd + system sh/exec.sh -n dnode1 -s stop -x SIGINT + system sh/exec.sh -n dnode1 -s start + + $loop_cnt = 0 + check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + sql show dnodes + print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 + if $data00 != 1 then + return -1 + endi + if $data04 != ready then + goto check_dnode_ready_0 + endi + + $loop_test = 1 + goto loop_test_pos +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/disk.sim b/tests/script/tsim/stable/disk.sim new file mode 100644 index 0000000000..0e33c2066d --- /dev/null +++ b/tests/script/tsim/stable/disk.sim @@ -0,0 +1,206 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = d_db +$tbPrefix = d_tb +$mtPrefix = d_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 2 then + return -1 +endi + +sql select count(tbcol) from $mt +print select count(tbcol) from $mt ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 6000 + +sql use $db +sql show vgroups +print vgroups ==> $rows +if $rows != 2 then + return -1 +endi + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +# TODO : where condition +# sql select count(tbcol) from $tb where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 5 then +# return -1 +# endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data00 +if $data00 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step6 +# TODO +# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +# print ===> $data00 +# if $data00 != 1 then +# return -1 +# endi +# if $rows != 5 then +# return -1 +# endi + +print =============== step7 +# TODO +# sql select count(*) from $mt +# print select count(*) from $mt ===> $data00 +# if $data00 != $totalNum then +# return -1 +# endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +# TODO +# sql select count(tbcol) as c from $mt where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 50 then +# return -1 +# endi +# +# sql select count(tbcol) as c from $mt where tgcol < 5 +# print ===> $data00 +# if $data00 != 100 then +# return -1 +# endi +# +# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 25 then +# return -1 +# endi + +print =============== step9 +# TODO : count from stable +# sql select count(tbcol) as b from $mt interval(1m) +# print select count(tbcol) as b from $mt interval(1m) ===> $data01 +# if $data01 != 10 then +# return -1 +# endi + +# sql select count(tbcol) as b from $mt interval(1d) +# print ===> $data02 +# if $data01 != 200 then +# return -1 +# endi + +print =============== step10 +# TODO +# print select count(tbcol) as b from $mt group by tgcol +# sql select count(tbcol) as b from $mt group by tgcol +# print ===> $data00 +# if $data00 != $rowNum then +# return -1 +# endi + +# if $rows != $tbNum then +# return -1 +# endi +# +print =============== step11 +# TODO : where condition +# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +# print ===> $data01 +# if $data01 != 1 then +# return -1 +# endi +# if $rows != 50 then +# return -1 +# endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/stable/dnode3.sim b/tests/script/tsim/stable/dnode3.sim new file mode 100644 index 0000000000..c2243b1ac8 --- /dev/null +++ b/tests/script/tsim/stable/dnode3.sim @@ -0,0 +1,213 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +# system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +# system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +# system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +# system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname PORT 7200 +sql create dnode $hostname PORT 7300 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi +if $data4_4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3v3_db +$tbPrefix = r3v3_tb +$mtPrefix = r3v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 2 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +# TODO : where condition +# sql select count(tbcol) from $tb where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 5 then +# return -1 +# endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data00 +if $data00 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step6 +# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +# print ===> $data00 +# if $data00 != 1 then +# return -1 +# endi +# if $rows != 5 then +# return -1 +# endi + +print =============== step7 +# print select count(*) from $mt +# sql select count(*) from $mt +# print ===> $data00 +# if $data00 != $totalNum then +# return -1 +# endi +# +# sql select count(tbcol) from $mt +# print ===> $data00 +# if $data00 != $totalNum then +# return -1 +# endi + +print =============== step8 +# sql select count(tbcol) as c from $mt where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 50 then +# return -1 +# endi +# +# sql select count(tbcol) as c from $mt where tgcol < 5 +# print ===> $data00 +# if $data00 != 100 then +# return -1 +# endi +# +# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 25 then +# return -1 +# endi + +print =============== step9 +# TODO : group by in stable +# sql select count(tbcol) as b from $mt interval(1m) +# print ===> $data00 +# if $data00 != 10 then +# return -1 +# endi +# +# sql select count(tbcol) as b from $mt interval(1d) +# print ===> $data00 +# if $data00 != 200 then +# return -1 +# endi + +print =============== step10 +# sql select count(tbcol) as b from $mt group by tgcol +# print ===> $data00 +# if $data00 != $rowNum then +# return -1 +# endi +# +# if $rows != $tbNum then +# return -1 +# endi + +print =============== step11 +# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +# print ===> $data00 +# if $data00 != 1 then +# return -1 +# endi +# if $rows != 50 then +# return -1 +# endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/stable/metrics.sim b/tests/script/tsim/stable/metrics.sim similarity index 64% rename from tests/script/general/stable/metrics.sim rename to tests/script/tsim/stable/metrics.sim index a3dca3f1a5..948af72d09 100644 --- a/tests/script/general/stable/metrics.sim +++ b/tests/script/tsim/stable/metrics.sim @@ -24,14 +24,14 @@ sql use $db sql create table $mt (ts timestamp, speed int) TAGS(sp int) sql show stables -if $rows != 1 then +if $rows != 1 then return -1 endi print =============== step2 sql drop table $mt sql show stables -if $rows != 0 then +if $rows != 0 then return -1 endi @@ -39,97 +39,98 @@ print =============== step3 sql create table $mt (ts timestamp, speed int) TAGS(sp int) sql show stables -if $rows != 1 then +if $rows != 1 then return -1 endi -if $data00 != $mt then +if $data00 != $mt then return -1 endi -if $data04 != 0 then - return -1 -endi -sql select * from $mt -if $rows != 0 then +if $data04 != 1 then return -1 endi +# TODO : select * from stable +# sql select * from $mt +# if $rows != 0 then +# return -1 +# endi print =============== step4 $i = 0 $tb = $tbPrefix . $i sql create table $tb using $mt tags(1) -$i = 1 +$i = 1 $tb = $tbPrefix . $i sql create table $tb using $mt tags(2) -$i = 2 +$i = 2 $tb = $tbPrefix . $i sql create table $tb using $mt tags(3) sql show tables -if $rows != 3 then - return -1 -endi -if $data03 != $mt then +if $rows != 3 then return -1 endi +# if $data03 != $mt then +# return -1 +# endi sql show stables -if $rows != 1 then +if $rows != 1 then return -1 endi -if $data00 != $mt then - return -1 -endi -if $data04 != 3 then +if $data00 != $mt then return -1 endi +# if $data04 != 3 then +# return -1 +# endi print =============== step5 $i = 0 $tb = $tbPrefix . $i -sql insert into $tb values (now + 1m , 1 ) +sql insert into $tb values (now + 1m , 1 ) $i = 1 $tb = $tbPrefix . $i -sql insert into $tb values (now + 1m , 1 ) +sql insert into $tb values (now + 1m , 1 ) $i = 2 $tb = $tbPrefix . $i -sql insert into $tb values (now + 1m , 1 ) +sql insert into $tb values (now + 1m , 1 ) print sleep 8000 sleep 8000 print =============== step6 -sql select * from $mt -print select * from $mt ==> $rows $data00 -if $rows != 3 then - return -1 -endi +# sql select * from $mt +# print select * from $mt ==> $rows $data00 +# if $rows != 3 then +# return -1 +# endi print =============== step7 -sql select * from $mt where sp = 1 -print select * from $mt where sp = 1 ==> $rows $data00 -if $rows != 1 then - return -1 -endi +# sql select * from $mt where sp = 1 +# print select * from $mt where sp = 1 ==> $rows $data00 +# if $rows != 1 then +# return -1 +# endi print =============== step8 sql drop table $mt print =============== step9 -sql show tables -if $rows != 0 then - return -1 -endi +#sql show tables +#if $rows != 0 then +# return -1 +#endi sql show stables -if $rows != 0 then +if $rows != 0 then return -1 endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 1 then return -1 endi diff --git a/tests/script/general/stable/refcount.sim b/tests/script/tsim/stable/refcount.sim similarity index 79% rename from tests/script/general/stable/refcount.sim rename to tests/script/tsim/stable/refcount.sim index 6629dc1177..1f00483090 100644 --- a/tests/script/general/stable/refcount.sim +++ b/tests/script/tsim/stable/refcount.sim @@ -16,11 +16,11 @@ sql create table d1.t2 (ts timestamp, i int); sql create table d1.t3 (ts timestamp, i int); sql insert into d1.t1 values(now, 1); sql insert into d1.t2 values(now, 1); -sql drop table d1.t1; +# sql drop table d1.t1; sql drop database d1; sql show databases; -if $rows != 0 then +if $rows != 1 then return -1 endi @@ -32,24 +32,24 @@ sql create table d2.t2 (ts timestamp, i int); sql create table d2.t3 (ts timestamp, i int); sql insert into d2.t1 values(now, 1); sql insert into d2.t2 values(now, 1); -sql drop table d2.t1; -sql drop table d2.t2; -sql drop table d2.t3; - -sql show d2.tables; -if $rows != 0 then - return -1 -endi +# sql drop table d2.t1; +# sql drop table d2.t2; +# sql drop table d2.t3; +# +# sql show d2.tables; +# if $rows != 0 then +# return -1 +# endi sql show d2.vgroups; -if $rows != 0 then +if $rows != 2 then return -1 endi sql drop database d2; sql show databases; -if $rows != 0 then +if $rows != 1 then return -1 endi @@ -61,24 +61,24 @@ sql create table d3.t1 using d3.st tags(1); sql create table d3.t2 using d3.st tags(1); sql create table d3.t3 using d3.st tags(1); sql insert into d3.t1 values(now, 1); -sql drop table d3.t1; -sql drop table d3.t2; -sql drop table d3.t3; - -sql show d3.tables; -if $rows != 0 then - return -1 -endi +# sql drop table d3.t1; +# sql drop table d3.t2; +# sql drop table d3.t3; +# +# sql show d3.tables; +# if $rows != 0 then +# return -1 +# endi sql show d3.vgroups; -if $rows != 0 then +if $rows != 2 then return -1 endi sql drop database d3; sql show databases; -if $rows != 0 then +if $rows != 1 then return -1 endi @@ -90,23 +90,23 @@ sql create table d4.t1 using d4.st tags(1); sql create table d4.t2 using d4.st tags(1); sql create table d4.t3 using d4.st tags(1); sql insert into d4.t1 values(now, 1); -sql drop table d4.t1; +# sql drop table d4.t1; sql drop table d4.st; - -sql show d4.tables; -if $rows != 0 then - return -1 -endi +# +# sql show d4.tables; +# if $rows != 0 then +# return -1 +# endi sql show d4.stables; -if $rows != 0 then +if $rows != 0 then return -1 endi sql drop database d4; sql show databases; -if $rows != 0 then +if $rows != 1 then return -1 endi @@ -118,12 +118,12 @@ sql create table d5.t1 using d5.st tags(1); sql create table d5.t2 using d5.st tags(1); sql create table d5.t3 using d5.st tags(1); sql insert into d5.t1 values(now, 1); -sql drop table d5.t1; +# sql drop table d5.t1; sql drop database d5; sql show databases; -if $rows != 0 then +if $rows != 1 then return -1 endi diff --git a/tests/script/general/stable/show.sim b/tests/script/tsim/stable/show.sim similarity index 63% rename from tests/script/general/stable/show.sim rename to tests/script/tsim/stable/show.sim index 5fe05b41eb..8ebb765a78 100644 --- a/tests/script/general/stable/show.sim +++ b/tests/script/tsim/stable/show.sim @@ -10,20 +10,37 @@ sql connect print ======================== create stable sql create database d1 +sql use d1 $x = 0 while $x < 128 $tb = d1.s . $x sql create table $tb (ts timestamp, i int) tags (j int) $x = $x + 1 -endw +endw + +print ======================== describe stables +# TODO : create stable error +$m = 0 +while $m < 128 + $tb = s . $m + $filter = ' . $tb + $filter = $filter . ' + sql show stables like $filter + # print sql : show stables like $filter ==> $rows + if $rows != 1 then + return -1 + endi + $m = $m + 1 +endw + print ======================== show stables sql show d1.stables print num of stables is $rows -if $rows != 128 then +if $rows != 128 then return -1 endi @@ -34,15 +51,15 @@ while $x < 424 $tb = d1.t . $x sql create table $tb using d1.s0 tags( $x ) $x = $x + 1 -endw +endw print ======================== show stables sql show d1.tables print num of tables is $rows -if $rows != 424 then +if $rows != 424 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/values.sim b/tests/script/tsim/stable/values.sim new file mode 100644 index 0000000000..e5e3118e12 --- /dev/null +++ b/tests/script/tsim/stable/values.sim @@ -0,0 +1,121 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +sql create database vdb0 +sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +sql create table vdb0.vtb00 using vdb0.mt tags( 0 ) +sql create table vdb0.vtb01 using vdb0.mt tags( 0 ) + +sql create database vdb1 +sql create table vdb1.mt (ts timestamp, tbcol int) TAGS(tgcol int) +# sql_error create table vdb1.vtb10 using vdb0.mt tags( 1 ) +# sql_error create table vdb1.vtb11 using vdb0.mt tags( 1 ) +sql create table vdb1.vtb10 using vdb1.mt tags( 1 ) +sql create table vdb1.vtb11 using vdb1.mt tags( 1 ) + +sql create database vdb2 +sql create table vdb2.mt (ts timestamp, tbcol int) TAGS(tgcol int) +# sql_error create table vdb2.vtb20 using vdb0.mt tags( 2 ) +# sql_error create table vdb2.vtb21 using vdb0.mt tags( 2 ) +sql create table vdb2.vtb20 using vdb2.mt tags( 2 ) +sql create table vdb2.vtb21 using vdb2.mt tags( 2 ) + +sql create database vdb3 +sql create table vdb3.mt (ts timestamp, tbcol int) TAGS(tgcol int) +# sql_error create table vdb3.vtb20 using vdb0.mt tags( 2 ) +# sql_error create table vdb3.vtb21 using vdb0.mt tags( 2 ) +sql create table vdb3.vtb30 using vdb3.mt tags( 3 ) +sql create table vdb3.vtb31 using vdb3.mt tags( 3 ) + +print =============== step2 +sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +# sql select * from vdb0.mt +sql select ts from vdb0.mt + +if $rows != 6 then + return -1 +endi + +print =============== step3 +sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +# TODO : select * from stable +# sql select * from vdb0.mt +sql select ts from vdb0.mt + +if $rows != 12 then + return -1 +endi + +print =============== step4 +# TODO : insert into diffrent table +# sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70) +# sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71) +# sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72) +# sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73) +# # sql select * from vdb0.mt +# sql select ts from vdb0.mt +# +# if $rows != 16 then +# return -1 +# endi + +print =============== step5 +# sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70) +# sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71) +# sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72) +# sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73) +# # sql select * from vdb0.mt +# sql select ts from vdb0.mt +# +# if $rows != 17 then +# return -1 +# endi + +print =============== step6 +# sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100) +# sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100) +# +# # sql select * from vdb0.mt +# sql select ts from vdb0.mt +# +# if $rows != 21 then +# return -1 +# endi + +print =============== step7 +# sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110) +# sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110) +# +# # sql select * from vdb0.mt +# sql select ts from vdb0.mt +# +# if $rows != 25 then +# return -1 +# endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/vnode3.sim b/tests/script/tsim/stable/vnode3.sim new file mode 100644 index 0000000000..2d408b4191 --- /dev/null +++ b/tests/script/tsim/stable/vnode3.sim @@ -0,0 +1,181 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = v3_db +$tbPrefix = v3_tb +$mtPrefix = v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 2 then + return -1 +endi + + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +# TODO : where condition +# sql select count(tbcol) from $tb where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 5 then +# return -1 +# endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data00 +if $data00 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step6 +# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +# print ===> $data00 +# if $data00 != 1 then +# return -1 +# endi +# if $rows != 5 then +# return -1 +#endi + +print =============== step7 +# TODO : count(*) err +# sql select count(*) from $mt +# print ===> $data00 +# if $data00 != $totalNum then +# return -1 +# endi +# +# sql select count(tbcol) from $mt +# print ===> $data00 +# if $data00 != $totalNum then +# return -1 +# endi + +print =============== step8 +# sql select count(tbcol) as c from $mt where ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 50 then +# return -1 +# endi + +# sql select count(tbcol) as c from $mt where tgcol < 5 +# print ===> $data00 +# if $data00 != 100 then +# return -1 +# endi + +# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +# print ===> $data00 +# if $data00 != 25 then +# return -1 +# endi + +print =============== step9 +# sql select count(tbcol) as b from $mt interval(1m) +# print ===> $data00 +# if $data00 != 10 then +# return -1 +# endi +# +# sql select count(tbcol) as b from $mt interval(1d) +# print ===> $data00 +# if $data00 != 200 then +# return -1 +# endi + +print =============== step10 +# sql select count(tbcol) as b from $mt group by tgcol +# print ===> $data00 +# if $data00 != $rowNum then +# return -1 +# endi +# +# if $rows != $tbNum then +# return -1 +# endi + +print =============== step11 +# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +# print ===> $data01 +# if $data01 != 1 then +# return -1 +# endi +# if $rows != 50 then +# return -1 +# endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/testCaseSuite.sim b/tests/script/tsim/testCaseSuite.sim index bf184f8794..4245529343 100644 --- a/tests/script/tsim/testCaseSuite.sim +++ b/tests/script/tsim/testCaseSuite.sim @@ -1,6 +1,7 @@ run tsim/user/basic1.sim +run tsim/db/alter_option.sim run tsim/db/basic1.sim run tsim/db/basic2.sim run tsim/db/basic3.sim @@ -20,6 +21,7 @@ run tsim/insert/null.sim run tsim/query/interval.sim run tsim/query/interval-offset.sim +run tsim/query/scalarFunction.sim run tsim/show/basic.sim diff --git a/tests/script/tsim/tmq/basic1.sim b/tests/script/tsim/tmq/basic1.sim index fe6a7a0660..cfcb1ac992 100644 --- a/tests/script/tsim/tmq/basic1.sim +++ b/tests/script/tsim/tmq/basic1.sim @@ -66,15 +66,15 @@ print =============== will support: * from stb; function from stb/ctb sql create topic topic_stb_column as select ts, c1, c3 from stb #sql create topic topic_stb_all as select * from stb -#sql create topic topic_stb_function as select ts, abs(c1), sina(c2) from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb sql create topic topic_ctb_column as select ts, c1, c3 from ct0 sql create topic topic_ctb_all as select * from ct0 -#sql create topic topic_ctb_function as select ts, abs(c1), sina(c2) from ct0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0 sql create topic topic_ntb_column as select ts, c1, c3 from ntb sql create topic topic_ntb_all as select * from ntb -#sql create topic topic_ntb_function as select ts, abs(c1), sina(c2) from ntb +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb sql show tables if $rows != 3 then @@ -147,6 +147,13 @@ endi # return -1 #endi +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +print cmd result----> $system_content +if $system_content != @{consume success: 20, 0}@ then + return -1 +endi + print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" print cmd result----> $system_content @@ -161,6 +168,13 @@ if $system_content != @{consume success: 10, 0}@ then return -1 endi +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +print cmd result----> $system_content +if $system_content != @{consume success: 10, 0}@ then + return -1 +endi + print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" print cmd result----> $system_content @@ -175,6 +189,13 @@ if $system_content != @{consume success: 20, 0}@ then return -1 endi +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +print cmd result----> $system_content +if $system_content != @{consume success: 20, 0}@ then + return -1 +endi + print =============== create database , vgroup 4 $dbNamme = d1 sql create database $dbNamme vgroups 4 diff --git a/tests/script/tsim/tmq/multiTopic.sim b/tests/script/tsim/tmq/multiTopic.sim new file mode 100644 index 0000000000..cd977e5909 --- /dev/null +++ b/tests/script/tsim/tmq/multiTopic.sim @@ -0,0 +1,224 @@ +#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406 +# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN +# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5; +# +# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval). +# +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## +######## This test case include scene2 and scene4 +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +$loop_cnt = 0 +$vgroups = 1 +$dbNamme = d0 +loop_vgroups: +print =============== create database $dbNamme vgroups $vgroups +sql create database $dbNamme vgroups $vgroups +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +if $loop_cnt == 0 then + if $rows != 2 then + return -1 + endi + if $data02 != 1 then # vgroups + print vgroups: $data02 + return -1 + endi +else + if $rows != 3 then + return -1 + endi + if $data00 == d1 then + if $data02 != 4 then # vgroups + print vgroups: $data02 + return -1 + endi + else + if $data12 != 4 then # vgroups + print vgroups: $data12 + return -1 + endi + endi +endi + +sql use $dbNamme + +print =============== create super table +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +$tbPrefix = ct +$tbNum = 100 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $i = $i + 1 +endw + +print =============== create normal table +sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10)) + +print =============== create multi topics. notes: now only support: +print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb +print =============== will support: * from stb + +sql create topic topic_stb_column as select ts, c1, c3 from stb +#sql create topic topic_stb_all as select * from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb + +sql create topic topic_ctb_column as select ts, c1, c3 from ct0 +sql create topic topic_ctb_all as select * from ct0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0 + +sql create topic topic_ntb_column as select ts, c1, c3 from ntb +sql create topic topic_ntb_all as select * from ntb +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb + +sql show tables +if $rows != 101 then + return -1 +endi + +print =============== insert data +$rowNum = 100 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + while $x < $rowNum + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + sql insert into $tb values ($tstart , $c , $x , $binary ) + sql insert into ntb values ($tstart , $c , $x , $binary ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 1640966400000 +endw + +#root@trd02 /home $ tmq_sim --help +# -c Configuration directory, default is +# -d The name of the database for cosumer, no default +# -t The topic string for cosumer, no default +# -k The key-value string for cosumer, no default +# -g showMsgFlag, default is 0 +# + +$totalMsgCnt = $rowNum * $tbNum +print inserted totalMsgCnt: $totalMsgCnt + +# supported key: +# group.id: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# td.connect.user:root +# td.connect.pass:taosdata +# td.connect.port:6030 +# td.connect.db:db + +$numOfTopics = 2 +$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" +#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 20000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$numOfTopics = 3 +$totalMsgCntOfmultiTopics = $rowNum * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 300, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$numOfTopics = 3 +$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 30000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +if $loop_cnt == 0 then + $loop_cnt = 1 + $vgroups = 4 + $dbNamme = d1 + goto loop_vgroups +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/oneTopic.sim b/tests/script/tsim/tmq/oneTopic.sim new file mode 100644 index 0000000000..8e8d00977c --- /dev/null +++ b/tests/script/tsim/tmq/oneTopic.sim @@ -0,0 +1,264 @@ +#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406 +# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN +# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5; +# +# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval). +# +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## +######## This test case include scene1 and scene3 +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +$loop_cnt = 0 +$vgroups = 1 +$dbNamme = d0 +loop_vgroups: +print =============== create database $dbNamme vgroups $vgroups +sql create database $dbNamme vgroups $vgroups +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +if $loop_cnt == 0 then + if $rows != 2 then + return -1 + endi + if $data02 != 1 then # vgroups + print vgroups: $data02 + return -1 + endi +else + if $rows != 3 then + return -1 + endi + if $data00 == d1 then + if $data02 != 4 then # vgroups + print vgroups: $data02 + return -1 + endi + else + if $data12 != 4 then # vgroups + print vgroups: $data12 + return -1 + endi + endi +endi + +sql use $dbNamme + +print =============== create super table +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +$tbPrefix = ct +$tbNum = 100 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $i = $i + 1 +endw + +print =============== create normal table +sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10)) + +print =============== create multi topics. notes: now only support: +print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb +print =============== will support: * from stb + +sql create topic topic_stb_column as select ts, c1, c3 from stb +#sql create topic topic_stb_all as select * from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb + +sql create topic topic_ctb_column as select ts, c1, c3 from ct0 +sql create topic topic_ctb_all as select * from ct0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0 + +sql create topic topic_ntb_column as select ts, c1, c3 from ntb +sql create topic topic_ntb_all as select * from ntb +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb + +sql show tables +if $rows != 101 then + return -1 +endi + +print =============== insert data +$rowNum = 100 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + while $x < $rowNum + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + sql insert into $tb values ($tstart , $c , $x , $binary ) + sql insert into ntb values ($tstart , $c , $x , $binary ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 1640966400000 +endw + +#root@trd02 /home $ tmq_sim --help +# -c Configuration directory, default is +# -d The name of the database for cosumer, no default +# -t The topic string for cosumer, no default +# -k The key-value string for cosumer, no default +# -g showMsgFlag, default is 0 +# + +$totalMsgCnt = $rowNum * $tbNum +print inserted totalMsgCnt: $totalMsgCnt + +# supported key: +# group.id: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# td.connect.user:root +# td.connect.pass:taosdata +# td.connect.port:6030 +# td.connect.db:db + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCnt +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" +#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" +#print cmd result----> $system_content +##if $system_content != @{consume success: 10000, 0}@ then +#if $system_content != $expect_result then +# return -1 +#endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $rowNum +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCnt +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +if $loop_cnt == 0 then + $loop_cnt = 1 + $vgroups = 4 + $dbNamme = d1 + goto loop_vgroups +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 4d3108500e..38264331c1 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -226,7 +226,7 @@ void loop_consume(tmq_t* tmq) { int32_t totalRows = 0; int32_t skipLogNum = 0; while (running) { - tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, 1); + tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, 3000); if (tmqMsg) { totalMsgs++; diff --git a/tools/taos-tools b/tools/taos-tools index f36b07f710..33cdfe4f90 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit f36b07f710d661dca88fdd70e73b5e3e16a960e0 +Subproject commit 33cdfe4f90a209f105c1b6091439798a9cde1e93