diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 67611d9563..b7fb988cec 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -54,16 +54,13 @@ 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 { @@ -96,6 +93,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) ; static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) { // WARNING: do not use info.numOfCols, @@ -103,13 +101,7 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) { int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock); for (int32_t i = 0; i < numOfOutput; ++i) { SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); - if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { - taosMemoryFreeClear(pColInfoData->varmeta.offset); - } else { - taosMemoryFreeClear(pColInfoData->nullbitmap); - } - - taosMemoryFreeClear(pColInfoData->pData); + colDataDestroy(pColInfoData); } taosArrayDestroy(pBlock->pDataBlock); diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 20d743046f..2d5fba7368 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -101,6 +101,54 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u ((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \ : ((p1_)->pData + ((r_) * (p1_)->info.bytes))) +static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uint32_t currentRow) { + // There is a placehold for each NULL value of binary or nchar type. + if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { + pColumnInfoData->varmeta.offset[currentRow] = -1; // it is a null value of VAR type. + } else { + colDataSetNull_f(pColumnInfoData->nullbitmap, currentRow); + } + + pColumnInfoData->hasNull = true; +} + +static FORCE_INLINE int32_t colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_TINYINT || + pColumnInfoData->info.type == TSDB_DATA_TYPE_UTINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_BOOL); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(int8_t*)p = *(int8_t*)v; +} + +static FORCE_INLINE int32_t colDataAppendInt16(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int16_t* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_SMALLINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_USMALLINT); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(int16_t*)p = *(int16_t*)v; +} + +static FORCE_INLINE int32_t colDataAppendInt32(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int32_t* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_INT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UINT); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(int32_t*)p = *(int32_t*)v; +} + +static FORCE_INLINE int32_t colDataAppendInt64(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int64_t* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_BIGINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UBIGINT); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(int64_t*)p = *(int64_t*)v; +} + +static FORCE_INLINE int32_t colDataAppendFloat(SColumnInfoData* pColumnInfoData, uint32_t currentRow, float* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_FLOAT); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(float*)p = *(float*)v; +} + +static FORCE_INLINE int32_t colDataAppendDouble(SColumnInfoData* pColumnInfoData, uint32_t currentRow, double* v) { + ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_DOUBLE); + char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; + *(double*)p = *(double*)v; +} + int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull); int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource, uint32_t numOfRow2); diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index a2899ead8e..4a3ce2db86 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -63,7 +63,7 @@ extern "C" { typedef struct { col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1)) int32_t type : 8; // column type - int32_t bytes : 24; // column bytes (restore to int32_t in case of misuse) + int32_t bytes : 24; // column bytes (0~16M) int32_t sma : 8; // block SMA: 0, no SMA, 1, sum/min/max, 2, ... int32_t offset : 24; // point offset in STpRow after the header part. } STColumn; @@ -81,12 +81,12 @@ typedef struct { // ----------------- TSDB SCHEMA DEFINITION typedef struct { - int32_t version; // version - int32_t numOfCols; // Number of columns appended - int32_t tlen; // maximum length of a STpRow without the header part (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + - // (bytes)) - uint16_t flen; // First part length in a STpRow after the header part - uint16_t vlen; // pure value part length, excluded the overhead (bytes only) + int32_t numOfCols; // Number of columns appended + schema_ver_t version; // schema version + uint16_t flen; // First part length in a STpRow after the header part + int32_t vlen; // pure value part length, excluded the overhead (bytes only) + int32_t tlen; // maximum length of a STpRow without the header part + // (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + (bytes)) STColumn columns[]; } STSchema; @@ -120,13 +120,13 @@ static FORCE_INLINE STColumn *tdGetColOfID(STSchema *pSchema, int16_t colId) { // ----------------- SCHEMA BUILDER DEFINITION typedef struct { - int32_t tCols; - int32_t nCols; - int32_t tlen; - uint16_t flen; - uint16_t vlen; - int32_t version; - STColumn *columns; + int32_t tCols; + int32_t nCols; + schema_ver_t version; + uint16_t flen; + int32_t vlen; + int32_t tlen; + STColumn *columns; } STSchemaBuilder; #define TD_VTYPE_BITS 2 // val type @@ -136,9 +136,9 @@ typedef struct { #define TD_BITMAP_BYTES(cnt) (ceil((double)cnt / TD_VTYPE_PARTS)) #define TD_BIT_TO_BYTES(cnt) (ceil((double)cnt / 8)) -int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version); +int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version); void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder); -void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version); +void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version); int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, col_id_t colId, col_bytes_t bytes); STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder); diff --git a/include/common/tmsg.h b/include/common/tmsg.h index bdb6181884..e4b3ce722b 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -363,7 +363,7 @@ typedef struct { int8_t createType; int8_t superUser; // denote if it is a super user or not char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_USET_PASSWORD_LEN]; } SCreateUserReq; int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq); @@ -373,7 +373,7 @@ typedef struct { int8_t alterType; int8_t superUser; char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_USET_PASSWORD_LEN]; char dbname[TSDB_DB_FNAME_LEN]; } SAlterUserReq; @@ -565,8 +565,10 @@ typedef struct { SArray* pVgroupInfos; // Array of SVgroupInfo } SUseDbRsp; -int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp); +int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp); int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp); +int32_t tSerializeSUseDbRspImp(SCoder* pEncoder, const SUseDbRsp* pRsp); +int32_t tDeserializeSUseDbRspImp(SCoder* pDecoder, SUseDbRsp* pRsp); void tFreeSUsedbRsp(SUseDbRsp* pRsp); typedef struct { @@ -799,7 +801,10 @@ typedef struct SVgroupInfo { uint32_t hashBegin; uint32_t hashEnd; SEpSet epSet; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + union { + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t taskId; // used in stream + }; } SVgroupInfo; typedef struct { diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index da34ca6253..c5904904ab 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -82,102 +82,111 @@ #define TK_SINGLE_STABLE 64 #define TK_STREAM_MODE 65 #define TK_RETENTIONS 66 -#define TK_FILE_FACTOR 67 -#define TK_NK_FLOAT 68 -#define TK_TABLE 69 -#define TK_NK_LP 70 -#define TK_NK_RP 71 -#define TK_STABLE 72 -#define TK_ADD 73 -#define TK_COLUMN 74 -#define TK_MODIFY 75 -#define TK_RENAME 76 -#define TK_TAG 77 -#define TK_SET 78 -#define TK_NK_EQ 79 -#define TK_USING 80 -#define TK_TAGS 81 -#define TK_NK_DOT 82 -#define TK_NK_COMMA 83 -#define TK_COMMENT 84 -#define TK_BOOL 85 -#define TK_TINYINT 86 -#define TK_SMALLINT 87 -#define TK_INT 88 -#define TK_INTEGER 89 -#define TK_BIGINT 90 -#define TK_FLOAT 91 -#define TK_DOUBLE 92 -#define TK_BINARY 93 -#define TK_TIMESTAMP 94 -#define TK_NCHAR 95 -#define TK_UNSIGNED 96 -#define TK_JSON 97 -#define TK_VARCHAR 98 -#define TK_MEDIUMBLOB 99 -#define TK_BLOB 100 -#define TK_VARBINARY 101 -#define TK_DECIMAL 102 -#define TK_SMA 103 -#define TK_ROLLUP 104 -#define TK_SHOW 105 -#define TK_DATABASES 106 -#define TK_TABLES 107 -#define TK_STABLES 108 -#define TK_MNODES 109 -#define TK_MODULES 110 -#define TK_QNODES 111 -#define TK_FUNCTIONS 112 -#define TK_INDEXES 113 -#define TK_FROM 114 -#define TK_LIKE 115 -#define TK_INDEX 116 -#define TK_FULLTEXT 117 -#define TK_FUNCTION 118 -#define TK_INTERVAL 119 -#define TK_TOPIC 120 -#define TK_AS 121 -#define TK_NK_BOOL 122 -#define TK_NK_VARIABLE 123 -#define TK_BETWEEN 124 -#define TK_IS 125 -#define TK_NULL 126 -#define TK_NK_LT 127 -#define TK_NK_GT 128 -#define TK_NK_LE 129 -#define TK_NK_GE 130 -#define TK_NK_NE 131 -#define TK_MATCH 132 -#define TK_NMATCH 133 -#define TK_IN 134 -#define TK_JOIN 135 -#define TK_INNER 136 -#define TK_SELECT 137 -#define TK_DISTINCT 138 -#define TK_WHERE 139 -#define TK_PARTITION 140 -#define TK_BY 141 -#define TK_SESSION 142 -#define TK_STATE_WINDOW 143 -#define TK_SLIDING 144 -#define TK_FILL 145 -#define TK_VALUE 146 -#define TK_NONE 147 -#define TK_PREV 148 -#define TK_LINEAR 149 -#define TK_NEXT 150 -#define TK_GROUP 151 -#define TK_HAVING 152 -#define TK_ORDER 153 -#define TK_SLIMIT 154 -#define TK_SOFFSET 155 -#define TK_LIMIT 156 -#define TK_OFFSET 157 -#define TK_ASC 158 -#define TK_DESC 159 -#define TK_NULLS 160 -#define TK_FIRST 161 -#define TK_LAST 162 +#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_COMMENT 82 +#define TK_BOOL 83 +#define TK_TINYINT 84 +#define TK_SMALLINT 85 +#define TK_INT 86 +#define TK_INTEGER 87 +#define TK_BIGINT 88 +#define TK_FLOAT 89 +#define TK_DOUBLE 90 +#define TK_BINARY 91 +#define TK_TIMESTAMP 92 +#define TK_NCHAR 93 +#define TK_UNSIGNED 94 +#define TK_JSON 95 +#define TK_VARCHAR 96 +#define TK_MEDIUMBLOB 97 +#define TK_BLOB 98 +#define TK_VARBINARY 99 +#define TK_DECIMAL 100 +#define TK_SMA 101 +#define TK_ROLLUP 102 +#define TK_FILE_FACTOR 103 +#define TK_NK_FLOAT 104 +#define TK_DELAY 105 +#define TK_SHOW 106 +#define TK_DATABASES 107 +#define TK_TABLES 108 +#define TK_STABLES 109 +#define TK_MNODES 110 +#define TK_MODULES 111 +#define TK_QNODES 112 +#define TK_FUNCTIONS 113 +#define TK_INDEXES 114 +#define TK_FROM 115 +#define TK_LIKE 116 +#define TK_INDEX 117 +#define TK_FULLTEXT 118 +#define TK_FUNCTION 119 +#define TK_INTERVAL 120 +#define TK_TOPIC 121 +#define TK_AS 122 +#define TK_NK_BOOL 123 +#define TK_NK_VARIABLE 124 +#define TK_NK_UNDERLINE 125 +#define TK_ROWTS 126 +#define TK_TBNAME 127 +#define TK_QSTARTTS 128 +#define TK_QENDTS 129 +#define TK_WSTARTTS 130 +#define TK_WENDTS 131 +#define TK_WDURATION 132 +#define TK_BETWEEN 133 +#define TK_IS 134 +#define TK_NULL 135 +#define TK_NK_LT 136 +#define TK_NK_GT 137 +#define TK_NK_LE 138 +#define TK_NK_GE 139 +#define TK_NK_NE 140 +#define TK_MATCH 141 +#define TK_NMATCH 142 +#define TK_IN 143 +#define TK_JOIN 144 +#define TK_INNER 145 +#define TK_SELECT 146 +#define TK_DISTINCT 147 +#define TK_WHERE 148 +#define TK_PARTITION 149 +#define TK_BY 150 +#define TK_SESSION 151 +#define TK_STATE_WINDOW 152 +#define TK_SLIDING 153 +#define TK_FILL 154 +#define TK_VALUE 155 +#define TK_NONE 156 +#define TK_PREV 157 +#define TK_LINEAR 158 +#define TK_NEXT 159 +#define TK_GROUP 160 +#define TK_HAVING 161 +#define TK_ORDER 162 +#define TK_SLIMIT 163 +#define TK_SOFFSET 164 +#define TK_LIMIT 165 +#define TK_OFFSET 166 +#define TK_ASC 167 +#define TK_DESC 168 +#define TK_NULLS 169 +#define TK_FIRST 170 +#define TK_LAST 171 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 87dc752703..19442af206 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -30,6 +30,7 @@ typedef uint8_t TDRowValT; typedef int16_t col_id_t; typedef int8_t col_type_t; typedef int32_t col_bytes_t; +typedef uint16_t schema_ver_t; #pragma pack(push, 1) typedef struct { diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 6c4774c3be..e7895bd972 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -27,16 +27,22 @@ extern "C" { struct SqlFunctionCtx; struct SResultRowEntryInfo; -typedef struct SFunctionNode SFunctionNode; +struct SFunctionNode; +typedef struct SScalarParam SScalarParam; typedef struct SFuncExecEnv { int32_t calcMemSize; } SFuncExecEnv; -typedef bool (*FExecGetEnv)(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +typedef bool (*FExecGetEnv)(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); typedef bool (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); typedef void (*FExecProcess)(struct SqlFunctionCtx *pCtx); typedef void (*FExecFinalize)(struct SqlFunctionCtx *pCtx); +typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); + +typedef struct SScalarFuncExecFuncs { + FScalarExecProcess process; +} SScalarFuncExecFuncs; typedef struct SFuncExecFuncs { FExecGetEnv getEnv; @@ -191,6 +197,7 @@ typedef struct SqlFunctionCtx { SPoint1 start; SPoint1 end; SFuncExecFuncs fpSet; + SScalarFuncExecFuncs sfp; } SqlFunctionCtx; enum { @@ -203,7 +210,7 @@ enum { }; typedef struct tExprNode { - uint8_t nodeType; + int32_t nodeType; union { struct { int32_t optr; // binary operator @@ -219,7 +226,7 @@ typedef struct tExprNode { char functionName[FUNCTIONS_NAME_MAX_LENGTH]; // todo refactor int32_t functionId; int32_t num; - SFunctionNode *pFunctNode; + struct SFunctionNode *pFunctNode; // Note that the attribute of pChild is not the parameter of function, it is the columns that involved in the // calculation instead. // E.g., Cov(col1, col2), the column information, w.r.t. the col1 and col2, is kept in pChild nodes. @@ -227,6 +234,10 @@ typedef struct tExprNode { // operator and is kept in the attribute of _node. struct tExprNode **pChild; } _function; + + struct { + struct SNode* pRootNode; + } _optrRoot; }; } tExprNode; @@ -250,25 +261,11 @@ typedef struct SAggFunctionInfo { int32_t (*dataReqFunc)(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId); } SAggFunctionInfo; -typedef struct SScalarParam { - void *data; - union { - SColumnInfoData *columnData; - void *data; - } orig; - char *bitmap; - bool dataInBlock; - int32_t num; - int32_t type; - int32_t bytes; -} SScalarParam; - -typedef struct SScalarFunctionInfo { - char name[FUNCTIONS_NAME_MAX_LENGTH]; - int8_t type; // scalar function or aggregation function - uint32_t functionId; // index of scalar function - void (*process)(struct SScalarParam* pOutput, size_t numOfInput, const struct SScalarParam *pInput); -} SScalarFunctionInfo; +struct SScalarParam { + SColumnInfoData *columnData; + SHashObj *pHashFilter; + int32_t numOfRows; +}; typedef struct SMultiFunctionsDesc { bool stableQuery; diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 85a9cd0b23..7d46b543cb 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -96,20 +96,22 @@ typedef enum EFunctionType { FUNCTION_TYPE_SERVER_SERSION, FUNCTION_TYPE_SERVER_STATUS, FUNCTION_TYPE_CURRENT_USER, - FUNCTION_TYPE_USER + FUNCTION_TYPE_USER, + + // pseudo column function + FUNCTION_TYPE_ROWTS = 3500, + FUNCTION_TYPE_TBNAME, + FUNCTION_TYPE_QSTARTTS, + FUNCTION_TYPE_QENDTS, + FUNCTION_TYPE_WSTARTTS, + FUNCTION_TYPE_WENDTS, + FUNCTION_TYPE_WDURATION } EFunctionType; struct SqlFunctionCtx; struct SResultRowEntryInfo; struct STimeWindow; -typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); - -typedef struct SScalarFuncExecFuncs { - FScalarExecProcess process; -} SScalarFuncExecFuncs; - - int32_t fmFuncMgtInit(); void fmFuncMgtDestroy(); @@ -125,6 +127,8 @@ bool fmIsStringFunc(int32_t funcId); bool fmIsDatetimeFunc(int32_t funcId); bool fmIsTimelineFunc(int32_t funcId); bool fmIsTimeorderFunc(int32_t funcId); +bool fmIsWindowPseudoColumnFunc(int32_t funcId); +bool fmIsWindowClauseFunc(int32_t funcId); int32_t fmFuncScanType(int32_t funcId); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 48a3a9bda8..a03c496b4f 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -41,6 +41,7 @@ typedef struct SDatabaseOptions { int32_t numOfVgroups; int8_t singleStable; int8_t streamMode; + SNodeList* pRetentions; } SDatabaseOptions; typedef struct SCreateDatabaseStmt { @@ -73,6 +74,9 @@ typedef struct STableOptions { int32_t ttl; char comments[TSDB_STB_COMMENT_LEN]; SNodeList* pSma; + SNodeList* pFuncs; + float filesFactor; + int32_t delay; } STableOptions; typedef struct SColumnDefNode { diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 12c03afcb6..c6d17ef65c 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -40,7 +40,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type); int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type); int32_t vectorGetConvertType(int32_t type1, int32_t type2); -int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut); +int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut); int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 8be9bbbebd..02fe591a09 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -72,8 +72,9 @@ typedef struct { } STaskDispatcherFixedEp; typedef struct { - int8_t hashMethod; - SArray* info; + // int8_t hashMethod; + char stbFullName[TSDB_TABLE_FNAME_LEN]; + SUseDbRsp dbInfo; } STaskDispatcherShuffle; typedef struct { @@ -135,7 +136,6 @@ typedef struct { int8_t sinkType; int8_t dispatchType; int16_t dispatchMsgType; - int32_t downstreamTaskId; int32_t nodeId; SEpSet epSet; diff --git a/include/util/tdef.h b/include/util/tdef.h index 6c5208ec00..193be4a3e6 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -369,6 +369,18 @@ typedef enum ELogicConditionType { #define TSDB_MAX_DB_CACHE_LAST_ROW 3 #define TSDB_DEFAULT_CACHE_LAST_ROW 0 +#define TSDB_MIN_DB_STREAM_MODE 0 +#define TSDB_MAX_DB_STREAM_MODE 1 +#define TSDB_DEFAULT_DB_STREAM_MODE 0 + +#define TSDB_MIN_DB_FILE_FACTOR 0 +#define TSDB_MAX_DB_FILE_FACTOR 1 +#define TSDB_DEFAULT_DB_FILE_FACTOR 0.1 + +#define TSDB_MIN_DB_DELAY 1 +#define TSDB_MAX_DB_DELAY 10 +#define TSDB_DEFAULT_DB_DELAY 2 + #define TSDB_MAX_JOIN_TABLE_NUM 10 #define TSDB_MAX_UNION_CLAUSE 5 diff --git a/include/util/tqueue.h b/include/util/tqueue.h index 3bccc7404b..70db65d50f 100644 --- a/include/util/tqueue.h +++ b/include/util/tqueue.h @@ -56,7 +56,7 @@ void taosCloseQueue(STaosQueue *queue); void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp); void *taosAllocateQitem(int32_t size); void taosFreeQitem(void *pItem); -int32_t taosWriteQitem(STaosQueue *queue, void *pItem); +void taosWriteQitem(STaosQueue *queue, void *pItem); int32_t taosReadQitem(STaosQueue *queue, void **ppItem); bool taosQueueEmpty(STaosQueue *queue); int32_t taosQueueSize(STaosQueue *queue); diff --git a/include/util/tworker.h b/include/util/tworker.h index 92d474c885..3545aeed89 100644 --- a/include/util/tworker.h +++ b/include/util/tworker.h @@ -70,8 +70,8 @@ void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue); typedef struct { const char *name; - int32_t minNum; - int32_t maxNum; + int32_t min; + int32_t max; FItem fp; void *param; } SSingleWorkerCfg; @@ -84,7 +84,7 @@ typedef struct { typedef struct { const char *name; - int32_t maxNum; + int32_t max; FItems fp; void *param; } SMultiWorkerCfg; diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 7d7e51bc27..49cb12cccd 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -235,7 +235,7 @@ void initMsgHandleFp(); TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, uint16_t port); -void* doFetchRow(SRequestObj* pRequest); +void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr); int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 6e65a4267f..d8017a8727 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -545,7 +545,33 @@ TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, c return taos_connect(ipStr, userStr, passStr, dbStr, port); } -void* doFetchRow(SRequestObj* pRequest) { +static void doSetOneRowPtr(SReqResultInfo* pResultInfo) { + for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) { + SResultColumn* pCol = &pResultInfo->pCol[i]; + + int32_t type = pResultInfo->fields[i].type; + int32_t bytes = pResultInfo->fields[i].bytes; + + if (IS_VAR_DATA_TYPE(type)) { + if (pCol->offset[pResultInfo->current] != -1) { + char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData; + + pResultInfo->length[i] = varDataLen(pStart); + pResultInfo->row[i] = varDataVal(pStart); + } else { + pResultInfo->row[i] = NULL; + } + } else { + if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) { + pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current; + } else { + pResultInfo->row[i] = NULL; + } + } + } +} + +void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { assert(pRequest != NULL); SReqResultInfo* pResultInfo = &pRequest->body.resInfo; @@ -555,17 +581,20 @@ void* doFetchRow(SRequestObj* pRequest) { if (pRequest->type == TDMT_VND_QUERY) { // All data has returned to App already, no need to try again if (pResultInfo->completed) { + pResultInfo->numOfRows = 0; return NULL; } SReqResultInfo* pResInfo = &pRequest->body.resInfo; pRequest->code = schedulerFetchRows(pRequest->body.queryJob, (void**)&pResInfo->pData); if (pRequest->code != TSDB_CODE_SUCCESS) { + pResultInfo->numOfRows = 0; return NULL; } pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData); if (pRequest->code != TSDB_CODE_SUCCESS) { + pResultInfo->numOfRows = 0; return NULL; } @@ -633,41 +662,11 @@ void* doFetchRow(SRequestObj* pRequest) { } _return: - - for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) { - SResultColumn* pCol = &pResultInfo->pCol[i]; - - int32_t type = pResultInfo->fields[i].type; - int32_t bytes = pResultInfo->fields[i].bytes; - - if (IS_VAR_DATA_TYPE(type)) { - if (pCol->offset[pResultInfo->current] != -1) { - char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData; - - pResultInfo->length[i] = varDataLen(pStart); - pResultInfo->row[i] = varDataVal(pStart); - - if (type == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(pResultInfo->convertBuf[i])); - ASSERT(len <= bytes); - - pResultInfo->row[i] = varDataVal(pResultInfo->convertBuf[i]); - varDataSetLen(pResultInfo->convertBuf[i], len); - pResultInfo->length[i] = len; - } - } else { - pResultInfo->row[i] = NULL; - } - } else { - if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) { - pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current; - } else { - pResultInfo->row[i] = NULL; - } - } + if (setupOneRowPtr) { + doSetOneRowPtr(pResultInfo); + pResultInfo->current += 1; } - pResultInfo->current += 1; return pResultInfo->row; } @@ -681,12 +680,6 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - - for(int32_t i = 0; i < pResInfo->numOfCols; ++i) { - if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) { - pResInfo->convertBuf[i] = taosMemoryCalloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes)); - } - } } return TSDB_CODE_SUCCESS; @@ -723,6 +716,35 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 pStart += colLength[i]; } + for (int32_t i = 0; i < numOfCols; ++i) { + int32_t type = pResultInfo->fields[i].type; + int32_t bytes = pResultInfo->fields[i].bytes; + + if (type == TSDB_DATA_TYPE_NCHAR) { + char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pResultInfo->convertBuf[i] = p; + + SResultColumn* pCol = &pResultInfo->pCol[i]; + for (int32_t j = 0; j < numOfRows; ++j) { + if (pCol->offset[j] != -1) { + pStart = pCol->offset[j] + pCol->pData; + + int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p)); + ASSERT(len <= bytes); + + varDataSetLen(p, len); + pCol->offset[j] = (p - pResultInfo->convertBuf[i]); + p += (len + VARSTR_HEADER_SIZE); + } + } + + pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i]; + } + } + return TSDB_CODE_SUCCESS; } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 09a0233e04..a84aebabc8 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -138,20 +138,20 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { return taos_query_l(taos, sql, (int32_t) strlen(sql)); } -TAOS_ROW taos_fetch_row(TAOS_RES *pRes) { - if (pRes == NULL) { +TAOS_ROW taos_fetch_row(TAOS_RES *res) { + if (res == NULL) { return NULL; } - SRequestObj *pRequest = (SRequestObj *) pRes; + SRequestObj *pRequest = (SRequestObj *) res; if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT || pRequest->code != TSDB_CODE_SUCCESS || - taos_num_fields(pRes) == 0) { + taos_num_fields(res) == 0) { return NULL; } - return doFetchRow(pRequest); + return doFetchRow(pRequest, true); } int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) { @@ -246,6 +246,7 @@ int* taos_fetch_lengths(TAOS_RES *res) { return ((SRequestObj*) res)->body.resInfo.length; } +// todo intergrate with tDataTypes const char *taos_data_type(int type) { switch (type) { case TSDB_DATA_TYPE_NULL: return "TSDB_DATA_TYPE_NULL"; @@ -256,9 +257,11 @@ const char *taos_data_type(int type) { case TSDB_DATA_TYPE_BIGINT: return "TSDB_DATA_TYPE_BIGINT"; case TSDB_DATA_TYPE_FLOAT: return "TSDB_DATA_TYPE_FLOAT"; case TSDB_DATA_TYPE_DOUBLE: return "TSDB_DATA_TYPE_DOUBLE"; - case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_BINARY"; + case TSDB_DATA_TYPE_VARCHAR: return "TSDB_DATA_TYPE_VARCHAR"; +// case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_VARCHAR"; case TSDB_DATA_TYPE_TIMESTAMP: return "TSDB_DATA_TYPE_TIMESTAMP"; case TSDB_DATA_TYPE_NCHAR: return "TSDB_DATA_TYPE_NCHAR"; + case TSDB_DATA_TYPE_JSON: return "TSDB_DATA_TYPE_JSON"; default: return "UNKNOWN"; } } @@ -316,11 +319,37 @@ void taos_stop_query(TAOS_RES *res) { } bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) { - return false; + SRequestObj* pRequestObj = res; + SReqResultInfo* pResultInfo = &pRequestObj->body.resInfo; + if (col >= pResultInfo->numOfCols || col < 0 || row >= pResultInfo->numOfRows || row < 0) { + return true; + } + + SResultColumn* pCol = &pRequestObj->body.resInfo.pCol[col]; + return colDataIsNull_f(pCol->nullbitmap, row); } int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { - return 0; + if (res == NULL) { + return 0; + } + + SRequestObj *pRequest = (SRequestObj *) res; + if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || + pRequest->type == TSDB_SQL_INSERT || + pRequest->code != TSDB_CODE_SUCCESS || + taos_num_fields(res) == 0) { + return 0; + } + + doFetchRow(pRequest, false); + + // TODO refactor + SReqResultInfo* pResultInfo = &pRequest->body.resInfo; + pResultInfo->current = pResultInfo->numOfRows; + *rows = pResultInfo->row; + + return pResultInfo->numOfRows; } int taos_validate_sql(TAOS *taos, const char *sql) { diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index c624e383fb..d2a5f1ab74 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1241,6 +1241,16 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { return pageSize / (blockDataGetSerialRowSize(pBlock) + blockDataGetSerialMetaSize(pBlock)); } +void colDataDestroy(SColumnInfoData* pColData) { + if (IS_VAR_DATA_TYPE(pColData->info.type)) { + taosMemoryFree(pColData->varmeta.offset); + } else { + taosMemoryFree(pColData->nullbitmap); + } + + taosMemoryFree(pColData->pData); +} + int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { int64_t tbUid = pBlock->info.uid; int16_t numOfCols = pBlock->info.numOfCols; diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 1b7157c49c..7fd66e95ad 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -123,7 +123,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) { return buf; } -int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { +int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version) { if (pBuilder == NULL) return -1; pBuilder->tCols = 256; @@ -140,7 +140,7 @@ void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) { } } -void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { +void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version) { pBuilder->nCols = 0; pBuilder->tlen = 0; pBuilder->flen = 0; @@ -168,6 +168,9 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, col_id_t colId, col colSetOffset(pCol, pTCol->offset + TYPE_BYTES[pTCol->type]); } + // TODO: set sma value by user input + pCol->sma = 1; + if (IS_VAR_DATA_TYPE(type)) { colSetBytes(pCol, bytes); pBuilder->tlen += (TYPE_BYTES[type] + bytes); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f464ce6f50..c85184ffba 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1829,7 +1829,7 @@ int32_t tDeserializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) { return 0; } -static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) { +int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, const SUseDbRsp *pRsp) { if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1; if (tEncodeI64(pEncoder, pRsp->uid) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->vgVersion) < 0) return -1; @@ -1848,7 +1848,7 @@ static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) { return 0; } -int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, SUseDbRsp *pRsp) { +int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, const SUseDbRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); diff --git a/source/dnode/mgmt/bnode/inc/bmInt.h b/source/dnode/mgmt/bnode/inc/bmInt.h index 8cfff0f1f3..f19ba4e034 100644 --- a/source/dnode/mgmt/bnode/inc/bmInt.h +++ b/source/dnode/mgmt/bnode/inc/bmInt.h @@ -43,7 +43,7 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); // bmWorker.c int32_t bmStartWorker(SBnodeMgmt *pMgmt); void bmStopWorker(SBnodeMgmt *pMgmt); -int32_t bmProcessWriteMsg(SBnodeMgmt *pMgmt, SNodeMsg *pMsg); +int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/bnode/src/bmWorker.c b/source/dnode/mgmt/bnode/src/bmWorker.c index 7698aa9dbd..932c008e34 100644 --- a/source/dnode/mgmt/bnode/src/bmWorker.c +++ b/source/dnode/mgmt/bnode/src/bmWorker.c @@ -63,15 +63,17 @@ static void bmProcessQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs taosArrayDestroy(pArray); } -int32_t bmProcessWriteMsg(SBnodeMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SBnodeMgmt *pMgmt = pWrapper->pMgmt; SMultiWorker *pWorker = &pMgmt->writeWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } int32_t bmStartWorker(SBnodeMgmt *pMgmt) { - SMultiWorkerCfg cfg = {.maxNum = 1, .name = "bnode-write", .fp = (FItems)bmProcessQueue, .param = pMgmt}; + SMultiWorkerCfg cfg = {.max = 1, .name = "bnode-write", .fp = (FItems)bmProcessQueue, .param = pMgmt}; if (tMultiWorkerInit(&pMgmt->writeWorker, &cfg) != 0) { dError("failed to start bnode write worker since %s", terrstr()); return -1; diff --git a/source/dnode/mgmt/container/inc/dnd.h b/source/dnode/mgmt/container/inc/dnd.h index f6c8897f64..7c06e08dff 100644 --- a/source/dnode/mgmt/container/inc/dnd.h +++ b/source/dnode/mgmt/container/inc/dnd.h @@ -63,7 +63,7 @@ typedef struct SQnodeMgmt SQnodeMgmt; typedef struct SSnodeMgmt SSnodeMgmt; typedef struct SBnodeMgmt SBnodeMgmt; -typedef int32_t (*NodeMsgFp)(void *pMgmt, SNodeMsg *pMsg); +typedef int32_t (*NodeMsgFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); typedef int32_t (*OpenNodeFp)(SMgmtWrapper *pWrapper); typedef void (*CloseNodeFp)(SMgmtWrapper *pWrapper); typedef int32_t (*StartNodeFp)(SMgmtWrapper *pWrapper); diff --git a/source/dnode/mgmt/container/src/dndExec.c b/source/dnode/mgmt/container/src/dndExec.c index a7b8ca288b..8ffa53f034 100644 --- a/source/dnode/mgmt/container/src/dndExec.c +++ b/source/dnode/mgmt/container/src/dndExec.c @@ -108,23 +108,25 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) { } static void dndClearNodesExecpt(SDnode *pDnode, ENodeType except) { - dndCleanupServer(pDnode); + // dndCleanupServer(pDnode); for (ENodeType n = 0; n < NODE_MAX; ++n) { if (except == n) continue; SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - dndCloseNode(pWrapper); + pWrapper->required = false; } } static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t msgLen, void *pCont, int32_t contLen) { - dTrace("msg:%p, get from child queue", pMsg); SRpcMsg *pRpc = &pMsg->rpcMsg; pRpc->pCont = pCont; + dTrace("msg:%p, get from child process queue, type:%s handle:%p app:%p", pMsg, TMSG_INFO(pRpc->msgType), + pRpc->handle, pRpc->ahandle); NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)]; int32_t code = (*msgFp)(pWrapper, pMsg); if (code != 0) { + dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code)); if (pRpc->msgType & 1U) { SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; dndSendRsp(pWrapper, &rsp); @@ -136,11 +138,13 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t } } -static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRsp, int32_t msgLen, void *pCont, int32_t contLen) { - dTrace("msg:%p, get from parent queue", pRsp); - pRsp->pCont = pCont; - dndSendRsp(pWrapper, pRsp); - taosMemoryFree(pRsp); +static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, int32_t msgLen, void *pCont, int32_t contLen) { + pRpc->pCont = pCont; + dTrace("msg:%p, get from parent process queue, type:%s handle:%p app:%p", pRpc, TMSG_INFO(pRpc->msgType), + pRpc->handle, pRpc->ahandle); + + dndSendRsp(pWrapper, pRpc); + taosMemoryFree(pRpc); } static int32_t dndRunInMultiProcess(SDnode *pDnode) { diff --git a/source/dnode/mgmt/container/src/dndMsg.c b/source/dnode/mgmt/container/src/dndMsg.c index b72d085861..5da1d73034 100644 --- a/source/dnode/mgmt/container/src/dndMsg.c +++ b/source/dnode/mgmt/container/src/dndMsg.c @@ -62,7 +62,7 @@ void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) { if (pWrapper->procType == PROC_SINGLE) { dTrace("msg:%p, is created, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle, pMsg->user); - code = (*msgFp)(pWrapper->pMgmt, pMsg); + 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, pRpc->ahandle, pMsg->user); diff --git a/source/dnode/mgmt/dnode/inc/dmInt.h b/source/dnode/mgmt/dnode/inc/dmInt.h index b02b1d2297..3036d1f5ad 100644 --- a/source/dnode/mgmt/dnode/inc/dmInt.h +++ b/source/dnode/mgmt/dnode/inc/dmInt.h @@ -54,7 +54,7 @@ int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); int32_t dmStartWorker(SDnodeMgmt *pMgmt); void dmStopWorker(SDnodeMgmt *pMgmt); int32_t dmStartThread(SDnodeMgmt *pMgmt); -int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); +int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/dnode/src/dmMsg.c b/source/dnode/mgmt/dnode/src/dmMsg.c index eb4e843c55..b301ef478b 100644 --- a/source/dnode/mgmt/dnode/src/dmMsg.c +++ b/source/dnode/mgmt/dnode/src/dmMsg.c @@ -118,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { void dmInitMsgHandles(SMgmtWrapper *pWrapper) { // Requests handled by DNODE - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, dmProcessMgmtMsg, VND_VGID); // Requests handled by MNODE - dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, VND_VGID); } diff --git a/source/dnode/mgmt/dnode/src/dmWorker.c b/source/dnode/mgmt/dnode/src/dmWorker.c index d34a26436c..63b9704b78 100644 --- a/source/dnode/mgmt/dnode/src/dmWorker.c +++ b/source/dnode/mgmt/dnode/src/dmWorker.c @@ -101,14 +101,14 @@ static void dmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { int32_t dmStartWorker(SDnodeMgmt *pMgmt) { SSingleWorkerCfg mgmtCfg = { - .minNum = 1, .maxNum = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessQueue, .param = pMgmt}; + .min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessQueue, .param = pMgmt}; if (tSingleWorkerInit(&pMgmt->mgmtWorker, &mgmtCfg) != 0) { dError("failed to start dnode mgmt worker since %s", terrstr()); return -1; } SSingleWorkerCfg statusCfg = { - .minNum = 1, .maxNum = 1, .name = "dnode-status", .fp = (FItem)dmProcessQueue, .param = pMgmt}; + .min = 1, .max = 1, .name = "dnode-status", .fp = (FItem)dmProcessQueue, .param = pMgmt}; if (tSingleWorkerInit(&pMgmt->statusWorker, &statusCfg) != 0) { dError("failed to start dnode status worker since %s", terrstr()); return -1; @@ -140,12 +140,14 @@ void dmStopWorker(SDnodeMgmt *pMgmt) { dDebug("dnode workers are closed"); } -int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SDnodeMgmt *pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->mgmtWorker; if (pMsg->rpcMsg.msgType == TDMT_MND_STATUS_RSP) { pWorker = &pMgmt->statusWorker; } dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } diff --git a/source/dnode/mgmt/mnode/inc/mmInt.h b/source/dnode/mgmt/mnode/inc/mmInt.h index cd4585048b..86cba97a33 100644 --- a/source/dnode/mgmt/mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mnode/inc/mmInt.h @@ -55,13 +55,14 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg); // mmWorker.c int32_t mmStartWorker(SMnodeMgmt *pMgmt); void mmStopWorker(SMnodeMgmt *pMgmt); -int32_t mmProcessWriteMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t mmProcessSyncMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t mmProcessReadMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t mmProcessQueryMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpcMsg); -int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpcMsg); +int32_t mmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t mmProcessReadMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); +int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); +int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); +int32_t mmPutMsgToSyncQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/mnode/src/mmInt.c b/source/dnode/mgmt/mnode/src/mmInt.c index 61afcb11d1..f5a3252fa2 100644 --- a/source/dnode/mgmt/mnode/src/mmInt.c +++ b/source/dnode/mgmt/mnode/src/mmInt.c @@ -48,6 +48,7 @@ static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) { msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue; msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue; msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue; + msgCb.queueFps[SYNC_QUEUE] = mmPutMsgToWriteQueue; msgCb.sendReqFp = dndSendReqToDnode; msgCb.sendMnodeReqFp = dndSendReqToMnode; msgCb.sendRspFp = dndSendRsp; diff --git a/source/dnode/mgmt/mnode/src/mmMsg.c b/source/dnode/mgmt/mnode/src/mmMsg.c index d04077baf8..6afcd249b3 100644 --- a/source/dnode/mgmt/mnode/src/mmMsg.c +++ b/source/dnode/mgmt/mnode/src/mmMsg.c @@ -75,91 +75,91 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { void mmInitMsgHandles(SMgmtWrapper *pWrapper) { // Requests handled by DNODE - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, VND_VGID); // Requests handled by MNODE - dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, VND_VGID); // Requests handled by VNODE - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)mmProcessQueryMsg, MND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)mmProcessQueryMsg, MND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)mmProcessQueryMsg, MND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)mmProcessQueryMsg, MND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)mmProcessQueryMsg, MND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MND_VGID); } diff --git a/source/dnode/mgmt/mnode/src/mmWorker.c b/source/dnode/mgmt/mnode/src/mmWorker.c index 27489b45d0..c4aafe05e4 100644 --- a/source/dnode/mgmt/mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mnode/src/mmWorker.c @@ -19,7 +19,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; - dTrace("msg:%p, will be processed in mnode queue", pMsg); + dTrace("msg:%p, get from mnode queue", pMsg); SRpcMsg *pRpc = &pMsg->rpcMsg; int32_t code = -1; @@ -31,9 +31,11 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { } if (pRpc->msgType & 1U) { - if (pRpc->handle == NULL) return; - if (code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { - if (code != 0) code = terrno; + if (pRpc->handle != NULL && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + if (code != 0) { + code = terrno; + dError("msg:%p, failed to process since %s", pMsg, terrstr()); + } SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .contLen = pMsg->rspLen, .pCont = pMsg->pRsp}; dndSendRsp(pMgmt->pWrapper, &rsp); } @@ -47,7 +49,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; - dTrace("msg:%p, will be processed in mnode queue", pMsg); + dTrace("msg:%p, get from mnode query queue", pMsg); SRpcMsg *pRpc = &pMsg->rpcMsg; int32_t code = -1; @@ -55,8 +57,8 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { code = mndProcessMsg(pMsg); if (pRpc->msgType & 1U) { - if (pRpc->handle == NULL) return; - if (code != 0) { + if (pRpc->handle != NULL && code != 0) { + dError("msg:%p, failed to process since %s", pMsg, terrstr()); SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .ahandle = pRpc->ahandle}; dndSendRsp(pMgmt->pWrapper, &rsp); } @@ -67,83 +69,86 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { taosFreeQitem(pMsg); } - -static int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SNodeMsg *pMsg) { +static void mmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) { dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); } -int32_t mmProcessWriteMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->writeWorker, pMsg); +int32_t mmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mmPutMsgToWorker(&pMgmt->writeWorker, pMsg); + return 0; } -int32_t mmProcessSyncMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg); +int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mmPutMsgToWorker(&pMgmt->syncWorker, pMsg); + return 0; } -int32_t mmProcessReadMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->readWorker, pMsg); +int32_t mmProcessReadMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mmPutMsgToWorker(&pMgmt->readWorker, pMsg); + return 0; } -int32_t mmProcessQueryMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->queryWorker, pMsg); +int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mmPutMsgToWorker(&pMgmt->queryWorker, pMsg); + return 0; } -static int32_t mmPutRpcMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pRpc) { +static int32_t mmPutRpcMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pRpc) { SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg)); - if (pMsg == NULL) { - return -1; - } + if (pMsg == NULL) return -1; dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType)); pMsg->rpcMsg = *pRpc; - - int32_t code = taosWriteQitem(pWorker->queue, pMsg); - if (code != 0) { - dTrace("msg:%p, is freed", pMsg); - taosFreeQitem(pMsg); - rpcFreeCont(pRpc->pCont); - } - - return code; -} - -int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { - SMnodeMgmt *pMgmt = pWrapper->pMgmt; - return mmPutRpcMsgToWorker(pMgmt, &pMgmt->writeWorker, pRpc); -} - -int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { - SMnodeMgmt *pMgmt = pWrapper->pMgmt; - return mmPutRpcMsgToWorker(pMgmt, &pMgmt->readWorker, pRpc); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { SMnodeMgmt *pMgmt = pWrapper->pMgmt; - return mmPutRpcMsgToWorker(pMgmt, &pMgmt->queryWorker, pRpc); + return mmPutRpcMsgToWorker(&pMgmt->queryWorker, pRpc); } +int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + return mmPutRpcMsgToWorker(&pMgmt->writeWorker, pRpc); +} + +int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + return mmPutRpcMsgToWorker(&pMgmt->readWorker, pRpc); +} + +int32_t mmPutMsgToSyncQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pRpc); +} int32_t mmStartWorker(SMnodeMgmt *pMgmt) { - SSingleWorkerCfg cfg = {.minNum = 0, .maxNum = 1, .name = "mnode-read", .fp = (FItem)mmProcessQueue, .param = pMgmt}; - SSingleWorkerCfg queryCfg = {.minNum = 0, .maxNum = 1, .name = "mnode-query", .fp = (FItem)mmProcessQueryQueue, .param = pMgmt}; - - if (tSingleWorkerInit(&pMgmt->queryWorker, &queryCfg) != 0) { + SSingleWorkerCfg qCfg = {.min = 0, .max = 1, .name = "mnode-query", .fp = (FItem)mmProcessQueryQueue, .param = pMgmt}; + if (tSingleWorkerInit(&pMgmt->queryWorker, &qCfg) != 0) { dError("failed to start mnode-query worker since %s", terrstr()); return -1; } - if (tSingleWorkerInit(&pMgmt->readWorker, &cfg) != 0) { + SSingleWorkerCfg rCfg = {.min = 0, .max = 1, .name = "mnode-read", .fp = (FItem)mmProcessQueue, .param = pMgmt}; + if (tSingleWorkerInit(&pMgmt->readWorker, &rCfg) != 0) { dError("failed to start mnode-read worker since %s", terrstr()); return -1; } - if (tSingleWorkerInit(&pMgmt->writeWorker, &cfg) != 0) { + SSingleWorkerCfg wCfg = {.min = 0, .max = 1, .name = "mnode-write", .fp = (FItem)mmProcessQueue, .param = pMgmt}; + if (tSingleWorkerInit(&pMgmt->writeWorker, &wCfg) != 0) { dError("failed to start mnode-write worker since %s", terrstr()); return -1; } - if (tSingleWorkerInit(&pMgmt->syncWorker, &cfg) != 0) { + SSingleWorkerCfg sCfg = {.min = 0, .max = 1, .name = "mnode-sync", .fp = (FItem)mmProcessQueue, .param = pMgmt}; + if (tSingleWorkerInit(&pMgmt->syncWorker, &sCfg) != 0) { dError("failed to start mnode sync-worker since %s", terrstr()); return -1; } @@ -153,8 +158,8 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { } void mmStopWorker(SMnodeMgmt *pMgmt) { - tSingleWorkerCleanup(&pMgmt->readWorker); tSingleWorkerCleanup(&pMgmt->queryWorker); + tSingleWorkerCleanup(&pMgmt->readWorker); tSingleWorkerCleanup(&pMgmt->writeWorker); tSingleWorkerCleanup(&pMgmt->syncWorker); dDebug("mnode workers are closed"); diff --git a/source/dnode/mgmt/qnode/inc/qmInt.h b/source/dnode/mgmt/qnode/inc/qmInt.h index 52d23a445c..3e975663d3 100644 --- a/source/dnode/mgmt/qnode/inc/qmInt.h +++ b/source/dnode/mgmt/qnode/inc/qmInt.h @@ -48,8 +48,8 @@ int32_t qmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype); int32_t qmStartWorker(SQnodeMgmt *pMgmt); void qmStopWorker(SQnodeMgmt *pMgmt); -int32_t qmProcessQueryMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t qmProcessFetchMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg); +int32_t qmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t qmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/qnode/src/qmMsg.c b/source/dnode/mgmt/qnode/src/qmMsg.c index ebe6477e81..da5ba6472a 100644 --- a/source/dnode/mgmt/qnode/src/qmMsg.c +++ b/source/dnode/mgmt/qnode/src/qmMsg.c @@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { void qmInitMsgHandles(SMgmtWrapper *pWrapper) { // Requests handled by VNODE - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); - dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QND_VGID); } diff --git a/source/dnode/mgmt/qnode/src/qmWorker.c b/source/dnode/mgmt/qnode/src/qmWorker.c index aa4da82790..14efb311b1 100644 --- a/source/dnode/mgmt/qnode/src/qmWorker.c +++ b/source/dnode/mgmt/qnode/src/qmWorker.c @@ -49,14 +49,22 @@ static void qmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { taosFreeQitem(pMsg); } -static int32_t qmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) { +static void qmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) { dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); } -int32_t qmProcessQueryMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg) { return qmPutMsgToWorker(&pMgmt->queryWorker, pMsg); } +int32_t qmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SQnodeMgmt *pMgmt = pWrapper->pMgmt; + qmPutMsgToWorker(&pMgmt->queryWorker, pMsg); + return 0; +} -int32_t qmProcessFetchMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg) { return qmPutMsgToWorker(&pMgmt->fetchWorker, pMsg); } +int32_t qmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SQnodeMgmt *pMgmt = pWrapper->pMgmt; + qmPutMsgToWorker(&pMgmt->fetchWorker, pMsg); + return 0; +} static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pRpc) { SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg)); @@ -66,15 +74,8 @@ static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SR dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType)); pMsg->rpcMsg = *pRpc; - - int32_t code = taosWriteQitem(pWorker->queue, pMsg); - if (code != 0) { - dTrace("msg:%p, is freed", pMsg); - taosFreeQitem(pMsg); - rpcFreeCont(pRpc->pCont); - } - - return code; + taosWriteQitem(pWorker->queue, pMsg); + return 0; } int32_t qmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { @@ -110,8 +111,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) { int32_t minQueryThreads = TMAX((int32_t)(tsNumOfCores * tsRatioOfQueryCores), 1); int32_t maxQueryThreads = minQueryThreads; - SSingleWorkerCfg queryCfg = {.minNum = minQueryThreads, - .maxNum = maxQueryThreads, + SSingleWorkerCfg queryCfg = {.min = minQueryThreads, + .max = maxQueryThreads, .name = "qnode-query", .fp = (FItem)qmProcessQueryQueue, .param = pMgmt}; @@ -121,8 +122,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) { return -1; } - SSingleWorkerCfg fetchCfg = {.minNum = minFetchThreads, - .maxNum = maxFetchThreads, + SSingleWorkerCfg fetchCfg = {.min = minFetchThreads, + .max = maxFetchThreads, .name = "qnode-fetch", .fp = (FItem)qmProcessFetchQueue, .param = pMgmt}; diff --git a/source/dnode/mgmt/snode/inc/smInt.h b/source/dnode/mgmt/snode/inc/smInt.h index f2b510483c..9290384cab 100644 --- a/source/dnode/mgmt/snode/inc/smInt.h +++ b/source/dnode/mgmt/snode/inc/smInt.h @@ -46,10 +46,10 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); // smWorker.c int32_t smStartWorker(SSnodeMgmt *pMgmt); void smStopWorker(SSnodeMgmt *pMgmt); -int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t smProcessSharedMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t smProcessExecMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg); +int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t smProcessSharedMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t smProcessExecMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/snode/src/smMsg.c b/source/dnode/mgmt/snode/src/smMsg.c index aea1dded56..c522ef7fc3 100644 --- a/source/dnode/mgmt/snode/src/smMsg.c +++ b/source/dnode/mgmt/snode/src/smMsg.c @@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { void smInitMsgHandles(SMgmtWrapper *pWrapper) { // Requests handled by SNODE - dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, VND_VGID); } diff --git a/source/dnode/mgmt/snode/src/smWorker.c b/source/dnode/mgmt/snode/src/smWorker.c index 5913713ff3..0326d7dd9f 100644 --- a/source/dnode/mgmt/snode/src/smWorker.c +++ b/source/dnode/mgmt/snode/src/smWorker.c @@ -57,7 +57,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) { return -1; } - SMultiWorkerCfg cfg = {.maxNum = 1, .name = "snode-unique", .fp = smProcessUniqueQueue, .param = pMgmt}; + SMultiWorkerCfg cfg = {.max = 1, .name = "snode-unique", .fp = smProcessUniqueQueue, .param = pMgmt}; if (tMultiWorkerInit(pUniqueWorker, &cfg) != 0) { dError("failed to start snode-unique worker since %s", terrstr()); @@ -69,8 +69,8 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) { } } - SSingleWorkerCfg cfg = {.minNum = SND_SHARED_THREAD_NUM, - .maxNum = SND_SHARED_THREAD_NUM, + SSingleWorkerCfg cfg = {.min = SND_SHARED_THREAD_NUM, + .max = SND_SHARED_THREAD_NUM, .name = "snode-shared", .fp = (FItem)smProcessSharedQueue, .param = pMgmt}; @@ -107,7 +107,8 @@ static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) { return 0; } -int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SSnodeMgmt *pMgmt = pWrapper->pMgmt; SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, 0); if (pWorker == NULL) { terrno = TSDB_CODE_INVALID_MSG; @@ -115,10 +116,12 @@ int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { } dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } -int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SSnodeMgmt *pMgmt = pWrapper->pMgmt; int32_t index = smGetSWIdFromMsg(&pMsg->rpcMsg); SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index); if (pWorker == NULL) { @@ -127,21 +130,24 @@ int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { } dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } -int32_t smProcessSharedMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t smProcessSharedMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SSnodeMgmt *pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->sharedWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } -int32_t smProcessExecMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) { - int32_t workerType = smGetSWTypeFromMsg(&pMsg->rpcMsg); +int32_t smProcessExecMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + int32_t workerType = smGetSWTypeFromMsg(&pMsg->rpcMsg); if (workerType == SND_WORKER_TYPE__SHARED) { - return smProcessSharedMsg(pMgmt, pMsg); + return smProcessSharedMsg(pWrapper, pMsg); } else { - return smProcessUniqueMsg(pMgmt, pMsg); + return smProcessUniqueMsg(pWrapper, pMsg); } } diff --git a/source/dnode/mgmt/vnode/inc/vmInt.h b/source/dnode/mgmt/vnode/inc/vmInt.h index 197c606a0d..6722fe1d65 100644 --- a/source/dnode/mgmt/vnode/inc/vmInt.h +++ b/source/dnode/mgmt/vnode/inc/vmInt.h @@ -108,12 +108,12 @@ int32_t vmPutMsgToFetchQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); int32_t vmPutMsgToApplyQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype); -int32_t vmProcessWriteMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); -int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); -int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); -int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); -int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); -int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg); +int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrappert, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/vnode/src/vmMsg.c b/source/dnode/mgmt/vnode/src/vmMsg.c index 1682c6043d..7a6494cfa1 100644 --- a/source/dnode/mgmt/vnode/src/vmMsg.c +++ b/source/dnode/mgmt/vnode/src/vmMsg.c @@ -281,11 +281,12 @@ void vmInitMsgHandles(SMgmtWrapper *pWrapper) { dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, VND_VGID); dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID); dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, VND_VGID); dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID); - dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, VND_VGID); + dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, VND_VGID); } diff --git a/source/dnode/mgmt/vnode/src/vmWorker.c b/source/dnode/mgmt/vnode/src/vmWorker.c index 7b6d78a60c..193807317f 100644 --- a/source/dnode/mgmt/vnode/src/vmWorker.c +++ b/source/dnode/mgmt/vnode/src/vmWorker.c @@ -179,9 +179,7 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO } static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) { - SRpcMsg *pRpc = &pMsg->rpcMsg; - int32_t code = -1; - + SRpcMsg *pRpc = &pMsg->rpcMsg; SMsgHead *pHead = pRpc->pCont; pHead->contLen = ntohl(pHead->contLen); pHead->vgId = ntohl(pHead->vgId); @@ -192,28 +190,30 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp return -1; } + int32_t code = 0; switch (qtype) { case QUERY_QUEUE: dTrace("msg:%p, will be written into vnode-query queue", pMsg); - code = taosWriteQitem(pVnode->pQueryQ, pMsg); + taosWriteQitem(pVnode->pQueryQ, pMsg); break; case FETCH_QUEUE: dTrace("msg:%p, will be written into vnode-fetch queue", pMsg); - code = taosWriteQitem(pVnode->pFetchQ, pMsg); + taosWriteQitem(pVnode->pFetchQ, pMsg); break; case WRITE_QUEUE: dTrace("msg:%p, will be written into vnode-write queue", pMsg); - code = taosWriteQitem(pVnode->pWriteQ, pMsg); + taosWriteQitem(pVnode->pWriteQ, pMsg); break; case SYNC_QUEUE: dTrace("msg:%p, will be written into vnode-sync queue", pMsg); - code = taosWriteQitem(pVnode->pSyncQ, pMsg); + taosWriteQitem(pVnode->pSyncQ, pMsg); break; case MERGE_QUEUE: dTrace("msg:%p, will be written into vnode-merge queue", pMsg); - code = taosWriteQitem(pVnode->pMergeQ, pMsg); + taosWriteQitem(pVnode->pMergeQ, pMsg); break; default: + code = -1; terrno = TSDB_CODE_INVALID_PARA; break; } @@ -222,52 +222,73 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp return code; } -int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); } +int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + return vmPutNodeMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); +} -int32_t vmProcessWriteMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, WRITE_QUEUE); } +int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + return vmPutNodeMsgToQueue(pMgmt, pMsg, WRITE_QUEUE); +} -int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, QUERY_QUEUE); } +int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + return vmPutNodeMsgToQueue(pMgmt, pMsg, QUERY_QUEUE); +} -int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); } +int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); +} -int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, MERGE_QUEUE); } +int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + return vmPutNodeMsgToQueue(pMgmt, pMsg, MERGE_QUEUE); +} -int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { +int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->mgmtWorker; dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name); - return taosWriteQitem(pWorker->queue, pMsg); + taosWriteQitem(pWorker->queue, pMsg); + return 0; } static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) { SVnodesMgmt *pMgmt = pWrapper->pMgmt; - int32_t code = -1; SMsgHead *pHead = pRpc->pCont; SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) return -1; SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg)); - if (pMsg != NULL) { + int32_t code = 0; + + if (pMsg == NULL) { + code = -1; + } else { dTrace("msg:%p, is created, type:%s", pMsg, TMSG_INFO(pRpc->msgType)); pMsg->rpcMsg = *pRpc; switch (qtype) { case QUERY_QUEUE: dTrace("msg:%p, will be put into vnode-query queue", pMsg); - code = taosWriteQitem(pVnode->pQueryQ, pMsg); + taosWriteQitem(pVnode->pQueryQ, pMsg); break; case FETCH_QUEUE: dTrace("msg:%p, will be put into vnode-fetch queue", pMsg); - code = taosWriteQitem(pVnode->pFetchQ, pMsg); + taosWriteQitem(pVnode->pFetchQ, pMsg); break; case APPLY_QUEUE: dTrace("msg:%p, will be put into vnode-apply queue", pMsg); - code = taosWriteQitem(pVnode->pApplyQ, pMsg); + taosWriteQitem(pVnode->pApplyQ, pMsg); break; case MERGE_QUEUE: dTrace("msg:%p, will be put into vnode-merge queue", pMsg); - code = taosWriteQitem(pVnode->pMergeQ, pMsg); + taosWriteQitem(pVnode->pMergeQ, pMsg); break; default: + code = -1; terrno = TSDB_CODE_INVALID_PARA; break; } @@ -394,7 +415,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) { if (tWWorkerInit(pWPool) != 0) return -1; SSingleWorkerCfg cfg = { - .minNum = 1, .maxNum = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt}; + .min = 1, .max = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt}; if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) { dError("failed to start vnode-mgmt worker since %s", terrstr()); return -1; diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index 125b0d3191..c0b25d74d1 100644 --- a/source/dnode/mnode/impl/inc/mndDb.h +++ b/source/dnode/mnode/impl/inc/mndDb.h @@ -28,6 +28,7 @@ SDbObj *mndAcquireDb(SMnode *pMnode, const char *db); void mndReleaseDb(SMnode *pMnode, SDbObj *pDb); int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen); char *mnGetDbStr(char *src); +int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 05c7d79a1a..bd66bdeae9 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -276,6 +276,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->quorum > pCfg->replications) return -1; if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1; if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1; + if (pCfg->streamMode < TSDB_MIN_DB_STREAM_MODE || pCfg->streamMode > TSDB_MAX_DB_STREAM_MODE) return -1; return TSDB_CODE_SUCCESS; } @@ -285,8 +286,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS; if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP; - if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = TSDB_DEFAULT_KEEP; - if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = TSDB_DEFAULT_KEEP; + if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0; + if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1; if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MIN_ROW_FBLOCK; if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAX_ROW_FBLOCK; if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME; @@ -298,6 +299,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->quorum < 0) pCfg->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION; if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE_OPTION; if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW; + if (pCfg->streamMode < 0) pCfg->streamMode = TSDB_DEFAULT_DB_STREAM_MODE; + if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0; } static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) { @@ -431,11 +434,11 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate .daysToKeep2 = pCreate->daysToKeep2, .minRows = pCreate->minRows, .maxRows = pCreate->maxRows, - .fsyncPeriod = pCreate->fsyncPeriod, .commitTime = pCreate->commitTime, + .fsyncPeriod = pCreate->fsyncPeriod, + .walLevel = pCreate->walLevel, .precision = pCreate->precision, .compression = pCreate->compression, - .walLevel = pCreate->walLevel, .replications = pCreate->replications, .quorum = pCreate->quorum, .update = pCreate->update, @@ -445,7 +448,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate dbObj.cfg.numOfRetensions = pCreate->numOfRetensions; dbObj.cfg.pRetensions = pCreate->pRetensions; - pCreate = NULL; + pCreate->pRetensions = NULL; mndSetDefaultDbCfg(&dbObj.cfg); @@ -955,7 +958,6 @@ void mndGetDBTableNum(SDbObj *pDb, SMnode *pMnode, int32_t *num) { sdbCancelFetch(pSdb, pIter); } - static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { int32_t vindex = 0; SSdb *pSdb = pMnode->pSdb; @@ -991,7 +993,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { } sdbRelease(pSdb, pVgroup); - + if (pDb && (vindex >= pDb->cfg.numOfVgroups)) { break; } @@ -1000,6 +1002,28 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { sdbCancelFetch(pSdb, pIter); } +int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq) { + pRsp->pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); + if (pRsp->pVgroupInfos == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + int32_t numOfTable = 0; + mndGetDBTableNum(pDb, pMnode, &numOfTable); + + if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable) { + mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos); + } + + memcpy(pRsp->db, pDb->name, TSDB_DB_FNAME_LEN); + pRsp->uid = pDb->uid; + pRsp->vgVersion = pDb->vgVersion; + pRsp->vgNum = taosArrayGetSize(pRsp->pVgroupInfos); + pRsp->hashMethod = pDb->hashMethod; + return 0; +} + static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { SMnode *pMnode = pReq->pNode; int32_t code = -1; @@ -1023,10 +1047,10 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto USE_DB_OVER; } - + mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos); usedbRsp.vgVersion = vgVersion++; - + if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) { terrno = TSDB_CODE_MND_DB_NOT_EXIST; } @@ -1034,7 +1058,7 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { usedbRsp.vgVersion = usedbReq.vgVersion; code = 0; } - usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos); + usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos); // no jump, need to construct rsp } else { @@ -1057,24 +1081,10 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { goto USE_DB_OVER; } - usedbRsp.pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); - if (usedbRsp.pVgroupInfos == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + if (mndExtractDbInfo(pMnode, pDb, &usedbRsp, &usedbReq) < 0) { goto USE_DB_OVER; } - int32_t numOfTable = 0; - mndGetDBTableNum(pDb, pMnode, &numOfTable); - - if (usedbReq.vgVersion < pDb->vgVersion || usedbReq.dbId != pDb->uid || numOfTable != usedbReq.numOfTable) { - mndBuildDBVgroupInfo(pDb, pMnode, usedbRsp.pVgroupInfos); - } - - memcpy(usedbRsp.db, pDb->name, TSDB_DB_FNAME_LEN); - usedbRsp.uid = pDb->uid; - usedbRsp.vgVersion = pDb->vgVersion; - usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos); - usedbRsp.hashMethod = pDb->hashMethod; code = 0; } } @@ -1138,7 +1148,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, mndReleaseDb(pMnode, pDb); continue; } - + usedbRsp.pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); if (usedbRsp.pVgroupInfos == NULL) { mndReleaseDb(pMnode, pDb); @@ -1364,11 +1374,11 @@ static int32_t mndGetDbMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMet pSchema[cols].bytes = pShow->bytes[cols]; cols++; -// pShow->bytes[cols] = 1; -// pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; -// strcpy(pSchema[cols].name, "update"); -// pSchema[cols].bytes = pShow->bytes[cols]; -// cols++; + // pShow->bytes[cols] = 1; + // pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; + // strcpy(pSchema[cols].name, "update"); + // pSchema[cols].bytes = pShow->bytes[cols]; + // cols++; pMeta->numOfColumns = cols; pShow->numOfColumns = cols; @@ -1396,14 +1406,15 @@ char *mnGetDbStr(char *src) { return pos; } -static char* getDataPosition(char* pData, SShowObj* pShow, int32_t cols, int32_t rows, int32_t capacityOfRow) { +static char *getDataPosition(char *pData, SShowObj *pShow, int32_t cols, int32_t rows, int32_t capacityOfRow) { return pData + pShow->offset[cols] * capacityOfRow + pShow->bytes[cols] * rows; } -static void dumpDbInfoToPayload(char* data, SDbObj* pDb, SShowObj* pShow, int32_t rows, int32_t rowCapacity, int64_t numOfTables) { +static void dumpDbInfoToPayload(char *data, SDbObj *pDb, SShowObj *pShow, int32_t rows, int32_t rowCapacity, + int64_t numOfTables) { int32_t cols = 0; - char* pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); + char *pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); char *name = mnGetDbStr(pDb->name); if (name != NULL) { STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]); @@ -1497,20 +1508,28 @@ static void dumpDbInfoToPayload(char* data, SDbObj* pDb, SShowObj* pShow, int32_ STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2); cols++; -// pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); -// *(int8_t *)pWrite = pDb->cfg.update; + // pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); + // *(int8_t *)pWrite = pDb->cfg.update; } -static void setInformationSchemaDbCfg(SDbObj* pDbObj) { +static void setInformationSchemaDbCfg(SDbObj *pDbObj) { ASSERT(pDbObj != NULL); strncpy(pDbObj->name, TSDB_INFORMATION_SCHEMA_DB, tListLen(pDbObj->name)); - pDbObj->createdTime = 0; + pDbObj->createdTime = 0; pDbObj->cfg.numOfVgroups = 0; - pDbObj->cfg.quorum = 1; + pDbObj->cfg.quorum = 1; pDbObj->cfg.replications = 1; - pDbObj->cfg.update = 1; - pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI; + pDbObj->cfg.update = 1; + pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI; +} + +static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) { + SVgObj *pVgroup = pObj; + int32_t *numOfTables = p1; + + *numOfTables += pVgroup->numOfTables; + return true; } static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rowsCapacity) { @@ -1525,7 +1544,10 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, char *data, int32 break; } - dumpDbInfoToPayload(data, pDb, pShow, numOfRows, rowsCapacity, 0); + int32_t numOfTables = 0; + sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL); + + dumpDbInfoToPayload(data, pDb, pShow, numOfRows, rowsCapacity, numOfTables); numOfRows++; sdbRelease(pSdb, pDb); } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 697811cd04..566bd1d282 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -119,6 +119,53 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, int64_t dbUid) { return pVgroup; } +int32_t mndAddSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, int64_t smaId) { + SSdb* pSdb = pMnode->pSdb; + void* pIter = NULL; + SArray* tasks = taosArrayGetP(pStream->tasks, 0); + + ASSERT(taosArrayGetSize(pStream->tasks) == 1); + + while (1) { + SVgObj* pVgroup; + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); + if (pIter == NULL) break; + if (pVgroup->dbUid != pStream->dbUid) { + sdbRelease(pSdb, pVgroup); + continue; + } + SStreamTask* pTask = tNewSStreamTask(pStream->uid); + if (pTask == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + taosArrayPush(tasks, &pTask); + + pTask->nodeId = pVgroup->vgId; + pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup); + + // source + pTask->sourceType = TASK_SOURCE__MERGE; + + // exec + pTask->execType = TASK_EXEC__NONE; + + // sink + if (smaId != -1) { + pTask->sinkType = TASK_SINK__SMA; + pTask->smaSink.smaId = smaId; + } else { + pTask->sinkType = TASK_SINK__TABLE; + } + + // dispatch + pTask->dispatchType = TASK_DISPATCH__NONE; + + mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_VND_TASK_DEPLOY, pVgroup->vgId); + } + return 0; +} + int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, int64_t smaId) { SSdb* pSdb = pMnode->pSdb; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); @@ -132,6 +179,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i ASSERT(totLevel <= 2); pStream->tasks = taosArrayInit(totLevel, sizeof(void*)); + bool hasExtraSink = false; + if (totLevel == 2) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); + taosArrayPush(pStream->tasks, &taskOneLevel); + // add extra sink + hasExtraSink = true; + mndAddSinkToStream(pMnode, pTrans, pStream, smaId); + } + for (int32_t level = 0; level < totLevel; level++) { SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level); @@ -164,9 +220,13 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i // only for inplace pTask->sinkType = TASK_SINK__SHOW; pTask->showSink.reserved = 0; - if (smaId != -1) { - pTask->sinkType = TASK_SINK__SMA; - pTask->smaSink.smaId = smaId; + if (!hasExtraSink) { + if (smaId != -1) { + pTask->sinkType = TASK_SINK__SMA; + pTask->smaSink.smaId = smaId; + } else { + pTask->sinkType = TASK_SINK__TABLE; + } } } else { pTask->sinkType = TASK_SINK__NONE; @@ -175,17 +235,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i // dispatch part if (level == 0) { pTask->dispatchType = TASK_DISPATCH__NONE; - // if inplace sink, no dispatcher - // if fixed ep, add fixed ep dispatcher - // if shuffle, add shuffle dispatcher } else { // add fixed ep dispatcher int32_t lastLevel = level - 1; ASSERT(lastLevel == 0); + if (hasExtraSink) lastLevel++; SArray* pArray = taosArrayGetP(pStream->tasks, lastLevel); // one merge only ASSERT(taosArrayGetSize(pArray) == 1); - SStreamTask* lastLevelTask = taosArrayGetP(pArray, lastLevel); + SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0); pTask->dispatchMsgType = TDMT_VND_TASK_MERGE_EXEC; pTask->dispatchType = TASK_DISPATCH__FIXED; @@ -222,8 +280,44 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i /*pTask->sinkType = TASK_SINK__NONE;*/ // dispatch part - pTask->dispatchType = TASK_DISPATCH__SHUFFLE; - pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC; + ASSERT(hasExtraSink); + /*pTask->dispatchType = TASK_DISPATCH__NONE;*/ +#if 1 + + if (hasExtraSink) { + // add dispatcher + pTask->dispatchType = TASK_DISPATCH__SHUFFLE; + + pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC; + SDbObj* pDb = mndAcquireDb(pMnode, pStream->db); + ASSERT(pDb); + if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) { + sdbRelease(pSdb, pDb); + qDestroyQueryPlan(pPlan); + return -1; + } + sdbRelease(pSdb, pDb); + + // put taskId to useDbRsp + // TODO: optimize + SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; + int32_t sz = taosArrayGetSize(pVgs); + SArray* sinkLv = taosArrayGetP(pStream->tasks, 0); + int32_t sinkLvSize = taosArrayGetSize(sinkLv); + for (int32_t i = 0; i < sz; i++) { + SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i); + for (int32_t j = 0; j < sinkLvSize; j++) { + SStreamTask* pLastLevelTask = taosArrayGetP(sinkLv, j); + /*printf("vgid %d node id %d\n", pVgInfo->vgId, pTask->nodeId);*/ + if (pLastLevelTask->nodeId == pVgInfo->vgId) { + pVgInfo->taskId = pLastLevelTask->taskId; + /*printf("taskid %d set to %d\n", pVgInfo->taskId, pTask->taskId);*/ + break; + } + } + } + } +#endif // exec part pTask->execType = TASK_EXEC__MERGE; diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 7d3f755cd7..469805387f 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -87,12 +87,6 @@ static int32_t mndCreateDefaultUsers(SMnode *pMnode) { return -1; } -#if 0 - if (mndCreateDefaultUser(pMnode, TSDB_DEFAULT_USER, "_" TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS) != 0) { - return -1; - } -#endif - return 0; } diff --git a/source/dnode/vnode/src/inc/tsdbReadImpl.h b/source/dnode/vnode/src/inc/tsdbReadImpl.h index cd24358b27..17c220a35a 100644 --- a/source/dnode/vnode/src/inc/tsdbReadImpl.h +++ b/source/dnode/vnode/src/inc/tsdbReadImpl.h @@ -67,12 +67,13 @@ typedef struct { uint8_t last : 1; uint8_t blkVer : 7; uint8_t numOfSubBlocks; - int16_t numOfCols; // not including timestamp column + col_id_t numOfCols; // not including timestamp column uint32_t len; // data block length - uint32_t keyLen : 24; // key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols + uint32_t keyLen : 20; // key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols + uint32_t algorithm : 4; uint32_t reserve : 8; - int32_t algorithm : 8; - int32_t numOfRows : 24; + col_id_t numOfBSma; + uint16_t numOfRows; int64_t offset; uint64_t aggrStat : 1; uint64_t aggrOffset : 63; @@ -80,7 +81,7 @@ typedef struct { TSKEY keyLast; } SBlockV0; -#define SBlock SBlockV0 // latest SBlock definition +#define SBlock SBlockV0 // latest SBlock definition #endif diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 7b0606512c..5ec5b1d58f 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -19,15 +19,14 @@ #include "tmallocator.h" // #include "sync.h" #include "tcoding.h" +#include "tdatablock.h" #include "tfs.h" #include "tlist.h" #include "tlockfree.h" #include "tmacro.h" -#include "wal.h" - #include "vnode.h" - #include "vnodeQuery.h" +#include "wal.h" #ifdef __cplusplus extern "C" { @@ -203,7 +202,7 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen); // sma -void smaHandleRes(SVnode* pVnode, int64_t smaId, const SArray* data); +void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 55202335e0..159ec5b3e8 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -473,10 +473,16 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) { } tCoderClear(&decoder); + // exec if (tqExpandTask(pTq, pTask, 4) < 0) { ASSERT(0); } + + // sink pTask->ahandle = pTq->pVnode; + if (pTask->sinkType == TASK_SINK__SMA) { + pTask->smaSink.smaHandle = smaHandleRes; + } taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), pTask, sizeof(SStreamTask)); @@ -502,7 +508,9 @@ int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen) { SStreamTaskExecReq req; tDecodeSStreamTaskExecReq(msg, &req); - int32_t taskId = req.taskId; + int32_t taskId = req.taskId; + ASSERT(taskId); + SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); ASSERT(pTask); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index eb8df61051..3e0b03f331 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -43,20 +43,20 @@ typedef struct { #define TSDB_DEFAULT_BLOCK_ROWS(maxRows) ((maxRows)*4 / 5) -#define TSDB_COMMIT_REPO(ch) TSDB_READ_REPO(&(ch->readh)) -#define TSDB_COMMIT_REPO_ID(ch) REPO_ID(TSDB_READ_REPO(&(ch->readh))) -#define TSDB_COMMIT_WRITE_FSET(ch) (&((ch)->wSet)) -#define TSDB_COMMIT_TABLE(ch) ((ch)->pTable) -#define TSDB_COMMIT_HEAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_HEAD) -#define TSDB_COMMIT_DATA_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_DATA) -#define TSDB_COMMIT_LAST_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_LAST) -#define TSDB_COMMIT_SMAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAD) -#define TSDB_COMMIT_SMAL_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAL) -#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh)) -#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh)) -#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh)) +#define TSDB_COMMIT_REPO(ch) TSDB_READ_REPO(&(ch->readh)) +#define TSDB_COMMIT_REPO_ID(ch) REPO_ID(TSDB_READ_REPO(&(ch->readh))) +#define TSDB_COMMIT_WRITE_FSET(ch) (&((ch)->wSet)) +#define TSDB_COMMIT_TABLE(ch) ((ch)->pTable) +#define TSDB_COMMIT_HEAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_HEAD) +#define TSDB_COMMIT_DATA_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_DATA) +#define TSDB_COMMIT_LAST_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_LAST) +#define TSDB_COMMIT_SMAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAD) +#define TSDB_COMMIT_SMAL_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAL) +#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh)) +#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh)) +#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh)) #define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRowsPerFileBlock) -#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch))) +#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch))) static void tsdbStartCommit(STsdb *pRepo); static void tsdbEndCommit(STsdb *pTsdb, int eno); @@ -1204,9 +1204,10 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) { int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDFileAggr, SDataCols *pDataCols, SBlock *pBlock, bool isLast, bool isSuper, void **ppBuf, void **ppCBuf, void **ppExBuf) { - STsdbCfg * pCfg = REPO_CFG(pRepo); - SBlockData * pBlockData = NULL; + STsdbCfg *pCfg = REPO_CFG(pRepo); + SBlockData *pBlockData = NULL; SAggrBlkData *pAggrBlkData = NULL; + STSchema *pSchema = pTable->pSchema; int64_t offset = 0, offsetAggr = 0; int rowsToWrite = pDataCols->numOfRows; @@ -1225,10 +1226,12 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF pAggrBlkData = (SAggrBlkData *)(*ppExBuf); // Get # of cols not all NULL(not including key column) - int nColsNotAllNull = 0; + col_id_t nColsNotAllNull = 0; + col_id_t nColsOfBlockSma = 0; for (int ncol = 1; ncol < pDataCols->numOfCols; ++ncol) { // ncol from 1, we skip the timestamp column - SDataCol * pDataCol = pDataCols->cols + ncol; - SBlockCol * pBlockCol = pBlockData->cols + nColsNotAllNull; + STColumn *pColumn = pSchema->columns + ncol; + SDataCol *pDataCol = pDataCols->cols + ncol; + SBlockCol *pBlockCol = pBlockData->cols + nColsNotAllNull; SAggrBlkCol *pAggrBlkCol = (SAggrBlkCol *)pAggrBlkData + nColsNotAllNull; if (isAllRowsNull(pDataCol)) { // all data to commit are NULL, just ignore it @@ -1260,7 +1263,12 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF } else { TD_SET_COL_ROWS_MISC(pBlockCol); } - nColsNotAllNull++; + + ++nColsNotAllNull; + + if (pColumn->sma) { + ++nColsOfBlockSma; + } } ASSERT(nColsNotAllNull >= 0 && nColsNotAllNull <= pDataCols->numOfCols); @@ -1357,9 +1365,8 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF return -1; } - uint32_t aggrStatus = nColsNotAllNull > 0 ? 1 : 0; + uint32_t aggrStatus = nColsOfBlockSma > 0 ? 1 : 0; if (aggrStatus > 0) { - taosCalcChecksumAppend(0, (uint8_t *)pAggrBlkData, tsizeAggr); tsdbUpdateDFileMagic(pDFileAggr, POINTER_SHIFT(pAggrBlkData, tsizeAggr - sizeof(TSCKSUM))); @@ -1378,6 +1385,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF pBlock->keyLen = keyLen; pBlock->numOfSubBlocks = isSuper ? 1 : 0; pBlock->numOfCols = nColsNotAllNull; + pBlock->numOfBSma = nColsOfBlockSma; pBlock->keyFirst = dataColsKeyFirst(pDataCols); pBlock->keyLast = dataColsKeyLast(pDataCols); pBlock->aggrStat = aggrStatus; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index 9619ac036e..304b3286fe 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -321,7 +321,7 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) { return -1; } - size_t sizeAggr = tsdbBlockAggrSize(pBlock->numOfCols, (uint32_t)pBlock->blkVer); + size_t sizeAggr = tsdbBlockAggrSize(pBlock->numOfBSma, (uint32_t)pBlock->blkVer); if (tsdbMakeRoom((void **)(&(pReadh->pAggrBlkData)), sizeAggr) < 0) return -1; int64_t nreadAggr = tsdbReadDFile(pDFileAggr, (void *)(pReadh->pAggrBlkData), sizeAggr); diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index 98256e6b24..c220e6001f 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -15,6 +15,11 @@ #include "vnd.h" +void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { + // TODO + blockDebugShowData(data); +} + void vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { SNodeMsg *pMsg; SRpcMsg *pRpc; @@ -184,12 +189,16 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { } } break; case TDMT_VND_CREATE_SMA: { // timeRangeSMA -#if 0 +#if 1 + SSmaCfg vCreateSmaReq = {0}; if (tDeserializeSVCreateTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateSmaReq) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + vWarn("vgId%d: TDMT_VND_CREATE_SMA received but deserialize failed since %s", pVnode->config.vgId, terrstr(terrno)); return -1; } + vWarn("vgId%d: TDMT_VND_CREATE_SMA received for %s:%" PRIi64, pVnode->config.vgId, vCreateSmaReq.tSma.indexName, + vCreateSmaReq.tSma.indexUid); // record current timezone of server side tstrncpy(vCreateSmaReq.tSma.timezone, tsTimezoneStr, TD_TIMEZONE_LEN); diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 29a4b7f552..d010ea4437 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -330,7 +330,6 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // step 2: insert data - STSmaDataWrapper *pSmaData = NULL; STsdb *pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb)); STsdbCfg *pCfg = &pTsdb->config; @@ -416,6 +415,8 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { col_id_t numOfCols = 4096; ASSERT_GT(numOfCols, 0); +#if 0 + STSmaDataWrapper *pSmaData = NULL; pSmaData = (STSmaDataWrapper *)buf; printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData); pSmaData->skey = skey1; @@ -459,9 +460,13 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pSmaData->dataLen = (len - sizeof(STSmaDataWrapper)); ASSERT_GE(bufSize, pSmaData->dataLen); - // execute ASSERT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); +#endif + + SSDataBlock *pSmaData = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock)); + + // step 3: query uint32_t checkDataCnt = 0; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 468e2c5431..fe48cc21e4 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -469,7 +469,7 @@ typedef struct SOptrBasicInfo { int32_t* rowCellInfoOffset; // offset value for each row result cell info SqlFunctionCtx* pCtx; SSDataBlock* pRes; - int32_t capacity; + int32_t capacity; // TODO remove it } SOptrBasicInfo; //TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f5124665d5..f38888440c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1246,17 +1246,40 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunction } } -static void projectApplyFunctions(SSDataBlock* pResult, SqlFunctionCtx *pCtx, int32_t numOfOutput) { +static void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx *pCtx, int32_t numOfOutput) { for (int32_t k = 0; k < numOfOutput; ++k) { - if (pCtx[k].fpSet.init == NULL) { // it is a project query + if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, k); colDataAssign(pColInfoData, pCtx[k].input.pData[0], pCtx[k].input.numOfRows); - } else { // TODO: arithmetic and other process. + + pResult->info.rows = pCtx[0].input.numOfRows; + } else if (pExpr[k].pExpr->nodeType == QUERY_NODE_OPERATOR) { + SArray* pBlockList = taosArrayInit(4, POINTER_BYTES); + taosArrayPush(pBlockList, &pSrcBlock); + + SScalarParam dest = {0}; + dest.columnData = taosArrayGet(pResult->pDataBlock, k); + + scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest); + pResult->info.rows = dest.numOfRows; + + taosArrayDestroy(pBlockList); + } else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) { + ASSERT(!fmIsAggFunc(pCtx->functionId)); + + SScalarParam p = {.numOfRows = pSrcBlock->info.rows}; + int32_t slotId = pExpr[k].base.pParam[0].pCol->slotId; + p.columnData = taosArrayGet(pSrcBlock->pDataBlock, slotId); + + SScalarParam dest = {0}; + dest.columnData = taosArrayGet(pResult->pDataBlock, k); + pCtx[k].sfp.process(&p, 1, &dest); + + pResult->info.rows = dest.numOfRows; + } else { ASSERT(0); } } - - pResult->info.rows = pCtx[0].input.numOfRows; } void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SArray* pDataBlock, TSKEY prevTs, @@ -2013,107 +2036,6 @@ static int32_t setCtxTagColumnInfo(SqlFunctionCtx *pCtx, int32_t numOfOutput) { return TSDB_CODE_SUCCESS; } -static SqlFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput, - int32_t** rowCellInfoOffset) { - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - - SqlFunctionCtx * pFuncCtx = (SqlFunctionCtx *)taosMemoryCalloc(numOfOutput, sizeof(SqlFunctionCtx)); - if (pFuncCtx == NULL) { - return NULL; - } - - *rowCellInfoOffset = taosMemoryCalloc(numOfOutput, sizeof(int32_t)); - if (*rowCellInfoOffset == 0) { - taosMemoryFreeClear(pFuncCtx); - return NULL; - } - - for (int32_t i = 0; i < numOfOutput; ++i) { - SExprBasicInfo *pFunct = &pExpr[i].base; - SqlFunctionCtx* pCtx = &pFuncCtx[i]; -#if 0 - SColIndex *pIndex = &pFunct->colInfo; - - if (TSDB_COL_REQ_NULL(pIndex->flag)) { - pCtx->requireNull = true; - pIndex->flag &= ~(TSDB_COL_NULL); - } else { - pCtx->requireNull = false; - } -#endif -// pCtx->inputBytes = pFunct->colBytes; -// pCtx->inputType = pFunct->colType; - - pCtx->ptsOutputBuf = NULL; - - pCtx->resDataInfo.bytes = pFunct->resSchema.bytes; - pCtx->resDataInfo.type = pFunct->resSchema.type; - - pCtx->order = pQueryAttr->order.order; -// pCtx->functionId = pFunct->functionId; - pCtx->stableQuery = pQueryAttr->stableQuery; -// pCtx->resDataInfo.interBufSize = pFunct->interBytes; - pCtx->start.key = INT64_MIN; - pCtx->end.key = INT64_MIN; - - pCtx->numOfParams = pFunct->numOfParams; - for (int32_t j = 0; j < pCtx->numOfParams; ++j) { - int16_t type = pFunct->pParam[j].param.nType; - int16_t bytes = pFunct->pParam[j].param.nType; - - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { -// taosVariantCreateFromBinary(&pCtx->param[j], pFunct->param[j].pz, bytes, type); - } else { -// taosVariantCreateFromBinary(&pCtx->param[j], (char *)&pFunct->param[j].i, bytes, type); - } - } - - // set the order information for top/bottom query - int32_t functionId = pCtx->functionId; - - if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) { - int32_t f = getExprFunctionId(&pExpr[0]); - assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY); - - pCtx->param[2].i = pQueryAttr->order.order; - pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[3].i = functionId; - pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT; - - pCtx->param[1].i = pQueryAttr->order.col.colId; - } else if (functionId == FUNCTION_INTERP) { - pCtx->param[2].i = (int8_t)pQueryAttr->fillType; - if (pQueryAttr->fillVal != NULL) { - if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) { - pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; - } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value - if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) { - taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i], pCtx->inputBytes, pCtx->inputType); - } - } - } - } else if (functionId == FUNCTION_TS_COMP) { - pCtx->param[0].i = pQueryAttr->vgId; //TODO this should be the parameter from client - pCtx->param[0].nType = TSDB_DATA_TYPE_BIGINT; - } else if (functionId == FUNCTION_TWA) { - pCtx->param[1].i = pQueryAttr->window.skey; - pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[2].i = pQueryAttr->window.ekey; - pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; - } else if (functionId == FUNCTION_ARITHM) { -// pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i); - } - } - -// for(int32_t i = 1; i < numOfOutput; ++i) { -// (*rowCellInfoOffset)[i] = (int32_t)((*rowCellInfoOffset)[i - 1] + sizeof(SResultRowEntryInfo) + pExpr[i - 1].base.interBytes); -// } - - setCtxTagColumnInfo(pFuncCtx, numOfOutput); - - return pFuncCtx; -} - static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset) { SqlFunctionCtx * pFuncCtx = (SqlFunctionCtx *)taosMemoryCalloc(numOfOutput, sizeof(SqlFunctionCtx)); if (pFuncCtx == NULL) { @@ -2132,15 +2054,22 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num SExprBasicInfo *pFunct = &pExpr->base; SqlFunctionCtx* pCtx = &pFuncCtx[i]; - if (pExpr->pExpr->_function.pFunctNode != NULL) { + pCtx->functionId = -1; + if (pExpr->pExpr->nodeType == QUERY_NODE_FUNCTION) { SFuncExecEnv env = {0}; pCtx->functionId = pExpr->pExpr->_function.pFunctNode->funcId; - fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); - pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); + if (fmIsAggFunc(pCtx->functionId)) { + fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); + pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); + } else { + fmGetScalarFuncExecFuncs(pCtx->functionId, &pCtx->sfp); + } pCtx->resDataInfo.interBufSize = env.calcMemSize; - } else { - pCtx->functionId = -1; + } else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) { + + } else if (pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) { + } pCtx->input.numOfInputCols = pFunct->numOfParams; @@ -5578,11 +5507,11 @@ EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) { SOperatorNode *node = (SOperatorNode *)pNode; if (OP_TYPE_EQUAL == node->opType) { - *(int32_t *)pContext = 1; + *(int32_t *)pContext = 1; return DEAL_RES_CONTINUE; } - *(int32_t *)pContext = 0; + *(int32_t *)pContext = 0; return DEAL_RES_IGNORE_CHILD; } @@ -5590,14 +5519,14 @@ EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) { if (1 != *(int32_t *)pContext) { return DEAL_RES_CONTINUE; } - + SColumnNode *node = (SColumnNode *)pNode; if (TSDB_INS_USER_STABLES_DBNAME_COLID == node->colId) { - *(int32_t *)pContext = 2; + *(int32_t *)pContext = 2; return DEAL_RES_CONTINUE; } - *(int32_t *)pContext = 0; + *(int32_t *)pContext = 0; return DEAL_RES_CONTINUE; } case QUERY_NODE_VALUE: { @@ -5607,7 +5536,7 @@ EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) { SValueNode *node = (SValueNode *)pNode; char *dbName = nodesGetValueFromNode(node); - strncpy(pContext, varDataVal(dbName), varDataLen(dbName)); + strncpy(pContext, varDataVal(dbName), varDataLen(dbName)); *((char *)pContext + varDataLen(dbName)) = 0; return DEAL_RES_ERROR; // stop walk } @@ -6654,7 +6583,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) blockDataCleanup(pRes); if (pProjectInfo->existDataBlock) { // TODO refactor -// STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; SSDataBlock* pBlock = pProjectInfo->existDataBlock; pProjectInfo->existDataBlock = NULL; *newgroup = true; @@ -6668,9 +6596,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC); blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows); - projectApplyFunctions(pInfo->pRes, pInfo->pCtx, pOperator->numOfOutput); - - pRes->info.rows = getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, NULL); + projectApplyFunctions(pOperator->pExpr, pInfo->pRes, pBlock, pInfo->pCtx, pOperator->numOfOutput); if (pRes->info.rows >= pProjectInfo->binfo.capacity*0.8) { copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); resetResultRowEntryResult(pInfo->pCtx, pOperator->numOfOutput); @@ -6713,15 +6639,15 @@ static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC); - updateOutputBuf(pInfo, &pInfo->capacity, pBlock->info.rows); + blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows); - projectApplyFunctions(pInfo->pRes, pInfo->pCtx, pOperator->numOfOutput); - if (pRes->info.rows >= pProjectInfo->threshold) { + projectApplyFunctions(pOperator->pExpr, pInfo->pRes, pBlock, pInfo->pCtx, pOperator->numOfOutput); + if (pRes->info.rows >= pOperator->resultInfo.threshold) { break; } } - copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); +// copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; } @@ -7811,7 +7737,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); - pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); +// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); // pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); @@ -7836,7 +7762,7 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper SStateWindowOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStateWindowOperatorInfo)); pInfo->colIndex = -1; pInfo->reptScan = false; - pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); +// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); // pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); @@ -7901,7 +7827,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); - pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); +// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); // pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); @@ -7925,7 +7851,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); - pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); +// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); // pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); @@ -8533,16 +8459,18 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* // it is a project query, or group by column if (nodeType(pTargetNode->pExpr) == QUERY_NODE_COLUMN) { + pExp->pExpr->nodeType = QUERY_NODE_COLUMN; SColumnNode* pColNode = (SColumnNode*) pTargetNode->pExpr; SDataType* pType = &pColNode->node.resType; pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pColNode->colName); - pCol->slotId = pColNode->slotId; + pCol->slotId = pColNode->slotId; // TODO refactor pCol->bytes = pType->bytes; pCol->type = pType->type; pCol->scale = pType->scale; pCol->precision = pType->precision; - } else { + } else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_FUNCTION) { + pExp->pExpr->nodeType = QUERY_NODE_FUNCTION; SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr; SDataType* pType = &pFuncNode->node.resType; @@ -8556,7 +8484,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* int32_t numOfParam = LIST_LENGTH(pFuncNode->pParameterList); for (int32_t j = 0; j < numOfParam; ++j) { SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j); - SColumnNode* pcn = (SColumnNode*)p1; + SColumnNode* pcn = (SColumnNode*)p1; // TODO refactor pCol->slotId = pcn->slotId; pCol->bytes = pcn->node.resType.bytes; @@ -8565,6 +8493,22 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pCol->precision = pcn->node.resType.precision; pCol->dataBlockId = pcn->dataBlockId; } + } else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_OPERATOR) { + pExp->pExpr->nodeType = QUERY_NODE_OPERATOR; + SOperatorNode* pNode = (SOperatorNode*) pTargetNode->pExpr; + + SDataType* pType = &pNode->node.resType; + pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pNode->node.aliasName); + + pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr; + + pCol->slotId = pTargetNode->slotId; // TODO refactor + pCol->bytes = pType->bytes; + pCol->type = pType->type; + pCol->scale = pType->scale; + pCol->precision = pType->precision; + } else { + ASSERT(0); } } @@ -8627,7 +8571,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa SArray* colList = extractScanColumnId(pScanNode->pScanCols); SOperatorInfo* pOperator = createSysTableScanOperatorInfo(pHandle->meta, pResBlock, &pScanNode->tableName, - pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, + pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList, pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId); return pOperator; } else { diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 598a28b2eb..2c0148e04f 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -33,6 +33,8 @@ extern "C" { #define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4) #define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5) #define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) +#define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7) +#define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 214204723f..f7fccb29f7 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -25,23 +25,23 @@ extern "C" { bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); void functionFinalize(SqlFunctionCtx *pCtx); -bool getCountFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); void countFunction(SqlFunctionCtx *pCtx); -bool getSumFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); void sumFunction(SqlFunctionCtx *pCtx); bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -bool getMinmaxFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); void minFunction(SqlFunctionCtx* pCtx); void maxFunction(SqlFunctionCtx *pCtx); -bool getStddevFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); void stddevFunction(SqlFunctionCtx* pCtx); void stddevFinalize(SqlFunctionCtx* pCtx); -bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); void firstFunction(SqlFunctionCtx *pCtx); void lastFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 70b2a48da7..823cb3315e 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -291,6 +291,76 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = NULL, .sprocessFunc = NULL, .finalizeFunc = NULL + }, + { + .name = "_rowts", + .type = FUNCTION_TYPE_ROWTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "tbname", + .type = FUNCTION_TYPE_TBNAME, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_qstartts", + .type = FUNCTION_TYPE_QSTARTTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_qendts", + .type = FUNCTION_TYPE_QENDTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_wstartts", + .type = FUNCTION_TYPE_QSTARTTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_wendts", + .type = FUNCTION_TYPE_QENDTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_wduration", + .type = FUNCTION_TYPE_WDURATION, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL } }; @@ -329,8 +399,23 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { break; } case FUNCTION_TYPE_CONCAT: + case FUNCTION_TYPE_ROWTS: + case FUNCTION_TYPE_TBNAME: + case FUNCTION_TYPE_QSTARTTS: + case FUNCTION_TYPE_QENDTS: + case FUNCTION_TYPE_WSTARTTS: + case FUNCTION_TYPE_WENDTS: + case FUNCTION_TYPE_WDURATION: // todo break; + + case FUNCTION_TYPE_ABS: { + SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); + int32_t paraType = pParam->node.resType.type; + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; + break; + } + default: ASSERT(0); // to found the fault ASAP. } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 10ac8bbf43..3858258374 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -44,6 +44,13 @@ static void doInitFunctionHashTable() { } } +static bool isSpecificClassifyFunc(int32_t funcId, uint64_t classification) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNC_MGT_TEST_MASK(funcMgtBuiltins[funcId].classification, classification); +} + int32_t fmFuncMgtInit() { taosThreadOnce(&functionHashTableInit, doInitFunctionHashTable); return initFunctionCode; @@ -89,10 +96,19 @@ int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet) { } bool fmIsAggFunc(int32_t funcId) { - if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { - return false; - } - return FUNC_MGT_TEST_MASK(funcMgtBuiltins[funcId].classification, FUNC_MGT_AGG_FUNC); + return isSpecificClassifyFunc(funcId, FUNC_MGT_AGG_FUNC); +} + +bool fmIsScalarFunc(int32_t funcId) { + return isSpecificClassifyFunc(funcId, FUNC_MGT_SCALAR_FUNC); +} + +bool fmIsWindowPseudoColumnFunc(int32_t funcId) { + return isSpecificClassifyFunc(funcId, FUNC_MGT_WINDOW_PC_FUNC); +} + +bool fmIsWindowClauseFunc(int32_t funcId) { + return fmIsAggFunc(funcId) || fmIsWindowPseudoColumnFunc(funcId); } void fmFuncMgtDestroy() { diff --git a/source/libs/function/src/taggfunction.c b/source/libs/function/src/taggfunction.c index 05ed30c61a..af24906c9e 100644 --- a/source/libs/function/src/taggfunction.c +++ b/source/libs/function/src/taggfunction.c @@ -3078,8 +3078,8 @@ static void arithmetic_function(SqlFunctionCtx *pCtx) { GET_RES_INFO(pCtx)->numOfRes += pCtx->size; //SScalarFunctionSupport *pSup = (SScalarFunctionSupport *)pCtx->param[1].pz; - SScalarParam output = {0}; - output.data = pCtx->pOutput; +// SScalarParam output = {0}; +// output.data = pCtx->pOutput; //evaluateExprNodeTree(pSup->pExprInfo->pExpr, pCtx->size, &output, pSup, getArithColumnData); } diff --git a/source/libs/index/inc/index_fst.h b/source/libs/index/inc/index_fst.h index cf5c3f306b..b131aa0d9d 100644 --- a/source/libs/index/inc/index_fst.h +++ b/source/libs/index/inc/index_fst.h @@ -21,9 +21,9 @@ extern "C" { #endif #include "indexInt.h" -#include "index_fst_node.h" #include "index_fst_automation.h" #include "index_fst_counting_writer.h" +#include "index_fst_node.h" #include "index_fst_registry.h" #include "index_fst_util.h" @@ -257,9 +257,9 @@ typedef struct FstMeta { } FstMeta; typedef struct Fst { - FstMeta* meta; - FstSlice* data; // - FstNode* root; // + FstMeta* meta; + FstSlice* data; // + FstNode* root; // TdThreadMutex mtx; } Fst; @@ -325,10 +325,10 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb FstStreamBuilder* fstStreamBuilderCreate(Fst* fst, AutomationCtx* aut); void fstStreamBuilderDestroy(FstStreamBuilder* b); -// set up bound range -// refator, simple code by marco -FstStreamBuilder* fstStreamBuilderRange(FstStreamBuilder* b, FstSlice* val, RangeType type); +// set up bound range +// refator later: to simple code by marco +void fstStreamBuilderSetRange(FstStreamBuilder* b, FstSlice* val, RangeType type); #ifdef __cplusplus } diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index 09f382bbdc..1a556950ba 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -1184,7 +1184,7 @@ StreamWithState* streamWithStateCreate(Fst* fst, AutomationCtx* automation, FstB sws->aut = automation; sws->inp = (SArray*)taosArrayInit(256, sizeof(uint8_t)); - sws->emptyOutput.null = false; + sws->emptyOutput.null = true; sws->emptyOutput.out = 0; sws->stack = (SArray*)taosArrayInit(256, sizeof(StreamState)); @@ -1239,8 +1239,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) { for (uint32_t i = 0; i < len; i++) { uint8_t b = data[i]; uint64_t res = 0; - bool null = fstNodeFindInput(node, b, &res); - if (null == false) { + bool find = fstNodeFindInput(node, b, &res); + if (find == true) { FstTransition trn; fstNodeGetTransitionAt(node, res, &trn); void* preState = autState; @@ -1317,7 +1317,7 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb if (FST_NODE_ADDR(p->node) != fstGetRootAddr(sws->fst)) { taosArrayPop(sws->inp); } - streamStateDestroy(p); + // streamStateDestroy(p); continue; } FstTransition trn; @@ -1425,9 +1425,9 @@ void fstStreamBuilderDestroy(FstStreamBuilder* b) { taosMemoryFreeClear(b->max); taosMemoryFree(b); } -FstStreamBuilder* fstStreamBuilderRange(FstStreamBuilder* b, FstSlice* val, RangeType type) { +void fstStreamBuilderSetRange(FstStreamBuilder* b, FstSlice* val, RangeType type) { if (b == NULL) { - return NULL; + return; } if (type == GE) { b->min->type = Included; @@ -1446,5 +1446,4 @@ FstStreamBuilder* fstStreamBuilderRange(FstStreamBuilder* b, FstSlice* val, Rang fstSliceDestroy(&(b->max->data)); b->max->data = fstSliceDeepCopy(val, 0, FST_SLICE_LEN(val) - 1); } - return b; } diff --git a/source/libs/index/src/index_fst_automation.c b/source/libs/index/src/index_fst_automation.c index 668a527d4a..20e981559d 100644 --- a/source/libs/index/src/index_fst_automation.c +++ b/source/libs/index/src/index_fst_automation.c @@ -85,10 +85,20 @@ static void* prefixStart(AutomationCtx* ctx) { }; static bool prefixIsMatch(AutomationCtx* ctx, void* sv) { StartWithStateValue* ssv = (StartWithStateValue*)sv; - return ssv->val == strlen(ctx->data); + if (ssv == NULL) { + return false; + } + if (ssv->type == FST_INT) { + return ssv->val == strlen(ctx->data); + } else { + return false; + } } static bool prefixCanMatch(AutomationCtx* ctx, void* sv) { StartWithStateValue* ssv = (StartWithStateValue*)sv; + if (ssv == NULL) { + return false; + } return ssv->val >= 0; } static bool prefixWillAlwaysMatch(AutomationCtx* ctx, void* state) { return true; } @@ -154,15 +164,7 @@ AutomationCtx* automCtxCreate(void* data, AutomationType atype) { // add more search type } - char* dst = NULL; - if (data != NULL) { - char* src = (char*)data; - size_t len = strlen(src); - dst = (char*)taosMemoryCalloc(1, len * sizeof(char) + 1); - memcpy(dst, src, len); - } - - ctx->data = dst; + ctx->data = (data != NULL ? strdup((char*)data) : NULL); ctx->type = atype; ctx->stdata = (void*)sv; return ctx; diff --git a/source/libs/index/test/fstTest.cc b/source/libs/index/test/fstTest.cc index 94923726dd..f13fdf7214 100644 --- a/source/libs/index/test/fstTest.cc +++ b/source/libs/index/test/fstTest.cc @@ -96,11 +96,37 @@ class FstReadMemory { char* ch = (char*)fstSliceData(s, &sz); std::string key(ch, sz); printf("key: %s, val: %" PRIu64 "\n", key.c_str(), (uint64_t)(rt->out.out)); + result.push_back(rt->out.out); swsResultDestroy(rt); } - for (size_t i = 0; i < result.size(); i++) { + return true; + } + bool SearchRange(AutomationCtx* ctx, const std::string& low, RangeType lowType, const std::string& high, + RangeType highType, std::vector& result) { + FstStreamBuilder* sb = fstSearch(_fst, ctx); + + FstSlice l = fstSliceCreate((uint8_t*)low.c_str(), low.size()); + FstSlice h = fstSliceCreate((uint8_t*)high.c_str(), high.size()); + + // range [low, high); + fstStreamBuilderSetRange(sb, &l, lowType); + fstStreamBuilderSetRange(sb, &h, highType); + + fstSliceDestroy(&l); + fstSliceDestroy(&h); + + StreamWithState* st = streamBuilderIntoStream(sb); + StreamWithStateResult* rt = NULL; + while ((rt = streamWithStateNextWith(st, NULL)) != NULL) { + // result.push_back((uint64_t)(rt->out.out)); + FstSlice* s = &rt->data; + int32_t sz = 0; + char* ch = (char*)fstSliceData(s, &sz); + std::string key(ch, sz); + printf("key: %s, val: %" PRIu64 "\n", key.c_str(), (uint64_t)(rt->out.out)); + result.push_back(rt->out.out); + swsResultDestroy(rt); } - std::cout << std::endl; return true; } bool SearchWithTimeCostUs(AutomationCtx* ctx, std::vector& result) { @@ -233,7 +259,7 @@ void checkFstLongTerm() { // taosMemoryFree(ctx); // delete m; } -void checkFstCheckIterator() { +void checkFstCheckIterator1() { FstWriter* fw = new FstWriter; int64_t s = taosGetTimestampUs(); int count = 2; @@ -243,8 +269,7 @@ void checkFstCheckIterator() { std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; fw->Put("Hello world", 1); - fw->Put("hello world", 2); - fw->Put("hello worle", 3); + fw->Put("Hello worle", 2); fw->Put("hello worlf", 4); delete fw; @@ -258,7 +283,7 @@ void checkFstCheckIterator() { // prefix search std::vector result; - AutomationCtx* ctx = automCtxCreate((void*)"H", AUTOMATION_PREFIX); + AutomationCtx* ctx = automCtxCreate((void*)"He", AUTOMATION_ALWAYS); m->Search(ctx, result); std::cout << "size: " << result.size() << std::endl; // assert(result.size() == count); @@ -269,6 +294,161 @@ void checkFstCheckIterator() { taosMemoryFree(ctx); delete m; } +void checkFstCheckIterator2() { + FstWriter* fw = new FstWriter; + int64_t s = taosGetTimestampUs(); + int count = 2; + // Performance_fstWriteRecords(fw); + int64_t e = taosGetTimestampUs(); + + std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; + + fw->Put("a", 1); + fw->Put("b", 2); + fw->Put("c", 4); + delete fw; + + FstReadMemory* m = new FstReadMemory(1024 * 64); + if (m->init() == false) { + std::cout << "init readMemory failed" << std::endl; + delete m; + return; + } + + // prefix search + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"He", AUTOMATION_ALWAYS); + m->Search(ctx, result); + std::cout << "size: " << result.size() << std::endl; + // assert(result.size() == count); + for (int i = 0; i < result.size(); i++) { + // assert(result[i] == i); // check result + } + + taosMemoryFree(ctx); + delete m; +} +void checkFstCheckIteratorPrefix() { + FstWriter* fw = new FstWriter; + int64_t s = taosGetTimestampUs(); + int count = 2; + // Performance_fstWriteRecords(fw); + int64_t e = taosGetTimestampUs(); + + std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; + + fw->Put("Hello world", 1); + fw->Put("Hello worle", 2); + fw->Put("hello worlf", 4); + fw->Put("ja", 4); + fw->Put("jb", 4); + fw->Put("jc", 4); + fw->Put("jddddddddd", 4); + fw->Put("jefffffff", 4); + delete fw; + + FstReadMemory* m = new FstReadMemory(1024 * 64); + if (m->init() == false) { + std::cout << "init readMemory failed" << std::endl; + delete m; + return; + } + { + // prefix search + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 1); + taosMemoryFree(ctx); + } + { + // prefix search + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"Hello", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 2); + taosMemoryFree(ctx); + } + { + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"jddd", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 1); + taosMemoryFree(ctx); + } + delete m; +} +void checkFstCheckIteratorRange1() { + FstWriter* fw = new FstWriter; + int64_t s = taosGetTimestampUs(); + int count = 2; + // Performance_fstWriteRecords(fw); + int64_t e = taosGetTimestampUs(); + + std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; + + fw->Put("a", 1); + fw->Put("b", 2); + fw->Put("c", 3); + fw->Put("d", 4); + fw->Put("e", 5); + delete fw; + + FstReadMemory* m = new FstReadMemory(1024 * 64); + if (m->init() == false) { + std::cout << "init readMemory failed" << std::endl; + delete m; + return; + } + { + // prefix search + std::vector result; + AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_ALWAYS); + // [b, e) + m->SearchRange(ctx, "b", GE, "e", LT, result); + assert(result.size() == 3); + taosMemoryFree(ctx); + } +} +void checkFstCheckIteratorRange2() { + FstWriter* fw = new FstWriter; + int64_t s = taosGetTimestampUs(); + int count = 2; + // Performance_fstWriteRecords(fw); + int64_t e = taosGetTimestampUs(); + + std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; + + fw->Put("ab", 1); + fw->Put("bd", 2); + fw->Put("cdd", 3); + fw->Put("cde", 3); + fw->Put("ddd", 4); + fw->Put("ed", 5); + delete fw; + + FstReadMemory* m = new FstReadMemory(1024 * 64); + if (m->init() == false) { + std::cout << "init readMemory failed" << std::endl; + delete m; + return; + } + { + // prefix search + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_ALWAYS); + + // [b, e) + m->SearchRange(ctx, "b", GE, "ed", LT, result); + assert(result.size() == 4); + taosMemoryFree(ctx); + } +} void fst_get(Fst* fst) { for (int i = 0; i < 10000; i++) { @@ -332,7 +512,11 @@ int main(int argc, char* argv[]) { // path suid colName ver // iterTFileReader(argv[1], argv[2], argv[3], argv[4]); //} - checkFstCheckIterator(); + // checkFstCheckIterator1(); + // checkFstCheckIterator2(); + // checkFstCheckIteratorPrefix(); + checkFstCheckIteratorRange1(); + checkFstCheckIteratorRange2(); // checkFstLongTerm(); // checkFstPrefixSearch(); diff --git a/source/libs/index/test/fstUT.cc b/source/libs/index/test/fstUT.cc index 1bdc7fc9c9..e7efbaf21f 100644 --- a/source/libs/index/test/fstUT.cc +++ b/source/libs/index/test/fstUT.cc @@ -13,9 +13,9 @@ #include "index_fst_util.h" #include "index_tfile.h" #include "tglobal.h" +#include "tlog.h" #include "tskiplist.h" #include "tutil.h" -#include "tlog.h" static std::string dir = "/tmp/index"; diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 358edcb279..0fe5df183d 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -53,7 +53,6 @@ typedef enum EDatabaseOptionType { DB_OPTION_SINGLE_STABLE, DB_OPTION_STREAM_MODE, DB_OPTION_RETENTIONS, - DB_OPTION_FILE_FACTOR, DB_OPTION_MAX } EDatabaseOptionType; @@ -63,6 +62,8 @@ typedef enum ETableOptionType { TABLE_OPTION_TTL, TABLE_OPTION_COMMENT, TABLE_OPTION_SMA, + TABLE_OPTION_FILE_FACTOR, + TABLE_OPTION_DELAY, TABLE_OPTION_MAX } ETableOptionType; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 529fbb55c8..951fba0052 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -15,6 +15,7 @@ #include #include +#include "functionMgt.h" #include "nodes.h" #include "parToken.h" #include "ttokendef.h" @@ -146,7 +147,6 @@ db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &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); } -db_options(A) ::= db_options(B) FILE_FACTOR NK_FLOAT(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FILE_FACTOR, &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); } @@ -263,6 +263,8 @@ table_options(A) ::= table_options(B) KEEP NK_INTEGER(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); } @@ -416,7 +418,7 @@ topic_name(A) ::= NK_ID(B). /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } -//expression(A) ::= pseudo_column(B). { A = B; } +expression(A) ::= pseudo_column(B). { A = B; } expression(A) ::= column_reference(B). { A = B; } expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); } @@ -466,7 +468,38 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C). column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); } column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); } -//pseudo_column(A) ::= NK_NOW. { A = createFunctionNode(pCxt, NULL, NULL); } +//pseudo_column(A) ::= NK_NOW. { A = createFunctionNode(pCxt, NULL, NULL); } +pseudo_column(A) ::= NK_UNDERLINE(B) ROWTS(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } +pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= NK_UNDERLINE(B) QSTARTTS(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } +pseudo_column(A) ::= NK_UNDERLINE(B) QENDTS(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } +pseudo_column(A) ::= NK_UNDERLINE(B) WSTARTTS(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } +pseudo_column(A) ::= NK_UNDERLINE(B) WENDTS(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } +pseudo_column(A) ::= NK_UNDERLINE(B) WDURATION(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + } /************************************************ predicate ***********************************************************/ predicate(A) ::= expression(B) compare_op(C) expression(D). { diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index a958a748e2..c5a632482c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -248,12 +248,37 @@ static SDatabaseOptions* setDbStreamMode(SAstCreateContext* pCxt, SDatabaseOptio } static SDatabaseOptions* setDbRetentions(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { - // todo - return pOptions; -} + pOptions->pRetentions = nodesMakeList(); + if (NULL == pOptions->pRetentions) { + pCxt->valid = false; + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); + return pOptions; + } + + char val[20] = {0}; + int32_t len = trimString(pVal->z, pVal->n, val, sizeof(val)); + char* pStart = val; + char* pEnd = val + len; + int32_t sepOrder = 1; + while (1) { + char* pPos = strchr(pStart, (0 == sepOrder % 2) ? ',' : ':'); + SToken t = { .type = TK_NK_VARIABLE, .z = pStart, .n = (NULL == pPos ? pEnd - pStart : pPos - pStart)}; + if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pOptions->pRetentions, createDurationValueNode(pCxt, &t))) { + pCxt->valid = false; + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); + return pOptions; + } + if (NULL == pPos) { + break; + } + pStart = pPos + 1; + } + + if (LIST_LENGTH(pOptions->pRetentions) % 2 != 0) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid db option retentions: %s", val); + pCxt->valid = false; + } -static SDatabaseOptions* setDbFileFactor(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { - // todo return pOptions; } @@ -276,7 +301,6 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_SINGLE_STABLE] = setDbSingleStable; setDbOptionFuncs[DB_OPTION_STREAM_MODE] = setDbStreamMode; setDbOptionFuncs[DB_OPTION_RETENTIONS] = setDbRetentions; - setDbOptionFuncs[DB_OPTION_FILE_FACTOR] = setDbFileFactor; } static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { @@ -314,10 +338,36 @@ static STableOptions* setTableComment(SAstCreateContext* pCxt, STableOptions* pO return pOptions; } +static STableOptions* setTableFileFactor(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { + double val = strtod(pVal->z, NULL); + if (val < TSDB_MIN_DB_FILE_FACTOR || val > TSDB_MAX_DB_FILE_FACTOR) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, + "invalid table option file_factor: %f valid range: [%d, %d]", val, TSDB_MIN_DB_FILE_FACTOR, TSDB_MAX_DB_FILE_FACTOR); + pCxt->valid = false; + return pOptions; + } + pOptions->filesFactor = val; + return pOptions; +} + +static STableOptions* setTableDelay(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { + int64_t val = strtol(pVal->z, NULL, 10); + if (val < TSDB_MIN_DB_DELAY || val > TSDB_MAX_DB_DELAY) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, + "invalid table option delay: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_DELAY, TSDB_MAX_DB_DELAY); + pCxt->valid = false; + return pOptions; + } + pOptions->delay = val; + return pOptions; +} + static void initSetTableOptionFp() { setTableOptionFuncs[TABLE_OPTION_KEEP] = setTableKeep; setTableOptionFuncs[TABLE_OPTION_TTL] = setTableTtl; setTableOptionFuncs[TABLE_OPTION_COMMENT] = setTableComment; + setTableOptionFuncs[TABLE_OPTION_FILE_FACTOR] = setTableFileFactor; + setTableOptionFuncs[TABLE_OPTION_DELAY] = setTableDelay; } void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) { @@ -906,6 +956,8 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { CHECK_OUT_OF_MEM(pOptions); pOptions->keep = TSDB_DEFAULT_KEEP; pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION; + pOptions->filesFactor = TSDB_DEFAULT_DB_FILE_FACTOR; + pOptions->delay = TSDB_DEFAULT_DB_DELAY; return (SNode*)pOptions; } @@ -914,6 +966,8 @@ SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt) { CHECK_OUT_OF_MEM(pOptions); pOptions->keep = -1; pOptions->ttl = -1; + pOptions->filesFactor = -1; + pOptions->delay = -1; return (SNode*)pOptions; } @@ -927,7 +981,12 @@ SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pS } SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pFuncs) { - // todo + if (1 != LIST_LENGTH(pFuncs)) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid table option rollup: only one function is allowed"); + pCxt->valid = false; + return pOptions; + } + ((STableOptions*)pOptions)->pFuncs = pFuncs; return pOptions; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 79651cd325..adf5523db3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -48,6 +48,7 @@ static SKeyword keywordTable[] = { {"DATABASE", TK_DATABASE}, {"DATABASES", TK_DATABASES}, {"DAYS", TK_DAYS}, + {"DELAY", TK_DELAY}, {"DESC", TK_DESC}, {"DISTINCT", TK_DISTINCT}, {"DNODE", TK_DNODE}, @@ -55,7 +56,7 @@ static SKeyword keywordTable[] = { {"DOUBLE", TK_DOUBLE}, {"DROP", TK_DROP}, {"EXISTS", TK_EXISTS}, - // {"FILE", TK_FILE}, + {"FILE_FACTOR", TK_FILE_FACTOR}, {"FILL", TK_FILL}, {"FLOAT", TK_FLOAT}, {"FROM", TK_FROM}, @@ -103,10 +104,15 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, + {"QENDTS", TK_QENDTS}, {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, + {"QSTARTTS", TK_QSTARTTS}, {"QUORUM", TK_QUORUM}, {"REPLICA", TK_REPLICA}, + {"RETENTIONS", TK_RETENTIONS}, + {"ROLLUP", TK_ROLLUP}, + {"ROWTS", TK_ROWTS}, {"SELECT", TK_SELECT}, {"SESSION", TK_SESSION}, {"SHOW", TK_SHOW}, @@ -124,6 +130,7 @@ static SKeyword keywordTable[] = { {"TABLE", TK_TABLE}, {"TABLES", TK_TABLES}, {"TAGS", TK_TAGS}, + {"TBNAME", TK_TBNAME}, {"TIMESTAMP", TK_TIMESTAMP}, {"TINYINT", TK_TINYINT}, {"TOPIC", TK_TOPIC}, @@ -138,7 +145,10 @@ static SKeyword keywordTable[] = { {"VARCHAR", TK_VARCHAR}, {"VGROUPS", TK_VGROUPS}, {"WAL", TK_WAL}, + {"WDURATION", TK_WDURATION}, + {"WENDTS", TK_WENDTS}, {"WHERE", TK_WHERE}, + {"WSTARTTS", TK_WSTARTTS}, // {"ID", TK_ID}, // {"STRING", TK_STRING}, // {"EQ", TK_EQ}, @@ -230,7 +240,6 @@ static SKeyword keywordTable[] = { // {"TRIGGER", TK_TRIGGER}, // {"VIEW", TK_VIEW}, // {"SEMI", TK_SEMI}, - // {"TBNAME", TK_TBNAME}, // {"VNODES", TK_VNODES}, // {"PARTITIONS", TK_PARTITIONS}, // {"TOPICS", TK_TOPICS}, @@ -424,6 +433,10 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { *tokenId = TK_NK_QUESTION; return 1; } + case '_': { + *tokenId = TK_NK_UNDERLINE; + return 1; + } case '`': case '\'': case '"': { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 60ee8be76d..6771eafa09 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -920,7 +920,35 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } -static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt, SCreateDbReq* pReq) { +static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbReq* pReq) { + if (NULL != pRetentions) { + pReq->pRetensions = taosArrayInit(LIST_LENGTH(pRetentions) / 2, sizeof(SRetention)); + if (NULL == pReq->pRetensions) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SValueNode* pFreq = NULL; + SValueNode* pKeep = NULL; + SNode* pNode = NULL; + int32_t index = 0; + FOREACH(pNode, pRetentions) { + if (0 == index % 2) { + pFreq = (SValueNode*)pNode; + } else { + pKeep = (SValueNode*)pNode; + SRetention retention = { + .freq = pFreq->datum.i, + .freqUnit = pFreq->unit, + .keep = pKeep->datum.i, + .keepUnit = pKeep->unit + }; + taosArrayPush(pReq->pRetensions, &retention); + } + } + } + return TSDB_CODE_SUCCESS; +} + +static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt, SCreateDbReq* pReq) { SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, pReq->db); @@ -944,27 +972,45 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt pReq->cacheLastRow = pStmt->pOptions->cachelast; pReq->ignoreExist = pStmt->ignoreExists; pReq->streamMode = pStmt->pOptions->streamMode; - return; + return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); +} + +static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { + if (NULL != pStmt->pOptions->pRetentions) { + SNode* pNode = NULL; + FOREACH(pNode, pStmt->pOptions->pRetentions) { + if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pNode)) { + return pCxt->errCode; + } + } + } + return TSDB_CODE_SUCCESS; } static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { SCreateDbReq createReq = {0}; - buildCreateDbReq(pCxt, pStmt, &createReq); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; + int32_t code = checkCreateDatabase(pCxt, pStmt); + if (TSDB_CODE_SUCCESS == code) { + code = buildCreateDbReq(pCxt, pStmt, &createReq); } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB; - pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); - return TSDB_CODE_SUCCESS; + if (TSDB_CODE_SUCCESS == code) { + pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB; + pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + } + + return code; } static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) { @@ -1035,7 +1081,7 @@ static int32_t calcTypeBytes(SDataType dt) { } } -static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { +static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) { *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); SNode* pNode; FOREACH(pNode, pList) { @@ -1047,13 +1093,77 @@ static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { return TSDB_CODE_SUCCESS; } +static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { + if (NULL == pList) { + return TSDB_CODE_SUCCESS; + } + + *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); + SNode* pNode; + FOREACH(pNode, pList) { + SColumnNode* pCol = (SColumnNode*)pNode; + SField field = { .type = pCol->node.resType.type, .bytes = calcTypeBytes(pCol->node.resType) }; + strcpy(field.name, pCol->colName); + taosArrayPush(*pArray, &field); + } + return TSDB_CODE_SUCCESS; +} + +static const SColumnDefNode* findColDef(const SNodeList* pCols, const SColumnNode* pCol) { + SNode* pColDef = NULL; + FOREACH(pColDef, pCols) { + if (0 == strcmp(pCol->colName, ((SColumnDefNode*)pColDef)->colName)) { + return (SColumnDefNode*)pColDef; + } + } + return NULL; +} + +static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { + if (NULL != pStmt->pOptions->pSma) { + SNode* pNode = NULL; + FOREACH(pNode, pStmt->pOptions->pSma) { + SColumnNode* pSmaCol = (SColumnNode*)pNode; + const SColumnDefNode* pColDef = findColDef(pStmt->pCols, pSmaCol); + if (NULL == pColDef) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pSmaCol->colName); + } + pSmaCol->node.resType = pColDef->dataType; + } + } + if (NULL != pStmt->pOptions->pFuncs) { + SFunctionNode* pFunc = nodesListGetNode(pStmt->pOptions->pFuncs, 0); + if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pFunc->functionName, &pFunc->funcId, &pFunc->funcType)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_FUNTION, pFunc->functionName); + } + } + return TSDB_CODE_SUCCESS; +} + +static int32_t getAggregationMethod(SNodeList* pFuncs) { + if (NULL == pFuncs) { + return -1; + } + return ((SFunctionNode*)nodesListGetNode(pFuncs, 0))->funcId; +} + static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { + int32_t code = checkCreateTable(pCxt, pStmt); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + SMCreateStbReq createReq = {0}; createReq.igExists = pStmt->ignoreExists; - columnNodeToField(pStmt->pCols, &createReq.pColumns); - columnNodeToField(pStmt->pTags, &createReq.pTags); + createReq.aggregationMethod = getAggregationMethod(pStmt->pOptions->pFuncs); + createReq.xFilesFactor = pStmt->pOptions->filesFactor; + createReq.delay = pStmt->pOptions->delay; + columnDefNodeToField(pStmt->pCols, &createReq.pColumns); + columnDefNodeToField(pStmt->pTags, &createReq.pTags); + columnNodeToField(pStmt->pOptions->pSma, &createReq.pSmas); createReq.numOfColumns = LIST_LENGTH(pStmt->pCols); createReq.numOfTags = LIST_LENGTH(pStmt->pTags); + createReq.numOfSmas = LIST_LENGTH(pStmt->pOptions->pSma); SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; strcpy(tableName.dbname, pStmt->dbName); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 451587c8bf..fcc47d53fb 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -32,6 +32,7 @@ #include #include +#include "functionMgt.h" #include "nodes.h" #include "parToken.h" #include "ttokendef.h" @@ -73,7 +74,7 @@ ** which is ParseTOKENTYPE. The entry in the union ** for terminal symbols is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. If -** zero the stack is dynamically sized using taosMemoryRealloc() +** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument ** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter @@ -99,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 258 +#define YYNOCODE 268 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - ENullOrder yy73; - SNodeList* yy136; - SNode* yy140; - EJoinType yy144; - SToken yy149; - EOrder yy158; - int32_t yy160; - SAlterOption yy233; - SDataType yy256; - EFillMode yy306; - EOperatorType yy320; - bool yy497; + EOrder yy106; + EFillMode yy142; + SNode* yy176; + SToken yy225; + EJoinType yy236; + SAlterOption yy325; + EOperatorType yy404; + SDataType yy448; + ENullOrder yy465; + bool yy505; + int32_t yy508; + SNodeList* yy512; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -131,17 +132,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 430 -#define YYNRULE 337 -#define YYNTOKEN 163 -#define YY_MAX_SHIFT 429 -#define YY_MIN_SHIFTREDUCE 662 -#define YY_MAX_SHIFTREDUCE 998 -#define YY_ERROR_ACTION 999 -#define YY_ACCEPT_ACTION 1000 -#define YY_NO_ACTION 1001 -#define YY_MIN_REDUCE 1002 -#define YY_MAX_REDUCE 1338 +#define YYNSTATE 432 +#define YYNRULE 346 +#define YYNTOKEN 172 +#define YY_MAX_SHIFT 431 +#define YY_MIN_SHIFTREDUCE 673 +#define YY_MAX_SHIFTREDUCE 1018 +#define YY_ERROR_ACTION 1019 +#define YY_ACCEPT_ACTION 1020 +#define YY_NO_ACTION 1021 +#define YY_MIN_REDUCE 1022 +#define YY_MAX_REDUCE 1367 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -208,398 +209,407 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1263) +#define YY_ACTTAB_COUNT (1291) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1045, 1204, 225, 43, 24, 170, 362, 1200, 1206, 1095, - /* 10 */ 250, 269, 89, 31, 29, 27, 26, 25, 20, 1204, - /* 20 */ 1101, 27, 26, 25, 1084, 1200, 1205, 1106, 31, 29, - /* 30 */ 27, 26, 25, 361, 1000, 78, 209, 869, 77, 76, - /* 40 */ 75, 74, 73, 72, 71, 70, 69, 1091, 211, 414, - /* 50 */ 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, - /* 60 */ 403, 402, 401, 400, 399, 398, 397, 396, 1003, 105, - /* 70 */ 270, 1014, 881, 31, 29, 27, 26, 25, 1231, 132, - /* 80 */ 904, 349, 111, 249, 237, 346, 1216, 1180, 275, 78, - /* 90 */ 131, 22, 77, 76, 75, 74, 73, 72, 71, 70, - /* 100 */ 69, 31, 29, 27, 26, 25, 1231, 1317, 211, 291, - /* 110 */ 320, 286, 270, 346, 290, 44, 905, 289, 129, 287, - /* 120 */ 117, 345, 288, 348, 1315, 23, 232, 1192, 899, 900, - /* 130 */ 901, 902, 903, 907, 908, 909, 1082, 204, 1217, 1220, - /* 140 */ 904, 772, 385, 384, 383, 776, 382, 778, 779, 381, - /* 150 */ 781, 378, 109, 787, 375, 789, 790, 372, 369, 1151, - /* 160 */ 1216, 849, 128, 1144, 305, 224, 125, 43, 326, 189, - /* 170 */ 1149, 361, 1136, 30, 28, 941, 905, 847, 258, 242, - /* 180 */ 1231, 234, 395, 849, 1102, 23, 232, 346, 899, 900, - /* 190 */ 901, 902, 903, 907, 908, 909, 1204, 348, 361, 847, - /* 200 */ 896, 1192, 1200, 1205, 306, 362, 334, 848, 12, 118, - /* 210 */ 66, 61, 1217, 1220, 1256, 1216, 965, 279, 210, 1252, - /* 220 */ 1168, 10, 122, 121, 30, 28, 1106, 120, 1317, 848, - /* 230 */ 1317, 1, 234, 426, 849, 1231, 316, 963, 964, 966, - /* 240 */ 967, 117, 333, 117, 1216, 1315, 245, 1315, 10, 324, - /* 250 */ 847, 337, 348, 1171, 1173, 426, 1192, 349, 699, 12, - /* 260 */ 698, 850, 853, 1181, 1231, 362, 62, 1217, 1220, 1256, - /* 270 */ 66, 333, 283, 227, 1252, 112, 282, 285, 700, 330, - /* 280 */ 848, 348, 1, 850, 853, 1192, 1106, 166, 118, 9, - /* 290 */ 8, 59, 1216, 312, 1283, 62, 1217, 1220, 1256, 284, - /* 300 */ 92, 93, 227, 1252, 112, 1317, 426, 330, 1098, 106, - /* 310 */ 1073, 906, 1231, 31, 29, 27, 26, 25, 1316, 346, - /* 320 */ 21, 1216, 1315, 1284, 395, 1270, 90, 871, 92, 348, - /* 330 */ 910, 422, 421, 1192, 850, 853, 114, 1263, 1264, 870, - /* 340 */ 1268, 1231, 1267, 62, 1217, 1220, 1256, 334, 346, 118, - /* 350 */ 227, 1252, 1329, 698, 90, 1097, 1216, 867, 348, 917, - /* 360 */ 1231, 1290, 1192, 868, 163, 1263, 329, 346, 328, 277, - /* 370 */ 238, 1317, 62, 1217, 1220, 1256, 1231, 362, 104, 227, - /* 380 */ 1252, 1329, 1103, 346, 117, 1216, 1108, 388, 1315, 1025, - /* 390 */ 1313, 1093, 323, 348, 30, 28, 1192, 1192, 1106, 1024, - /* 400 */ 1270, 336, 234, 104, 849, 1231, 1083, 62, 1217, 1220, - /* 410 */ 1256, 1109, 346, 1151, 227, 1252, 1329, 1266, 362, 239, - /* 420 */ 847, 1151, 348, 359, 1149, 1274, 1192, 246, 165, 12, - /* 430 */ 1192, 334, 1149, 30, 28, 1015, 199, 1217, 1220, 1106, - /* 440 */ 1192, 234, 1216, 849, 194, 1023, 1022, 1021, 137, 196, - /* 450 */ 848, 135, 1, 1041, 319, 1317, 30, 28, 347, 847, - /* 460 */ 6, 195, 1231, 392, 234, 1216, 849, 391, 117, 346, - /* 470 */ 1020, 123, 1315, 1151, 118, 292, 426, 325, 321, 348, - /* 480 */ 1019, 1018, 847, 1192, 1172, 1231, 1192, 1192, 1192, 848, - /* 490 */ 393, 7, 346, 63, 1217, 1220, 1256, 1151, 872, 1089, - /* 500 */ 1255, 1252, 348, 1048, 850, 853, 1192, 948, 1150, 390, - /* 510 */ 389, 1192, 848, 869, 7, 426, 63, 1217, 1220, 1256, - /* 520 */ 244, 1192, 1192, 344, 1252, 30, 28, 303, 104, 30, - /* 530 */ 28, 64, 387, 234, 341, 849, 1108, 234, 426, 849, - /* 540 */ 301, 1216, 1270, 850, 853, 1002, 31, 29, 27, 26, - /* 550 */ 25, 847, 291, 936, 286, 847, 1017, 290, 118, 1265, - /* 560 */ 289, 1231, 287, 118, 1216, 288, 850, 853, 346, 87, - /* 570 */ 86, 85, 84, 83, 82, 81, 80, 79, 348, 867, - /* 580 */ 1036, 848, 1192, 7, 1231, 848, 251, 1, 1074, 263, - /* 590 */ 1016, 346, 107, 1217, 1220, 940, 429, 1192, 264, 151, - /* 600 */ 1216, 348, 294, 167, 362, 1192, 247, 426, 342, 360, - /* 610 */ 187, 426, 308, 88, 104, 63, 1217, 1220, 1256, 418, - /* 620 */ 1231, 186, 1108, 1253, 98, 1106, 1013, 346, 317, 335, - /* 630 */ 1330, 1192, 1034, 1012, 1011, 850, 853, 348, 362, 850, - /* 640 */ 853, 1192, 1145, 184, 233, 362, 60, 1010, 1009, 182, - /* 650 */ 248, 205, 1217, 1220, 297, 1008, 160, 1007, 1216, 1106, - /* 660 */ 1275, 936, 1232, 1216, 276, 262, 1106, 1192, 257, 256, - /* 670 */ 255, 254, 253, 338, 1192, 1192, 1006, 856, 1231, 139, - /* 680 */ 358, 1216, 138, 1231, 141, 346, 1216, 140, 1192, 1192, - /* 690 */ 346, 855, 994, 995, 311, 348, 1192, 147, 1192, 1192, - /* 700 */ 348, 1231, 313, 330, 1192, 331, 1231, 859, 346, 205, - /* 710 */ 1217, 1220, 1005, 346, 107, 1217, 1220, 1192, 348, 9, - /* 720 */ 8, 858, 1192, 348, 92, 231, 867, 1192, 1216, 939, - /* 730 */ 235, 1216, 205, 1217, 1220, 1286, 1216, 205, 1217, 1220, - /* 740 */ 31, 29, 27, 26, 25, 339, 330, 1170, 1231, 52, - /* 750 */ 90, 1231, 1331, 1192, 169, 346, 1231, 1081, 346, 332, - /* 760 */ 113, 1263, 1264, 346, 1268, 348, 1099, 92, 348, 1192, - /* 770 */ 2, 119, 1192, 348, 1216, 143, 260, 1192, 142, 203, - /* 780 */ 1217, 1220, 206, 1217, 1220, 962, 156, 197, 1217, 1220, - /* 790 */ 252, 259, 261, 90, 1231, 265, 1216, 41, 154, 881, - /* 800 */ 911, 346, 1216, 115, 1263, 1264, 875, 1268, 997, 998, - /* 810 */ 266, 348, 32, 267, 392, 1192, 1231, 124, 391, 874, - /* 820 */ 878, 58, 1231, 346, 127, 207, 1217, 1220, 1210, 346, - /* 830 */ 1216, 54, 32, 348, 842, 268, 1216, 1192, 271, 348, - /* 840 */ 1208, 393, 42, 1192, 278, 130, 32, 198, 1217, 1220, - /* 850 */ 1231, 873, 68, 208, 1217, 1220, 1231, 346, 175, 280, - /* 860 */ 390, 389, 223, 346, 1216, 1096, 354, 348, 181, 134, - /* 870 */ 173, 1192, 1092, 348, 765, 136, 100, 1192, 95, 101, - /* 880 */ 96, 1228, 1217, 1220, 1231, 1094, 98, 1227, 1217, 1220, - /* 890 */ 760, 346, 1216, 1090, 793, 797, 102, 803, 1216, 802, - /* 900 */ 310, 348, 41, 103, 146, 1192, 367, 96, 99, 97, - /* 910 */ 149, 98, 1231, 307, 309, 1226, 1217, 1220, 1231, 346, - /* 920 */ 96, 872, 318, 1297, 1287, 346, 352, 152, 853, 348, - /* 930 */ 315, 1296, 1216, 1192, 226, 348, 5, 159, 155, 1192, - /* 940 */ 1216, 322, 327, 214, 1217, 1220, 241, 240, 1277, 213, - /* 950 */ 1217, 1220, 1231, 314, 4, 161, 861, 936, 91, 346, - /* 960 */ 1231, 871, 110, 1271, 33, 162, 228, 346, 1216, 348, - /* 970 */ 1332, 340, 854, 1192, 296, 218, 343, 348, 17, 1238, - /* 980 */ 1179, 1192, 168, 215, 1217, 1220, 350, 1314, 1231, 304, - /* 990 */ 351, 212, 1217, 1220, 355, 346, 1178, 283, 356, 236, - /* 1000 */ 177, 282, 857, 145, 357, 348, 299, 179, 53, 1192, - /* 1010 */ 51, 293, 188, 219, 144, 217, 216, 190, 281, 202, - /* 1020 */ 1217, 1220, 1107, 365, 284, 185, 425, 200, 363, 201, - /* 1030 */ 192, 193, 1186, 825, 1163, 1162, 94, 1161, 1160, 40, - /* 1040 */ 1159, 1158, 39, 1157, 1156, 827, 1155, 1154, 1153, 1152, - /* 1050 */ 1047, 1185, 1176, 126, 1085, 711, 862, 853, 1046, 1044, - /* 1060 */ 272, 273, 274, 1033, 1032, 1029, 1087, 67, 133, 808, - /* 1070 */ 1086, 807, 1042, 1037, 740, 806, 1035, 739, 1028, 220, - /* 1080 */ 738, 1027, 221, 737, 222, 1184, 1183, 36, 1175, 150, - /* 1090 */ 300, 302, 3, 736, 735, 65, 45, 32, 14, 153, - /* 1100 */ 295, 37, 15, 158, 19, 298, 1208, 34, 11, 164, - /* 1110 */ 48, 8, 35, 16, 148, 897, 353, 1174, 180, 1001, - /* 1120 */ 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, - /* 1130 */ 983, 982, 229, 987, 986, 230, 863, 1001, 1001, 1001, - /* 1140 */ 1001, 1001, 1001, 178, 1001, 961, 1001, 108, 1001, 157, - /* 1150 */ 1001, 955, 46, 1001, 954, 933, 1001, 47, 1001, 1001, - /* 1160 */ 932, 1001, 988, 1001, 1001, 1001, 1001, 1001, 1001, 366, - /* 1170 */ 879, 13, 116, 18, 243, 172, 959, 174, 176, 1001, - /* 1180 */ 171, 49, 50, 1001, 1207, 38, 370, 1001, 373, 794, - /* 1190 */ 54, 376, 771, 1001, 379, 183, 1001, 364, 799, 1001, - /* 1200 */ 1001, 1001, 368, 731, 791, 371, 1043, 1001, 788, 723, - /* 1210 */ 1001, 428, 423, 801, 374, 786, 800, 782, 1001, 1001, - /* 1220 */ 1001, 730, 377, 729, 728, 709, 780, 727, 380, 394, - /* 1230 */ 785, 726, 1031, 725, 724, 417, 722, 721, 1030, 1026, - /* 1240 */ 416, 720, 55, 56, 57, 415, 420, 732, 719, 424, - /* 1250 */ 1001, 851, 718, 717, 716, 386, 715, 784, 191, 783, - /* 1260 */ 714, 419, 427, + /* 0 */ 1225, 43, 306, 1237, 1114, 350, 1221, 1227, 238, 1110, + /* 10 */ 89, 1201, 31, 29, 27, 26, 25, 1253, 1120, 24, + /* 20 */ 170, 1346, 226, 1253, 347, 31, 29, 27, 26, 25, + /* 30 */ 347, 363, 363, 1103, 1345, 362, 66, 270, 1344, 1225, + /* 40 */ 349, 1237, 307, 280, 1213, 1221, 1226, 212, 1065, 335, + /* 50 */ 321, 362, 1125, 1125, 61, 1238, 1239, 1242, 1285, 879, + /* 60 */ 212, 1253, 211, 1281, 246, 363, 271, 1346, 347, 894, + /* 70 */ 1122, 1192, 1194, 239, 1346, 106, 1092, 924, 349, 271, + /* 80 */ 117, 104, 1213, 12, 1344, 189, 1125, 117, 1155, 1127, + /* 90 */ 924, 1344, 107, 1238, 1239, 1242, 1023, 416, 415, 414, + /* 100 */ 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, + /* 110 */ 403, 402, 401, 400, 399, 43, 925, 78, 926, 346, + /* 120 */ 77, 76, 75, 74, 73, 72, 71, 70, 69, 925, + /* 130 */ 336, 1359, 1121, 23, 233, 21, 919, 920, 921, 922, + /* 140 */ 923, 927, 928, 929, 883, 930, 23, 233, 1102, 919, + /* 150 */ 920, 921, 922, 923, 927, 928, 929, 9, 8, 1237, + /* 160 */ 362, 782, 386, 385, 384, 786, 383, 788, 789, 382, + /* 170 */ 791, 379, 309, 797, 376, 799, 800, 373, 370, 1253, + /* 180 */ 30, 28, 363, 1172, 98, 118, 334, 360, 235, 225, + /* 190 */ 861, 30, 28, 961, 1170, 105, 349, 1034, 284, 235, + /* 200 */ 1213, 861, 283, 1125, 1237, 395, 859, 916, 12, 394, + /* 210 */ 62, 1238, 1239, 1242, 1285, 11, 251, 859, 228, 1281, + /* 220 */ 112, 1253, 363, 285, 1253, 937, 11, 66, 347, 1116, + /* 230 */ 396, 334, 166, 881, 286, 52, 1, 109, 313, 1312, + /* 240 */ 219, 349, 210, 1125, 243, 1213, 165, 1, 1165, 393, + /* 250 */ 392, 391, 1118, 390, 324, 62, 1238, 1239, 1242, 1285, + /* 260 */ 428, 1225, 284, 228, 1281, 112, 283, 1221, 1226, 1172, + /* 270 */ 1213, 428, 860, 325, 1237, 240, 220, 104, 218, 217, + /* 280 */ 1170, 282, 118, 860, 1313, 1128, 118, 285, 710, 1299, + /* 290 */ 709, 862, 865, 201, 1253, 907, 31, 29, 27, 26, + /* 300 */ 25, 347, 862, 865, 201, 882, 907, 1296, 711, 1101, + /* 310 */ 1237, 349, 1045, 78, 118, 1213, 77, 76, 75, 74, + /* 320 */ 73, 72, 71, 70, 69, 62, 1238, 1239, 1242, 1285, + /* 330 */ 1253, 424, 423, 228, 1281, 1358, 363, 347, 245, 350, + /* 340 */ 1237, 361, 30, 28, 1319, 1202, 104, 349, 30, 28, + /* 350 */ 235, 1213, 861, 1213, 1127, 398, 235, 1125, 861, 709, + /* 360 */ 1253, 62, 1238, 1239, 1242, 1285, 985, 347, 859, 228, + /* 370 */ 1281, 1358, 968, 1172, 859, 278, 338, 349, 881, 247, + /* 380 */ 1342, 1213, 320, 11, 1170, 1044, 317, 983, 984, 986, + /* 390 */ 987, 62, 1238, 1239, 1242, 1285, 1237, 398, 7, 228, + /* 400 */ 1281, 1358, 339, 906, 1, 908, 909, 910, 911, 912, + /* 410 */ 1303, 880, 1299, 326, 322, 342, 1253, 30, 28, 348, + /* 420 */ 1068, 59, 428, 347, 1172, 235, 1213, 861, 428, 1043, + /* 430 */ 1295, 93, 1189, 349, 860, 1193, 960, 1213, 1117, 120, + /* 440 */ 860, 363, 335, 859, 1304, 956, 184, 202, 1238, 1239, + /* 450 */ 1242, 1014, 1015, 862, 865, 201, 248, 907, 389, 862, + /* 460 */ 865, 201, 1125, 907, 104, 259, 1112, 1346, 879, 292, + /* 470 */ 1213, 287, 1127, 7, 291, 252, 118, 290, 264, 288, + /* 480 */ 117, 1035, 289, 982, 1344, 340, 1237, 265, 31, 29, + /* 490 */ 27, 26, 25, 30, 28, 41, 1299, 428, 6, 363, + /* 500 */ 343, 235, 137, 861, 249, 135, 1253, 30, 28, 860, + /* 510 */ 122, 121, 1061, 347, 1294, 235, 1237, 861, 139, 859, + /* 520 */ 1125, 138, 884, 349, 27, 26, 25, 1213, 862, 865, + /* 530 */ 201, 1108, 907, 859, 293, 337, 1253, 63, 1238, 1239, + /* 540 */ 1242, 1285, 1056, 347, 388, 1284, 1281, 1042, 1093, 7, + /* 550 */ 1054, 318, 167, 349, 1172, 263, 1041, 1213, 258, 257, + /* 560 */ 256, 255, 254, 1, 295, 1171, 431, 63, 1238, 1239, + /* 570 */ 1242, 1285, 298, 428, 1237, 345, 1281, 868, 141, 959, + /* 580 */ 187, 140, 1040, 88, 160, 860, 277, 428, 1213, 420, + /* 590 */ 1039, 186, 331, 1166, 1253, 156, 1038, 1213, 1037, 860, + /* 600 */ 956, 347, 1100, 304, 862, 865, 201, 154, 907, 9, + /* 610 */ 8, 349, 1315, 92, 60, 1213, 302, 182, 862, 865, + /* 620 */ 201, 332, 907, 1213, 151, 63, 1238, 1239, 1242, 1285, + /* 630 */ 143, 1213, 335, 142, 1282, 1237, 1036, 1213, 1254, 1213, + /* 640 */ 90, 1017, 1018, 871, 1237, 169, 58, 867, 359, 1033, + /* 650 */ 163, 1292, 330, 1032, 329, 1253, 54, 1346, 1031, 395, + /* 660 */ 1030, 879, 347, 394, 1253, 312, 931, 1029, 147, 2, + /* 670 */ 117, 347, 349, 1237, 1344, 1028, 1213, 1213, 32, 234, + /* 680 */ 1020, 349, 1237, 119, 396, 1213, 206, 1238, 1239, 1242, + /* 690 */ 1213, 1237, 1191, 1253, 1213, 204, 1238, 1239, 1242, 1213, + /* 700 */ 347, 1213, 1253, 393, 392, 391, 253, 390, 1213, 347, + /* 710 */ 349, 1253, 1027, 870, 1213, 261, 1213, 314, 347, 349, + /* 720 */ 887, 1237, 260, 1213, 206, 1238, 1239, 1242, 349, 250, + /* 730 */ 262, 124, 1213, 205, 1238, 1239, 1242, 242, 241, 1237, + /* 740 */ 266, 1253, 107, 1238, 1239, 1242, 1026, 873, 347, 267, + /* 750 */ 886, 268, 194, 1213, 1346, 127, 331, 196, 349, 1253, + /* 760 */ 42, 1025, 1213, 866, 269, 327, 347, 117, 1237, 195, + /* 770 */ 891, 1344, 207, 1238, 1239, 1242, 349, 92, 130, 123, + /* 780 */ 1213, 1360, 32, 232, 272, 885, 20, 1213, 1253, 854, + /* 790 */ 206, 1238, 1239, 1242, 279, 347, 31, 29, 27, 26, + /* 800 */ 25, 32, 1213, 68, 90, 349, 1022, 281, 1115, 1213, + /* 810 */ 134, 1231, 236, 333, 113, 1292, 1293, 364, 1297, 206, + /* 820 */ 1238, 1239, 1242, 1229, 1237, 1111, 136, 100, 101, 869, + /* 830 */ 87, 86, 85, 84, 83, 82, 81, 80, 79, 861, + /* 840 */ 64, 175, 355, 1113, 1253, 181, 1237, 132, 874, 865, + /* 850 */ 111, 347, 1237, 173, 95, 859, 276, 96, 131, 775, + /* 860 */ 1109, 349, 102, 103, 224, 1213, 1253, 308, 146, 311, + /* 870 */ 770, 98, 1253, 347, 1237, 199, 1238, 1239, 1242, 347, + /* 880 */ 118, 44, 41, 349, 129, 310, 331, 1213, 149, 349, + /* 890 */ 884, 1316, 319, 1213, 1253, 1326, 152, 208, 1238, 1239, + /* 900 */ 1242, 347, 1237, 200, 1238, 1239, 1242, 92, 803, 428, + /* 910 */ 1237, 349, 807, 353, 316, 1213, 865, 1325, 5, 155, + /* 920 */ 368, 860, 1253, 227, 96, 209, 1238, 1239, 1242, 347, + /* 930 */ 1253, 128, 323, 1306, 90, 125, 159, 347, 1237, 349, + /* 940 */ 862, 865, 315, 1213, 114, 1292, 1293, 349, 1297, 328, + /* 950 */ 4, 1213, 161, 1250, 1238, 1239, 1242, 1237, 1253, 22, + /* 960 */ 110, 1249, 1238, 1239, 1242, 347, 1237, 956, 813, 31, + /* 970 */ 29, 27, 26, 25, 883, 349, 812, 1253, 1300, 1213, + /* 980 */ 97, 91, 33, 162, 347, 1237, 1253, 229, 98, 1248, + /* 990 */ 1238, 1239, 1242, 347, 349, 1361, 344, 341, 1213, 1343, + /* 1000 */ 168, 17, 1267, 349, 99, 1253, 356, 1213, 215, 1238, + /* 1010 */ 1239, 1242, 347, 1237, 1200, 351, 96, 214, 1238, 1239, + /* 1020 */ 1242, 352, 349, 177, 1199, 237, 1213, 357, 331, 358, + /* 1030 */ 179, 188, 51, 1253, 1126, 53, 216, 1238, 1239, 1242, + /* 1040 */ 347, 1237, 366, 297, 190, 185, 427, 197, 198, 92, + /* 1050 */ 349, 193, 1207, 192, 1213, 837, 1184, 1183, 305, 94, + /* 1060 */ 1182, 1253, 1181, 1180, 213, 1238, 1239, 1242, 347, 1179, + /* 1070 */ 1178, 1177, 145, 1176, 1175, 300, 90, 839, 349, 1174, + /* 1080 */ 294, 1173, 1213, 144, 1067, 1206, 115, 1292, 1293, 1197, + /* 1090 */ 1297, 126, 203, 1238, 1239, 1242, 1104, 722, 1066, 1064, + /* 1100 */ 292, 275, 287, 273, 274, 291, 40, 1053, 290, 39, + /* 1110 */ 288, 1052, 1049, 289, 1106, 31, 29, 27, 26, 25, + /* 1120 */ 67, 133, 818, 1105, 820, 819, 750, 1062, 749, 748, + /* 1130 */ 747, 746, 745, 1057, 296, 221, 1055, 222, 223, 299, + /* 1140 */ 1048, 301, 1047, 303, 65, 1205, 1204, 36, 1196, 148, + /* 1150 */ 45, 150, 14, 3, 15, 34, 32, 37, 158, 19, + /* 1160 */ 1229, 48, 10, 164, 8, 917, 153, 1003, 1002, 230, + /* 1170 */ 1007, 981, 894, 108, 354, 1006, 157, 231, 975, 974, + /* 1180 */ 1195, 180, 875, 1021, 116, 46, 47, 1021, 1021, 953, + /* 1190 */ 1021, 952, 1021, 1021, 178, 1008, 1063, 1051, 1050, 367, + /* 1200 */ 1021, 244, 1021, 371, 892, 781, 35, 172, 1021, 16, + /* 1210 */ 979, 13, 18, 374, 171, 174, 377, 176, 49, 380, + /* 1220 */ 50, 425, 1021, 1021, 38, 815, 809, 426, 804, 742, + /* 1230 */ 811, 54, 369, 810, 1228, 183, 801, 365, 372, 1021, + /* 1240 */ 798, 375, 734, 792, 378, 422, 790, 381, 741, 740, + /* 1250 */ 720, 739, 397, 55, 738, 737, 736, 735, 56, 733, + /* 1260 */ 796, 418, 795, 794, 387, 732, 793, 731, 57, 730, + /* 1270 */ 729, 728, 727, 726, 725, 417, 1046, 421, 863, 191, + /* 1280 */ 429, 419, 430, 1021, 1021, 1021, 1021, 1021, 1021, 1021, + /* 1290 */ 814, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 0, 207, 190, 174, 221, 222, 172, 213, 214, 187, - /* 10 */ 172, 177, 183, 12, 13, 14, 15, 16, 2, 207, - /* 20 */ 191, 14, 15, 16, 0, 213, 214, 193, 12, 13, - /* 30 */ 14, 15, 16, 20, 163, 21, 198, 20, 24, 25, - /* 40 */ 26, 27, 28, 29, 30, 31, 32, 187, 47, 49, - /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - /* 60 */ 60, 61, 62, 63, 64, 65, 66, 67, 0, 165, - /* 70 */ 46, 167, 71, 12, 13, 14, 15, 16, 186, 33, - /* 80 */ 79, 203, 36, 212, 206, 193, 166, 209, 42, 21, - /* 90 */ 44, 2, 24, 25, 26, 27, 28, 29, 30, 31, - /* 100 */ 32, 12, 13, 14, 15, 16, 186, 236, 47, 49, - /* 110 */ 218, 51, 46, 193, 54, 69, 115, 57, 72, 59, - /* 120 */ 249, 47, 62, 203, 253, 124, 125, 207, 127, 128, - /* 130 */ 129, 130, 131, 132, 133, 134, 0, 217, 218, 219, - /* 140 */ 79, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 150 */ 94, 95, 185, 97, 98, 99, 100, 101, 102, 186, - /* 160 */ 166, 22, 116, 196, 172, 192, 120, 174, 248, 179, - /* 170 */ 197, 20, 182, 12, 13, 14, 115, 38, 63, 190, - /* 180 */ 186, 20, 46, 22, 191, 124, 125, 193, 127, 128, - /* 190 */ 129, 130, 131, 132, 133, 134, 207, 203, 20, 38, - /* 200 */ 126, 207, 213, 214, 212, 172, 212, 68, 47, 137, - /* 210 */ 177, 217, 218, 219, 220, 166, 126, 184, 224, 225, - /* 220 */ 193, 70, 107, 108, 12, 13, 193, 200, 236, 68, - /* 230 */ 236, 70, 20, 94, 22, 186, 146, 147, 148, 149, - /* 240 */ 150, 249, 193, 249, 166, 253, 195, 253, 70, 20, - /* 250 */ 38, 3, 203, 202, 203, 94, 207, 203, 20, 47, - /* 260 */ 22, 122, 123, 209, 186, 172, 217, 218, 219, 220, - /* 270 */ 177, 193, 57, 224, 225, 226, 61, 184, 40, 172, - /* 280 */ 68, 203, 70, 122, 123, 207, 193, 238, 137, 1, - /* 290 */ 2, 171, 166, 244, 245, 217, 218, 219, 220, 84, - /* 300 */ 193, 181, 224, 225, 226, 236, 94, 172, 188, 175, - /* 310 */ 176, 115, 186, 12, 13, 14, 15, 16, 249, 193, - /* 320 */ 124, 166, 253, 245, 46, 215, 219, 20, 193, 203, - /* 330 */ 134, 169, 170, 207, 122, 123, 229, 230, 231, 20, - /* 340 */ 233, 186, 232, 217, 218, 219, 220, 212, 193, 137, - /* 350 */ 224, 225, 226, 22, 219, 166, 166, 20, 203, 71, - /* 360 */ 186, 235, 207, 20, 229, 230, 231, 193, 233, 38, - /* 370 */ 178, 236, 217, 218, 219, 220, 186, 172, 186, 224, - /* 380 */ 225, 226, 177, 193, 249, 166, 194, 81, 253, 166, - /* 390 */ 235, 187, 218, 203, 12, 13, 207, 207, 193, 166, - /* 400 */ 215, 153, 20, 186, 22, 186, 0, 217, 218, 219, - /* 410 */ 220, 194, 193, 186, 224, 225, 226, 232, 172, 192, - /* 420 */ 38, 186, 203, 177, 197, 235, 207, 192, 121, 47, - /* 430 */ 207, 212, 197, 12, 13, 167, 217, 218, 219, 193, - /* 440 */ 207, 20, 166, 22, 18, 166, 166, 166, 74, 23, - /* 450 */ 68, 77, 70, 0, 119, 236, 12, 13, 14, 38, - /* 460 */ 43, 35, 186, 57, 20, 166, 22, 61, 249, 193, - /* 470 */ 166, 45, 253, 186, 137, 22, 94, 142, 143, 203, - /* 480 */ 166, 166, 38, 207, 197, 186, 207, 207, 207, 68, - /* 490 */ 84, 70, 193, 217, 218, 219, 220, 186, 20, 187, - /* 500 */ 224, 225, 203, 0, 122, 123, 207, 14, 197, 103, - /* 510 */ 104, 207, 68, 20, 70, 94, 217, 218, 219, 220, - /* 520 */ 178, 207, 207, 224, 225, 12, 13, 21, 186, 12, - /* 530 */ 13, 105, 187, 20, 83, 22, 194, 20, 94, 22, - /* 540 */ 34, 166, 215, 122, 123, 0, 12, 13, 14, 15, - /* 550 */ 16, 38, 49, 136, 51, 38, 166, 54, 137, 232, - /* 560 */ 57, 186, 59, 137, 166, 62, 122, 123, 193, 24, - /* 570 */ 25, 26, 27, 28, 29, 30, 31, 32, 203, 20, - /* 580 */ 0, 68, 207, 70, 186, 68, 27, 70, 176, 30, - /* 590 */ 166, 193, 217, 218, 219, 4, 19, 207, 39, 121, - /* 600 */ 166, 203, 22, 256, 172, 207, 178, 94, 157, 177, - /* 610 */ 33, 94, 71, 36, 186, 217, 218, 219, 220, 42, - /* 620 */ 186, 44, 194, 225, 83, 193, 166, 193, 247, 254, - /* 630 */ 255, 207, 0, 166, 166, 122, 123, 203, 172, 122, - /* 640 */ 123, 207, 196, 177, 210, 172, 69, 166, 166, 72, - /* 650 */ 177, 217, 218, 219, 22, 166, 241, 166, 166, 193, - /* 660 */ 135, 136, 186, 166, 169, 106, 193, 207, 109, 110, - /* 670 */ 111, 112, 113, 83, 207, 207, 166, 38, 186, 74, - /* 680 */ 103, 166, 77, 186, 74, 193, 166, 77, 207, 207, - /* 690 */ 193, 38, 158, 159, 117, 203, 207, 120, 207, 207, - /* 700 */ 203, 186, 210, 172, 207, 234, 186, 68, 193, 217, - /* 710 */ 218, 219, 166, 193, 217, 218, 219, 207, 203, 1, - /* 720 */ 2, 68, 207, 203, 193, 210, 20, 207, 166, 138, - /* 730 */ 210, 166, 217, 218, 219, 216, 166, 217, 218, 219, - /* 740 */ 12, 13, 14, 15, 16, 155, 172, 172, 186, 171, - /* 750 */ 219, 186, 255, 207, 250, 193, 186, 0, 193, 228, - /* 760 */ 229, 230, 231, 193, 233, 203, 188, 193, 203, 207, - /* 770 */ 237, 114, 207, 203, 166, 74, 115, 207, 77, 217, - /* 780 */ 218, 219, 217, 218, 219, 71, 71, 217, 218, 219, - /* 790 */ 201, 199, 199, 219, 186, 172, 166, 83, 83, 71, - /* 800 */ 71, 193, 166, 229, 230, 231, 20, 233, 161, 162, - /* 810 */ 211, 203, 83, 193, 57, 207, 186, 174, 61, 20, - /* 820 */ 71, 70, 186, 193, 174, 217, 218, 219, 70, 193, - /* 830 */ 166, 80, 83, 203, 71, 204, 166, 207, 172, 203, - /* 840 */ 82, 84, 174, 207, 168, 174, 83, 217, 218, 219, - /* 850 */ 186, 20, 172, 217, 218, 219, 186, 193, 71, 186, - /* 860 */ 103, 104, 168, 193, 166, 186, 71, 203, 71, 186, - /* 870 */ 83, 207, 186, 203, 71, 186, 186, 207, 83, 186, - /* 880 */ 83, 217, 218, 219, 186, 186, 83, 217, 218, 219, - /* 890 */ 71, 193, 166, 186, 71, 71, 186, 71, 166, 71, - /* 900 */ 204, 203, 83, 186, 171, 207, 83, 83, 71, 83, - /* 910 */ 171, 83, 186, 211, 193, 217, 218, 219, 186, 193, - /* 920 */ 83, 20, 145, 246, 216, 193, 144, 208, 123, 203, - /* 930 */ 207, 246, 166, 207, 207, 203, 152, 242, 208, 207, - /* 940 */ 166, 207, 151, 217, 218, 219, 12, 13, 243, 217, - /* 950 */ 218, 219, 186, 140, 139, 239, 22, 136, 193, 193, - /* 960 */ 186, 20, 240, 215, 114, 227, 160, 193, 166, 203, - /* 970 */ 257, 154, 38, 207, 4, 35, 156, 203, 70, 223, - /* 980 */ 208, 207, 251, 217, 218, 219, 207, 252, 186, 19, - /* 990 */ 207, 217, 218, 219, 118, 193, 208, 57, 205, 207, - /* 1000 */ 193, 61, 68, 33, 204, 203, 36, 171, 70, 207, - /* 1010 */ 171, 41, 182, 73, 44, 75, 76, 172, 78, 217, - /* 1020 */ 218, 219, 193, 189, 84, 171, 168, 180, 94, 180, - /* 1030 */ 173, 164, 0, 82, 0, 0, 114, 0, 0, 69, - /* 1040 */ 0, 0, 72, 0, 0, 22, 0, 0, 0, 0, - /* 1050 */ 0, 0, 0, 43, 0, 48, 122, 123, 0, 0, - /* 1060 */ 38, 36, 43, 0, 0, 0, 0, 79, 77, 38, - /* 1070 */ 0, 38, 0, 0, 38, 22, 0, 38, 0, 22, - /* 1080 */ 38, 0, 22, 38, 22, 0, 0, 121, 0, 116, - /* 1090 */ 22, 22, 83, 38, 38, 20, 70, 83, 141, 71, - /* 1100 */ 39, 83, 141, 83, 83, 38, 82, 135, 141, 82, - /* 1110 */ 4, 2, 83, 83, 43, 126, 119, 0, 116, 258, - /* 1120 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1130 */ 38, 38, 38, 38, 38, 38, 22, 258, 258, 258, - /* 1140 */ 258, 258, 258, 43, 258, 71, 258, 70, 258, 70, - /* 1150 */ 258, 71, 70, 258, 71, 71, 258, 70, 258, 258, - /* 1160 */ 71, 258, 71, 258, 258, 258, 258, 258, 258, 38, - /* 1170 */ 71, 70, 82, 70, 38, 71, 71, 70, 70, 258, - /* 1180 */ 82, 70, 70, 258, 82, 70, 38, 258, 38, 71, - /* 1190 */ 80, 38, 22, 258, 38, 82, 258, 81, 22, 258, - /* 1200 */ 258, 258, 70, 22, 71, 70, 0, 258, 71, 22, - /* 1210 */ 258, 20, 22, 38, 70, 96, 38, 71, 258, 258, - /* 1220 */ 258, 38, 70, 38, 38, 48, 71, 38, 70, 47, - /* 1230 */ 96, 38, 0, 38, 38, 43, 38, 38, 0, 0, - /* 1240 */ 36, 38, 70, 70, 70, 38, 37, 68, 38, 21, - /* 1250 */ 258, 22, 38, 38, 38, 84, 38, 96, 22, 96, - /* 1260 */ 38, 38, 21, 258, 258, 258, 258, 258, 258, 258, - /* 1270 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1280 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1290 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1300 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1310 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1320 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1330 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1340 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1350 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1360 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1370 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1380 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1390 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1400 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1410 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - /* 1420 */ 258, 258, 258, 258, 258, 258, + /* 0 */ 216, 183, 181, 175, 196, 212, 222, 223, 215, 196, + /* 10 */ 192, 218, 12, 13, 14, 15, 16, 195, 200, 231, + /* 20 */ 232, 246, 199, 195, 202, 12, 13, 14, 15, 16, + /* 30 */ 202, 181, 181, 0, 259, 20, 186, 186, 263, 216, + /* 40 */ 212, 175, 221, 193, 216, 222, 223, 47, 0, 221, + /* 50 */ 228, 20, 202, 202, 226, 227, 228, 229, 230, 20, + /* 60 */ 47, 195, 234, 235, 204, 181, 46, 246, 202, 69, + /* 70 */ 186, 211, 212, 187, 246, 184, 185, 77, 212, 46, + /* 80 */ 259, 195, 216, 68, 263, 188, 202, 259, 191, 203, + /* 90 */ 77, 263, 226, 227, 228, 229, 0, 49, 50, 51, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + /* 110 */ 62, 63, 64, 65, 66, 183, 116, 21, 116, 47, + /* 120 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 116, + /* 130 */ 264, 265, 200, 133, 134, 133, 136, 137, 138, 139, + /* 140 */ 140, 141, 142, 143, 20, 143, 133, 134, 0, 136, + /* 150 */ 137, 138, 139, 140, 141, 142, 143, 1, 2, 175, + /* 160 */ 20, 83, 84, 85, 86, 87, 88, 89, 90, 91, + /* 170 */ 92, 93, 69, 95, 96, 97, 98, 99, 100, 195, + /* 180 */ 12, 13, 181, 195, 81, 146, 202, 186, 20, 201, + /* 190 */ 22, 12, 13, 14, 206, 174, 212, 176, 57, 20, + /* 200 */ 216, 22, 61, 202, 175, 57, 38, 135, 68, 61, + /* 210 */ 226, 227, 228, 229, 230, 47, 181, 38, 234, 235, + /* 220 */ 236, 195, 181, 82, 195, 69, 47, 186, 202, 175, + /* 230 */ 82, 202, 248, 20, 193, 180, 68, 194, 254, 255, + /* 240 */ 35, 212, 207, 202, 199, 216, 122, 68, 205, 101, + /* 250 */ 102, 103, 197, 105, 228, 226, 227, 228, 229, 230, + /* 260 */ 92, 216, 57, 234, 235, 236, 61, 222, 223, 195, + /* 270 */ 216, 92, 104, 20, 175, 201, 71, 195, 73, 74, + /* 280 */ 206, 76, 146, 104, 255, 203, 146, 82, 20, 224, + /* 290 */ 22, 123, 124, 125, 195, 127, 12, 13, 14, 15, + /* 300 */ 16, 202, 123, 124, 125, 20, 127, 242, 40, 0, + /* 310 */ 175, 212, 175, 21, 146, 216, 24, 25, 26, 27, + /* 320 */ 28, 29, 30, 31, 32, 226, 227, 228, 229, 230, + /* 330 */ 195, 178, 179, 234, 235, 236, 181, 202, 187, 212, + /* 340 */ 175, 186, 12, 13, 245, 218, 195, 212, 12, 13, + /* 350 */ 20, 216, 22, 216, 203, 46, 20, 202, 22, 22, + /* 360 */ 195, 226, 227, 228, 229, 230, 135, 202, 38, 234, + /* 370 */ 235, 236, 14, 195, 38, 38, 3, 212, 20, 201, + /* 380 */ 245, 216, 120, 47, 206, 175, 155, 156, 157, 158, + /* 390 */ 159, 226, 227, 228, 229, 230, 175, 46, 68, 234, + /* 400 */ 235, 236, 81, 126, 68, 128, 129, 130, 131, 132, + /* 410 */ 245, 20, 224, 151, 152, 81, 195, 12, 13, 14, + /* 420 */ 0, 180, 92, 202, 195, 20, 216, 22, 92, 175, + /* 430 */ 242, 190, 202, 212, 104, 206, 4, 216, 197, 209, + /* 440 */ 104, 181, 221, 38, 144, 145, 186, 226, 227, 228, + /* 450 */ 229, 167, 168, 123, 124, 125, 187, 127, 79, 123, + /* 460 */ 124, 125, 202, 127, 195, 63, 196, 246, 20, 49, + /* 470 */ 216, 51, 203, 68, 54, 27, 146, 57, 30, 59, + /* 480 */ 259, 176, 62, 69, 263, 164, 175, 39, 12, 13, + /* 490 */ 14, 15, 16, 12, 13, 81, 224, 92, 43, 181, + /* 500 */ 166, 20, 72, 22, 186, 75, 195, 12, 13, 104, + /* 510 */ 108, 109, 0, 202, 242, 20, 175, 22, 72, 38, + /* 520 */ 202, 75, 20, 212, 14, 15, 16, 216, 123, 124, + /* 530 */ 125, 196, 127, 38, 22, 162, 195, 226, 227, 228, + /* 540 */ 229, 230, 0, 202, 196, 234, 235, 175, 185, 68, + /* 550 */ 0, 257, 266, 212, 195, 107, 175, 216, 110, 111, + /* 560 */ 112, 113, 114, 68, 22, 206, 19, 226, 227, 228, + /* 570 */ 229, 230, 22, 92, 175, 234, 235, 38, 72, 147, + /* 580 */ 33, 75, 175, 36, 251, 104, 178, 92, 216, 42, + /* 590 */ 175, 44, 181, 205, 195, 69, 175, 216, 175, 104, + /* 600 */ 145, 202, 0, 21, 123, 124, 125, 81, 127, 1, + /* 610 */ 2, 212, 225, 202, 67, 216, 34, 70, 123, 124, + /* 620 */ 125, 244, 127, 216, 122, 226, 227, 228, 229, 230, + /* 630 */ 72, 216, 221, 75, 235, 175, 175, 216, 195, 216, + /* 640 */ 229, 170, 171, 104, 175, 260, 68, 38, 101, 175, + /* 650 */ 239, 240, 241, 175, 243, 195, 78, 246, 175, 57, + /* 660 */ 175, 20, 202, 61, 195, 118, 69, 175, 121, 247, + /* 670 */ 259, 202, 212, 175, 263, 175, 216, 216, 81, 219, + /* 680 */ 172, 212, 175, 115, 82, 216, 226, 227, 228, 229, + /* 690 */ 216, 175, 181, 195, 216, 226, 227, 228, 229, 216, + /* 700 */ 202, 216, 195, 101, 102, 103, 210, 105, 216, 202, + /* 710 */ 212, 195, 175, 104, 216, 116, 216, 219, 202, 212, + /* 720 */ 20, 175, 208, 216, 226, 227, 228, 229, 212, 221, + /* 730 */ 208, 183, 216, 226, 227, 228, 229, 12, 13, 175, + /* 740 */ 181, 195, 226, 227, 228, 229, 175, 22, 202, 220, + /* 750 */ 20, 202, 18, 216, 246, 183, 181, 23, 212, 195, + /* 760 */ 183, 175, 216, 38, 213, 258, 202, 259, 175, 35, + /* 770 */ 69, 263, 226, 227, 228, 229, 212, 202, 183, 45, + /* 780 */ 216, 265, 81, 219, 181, 20, 2, 216, 195, 69, + /* 790 */ 226, 227, 228, 229, 177, 202, 12, 13, 14, 15, + /* 800 */ 16, 81, 216, 181, 229, 212, 0, 195, 195, 216, + /* 810 */ 195, 68, 219, 238, 239, 240, 241, 92, 243, 226, + /* 820 */ 227, 228, 229, 80, 175, 195, 195, 195, 195, 104, + /* 830 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, + /* 840 */ 106, 69, 69, 195, 195, 69, 175, 33, 123, 124, + /* 850 */ 36, 202, 175, 81, 81, 38, 42, 81, 44, 69, + /* 860 */ 195, 212, 195, 195, 177, 216, 195, 220, 180, 213, + /* 870 */ 69, 81, 195, 202, 175, 226, 227, 228, 229, 202, + /* 880 */ 146, 67, 81, 212, 70, 202, 181, 216, 180, 212, + /* 890 */ 20, 225, 154, 216, 195, 256, 217, 226, 227, 228, + /* 900 */ 229, 202, 175, 226, 227, 228, 229, 202, 69, 92, + /* 910 */ 175, 212, 69, 153, 216, 216, 124, 256, 161, 217, + /* 920 */ 81, 104, 195, 216, 81, 226, 227, 228, 229, 202, + /* 930 */ 195, 117, 216, 253, 229, 121, 252, 202, 175, 212, + /* 940 */ 123, 124, 149, 216, 239, 240, 241, 212, 243, 160, + /* 950 */ 148, 216, 249, 226, 227, 228, 229, 175, 195, 2, + /* 960 */ 250, 226, 227, 228, 229, 202, 175, 145, 69, 12, + /* 970 */ 13, 14, 15, 16, 20, 212, 69, 195, 224, 216, + /* 980 */ 81, 202, 115, 237, 202, 175, 195, 169, 81, 226, + /* 990 */ 227, 228, 229, 202, 212, 267, 165, 163, 216, 262, + /* 1000 */ 261, 68, 233, 212, 69, 195, 119, 216, 226, 227, + /* 1010 */ 228, 229, 202, 175, 217, 216, 81, 226, 227, 228, + /* 1020 */ 229, 216, 212, 202, 217, 216, 216, 214, 181, 213, + /* 1030 */ 180, 191, 180, 195, 202, 68, 226, 227, 228, 229, + /* 1040 */ 202, 175, 198, 4, 181, 180, 177, 189, 189, 202, + /* 1050 */ 212, 173, 0, 182, 216, 80, 0, 0, 19, 115, + /* 1060 */ 0, 195, 0, 0, 226, 227, 228, 229, 202, 0, + /* 1070 */ 0, 0, 33, 0, 0, 36, 229, 22, 212, 0, + /* 1080 */ 41, 0, 216, 44, 0, 0, 239, 240, 241, 0, + /* 1090 */ 243, 43, 226, 227, 228, 229, 0, 48, 0, 0, + /* 1100 */ 49, 43, 51, 38, 36, 54, 67, 0, 57, 70, + /* 1110 */ 59, 0, 0, 62, 0, 12, 13, 14, 15, 16, + /* 1120 */ 77, 75, 22, 0, 38, 38, 38, 0, 38, 38, + /* 1130 */ 38, 38, 38, 0, 39, 22, 0, 22, 22, 38, + /* 1140 */ 0, 22, 0, 22, 20, 0, 0, 122, 0, 43, + /* 1150 */ 68, 117, 150, 81, 150, 144, 81, 81, 81, 81, + /* 1160 */ 80, 4, 150, 80, 2, 135, 69, 38, 38, 38, + /* 1170 */ 38, 69, 69, 68, 120, 38, 68, 38, 69, 69, + /* 1180 */ 0, 117, 22, 268, 80, 68, 68, 268, 268, 69, + /* 1190 */ 268, 69, 268, 268, 43, 69, 0, 0, 0, 38, + /* 1200 */ 268, 38, 268, 38, 69, 22, 81, 69, 268, 81, + /* 1210 */ 69, 68, 68, 38, 80, 68, 38, 68, 68, 38, + /* 1220 */ 68, 22, 268, 268, 68, 38, 22, 21, 69, 22, + /* 1230 */ 38, 78, 68, 38, 80, 80, 69, 79, 68, 268, + /* 1240 */ 69, 68, 22, 69, 68, 37, 69, 68, 38, 38, + /* 1250 */ 48, 38, 47, 68, 38, 38, 38, 38, 68, 38, + /* 1260 */ 94, 36, 94, 94, 82, 38, 94, 38, 68, 38, + /* 1270 */ 38, 38, 38, 38, 38, 38, 0, 38, 22, 22, + /* 1280 */ 21, 43, 20, 268, 268, 268, 268, 268, 268, 268, + /* 1290 */ 104, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1300 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1310 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1320 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1330 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1340 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1350 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1360 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1370 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1380 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1390 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1400 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1410 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1420 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1430 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1440 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1450 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 1460 */ 268, 268, 268, }; -#define YY_SHIFT_COUNT (429) +#define YY_SHIFT_COUNT (431) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1241) +#define YY_SHIFT_MAX (1276) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 426, 212, 161, 382, 382, 382, 382, 421, 382, 382, - /* 10 */ 151, 513, 517, 444, 513, 513, 513, 513, 513, 513, - /* 20 */ 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, - /* 30 */ 513, 513, 513, 178, 178, 178, 337, 934, 934, 13, - /* 40 */ 13, 934, 13, 13, 66, 17, 229, 229, 72, 319, - /* 50 */ 17, 13, 13, 17, 13, 17, 319, 17, 17, 13, - /* 60 */ 278, 1, 61, 61, 559, 14, 940, 139, 60, 139, - /* 70 */ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - /* 80 */ 139, 139, 139, 139, 139, 139, 139, 139, 238, 24, - /* 90 */ 307, 307, 307, 136, 343, 319, 17, 17, 17, 306, - /* 100 */ 56, 56, 56, 56, 56, 68, 503, 534, 90, 215, - /* 110 */ 335, 331, 478, 525, 417, 525, 493, 248, 591, 706, - /* 120 */ 657, 661, 661, 706, 786, 66, 343, 799, 66, 66, - /* 130 */ 706, 66, 831, 17, 17, 17, 17, 17, 17, 17, - /* 140 */ 17, 17, 17, 17, 706, 831, 786, 278, 343, 799, - /* 150 */ 278, 901, 777, 782, 805, 777, 782, 805, 805, 784, - /* 160 */ 791, 813, 815, 821, 343, 941, 850, 806, 820, 817, - /* 170 */ 908, 17, 782, 805, 805, 782, 805, 876, 343, 799, - /* 180 */ 278, 306, 278, 343, 938, 706, 278, 831, 1263, 1263, - /* 190 */ 1263, 1263, 0, 545, 577, 46, 970, 16, 89, 728, - /* 200 */ 406, 757, 301, 301, 301, 301, 301, 301, 301, 115, - /* 210 */ 288, 196, 7, 7, 7, 7, 374, 605, 610, 701, - /* 220 */ 453, 580, 632, 506, 541, 714, 715, 718, 647, 590, - /* 230 */ 451, 729, 74, 749, 758, 763, 787, 795, 797, 803, - /* 240 */ 639, 653, 819, 823, 824, 826, 828, 837, 751, 1032, - /* 250 */ 951, 1034, 1035, 922, 1037, 1038, 1040, 1041, 1043, 1044, - /* 260 */ 1023, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1010, 1054, - /* 270 */ 1007, 1058, 1059, 1022, 1025, 1019, 1063, 1064, 1065, 1066, - /* 280 */ 988, 991, 1031, 1033, 1053, 1070, 1036, 1039, 1042, 1045, - /* 290 */ 1055, 1056, 1072, 1057, 1073, 1060, 1061, 1076, 1062, 1067, - /* 300 */ 1078, 1068, 1081, 1069, 1075, 1085, 1086, 966, 1088, 1026, - /* 310 */ 1071, 973, 1009, 1014, 957, 1028, 1018, 1074, 1077, 1079, - /* 320 */ 1080, 1082, 1083, 1020, 1024, 1087, 1021, 961, 1084, 1089, - /* 330 */ 1027, 972, 1029, 1090, 1091, 1030, 967, 1106, 1092, 1093, - /* 340 */ 1094, 1095, 1096, 1097, 1109, 989, 1098, 1099, 1101, 1103, - /* 350 */ 1104, 1105, 1107, 1108, 997, 1111, 1117, 1100, 1002, 1112, - /* 360 */ 1110, 1102, 1113, 1114, 1115, 1116, 1118, 1131, 1136, 1132, - /* 370 */ 1133, 1148, 1135, 1137, 1150, 1144, 1146, 1153, 1152, 1155, - /* 380 */ 1156, 1158, 1119, 1134, 1161, 1163, 1170, 1171, 1172, 1173, - /* 390 */ 1174, 1175, 1178, 1176, 1177, 1182, 1179, 1181, 1183, 1185, - /* 400 */ 1186, 1189, 1193, 1195, 1196, 1187, 1198, 1199, 1203, 1210, - /* 410 */ 1214, 1215, 1216, 1218, 1222, 1206, 1207, 1204, 1192, 1232, - /* 420 */ 1223, 1209, 1238, 1239, 1190, 1228, 1229, 1236, 1241, 1191, + /* 0 */ 734, 168, 179, 336, 336, 336, 336, 330, 336, 336, + /* 10 */ 481, 495, 140, 405, 481, 481, 481, 481, 481, 481, + /* 20 */ 481, 481, 481, 481, 481, 481, 481, 481, 481, 481, + /* 30 */ 481, 481, 481, 15, 15, 15, 39, 725, 725, 31, + /* 40 */ 31, 725, 31, 31, 20, 213, 253, 253, 136, 285, + /* 50 */ 213, 31, 31, 213, 31, 213, 285, 213, 213, 31, + /* 60 */ 351, 0, 13, 13, 448, 292, 205, 817, 1051, 817, + /* 70 */ 817, 817, 817, 817, 817, 817, 817, 817, 817, 817, + /* 80 */ 817, 817, 817, 817, 817, 817, 817, 817, 268, 33, + /* 90 */ 124, 124, 124, 309, 391, 285, 213, 213, 213, 379, + /* 100 */ 78, 78, 78, 78, 78, 96, 420, 284, 231, 141, + /* 110 */ 262, 337, 502, 300, 455, 300, 358, 373, 432, 641, + /* 120 */ 568, 599, 599, 641, 700, 20, 391, 730, 20, 20, + /* 130 */ 641, 20, 765, 213, 213, 213, 213, 213, 213, 213, + /* 140 */ 213, 213, 213, 213, 641, 765, 700, 351, 391, 730, + /* 150 */ 351, 870, 738, 760, 792, 738, 760, 792, 792, 757, + /* 160 */ 789, 793, 802, 822, 391, 954, 867, 818, 831, 834, + /* 170 */ 933, 213, 760, 792, 792, 760, 792, 887, 391, 730, + /* 180 */ 351, 379, 351, 391, 967, 641, 351, 765, 1291, 1291, + /* 190 */ 1291, 1291, 48, 806, 547, 814, 1039, 148, 602, 784, + /* 200 */ 957, 277, 1103, 476, 476, 476, 476, 476, 476, 476, + /* 210 */ 402, 156, 2, 510, 510, 510, 510, 430, 446, 506, + /* 220 */ 558, 512, 542, 550, 582, 103, 414, 526, 608, 471, + /* 230 */ 321, 334, 597, 72, 701, 743, 720, 772, 773, 776, + /* 240 */ 790, 539, 609, 801, 839, 843, 899, 907, 935, 578, + /* 250 */ 1052, 975, 1056, 1057, 944, 1060, 1062, 1063, 1069, 1070, + /* 260 */ 1071, 1055, 1073, 1074, 1079, 1081, 1084, 1085, 1089, 1048, + /* 270 */ 1096, 1049, 1098, 1099, 1065, 1068, 1058, 1107, 1111, 1112, + /* 280 */ 1114, 1043, 1046, 1086, 1087, 1100, 1123, 1088, 1090, 1091, + /* 290 */ 1092, 1093, 1094, 1127, 1113, 1133, 1115, 1095, 1136, 1116, + /* 300 */ 1101, 1140, 1119, 1142, 1121, 1124, 1145, 1146, 1025, 1148, + /* 310 */ 1082, 1106, 1034, 1072, 1075, 1002, 1097, 1076, 1102, 1105, + /* 320 */ 1108, 1109, 1117, 1110, 1077, 1080, 1118, 1078, 1004, 1120, + /* 330 */ 1122, 1083, 1011, 1125, 1104, 1126, 1128, 1012, 1157, 1129, + /* 340 */ 1130, 1131, 1132, 1137, 1139, 1162, 1030, 1134, 1135, 1143, + /* 350 */ 1144, 1138, 1141, 1147, 1149, 1054, 1150, 1180, 1151, 1064, + /* 360 */ 1152, 1153, 1154, 1155, 1160, 1156, 1158, 1159, 1161, 1163, + /* 370 */ 1164, 1167, 1165, 1170, 1171, 1175, 1173, 1174, 1178, 1176, + /* 380 */ 1177, 1181, 1179, 1166, 1168, 1169, 1172, 1183, 1182, 1185, + /* 390 */ 1187, 1186, 1190, 1200, 1192, 1195, 1204, 1202, 1205, 1207, + /* 400 */ 1210, 1211, 1213, 1216, 1217, 1218, 1219, 1220, 1221, 1227, + /* 410 */ 1229, 1231, 1232, 1233, 1234, 1235, 1236, 1196, 1237, 1225, + /* 420 */ 1238, 1197, 1239, 1208, 1198, 1276, 1199, 1206, 1256, 1257, + /* 430 */ 1259, 1262, }; #define YY_REDUCE_COUNT (191) -#define YY_REDUCE_MIN (-217) -#define YY_REDUCE_MAX (867) +#define YY_REDUCE_MIN (-225) +#define YY_REDUCE_MAX (878) static const short yy_reduce_ofst[] = { - /* 0 */ -129, -6, 49, 78, 126, 155, 190, 219, 276, 299, - /* 10 */ 135, 375, 398, 434, 492, -80, 497, 515, 520, 562, - /* 20 */ 565, 570, 608, 630, 636, 664, 670, 698, 726, 732, - /* 30 */ 766, 774, 802, 531, 107, 574, -8, -188, -11, 33, - /* 40 */ 93, -206, -166, 205, -171, -27, -108, 174, 69, -122, - /* 50 */ 192, 246, 432, 227, 466, 342, 51, 235, 428, 473, - /* 60 */ 120, -217, -217, -217, -162, -96, -33, 189, 134, 223, - /* 70 */ 233, 279, 280, 281, 304, 314, 315, 390, 424, 460, - /* 80 */ 467, 468, 481, 482, 489, 491, 510, 546, 162, -7, - /* 90 */ 110, 185, 327, 578, 27, 54, 217, 287, 311, -10, - /* 100 */ -178, -140, 204, 312, 345, 268, 412, 347, 381, 446, - /* 110 */ 415, 495, 519, 471, 471, 471, 476, 504, 533, 575, - /* 120 */ 589, 592, 593, 623, 599, 643, 620, 631, 650, 668, - /* 130 */ 666, 671, 676, 673, 679, 683, 686, 689, 690, 693, - /* 140 */ 699, 707, 710, 717, 680, 694, 702, 733, 721, 696, - /* 150 */ 739, 708, 677, 719, 723, 685, 730, 727, 734, 705, - /* 160 */ 695, 722, 716, 471, 765, 748, 738, 713, 735, 731, - /* 170 */ 756, 476, 772, 779, 783, 788, 792, 793, 807, 800, - /* 180 */ 836, 830, 839, 829, 834, 845, 854, 858, 847, 849, - /* 190 */ 857, 867, + /* 0 */ 508, -172, -16, 29, 99, 135, 165, 221, 311, 341, + /* 10 */ -134, 399, 411, 460, 498, 507, 516, 564, 593, 469, + /* 20 */ 546, 649, 671, 677, 699, 727, 735, 763, 782, 791, + /* 30 */ 810, 838, 866, 575, 705, 847, -179, -177, 45, -150, + /* 40 */ 41, -216, -149, -116, -182, -12, -178, 26, -225, -207, + /* 50 */ -114, 1, 155, 74, 260, 151, -140, 178, 269, 318, + /* 60 */ 241, -212, -212, -212, 35, 21, 43, 54, -109, 137, + /* 70 */ 210, 254, 372, 381, 407, 415, 421, 423, 461, 474, + /* 80 */ 478, 483, 485, 492, 500, 537, 571, 586, 153, -68, + /* 90 */ 65, 188, 272, 55, 230, 127, 82, 229, 359, -103, + /* 100 */ -192, -187, 270, 335, 348, 305, 363, 286, 294, 388, + /* 110 */ 333, 408, 387, 377, 377, 377, 443, 385, 422, 511, + /* 120 */ 496, 514, 522, 559, 529, 548, 549, 551, 572, 577, + /* 130 */ 603, 595, 617, 612, 613, 615, 630, 631, 632, 633, + /* 140 */ 648, 665, 667, 668, 622, 687, 647, 688, 683, 656, + /* 150 */ 708, 666, 639, 679, 698, 661, 702, 707, 716, 680, + /* 160 */ 684, 710, 703, 377, 779, 754, 746, 728, 737, 739, + /* 170 */ 769, 443, 797, 799, 805, 807, 809, 813, 821, 816, + /* 180 */ 850, 840, 852, 832, 844, 863, 865, 869, 858, 859, + /* 190 */ 871, 878, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 10 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 20 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 30 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 40 */ 999, 999, 999, 999, 1052, 999, 999, 999, 999, 999, - /* 50 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 60 */ 1050, 999, 1258, 999, 1164, 999, 999, 999, 999, 999, - /* 70 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 80 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 1052, - /* 90 */ 1269, 1269, 1269, 1050, 999, 999, 999, 999, 999, 1135, - /* 100 */ 999, 999, 999, 999, 999, 999, 999, 1333, 999, 1088, - /* 110 */ 1293, 999, 1285, 1261, 1275, 1262, 999, 1318, 1278, 999, - /* 120 */ 1169, 1166, 1166, 999, 999, 1052, 999, 999, 1052, 1052, - /* 130 */ 999, 1052, 999, 999, 999, 999, 999, 999, 999, 999, - /* 140 */ 999, 999, 999, 999, 999, 999, 999, 1050, 999, 999, - /* 150 */ 1050, 999, 1300, 1298, 999, 1300, 1298, 999, 999, 1312, - /* 160 */ 1308, 1291, 1289, 1275, 999, 999, 999, 1336, 1324, 1320, - /* 170 */ 999, 999, 1298, 999, 999, 1298, 999, 1177, 999, 999, - /* 180 */ 1050, 999, 1050, 999, 1104, 999, 1050, 999, 1138, 1138, - /* 190 */ 1053, 1004, 999, 999, 999, 999, 999, 999, 999, 999, - /* 200 */ 999, 999, 1230, 1311, 1310, 1229, 1235, 1234, 1233, 999, - /* 210 */ 999, 999, 1224, 1225, 1223, 1222, 999, 999, 999, 999, - /* 220 */ 999, 999, 999, 999, 999, 999, 999, 1259, 999, 1321, - /* 230 */ 1325, 999, 999, 999, 1209, 999, 999, 999, 999, 999, - /* 240 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 250 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 260 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 270 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 280 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 290 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 300 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 310 */ 999, 999, 1282, 1292, 999, 999, 999, 999, 999, 999, - /* 320 */ 999, 999, 999, 999, 1209, 999, 1309, 999, 1268, 1264, - /* 330 */ 999, 999, 1260, 999, 999, 1319, 999, 999, 999, 999, - /* 340 */ 999, 999, 999, 999, 1254, 999, 999, 999, 999, 999, - /* 350 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 360 */ 999, 1208, 999, 999, 999, 999, 999, 999, 999, 1132, - /* 370 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 380 */ 999, 999, 1117, 1115, 1114, 1113, 999, 1110, 999, 999, - /* 390 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 400 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 410 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, - /* 420 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + /* 0 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 10 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 20 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 30 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 40 */ 1019, 1019, 1019, 1019, 1072, 1019, 1019, 1019, 1019, 1019, + /* 50 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 60 */ 1070, 1019, 1287, 1019, 1185, 1019, 1019, 1019, 1019, 1019, + /* 70 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 80 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1072, + /* 90 */ 1298, 1298, 1298, 1070, 1019, 1019, 1019, 1019, 1019, 1154, + /* 100 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1362, 1019, 1107, + /* 110 */ 1322, 1019, 1314, 1290, 1304, 1291, 1019, 1347, 1307, 1019, + /* 120 */ 1190, 1187, 1187, 1019, 1019, 1072, 1019, 1019, 1072, 1072, + /* 130 */ 1019, 1072, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 140 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1070, 1019, 1019, + /* 150 */ 1070, 1019, 1329, 1327, 1019, 1329, 1327, 1019, 1019, 1341, + /* 160 */ 1337, 1320, 1318, 1304, 1019, 1019, 1019, 1365, 1353, 1349, + /* 170 */ 1019, 1019, 1327, 1019, 1019, 1327, 1019, 1198, 1019, 1019, + /* 180 */ 1070, 1019, 1070, 1019, 1123, 1019, 1070, 1019, 1157, 1157, + /* 190 */ 1073, 1024, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 200 */ 1019, 1019, 1019, 1252, 1340, 1339, 1251, 1264, 1263, 1262, + /* 210 */ 1019, 1019, 1019, 1246, 1247, 1245, 1244, 1019, 1019, 1019, + /* 220 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1288, 1019, + /* 230 */ 1350, 1354, 1019, 1019, 1019, 1230, 1019, 1019, 1019, 1019, + /* 240 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 250 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 260 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 270 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 280 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 290 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 300 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 310 */ 1019, 1019, 1019, 1311, 1321, 1019, 1019, 1019, 1019, 1019, + /* 320 */ 1019, 1019, 1019, 1019, 1019, 1230, 1019, 1338, 1019, 1297, + /* 330 */ 1293, 1019, 1019, 1289, 1019, 1019, 1348, 1019, 1019, 1019, + /* 340 */ 1019, 1019, 1019, 1019, 1019, 1283, 1019, 1019, 1019, 1019, + /* 350 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 360 */ 1019, 1019, 1229, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 370 */ 1151, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 380 */ 1019, 1019, 1019, 1136, 1134, 1133, 1132, 1019, 1129, 1019, + /* 390 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 400 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 410 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 420 */ 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, + /* 430 */ 1019, 1019, }; /********** End of lemon-generated parsing tables *****************************/ @@ -773,197 +783,207 @@ static const char *const yyTokenName[] = { /* 64 */ "SINGLE_STABLE", /* 65 */ "STREAM_MODE", /* 66 */ "RETENTIONS", - /* 67 */ "FILE_FACTOR", - /* 68 */ "NK_FLOAT", - /* 69 */ "TABLE", - /* 70 */ "NK_LP", - /* 71 */ "NK_RP", - /* 72 */ "STABLE", - /* 73 */ "ADD", - /* 74 */ "COLUMN", - /* 75 */ "MODIFY", - /* 76 */ "RENAME", - /* 77 */ "TAG", - /* 78 */ "SET", - /* 79 */ "NK_EQ", - /* 80 */ "USING", - /* 81 */ "TAGS", - /* 82 */ "NK_DOT", - /* 83 */ "NK_COMMA", - /* 84 */ "COMMENT", - /* 85 */ "BOOL", - /* 86 */ "TINYINT", - /* 87 */ "SMALLINT", - /* 88 */ "INT", - /* 89 */ "INTEGER", - /* 90 */ "BIGINT", - /* 91 */ "FLOAT", - /* 92 */ "DOUBLE", - /* 93 */ "BINARY", - /* 94 */ "TIMESTAMP", - /* 95 */ "NCHAR", - /* 96 */ "UNSIGNED", - /* 97 */ "JSON", - /* 98 */ "VARCHAR", - /* 99 */ "MEDIUMBLOB", - /* 100 */ "BLOB", - /* 101 */ "VARBINARY", - /* 102 */ "DECIMAL", - /* 103 */ "SMA", - /* 104 */ "ROLLUP", - /* 105 */ "SHOW", - /* 106 */ "DATABASES", - /* 107 */ "TABLES", - /* 108 */ "STABLES", - /* 109 */ "MNODES", - /* 110 */ "MODULES", - /* 111 */ "QNODES", - /* 112 */ "FUNCTIONS", - /* 113 */ "INDEXES", - /* 114 */ "FROM", - /* 115 */ "LIKE", - /* 116 */ "INDEX", - /* 117 */ "FULLTEXT", - /* 118 */ "FUNCTION", - /* 119 */ "INTERVAL", - /* 120 */ "TOPIC", - /* 121 */ "AS", - /* 122 */ "NK_BOOL", - /* 123 */ "NK_VARIABLE", - /* 124 */ "BETWEEN", - /* 125 */ "IS", - /* 126 */ "NULL", - /* 127 */ "NK_LT", - /* 128 */ "NK_GT", - /* 129 */ "NK_LE", - /* 130 */ "NK_GE", - /* 131 */ "NK_NE", - /* 132 */ "MATCH", - /* 133 */ "NMATCH", - /* 134 */ "IN", - /* 135 */ "JOIN", - /* 136 */ "INNER", - /* 137 */ "SELECT", - /* 138 */ "DISTINCT", - /* 139 */ "WHERE", - /* 140 */ "PARTITION", - /* 141 */ "BY", - /* 142 */ "SESSION", - /* 143 */ "STATE_WINDOW", - /* 144 */ "SLIDING", - /* 145 */ "FILL", - /* 146 */ "VALUE", - /* 147 */ "NONE", - /* 148 */ "PREV", - /* 149 */ "LINEAR", - /* 150 */ "NEXT", - /* 151 */ "GROUP", - /* 152 */ "HAVING", - /* 153 */ "ORDER", - /* 154 */ "SLIMIT", - /* 155 */ "SOFFSET", - /* 156 */ "LIMIT", - /* 157 */ "OFFSET", - /* 158 */ "ASC", - /* 159 */ "DESC", - /* 160 */ "NULLS", - /* 161 */ "FIRST", - /* 162 */ "LAST", - /* 163 */ "cmd", - /* 164 */ "account_options", - /* 165 */ "alter_account_options", - /* 166 */ "literal", - /* 167 */ "alter_account_option", - /* 168 */ "user_name", - /* 169 */ "dnode_endpoint", - /* 170 */ "dnode_host_name", - /* 171 */ "not_exists_opt", - /* 172 */ "db_name", - /* 173 */ "db_options", - /* 174 */ "exists_opt", - /* 175 */ "alter_db_options", - /* 176 */ "alter_db_option", - /* 177 */ "full_table_name", - /* 178 */ "column_def_list", - /* 179 */ "tags_def_opt", - /* 180 */ "table_options", - /* 181 */ "multi_create_clause", - /* 182 */ "tags_def", - /* 183 */ "multi_drop_clause", - /* 184 */ "alter_table_clause", - /* 185 */ "alter_table_options", - /* 186 */ "column_name", - /* 187 */ "type_name", - /* 188 */ "create_subtable_clause", - /* 189 */ "specific_tags_opt", - /* 190 */ "literal_list", - /* 191 */ "drop_table_clause", - /* 192 */ "col_name_list", - /* 193 */ "table_name", - /* 194 */ "column_def", - /* 195 */ "func_name_list", - /* 196 */ "alter_table_option", - /* 197 */ "col_name", - /* 198 */ "db_name_cond_opt", - /* 199 */ "like_pattern_opt", - /* 200 */ "table_name_cond", - /* 201 */ "from_db_opt", - /* 202 */ "func_name", - /* 203 */ "function_name", - /* 204 */ "index_name", - /* 205 */ "index_options", - /* 206 */ "func_list", - /* 207 */ "duration_literal", - /* 208 */ "sliding_opt", - /* 209 */ "func", - /* 210 */ "expression_list", - /* 211 */ "topic_name", - /* 212 */ "query_expression", - /* 213 */ "signed", - /* 214 */ "signed_literal", - /* 215 */ "table_alias", - /* 216 */ "column_alias", - /* 217 */ "expression", - /* 218 */ "column_reference", - /* 219 */ "subquery", - /* 220 */ "predicate", - /* 221 */ "compare_op", - /* 222 */ "in_op", - /* 223 */ "in_predicate_value", - /* 224 */ "boolean_value_expression", - /* 225 */ "boolean_primary", - /* 226 */ "common_expression", - /* 227 */ "from_clause", - /* 228 */ "table_reference_list", - /* 229 */ "table_reference", - /* 230 */ "table_primary", - /* 231 */ "joined_table", - /* 232 */ "alias_opt", - /* 233 */ "parenthesized_joined_table", - /* 234 */ "join_type", - /* 235 */ "search_condition", - /* 236 */ "query_specification", - /* 237 */ "set_quantifier_opt", - /* 238 */ "select_list", - /* 239 */ "where_clause_opt", - /* 240 */ "partition_by_clause_opt", - /* 241 */ "twindow_clause_opt", - /* 242 */ "group_by_clause_opt", - /* 243 */ "having_clause_opt", - /* 244 */ "select_sublist", - /* 245 */ "select_item", - /* 246 */ "fill_opt", - /* 247 */ "fill_mode", - /* 248 */ "group_by_list", - /* 249 */ "query_expression_body", - /* 250 */ "order_by_clause_opt", - /* 251 */ "slimit_clause_opt", - /* 252 */ "limit_clause_opt", - /* 253 */ "query_primary", - /* 254 */ "sort_specification_list", - /* 255 */ "sort_specification", - /* 256 */ "ordering_specification_opt", - /* 257 */ "null_ordering_opt", + /* 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", + /* 82 */ "COMMENT", + /* 83 */ "BOOL", + /* 84 */ "TINYINT", + /* 85 */ "SMALLINT", + /* 86 */ "INT", + /* 87 */ "INTEGER", + /* 88 */ "BIGINT", + /* 89 */ "FLOAT", + /* 90 */ "DOUBLE", + /* 91 */ "BINARY", + /* 92 */ "TIMESTAMP", + /* 93 */ "NCHAR", + /* 94 */ "UNSIGNED", + /* 95 */ "JSON", + /* 96 */ "VARCHAR", + /* 97 */ "MEDIUMBLOB", + /* 98 */ "BLOB", + /* 99 */ "VARBINARY", + /* 100 */ "DECIMAL", + /* 101 */ "SMA", + /* 102 */ "ROLLUP", + /* 103 */ "FILE_FACTOR", + /* 104 */ "NK_FLOAT", + /* 105 */ "DELAY", + /* 106 */ "SHOW", + /* 107 */ "DATABASES", + /* 108 */ "TABLES", + /* 109 */ "STABLES", + /* 110 */ "MNODES", + /* 111 */ "MODULES", + /* 112 */ "QNODES", + /* 113 */ "FUNCTIONS", + /* 114 */ "INDEXES", + /* 115 */ "FROM", + /* 116 */ "LIKE", + /* 117 */ "INDEX", + /* 118 */ "FULLTEXT", + /* 119 */ "FUNCTION", + /* 120 */ "INTERVAL", + /* 121 */ "TOPIC", + /* 122 */ "AS", + /* 123 */ "NK_BOOL", + /* 124 */ "NK_VARIABLE", + /* 125 */ "NK_UNDERLINE", + /* 126 */ "ROWTS", + /* 127 */ "TBNAME", + /* 128 */ "QSTARTTS", + /* 129 */ "QENDTS", + /* 130 */ "WSTARTTS", + /* 131 */ "WENDTS", + /* 132 */ "WDURATION", + /* 133 */ "BETWEEN", + /* 134 */ "IS", + /* 135 */ "NULL", + /* 136 */ "NK_LT", + /* 137 */ "NK_GT", + /* 138 */ "NK_LE", + /* 139 */ "NK_GE", + /* 140 */ "NK_NE", + /* 141 */ "MATCH", + /* 142 */ "NMATCH", + /* 143 */ "IN", + /* 144 */ "JOIN", + /* 145 */ "INNER", + /* 146 */ "SELECT", + /* 147 */ "DISTINCT", + /* 148 */ "WHERE", + /* 149 */ "PARTITION", + /* 150 */ "BY", + /* 151 */ "SESSION", + /* 152 */ "STATE_WINDOW", + /* 153 */ "SLIDING", + /* 154 */ "FILL", + /* 155 */ "VALUE", + /* 156 */ "NONE", + /* 157 */ "PREV", + /* 158 */ "LINEAR", + /* 159 */ "NEXT", + /* 160 */ "GROUP", + /* 161 */ "HAVING", + /* 162 */ "ORDER", + /* 163 */ "SLIMIT", + /* 164 */ "SOFFSET", + /* 165 */ "LIMIT", + /* 166 */ "OFFSET", + /* 167 */ "ASC", + /* 168 */ "DESC", + /* 169 */ "NULLS", + /* 170 */ "FIRST", + /* 171 */ "LAST", + /* 172 */ "cmd", + /* 173 */ "account_options", + /* 174 */ "alter_account_options", + /* 175 */ "literal", + /* 176 */ "alter_account_option", + /* 177 */ "user_name", + /* 178 */ "dnode_endpoint", + /* 179 */ "dnode_host_name", + /* 180 */ "not_exists_opt", + /* 181 */ "db_name", + /* 182 */ "db_options", + /* 183 */ "exists_opt", + /* 184 */ "alter_db_options", + /* 185 */ "alter_db_option", + /* 186 */ "full_table_name", + /* 187 */ "column_def_list", + /* 188 */ "tags_def_opt", + /* 189 */ "table_options", + /* 190 */ "multi_create_clause", + /* 191 */ "tags_def", + /* 192 */ "multi_drop_clause", + /* 193 */ "alter_table_clause", + /* 194 */ "alter_table_options", + /* 195 */ "column_name", + /* 196 */ "type_name", + /* 197 */ "create_subtable_clause", + /* 198 */ "specific_tags_opt", + /* 199 */ "literal_list", + /* 200 */ "drop_table_clause", + /* 201 */ "col_name_list", + /* 202 */ "table_name", + /* 203 */ "column_def", + /* 204 */ "func_name_list", + /* 205 */ "alter_table_option", + /* 206 */ "col_name", + /* 207 */ "db_name_cond_opt", + /* 208 */ "like_pattern_opt", + /* 209 */ "table_name_cond", + /* 210 */ "from_db_opt", + /* 211 */ "func_name", + /* 212 */ "function_name", + /* 213 */ "index_name", + /* 214 */ "index_options", + /* 215 */ "func_list", + /* 216 */ "duration_literal", + /* 217 */ "sliding_opt", + /* 218 */ "func", + /* 219 */ "expression_list", + /* 220 */ "topic_name", + /* 221 */ "query_expression", + /* 222 */ "signed", + /* 223 */ "signed_literal", + /* 224 */ "table_alias", + /* 225 */ "column_alias", + /* 226 */ "expression", + /* 227 */ "pseudo_column", + /* 228 */ "column_reference", + /* 229 */ "subquery", + /* 230 */ "predicate", + /* 231 */ "compare_op", + /* 232 */ "in_op", + /* 233 */ "in_predicate_value", + /* 234 */ "boolean_value_expression", + /* 235 */ "boolean_primary", + /* 236 */ "common_expression", + /* 237 */ "from_clause", + /* 238 */ "table_reference_list", + /* 239 */ "table_reference", + /* 240 */ "table_primary", + /* 241 */ "joined_table", + /* 242 */ "alias_opt", + /* 243 */ "parenthesized_joined_table", + /* 244 */ "join_type", + /* 245 */ "search_condition", + /* 246 */ "query_specification", + /* 247 */ "set_quantifier_opt", + /* 248 */ "select_list", + /* 249 */ "where_clause_opt", + /* 250 */ "partition_by_clause_opt", + /* 251 */ "twindow_clause_opt", + /* 252 */ "group_by_clause_opt", + /* 253 */ "having_clause_opt", + /* 254 */ "select_sublist", + /* 255 */ "select_item", + /* 256 */ "fill_opt", + /* 257 */ "fill_mode", + /* 258 */ "group_by_list", + /* 259 */ "query_expression_body", + /* 260 */ "order_by_clause_opt", + /* 261 */ "slimit_clause_opt", + /* 262 */ "limit_clause_opt", + /* 263 */ "query_primary", + /* 264 */ "sort_specification_list", + /* 265 */ "sort_specification", + /* 266 */ "ordering_specification_opt", + /* 267 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1041,273 +1061,282 @@ static const char *const yyRuleName[] = { /* 67 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", /* 68 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", /* 69 */ "db_options ::= db_options RETENTIONS NK_STRING", - /* 70 */ "db_options ::= db_options FILE_FACTOR NK_FLOAT", - /* 71 */ "alter_db_options ::= alter_db_option", - /* 72 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 73 */ "alter_db_option ::= BLOCKS NK_INTEGER", - /* 74 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 75 */ "alter_db_option ::= KEEP NK_INTEGER", - /* 76 */ "alter_db_option ::= WAL NK_INTEGER", - /* 77 */ "alter_db_option ::= QUORUM NK_INTEGER", - /* 78 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 79 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 80 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 81 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 82 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 83 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 84 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 85 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 86 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 87 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 88 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 89 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 90 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 91 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 92 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 93 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 94 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 95 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", - /* 96 */ "multi_create_clause ::= create_subtable_clause", - /* 97 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 98 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 99 */ "multi_drop_clause ::= drop_table_clause", - /* 100 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 101 */ "drop_table_clause ::= exists_opt full_table_name", - /* 102 */ "specific_tags_opt ::=", - /* 103 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 104 */ "full_table_name ::= table_name", - /* 105 */ "full_table_name ::= db_name NK_DOT table_name", - /* 106 */ "column_def_list ::= column_def", - /* 107 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 108 */ "column_def ::= column_name type_name", - /* 109 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 110 */ "type_name ::= BOOL", - /* 111 */ "type_name ::= TINYINT", - /* 112 */ "type_name ::= SMALLINT", - /* 113 */ "type_name ::= INT", - /* 114 */ "type_name ::= INTEGER", - /* 115 */ "type_name ::= BIGINT", - /* 116 */ "type_name ::= FLOAT", - /* 117 */ "type_name ::= DOUBLE", - /* 118 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 119 */ "type_name ::= TIMESTAMP", - /* 120 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 121 */ "type_name ::= TINYINT UNSIGNED", - /* 122 */ "type_name ::= SMALLINT UNSIGNED", - /* 123 */ "type_name ::= INT UNSIGNED", - /* 124 */ "type_name ::= BIGINT UNSIGNED", - /* 125 */ "type_name ::= JSON", - /* 126 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 127 */ "type_name ::= MEDIUMBLOB", - /* 128 */ "type_name ::= BLOB", - /* 129 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 130 */ "type_name ::= DECIMAL", - /* 131 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 132 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 133 */ "tags_def_opt ::=", - /* 134 */ "tags_def_opt ::= tags_def", - /* 135 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 136 */ "table_options ::=", - /* 137 */ "table_options ::= table_options COMMENT NK_STRING", - /* 138 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 139 */ "table_options ::= table_options TTL NK_INTEGER", - /* 140 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 141 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 142 */ "alter_table_options ::= alter_table_option", - /* 143 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 144 */ "alter_table_option ::= COMMENT NK_STRING", - /* 145 */ "alter_table_option ::= KEEP NK_INTEGER", - /* 146 */ "alter_table_option ::= TTL NK_INTEGER", - /* 147 */ "col_name_list ::= col_name", - /* 148 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 149 */ "col_name ::= column_name", - /* 150 */ "cmd ::= SHOW DNODES", - /* 151 */ "cmd ::= SHOW USERS", - /* 152 */ "cmd ::= SHOW DATABASES", - /* 153 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 154 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 155 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 156 */ "cmd ::= SHOW MNODES", - /* 157 */ "cmd ::= SHOW MODULES", - /* 158 */ "cmd ::= SHOW QNODES", - /* 159 */ "cmd ::= SHOW FUNCTIONS", - /* 160 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 161 */ "cmd ::= SHOW STREAMS", - /* 162 */ "db_name_cond_opt ::=", - /* 163 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 164 */ "like_pattern_opt ::=", - /* 165 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 166 */ "table_name_cond ::= table_name", - /* 167 */ "from_db_opt ::=", - /* 168 */ "from_db_opt ::= FROM db_name", - /* 169 */ "func_name_list ::= func_name", - /* 170 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 171 */ "func_name ::= function_name", - /* 172 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 173 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 174 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 175 */ "index_options ::=", - /* 176 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 177 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 178 */ "func_list ::= func", - /* 179 */ "func_list ::= func_list NK_COMMA func", - /* 180 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 181 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 182 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 183 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 184 */ "cmd ::= query_expression", - /* 185 */ "literal ::= NK_INTEGER", - /* 186 */ "literal ::= NK_FLOAT", - /* 187 */ "literal ::= NK_STRING", - /* 188 */ "literal ::= NK_BOOL", - /* 189 */ "literal ::= TIMESTAMP NK_STRING", - /* 190 */ "literal ::= duration_literal", - /* 191 */ "duration_literal ::= NK_VARIABLE", - /* 192 */ "signed ::= NK_INTEGER", - /* 193 */ "signed ::= NK_PLUS NK_INTEGER", - /* 194 */ "signed ::= NK_MINUS NK_INTEGER", - /* 195 */ "signed ::= NK_FLOAT", - /* 196 */ "signed ::= NK_PLUS NK_FLOAT", - /* 197 */ "signed ::= NK_MINUS NK_FLOAT", - /* 198 */ "signed_literal ::= signed", - /* 199 */ "signed_literal ::= NK_STRING", - /* 200 */ "signed_literal ::= NK_BOOL", - /* 201 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 202 */ "signed_literal ::= duration_literal", - /* 203 */ "literal_list ::= signed_literal", - /* 204 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 205 */ "db_name ::= NK_ID", - /* 206 */ "table_name ::= NK_ID", - /* 207 */ "column_name ::= NK_ID", - /* 208 */ "function_name ::= NK_ID", - /* 209 */ "table_alias ::= NK_ID", - /* 210 */ "column_alias ::= NK_ID", - /* 211 */ "user_name ::= NK_ID", - /* 212 */ "index_name ::= NK_ID", - /* 213 */ "topic_name ::= NK_ID", - /* 214 */ "expression ::= literal", - /* 215 */ "expression ::= column_reference", - /* 216 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 217 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 218 */ "expression ::= subquery", - /* 219 */ "expression ::= NK_LP expression NK_RP", - /* 220 */ "expression ::= NK_PLUS expression", - /* 221 */ "expression ::= NK_MINUS expression", - /* 222 */ "expression ::= expression NK_PLUS expression", - /* 223 */ "expression ::= expression NK_MINUS expression", - /* 224 */ "expression ::= expression NK_STAR expression", - /* 225 */ "expression ::= expression NK_SLASH expression", - /* 226 */ "expression ::= expression NK_REM expression", - /* 227 */ "expression_list ::= expression", - /* 228 */ "expression_list ::= expression_list NK_COMMA expression", - /* 229 */ "column_reference ::= column_name", - /* 230 */ "column_reference ::= table_name NK_DOT column_name", - /* 231 */ "predicate ::= expression compare_op expression", - /* 232 */ "predicate ::= expression BETWEEN expression AND expression", - /* 233 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 234 */ "predicate ::= expression IS NULL", - /* 235 */ "predicate ::= expression IS NOT NULL", - /* 236 */ "predicate ::= expression in_op in_predicate_value", - /* 237 */ "compare_op ::= NK_LT", - /* 238 */ "compare_op ::= NK_GT", - /* 239 */ "compare_op ::= NK_LE", - /* 240 */ "compare_op ::= NK_GE", - /* 241 */ "compare_op ::= NK_NE", - /* 242 */ "compare_op ::= NK_EQ", - /* 243 */ "compare_op ::= LIKE", - /* 244 */ "compare_op ::= NOT LIKE", - /* 245 */ "compare_op ::= MATCH", - /* 246 */ "compare_op ::= NMATCH", - /* 247 */ "in_op ::= IN", - /* 248 */ "in_op ::= NOT IN", - /* 249 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 250 */ "boolean_value_expression ::= boolean_primary", - /* 251 */ "boolean_value_expression ::= NOT boolean_primary", - /* 252 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 253 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 254 */ "boolean_primary ::= predicate", - /* 255 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 256 */ "common_expression ::= expression", - /* 257 */ "common_expression ::= boolean_value_expression", - /* 258 */ "from_clause ::= FROM table_reference_list", - /* 259 */ "table_reference_list ::= table_reference", - /* 260 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 261 */ "table_reference ::= table_primary", - /* 262 */ "table_reference ::= joined_table", - /* 263 */ "table_primary ::= table_name alias_opt", - /* 264 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 265 */ "table_primary ::= subquery alias_opt", - /* 266 */ "table_primary ::= parenthesized_joined_table", - /* 267 */ "alias_opt ::=", - /* 268 */ "alias_opt ::= table_alias", - /* 269 */ "alias_opt ::= AS table_alias", - /* 270 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 271 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 272 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 273 */ "join_type ::=", - /* 274 */ "join_type ::= INNER", - /* 275 */ "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", - /* 276 */ "set_quantifier_opt ::=", - /* 277 */ "set_quantifier_opt ::= DISTINCT", - /* 278 */ "set_quantifier_opt ::= ALL", - /* 279 */ "select_list ::= NK_STAR", - /* 280 */ "select_list ::= select_sublist", - /* 281 */ "select_sublist ::= select_item", - /* 282 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 283 */ "select_item ::= common_expression", - /* 284 */ "select_item ::= common_expression column_alias", - /* 285 */ "select_item ::= common_expression AS column_alias", - /* 286 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 287 */ "where_clause_opt ::=", - /* 288 */ "where_clause_opt ::= WHERE search_condition", - /* 289 */ "partition_by_clause_opt ::=", - /* 290 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 291 */ "twindow_clause_opt ::=", - /* 292 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 293 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 294 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 295 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 296 */ "sliding_opt ::=", - /* 297 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 298 */ "fill_opt ::=", - /* 299 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 300 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 301 */ "fill_mode ::= NONE", - /* 302 */ "fill_mode ::= PREV", - /* 303 */ "fill_mode ::= NULL", - /* 304 */ "fill_mode ::= LINEAR", - /* 305 */ "fill_mode ::= NEXT", - /* 306 */ "group_by_clause_opt ::=", - /* 307 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 308 */ "group_by_list ::= expression", - /* 309 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 310 */ "having_clause_opt ::=", - /* 311 */ "having_clause_opt ::= HAVING search_condition", - /* 312 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 313 */ "query_expression_body ::= query_primary", - /* 314 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 315 */ "query_primary ::= query_specification", - /* 316 */ "order_by_clause_opt ::=", - /* 317 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 318 */ "slimit_clause_opt ::=", - /* 319 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 320 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 321 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 322 */ "limit_clause_opt ::=", - /* 323 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 324 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 325 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 326 */ "subquery ::= NK_LP query_expression NK_RP", - /* 327 */ "search_condition ::= common_expression", - /* 328 */ "sort_specification_list ::= sort_specification", - /* 329 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 330 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 331 */ "ordering_specification_opt ::=", - /* 332 */ "ordering_specification_opt ::= ASC", - /* 333 */ "ordering_specification_opt ::= DESC", - /* 334 */ "null_ordering_opt ::=", - /* 335 */ "null_ordering_opt ::= NULLS FIRST", - /* 336 */ "null_ordering_opt ::= NULLS LAST", + /* 70 */ "alter_db_options ::= alter_db_option", + /* 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", + /* 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 ::= query_expression", + /* 186 */ "literal ::= NK_INTEGER", + /* 187 */ "literal ::= NK_FLOAT", + /* 188 */ "literal ::= NK_STRING", + /* 189 */ "literal ::= NK_BOOL", + /* 190 */ "literal ::= TIMESTAMP NK_STRING", + /* 191 */ "literal ::= duration_literal", + /* 192 */ "duration_literal ::= NK_VARIABLE", + /* 193 */ "signed ::= NK_INTEGER", + /* 194 */ "signed ::= NK_PLUS NK_INTEGER", + /* 195 */ "signed ::= NK_MINUS NK_INTEGER", + /* 196 */ "signed ::= NK_FLOAT", + /* 197 */ "signed ::= NK_PLUS NK_FLOAT", + /* 198 */ "signed ::= NK_MINUS NK_FLOAT", + /* 199 */ "signed_literal ::= signed", + /* 200 */ "signed_literal ::= NK_STRING", + /* 201 */ "signed_literal ::= NK_BOOL", + /* 202 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 203 */ "signed_literal ::= duration_literal", + /* 204 */ "literal_list ::= signed_literal", + /* 205 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 206 */ "db_name ::= NK_ID", + /* 207 */ "table_name ::= NK_ID", + /* 208 */ "column_name ::= NK_ID", + /* 209 */ "function_name ::= NK_ID", + /* 210 */ "table_alias ::= NK_ID", + /* 211 */ "column_alias ::= NK_ID", + /* 212 */ "user_name ::= NK_ID", + /* 213 */ "index_name ::= NK_ID", + /* 214 */ "topic_name ::= NK_ID", + /* 215 */ "expression ::= literal", + /* 216 */ "expression ::= pseudo_column", + /* 217 */ "expression ::= column_reference", + /* 218 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 219 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 220 */ "expression ::= subquery", + /* 221 */ "expression ::= NK_LP expression NK_RP", + /* 222 */ "expression ::= NK_PLUS expression", + /* 223 */ "expression ::= NK_MINUS expression", + /* 224 */ "expression ::= expression NK_PLUS expression", + /* 225 */ "expression ::= expression NK_MINUS expression", + /* 226 */ "expression ::= expression NK_STAR expression", + /* 227 */ "expression ::= expression NK_SLASH expression", + /* 228 */ "expression ::= expression NK_REM expression", + /* 229 */ "expression_list ::= expression", + /* 230 */ "expression_list ::= expression_list NK_COMMA expression", + /* 231 */ "column_reference ::= column_name", + /* 232 */ "column_reference ::= table_name NK_DOT column_name", + /* 233 */ "pseudo_column ::= NK_UNDERLINE ROWTS", + /* 234 */ "pseudo_column ::= TBNAME", + /* 235 */ "pseudo_column ::= NK_UNDERLINE QSTARTTS", + /* 236 */ "pseudo_column ::= NK_UNDERLINE QENDTS", + /* 237 */ "pseudo_column ::= NK_UNDERLINE WSTARTTS", + /* 238 */ "pseudo_column ::= NK_UNDERLINE WENDTS", + /* 239 */ "pseudo_column ::= NK_UNDERLINE WDURATION", + /* 240 */ "predicate ::= expression compare_op expression", + /* 241 */ "predicate ::= expression BETWEEN expression AND expression", + /* 242 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 243 */ "predicate ::= expression IS NULL", + /* 244 */ "predicate ::= expression IS NOT NULL", + /* 245 */ "predicate ::= expression in_op in_predicate_value", + /* 246 */ "compare_op ::= NK_LT", + /* 247 */ "compare_op ::= NK_GT", + /* 248 */ "compare_op ::= NK_LE", + /* 249 */ "compare_op ::= NK_GE", + /* 250 */ "compare_op ::= NK_NE", + /* 251 */ "compare_op ::= NK_EQ", + /* 252 */ "compare_op ::= LIKE", + /* 253 */ "compare_op ::= NOT LIKE", + /* 254 */ "compare_op ::= MATCH", + /* 255 */ "compare_op ::= NMATCH", + /* 256 */ "in_op ::= IN", + /* 257 */ "in_op ::= NOT IN", + /* 258 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 259 */ "boolean_value_expression ::= boolean_primary", + /* 260 */ "boolean_value_expression ::= NOT boolean_primary", + /* 261 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 262 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 263 */ "boolean_primary ::= predicate", + /* 264 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 265 */ "common_expression ::= expression", + /* 266 */ "common_expression ::= boolean_value_expression", + /* 267 */ "from_clause ::= FROM table_reference_list", + /* 268 */ "table_reference_list ::= table_reference", + /* 269 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 270 */ "table_reference ::= table_primary", + /* 271 */ "table_reference ::= joined_table", + /* 272 */ "table_primary ::= table_name alias_opt", + /* 273 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 274 */ "table_primary ::= subquery alias_opt", + /* 275 */ "table_primary ::= parenthesized_joined_table", + /* 276 */ "alias_opt ::=", + /* 277 */ "alias_opt ::= table_alias", + /* 278 */ "alias_opt ::= AS table_alias", + /* 279 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 280 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 281 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 282 */ "join_type ::=", + /* 283 */ "join_type ::= INNER", + /* 284 */ "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", + /* 285 */ "set_quantifier_opt ::=", + /* 286 */ "set_quantifier_opt ::= DISTINCT", + /* 287 */ "set_quantifier_opt ::= ALL", + /* 288 */ "select_list ::= NK_STAR", + /* 289 */ "select_list ::= select_sublist", + /* 290 */ "select_sublist ::= select_item", + /* 291 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 292 */ "select_item ::= common_expression", + /* 293 */ "select_item ::= common_expression column_alias", + /* 294 */ "select_item ::= common_expression AS column_alias", + /* 295 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 296 */ "where_clause_opt ::=", + /* 297 */ "where_clause_opt ::= WHERE search_condition", + /* 298 */ "partition_by_clause_opt ::=", + /* 299 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 300 */ "twindow_clause_opt ::=", + /* 301 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 302 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 303 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 304 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 305 */ "sliding_opt ::=", + /* 306 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 307 */ "fill_opt ::=", + /* 308 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 309 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 310 */ "fill_mode ::= NONE", + /* 311 */ "fill_mode ::= PREV", + /* 312 */ "fill_mode ::= NULL", + /* 313 */ "fill_mode ::= LINEAR", + /* 314 */ "fill_mode ::= NEXT", + /* 315 */ "group_by_clause_opt ::=", + /* 316 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 317 */ "group_by_list ::= expression", + /* 318 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 319 */ "having_clause_opt ::=", + /* 320 */ "having_clause_opt ::= HAVING search_condition", + /* 321 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 322 */ "query_expression_body ::= query_primary", + /* 323 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 324 */ "query_primary ::= query_specification", + /* 325 */ "order_by_clause_opt ::=", + /* 326 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 327 */ "slimit_clause_opt ::=", + /* 328 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 329 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 330 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 331 */ "limit_clause_opt ::=", + /* 332 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 333 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 334 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 335 */ "subquery ::= NK_LP query_expression NK_RP", + /* 336 */ "search_condition ::= common_expression", + /* 337 */ "sort_specification_list ::= sort_specification", + /* 338 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 339 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 340 */ "ordering_specification_opt ::=", + /* 341 */ "ordering_specification_opt ::= ASC", + /* 342 */ "ordering_specification_opt ::= DESC", + /* 343 */ "null_ordering_opt ::=", + /* 344 */ "null_ordering_opt ::= NULLS FIRST", + /* 345 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1325,10 +1354,10 @@ static int yyGrowStack(yyParser *p){ newSize = p->yystksz*2 + 100; idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; if( p->yystack==&p->yystk0 ){ - pNew = taosMemoryMalloc(newSize*sizeof(pNew[0])); + pNew = malloc(newSize*sizeof(pNew[0])); if( pNew ) pNew[0] = p->yystk0; }else{ - pNew = taosMemoryRealloc(p->yystack, newSize*sizeof(pNew[0])); + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); } if( pNew ){ p->yystack = pNew; @@ -1434,145 +1463,146 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 163: /* cmd */ - case 166: /* literal */ - case 173: /* db_options */ - case 175: /* alter_db_options */ - case 177: /* full_table_name */ - case 180: /* table_options */ - case 184: /* alter_table_clause */ - case 185: /* alter_table_options */ - case 188: /* create_subtable_clause */ - case 191: /* drop_table_clause */ - case 194: /* column_def */ - case 197: /* col_name */ - case 198: /* db_name_cond_opt */ - case 199: /* like_pattern_opt */ - case 200: /* table_name_cond */ - case 201: /* from_db_opt */ - case 202: /* func_name */ - case 205: /* index_options */ - case 207: /* duration_literal */ - case 208: /* sliding_opt */ - case 209: /* func */ - case 212: /* query_expression */ - case 213: /* signed */ - case 214: /* signed_literal */ - case 217: /* expression */ - case 218: /* column_reference */ - case 219: /* subquery */ - case 220: /* predicate */ - case 223: /* in_predicate_value */ - case 224: /* boolean_value_expression */ - case 225: /* boolean_primary */ - case 226: /* common_expression */ - case 227: /* from_clause */ - case 228: /* table_reference_list */ - case 229: /* table_reference */ - case 230: /* table_primary */ - case 231: /* joined_table */ - case 233: /* parenthesized_joined_table */ - case 235: /* search_condition */ - case 236: /* query_specification */ - case 239: /* where_clause_opt */ - case 241: /* twindow_clause_opt */ - case 243: /* having_clause_opt */ - case 245: /* select_item */ - case 246: /* fill_opt */ - case 249: /* query_expression_body */ - case 251: /* slimit_clause_opt */ - case 252: /* limit_clause_opt */ - case 253: /* query_primary */ - case 255: /* sort_specification */ + case 172: /* cmd */ + case 175: /* literal */ + case 182: /* db_options */ + case 184: /* alter_db_options */ + case 186: /* full_table_name */ + case 189: /* table_options */ + case 193: /* alter_table_clause */ + case 194: /* alter_table_options */ + case 197: /* create_subtable_clause */ + case 200: /* drop_table_clause */ + case 203: /* column_def */ + case 206: /* col_name */ + case 207: /* db_name_cond_opt */ + case 208: /* like_pattern_opt */ + case 209: /* table_name_cond */ + case 210: /* from_db_opt */ + case 211: /* func_name */ + case 214: /* index_options */ + case 216: /* duration_literal */ + case 217: /* sliding_opt */ + case 218: /* func */ + case 221: /* query_expression */ + case 222: /* signed */ + case 223: /* signed_literal */ + case 226: /* expression */ + case 227: /* pseudo_column */ + case 228: /* column_reference */ + case 229: /* subquery */ + case 230: /* predicate */ + case 233: /* in_predicate_value */ + case 234: /* boolean_value_expression */ + case 235: /* boolean_primary */ + case 236: /* common_expression */ + case 237: /* from_clause */ + case 238: /* table_reference_list */ + case 239: /* table_reference */ + case 240: /* table_primary */ + case 241: /* joined_table */ + case 243: /* parenthesized_joined_table */ + case 245: /* search_condition */ + case 246: /* query_specification */ + case 249: /* where_clause_opt */ + case 251: /* twindow_clause_opt */ + case 253: /* having_clause_opt */ + case 255: /* select_item */ + case 256: /* fill_opt */ + case 259: /* query_expression_body */ + case 261: /* slimit_clause_opt */ + case 262: /* limit_clause_opt */ + case 263: /* query_primary */ + case 265: /* sort_specification */ { - nodesDestroyNode((yypminor->yy140)); + nodesDestroyNode((yypminor->yy176)); } break; - case 164: /* account_options */ - case 165: /* alter_account_options */ - case 167: /* alter_account_option */ + case 173: /* account_options */ + case 174: /* alter_account_options */ + case 176: /* alter_account_option */ { } break; - case 168: /* user_name */ - case 169: /* dnode_endpoint */ - case 170: /* dnode_host_name */ - case 172: /* db_name */ - case 186: /* column_name */ - case 193: /* table_name */ - case 203: /* function_name */ - case 204: /* index_name */ - case 211: /* topic_name */ - case 215: /* table_alias */ - case 216: /* column_alias */ - case 232: /* alias_opt */ + case 177: /* user_name */ + case 178: /* dnode_endpoint */ + case 179: /* dnode_host_name */ + case 181: /* db_name */ + case 195: /* column_name */ + case 202: /* table_name */ + case 212: /* function_name */ + case 213: /* index_name */ + case 220: /* topic_name */ + case 224: /* table_alias */ + case 225: /* column_alias */ + case 242: /* alias_opt */ { } break; - case 171: /* not_exists_opt */ - case 174: /* exists_opt */ - case 237: /* set_quantifier_opt */ + case 180: /* not_exists_opt */ + case 183: /* exists_opt */ + case 247: /* set_quantifier_opt */ { } break; - case 176: /* alter_db_option */ - case 196: /* alter_table_option */ + case 185: /* alter_db_option */ + case 205: /* alter_table_option */ { } break; - case 178: /* column_def_list */ - case 179: /* tags_def_opt */ - case 181: /* multi_create_clause */ - case 182: /* tags_def */ - case 183: /* multi_drop_clause */ - case 189: /* specific_tags_opt */ - case 190: /* literal_list */ - case 192: /* col_name_list */ - case 195: /* func_name_list */ - case 206: /* func_list */ - case 210: /* expression_list */ - case 238: /* select_list */ - case 240: /* partition_by_clause_opt */ - case 242: /* group_by_clause_opt */ - case 244: /* select_sublist */ - case 248: /* group_by_list */ - case 250: /* order_by_clause_opt */ - case 254: /* sort_specification_list */ + case 187: /* column_def_list */ + case 188: /* tags_def_opt */ + case 190: /* multi_create_clause */ + case 191: /* tags_def */ + case 192: /* multi_drop_clause */ + case 198: /* specific_tags_opt */ + case 199: /* literal_list */ + case 201: /* col_name_list */ + case 204: /* func_name_list */ + case 215: /* func_list */ + case 219: /* expression_list */ + case 248: /* select_list */ + case 250: /* partition_by_clause_opt */ + case 252: /* group_by_clause_opt */ + case 254: /* select_sublist */ + case 258: /* group_by_list */ + case 260: /* order_by_clause_opt */ + case 264: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy136)); + nodesDestroyList((yypminor->yy512)); } break; - case 187: /* type_name */ + case 196: /* type_name */ { } break; - case 221: /* compare_op */ - case 222: /* in_op */ + case 231: /* compare_op */ + case 232: /* in_op */ { } break; - case 234: /* join_type */ + case 244: /* join_type */ { } break; - case 247: /* fill_mode */ + case 257: /* fill_mode */ { } break; - case 256: /* ordering_specification_opt */ + case 266: /* ordering_specification_opt */ { } break; - case 257: /* null_ordering_opt */ + case 267: /* null_ordering_opt */ { } @@ -1610,7 +1640,7 @@ void ParseFinalize(void *p){ yyParser *pParser = (yyParser*)p; while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 - if( pParser->yystack!=&pParser->yystk0 ) taosMemoryFree(pParser->yystack); + if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); #endif } @@ -1871,343 +1901,352 @@ 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[] = { - { 163, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 163, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 164, 0 }, /* (2) account_options ::= */ - { 164, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 164, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 164, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 164, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 164, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 164, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 164, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 164, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 164, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 165, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 165, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 167, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 167, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 167, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 167, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 167, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 167, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 167, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 167, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 167, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 167, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 163, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 163, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 163, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 163, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 163, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - { 163, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 163, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - { 163, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - { 163, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 163, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 163, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - { 163, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 169, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ - { 170, -1 }, /* (37) dnode_host_name ::= NK_ID */ - { 170, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ - { 163, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - { 163, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 163, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 163, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 163, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 163, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ - { 163, -2 }, /* (45) cmd ::= USE db_name */ - { 163, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 171, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ - { 171, 0 }, /* (48) not_exists_opt ::= */ - { 174, -2 }, /* (49) exists_opt ::= IF EXISTS */ - { 174, 0 }, /* (50) exists_opt ::= */ - { 173, 0 }, /* (51) db_options ::= */ - { 173, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ - { 173, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ - { 173, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ - { 173, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ - { 173, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ - { 173, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ - { 173, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ - { 173, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ - { 173, -3 }, /* (60) db_options ::= db_options KEEP NK_INTEGER */ - { 173, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ - { 173, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ - { 173, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ - { 173, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ - { 173, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ - { 173, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ - { 173, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 173, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 173, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ - { 173, -3 }, /* (70) db_options ::= db_options FILE_FACTOR NK_FLOAT */ - { 175, -1 }, /* (71) alter_db_options ::= alter_db_option */ - { 175, -2 }, /* (72) alter_db_options ::= alter_db_options alter_db_option */ - { 176, -2 }, /* (73) alter_db_option ::= BLOCKS NK_INTEGER */ - { 176, -2 }, /* (74) alter_db_option ::= FSYNC NK_INTEGER */ - { 176, -2 }, /* (75) alter_db_option ::= KEEP NK_INTEGER */ - { 176, -2 }, /* (76) alter_db_option ::= WAL NK_INTEGER */ - { 176, -2 }, /* (77) alter_db_option ::= QUORUM NK_INTEGER */ - { 176, -2 }, /* (78) alter_db_option ::= CACHELAST NK_INTEGER */ - { 163, -9 }, /* (79) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 163, -3 }, /* (80) cmd ::= CREATE TABLE multi_create_clause */ - { 163, -9 }, /* (81) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 163, -3 }, /* (82) cmd ::= DROP TABLE multi_drop_clause */ - { 163, -4 }, /* (83) cmd ::= DROP STABLE exists_opt full_table_name */ - { 163, -3 }, /* (84) cmd ::= ALTER TABLE alter_table_clause */ - { 163, -3 }, /* (85) cmd ::= ALTER STABLE alter_table_clause */ - { 184, -2 }, /* (86) alter_table_clause ::= full_table_name alter_table_options */ - { 184, -5 }, /* (87) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 184, -4 }, /* (88) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 184, -5 }, /* (89) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 184, -5 }, /* (90) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 184, -5 }, /* (91) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 184, -4 }, /* (92) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 184, -5 }, /* (93) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 184, -5 }, /* (94) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 184, -6 }, /* (95) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - { 181, -1 }, /* (96) multi_create_clause ::= create_subtable_clause */ - { 181, -2 }, /* (97) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 188, -9 }, /* (98) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 183, -1 }, /* (99) multi_drop_clause ::= drop_table_clause */ - { 183, -2 }, /* (100) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 191, -2 }, /* (101) drop_table_clause ::= exists_opt full_table_name */ - { 189, 0 }, /* (102) specific_tags_opt ::= */ - { 189, -3 }, /* (103) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 177, -1 }, /* (104) full_table_name ::= table_name */ - { 177, -3 }, /* (105) full_table_name ::= db_name NK_DOT table_name */ - { 178, -1 }, /* (106) column_def_list ::= column_def */ - { 178, -3 }, /* (107) column_def_list ::= column_def_list NK_COMMA column_def */ - { 194, -2 }, /* (108) column_def ::= column_name type_name */ - { 194, -4 }, /* (109) column_def ::= column_name type_name COMMENT NK_STRING */ - { 187, -1 }, /* (110) type_name ::= BOOL */ - { 187, -1 }, /* (111) type_name ::= TINYINT */ - { 187, -1 }, /* (112) type_name ::= SMALLINT */ - { 187, -1 }, /* (113) type_name ::= INT */ - { 187, -1 }, /* (114) type_name ::= INTEGER */ - { 187, -1 }, /* (115) type_name ::= BIGINT */ - { 187, -1 }, /* (116) type_name ::= FLOAT */ - { 187, -1 }, /* (117) type_name ::= DOUBLE */ - { 187, -4 }, /* (118) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 187, -1 }, /* (119) type_name ::= TIMESTAMP */ - { 187, -4 }, /* (120) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 187, -2 }, /* (121) type_name ::= TINYINT UNSIGNED */ - { 187, -2 }, /* (122) type_name ::= SMALLINT UNSIGNED */ - { 187, -2 }, /* (123) type_name ::= INT UNSIGNED */ - { 187, -2 }, /* (124) type_name ::= BIGINT UNSIGNED */ - { 187, -1 }, /* (125) type_name ::= JSON */ - { 187, -4 }, /* (126) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 187, -1 }, /* (127) type_name ::= MEDIUMBLOB */ - { 187, -1 }, /* (128) type_name ::= BLOB */ - { 187, -4 }, /* (129) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 187, -1 }, /* (130) type_name ::= DECIMAL */ - { 187, -4 }, /* (131) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 187, -6 }, /* (132) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 179, 0 }, /* (133) tags_def_opt ::= */ - { 179, -1 }, /* (134) tags_def_opt ::= tags_def */ - { 182, -4 }, /* (135) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 180, 0 }, /* (136) table_options ::= */ - { 180, -3 }, /* (137) table_options ::= table_options COMMENT NK_STRING */ - { 180, -3 }, /* (138) table_options ::= table_options KEEP NK_INTEGER */ - { 180, -3 }, /* (139) table_options ::= table_options TTL NK_INTEGER */ - { 180, -5 }, /* (140) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 180, -5 }, /* (141) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 185, -1 }, /* (142) alter_table_options ::= alter_table_option */ - { 185, -2 }, /* (143) alter_table_options ::= alter_table_options alter_table_option */ - { 196, -2 }, /* (144) alter_table_option ::= COMMENT NK_STRING */ - { 196, -2 }, /* (145) alter_table_option ::= KEEP NK_INTEGER */ - { 196, -2 }, /* (146) alter_table_option ::= TTL NK_INTEGER */ - { 192, -1 }, /* (147) col_name_list ::= col_name */ - { 192, -3 }, /* (148) col_name_list ::= col_name_list NK_COMMA col_name */ - { 197, -1 }, /* (149) col_name ::= column_name */ - { 163, -2 }, /* (150) cmd ::= SHOW DNODES */ - { 163, -2 }, /* (151) cmd ::= SHOW USERS */ - { 163, -2 }, /* (152) cmd ::= SHOW DATABASES */ - { 163, -4 }, /* (153) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 163, -4 }, /* (154) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 163, -3 }, /* (155) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 163, -2 }, /* (156) cmd ::= SHOW MNODES */ - { 163, -2 }, /* (157) cmd ::= SHOW MODULES */ - { 163, -2 }, /* (158) cmd ::= SHOW QNODES */ - { 163, -2 }, /* (159) cmd ::= SHOW FUNCTIONS */ - { 163, -5 }, /* (160) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 163, -2 }, /* (161) cmd ::= SHOW STREAMS */ - { 198, 0 }, /* (162) db_name_cond_opt ::= */ - { 198, -2 }, /* (163) db_name_cond_opt ::= db_name NK_DOT */ - { 199, 0 }, /* (164) like_pattern_opt ::= */ - { 199, -2 }, /* (165) like_pattern_opt ::= LIKE NK_STRING */ - { 200, -1 }, /* (166) table_name_cond ::= table_name */ - { 201, 0 }, /* (167) from_db_opt ::= */ - { 201, -2 }, /* (168) from_db_opt ::= FROM db_name */ - { 195, -1 }, /* (169) func_name_list ::= func_name */ - { 195, -3 }, /* (170) func_name_list ::= func_name_list NK_COMMA col_name */ - { 202, -1 }, /* (171) func_name ::= function_name */ - { 163, -8 }, /* (172) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 163, -10 }, /* (173) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 163, -6 }, /* (174) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 205, 0 }, /* (175) index_options ::= */ - { 205, -9 }, /* (176) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 205, -11 }, /* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 206, -1 }, /* (178) func_list ::= func */ - { 206, -3 }, /* (179) func_list ::= func_list NK_COMMA func */ - { 209, -4 }, /* (180) func ::= function_name NK_LP expression_list NK_RP */ - { 163, -6 }, /* (181) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 163, -6 }, /* (182) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 163, -4 }, /* (183) cmd ::= DROP TOPIC exists_opt topic_name */ - { 163, -1 }, /* (184) cmd ::= query_expression */ - { 166, -1 }, /* (185) literal ::= NK_INTEGER */ - { 166, -1 }, /* (186) literal ::= NK_FLOAT */ - { 166, -1 }, /* (187) literal ::= NK_STRING */ - { 166, -1 }, /* (188) literal ::= NK_BOOL */ - { 166, -2 }, /* (189) literal ::= TIMESTAMP NK_STRING */ - { 166, -1 }, /* (190) literal ::= duration_literal */ - { 207, -1 }, /* (191) duration_literal ::= NK_VARIABLE */ - { 213, -1 }, /* (192) signed ::= NK_INTEGER */ - { 213, -2 }, /* (193) signed ::= NK_PLUS NK_INTEGER */ - { 213, -2 }, /* (194) signed ::= NK_MINUS NK_INTEGER */ - { 213, -1 }, /* (195) signed ::= NK_FLOAT */ - { 213, -2 }, /* (196) signed ::= NK_PLUS NK_FLOAT */ - { 213, -2 }, /* (197) signed ::= NK_MINUS NK_FLOAT */ - { 214, -1 }, /* (198) signed_literal ::= signed */ - { 214, -1 }, /* (199) signed_literal ::= NK_STRING */ - { 214, -1 }, /* (200) signed_literal ::= NK_BOOL */ - { 214, -2 }, /* (201) signed_literal ::= TIMESTAMP NK_STRING */ - { 214, -1 }, /* (202) signed_literal ::= duration_literal */ - { 190, -1 }, /* (203) literal_list ::= signed_literal */ - { 190, -3 }, /* (204) literal_list ::= literal_list NK_COMMA signed_literal */ - { 172, -1 }, /* (205) db_name ::= NK_ID */ - { 193, -1 }, /* (206) table_name ::= NK_ID */ - { 186, -1 }, /* (207) column_name ::= NK_ID */ - { 203, -1 }, /* (208) function_name ::= NK_ID */ - { 215, -1 }, /* (209) table_alias ::= NK_ID */ - { 216, -1 }, /* (210) column_alias ::= NK_ID */ - { 168, -1 }, /* (211) user_name ::= NK_ID */ - { 204, -1 }, /* (212) index_name ::= NK_ID */ - { 211, -1 }, /* (213) topic_name ::= NK_ID */ - { 217, -1 }, /* (214) expression ::= literal */ - { 217, -1 }, /* (215) expression ::= column_reference */ - { 217, -4 }, /* (216) expression ::= function_name NK_LP expression_list NK_RP */ - { 217, -4 }, /* (217) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 217, -1 }, /* (218) expression ::= subquery */ - { 217, -3 }, /* (219) expression ::= NK_LP expression NK_RP */ - { 217, -2 }, /* (220) expression ::= NK_PLUS expression */ - { 217, -2 }, /* (221) expression ::= NK_MINUS expression */ - { 217, -3 }, /* (222) expression ::= expression NK_PLUS expression */ - { 217, -3 }, /* (223) expression ::= expression NK_MINUS expression */ - { 217, -3 }, /* (224) expression ::= expression NK_STAR expression */ - { 217, -3 }, /* (225) expression ::= expression NK_SLASH expression */ - { 217, -3 }, /* (226) expression ::= expression NK_REM expression */ - { 210, -1 }, /* (227) expression_list ::= expression */ - { 210, -3 }, /* (228) expression_list ::= expression_list NK_COMMA expression */ - { 218, -1 }, /* (229) column_reference ::= column_name */ - { 218, -3 }, /* (230) column_reference ::= table_name NK_DOT column_name */ - { 220, -3 }, /* (231) predicate ::= expression compare_op expression */ - { 220, -5 }, /* (232) predicate ::= expression BETWEEN expression AND expression */ - { 220, -6 }, /* (233) predicate ::= expression NOT BETWEEN expression AND expression */ - { 220, -3 }, /* (234) predicate ::= expression IS NULL */ - { 220, -4 }, /* (235) predicate ::= expression IS NOT NULL */ - { 220, -3 }, /* (236) predicate ::= expression in_op in_predicate_value */ - { 221, -1 }, /* (237) compare_op ::= NK_LT */ - { 221, -1 }, /* (238) compare_op ::= NK_GT */ - { 221, -1 }, /* (239) compare_op ::= NK_LE */ - { 221, -1 }, /* (240) compare_op ::= NK_GE */ - { 221, -1 }, /* (241) compare_op ::= NK_NE */ - { 221, -1 }, /* (242) compare_op ::= NK_EQ */ - { 221, -1 }, /* (243) compare_op ::= LIKE */ - { 221, -2 }, /* (244) compare_op ::= NOT LIKE */ - { 221, -1 }, /* (245) compare_op ::= MATCH */ - { 221, -1 }, /* (246) compare_op ::= NMATCH */ - { 222, -1 }, /* (247) in_op ::= IN */ - { 222, -2 }, /* (248) in_op ::= NOT IN */ - { 223, -3 }, /* (249) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 224, -1 }, /* (250) boolean_value_expression ::= boolean_primary */ - { 224, -2 }, /* (251) boolean_value_expression ::= NOT boolean_primary */ - { 224, -3 }, /* (252) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 224, -3 }, /* (253) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 225, -1 }, /* (254) boolean_primary ::= predicate */ - { 225, -3 }, /* (255) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 226, -1 }, /* (256) common_expression ::= expression */ - { 226, -1 }, /* (257) common_expression ::= boolean_value_expression */ - { 227, -2 }, /* (258) from_clause ::= FROM table_reference_list */ - { 228, -1 }, /* (259) table_reference_list ::= table_reference */ - { 228, -3 }, /* (260) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 229, -1 }, /* (261) table_reference ::= table_primary */ - { 229, -1 }, /* (262) table_reference ::= joined_table */ - { 230, -2 }, /* (263) table_primary ::= table_name alias_opt */ - { 230, -4 }, /* (264) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 230, -2 }, /* (265) table_primary ::= subquery alias_opt */ - { 230, -1 }, /* (266) table_primary ::= parenthesized_joined_table */ - { 232, 0 }, /* (267) alias_opt ::= */ - { 232, -1 }, /* (268) alias_opt ::= table_alias */ - { 232, -2 }, /* (269) alias_opt ::= AS table_alias */ - { 233, -3 }, /* (270) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 233, -3 }, /* (271) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 231, -6 }, /* (272) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 234, 0 }, /* (273) join_type ::= */ - { 234, -1 }, /* (274) join_type ::= INNER */ - { 236, -9 }, /* (275) 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 */ - { 237, 0 }, /* (276) set_quantifier_opt ::= */ - { 237, -1 }, /* (277) set_quantifier_opt ::= DISTINCT */ - { 237, -1 }, /* (278) set_quantifier_opt ::= ALL */ - { 238, -1 }, /* (279) select_list ::= NK_STAR */ - { 238, -1 }, /* (280) select_list ::= select_sublist */ - { 244, -1 }, /* (281) select_sublist ::= select_item */ - { 244, -3 }, /* (282) select_sublist ::= select_sublist NK_COMMA select_item */ - { 245, -1 }, /* (283) select_item ::= common_expression */ - { 245, -2 }, /* (284) select_item ::= common_expression column_alias */ - { 245, -3 }, /* (285) select_item ::= common_expression AS column_alias */ - { 245, -3 }, /* (286) select_item ::= table_name NK_DOT NK_STAR */ - { 239, 0 }, /* (287) where_clause_opt ::= */ - { 239, -2 }, /* (288) where_clause_opt ::= WHERE search_condition */ - { 240, 0 }, /* (289) partition_by_clause_opt ::= */ - { 240, -3 }, /* (290) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 241, 0 }, /* (291) twindow_clause_opt ::= */ - { 241, -6 }, /* (292) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 241, -4 }, /* (293) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 241, -6 }, /* (294) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 241, -8 }, /* (295) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 208, 0 }, /* (296) sliding_opt ::= */ - { 208, -4 }, /* (297) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 246, 0 }, /* (298) fill_opt ::= */ - { 246, -4 }, /* (299) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 246, -6 }, /* (300) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 247, -1 }, /* (301) fill_mode ::= NONE */ - { 247, -1 }, /* (302) fill_mode ::= PREV */ - { 247, -1 }, /* (303) fill_mode ::= NULL */ - { 247, -1 }, /* (304) fill_mode ::= LINEAR */ - { 247, -1 }, /* (305) fill_mode ::= NEXT */ - { 242, 0 }, /* (306) group_by_clause_opt ::= */ - { 242, -3 }, /* (307) group_by_clause_opt ::= GROUP BY group_by_list */ - { 248, -1 }, /* (308) group_by_list ::= expression */ - { 248, -3 }, /* (309) group_by_list ::= group_by_list NK_COMMA expression */ - { 243, 0 }, /* (310) having_clause_opt ::= */ - { 243, -2 }, /* (311) having_clause_opt ::= HAVING search_condition */ - { 212, -4 }, /* (312) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 249, -1 }, /* (313) query_expression_body ::= query_primary */ - { 249, -4 }, /* (314) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 253, -1 }, /* (315) query_primary ::= query_specification */ - { 250, 0 }, /* (316) order_by_clause_opt ::= */ - { 250, -3 }, /* (317) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 251, 0 }, /* (318) slimit_clause_opt ::= */ - { 251, -2 }, /* (319) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 251, -4 }, /* (320) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 251, -4 }, /* (321) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 252, 0 }, /* (322) limit_clause_opt ::= */ - { 252, -2 }, /* (323) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 252, -4 }, /* (324) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 252, -4 }, /* (325) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 219, -3 }, /* (326) subquery ::= NK_LP query_expression NK_RP */ - { 235, -1 }, /* (327) search_condition ::= common_expression */ - { 254, -1 }, /* (328) sort_specification_list ::= sort_specification */ - { 254, -3 }, /* (329) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 255, -3 }, /* (330) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 256, 0 }, /* (331) ordering_specification_opt ::= */ - { 256, -1 }, /* (332) ordering_specification_opt ::= ASC */ - { 256, -1 }, /* (333) ordering_specification_opt ::= DESC */ - { 257, 0 }, /* (334) null_ordering_opt ::= */ - { 257, -2 }, /* (335) null_ordering_opt ::= NULLS FIRST */ - { 257, -2 }, /* (336) null_ordering_opt ::= NULLS LAST */ + { 172, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 172, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 173, 0 }, /* (2) account_options ::= */ + { 173, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 173, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 173, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 173, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 173, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 173, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 173, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 173, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 173, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 174, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 174, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 176, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 176, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 176, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 176, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 176, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 176, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 176, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 176, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 176, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 176, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 172, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 172, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 172, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 172, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 172, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + { 172, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 172, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + { 172, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + { 172, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 172, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 172, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + { 172, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 178, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ + { 179, -1 }, /* (37) dnode_host_name ::= NK_ID */ + { 179, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ + { 172, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + { 172, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 172, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 172, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 172, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 172, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ + { 172, -2 }, /* (45) cmd ::= USE db_name */ + { 172, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 180, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ + { 180, 0 }, /* (48) not_exists_opt ::= */ + { 183, -2 }, /* (49) exists_opt ::= IF EXISTS */ + { 183, 0 }, /* (50) exists_opt ::= */ + { 182, 0 }, /* (51) db_options ::= */ + { 182, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ + { 182, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ + { 182, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ + { 182, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ + { 182, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ + { 182, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ + { 182, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ + { 182, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ + { 182, -3 }, /* (60) db_options ::= db_options KEEP NK_INTEGER */ + { 182, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ + { 182, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ + { 182, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ + { 182, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ + { 182, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ + { 182, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ + { 182, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 182, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 182, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ + { 184, -1 }, /* (70) alter_db_options ::= alter_db_option */ + { 184, -2 }, /* (71) alter_db_options ::= alter_db_options alter_db_option */ + { 185, -2 }, /* (72) alter_db_option ::= BLOCKS NK_INTEGER */ + { 185, -2 }, /* (73) alter_db_option ::= FSYNC NK_INTEGER */ + { 185, -2 }, /* (74) alter_db_option ::= KEEP NK_INTEGER */ + { 185, -2 }, /* (75) alter_db_option ::= WAL NK_INTEGER */ + { 185, -2 }, /* (76) alter_db_option ::= QUORUM NK_INTEGER */ + { 185, -2 }, /* (77) alter_db_option ::= CACHELAST NK_INTEGER */ + { 172, -9 }, /* (78) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 172, -3 }, /* (79) cmd ::= CREATE TABLE multi_create_clause */ + { 172, -9 }, /* (80) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 172, -3 }, /* (81) cmd ::= DROP TABLE multi_drop_clause */ + { 172, -4 }, /* (82) cmd ::= DROP STABLE exists_opt full_table_name */ + { 172, -3 }, /* (83) cmd ::= ALTER TABLE alter_table_clause */ + { 172, -3 }, /* (84) cmd ::= ALTER STABLE alter_table_clause */ + { 193, -2 }, /* (85) alter_table_clause ::= full_table_name alter_table_options */ + { 193, -5 }, /* (86) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 193, -4 }, /* (87) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 193, -5 }, /* (88) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 193, -5 }, /* (89) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 193, -5 }, /* (90) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 193, -4 }, /* (91) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 193, -5 }, /* (92) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 193, -5 }, /* (93) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 193, -6 }, /* (94) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 190, -1 }, /* (95) multi_create_clause ::= create_subtable_clause */ + { 190, -2 }, /* (96) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 197, -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 */ + { 192, -1 }, /* (98) multi_drop_clause ::= drop_table_clause */ + { 192, -2 }, /* (99) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 200, -2 }, /* (100) drop_table_clause ::= exists_opt full_table_name */ + { 198, 0 }, /* (101) specific_tags_opt ::= */ + { 198, -3 }, /* (102) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 186, -1 }, /* (103) full_table_name ::= table_name */ + { 186, -3 }, /* (104) full_table_name ::= db_name NK_DOT table_name */ + { 187, -1 }, /* (105) column_def_list ::= column_def */ + { 187, -3 }, /* (106) column_def_list ::= column_def_list NK_COMMA column_def */ + { 203, -2 }, /* (107) column_def ::= column_name type_name */ + { 203, -4 }, /* (108) column_def ::= column_name type_name COMMENT NK_STRING */ + { 196, -1 }, /* (109) type_name ::= BOOL */ + { 196, -1 }, /* (110) type_name ::= TINYINT */ + { 196, -1 }, /* (111) type_name ::= SMALLINT */ + { 196, -1 }, /* (112) type_name ::= INT */ + { 196, -1 }, /* (113) type_name ::= INTEGER */ + { 196, -1 }, /* (114) type_name ::= BIGINT */ + { 196, -1 }, /* (115) type_name ::= FLOAT */ + { 196, -1 }, /* (116) type_name ::= DOUBLE */ + { 196, -4 }, /* (117) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 196, -1 }, /* (118) type_name ::= TIMESTAMP */ + { 196, -4 }, /* (119) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 196, -2 }, /* (120) type_name ::= TINYINT UNSIGNED */ + { 196, -2 }, /* (121) type_name ::= SMALLINT UNSIGNED */ + { 196, -2 }, /* (122) type_name ::= INT UNSIGNED */ + { 196, -2 }, /* (123) type_name ::= BIGINT UNSIGNED */ + { 196, -1 }, /* (124) type_name ::= JSON */ + { 196, -4 }, /* (125) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 196, -1 }, /* (126) type_name ::= MEDIUMBLOB */ + { 196, -1 }, /* (127) type_name ::= BLOB */ + { 196, -4 }, /* (128) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 196, -1 }, /* (129) type_name ::= DECIMAL */ + { 196, -4 }, /* (130) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 196, -6 }, /* (131) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 188, 0 }, /* (132) tags_def_opt ::= */ + { 188, -1 }, /* (133) tags_def_opt ::= tags_def */ + { 191, -4 }, /* (134) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 189, 0 }, /* (135) table_options ::= */ + { 189, -3 }, /* (136) table_options ::= table_options COMMENT NK_STRING */ + { 189, -3 }, /* (137) table_options ::= table_options KEEP NK_INTEGER */ + { 189, -3 }, /* (138) table_options ::= table_options TTL NK_INTEGER */ + { 189, -5 }, /* (139) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 189, -5 }, /* (140) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 189, -3 }, /* (141) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 189, -3 }, /* (142) table_options ::= table_options DELAY NK_INTEGER */ + { 194, -1 }, /* (143) alter_table_options ::= alter_table_option */ + { 194, -2 }, /* (144) alter_table_options ::= alter_table_options alter_table_option */ + { 205, -2 }, /* (145) alter_table_option ::= COMMENT NK_STRING */ + { 205, -2 }, /* (146) alter_table_option ::= KEEP NK_INTEGER */ + { 205, -2 }, /* (147) alter_table_option ::= TTL NK_INTEGER */ + { 201, -1 }, /* (148) col_name_list ::= col_name */ + { 201, -3 }, /* (149) col_name_list ::= col_name_list NK_COMMA col_name */ + { 206, -1 }, /* (150) col_name ::= column_name */ + { 172, -2 }, /* (151) cmd ::= SHOW DNODES */ + { 172, -2 }, /* (152) cmd ::= SHOW USERS */ + { 172, -2 }, /* (153) cmd ::= SHOW DATABASES */ + { 172, -4 }, /* (154) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 172, -4 }, /* (155) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 172, -3 }, /* (156) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 172, -2 }, /* (157) cmd ::= SHOW MNODES */ + { 172, -2 }, /* (158) cmd ::= SHOW MODULES */ + { 172, -2 }, /* (159) cmd ::= SHOW QNODES */ + { 172, -2 }, /* (160) cmd ::= SHOW FUNCTIONS */ + { 172, -5 }, /* (161) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 172, -2 }, /* (162) cmd ::= SHOW STREAMS */ + { 207, 0 }, /* (163) db_name_cond_opt ::= */ + { 207, -2 }, /* (164) db_name_cond_opt ::= db_name NK_DOT */ + { 208, 0 }, /* (165) like_pattern_opt ::= */ + { 208, -2 }, /* (166) like_pattern_opt ::= LIKE NK_STRING */ + { 209, -1 }, /* (167) table_name_cond ::= table_name */ + { 210, 0 }, /* (168) from_db_opt ::= */ + { 210, -2 }, /* (169) from_db_opt ::= FROM db_name */ + { 204, -1 }, /* (170) func_name_list ::= func_name */ + { 204, -3 }, /* (171) func_name_list ::= func_name_list NK_COMMA col_name */ + { 211, -1 }, /* (172) func_name ::= function_name */ + { 172, -8 }, /* (173) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 172, -10 }, /* (174) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 172, -6 }, /* (175) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 214, 0 }, /* (176) index_options ::= */ + { 214, -9 }, /* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 214, -11 }, /* (178) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 215, -1 }, /* (179) func_list ::= func */ + { 215, -3 }, /* (180) func_list ::= func_list NK_COMMA func */ + { 218, -4 }, /* (181) func ::= function_name NK_LP expression_list NK_RP */ + { 172, -6 }, /* (182) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 172, -6 }, /* (183) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 172, -4 }, /* (184) cmd ::= DROP TOPIC exists_opt topic_name */ + { 172, -1 }, /* (185) cmd ::= query_expression */ + { 175, -1 }, /* (186) literal ::= NK_INTEGER */ + { 175, -1 }, /* (187) literal ::= NK_FLOAT */ + { 175, -1 }, /* (188) literal ::= NK_STRING */ + { 175, -1 }, /* (189) literal ::= NK_BOOL */ + { 175, -2 }, /* (190) literal ::= TIMESTAMP NK_STRING */ + { 175, -1 }, /* (191) literal ::= duration_literal */ + { 216, -1 }, /* (192) duration_literal ::= NK_VARIABLE */ + { 222, -1 }, /* (193) signed ::= NK_INTEGER */ + { 222, -2 }, /* (194) signed ::= NK_PLUS NK_INTEGER */ + { 222, -2 }, /* (195) signed ::= NK_MINUS NK_INTEGER */ + { 222, -1 }, /* (196) signed ::= NK_FLOAT */ + { 222, -2 }, /* (197) signed ::= NK_PLUS NK_FLOAT */ + { 222, -2 }, /* (198) signed ::= NK_MINUS NK_FLOAT */ + { 223, -1 }, /* (199) signed_literal ::= signed */ + { 223, -1 }, /* (200) signed_literal ::= NK_STRING */ + { 223, -1 }, /* (201) signed_literal ::= NK_BOOL */ + { 223, -2 }, /* (202) signed_literal ::= TIMESTAMP NK_STRING */ + { 223, -1 }, /* (203) signed_literal ::= duration_literal */ + { 199, -1 }, /* (204) literal_list ::= signed_literal */ + { 199, -3 }, /* (205) literal_list ::= literal_list NK_COMMA signed_literal */ + { 181, -1 }, /* (206) db_name ::= NK_ID */ + { 202, -1 }, /* (207) table_name ::= NK_ID */ + { 195, -1 }, /* (208) column_name ::= NK_ID */ + { 212, -1 }, /* (209) function_name ::= NK_ID */ + { 224, -1 }, /* (210) table_alias ::= NK_ID */ + { 225, -1 }, /* (211) column_alias ::= NK_ID */ + { 177, -1 }, /* (212) user_name ::= NK_ID */ + { 213, -1 }, /* (213) index_name ::= NK_ID */ + { 220, -1 }, /* (214) topic_name ::= NK_ID */ + { 226, -1 }, /* (215) expression ::= literal */ + { 226, -1 }, /* (216) expression ::= pseudo_column */ + { 226, -1 }, /* (217) expression ::= column_reference */ + { 226, -4 }, /* (218) expression ::= function_name NK_LP expression_list NK_RP */ + { 226, -4 }, /* (219) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 226, -1 }, /* (220) expression ::= subquery */ + { 226, -3 }, /* (221) expression ::= NK_LP expression NK_RP */ + { 226, -2 }, /* (222) expression ::= NK_PLUS expression */ + { 226, -2 }, /* (223) expression ::= NK_MINUS expression */ + { 226, -3 }, /* (224) expression ::= expression NK_PLUS expression */ + { 226, -3 }, /* (225) expression ::= expression NK_MINUS expression */ + { 226, -3 }, /* (226) expression ::= expression NK_STAR expression */ + { 226, -3 }, /* (227) expression ::= expression NK_SLASH expression */ + { 226, -3 }, /* (228) expression ::= expression NK_REM expression */ + { 219, -1 }, /* (229) expression_list ::= expression */ + { 219, -3 }, /* (230) expression_list ::= expression_list NK_COMMA expression */ + { 228, -1 }, /* (231) column_reference ::= column_name */ + { 228, -3 }, /* (232) column_reference ::= table_name NK_DOT column_name */ + { 227, -2 }, /* (233) pseudo_column ::= NK_UNDERLINE ROWTS */ + { 227, -1 }, /* (234) pseudo_column ::= TBNAME */ + { 227, -2 }, /* (235) pseudo_column ::= NK_UNDERLINE QSTARTTS */ + { 227, -2 }, /* (236) pseudo_column ::= NK_UNDERLINE QENDTS */ + { 227, -2 }, /* (237) pseudo_column ::= NK_UNDERLINE WSTARTTS */ + { 227, -2 }, /* (238) pseudo_column ::= NK_UNDERLINE WENDTS */ + { 227, -2 }, /* (239) pseudo_column ::= NK_UNDERLINE WDURATION */ + { 230, -3 }, /* (240) predicate ::= expression compare_op expression */ + { 230, -5 }, /* (241) predicate ::= expression BETWEEN expression AND expression */ + { 230, -6 }, /* (242) predicate ::= expression NOT BETWEEN expression AND expression */ + { 230, -3 }, /* (243) predicate ::= expression IS NULL */ + { 230, -4 }, /* (244) predicate ::= expression IS NOT NULL */ + { 230, -3 }, /* (245) predicate ::= expression in_op in_predicate_value */ + { 231, -1 }, /* (246) compare_op ::= NK_LT */ + { 231, -1 }, /* (247) compare_op ::= NK_GT */ + { 231, -1 }, /* (248) compare_op ::= NK_LE */ + { 231, -1 }, /* (249) compare_op ::= NK_GE */ + { 231, -1 }, /* (250) compare_op ::= NK_NE */ + { 231, -1 }, /* (251) compare_op ::= NK_EQ */ + { 231, -1 }, /* (252) compare_op ::= LIKE */ + { 231, -2 }, /* (253) compare_op ::= NOT LIKE */ + { 231, -1 }, /* (254) compare_op ::= MATCH */ + { 231, -1 }, /* (255) compare_op ::= NMATCH */ + { 232, -1 }, /* (256) in_op ::= IN */ + { 232, -2 }, /* (257) in_op ::= NOT IN */ + { 233, -3 }, /* (258) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 234, -1 }, /* (259) boolean_value_expression ::= boolean_primary */ + { 234, -2 }, /* (260) boolean_value_expression ::= NOT boolean_primary */ + { 234, -3 }, /* (261) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 234, -3 }, /* (262) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 235, -1 }, /* (263) boolean_primary ::= predicate */ + { 235, -3 }, /* (264) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 236, -1 }, /* (265) common_expression ::= expression */ + { 236, -1 }, /* (266) common_expression ::= boolean_value_expression */ + { 237, -2 }, /* (267) from_clause ::= FROM table_reference_list */ + { 238, -1 }, /* (268) table_reference_list ::= table_reference */ + { 238, -3 }, /* (269) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 239, -1 }, /* (270) table_reference ::= table_primary */ + { 239, -1 }, /* (271) table_reference ::= joined_table */ + { 240, -2 }, /* (272) table_primary ::= table_name alias_opt */ + { 240, -4 }, /* (273) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 240, -2 }, /* (274) table_primary ::= subquery alias_opt */ + { 240, -1 }, /* (275) table_primary ::= parenthesized_joined_table */ + { 242, 0 }, /* (276) alias_opt ::= */ + { 242, -1 }, /* (277) alias_opt ::= table_alias */ + { 242, -2 }, /* (278) alias_opt ::= AS table_alias */ + { 243, -3 }, /* (279) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 243, -3 }, /* (280) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 241, -6 }, /* (281) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 244, 0 }, /* (282) join_type ::= */ + { 244, -1 }, /* (283) join_type ::= INNER */ + { 246, -9 }, /* (284) 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 */ + { 247, 0 }, /* (285) set_quantifier_opt ::= */ + { 247, -1 }, /* (286) set_quantifier_opt ::= DISTINCT */ + { 247, -1 }, /* (287) set_quantifier_opt ::= ALL */ + { 248, -1 }, /* (288) select_list ::= NK_STAR */ + { 248, -1 }, /* (289) select_list ::= select_sublist */ + { 254, -1 }, /* (290) select_sublist ::= select_item */ + { 254, -3 }, /* (291) select_sublist ::= select_sublist NK_COMMA select_item */ + { 255, -1 }, /* (292) select_item ::= common_expression */ + { 255, -2 }, /* (293) select_item ::= common_expression column_alias */ + { 255, -3 }, /* (294) select_item ::= common_expression AS column_alias */ + { 255, -3 }, /* (295) select_item ::= table_name NK_DOT NK_STAR */ + { 249, 0 }, /* (296) where_clause_opt ::= */ + { 249, -2 }, /* (297) where_clause_opt ::= WHERE search_condition */ + { 250, 0 }, /* (298) partition_by_clause_opt ::= */ + { 250, -3 }, /* (299) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 251, 0 }, /* (300) twindow_clause_opt ::= */ + { 251, -6 }, /* (301) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 251, -4 }, /* (302) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 251, -6 }, /* (303) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 251, -8 }, /* (304) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 217, 0 }, /* (305) sliding_opt ::= */ + { 217, -4 }, /* (306) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 256, 0 }, /* (307) fill_opt ::= */ + { 256, -4 }, /* (308) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 256, -6 }, /* (309) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 257, -1 }, /* (310) fill_mode ::= NONE */ + { 257, -1 }, /* (311) fill_mode ::= PREV */ + { 257, -1 }, /* (312) fill_mode ::= NULL */ + { 257, -1 }, /* (313) fill_mode ::= LINEAR */ + { 257, -1 }, /* (314) fill_mode ::= NEXT */ + { 252, 0 }, /* (315) group_by_clause_opt ::= */ + { 252, -3 }, /* (316) group_by_clause_opt ::= GROUP BY group_by_list */ + { 258, -1 }, /* (317) group_by_list ::= expression */ + { 258, -3 }, /* (318) group_by_list ::= group_by_list NK_COMMA expression */ + { 253, 0 }, /* (319) having_clause_opt ::= */ + { 253, -2 }, /* (320) having_clause_opt ::= HAVING search_condition */ + { 221, -4 }, /* (321) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 259, -1 }, /* (322) query_expression_body ::= query_primary */ + { 259, -4 }, /* (323) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 263, -1 }, /* (324) query_primary ::= query_specification */ + { 260, 0 }, /* (325) order_by_clause_opt ::= */ + { 260, -3 }, /* (326) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 261, 0 }, /* (327) slimit_clause_opt ::= */ + { 261, -2 }, /* (328) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 261, -4 }, /* (329) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 261, -4 }, /* (330) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 262, 0 }, /* (331) limit_clause_opt ::= */ + { 262, -2 }, /* (332) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 262, -4 }, /* (333) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 262, -4 }, /* (334) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 229, -3 }, /* (335) subquery ::= NK_LP query_expression NK_RP */ + { 245, -1 }, /* (336) search_condition ::= common_expression */ + { 264, -1 }, /* (337) sort_specification_list ::= sort_specification */ + { 264, -3 }, /* (338) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 265, -3 }, /* (339) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 266, 0 }, /* (340) ordering_specification_opt ::= */ + { 266, -1 }, /* (341) ordering_specification_opt ::= ASC */ + { 266, -1 }, /* (342) ordering_specification_opt ::= DESC */ + { 267, 0 }, /* (343) null_ordering_opt ::= */ + { 267, -2 }, /* (344) null_ordering_opt ::= NULLS FIRST */ + { 267, -2 }, /* (345) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2296,11 +2335,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,164,&yymsp[0].minor); + yy_destructor(yypParser,173,&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,165,&yymsp[0].minor); + yy_destructor(yypParser,174,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -2314,20 +2353,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,164,&yymsp[-2].minor); +{ yy_destructor(yypParser,173,&yymsp[-2].minor); { } - yy_destructor(yypParser,166,&yymsp[0].minor); + yy_destructor(yypParser,175,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,167,&yymsp[0].minor); +{ yy_destructor(yypParser,176,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,165,&yymsp[-1].minor); +{ yy_destructor(yypParser,174,&yymsp[-1].minor); { } - yy_destructor(yypParser,167,&yymsp[0].minor); + yy_destructor(yypParser,176,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -2341,31 +2380,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,166,&yymsp[0].minor); + yy_destructor(yypParser,175,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy149, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy225, 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.yy149, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy225, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy225); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy149, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy225, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy225, &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.yy149); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy225); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -2382,17 +2421,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 205: /* db_name ::= NK_ID */ yytestcase(yyruleno==205); - case 206: /* table_name ::= NK_ID */ yytestcase(yyruleno==206); - case 207: /* column_name ::= NK_ID */ yytestcase(yyruleno==207); - case 208: /* function_name ::= NK_ID */ yytestcase(yyruleno==208); - case 209: /* table_alias ::= NK_ID */ yytestcase(yyruleno==209); - case 210: /* column_alias ::= NK_ID */ yytestcase(yyruleno==210); - case 211: /* user_name ::= NK_ID */ yytestcase(yyruleno==211); - case 212: /* index_name ::= NK_ID */ yytestcase(yyruleno==212); - case 213: /* topic_name ::= NK_ID */ yytestcase(yyruleno==213); -{ yylhsminor.yy149 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy149 = yylhsminor.yy149; + case 206: /* db_name ::= NK_ID */ yytestcase(yyruleno==206); + case 207: /* table_name ::= NK_ID */ yytestcase(yyruleno==207); + case 208: /* column_name ::= NK_ID */ yytestcase(yyruleno==208); + case 209: /* function_name ::= NK_ID */ yytestcase(yyruleno==209); + case 210: /* table_alias ::= NK_ID */ yytestcase(yyruleno==210); + case 211: /* column_alias ::= NK_ID */ yytestcase(yyruleno==211); + case 212: /* user_name ::= NK_ID */ yytestcase(yyruleno==212); + case 213: /* index_name ::= NK_ID */ yytestcase(yyruleno==213); + case 214: /* topic_name ::= NK_ID */ yytestcase(yyruleno==214); +{ yylhsminor.yy225 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy225 = yylhsminor.yy225; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -2407,922 +2446,944 @@ 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.yy497, &yymsp[-1].minor.yy149, yymsp[0].minor.yy140); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy505, &yymsp[-1].minor.yy225, yymsp[0].minor.yy176); } break; case 44: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy505, &yymsp[0].minor.yy225); } break; case 45: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy225); } break; case 46: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy149, yymsp[0].minor.yy140); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy176); } break; case 47: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy497 = true; } +{ yymsp[-2].minor.yy505 = true; } break; case 48: /* not_exists_opt ::= */ case 50: /* exists_opt ::= */ yytestcase(yyruleno==50); - case 276: /* set_quantifier_opt ::= */ yytestcase(yyruleno==276); -{ yymsp[1].minor.yy497 = false; } + case 285: /* set_quantifier_opt ::= */ yytestcase(yyruleno==285); +{ yymsp[1].minor.yy505 = false; } break; case 49: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy497 = true; } +{ yymsp[-1].minor.yy505 = true; } break; case 51: /* db_options ::= */ -{ yymsp[1].minor.yy140 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy176 = createDefaultDatabaseOptions(pCxt); } break; case 52: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 53: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 54: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 55: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 56: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 57: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 58: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 59: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 60: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 61: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 62: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 63: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 64: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 65: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 66: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 67: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 68: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; case 69: /* db_options ::= db_options RETENTIONS NK_STRING */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-2].minor.yy176, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 70: /* db_options ::= db_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-2].minor.yy140, DB_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 70: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy176 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy176 = setDatabaseOption(pCxt, yylhsminor.yy176, yymsp[0].minor.yy325.type, &yymsp[0].minor.yy325.val); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 71: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy140 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy140 = setDatabaseOption(pCxt, yylhsminor.yy140, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 71: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy176 = setDatabaseOption(pCxt, yymsp[-1].minor.yy176, yymsp[0].minor.yy325.type, &yymsp[0].minor.yy325.val); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 72: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy140 = setDatabaseOption(pCxt, yymsp[-1].minor.yy140, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 72: /* alter_db_option ::= BLOCKS NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 73: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 73: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } + break; + case 74: /* alter_db_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_KEEP; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } + break; + case 75: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_WAL; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 74: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } - break; - case 75: /* alter_db_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_KEEP; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } - break; - case 76: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_WAL; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 76: /* alter_db_option ::= QUORUM NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 77: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 77: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy325.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.yy505, yymsp[-5].minor.yy176, yymsp[-3].minor.yy512, yymsp[-1].minor.yy512, yymsp[0].minor.yy176); } + break; + case 79: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy512); } + break; + case 81: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy512); } + break; + case 82: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy505, yymsp[0].minor.yy176); } + break; + case 83: /* cmd ::= ALTER TABLE alter_table_clause */ + case 84: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==84); + case 185: /* cmd ::= query_expression */ yytestcase(yyruleno==185); +{ pCxt->pRootNode = yymsp[0].minor.yy176; } + break; + case 85: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy176 = createAlterTableOption(pCxt, yymsp[-1].minor.yy176, yymsp[0].minor.yy176); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; + break; + case 86: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy176 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; + break; + case 87: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy176 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy176, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy225); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; + break; + case 88: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy176 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; + break; + case 89: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy176 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 78: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } - break; - case 79: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 81: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==81); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy497, yymsp[-5].minor.yy140, yymsp[-3].minor.yy136, yymsp[-1].minor.yy136, yymsp[0].minor.yy140); } - break; - case 80: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy136); } - break; - case 82: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy136); } - break; - case 83: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy140); } - break; - case 84: /* cmd ::= ALTER TABLE alter_table_clause */ - case 85: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==85); - case 184: /* cmd ::= query_expression */ yytestcase(yyruleno==184); -{ pCxt->pRootNode = yymsp[0].minor.yy140; } - break; - case 86: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy140 = createAlterTableOption(pCxt, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; - break; - case 87: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy149, yymsp[0].minor.yy256); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; - break; - case 88: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy140 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy140, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; - break; - case 89: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy149, yymsp[0].minor.yy256); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; - break; - case 90: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy140 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 90: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy176 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 91: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy149, yymsp[0].minor.yy256); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 91: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy176 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy176, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy225); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 92: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy140 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy140, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 92: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy176 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 93: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy149, yymsp[0].minor.yy256); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 93: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy176 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy176, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 94: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy140 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 94: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ +{ yylhsminor.yy176 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy176, &yymsp[-2].minor.yy225, yymsp[0].minor.yy176); } + yymsp[-5].minor.yy176 = yylhsminor.yy176; break; - case 95: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy140 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy140, &yymsp[-2].minor.yy149, yymsp[0].minor.yy140); } - yymsp[-5].minor.yy140 = yylhsminor.yy140; + 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 204: /* literal_list ::= signed_literal */ yytestcase(yyruleno==204); + case 290: /* select_sublist ::= select_item */ yytestcase(yyruleno==290); + case 337: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==337); +{ yylhsminor.yy512 = createNodeList(pCxt, yymsp[0].minor.yy176); } + yymsp[0].minor.yy512 = yylhsminor.yy512; break; - case 96: /* multi_create_clause ::= create_subtable_clause */ - case 99: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==99); - case 106: /* column_def_list ::= column_def */ yytestcase(yyruleno==106); - case 147: /* col_name_list ::= col_name */ yytestcase(yyruleno==147); - case 169: /* func_name_list ::= func_name */ yytestcase(yyruleno==169); - case 178: /* func_list ::= func */ yytestcase(yyruleno==178); - case 203: /* literal_list ::= signed_literal */ yytestcase(yyruleno==203); - case 281: /* select_sublist ::= select_item */ yytestcase(yyruleno==281); - case 328: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==328); -{ yylhsminor.yy136 = createNodeList(pCxt, yymsp[0].minor.yy140); } - yymsp[0].minor.yy136 = yylhsminor.yy136; + 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.yy512 = addNodeToList(pCxt, yymsp[-1].minor.yy512, yymsp[0].minor.yy176); } + yymsp[-1].minor.yy512 = yylhsminor.yy512; break; - case 97: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 100: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==100); -{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-1].minor.yy136, yymsp[0].minor.yy140); } - yymsp[-1].minor.yy136 = yylhsminor.yy136; + 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.yy176 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy505, yymsp[-7].minor.yy176, yymsp[-5].minor.yy176, yymsp[-4].minor.yy512, yymsp[-1].minor.yy512); } + yymsp[-8].minor.yy176 = yylhsminor.yy176; break; - case 98: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy140 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy497, yymsp[-7].minor.yy140, yymsp[-5].minor.yy140, yymsp[-4].minor.yy136, yymsp[-1].minor.yy136); } - yymsp[-8].minor.yy140 = yylhsminor.yy140; + case 100: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy176 = createDropTableClause(pCxt, yymsp[-1].minor.yy505, yymsp[0].minor.yy176); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 101: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy140 = createDropTableClause(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy140); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 101: /* specific_tags_opt ::= */ + case 132: /* tags_def_opt ::= */ yytestcase(yyruleno==132); + case 298: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==298); + case 315: /* group_by_clause_opt ::= */ yytestcase(yyruleno==315); + case 325: /* order_by_clause_opt ::= */ yytestcase(yyruleno==325); +{ yymsp[1].minor.yy512 = NULL; } break; - case 102: /* specific_tags_opt ::= */ - case 133: /* tags_def_opt ::= */ yytestcase(yyruleno==133); - case 289: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==289); - case 306: /* group_by_clause_opt ::= */ yytestcase(yyruleno==306); - case 316: /* order_by_clause_opt ::= */ yytestcase(yyruleno==316); -{ yymsp[1].minor.yy136 = NULL; } + case 102: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy512 = yymsp[-1].minor.yy512; } break; - case 103: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy136 = yymsp[-1].minor.yy136; } + case 103: /* full_table_name ::= table_name */ +{ yylhsminor.yy176 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy225, NULL); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 104: /* full_table_name ::= table_name */ -{ yylhsminor.yy140 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy149, NULL); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 104: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy176 = createRealTableNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225, NULL); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 105: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy140 = createRealTableNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149, NULL); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + 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 205: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==205); + case 291: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==291); + case 338: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==338); +{ yylhsminor.yy512 = addNodeToList(pCxt, yymsp[-2].minor.yy512, yymsp[0].minor.yy176); } + yymsp[-2].minor.yy512 = yylhsminor.yy512; break; - case 107: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 148: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==148); - case 170: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==170); - case 179: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==179); - case 204: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==204); - case 282: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==282); - case 329: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==329); -{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, yymsp[0].minor.yy140); } - yymsp[-2].minor.yy136 = yylhsminor.yy136; + case 107: /* column_def ::= column_name type_name */ +{ yylhsminor.yy176 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448, NULL); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 108: /* column_def ::= column_name type_name */ -{ yylhsminor.yy140 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy149, yymsp[0].minor.yy256, NULL); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 108: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy176 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-2].minor.yy448, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 109: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy140 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-2].minor.yy256, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 109: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 110: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 110: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 111: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 111: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 112: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 112: /* type_name ::= INT */ + case 113: /* type_name ::= INTEGER */ yytestcase(yyruleno==113); +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 113: /* type_name ::= INT */ - case 114: /* type_name ::= INTEGER */ yytestcase(yyruleno==114); -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_INT); } + case 114: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 115: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 115: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 116: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 116: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 117: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 117: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 118: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 118: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 119: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 119: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 120: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 120: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 121: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 121: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 122: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 122: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 123: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UINT); } + case 123: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 124: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 124: /* type_name ::= JSON */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 125: /* type_name ::= JSON */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_JSON); } + case 125: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 126: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 126: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 127: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 127: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 128: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 128: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 129: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 129: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 130: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 130: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 131: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 131: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 132: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 133: /* tags_def_opt ::= tags_def */ + case 289: /* select_list ::= select_sublist */ yytestcase(yyruleno==289); +{ yylhsminor.yy512 = yymsp[0].minor.yy512; } + yymsp[0].minor.yy512 = yylhsminor.yy512; break; - case 134: /* tags_def_opt ::= tags_def */ - case 280: /* select_list ::= select_sublist */ yytestcase(yyruleno==280); -{ yylhsminor.yy136 = yymsp[0].minor.yy136; } - yymsp[0].minor.yy136 = yylhsminor.yy136; + case 134: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy512 = yymsp[-1].minor.yy512; } break; - case 135: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy136 = yymsp[-1].minor.yy136; } + case 135: /* table_options ::= */ +{ yymsp[1].minor.yy176 = createDefaultTableOptions(pCxt); } break; - case 136: /* table_options ::= */ -{ yymsp[1].minor.yy140 = createDefaultTableOptions(pCxt); } + case 136: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-2].minor.yy176, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 137: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy140 = setTableOption(pCxt, yymsp[-2].minor.yy140, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 137: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-2].minor.yy176, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 138: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy140 = setTableOption(pCxt, yymsp[-2].minor.yy140, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 138: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-2].minor.yy176, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 139: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy140 = setTableOption(pCxt, yymsp[-2].minor.yy140, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 139: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy176 = setTableSmaOption(pCxt, yymsp[-4].minor.yy176, yymsp[-1].minor.yy512); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 140: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy140 = setTableSmaOption(pCxt, yymsp[-4].minor.yy140, yymsp[-1].minor.yy136); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 140: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy176 = setTableRollupOption(pCxt, yymsp[-4].minor.yy176, yymsp[-1].minor.yy512); } + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 141: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy140 = setTableRollupOption(pCxt, yymsp[-4].minor.yy140, yymsp[-1].minor.yy136); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + case 141: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-2].minor.yy176, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 142: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy140 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy140 = setTableOption(pCxt, yylhsminor.yy140, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 142: /* table_options ::= table_options DELAY NK_INTEGER */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-2].minor.yy176, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 143: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy140 = setTableOption(pCxt, yymsp[-1].minor.yy140, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 143: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy176 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy176 = setTableOption(pCxt, yylhsminor.yy176, yymsp[0].minor.yy325.type, &yymsp[0].minor.yy325.val); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 144: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy233.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 144: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy176 = setTableOption(pCxt, yymsp[-1].minor.yy176, yymsp[0].minor.yy325.type, &yymsp[0].minor.yy325.val); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 145: /* alter_table_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 145: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy325.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 146: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 146: /* alter_table_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 149: /* col_name ::= column_name */ -{ yylhsminor.yy140 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy149); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 147: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy325.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy325.val = yymsp[0].minor.yy0; } break; - case 150: /* cmd ::= SHOW DNODES */ + case 150: /* col_name ::= column_name */ +{ yylhsminor.yy176 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy225); } + yymsp[0].minor.yy176 = yylhsminor.yy176; + break; + case 151: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } break; - case 151: /* cmd ::= SHOW USERS */ + case 152: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); } break; - case 152: /* cmd ::= SHOW DATABASES */ + case 153: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; - case 153: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } + case 154: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy176, yymsp[0].minor.yy176); } break; - case 154: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } + case 155: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy176, yymsp[0].minor.yy176); } break; - case 155: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy140, NULL); } + case 156: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy176, NULL); } break; - case 156: /* cmd ::= SHOW MNODES */ + case 157: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } break; - case 157: /* cmd ::= SHOW MODULES */ + case 158: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); } break; - case 158: /* cmd ::= SHOW QNODES */ + case 159: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); } break; - case 159: /* cmd ::= SHOW FUNCTIONS */ + case 160: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; - case 160: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } + case 161: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy176, yymsp[0].minor.yy176); } break; - case 161: /* cmd ::= SHOW STREAMS */ + case 162: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; - case 162: /* db_name_cond_opt ::= */ - case 167: /* from_db_opt ::= */ yytestcase(yyruleno==167); -{ yymsp[1].minor.yy140 = createDefaultDatabaseCondValue(pCxt); } + case 163: /* db_name_cond_opt ::= */ + case 168: /* from_db_opt ::= */ yytestcase(yyruleno==168); +{ yymsp[1].minor.yy176 = createDefaultDatabaseCondValue(pCxt); } break; - case 163: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy149); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 164: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy225); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 164: /* like_pattern_opt ::= */ - case 175: /* index_options ::= */ yytestcase(yyruleno==175); - case 287: /* where_clause_opt ::= */ yytestcase(yyruleno==287); - case 291: /* twindow_clause_opt ::= */ yytestcase(yyruleno==291); - case 296: /* sliding_opt ::= */ yytestcase(yyruleno==296); - case 298: /* fill_opt ::= */ yytestcase(yyruleno==298); - case 310: /* having_clause_opt ::= */ yytestcase(yyruleno==310); - case 318: /* slimit_clause_opt ::= */ yytestcase(yyruleno==318); - case 322: /* limit_clause_opt ::= */ yytestcase(yyruleno==322); -{ yymsp[1].minor.yy140 = NULL; } + case 165: /* like_pattern_opt ::= */ + case 176: /* index_options ::= */ yytestcase(yyruleno==176); + case 296: /* where_clause_opt ::= */ yytestcase(yyruleno==296); + case 300: /* twindow_clause_opt ::= */ yytestcase(yyruleno==300); + case 305: /* sliding_opt ::= */ yytestcase(yyruleno==305); + case 307: /* fill_opt ::= */ yytestcase(yyruleno==307); + case 319: /* having_clause_opt ::= */ yytestcase(yyruleno==319); + case 327: /* slimit_clause_opt ::= */ yytestcase(yyruleno==327); + case 331: /* limit_clause_opt ::= */ yytestcase(yyruleno==331); +{ yymsp[1].minor.yy176 = NULL; } break; - case 165: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 166: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 166: /* table_name_cond ::= table_name */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy149); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 167: /* table_name_cond ::= table_name */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy225); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 168: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy149); } + case 169: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy225); } break; - case 171: /* func_name ::= function_name */ -{ yylhsminor.yy140 = createFunctionNode(pCxt, &yymsp[0].minor.yy149, NULL); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 172: /* func_name ::= function_name */ +{ yylhsminor.yy176 = createFunctionNode(pCxt, &yymsp[0].minor.yy225, NULL); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 172: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy497, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy149, NULL, yymsp[0].minor.yy140); } + 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.yy505, &yymsp[-3].minor.yy225, &yymsp[-1].minor.yy225, NULL, yymsp[0].minor.yy176); } break; - case 173: /* 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.yy497, &yymsp[-5].minor.yy149, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy136, NULL); } + 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.yy505, &yymsp[-5].minor.yy225, &yymsp[-3].minor.yy225, yymsp[-1].minor.yy512, NULL); } break; - case 174: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); } + case 175: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy505, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225); } break; - case 176: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy140 = createIndexOption(pCxt, yymsp[-6].minor.yy136, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), NULL, yymsp[0].minor.yy140); } + case 177: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy176 = createIndexOption(pCxt, yymsp[-6].minor.yy512, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), NULL, yymsp[0].minor.yy176); } break; - case 177: /* 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.yy140 = createIndexOption(pCxt, yymsp[-8].minor.yy136, releaseRawExprNode(pCxt, yymsp[-4].minor.yy140), releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), yymsp[0].minor.yy140); } + 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.yy176 = createIndexOption(pCxt, yymsp[-8].minor.yy512, releaseRawExprNode(pCxt, yymsp[-4].minor.yy176), releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), yymsp[0].minor.yy176); } break; - case 180: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy140 = createFunctionNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy136); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 181: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy176 = createFunctionNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-1].minor.yy512); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 181: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, yymsp[0].minor.yy140, NULL); } + case 182: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy505, &yymsp[-2].minor.yy225, yymsp[0].minor.yy176, NULL); } break; - case 182: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, NULL, &yymsp[0].minor.yy149); } + case 183: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy505, &yymsp[-2].minor.yy225, NULL, &yymsp[0].minor.yy225); } break; - case 183: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } + case 184: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy505, &yymsp[0].minor.yy225); } break; - case 185: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 186: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 186: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 187: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 187: /* literal ::= NK_STRING */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 188: /* literal ::= NK_STRING */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 188: /* literal ::= NK_BOOL */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 189: /* literal ::= NK_BOOL */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 189: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 190: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 190: /* literal ::= duration_literal */ - case 198: /* signed_literal ::= signed */ yytestcase(yyruleno==198); - case 214: /* expression ::= literal */ yytestcase(yyruleno==214); - case 215: /* expression ::= column_reference */ yytestcase(yyruleno==215); - case 218: /* expression ::= subquery */ yytestcase(yyruleno==218); - case 250: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==250); - case 254: /* boolean_primary ::= predicate */ yytestcase(yyruleno==254); - case 256: /* common_expression ::= expression */ yytestcase(yyruleno==256); - case 257: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==257); - case 259: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==259); - case 261: /* table_reference ::= table_primary */ yytestcase(yyruleno==261); - case 262: /* table_reference ::= joined_table */ yytestcase(yyruleno==262); - case 266: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==266); - case 313: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==313); - case 315: /* query_primary ::= query_specification */ yytestcase(yyruleno==315); -{ yylhsminor.yy140 = yymsp[0].minor.yy140; } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 191: /* literal ::= duration_literal */ + case 199: /* signed_literal ::= signed */ yytestcase(yyruleno==199); + case 215: /* expression ::= literal */ yytestcase(yyruleno==215); + case 216: /* expression ::= pseudo_column */ yytestcase(yyruleno==216); + case 217: /* expression ::= column_reference */ yytestcase(yyruleno==217); + case 220: /* expression ::= subquery */ yytestcase(yyruleno==220); + case 259: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==259); + case 263: /* boolean_primary ::= predicate */ yytestcase(yyruleno==263); + case 265: /* common_expression ::= expression */ yytestcase(yyruleno==265); + case 266: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==266); + case 268: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==268); + case 270: /* table_reference ::= table_primary */ yytestcase(yyruleno==270); + case 271: /* table_reference ::= joined_table */ yytestcase(yyruleno==271); + case 275: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==275); + case 322: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==322); + case 324: /* query_primary ::= query_specification */ yytestcase(yyruleno==324); +{ yylhsminor.yy176 = yymsp[0].minor.yy176; } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 191: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 192: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 192: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 193: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 193: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 194: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 194: /* signed ::= NK_MINUS NK_INTEGER */ + case 195: /* 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.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 195: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 196: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 196: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 197: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 197: /* signed ::= NK_MINUS NK_FLOAT */ + case 198: /* 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.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 199: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 200: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 200: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 201: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 201: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 202: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy176 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 202: /* signed_literal ::= duration_literal */ - case 327: /* search_condition ::= common_expression */ yytestcase(yyruleno==327); -{ yylhsminor.yy140 = releaseRawExprNode(pCxt, yymsp[0].minor.yy140); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 203: /* signed_literal ::= duration_literal */ + case 336: /* search_condition ::= common_expression */ yytestcase(yyruleno==336); +{ yylhsminor.yy176 = releaseRawExprNode(pCxt, yymsp[0].minor.yy176); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 216: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy149, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy136)); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 218: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy225, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-1].minor.yy512)); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 217: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy149, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy149, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 219: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy225, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy225, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 219: /* expression ::= NK_LP expression NK_RP */ - case 255: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==255); -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 221: /* expression ::= NK_LP expression NK_RP */ + case 264: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==264); +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy176)); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 220: /* expression ::= NK_PLUS expression */ + case 222: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy176)); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 221: /* expression ::= NK_MINUS expression */ + case 223: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy140), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy176), NULL)); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 222: /* expression ::= expression NK_PLUS expression */ + case 224: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 223: /* expression ::= expression NK_MINUS expression */ + case 225: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 224: /* expression ::= expression NK_STAR expression */ + case 226: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 225: /* expression ::= expression NK_SLASH expression */ + case 227: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 226: /* expression ::= expression NK_REM expression */ + case 228: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 227: /* expression_list ::= expression */ -{ yylhsminor.yy136 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); } - yymsp[0].minor.yy136 = yylhsminor.yy136; + case 229: /* expression_list ::= expression */ +{ yylhsminor.yy512 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy176)); } + yymsp[0].minor.yy512 = yylhsminor.yy512; break; - case 228: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); } - yymsp[-2].minor.yy136 = yylhsminor.yy136; + case 230: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy512 = addNodeToList(pCxt, yymsp[-2].minor.yy512, releaseRawExprNode(pCxt, yymsp[0].minor.yy176)); } + yymsp[-2].minor.yy512 = yylhsminor.yy512; break; - case 229: /* column_reference ::= column_name */ -{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy149, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy149)); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + case 231: /* column_reference ::= column_name */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy225, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy225)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 230: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149, createColumnNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149)); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 232: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225, createColumnNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225)); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 231: /* predicate ::= expression compare_op expression */ - case 236: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==236); + case 233: /* pseudo_column ::= NK_UNDERLINE ROWTS */ + case 235: /* pseudo_column ::= NK_UNDERLINE QSTARTTS */ yytestcase(yyruleno==235); + case 236: /* pseudo_column ::= NK_UNDERLINE QENDTS */ yytestcase(yyruleno==236); + case 237: /* pseudo_column ::= NK_UNDERLINE WSTARTTS */ yytestcase(yyruleno==237); + case 238: /* pseudo_column ::= NK_UNDERLINE WENDTS */ yytestcase(yyruleno==238); + case 239: /* pseudo_column ::= NK_UNDERLINE WDURATION */ yytestcase(yyruleno==239); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy320, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy176 = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 232: /* predicate ::= expression BETWEEN expression AND expression */ + case 234: /* pseudo_column ::= TBNAME */ +{ yylhsminor.yy176 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy176 = yylhsminor.yy176; + break; + case 240: /* predicate ::= expression compare_op expression */ + case 245: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==245); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy140), releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy404, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-4].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 233: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 241: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[-5].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy176), releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-5].minor.yy140 = yylhsminor.yy140; + yymsp[-4].minor.yy176 = yylhsminor.yy176; break; - case 234: /* predicate ::= expression IS NULL */ + case 242: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[-5].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-5].minor.yy176 = yylhsminor.yy176; break; - case 235: /* predicate ::= expression IS NOT NULL */ + case 243: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), NULL)); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 237: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy320 = OP_TYPE_LOWER_THAN; } - break; - case 238: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy320 = OP_TYPE_GREATER_THAN; } - break; - case 239: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy320 = OP_TYPE_LOWER_EQUAL; } - break; - case 240: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy320 = OP_TYPE_GREATER_EQUAL; } - break; - case 241: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy320 = OP_TYPE_NOT_EQUAL; } - break; - case 242: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy320 = OP_TYPE_EQUAL; } - break; - case 243: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy320 = OP_TYPE_LIKE; } - break; - case 244: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy320 = OP_TYPE_NOT_LIKE; } - break; - case 245: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy320 = OP_TYPE_MATCH; } - break; - case 246: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy320 = OP_TYPE_NMATCH; } - break; - case 247: /* in_op ::= IN */ -{ yymsp[0].minor.yy320 = OP_TYPE_IN; } - break; - case 248: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy320 = OP_TYPE_NOT_IN; } - break; - case 249: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy136)); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; - break; - case 251: /* boolean_value_expression ::= NOT boolean_primary */ + case 244: /* predicate ::= expression IS NOT NULL */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy140), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy176), NULL)); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 252: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 246: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy404 = OP_TYPE_LOWER_THAN; } + break; + case 247: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy404 = OP_TYPE_GREATER_THAN; } + break; + case 248: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy404 = OP_TYPE_LOWER_EQUAL; } + break; + case 249: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy404 = OP_TYPE_GREATER_EQUAL; } + break; + case 250: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy404 = OP_TYPE_NOT_EQUAL; } + break; + case 251: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy404 = OP_TYPE_EQUAL; } + break; + case 252: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy404 = OP_TYPE_LIKE; } + break; + case 253: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy404 = OP_TYPE_NOT_LIKE; } + break; + case 254: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy404 = OP_TYPE_MATCH; } + break; + case 255: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy404 = OP_TYPE_NMATCH; } + break; + case 256: /* in_op ::= IN */ +{ yymsp[0].minor.yy404 = OP_TYPE_IN; } + break; + case 257: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy404 = OP_TYPE_NOT_IN; } + break; + case 258: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy512)); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; + break; + case 260: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy176), NULL)); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 253: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 261: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 258: /* from_clause ::= FROM table_reference_list */ - case 288: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==288); - case 311: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==311); -{ yymsp[-1].minor.yy140 = yymsp[0].minor.yy140; } + case 262: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy176); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); + } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 260: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy140 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy140, yymsp[0].minor.yy140, NULL); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 267: /* from_clause ::= FROM table_reference_list */ + case 297: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==297); + case 320: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==320); +{ yymsp[-1].minor.yy176 = yymsp[0].minor.yy176; } break; - case 263: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy140 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 269: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy176 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy176, yymsp[0].minor.yy176, NULL); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 264: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy140 = createRealTableNode(pCxt, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 272: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy176 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 265: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy140 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140), &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 273: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy176 = createRealTableNode(pCxt, &yymsp[-3].minor.yy225, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 267: /* alias_opt ::= */ -{ yymsp[1].minor.yy149 = nil_token; } + case 274: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy176 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy176), &yymsp[0].minor.yy225); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 268: /* alias_opt ::= table_alias */ -{ yylhsminor.yy149 = yymsp[0].minor.yy149; } - yymsp[0].minor.yy149 = yylhsminor.yy149; + case 276: /* alias_opt ::= */ +{ yymsp[1].minor.yy225 = nil_token; } break; - case 269: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy149 = yymsp[0].minor.yy149; } + case 277: /* alias_opt ::= table_alias */ +{ yylhsminor.yy225 = yymsp[0].minor.yy225; } + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 270: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 271: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==271); -{ yymsp[-2].minor.yy140 = yymsp[-1].minor.yy140; } + case 278: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy225 = yymsp[0].minor.yy225; } break; - case 272: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy140 = createJoinTableNode(pCxt, yymsp[-4].minor.yy144, yymsp[-5].minor.yy140, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } - yymsp[-5].minor.yy140 = yylhsminor.yy140; + case 279: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 280: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==280); +{ yymsp[-2].minor.yy176 = yymsp[-1].minor.yy176; } break; - case 273: /* join_type ::= */ -{ yymsp[1].minor.yy144 = JOIN_TYPE_INNER; } + case 281: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy176 = createJoinTableNode(pCxt, yymsp[-4].minor.yy236, yymsp[-5].minor.yy176, yymsp[-2].minor.yy176, yymsp[0].minor.yy176); } + yymsp[-5].minor.yy176 = yylhsminor.yy176; break; - case 274: /* join_type ::= INNER */ -{ yymsp[0].minor.yy144 = JOIN_TYPE_INNER; } + case 282: /* join_type ::= */ +{ yymsp[1].minor.yy236 = JOIN_TYPE_INNER; } break; - case 275: /* 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 283: /* join_type ::= INNER */ +{ yymsp[0].minor.yy236 = JOIN_TYPE_INNER; } + break; + case 284: /* 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.yy140 = createSelectStmt(pCxt, yymsp[-7].minor.yy497, yymsp[-6].minor.yy136, yymsp[-5].minor.yy140); - yymsp[-8].minor.yy140 = addWhereClause(pCxt, yymsp[-8].minor.yy140, yymsp[-4].minor.yy140); - yymsp[-8].minor.yy140 = addPartitionByClause(pCxt, yymsp[-8].minor.yy140, yymsp[-3].minor.yy136); - yymsp[-8].minor.yy140 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy140, yymsp[-2].minor.yy140); - yymsp[-8].minor.yy140 = addGroupByClause(pCxt, yymsp[-8].minor.yy140, yymsp[-1].minor.yy136); - yymsp[-8].minor.yy140 = addHavingClause(pCxt, yymsp[-8].minor.yy140, yymsp[0].minor.yy140); + yymsp[-8].minor.yy176 = createSelectStmt(pCxt, yymsp[-7].minor.yy505, yymsp[-6].minor.yy512, yymsp[-5].minor.yy176); + yymsp[-8].minor.yy176 = addWhereClause(pCxt, yymsp[-8].minor.yy176, yymsp[-4].minor.yy176); + yymsp[-8].minor.yy176 = addPartitionByClause(pCxt, yymsp[-8].minor.yy176, yymsp[-3].minor.yy512); + yymsp[-8].minor.yy176 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy176, yymsp[-2].minor.yy176); + yymsp[-8].minor.yy176 = addGroupByClause(pCxt, yymsp[-8].minor.yy176, yymsp[-1].minor.yy512); + yymsp[-8].minor.yy176 = addHavingClause(pCxt, yymsp[-8].minor.yy176, yymsp[0].minor.yy176); } break; - case 277: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy497 = true; } + case 286: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy505 = true; } break; - case 278: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy497 = false; } + case 287: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy505 = false; } break; - case 279: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy136 = NULL; } + case 288: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy512 = NULL; } break; - case 283: /* select_item ::= common_expression */ + case 292: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); - yylhsminor.yy140 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy176); + yylhsminor.yy176 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy176), &t); } - yymsp[0].minor.yy140 = yylhsminor.yy140; + yymsp[0].minor.yy176 = yylhsminor.yy176; break; - case 284: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy140 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140), &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy140 = yylhsminor.yy140; + case 293: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy176 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy176), &yymsp[0].minor.yy225); } + yymsp[-1].minor.yy176 = yylhsminor.yy176; break; - case 285: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy140 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), &yymsp[0].minor.yy149); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 294: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy176 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), &yymsp[0].minor.yy225); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 286: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy140 = createColumnNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 295: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy176 = createColumnNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 290: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 307: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==307); - case 317: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==317); -{ yymsp[-2].minor.yy136 = yymsp[0].minor.yy136; } + case 299: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 316: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==316); + case 326: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==326); +{ yymsp[-2].minor.yy512 = yymsp[0].minor.yy512; } break; - case 292: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy140 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } + case 301: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy176 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy176), releaseRawExprNode(pCxt, yymsp[-1].minor.yy176)); } break; - case 293: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy140 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } + case 302: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy176 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy176)); } break; - case 294: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy140 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), NULL, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } + case 303: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy176 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy176), NULL, yymsp[-1].minor.yy176, yymsp[0].minor.yy176); } break; - case 295: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy140 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy140), releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } + case 304: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy176 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy176), releaseRawExprNode(pCxt, yymsp[-3].minor.yy176), yymsp[-1].minor.yy176, yymsp[0].minor.yy176); } break; - case 297: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy140 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy140); } + case 306: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy176 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy176); } break; - case 299: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy140 = createFillNode(pCxt, yymsp[-1].minor.yy306, NULL); } + case 308: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy176 = createFillNode(pCxt, yymsp[-1].minor.yy142, NULL); } break; - case 300: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy140 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy136)); } + case 309: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy176 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy512)); } break; - case 301: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy306 = FILL_MODE_NONE; } + case 310: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy142 = FILL_MODE_NONE; } break; - case 302: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy306 = FILL_MODE_PREV; } + case 311: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy142 = FILL_MODE_PREV; } break; - case 303: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy306 = FILL_MODE_NULL; } + case 312: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy142 = FILL_MODE_NULL; } break; - case 304: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy306 = FILL_MODE_LINEAR; } + case 313: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy142 = FILL_MODE_LINEAR; } break; - case 305: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy306 = FILL_MODE_NEXT; } + case 314: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy142 = FILL_MODE_NEXT; } break; - case 308: /* group_by_list ::= expression */ -{ yylhsminor.yy136 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[0].minor.yy136 = yylhsminor.yy136; + case 317: /* group_by_list ::= expression */ +{ yylhsminor.yy512 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } + yymsp[0].minor.yy512 = yylhsminor.yy512; break; - case 309: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy136 = yylhsminor.yy136; + case 318: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy512 = addNodeToList(pCxt, yymsp[-2].minor.yy512, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy176))); } + yymsp[-2].minor.yy512 = yylhsminor.yy512; break; - case 312: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 321: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy140 = addOrderByClause(pCxt, yymsp[-3].minor.yy140, yymsp[-2].minor.yy136); - yylhsminor.yy140 = addSlimitClause(pCxt, yylhsminor.yy140, yymsp[-1].minor.yy140); - yylhsminor.yy140 = addLimitClause(pCxt, yylhsminor.yy140, yymsp[0].minor.yy140); + yylhsminor.yy176 = addOrderByClause(pCxt, yymsp[-3].minor.yy176, yymsp[-2].minor.yy512); + yylhsminor.yy176 = addSlimitClause(pCxt, yylhsminor.yy176, yymsp[-1].minor.yy176); + yylhsminor.yy176 = addLimitClause(pCxt, yylhsminor.yy176, yymsp[0].minor.yy176); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 314: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy140 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy140, yymsp[0].minor.yy140); } - yymsp[-3].minor.yy140 = yylhsminor.yy140; + case 323: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy176 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy176, yymsp[0].minor.yy176); } + yymsp[-3].minor.yy176 = yylhsminor.yy176; break; - case 319: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 323: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==323); -{ yymsp[-1].minor.yy140 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 328: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 332: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==332); +{ yymsp[-1].minor.yy176 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 320: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 324: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==324); -{ yymsp[-3].minor.yy140 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 329: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 333: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==333); +{ yymsp[-3].minor.yy176 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 321: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 325: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==325); -{ yymsp[-3].minor.yy140 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 330: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 334: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==334); +{ yymsp[-3].minor.yy176 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 326: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy140); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 335: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy176 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy176); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 330: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy140 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), yymsp[-1].minor.yy158, yymsp[0].minor.yy73); } - yymsp[-2].minor.yy140 = yylhsminor.yy140; + case 339: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy176 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy176), yymsp[-1].minor.yy106, yymsp[0].minor.yy465); } + yymsp[-2].minor.yy176 = yylhsminor.yy176; break; - case 331: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy158 = ORDER_ASC; } + case 340: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy106 = ORDER_ASC; } break; - case 332: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy158 = ORDER_ASC; } + case 341: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy106 = ORDER_ASC; } break; - case 333: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy158 = ORDER_DESC; } + case 342: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy106 = ORDER_DESC; } break; - case 334: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy73 = NULL_ORDER_DEFAULT; } + case 343: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy465 = NULL_ORDER_DEFAULT; } break; - case 335: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy73 = NULL_ORDER_FIRST; } + case 344: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy465 = NULL_ORDER_FIRST; } break; - case 336: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy73 = NULL_ORDER_LAST; } + case 345: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy465 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 1813ad0827..88708ef369 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -206,6 +206,13 @@ TEST_F(ParserTest, selectExpression) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, selectPseudoColumn) { + setDatabase("root", "test"); + + bind("SELECT _wstartts, _wendts, count(*) FROM t1 interval(10s)"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, selectClause) { setDatabase("root", "test"); @@ -416,6 +423,7 @@ TEST_F(ParserTest, createDatabase) { "VGROUPS 100 " "SINGLE_STABLE 0 " "STREAM_MODE 1 " + "RETENTIONS '15s:7d,1m:21d,15m:5y'" ); ASSERT_TRUE(run()); } @@ -469,7 +477,7 @@ TEST_F(ParserTest, createTable) { "c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), c14 JSON, c15 VARCHAR(50)) " "TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 BINARY(20), a8 SMALLINT, " "a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), a14 JSON, a15 VARCHAR(50)) " - "KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)" + "KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2" ); ASSERT_TRUE(run()); @@ -491,7 +499,7 @@ TEST_F(ParserTest, createTable) { "c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), c14 JSON, c15 VARCHAR(50)) " "TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 BINARY(20), a8 SMALLINT, " "a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), a14 JSON, a15 VARCHAR(50)) " - "KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)" + "KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2" ); ASSERT_TRUE(run()); } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 740fb678fd..915c8bff83 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -411,7 +411,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, } static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SWindowLogicNode* pWindow, SLogicNode** pLogicNode) { - int32_t code = nodesCollectFuncs(pSelect, fmIsAggFunc, &pWindow->pFuncs); + int32_t code = nodesCollectFuncs(pSelect, fmIsWindowClauseFunc, &pWindow->pFuncs); if (TSDB_CODE_SUCCESS == code) { code = rewriteExpr(pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW); diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index c95845f8c7..b8226eb949 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -36,10 +36,6 @@ typedef struct SPhysiPlanContext { } SPhysiPlanContext; static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) { - if (QUERY_NODE_ORDER_BY_EXPR == nodeType(pNode)) { - return getSlotKey(((SOrderByExprNode*)pNode)->pExpr, pStmtName, pKey); - } - if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; if (NULL != pStmtName) { @@ -184,15 +180,16 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, int16_t nextSlotId = taosHashGetSize(pHash), slotId = 0; SNode* pNode = NULL; FOREACH(pNode, pList) { + SNode* pExpr = QUERY_NODE_ORDER_BY_EXPR == nodeType(pNode) ? ((SOrderByExprNode*)pNode)->pExpr : pNode; char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN] = {0}; - int32_t len = getSlotKey(pNode, pStmtName, name); + int32_t len = getSlotKey(pExpr, pStmtName, name); SSlotIndex* pIndex = taosHashGet(pHash, name, len); if (NULL == pIndex) { - code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, nextSlotId, output)); + code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output)); if (TSDB_CODE_SUCCESS == code) { code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash); } - pDataBlockDesc->resultRowSize += ((SExprNode*)pNode)->resType.bytes; + pDataBlockDesc->resultRowSize += ((SExprNode*)pExpr)->resType.bytes; slotId = nextSlotId; ++nextSlotId; } else { @@ -600,7 +597,7 @@ static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) { return collectAndRewrite(pContext, pNode); } case QUERY_NODE_FUNCTION: { - if (!fmIsAggFunc(((SFunctionNode*)(*pNode))->funcId)) { + if (fmIsScalarFunc(((SFunctionNode*)(*pNode))->funcId)) { return collectAndRewrite(pContext, pNode); } } diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 3d17cc260b..1de5e96335 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -192,6 +192,9 @@ TEST_F(PlannerTest, interval) { bind("SELECT count(*) FROM t1 interval(10s)"); ASSERT_TRUE(run()); + + bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)"); + ASSERT_TRUE(run()); } TEST_F(PlannerTest, sessionWindow) { diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index b79221cf82..cf34fc24a9 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -43,10 +43,12 @@ typedef struct SScalarCtx { #define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) +int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out); +SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows); + +#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type) +#define GET_PARAM_BYTES(_c) ((_c)->pColumnInfoData->info.bytes) -int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx); -bool sclIsNull(SScalarParam* param, int32_t idx); -void sclSetNull(SScalarParam* param, int32_t idx); void sclFreeParam(SScalarParam *param); #ifdef __cplusplus diff --git a/source/libs/scalar/inc/sclfunc.h b/source/libs/scalar/inc/sclfunc.h index 8915f37261..679411e004 100644 --- a/source/libs/scalar/inc/sclfunc.h +++ b/source/libs/scalar/inc/sclfunc.h @@ -22,19 +22,7 @@ extern "C" { #include "function.h" #include "scalar.h" -typedef struct SScalarFunctionSupport { - struct SExprInfo *pExprInfo; - int32_t numOfCols; - SColumnInfo *colList; - void *exprList; // client side used - int32_t offset; - char** data; -} SScalarFunctionSupport; -extern struct SScalarFunctionInfo scalarFunc[8]; - -int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarParam* pOutput, - void* param, char* (*getSourceDataBlock)(void*, const char*, int32_t)); #ifdef __cplusplus diff --git a/source/libs/scalar/inc/sclvector.h b/source/libs/scalar/inc/sclvector.h index 09b813359a..3f41ad875c 100644 --- a/source/libs/scalar/inc/sclvector.h +++ b/source/libs/scalar/inc/sclvector.h @@ -20,10 +20,66 @@ extern "C" { #endif -#include "sclfunc.h" +typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index); -typedef double (*_mathFunc)(double, double, bool *); +static FORCE_INLINE double getVectorDoubleValue_TINYINT(void *src, int32_t index) { + return (double)*((int8_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_UTINYINT(void *src, int32_t index) { + return (double)*((uint8_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_SMALLINT(void *src, int32_t index) { + return (double)*((int16_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_USMALLINT(void *src, int32_t index) { + return (double)*((uint16_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_INT(void *src, int32_t index) { + return (double)*((int32_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_UINT(void *src, int32_t index) { + return (double)*((uint32_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_BIGINT(void *src, int32_t index) { + return (double)*((int64_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_UBIGINT(void *src, int32_t index) { + return (double)*((uint64_t *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_FLOAT(void *src, int32_t index) { + return (double)*((float *)src + index); +} +static FORCE_INLINE double getVectorDoubleValue_DOUBLE(void *src, int32_t index) { + return (double)*((double *)src + index); +} +static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { + _getDoubleValue_fn_t p = NULL; + if (srcType == TSDB_DATA_TYPE_TINYINT) { + p = getVectorDoubleValue_TINYINT; + } else if (srcType == TSDB_DATA_TYPE_UTINYINT) { + p = getVectorDoubleValue_UTINYINT; + } else if (srcType == TSDB_DATA_TYPE_SMALLINT) { + p = getVectorDoubleValue_SMALLINT; + } else if (srcType == TSDB_DATA_TYPE_USMALLINT) { + p = getVectorDoubleValue_USMALLINT; + } else if (srcType == TSDB_DATA_TYPE_INT) { + p = getVectorDoubleValue_INT; + } else if (srcType == TSDB_DATA_TYPE_UINT) { + p = getVectorDoubleValue_UINT; + } else if (srcType == TSDB_DATA_TYPE_BIGINT) { + p = getVectorDoubleValue_BIGINT; + } else if (srcType == TSDB_DATA_TYPE_UBIGINT) { + p = getVectorDoubleValue_UBIGINT; + } else if (srcType == TSDB_DATA_TYPE_FLOAT) { + p = getVectorDoubleValue_FLOAT; + } else if (srcType == TSDB_DATA_TYPE_DOUBLE) { + p = getVectorDoubleValue_DOUBLE; + } else { + assert(0); + } + return p; +} typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType); typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order); diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 23e3e352c8..b0632bbc34 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -318,7 +318,7 @@ static FORCE_INLINE SFilterRangeNode* filterNewRange(SFilterRangeCtx *ctx, SFilt r->prev = NULL; r->next = NULL; } else { - r = taosMemoryCalloc(1, sizeof(SFilterRangeNode)); + r = taosMemoryCalloc(1, sizeof(SFilterRangeNode)); } FILTER_COPY_RA(&r->ra, ra); @@ -1021,26 +1021,21 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { if (node->opType == OP_TYPE_IN && (!IS_VAR_DATA_TYPE(type))) { SNodeListNode *listNode = (SNodeListNode *)node->pRight; SListCell *cell = listNode->pNodeList->pHead; - SScalarParam in = {.num = 1}, out = {.num = 1, .type = type}; + + SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; + out.columnData->info.type = type; for (int32_t i = 0; i < listNode->pNodeList->length; ++i) { SValueNode *valueNode = (SValueNode *)cell->pNode; - in.type = valueNode->node.resType.type; - in.bytes = valueNode->node.resType.bytes; - in.data = nodesGetValueFromNode(valueNode); - out.data = taosMemoryMalloc(sizeof(int64_t)); - - code = vectorConvertImpl(&in, &out); + code = doConvertDataType(valueNode, &out); if (code) { - fltError("convert from %d to %d failed", in.type, out.type); - taosMemoryFreeClear(out.data); +// fltError("convert from %d to %d failed", in.type, out.type); FLT_ERR_RET(code); } len = tDataTypes[type].bytes; - filterAddField(info, NULL, &out.data, FLD_TYPE_VALUE, &right, len, true); - + filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx); SFilterGroup fgroup = {0}; @@ -1054,7 +1049,6 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { filterAddFieldFromNode(info, node->pRight, &right); FLT_ERR_RET(filterAddUnit(info, node->opType, &left, &right, &uidx)); - SFilterGroup fgroup = {0}; filterAddUnitToGroup(&fgroup, uidx); @@ -1080,7 +1074,6 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right. t = FILTER_GET_FIELD(dst, right); - FILTER_SET_FLAG(t->flag, FLD_DATA_IS_HASH); } else { filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, varDataTLen(data), false); @@ -1101,14 +1094,12 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u int32_t filterAddUnitRight(SFilterInfo *info, uint8_t optr, SFilterFieldId *right, uint32_t uidx) { SFilterUnit *u = &info->units[uidx]; - u->compare.optr2 = optr; u->right2 = *right; return TSDB_CODE_SUCCESS; } - int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRangeCtx *ctx, uint32_t cidx, SFilterGroup *g, int32_t optr, SArray *res) { SFilterFieldId left, right, right2; uint32_t uidx = 0; @@ -1800,9 +1791,12 @@ int32_t fltInitValFieldData(SFilterInfo *info) { if (dType->type == type) { assignVal(fi->data, nodesGetValueFromNode(var), dType->bytes, type); } else { - SScalarParam in = {.data = nodesGetValueFromNode(var), .num = 1, .type = dType->type, .bytes = dType->bytes}; - SScalarParam out = {.data = fi->data, .num = 1, .type = type}; - if (vectorConvertImpl(&in, &out)) { + SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; + out.columnData->info.type = type; + + // todo refactor the convert + int32_t code = doConvertDataType(var, &out); + if (code != TSDB_CODE_SUCCESS) { qError("convert value to type[%d] failed", type); return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -3636,7 +3630,7 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options) if (*pInfo == NULL) { *pInfo = taosMemoryCalloc(1, sizeof(SFilterInfo)); if (NULL == *pInfo) { - fltError("calloc %d failed", (int32_t)sizeof(SFilterInfo)); + fltError("taosMemoryCalloc %d failed", (int32_t)sizeof(SFilterInfo)); FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } } @@ -3676,18 +3670,18 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnData FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output)); taosArrayDestroy(pList); - - *p = output.orig.data; - output.orig.data = NULL; - - sclFreeParam(&output); - - int8_t *r = output.data; - for (int32_t i = 0; i < output.num; ++i) { - if (0 == *(r+i)) { - return false; - } - } + // TODO Fix it +// *p = output.orig.data; +// output.orig.data = NULL; +// +// sclFreeParam(&output); +// +// int8_t *r = output.data; +// for (int32_t i = 0; i < output.num; ++i) { +// if (0 == *(r+i)) { +// return false; +// } +// } return true; } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 83902c9df8..7b2cb9ca67 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -6,6 +6,7 @@ #include "sclvector.h" #include "tcommon.h" #include "tdatablock.h" +#include "scalar.h" int32_t scalarGetOperatorParamNum(EOperatorType type) { if (OP_TYPE_IS_NULL == type || OP_TYPE_IS_NOT_NULL == type || OP_TYPE_IS_TRUE == type || OP_TYPE_IS_NOT_TRUE == type @@ -16,6 +17,41 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) { return 2; } +SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows) { + SColumnInfoData* pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); + if (pColumnData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + pColumnData->info.type = pType->type; + pColumnData->info.bytes = pType->bytes; + pColumnData->info.scale = pType->scale; + pColumnData->info.precision = pType->precision; + + int32_t code = blockDataEnsureColumnCapacity(pColumnData, numOfRows); + if (code != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFree(pColumnData); + return NULL; + } else { + return pColumnData; + } +} + +int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) { + SScalarParam in = {.numOfRows = 1}; + in.columnData = createColumnInfoData(&pValueNode->node.resType, 1); + colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); + + blockDataEnsureColumnCapacity(out->columnData, 1); + + int32_t code = vectorConvertImpl(&in, out); + sclFreeParam(&in); + + return code; +} + int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false); if (NULL == pObj) { @@ -28,10 +64,8 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { int32_t code = 0; SNodeListNode *nodeList = (SNodeListNode *)pNode; SListCell *cell = nodeList->pNodeList->pHead; - SScalarParam in = {.num = 1}, out = {.num = 1, .type = type}; - int8_t dummy = 0; - int32_t bufLen = 60; - out.data = taosMemoryMalloc(bufLen); + SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; + int32_t len = 0; void *buf = NULL; @@ -39,22 +73,21 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SValueNode *valueNode = (SValueNode *)cell->pNode; if (valueNode->node.resType.type != type) { - in.type = valueNode->node.resType.type; - in.bytes = valueNode->node.resType.bytes; - in.data = nodesGetValueFromNode(valueNode); - - code = vectorConvertImpl(&in, &out); - if (code) { - sclError("convert from %d to %d failed", in.type, out.type); + out.columnData->info.type = type; + out.columnData->info.bytes = tDataTypes[type].bytes; + + code = doConvertDataType(valueNode, &out); + if (code != TSDB_CODE_SUCCESS) { +// sclError("convert data from %d to %d failed", in.type, out.type); SCL_ERR_JRET(code); } if (IS_VAR_DATA_TYPE(type)) { - len = varDataLen(out.data); - buf = varDataVal(out.data); + len = varDataLen(out.columnData->pData); + buf = varDataVal(out.columnData->pData); } else { len = tDataTypes[type].bytes; - buf = out.data; + buf = out.columnData->pData; } } else { buf = nodesGetValueFromNode(valueNode); @@ -63,11 +96,10 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { buf = varDataVal(buf); } else { len = valueNode->node.resType.bytes; - buf = out.data; - } + } } - if (taosHashPut(pObj, buf, (size_t)len, &dummy, sizeof(dummy))) { + if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) { sclError("taosHashPut failed"); SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -75,40 +107,14 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { cell = cell->pNext; } - taosMemoryFreeClear(out.data); *data = pObj; - return TSDB_CODE_SUCCESS; _return: - - taosMemoryFreeClear(out.data); taosHashCleanup(pObj); - SCL_RET(code); } -FORCE_INLINE bool sclIsNull(SScalarParam* param, int32_t idx) { - if (param->dataInBlock) { - return colDataIsNull(param->orig.columnData, 0, idx, NULL); - } - - return param->bitmap ? colDataIsNull_f(param->bitmap, idx) : false; -} - -FORCE_INLINE void sclSetNull(SScalarParam* param, int32_t idx) { - if (NULL == param->bitmap) { - param->bitmap = taosMemoryCalloc(BitmapLen(param->num), sizeof(char)); - if (NULL == param->bitmap) { - sclError("calloc %d failed", param->num); - return; - } - } - - colDataSetNull_f(param->bitmap, idx); -} - - void sclFreeRes(SHashObj *res) { SScalarParam *p = NULL; void *pIter = taosHashIterate(res, NULL); @@ -118,31 +124,22 @@ void sclFreeRes(SHashObj *res) { if (p) { sclFreeParam(p); } - pIter = taosHashIterate(res, pIter); } - taosHashCleanup(res); } -void sclFreeParamNoData(SScalarParam *param) { - taosMemoryFreeClear(param->bitmap); -} - - void sclFreeParam(SScalarParam *param) { - sclFreeParamNoData(param); - - if (!param->dataInBlock) { - if (SCL_DATA_TYPE_DUMMY_HASH == param->type) { - taosHashCleanup((SHashObj *)param->orig.data); - } else { - taosMemoryFreeClear(param->orig.data); - } + if (param->columnData != NULL) { + colDataDestroy(param->columnData); + taosMemoryFreeClear(param->columnData); + } + + if (param->pHashFilter != NULL) { + taosHashCleanup(param->pHashFilter); } } - int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) { if (TSDB_DATA_TYPE_NULL == pNode->node.resType.type) { return TSDB_CODE_SUCCESS; @@ -155,7 +152,6 @@ int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) { } memcpy(*res, nodesGetValueFromNode(pNode), pNode->node.resType.bytes); - return TSDB_CODE_SUCCESS; } @@ -163,35 +159,26 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t switch (nodeType(node)) { case QUERY_NODE_VALUE: { SValueNode *valueNode = (SValueNode *)node; - //SCL_ERR_RET(sclCopyValueNodeValue(valueNode, ¶m->data)); - param->data = nodesGetValueFromNode(valueNode); - param->orig.data = param->data; - param->num = 1; - param->type = valueNode->node.resType.type; - param->bytes = valueNode->node.resType.bytes; - if (TSDB_DATA_TYPE_NULL == param->type) { - sclSetNull(param, 0); + + param->numOfRows = 1; + param->columnData = createColumnInfoData(&valueNode->node.resType, 1); + if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type) { + colDataAppend(param->columnData, 0, NULL, true); + } else { + colDataAppend(param->columnData, 0, nodesGetValueFromNode(valueNode), false); } - param->dataInBlock = false; - break; } case QUERY_NODE_NODE_LIST: { SNodeListNode *nodeList = (SNodeListNode *)node; - if (nodeList->pNodeList->length <= 0) { - sclError("invalid length in nodeList, length:%d", nodeList->pNodeList->length); + if (LIST_LENGTH(nodeList->pNodeList) <= 0) { + sclError("invalid length in nodeList, length:%d", LIST_LENGTH(nodeList->pNodeList)); SCL_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SCL_ERR_RET(scalarGenerateSetFromList(¶m->data, node, nodeList->dataType.type)); - param->orig.data = param->data; - param->num = 1; - param->type = SCL_DATA_TYPE_DUMMY_HASH; - param->dataInBlock = false; - + SCL_ERR_RET(scalarGenerateSetFromList((void**) ¶m->pHashFilter, node, nodeList->dataType.type)); if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) { - taosHashCleanup(param->orig.data); - param->orig.data = NULL; + taosHashCleanup(param->pHashFilter); sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param)); return TSDB_CODE_QRY_OUT_OF_MEMORY; } @@ -210,73 +197,38 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t } SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, ref->dataBlockId); - if (NULL == block || ref->slotId >= taosArrayGetSize(block->pDataBlock)) { sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock)); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } SColumnInfoData *columnData = (SColumnInfoData *)taosArrayGet(block->pDataBlock, ref->slotId); - param->data = NULL; - param->orig.columnData = columnData; - param->dataInBlock = true; - - param->num = block->info.rows; - param->type = columnData->info.type; - param->bytes = columnData->info.bytes; - + param->numOfRows = block->info.rows; + param->columnData = columnData; break; } - case QUERY_NODE_LOGIC_CONDITION: - case QUERY_NODE_OPERATOR: { + case QUERY_NODE_FUNCTION: + case QUERY_NODE_OPERATOR: + case QUERY_NODE_LOGIC_CONDITION: { SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES); if (NULL == res) { sclError("no result for node, type:%d, node:%p", nodeType(node), node); SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - *param = *res; - break; } - default: break; } - if (param->num > *rowNum) { - if ((1 != param->num) && (1 < *rowNum)) { - sclError("different row nums, rowNum:%d, newRowNum:%d", *rowNum, param->num); + if (param->numOfRows > *rowNum) { + if ((1 != param->numOfRows) && (1 < *rowNum)) { + sclError("different row nums, rowNum:%d, newRowNum:%d", *rowNum, param->numOfRows); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - *rowNum = param->num; - } - - return TSDB_CODE_SUCCESS; -} - -int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx) { - SScalarParam *param = NULL; - - for (int32_t i = 0; i < listNum; ++i) { - param = params + i; - - if (1 == param->num) { - continue; - } - - if (param->dataInBlock) { - param->data = colDataGetData(param->orig.columnData, idx); - } else if (idx) { - if (IS_VAR_DATA_TYPE(param->type)) { - param->data = (char *)(param->data) + varDataTLen(param->data); - } else { - param->data = (char *)(param->data) + tDataTypes[param->type].bytes; - } - } else { - param->data = param->orig.data; - } + *rowNum = param->numOfRows; } return TSDB_CODE_SUCCESS; @@ -298,16 +250,13 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC } SCL_ERR_JRET(sclInitParam(cell->pNode, ¶mList[i], ctx, rowNum)); - cell = cell->pNext; } *pParams = paramList; - return TSDB_CODE_SUCCESS; _return: - taosMemoryFreeClear(paramList); SCL_RET(code); } @@ -332,16 +281,13 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal } *pParams = paramList; - return TSDB_CODE_SUCCESS; _return: - taosMemoryFreeClear(paramList); SCL_RET(code); } - int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) { if (NULL == node->pParameterList || node->pParameterList->length <= 0) { sclError("invalid function parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0); @@ -359,37 +305,30 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu int32_t rowNum = 0; SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, &rowNum)); - output->type = node->node.resType.type; - output->data = taosMemoryCalloc(rowNum, sizeof(tDataTypes[output->type].bytes)); - if (NULL == output->data) { - sclError("calloc %d failed", (int32_t)(rowNum * sizeof(tDataTypes[output->type].bytes))); + output->columnData = createColumnInfoData(&node->node.resType, rowNum); + if (output->columnData == NULL) { + sclError("calloc %d failed", (int32_t)(rowNum * output->columnData->info.bytes)); SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - output->orig.data = output->data; - - for (int32_t i = 0; i < rowNum; ++i) { - sclMoveParamListData(output, 1, i); - sclMoveParamListData(params, node->pParameterList->length, i); +// for (int32_t i = 0; i < rowNum; ++i) { code = (*ffpSet.process)(params, node->pParameterList->length, output); if (code) { sclError("scalar function exec failed, funcId:%d, code:%s", node->funcId, tstrerror(code)); SCL_ERR_JRET(code); - } +// } } _return: for (int32_t i = 0; i < node->pParameterList->length; ++i) { - sclFreeParamNoData(params + i); +// sclFreeParamNoData(params + i); } taosMemoryFreeClear(params); - SCL_RET(code); } - int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *output) { if (NULL == node->pParameterList || node->pParameterList->length <= 0) { sclError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0); @@ -409,28 +348,24 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o SScalarParam *params = NULL; int32_t rowNum = 0; int32_t code = 0; - SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, &rowNum)); - output->type = node->node.resType.type; - output->bytes = sizeof(bool); - output->num = rowNum; - output->data = taosMemoryCalloc(rowNum, sizeof(bool)); - if (NULL == output->data) { + int32_t type = node->node.resType.type; + output->numOfRows = rowNum; + + SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; + output->columnData = createColumnInfoData(&t, rowNum); + if (output->columnData == NULL) { sclError("calloc %d failed", (int32_t)(rowNum * sizeof(bool))); SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - output->orig.data = output->data; bool value = false; - for (int32_t i = 0; i < rowNum; ++i) { - sclMoveParamListData(output, 1, i); - sclMoveParamListData(params, node->pParameterList->length, i); - for (int32_t m = 0; m < node->pParameterList->length; ++m) { - GET_TYPED_DATA(value, bool, params[m].type, params[m].data); - + char* p = colDataGetData(params[m].columnData, i); + GET_TYPED_DATA(value, bool, params[m].columnData->info.type, p); + if (LOGIC_COND_TYPE_AND == node->condType && (false == value)) { break; } else if (LOGIC_COND_TYPE_OR == node->condType && value) { @@ -440,13 +375,12 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o } } - *(bool *)output->data = value; + colDataAppend(output->columnData, i, (char*) &value, false); } _return: - for (int32_t i = 0; i < node->pParameterList->length; ++i) { - sclFreeParamNoData(params + i); +// sclFreeParamNoData(params + i); } taosMemoryFreeClear(params); @@ -459,16 +393,11 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp int32_t code = 0; SCL_ERR_RET(sclInitOperatorParams(¶ms, node, ctx, &rowNum)); - - output->type = node->node.resType.type; - output->num = rowNum; - output->bytes = tDataTypes[output->type].bytes; - output->data = taosMemoryCalloc(rowNum, tDataTypes[output->type].bytes); - if (NULL == output->data) { - sclError("calloc %d failed", (int32_t)rowNum * tDataTypes[output->type].bytes); + output->columnData = createColumnInfoData(&node->node.resType, rowNum); + if (output->columnData == NULL) { + sclError("calloc failed, size:%d", (int32_t)rowNum * node->node.resType.bytes); SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - output->orig.data = output->data; _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(node->opType); @@ -479,18 +408,14 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC); _return: - - for (int32_t i = 0; i < paramNum; ++i) { - sclFreeParamNoData(params + i); +// sclFreeParam(¶ms[i]); } taosMemoryFreeClear(params); - SCL_RET(code); } - EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { SFunctionNode *node = (SFunctionNode *)*pNode; SScalarParam output = {0}; @@ -510,11 +435,12 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { res->node.resType = node->node.resType; - if (IS_VAR_DATA_TYPE(output.type)) { - res->datum.p = output.data; - output.data = NULL; + int32_t type = output.columnData->info.type; + if (IS_VAR_DATA_TYPE(type)) { + res->datum.p = output.columnData->pData; + output.columnData->pData = NULL; } else { - memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes); + memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); } nodesDestroyNode(*pNode); @@ -527,8 +453,8 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) { SLogicConditionNode *node = (SLogicConditionNode *)*pNode; - SScalarParam output = {0}; + SScalarParam output = {0}; ctx->code = sclExecLogic(node, ctx, &output); if (ctx->code) { return DEAL_RES_ERROR; @@ -544,25 +470,25 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) { res->node.resType = node->node.resType; - if (IS_VAR_DATA_TYPE(output.type)) { - res->datum.p = output.data; - output.data = NULL; + int32_t type = output.columnData->info.type; + if (IS_VAR_DATA_TYPE(type)) { + res->datum.p = output.columnData->pData; + output.columnData->pData = NULL; } else { - memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes); + memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); } nodesDestroyNode(*pNode); *pNode = (SNode*)res; sclFreeParam(&output); - return DEAL_RES_CONTINUE; } EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)*pNode; - SScalarParam output = {0}; + SScalarParam output = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; ctx->code = sclExecOperator(node, ctx, &output); if (ctx->code) { return DEAL_RES_ERROR; @@ -578,22 +504,21 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { res->node.resType = node->node.resType; - if (IS_VAR_DATA_TYPE(output.type)) { - res->datum.p = output.data; - output.data = NULL; + int32_t type = output.columnData->info.type; + if (IS_VAR_DATA_TYPE(type)) { // todo refactor + res->datum.p = output.columnData->pData; + output.columnData->pData = NULL; } else { - memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes); + memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); } nodesDestroyNode(*pNode); *pNode = (SNode*)res; - sclFreeParam(&output); - + sclFreeParam(&output); return DEAL_RES_CONTINUE; } - EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { if (QUERY_NODE_VALUE == nodeType(*pNode) || QUERY_NODE_NODE_LIST == nodeType(*pNode)) { return DEAL_RES_CONTINUE; @@ -614,13 +539,10 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { } sclError("invalid node type for calculating constants, type:%d", nodeType(*pNode)); - ctx->code = TSDB_CODE_QRY_INVALID_INPUT; - return DEAL_RES_ERROR; } - EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { SFunctionNode *node = (SFunctionNode *)pNode; SScalarParam output = {0}; @@ -638,7 +560,6 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } - EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) { SLogicConditionNode *node = (SLogicConditionNode *)pNode; SScalarParam output = {0}; @@ -656,7 +577,6 @@ EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } - EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)pNode; SScalarParam output = {0}; @@ -699,27 +619,26 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } - for (int32_t i = 0; i < res->num; ++i) { - sclMoveParamListData(res, 1, i); - - colDataAppend(col, i, res->data, sclIsNull(res, i)); + for (int32_t i = 0; i < res->numOfRows; ++i) { + if (colDataIsNull(res->columnData, res->numOfRows, i, NULL)) { + colDataAppend(col, i, NULL, true); + } else { + char *p = colDataGetData(res->columnData, i); + colDataAppend(col, i, p, false); + } } sclFreeParam(res); - taosHashRemove(ctx->pRes, (void *)&target->pExpr, POINTER_BYTES); - return DEAL_RES_CONTINUE; } - EDealRes sclCalcWalker(SNode* pNode, void* pContext) { if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)) { return DEAL_RES_CONTINUE; } SScalarCtx *ctx = (SScalarCtx *)pContext; - if (QUERY_NODE_FUNCTION == nodeType(pNode)) { return sclWalkFunction(pNode, ctx); } @@ -737,14 +656,10 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) { } sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode)); - ctx->code = TSDB_CODE_QRY_INVALID_INPUT; - return DEAL_RES_ERROR; } - - int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { if (NULL == pNode) { SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); @@ -759,15 +674,11 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { } nodesRewriteNodePostOrder(&pNode, sclConstantsRewriter, (void *)&ctx); - SCL_ERR_JRET(ctx.code); - *pRes = pNode; _return: - sclFreeRes(ctx.pRes); - return code; } @@ -786,7 +697,6 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { } nodesWalkNodePostOrder(pNode, sclCalcWalker, (void *)&ctx); - SCL_ERR_JRET(ctx.code); if (pDst) { @@ -796,18 +706,14 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { SCL_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - sclMoveParamListData(res, 1, 0); - - *pDst = *res; - + colDataAssign(pDst->columnData, res->columnData, res->numOfRows); + pDst->numOfRows = res->numOfRows; taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); } _return: - //nodesDestroyNode(pNode); sclFreeRes(ctx.pRes); - return code; } diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index f2fdb29e4a..feada84685 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1,106 +1,118 @@ #include "sclfunc.h" +#include +#include "sclInt.h" #include "sclvector.h" static void assignBasicParaInfo(struct SScalarParam* dst, const struct SScalarParam* src) { - dst->type = src->type; - dst->bytes = src->bytes; - //dst->num = src->num; +// dst->type = src->type; +// dst->bytes = src->bytes; +// dst->num = src->num; } /** Math functions **/ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - assignBasicParaInfo(pOutput, pInput); - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { + SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pOutputData = pOutput->columnData; + + int32_t type = GET_PARAM_TYPE(pInput); + if (!IS_NUMERIC_TYPE(type)) { return TSDB_CODE_FAILED; } - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; + switch (type) { + case TSDB_DATA_TYPE_FLOAT: { + float *in = (float *)pInputData->pData; + float *out = (float *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; + } + break; } - switch (pInput->type) { - case TSDB_DATA_TYPE_FLOAT: { - float v; - GET_TYPED_DATA(v, float, pInput->type, input); - float result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; + case TSDB_DATA_TYPE_DOUBLE: { + double *in = (double *)pInputData->pData; + double *out = (double *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; } + break; + } - case TSDB_DATA_TYPE_DOUBLE: { - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; + case TSDB_DATA_TYPE_TINYINT: { + int8_t *in = (int8_t *)pInputData->pData; + int8_t *out = (int8_t *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; } + break; + } - case TSDB_DATA_TYPE_TINYINT: { - int8_t v; - GET_TYPED_DATA(v, int8_t, pInput->type, input); - int8_t result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; + case TSDB_DATA_TYPE_SMALLINT: { + int16_t *in = (int16_t *)pInputData->pData; + int16_t *out = (int16_t *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; } + break; + } - case TSDB_DATA_TYPE_SMALLINT: { - int16_t v; - GET_TYPED_DATA(v, int16_t, pInput->type, input); - int16_t result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; + case TSDB_DATA_TYPE_INT: { + int32_t *in = (int32_t *)pInputData->pData; + int32_t *out = (int32_t *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; } + break; + } - case TSDB_DATA_TYPE_INT: { - int32_t v; - GET_TYPED_DATA(v, int32_t, pInput->type, input); - int32_t result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; + case TSDB_DATA_TYPE_BIGINT: { + int64_t *in = (int64_t *)pInputData->pData; + int64_t *out = (int64_t *)pOutputData->pData; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = (in[i] > 0)? in[i] : -in[i]; } + break; + } - case TSDB_DATA_TYPE_BIGINT: { - int64_t v; - GET_TYPED_DATA(v, int64_t, pInput->type, input); - int64_t result; - result = (v > 0) ? v : -v; - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - default: { - memcpy(output, input, pInput->bytes); - break; - } + default: { + colDataAssign(pOutputData, pInputData, pInput->numOfRows); } } + pOutput->numOfRows = pInput->numOfRows; return TSDB_CODE_SUCCESS; } int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { +#if 0 if (inputNum != 2 || !IS_NUMERIC_TYPE(pInput[0].type) || !IS_NUMERIC_TYPE(pInput[1].type)) { return TSDB_CODE_FAILED; } - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - char **input = NULL, *output = NULL; bool hasNullInput = false; input = taosMemoryCalloc(inputNum, sizeof(char *)); @@ -132,11 +144,13 @@ int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu } taosMemoryFree(input); +#endif return TSDB_CODE_SUCCESS; } int32_t powFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { +#if 0 if (inputNum != 2 || !IS_NUMERIC_TYPE(pInput[0].type) || !IS_NUMERIC_TYPE(pInput[1].type)) { return TSDB_CODE_FAILED; } @@ -175,381 +189,140 @@ int32_t powFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu } taosMemoryFree(input); - +#endif return TSDB_CODE_SUCCESS; } -int32_t sqrtFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { +typedef float (*_float_fn)(float); +typedef double (*_double_fn)(double); + +int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) { + int32_t type = GET_PARAM_TYPE(pInput); + if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) { return TSDB_CODE_FAILED; } - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pOutputData = pOutput->columnData; - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; + _getDoubleValue_fn_t getValueFn = getVectorDoubleValueFn(type); - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); + double *out = (double *)pOutputData->pData; + + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = sqrt(v); - SET_TYPED_DATA(output, pOutput->type, result); + out[i] = valFn(getValueFn(pInputData->pData, i)); } + pOutput->numOfRows = pInput->numOfRows; return TSDB_CODE_SUCCESS; } -int32_t sinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { +int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _float_fn f1, _double_fn d1) { + int32_t type = GET_PARAM_TYPE(pInput); + if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) { return TSDB_CODE_FAILED; } - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pOutputData = pOutput->columnData; - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; + switch (type) { + case TSDB_DATA_TYPE_FLOAT: { + float *in = (float *)pInputData->pData; + float *out = (float *)pOutputData->pData; - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = f1(in[i]); + } + break; } - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = sin(v); - SET_TYPED_DATA(output, pOutput->type, result); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t cosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = cos(v); - SET_TYPED_DATA(output, pOutput->type, result); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t tanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = tan(v); - SET_TYPED_DATA(output, pOutput->type, result); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t asinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = asin(v); - SET_TYPED_DATA(output, pOutput->type, result); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t acosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = acos(v); - SET_TYPED_DATA(output, pOutput->type, result); + case TSDB_DATA_TYPE_DOUBLE: { + double *in = (double *)pInputData->pData; + double *out = (double *)pOutputData->pData; + + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_f(pInputData->nullbitmap, i)) { + colDataSetNull_f(pOutputData->nullbitmap, i); + continue; + } + out[i] = d1(in[i]); + } + break; + } + + default: { + colDataAssign(pOutputData, pInputData, pInput->numOfRows); + } } + pOutput->numOfRows = pInput->numOfRows; return TSDB_CODE_SUCCESS; } int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } + return doScalarFunctionUnique(pInput, inputNum, pOutput, atan); +} - pOutput->type = TSDB_DATA_TYPE_DOUBLE; - pOutput->bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; +int32_t sinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, sin); +} - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; +int32_t cosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, cos); +} - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } +int32_t tanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, tan); +} - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = atan(v); - SET_TYPED_DATA(output, pOutput->type, result); - } +int32_t asinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, asin); +} - return TSDB_CODE_SUCCESS; +int32_t acosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, acos); +} + +int32_t sqrtFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return doScalarFunctionUnique(pInput, inputNum, pOutput, sqrt); } int32_t ceilFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - switch (pInput->type) { - case TSDB_DATA_TYPE_FLOAT: { - float v; - GET_TYPED_DATA(v, float, pInput->type, input); - float result = ceilf(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - case TSDB_DATA_TYPE_DOUBLE: { - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = ceil(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - default: { - memcpy(output, input, pInput->bytes); - break; - } - } - } - - return TSDB_CODE_SUCCESS; + return doScalarFunction(pInput, inputNum, pOutput, ceilf, ceil); } int32_t floorFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - assignBasicParaInfo(pOutput, pInput); - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - switch (pInput->type) { - case TSDB_DATA_TYPE_FLOAT: { - float v; - GET_TYPED_DATA(v, float, pInput->type, input); - float result = floorf(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - case TSDB_DATA_TYPE_DOUBLE: { - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = floor(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - default: { - memcpy(output, input, pInput->bytes); - break; - } - } - } - - return TSDB_CODE_SUCCESS; + return doScalarFunction(pInput, inputNum, pOutput, floorf, floor); } int32_t roundFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - assignBasicParaInfo(pOutput, pInput); - if (inputNum != 1 || !IS_NUMERIC_TYPE(pInput->type)) { - return TSDB_CODE_FAILED; - } - - char *input = NULL, *output = NULL; - for (int32_t i = 0; i < pOutput->num; ++i) { - if (pInput->num == 1) { - input = pInput->data; - } else { - input = pInput->data + i * pInput->bytes; - } - output = pOutput->data + i * pOutput->bytes; - - if (isNull(input, pInput->type)) { - setNull(output, pOutput->type, pOutput->bytes); - continue; - } - - switch (pInput->type) { - case TSDB_DATA_TYPE_FLOAT: { - float v; - GET_TYPED_DATA(v, float, pInput->type, input); - float result = roundf(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - case TSDB_DATA_TYPE_DOUBLE: { - double v; - GET_TYPED_DATA(v, double, pInput->type, input); - double result = round(v); - SET_TYPED_DATA(output, pOutput->type, result); - break; - } - - default: { - memcpy(output, input, pInput->bytes); - break; - } - } - } - - return TSDB_CODE_SUCCESS; + return doScalarFunction(pInput, inputNum, pOutput, roundf, round); } static void tlength(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) { assert(numOfInput == 1); - +#if 0 int64_t* out = (int64_t*) pOutput->data; char* s = pLeft->data; for(int32_t i = 0; i < pLeft->num; ++i) { out[i] = varDataLen(POINTER_SHIFT(s, i * pLeft->bytes)); } +#endif } static void tconcat(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) { assert(numOfInput > 0); - +#if 0 int32_t rowLen = 0; int32_t num = 1; for(int32_t i = 0; i < numOfInput; ++i) { @@ -577,6 +350,7 @@ static void tconcat(SScalarParam* pOutput, size_t numOfInput, const SScalarParam rstart += rowLen; } +#endif } static void tltrim(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) { @@ -652,154 +426,3 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf } } -static void setScalarFuncParam(SScalarParam* param, int32_t type, int32_t bytes, void* pInput, int32_t numOfRows) { - param->bytes = bytes; - param->type = type; - param->num = numOfRows; - param->data = pInput; -} - - -#if 0 -int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncParam* pOutput, void* param, - char* (*getSourceDataBlock)(void*, const char*, int32_t)) { - if (pExprs == NULL) { - return 0; - } - - tExprNode* pLeft = pExprs->_node.pLeft; - tExprNode* pRight = pExprs->_node.pRight; - - /* the left output has result from the left child syntax tree */ - SScalarFuncParam leftOutput = {0}; - SScalarFuncParam rightOutput = {0}; - - if (pLeft->nodeType == TEXPR_BINARYEXPR_NODE || pLeft->nodeType == TEXPR_UNARYEXPR_NODE) { - leftOutput.data = taosMemoryMalloc(sizeof(int64_t) * numOfRows); - evaluateExprNodeTree(pLeft, numOfRows, &leftOutput, param, getSourceDataBlock); - } - - // the right output has result from the right child syntax tree - if (pRight->nodeType == TEXPR_BINARYEXPR_NODE || pRight->nodeType == TEXPR_UNARYEXPR_NODE) { - rightOutput.data = taosMemoryMalloc(sizeof(int64_t) * numOfRows); - evaluateExprNodeTree(pRight, numOfRows, &rightOutput, param, getSourceDataBlock); - } - - if (pExprs->nodeType == TEXPR_BINARYEXPR_NODE) { - _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(pExprs->_node.optr); - - SScalarFuncParam left = {0}, right = {0}; - if (pLeft->nodeType == TEXPR_BINARYEXPR_NODE || pLeft->nodeType == TEXPR_UNARYEXPR_NODE) { - setScalarFuncParam(&left, leftOutput.type, leftOutput.bytes, leftOutput.data, leftOutput.num); - } else if (pLeft->nodeType == TEXPR_COL_NODE) { - SSchema* pschema = pLeft->pSchema; - char* pLeftInputData = getSourceDataBlock(param, pschema->name, pschema->colId); - setScalarFuncParam(&right, pschema->type, pschema->bytes, pLeftInputData, numOfRows); - } else if (pLeft->nodeType == TEXPR_VALUE_NODE) { - SVariant* pVar = pRight->pVal; - setScalarFuncParam(&left, pVar->nType, pVar->nLen, &pVar->i, 1); - } - - if (pRight->nodeType == TEXPR_BINARYEXPR_NODE || pRight->nodeType == TEXPR_UNARYEXPR_NODE) { - setScalarFuncParam(&right, rightOutput.type, rightOutput.bytes, rightOutput.data, rightOutput.num); - } else if (pRight->nodeType == TEXPR_COL_NODE) { // exprLeft + columnRight - SSchema* pschema = pRight->pSchema; - char* pInputData = getSourceDataBlock(param, pschema->name, pschema->colId); - setScalarFuncParam(&right, pschema->type, pschema->bytes, pInputData, numOfRows); - } else if (pRight->nodeType == TEXPR_VALUE_NODE) { // exprLeft + 12 - SVariant* pVar = pRight->pVal; - setScalarFuncParam(&right, pVar->nType, pVar->nLen, &pVar->i, 1); - } - - void* outputBuf = pOutput->data; - if (isStringOp(pExprs->_node.optr)) { - outputBuf = taosMemoryRealloc(pOutput->data, (left.bytes + right.bytes) * left.num); - } - - OperatorFn(&left, &right, outputBuf, TSDB_ORDER_ASC); - // Set the result info - setScalarFuncParam(pOutput, TSDB_DATA_TYPE_DOUBLE, sizeof(double), outputBuf, numOfRows); - } else if (pExprs->nodeType == TEXPR_UNARYEXPR_NODE) { - _unary_scalar_fn_t OperatorFn = getUnaryScalarOperatorFn(pExprs->_node.optr); - SScalarFuncParam left = {0}; - - if (pLeft->nodeType == TEXPR_BINARYEXPR_NODE || pLeft->nodeType == TEXPR_UNARYEXPR_NODE) { - setScalarFuncParam(&left, leftOutput.type, leftOutput.bytes, leftOutput.data, leftOutput.num); - } else if (pLeft->nodeType == TEXPR_COL_NODE) { - SSchema* pschema = pLeft->pSchema; - char* pLeftInputData = getSourceDataBlock(param, pschema->name, pschema->colId); - setScalarFuncParam(&left, pschema->type, pschema->bytes, pLeftInputData, numOfRows); - } else if (pLeft->nodeType == TEXPR_VALUE_NODE) { - SVariant* pVar = pLeft->pVal; - setScalarFuncParam(&left, pVar->nType, pVar->nLen, &pVar->i, 1); - } - - // reserve enough memory buffer - if (isBinaryStringOp(pExprs->_node.optr)) { - void* outputBuf = taosMemoryRealloc(pOutput->data, left.bytes * left.num); - assert(outputBuf != NULL); - pOutput->data = outputBuf; - } - - OperatorFn(&left, pOutput); - } - - taosMemoryFreeClear(leftOutput.data); - taosMemoryFreeClear(rightOutput.data); - - return 0; -} -#endif - - -//SScalarFunctionInfo scalarFunc[8] = { -// {"ceil", FUNCTION_TYPE_SCALAR, FUNCTION_CEIL, tceil}, -// {"floor", FUNCTION_TYPE_SCALAR, FUNCTION_FLOOR, tfloor}, -// {"abs", FUNCTION_TYPE_SCALAR, FUNCTION_ABS, _tabs}, -// {"round", FUNCTION_TYPE_SCALAR, FUNCTION_ROUND, tround}, -// {"length", FUNCTION_TYPE_SCALAR, FUNCTION_LENGTH, tlength}, -// {"concat", FUNCTION_TYPE_SCALAR, FUNCTION_CONCAT, tconcat}, -// {"ltrim", FUNCTION_TYPE_SCALAR, FUNCTION_LTRIM, tltrim}, -// {"rtrim", FUNCTION_TYPE_SCALAR, FUNCTION_RTRIM, trtrim}, -//}; - -void setScalarFunctionSupp(struct SScalarFunctionSupport* sas, SExprInfo *pExprInfo, SSDataBlock* pSDataBlock) { - sas->numOfCols = (int32_t) pSDataBlock->info.numOfCols; - sas->pExprInfo = pExprInfo; - if (sas->colList != NULL) { - return; - } - - sas->colList = taosMemoryCalloc(1, pSDataBlock->info.numOfCols*sizeof(SColumnInfo)); - for(int32_t i = 0; i < sas->numOfCols; ++i) { - SColumnInfoData* pColData = taosArrayGet(pSDataBlock->pDataBlock, i); - sas->colList[i] = pColData->info; - } - - sas->data = taosMemoryCalloc(sas->numOfCols, POINTER_BYTES); - - // set the input column data - for (int32_t f = 0; f < pSDataBlock->info.numOfCols; ++f) { - SColumnInfoData *pColumnInfoData = taosArrayGet(pSDataBlock->pDataBlock, f); - sas->data[f] = pColumnInfoData->pData; - } -} - -SScalarFunctionSupport* createScalarFuncSupport(int32_t num) { - SScalarFunctionSupport* pSupp = taosMemoryCalloc(num, sizeof(SScalarFunctionSupport)); - return pSupp; -} - -void destroyScalarFuncSupport(struct SScalarFunctionSupport* pSupport, int32_t num) { - if (pSupport == NULL) { - return; - } - - for(int32_t i = 0; i < num; ++i) { - SScalarFunctionSupport* pSupp = &pSupport[i]; - taosMemoryFreeClear(pSupp->data); - taosMemoryFreeClear(pSupp->colList); - } - - taosMemoryFreeClear(pSupport); -} diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 2300f5a1d3..f22f9a5c3c 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -25,108 +25,6 @@ #include "tdatablock.h" #include "ttypes.h" -//GET_TYPED_DATA(v, double, pRight->type, (char *)&((right)[i])); - -void calc_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - int32_t *pLeft = (int32_t *)left; - int32_t *pRight = (int32_t *)right; - double * pOutput = (double *)output; - - int32_t i = (order == TSDB_ORDER_ASC) ? 0 : TMAX(numLeft, numRight) - 1; - int32_t step = (order == TSDB_ORDER_ASC) ? 1 : -1; - - if (numLeft == numRight) { - for (; i >= 0 && i < numRight; i += step, pOutput += 1) { - if (isNull((char *)&(pLeft[i]), TSDB_DATA_TYPE_INT) || isNull((char *)&(pRight[i]), TSDB_DATA_TYPE_INT)) { - SET_DOUBLE_NULL(pOutput); - continue; - } - - *pOutput = (double)pLeft[i] + pRight[i]; - } - } else if (numLeft == 1) { - for (; i >= 0 && i < numRight; i += step, pOutput += 1) { - if (isNull((char *)(pLeft), TSDB_DATA_TYPE_INT) || isNull((char *)&(pRight[i]), TSDB_DATA_TYPE_INT)) { - SET_DOUBLE_NULL(pOutput); - continue; - } - - *pOutput = (double)pLeft[0] + pRight[i]; - } - } else if (numRight == 1) { - for (; i >= 0 && i < numLeft; i += step, pOutput += 1) { - if (isNull((char *)&(pLeft[i]), TSDB_DATA_TYPE_INT) || isNull((char *)(pRight), TSDB_DATA_TYPE_INT)) { - SET_DOUBLE_NULL(pOutput); - continue; - } - *pOutput = (double)pLeft[i] + pRight[0]; - } - } -} - -typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index); - -double getVectorDoubleValue_TINYINT(void *src, int32_t index) { - return (double)*((int8_t *)src + index); -} -double getVectorDoubleValue_UTINYINT(void *src, int32_t index) { - return (double)*((uint8_t *)src + index); -} -double getVectorDoubleValue_SMALLINT(void *src, int32_t index) { - return (double)*((int16_t *)src + index); -} -double getVectorDoubleValue_USMALLINT(void *src, int32_t index) { - return (double)*((uint16_t *)src + index); -} -double getVectorDoubleValue_INT(void *src, int32_t index) { - return (double)*((int32_t *)src + index); -} -double getVectorDoubleValue_UINT(void *src, int32_t index) { - return (double)*((uint32_t *)src + index); -} -double getVectorDoubleValue_BIGINT(void *src, int32_t index) { - return (double)*((int64_t *)src + index); -} -double getVectorDoubleValue_UBIGINT(void *src, int32_t index) { - return (double)*((uint64_t *)src + index); -} -double getVectorDoubleValue_FLOAT(void *src, int32_t index) { - return (double)*((float *)src + index); -} -double getVectorDoubleValue_DOUBLE(void *src, int32_t index) { - return (double)*((double *)src + index); -} - -_getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { - _getDoubleValue_fn_t p = NULL; - if(srcType==TSDB_DATA_TYPE_TINYINT) { - p = getVectorDoubleValue_TINYINT; - }else if(srcType==TSDB_DATA_TYPE_UTINYINT) { - p = getVectorDoubleValue_UTINYINT; - }else if(srcType==TSDB_DATA_TYPE_SMALLINT) { - p = getVectorDoubleValue_SMALLINT; - }else if(srcType==TSDB_DATA_TYPE_USMALLINT) { - p = getVectorDoubleValue_USMALLINT; - }else if(srcType==TSDB_DATA_TYPE_INT) { - p = getVectorDoubleValue_INT; - }else if(srcType==TSDB_DATA_TYPE_UINT) { - p = getVectorDoubleValue_UINT; - }else if(srcType==TSDB_DATA_TYPE_BIGINT) { - p = getVectorDoubleValue_BIGINT; - }else if(srcType==TSDB_DATA_TYPE_UBIGINT) { - p = getVectorDoubleValue_UBIGINT; - }else if(srcType==TSDB_DATA_TYPE_FLOAT) { - p = getVectorDoubleValue_FLOAT; - }else if(srcType==TSDB_DATA_TYPE_DOUBLE) { - p = getVectorDoubleValue_DOUBLE; - }else { - assert(0); - } - return p; -} - - - typedef int64_t (*_getBigintValue_fn_t)(void *src, int32_t index); int64_t getVectorBigintValue_TINYINT(void *src, int32_t index) { @@ -187,9 +85,6 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { return p; } - - - typedef void* (*_getValueAddr_fn_t)(void *src, int32_t index); void* getVectorValueAddr_TINYINT(void *src, int32_t index) { @@ -261,28 +156,35 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { return p; } -static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t outType) { +static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex) { int64_t value = strtoll(buf, NULL, 10); - SET_TYPED_DATA(pOut->data, outType, value); + colDataAppend(pOut->columnData, rowIndex, (char*) &value, false); } -static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t outType) { +static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex) { uint64_t value = strtoull(buf, NULL, 10); - SET_TYPED_DATA(pOut->data, outType, value); + colDataAppend(pOut->columnData, rowIndex, (char*) &value, false); } -static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t outType) { +static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex) { double value = strtod(buf, NULL); - SET_TYPED_DATA(pOut->data, outType, value); + colDataAppend(pOut->columnData, rowIndex, (char*) &value, false); } +static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex) { + int64_t value = strtoll(buf, NULL, 10); + bool v = (value != 0)? true:false; + colDataAppend(pOut->columnData, rowIndex, (char*) &v, false); +} + +int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { + int32_t bufSize = pIn->columnData->info.bytes; + char *tmp = taosMemoryMalloc(bufSize); -int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { - int32_t bufSize = 0; - char *tmp = NULL; _bufConverteFunc func = NULL; - - if (IS_SIGNED_NUMERIC_TYPE(outType) || TSDB_DATA_TYPE_TIMESTAMP == outType || TSDB_DATA_TYPE_BOOL == outType) { + if (TSDB_DATA_TYPE_BOOL == outType) { + func = varToBool; + } else if (IS_SIGNED_NUMERIC_TYPE(outType) || TSDB_DATA_TYPE_TIMESTAMP == outType) { func = varToSigned; } else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) { func = varToUnsigned; @@ -292,31 +194,22 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t sclError("invalid convert outType:%d", outType); return TSDB_CODE_QRY_APP_ERROR; } - - for (int32_t i = 0; i < pIn->num; ++i) { - sclMoveParamListData(pIn, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pIn, i)) { - sclSetNull(pOut, i); + + pOut->numOfRows = pIn->numOfRows; + for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (colDataIsNull(pIn->columnData, pIn->numOfRows, i, NULL)) { + colDataAppend(pOut->columnData, i, NULL, true); continue; } + char* data = colDataGetData(pIn->columnData, i); if (TSDB_DATA_TYPE_BINARY == inType) { - if (varDataLen(pIn->data) >= bufSize) { - bufSize = varDataLen(pIn->data) + 1; - tmp = taosMemoryRealloc(tmp, bufSize); - } - - memcpy(tmp, varDataVal(pIn->data), varDataLen(pIn->data)); - tmp[varDataLen(pIn->data)] = 0; + memcpy(tmp, varDataVal(data), varDataLen(data)); + tmp[varDataLen(data)] = 0; } else { - if (varDataLen(pIn->data) * TSDB_NCHAR_SIZE >= bufSize) { - bufSize = varDataLen(pIn->data) * TSDB_NCHAR_SIZE + 1; - tmp = taosMemoryRealloc(tmp, bufSize); - } + ASSERT (varDataLen(data) <= bufSize); - int len = taosUcs4ToMbs((TdUcs4*)varDataVal(pIn->data), varDataLen(pIn->data), tmp); + int len = taosUcs4ToMbs((TdUcs4*)varDataVal(data), varDataLen(data), tmp); if (len < 0){ sclError("castConvert taosUcs4ToMbs error 1"); taosMemoryFreeClear(tmp); @@ -326,80 +219,82 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t tmp[len] = 0; } - (*func)(tmp, pOut, outType); + (*func)(tmp, pOut, i); } taosMemoryFreeClear(tmp); - return TSDB_CODE_SUCCESS; } -int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { - int16_t inType = pIn->type; - int16_t inBytes = pIn->bytes; - int16_t outType = pOut->type; - int16_t outBytes = pOut->bytes; +// TODO opt performance +int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) { + SColumnInfoData* pInputCol = pIn->columnData; + SColumnInfoData* pOutputCol = pOut->columnData; - if (inType == TSDB_DATA_TYPE_BINARY || inType == TSDB_DATA_TYPE_NCHAR) { + int16_t inType = pInputCol->info.type; + int16_t outType = pOutputCol->info.type; + + if (IS_VAR_DATA_TYPE(inType)) { return vectorConvertFromVarData(pIn, pOut, inType, outType); } switch (outType) { - case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_BOOL: { + for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (colDataIsNull_f(pInputCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); + continue; + } + + bool value = 0; + GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i)); + colDataAppend(pOutputCol, i, (char*) &value, false); + } + break; + } case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_TIMESTAMP: - for (int32_t i = 0; i < pIn->num; ++i) { - sclMoveParamListData(pIn, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pIn, i)) { - sclSetNull(pOut, i); + case TSDB_DATA_TYPE_TIMESTAMP: { + for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (colDataIsNull_f(pInputCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); continue; } int64_t value = 0; - - GET_TYPED_DATA(value, int64_t, inType, pIn->data); - SET_TYPED_DATA(pOut->data, outType, value); + GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i)); + colDataAppend(pOutputCol, i, (char *)&value, false); } break; - case TSDB_DATA_TYPE_UTINYINT: + } + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_UBIGINT: - for (int32_t i = 0; i < pIn->num; ++i) { - sclMoveParamListData(pIn, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pIn, i)) { - sclSetNull(pOut, i); + for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (colDataIsNull_f(pInputCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); continue; } uint64_t value = 0; - - GET_TYPED_DATA(value, uint64_t, inType, pIn->data); - SET_TYPED_DATA(pOut->data, outType, value); + GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i)); + colDataAppend(pOutputCol, i, (char*) &value, false); } break; case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_DOUBLE: - for (int32_t i = 0; i < pIn->num; ++i) { - sclMoveParamListData(pIn, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pIn, i)) { - sclSetNull(pOut, i); + for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (colDataIsNull_f(pInputCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); continue; } double value = 0; - - GET_TYPED_DATA(value, double, inType, pIn->data); - SET_TYPED_DATA(pOut->data, outType, value); + GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i)); + colDataAppend(pOutputCol, i, (char*) &value, false); } break; default: @@ -446,11 +341,13 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) { } int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* pLeftOut, SScalarParam* pRightOut) { - if (pLeft->type == pRight->type) { + if (pLeft->pHashFilter != NULL || pRight->pHashFilter != NULL) { return TSDB_CODE_SUCCESS; } - if (SCL_DATA_TYPE_DUMMY_HASH == pLeft->type || SCL_DATA_TYPE_DUMMY_HASH == pRight->type) { + int32_t leftType = GET_PARAM_TYPE(pLeft); + int32_t rightType = GET_PARAM_TYPE(pRight); + if (leftType == rightType) { return TSDB_CODE_SUCCESS; } @@ -458,7 +355,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p SScalarParam *param2 = NULL, *paramOut2 = NULL; int32_t code = 0; - if (pLeft->type < pRight->type) { + if (leftType < rightType) { param1 = pLeft; param2 = pRight; paramOut1 = pLeftOut; @@ -470,44 +367,38 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p paramOut2 = pLeftOut; } - - int8_t type = vectorGetConvertType(param1->type, param2->type); + int8_t type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2)); if (0 == type) { return TSDB_CODE_SUCCESS; } - if (type != param1->type) { - paramOut1->bytes = param1->bytes; - paramOut1->type = type; - paramOut1->num = param1->num; - paramOut1->data = taosMemoryMalloc(paramOut1->num * tDataTypes[paramOut1->type].bytes); - if (NULL == paramOut1->data) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + if (type != GET_PARAM_TYPE(param1)) { + SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; + paramOut1->numOfRows = param1->numOfRows; + + paramOut1->columnData = createColumnInfoData(&t, param1->numOfRows); + if (paramOut1->columnData == NULL) { + return terrno; } - paramOut1->orig.data = paramOut1->data; - + code = vectorConvertImpl(param1, paramOut1); if (code) { - taosMemoryFreeClear(paramOut1->data); +// taosMemoryFreeClear(paramOut1->data); return code; } } - if (type != param2->type) { - paramOut2->bytes = param2->bytes; - paramOut2->type = type; - paramOut2->num = param2->num; - paramOut2->data = taosMemoryMalloc(paramOut2->num * tDataTypes[paramOut2->type].bytes); - if (NULL == paramOut2->data) { - taosMemoryFreeClear(paramOut1->data); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + if (type != GET_PARAM_TYPE(param2)) { + SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; + paramOut2->numOfRows = param2->numOfRows; + + paramOut2->columnData = createColumnInfoData(&t, param2->numOfRows); + if (paramOut2->columnData == NULL) { + return terrno; } - paramOut2->orig.data = paramOut2->data; - + code = vectorConvertImpl(param2, paramOut2); if (code) { - taosMemoryFreeClear(paramOut1->data); - taosMemoryFreeClear(paramOut2->data); return code; } } @@ -515,652 +406,387 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p return TSDB_CODE_SUCCESS; } -void vectorMath(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, _mathFunc func) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - bool isNull = false; - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num, .dataInBlock = false}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num, .dataInBlock = false}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; +enum { + VECTOR_DO_CONVERT = 0x1, + VECTOR_UN_CONVERT = 0x2, +}; - if (vectorConvertImpl(pLeft, &leftParam)) { - return; +static int32_t doConvertHelper(SScalarParam* pDest, int32_t* convert, const SScalarParam* pParam, int32_t type) { + SColumnInfoData* pCol = pParam->columnData; + + if (IS_VAR_DATA_TYPE(pCol->info.type)) { + pDest->numOfRows = pParam->numOfRows; + + SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; + pDest->columnData = createColumnInfoData(&t, pParam->numOfRows); + if (pDest->columnData == NULL) { + sclError("malloc %d failed", (int32_t)(pParam->numOfRows * sizeof(double))); + return TSDB_CODE_OUT_OF_MEMORY; } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; + + int32_t code = vectorConvertImpl(pParam, pDest); + if (code != TSDB_CODE_SUCCESS) { + return code; } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; + + *convert = VECTOR_DO_CONVERT; + } else { + *convert = VECTOR_UN_CONVERT; } - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, (*func)(leftv, rightv, &isNull)); - if (isNull) { - sclSetNull(pOut, i); - isNull = false; - } - } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, (*func)(leftv, rightv, &isNull)); - if (isNull) { - sclSetNull(pOut, i); - isNull = false; - } - } - } else if (pRight->num == 1) { - sclMoveParamListData(pRight, 1, 0); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - SET_DOUBLE_VAL(pOut->data, (*func)(leftv, rightv, &isNull)); - if (isNull) { - sclSetNull(pOut, i); - isNull = false; - } - } - } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); + return TSDB_CODE_SUCCESS; } -double mathAdd(double leftv, double rightv, bool *isNull) { - return leftv + rightv; -} +// TODO not correct for descending order scan +static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); -double mathSub(double leftv, double rightv, bool *isNull) { - return leftv - rightv; -} + double *output = (double *)pOutputCol->pData; -double mathMultiply(double leftv, double rightv, bool *isNull) { - return leftv * rightv; -} - -double mathDivide(double leftv, double rightv, bool *isNull) { - double zero = 0; - if (0 == compareDoubleVal(&rightv, &zero)) { - *isNull = true; - return zero; + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, 0); + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } } - - return leftv / rightv; } -double mathRemainder(double leftv, double rightv, bool *isNull) { - double zero = 0; - if (0 == compareDoubleVal(&rightv, &zero)) { - *isNull = true; - return zero; +static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) { + SScalarParam convertParam = {0}; + + int32_t code = doConvertHelper(&convertParam, doConvert, pInput, TSDB_DATA_TYPE_DOUBLE); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return NULL; } - return leftv - ((int64_t)(leftv / rightv)) * rightv; -} - - -void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorMath(pLeft, pRight, pOut, _ord, mathAdd); -} - -void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorMath(pLeft, pRight, pOut, _ord, mathSub); -} - -void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorMath(pLeft, pRight, pOut, _ord, mathMultiply); -} - -void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorMath(pLeft, pRight, pOut, _ord, mathDivide); -} - -void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorMath(pLeft, pRight, pOut, _ord, mathRemainder); -} - -#if 0 -void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num, .dataInBlock = false}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num, .dataInBlock = false}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; - - if (vectorConvertImpl(pLeft, &leftParam)) { - return; - } - pLeft = &leftParam; + if (*doConvert == VECTOR_DO_CONVERT) { + return convertParam.columnData; + } else { + return pInput->columnData; } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; +} + +static void doReleaseVec(SColumnInfoData* pCol, int32_t type) { + if (type == VECTOR_DO_CONVERT) { + colDataDestroy(pCol); + taosMemoryFree(pCol); + } +} + +void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { + SColumnInfoData *pOutputCol = pOut->columnData; + + int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i); } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } } - pRight = &rightParam; + + } else if (pLeft->numOfRows == 1) { + vectorMathAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); } - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); +} + +// TODO not correct for descending order scan +static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = (getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, 0)) * factor; + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } + } +} + +void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { + SColumnInfoData *pOutputCol = pOut->columnData; + + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i); + } + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i); + } else if (pRight->numOfRows == 1) { + vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i); + } + + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); +} + +// TODO not correct for descending order scan +static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) * getVectorDoubleValueFnRight(pRightCol->pData, 0); + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } + } +} + +void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { + SColumnInfoData *pOutputCol = pOut->columnData; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) * getVectorDoubleValueFnRight(pRightCol->pData, i); + } + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathMultiplyHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorMathMultiplyHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); + } + + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); +} + +void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { + SColumnInfoData *pOutputCol = pOut->columnData; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { // check for the 0 value + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) / getVectorDoubleValueFnRight(pRightCol->pData, i); + } + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, 0) / getVectorDoubleValueFnRight(pRightCol->pData, i); + } + pOutputCol->hasNull = pRightCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pRightCol->nullbitmap, BitmapLen(pRight->numOfRows)); + } + } + } else if (pRight->numOfRows == 1) { + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) / getVectorDoubleValueFnRight(pRightCol->pData, 0); + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(pLeft->numOfRows)); + } + } + } + + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); +} + +void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { + SColumnInfoData *pOutputCol = pOut->columnData; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + double zero = 0.0; + + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + if (colDataIsNull_f(pLeftCol->nullbitmap, i) || colDataIsNull_f(pRightCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); continue; } - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, leftv + rightv); - } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, leftv + rightv); - } - } else if (pRight->num == 1) { - sclMoveParamListData(pRight, 1, 0); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); + double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); + double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); + if (compareDoubleVal(&zero, &rx)) { + colDataAppend(pOutputCol, i, NULL, true); continue; } - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - SET_DOUBLE_VAL(pOut->data, leftv + rightv); + *output = lx - ((int64_t)(lx / rx)) * rx; + } + } else if (pLeft->numOfRows == 1) { + double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0); + if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { + if (colDataIsNull_f(pRightCol->nullbitmap, i)) { + colDataAppend(pOutputCol, i, NULL, true); + continue; + } + + double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); + if (compareDoubleVal(&zero, &rx)) { + colDataAppend(pOutputCol, i, NULL, true); + continue; + } + + *output = lx - ((int64_t)(lx / rx)) * rx; + } + } + } else if (pRight->numOfRows == 1) { + double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0); + if (colDataIsNull_f(pRightCol->nullbitmap, 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)) { + colDataAppend(pOutputCol, i, NULL, true); + continue; + } + + double lx = getVectorDoubleValueFnLeft(pRightCol->pData, i); + if (compareDoubleVal(&zero, &lx)) { + colDataAppend(pOutputCol, i, NULL, true); + continue; + } + + *output = lx - ((int64_t)(lx / rx)) * rx; + } } } - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); } -void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; - - if (vectorConvertImpl(pLeft, &leftParam)) { - return; - } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; - } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; - } - - - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeft->type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRight->type); - - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, getVectorDoubleValueFnLeft(pLeft->data, i) - getVectorDoubleValueFnRight(pRight->data, i)); - } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data, 0) - getVectorDoubleValueFnRight(pRight->data,i)); - } - } else if (pRight->num == 1) { - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data,i) - getVectorDoubleValueFnRight(pRight->data,0)); - } - } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); -} -void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; - - if (vectorConvertImpl(pLeft, &leftParam)) { - return; - } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; - } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; - } - - - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeft->type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRight->type); - - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, getVectorDoubleValueFnLeft(pLeft->data, i) * getVectorDoubleValueFnRight(pRight->data, i)); - } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data, 0) * getVectorDoubleValueFnRight(pRight->data,i)); - } - } else if (pRight->num == 1) { - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data,i) * getVectorDoubleValueFnRight(pRight->data,0)); - } - } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); -} - -void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; - - if (vectorConvertImpl(pLeft, &leftParam)) { - return; - } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; - } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; - } - - - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeft->type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRight->type); - - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, getVectorDoubleValueFnLeft(pLeft->data, i) / getVectorDoubleValueFnRight(pRight->data, i)); - } - } else if (pLeft->num == 1) { - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data, 0) / getVectorDoubleValueFnRight(pRight->data,i)); - } - } else if (pRight->num == 1) { - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - SET_DOUBLE_VAL(pOut->data,getVectorDoubleValueFnLeft(pLeft->data,i) / getVectorDoubleValueFnRight(pRight->data,0)); - } - } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); -} - -void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double leftv = 0, rightv = 0; - - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(double)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; - - if (vectorConvertImpl(pLeft, &leftParam)) { - return; - } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(double)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; - } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; - } - - - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeft->type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRight->type); - - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - double v, u = 0.0; - GET_TYPED_DATA(v, double, pRight->type, pRight->data); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, double, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, double, pRight->type, pRight->data); - - SET_DOUBLE_VAL(pOut->data, left - ((int64_t)(left / right)) * right); - } - } else if (pLeft->num == 1) { - double left = getVectorDoubleValueFnLeft(pLeft->data, 0); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - double v, u = 0.0; - GET_TYPED_DATA(v, double, pRight->type, pRight->data); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - sclSetNull(pOut, i); - continue; - } - - double right = getVectorDoubleValueFnRight(pRight->data, i); - SET_DOUBLE_VAL(pOut->data, left - ((int64_t)(left / right)) * right); - } - } else if (pRight->num == 1) { - double right = getVectorDoubleValueFnRight(pRight->data, 0); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - double v, u = 0.0; - GET_TYPED_DATA(v, double, pRight->type, pRight->data); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - sclSetNull(pOut, i); - continue; - } - - double left = getVectorDoubleValueFnLeft(pLeft->data, i); - SET_DOUBLE_VAL(pOut->data, left - ((int64_t)(left / right)) * right); - } - } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); -} - -#endif - void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { +#if 0 int32_t len = pLeft->bytes + pRight->bytes; - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; char *output = (char *)out; - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step, output += len) { + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += len) { char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i); char* right = POINTER_SHIFT(pRight->data, pRight->bytes * i); - if (isNull(left, pLeft->type) || isNull(right, pRight->type)) { + if (isNull(left, pLeftCol->info.type) || isNull(right, pRight->info.type)) { setVardataNull(output, TSDB_DATA_TYPE_BINARY); continue; } @@ -1170,10 +796,10 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t memcpy(varDataVal(output) + varDataLen(left), varDataVal(right), varDataLen(right)); varDataSetLen(output, varDataLen(left) + varDataLen(right)); } - } else if (pLeft->num == 1) { - for (; i >= 0 && i < pRight->num; i += step, output += len) { + } else if (pLeft->numOfRows == 1) { + for (; i >= 0 && i < pRight->numOfRows; i += step, output += len) { char *right = POINTER_SHIFT(pRight->data, pRight->bytes * i); - if (isNull(pLeft->data, pLeft->type) || isNull(right, pRight->type)) { + if (isNull(pLeft->data, pLeftCol->info.type) || isNull(right, pRight->info.type)) { setVardataNull(output, TSDB_DATA_TYPE_BINARY); continue; } @@ -1182,10 +808,10 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t memcpy(varDataVal(output) + varDataLen(pLeft->data), varDataVal(right), varDataLen(right)); varDataSetLen(output, varDataLen(pLeft->data) + varDataLen(right)); } - } else if (pRight->num == 1) { - for (; i >= 0 && i < pLeft->num; i += step, output += len) { + } else if (pRight->numOfRows == 1) { + for (; i >= 0 && i < pLeft->numOfRows; i += step, output += len) { char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i); - if (isNull(left, pLeft->type) || isNull(pRight->data, pRight->type)) { + if (isNull(left, pLeftCol->info.type) || isNull(pRight->data, pRight->info.type)) { SET_DOUBLE_NULL(output); continue; } @@ -1195,257 +821,182 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t varDataSetLen(output, varDataLen(left) + varDataLen(pRight->data)); } } +#endif } +static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); + + double *output = (double *)pOutputCol->pData; + + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) & getVectorBigintValueFnRight(pRightCol->pData, 0); + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } + } +} void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; + SColumnInfoData *pOutputCol = pOut->columnData; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - int64_t leftv = 0, rightv = 0; - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(int64_t)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); - if (vectorConvertImpl(pLeft, &leftParam)) { - return; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); + + int64_t *output = (int64_t *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) & getVectorBigintValueFnRight(pRightCol->pData, i); } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(int64_t)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] & pRightCol->nullbitmap[j]; + } } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; + + } else if (pLeft->numOfRows == 1) { + vectorBitAndHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorBitAndHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); } + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); +} - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeft->type); - _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRight->type); +static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } + int64_t *output = (int64_t *)pOutputCol->pData; - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - SET_BIGINT_VAL(pOut->data, leftv & rightv); + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + // TODO set numOfRows NULL value + } else { + int64_t rx = getVectorBigintValueFnRight(pRightCol->pData, 0); + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) | rx; } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - SET_BIGINT_VAL(pOut->data, leftv & rightv); - } - } else if (pRight->num == 1) { - sclMoveParamListData(pRight, 1, 0); - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - - SET_BIGINT_VAL(pOut->data, leftv & rightv); + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); } } - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); } void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; + SColumnInfoData *pOutputCol = pOut->columnData; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - int64_t leftv = 0, rightv = 0; - SScalarParam leftParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pLeft->num}; - SScalarParam rightParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pRight->num}; - if (IS_VAR_DATA_TYPE(pLeft->type)) { - leftParam.data = taosMemoryCalloc(leftParam.num, sizeof(int64_t)); - if (NULL == leftParam.data) { - sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double))); - return; - } - leftParam.orig.data = leftParam.data; + int32_t leftConvert = 0, rightConvert = 0; + SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); - if (vectorConvertImpl(pLeft, &leftParam)) { - return; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); + + int64_t *output = (int64_t *)pOutputCol->pData; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) | getVectorBigintValueFnRight(pRightCol->pData, i); } - pLeft = &leftParam; - } - if (IS_VAR_DATA_TYPE(pRight->type)) { - rightParam.data = taosMemoryCalloc(rightParam.num, sizeof(int64_t)); - if (NULL == rightParam.data) { - sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double))); - sclFreeParam(&leftParam); - return; + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } } - rightParam.orig.data = rightParam.data; - - if (vectorConvertImpl(pRight, &rightParam)) { - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); - return; - } - pRight = &rightParam; + } else if (pLeft->numOfRows == 1) { + vectorBitOrHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorBitOrHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); } - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeft->type); - _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRight->type); - - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - SET_BIGINT_VAL(pOut->data, leftv | rightv); - } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - SET_BIGINT_VAL(pOut->data, leftv | rightv); - } - } else if (pRight->num == 1) { - sclMoveParamListData(pRight, 1, 0); - GET_TYPED_DATA(rightv, int64_t, pRight->type, pRight->data); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); - continue; - } - - GET_TYPED_DATA(leftv, int64_t, pLeft->type, pLeft->data); - - SET_BIGINT_VAL(pOut->data, leftv | rightv); - } - } - - - sclFreeParam(&leftParam); - sclFreeParam(&rightParam); + doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pRightCol, rightConvert); } - void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - __compar_fn_t fp = filterGetCompFunc(pLeft->type, optr); - bool res = false; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; + __compar_fn_t fp = filterGetCompFunc(GET_PARAM_TYPE(pLeft), optr); - if (pLeft->num == pRight->num) { - for (; i < pRight->num && i >= 0; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + + if (pRight->pHashFilter != NULL) { + for (; i >= 0 && i < pLeft->numOfRows; i += step) { + if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) /*|| + colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) { continue; } - res = filterDoCompare(fp, optr, pLeft->data, pRight->data); - - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); + char *pLeftData = colDataGetData(pLeft->columnData, i); + bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter); + colDataAppend(pOut->columnData, i, (char *)&res, false); } - } else if (pLeft->num == 1) { - sclMoveParamListData(pLeft, 1, 0); - - for (; i >= 0 && i < pRight->num; i += step) { - sclMoveParamListData(pRight, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, 0) || sclIsNull(pRight, i)) { - sclSetNull(pOut, i); - continue; + return; + } + + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step) { + if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) || + colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)) { + continue; // TODO set null or ignore } - - res = filterDoCompare(fp, optr, pLeft->data, pRight->data); - - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); + char *pLeftData = colDataGetData(pLeft->columnData, i); + char *pRightData = colDataGetData(pRight->columnData, i); + bool res = filterDoCompare(fp, optr, pLeftData, pRightData); + colDataAppend(pOut->columnData, i, (char *)&res, false); } - } else if (pRight->num == 1) { - sclMoveParamListData(pRight, 1, 0); - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i) || sclIsNull(pRight, 0)) { - sclSetNull(pOut, i); + } else if (pRight->numOfRows == 1) { + char *pRightData = colDataGetData(pRight->columnData, 0); + ASSERT(pLeft->pHashFilter == NULL); + + for (; i >= 0 && i < pLeft->numOfRows; i += step) { + if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL) /*|| + colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) { continue; } - res = filterDoCompare(fp, optr, pLeft->data, pRight->data); + char *pLeftData = colDataGetData(pLeft->columnData, i); + bool res = filterDoCompare(fp, optr, pLeftData, pRightData); + colDataAppend(pOut->columnData, i, (char *)&res, false); + } + } else if (pLeft->numOfRows == 1) { + char *pLeftData = colDataGetData(pLeft->columnData, 0); - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); + for (; i >= 0 && i < pRight->numOfRows; i += step) { + if (colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL) /*|| + colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/) { + continue; + } + + char *pRightData = colDataGetData(pLeft->columnData, i); + bool res = filterDoCompare(fp, optr, pLeftData, pRightData); + colDataAppend(pOut->columnData, i, (char *)&res, false); } } } @@ -1459,21 +1010,19 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut SScalarParam *param1 = NULL; SScalarParam *param2 = NULL; - int32_t type = 0; - if (pLeftOut.type) { + if (pLeftOut.columnData != NULL) { param1 = &pLeftOut; } else { param1 = pLeft; } - if (pRightOut.type) { + if (pRightOut.columnData != NULL) { param2 = &pRightOut; } else { param2 = pRight; } vectorCompareImpl(param1, param2, pOut, _ord, optr); - sclFreeParam(&pLeftOut); sclFreeParam(&pRightOut); } @@ -1527,63 +1076,44 @@ void vectorNotMatch(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOu } void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - bool res = false; - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i)) { - res = true; - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); - continue; + for(int32_t i = 0; i < pLeft->numOfRows; ++i) { + int8_t v = 0; + if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL)) { + v = 1; } - - res = false; - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); + colDataAppend(pOut->columnData, i, (char*) &v, false); } + + pOut->numOfRows = pLeft->numOfRows; } void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - bool res = false; - - for (; i >= 0 && i < pLeft->num; i += step) { - sclMoveParamListData(pLeft, 1, i); - sclMoveParamListData(pOut, 1, i); - - if (sclIsNull(pLeft, i)) { - res = false; - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); - continue; + for(int32_t i = 0; i < pLeft->numOfRows; ++i) { + int8_t v = 1; + if (colDataIsNull(pLeft->columnData, pLeft->numOfRows, i, NULL)) { + v = 0; } - - res = true; - SET_TYPED_DATA(pOut->data, TSDB_DATA_TYPE_BOOL, res); + colDataAppend(pOut->columnData, i, (char*) &v, false); } - + pOut->numOfRows = pLeft->numOfRows; } void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { vectorConvertImpl(pLeft, pOut); } - _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { switch (binFunctionId) { case OP_TYPE_ADD: - return vectorAdd; + return vectorMathAdd; case OP_TYPE_SUB: - return vectorSub; + return vectorMathSub; case OP_TYPE_MULTI: - return vectorMultiply; + return vectorMathMultiply; case OP_TYPE_DIV: - return vectorDivide; + return vectorMathDivide; case OP_TYPE_MOD: - return vectorRemainder; + return vectorMathRemainder; case OP_TYPE_GREATER_THAN: return vectorGreater; case OP_TYPE_GREATER_EQUAL: @@ -1622,6 +1152,4 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { assert(0); return NULL; } -} - - +} \ No newline at end of file diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index f0025de6b8..b3211babf1 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -269,7 +269,7 @@ TEST(constantTest, bigint_add_bigint) { ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); SValueNode *v = (SValueNode *)res; ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_EQ(v->datum.d, (scltLeftV + scltRightV)); + ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV)); nodesDestroyNode(res); } @@ -285,7 +285,7 @@ TEST(constantTest, double_sub_bigint) { ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); SValueNode *v = (SValueNode *)res; ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_EQ(v->datum.d, (scltLeftVd - scltRightV)); + ASSERT_FLOAT_EQ(v->datum.d, (scltLeftVd - scltRightV)); nodesDestroyNode(res); } @@ -340,7 +340,6 @@ TEST(constantTest, int_or_binary) { nodesDestroyNode(res); } - TEST(constantTest, int_greater_double) { SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); @@ -479,8 +478,6 @@ TEST(constantTest, int_not_equal_smallint2) { nodesDestroyNode(res); } - - TEST(constantTest, int_in_smallint1) { scltInitLogFile(); @@ -851,7 +848,6 @@ TEST(constantTest, int_add_int_is_true2) { nodesDestroyNode(res); } - TEST(constantTest, int_greater_int_is_true1) { SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; int32_t leftv = 1, rightv = 1; @@ -913,8 +909,6 @@ TEST(constantTest, greater_and_lower) { nodesDestroyNode(res); } - - TEST(columnTest, smallint_value_add_int_column) { scltInitLogFile(); @@ -967,7 +961,6 @@ TEST(columnTest, bigint_column_multi_binary_column) { scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); scltMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - SArray *blockList = taosArrayInit(1, POINTER_BYTES); taosArrayPush(blockList, &src); SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); @@ -1271,7 +1264,6 @@ TEST(columnTest, binary_column_like_binary) { nodesDestroyNode(opNode); } - TEST(columnTest, binary_column_is_true) { SNode *pLeft = NULL, *opNode = NULL; char leftv[5][5]= {0}; @@ -1286,7 +1278,7 @@ TEST(columnTest, binary_column_is_true) { } int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, leftv); scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL); @@ -1471,23 +1463,26 @@ void scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32_t } } - input->type = type; - input->num = num; - input->data = taosMemoryCalloc(num, bytes); - input->bytes = bytes; + input->columnData = (SColumnInfoData*) taosMemoryCalloc(1, sizeof(SColumnInfoData)); + input->numOfRows = num; + + input->columnData->info = createColumnInfo(0, type, bytes); + blockDataEnsureColumnCapacity(input->columnData, num); + if (setVal) { for (int32_t i = 0; i < num; ++i) { - memcpy(input->data + i * bytes, pVal, bytes); + colDataAppend(input->columnData, i, (const char*) pVal, false); } } else { - memset(input->data, 0, num * bytes); +// memset(input->data, 0, num * bytes); } *pInput = input; } void scltDestroyDataBlock(SScalarParam *pInput) { - taosMemoryFree(pInput->data); + colDataDestroy(pInput->columnData); + taosMemoryFree(pInput->columnData); taosMemoryFree(pInput); } @@ -1500,25 +1495,25 @@ TEST(ScalarFunctionTest, absFunction_constant) { //TINYINT int8_t val_tinyint = 10; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), val_tinyint); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); val_tinyint = -10; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), -val_tinyint); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -val_tinyint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1526,25 +1521,25 @@ TEST(ScalarFunctionTest, absFunction_constant) { //SMALLINT int16_t val_smallint = 10; type = TSDB_DATA_TYPE_SMALLINT; - scltMakeDataBlock(&pInput, type, &val_smallint, 1, true); + scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)pOutput->data + i), val_smallint); + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); val_smallint = -10; - scltMakeDataBlock(&pInput, type, &val_smallint, 1, true); + scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)pOutput->data + i), -val_smallint); + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -val_smallint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1552,25 +1547,25 @@ TEST(ScalarFunctionTest, absFunction_constant) { //INT int32_t val_int = 10; type = TSDB_DATA_TYPE_INT; - scltMakeDataBlock(&pInput, type, &val_int, 1, true); + scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)pOutput->data + i), val_int); + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); val_int = -10; - scltMakeDataBlock(&pInput, type, &val_int, 1, true); + scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)pOutput->data + i), -val_int); + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -val_int); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1578,13 +1573,13 @@ TEST(ScalarFunctionTest, absFunction_constant) { //BIGINT int64_t val_bigint = 10; type = TSDB_DATA_TYPE_BIGINT; - scltMakeDataBlock(&pInput, type, &val_bigint, 1, true); + scltMakeDataBlock(&pInput, type, &val_bigint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)pOutput->data + i), val_bigint); + ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), val_bigint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1596,7 +1591,7 @@ TEST(ScalarFunctionTest, absFunction_constant) { code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)pOutput->data + i), -val_bigint); + ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), -val_bigint); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1604,29 +1599,29 @@ TEST(ScalarFunctionTest, absFunction_constant) { //FLOAT float val_float = 10.15; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("float before ABS:%f\n", *(float *)pInput->data); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), val_float); - PRINTF("float after ABS:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); val_float = -10.15; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("float before ABS:%f\n", *(float *)pInput->data); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), -val_float); - PRINTF("float after ABS:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -val_float); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1634,13 +1629,13 @@ TEST(ScalarFunctionTest, absFunction_constant) { //DOUBLE double val_double = 10.15; type = TSDB_DATA_TYPE_DOUBLE; - scltMakeDataBlock(&pInput, type, &val_double, 1, true); + scltMakeDataBlock(&pInput, type, &val_double, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), val_double); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1652,7 +1647,7 @@ TEST(ScalarFunctionTest, absFunction_constant) { code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), -val_double); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -val_double); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1671,15 +1666,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint + i; - PRINTF("tiny_int before ABS:%d\n", *((int8_t *)pInput->data + i)); + int8_t v = val_tinyint + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("tiny_int before ABS:%d\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), val_tinyint + i); - PRINTF("tiny_int after ABS:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint + i); + PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1688,15 +1684,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint + i; - PRINTF("tiny_int before ABS:%d\n", *((int8_t *)pInput->data + i)); + int8_t v = val_tinyint + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("tiny_int before ABS:%d\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), -(val_tinyint + i)); - PRINTF("tiny_int after ABS:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -(val_tinyint + i)); + PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1707,16 +1704,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int16_t *)pInput->data + i) = val_smallint + i; - PRINTF("small_int before ABS:%d\n", *((int16_t *)pInput->data + i)); + int16_t v = val_smallint + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("small_int before ABS:%d\n", v); } - code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)pOutput->data + i), val_smallint + i); - PRINTF("small_int after ABS:%d\n", *((int16_t *)pOutput->data + i)); + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint + i); + PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1725,15 +1722,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int16_t *)pInput->data + i) = val_smallint + i; - PRINTF("small_int before ABS:%d\n", *((int16_t *)pInput->data + i)); + int16_t v = val_smallint + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("small_int before ABS:%d\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)pOutput->data + i), -(val_smallint + i)); - PRINTF("small_int after ABS:%d\n", *((int16_t *)pOutput->data + i)); + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -(val_smallint + i)); + PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1744,16 +1742,17 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int32_t *)pInput->data + i) = val_int + i; - PRINTF("int before ABS:%d\n", *((int32_t *)pInput->data + i)); + int32_t v = val_int + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("int before ABS:%d\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)pOutput->data + i), val_int + i); - PRINTF("int after ABS:%d\n", *((int32_t *)pOutput->data + i)); + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int + i); + PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1762,15 +1761,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int32_t *)pInput->data + i) = val_int + i; - PRINTF("int before ABS:%d\n", *((int32_t *)pInput->data + i)); + int32_t v = val_int + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("int before ABS:%d\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)pOutput->data + i), -(val_int + i)); - PRINTF("int after ABS:%d\n", *((int32_t *)pOutput->data + i)); + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -(val_int + i)); + PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1781,15 +1781,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float + i; - PRINTF("float before ABS:%f\n", *((float *)pInput->data + i)); + float v = val_float + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("float before ABS:%f\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), val_float + i); - PRINTF("float after ABS:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float + i); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1798,15 +1799,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float + i; - PRINTF("float before ABS:%f\n", *((float *)pInput->data + i)); + float v = val_float + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("float before ABS:%f\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), -(val_float + i)); - PRINTF("float after ABS:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -(val_float + i)); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1817,15 +1819,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((double *)pInput->data + i) = val_double + i; - PRINTF("double before ABS:%f\n", *((double *)pInput->data + i)); + double v = val_double + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("double before ABS:%f\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), val_double + i); - PRINTF("double after ABS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double + i); + PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1834,15 +1837,16 @@ TEST(ScalarFunctionTest, absFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((double *)pInput->data + i) = val_double + i; - PRINTF("double before ABS:%f\n", *((double *)pInput->data + i)); + double v = val_double + i; + colDataAppend(pInput->columnData, i, (const char*) &v, false); + PRINTF("double before ABS:%f\n", v); } code = absFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), -(val_double + i)); - PRINTF("double after ABS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -(val_double + i)); + PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -1860,15 +1864,15 @@ TEST(ScalarFunctionTest, sinFunction_constant) { //TINYINT int8_t val_tinyint = 13; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before SIN:%d\n", *((int8_t *)pInput->data)); code = sinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after SIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1876,15 +1880,15 @@ TEST(ScalarFunctionTest, sinFunction_constant) { //FLOAT float val_float = 13.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before SIN:%f\n", *((float *)pInput->data)); code = sinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after SIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -1907,15 +1911,15 @@ TEST(ScalarFunctionTest, sinFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before SIN:%d\n", *((int8_t *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); + PRINTF("tiny_int before SIN:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); } code = sinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after SIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1926,15 +1930,15 @@ TEST(ScalarFunctionTest, sinFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before SIN:%f\n", *((float *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); + PRINTF("float before SIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = sinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after SIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -1952,15 +1956,15 @@ TEST(ScalarFunctionTest, cosFunction_constant) { //TINYINT int8_t val_tinyint = 13; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before COS:%d\n", *((int8_t *)pInput->data)); code = cosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after COS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -1968,15 +1972,15 @@ TEST(ScalarFunctionTest, cosFunction_constant) { //FLOAT float val_float = 13.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before COS:%f\n", *((float *)pInput->data)); code = cosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after COS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -1997,15 +2001,15 @@ TEST(ScalarFunctionTest, cosFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before COS:%d\n", *((int8_t *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); + PRINTF("tiny_int before COS:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); } code = cosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after COS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2016,15 +2020,15 @@ TEST(ScalarFunctionTest, cosFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before COS:%f\n", *((float *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); + PRINTF("float before COS:%f\n", *(float *)colDataGetData(pInput->columnData, i)); } code = cosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after COS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2042,15 +2046,15 @@ TEST(ScalarFunctionTest, tanFunction_constant) { //TINYINT int8_t val_tinyint = 13; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before TAN:%d\n", *((int8_t *)pInput->data)); code = tanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after TAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2058,15 +2062,15 @@ TEST(ScalarFunctionTest, tanFunction_constant) { //FLOAT float val_float = 13.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before TAN:%f\n", *((float *)pInput->data)); code = tanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after TAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2087,15 +2091,15 @@ TEST(ScalarFunctionTest, tanFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before TAN:%d\n", *((int8_t *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); + PRINTF("tiny_int before TAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = tanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after TAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2106,15 +2110,15 @@ TEST(ScalarFunctionTest, tanFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before TAN:%f\n", *((float *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); + PRINTF("float before TAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = tanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after TAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2132,15 +2136,15 @@ TEST(ScalarFunctionTest, asinFunction_constant) { //TINYINT int8_t val_tinyint = 1; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)pInput->data)); code = asinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after ASIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2148,15 +2152,15 @@ TEST(ScalarFunctionTest, asinFunction_constant) { //FLOAT float val_float = 1.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before ASIN:%f\n", *((float *)pInput->data)); code = asinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after ASIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2178,15 +2182,15 @@ TEST(ScalarFunctionTest, asinFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)pInput->data + i)); + colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); + PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = asinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after ASIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2197,15 +2201,15 @@ TEST(ScalarFunctionTest, asinFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before ASIN:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ASIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = asinFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after ASIN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2223,15 +2227,15 @@ TEST(ScalarFunctionTest, acosFunction_constant) { //TINYINT int8_t val_tinyint = 1; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)pInput->data)); code = acosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after ACOS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2239,15 +2243,15 @@ TEST(ScalarFunctionTest, acosFunction_constant) { //FLOAT float val_float = 1.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before ACOS:%f\n", *((float *)pInput->data)); code = acosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after ACOS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2268,15 +2272,15 @@ TEST(ScalarFunctionTest, acosFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = acosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after ACOS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2287,15 +2291,15 @@ TEST(ScalarFunctionTest, acosFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before ACOS:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ACOS:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = acosFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after ACOS:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2313,15 +2317,15 @@ TEST(ScalarFunctionTest, atanFunction_constant) { //TINYINT int8_t val_tinyint = 1; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)pInput->data)); code = atanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after ATAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2329,15 +2333,15 @@ TEST(ScalarFunctionTest, atanFunction_constant) { //FLOAT float val_float = 1.00; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before ATAN:%f\n", *((float *)pInput->data)); code = atanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after ATAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2358,15 +2362,15 @@ TEST(ScalarFunctionTest, atanFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = atanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after ATAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2377,15 +2381,15 @@ TEST(ScalarFunctionTest, atanFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before ATAN:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ATAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = atanFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after ATAN:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2402,15 +2406,15 @@ TEST(ScalarFunctionTest, ceilFunction_constant) { //TINYINT int8_t val_tinyint = 10; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)pInput->data)); code = ceilFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), (int8_t)result); - PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2418,15 +2422,15 @@ TEST(ScalarFunctionTest, ceilFunction_constant) { //FLOAT float val_float = 9.5; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("float before CEIL:%f\n", *((float *)pInput->data)); code = ceilFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), (float)result); - PRINTF("float after CEIL:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2446,15 +2450,15 @@ TEST(ScalarFunctionTest, ceilFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = ceilFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), result[i]); - PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2465,15 +2469,15 @@ TEST(ScalarFunctionTest, ceilFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before CEIL:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before CEIL:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = ceilFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), result[i]); - PRINTF("float after CEIL:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2490,15 +2494,15 @@ TEST(ScalarFunctionTest, floorFunction_constant) { //TINYINT int8_t val_tinyint = 10; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)pInput->data)); code = floorFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), (int8_t)result); - PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2506,15 +2510,15 @@ TEST(ScalarFunctionTest, floorFunction_constant) { //FLOAT float val_float = 10.5; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("float before FLOOR:%f\n", *((float *)pInput->data)); code = floorFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), (float)result); - PRINTF("float after FLOOR:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2534,15 +2538,15 @@ TEST(ScalarFunctionTest, floorFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = floorFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), result[i]); - PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2553,15 +2557,15 @@ TEST(ScalarFunctionTest, floorFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before FLOOR:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before FLOOR:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = floorFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), result[i]); - PRINTF("float after FLOOR:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2578,15 +2582,15 @@ TEST(ScalarFunctionTest, roundFunction_constant) { //TINYINT int8_t val_tinyint = 10; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)pInput->data)); code = roundFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), (int8_t)result); - PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2594,15 +2598,15 @@ TEST(ScalarFunctionTest, roundFunction_constant) { //FLOAT float val_float = 9.5; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); PRINTF("float before ROUND:%f\n", *((float *)pInput->data)); code = roundFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), (float)result); - PRINTF("float after ROUND:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2622,15 +2626,15 @@ TEST(ScalarFunctionTest, roundFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = roundFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)pOutput->data + i), result[i]); - PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)pOutput->data + i)); + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2641,15 +2645,15 @@ TEST(ScalarFunctionTest, roundFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, type, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before ROUND:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ROUND:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = roundFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)pOutput->data + i), result[i]); - PRINTF("float after ROUND:%f\n", *((float *)pOutput->data + i)); + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2667,15 +2671,15 @@ TEST(ScalarFunctionTest, sqrtFunction_constant) { //TINYINT int8_t val_tinyint = 25; type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, 1, true); + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)pInput->data)); code = sqrtFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after SQRT:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2683,15 +2687,15 @@ TEST(ScalarFunctionTest, sqrtFunction_constant) { //FLOAT float val_float = 25.0; type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, 1, true); + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); PRINTF("float before SQRT:%f\n", *((float *)pInput->data)); code = sqrtFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after SQRT:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2712,15 +2716,15 @@ TEST(ScalarFunctionTest, sqrtFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput->data + i) = val_tinyint[i]; - PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)pInput->data + i)); + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); } code = sqrtFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after SQRT:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); scltDestroyDataBlock(pOutput); @@ -2731,15 +2735,15 @@ TEST(ScalarFunctionTest, sqrtFunction_column) { scltMakeDataBlock(&pInput, type, 0, rowNum, false); scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput->data + i) = val_float[i]; - PRINTF("float before SQRT:%f\n", *((float *)pInput->data + i)); + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before SQRT:%f\n", *((float *)colDataGetData(pInput->columnData, i))); } code = sqrtFunction(pInput, 1, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after SQRT:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(pInput); @@ -2760,7 +2764,7 @@ TEST(ScalarFunctionTest, logFunction_constant) { int8_t val_tinyint[] = {27, 3}; type = TSDB_DATA_TYPE_TINYINT; for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_tinyint[i], 1, true); + scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); pInput[i] = *input[i]; } scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2770,8 +2774,8 @@ TEST(ScalarFunctionTest, logFunction_constant) { code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2781,7 +2785,7 @@ TEST(ScalarFunctionTest, logFunction_constant) { float val_float[] = {64.0, 4.0}; type = TSDB_DATA_TYPE_FLOAT; for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_float[i], 1, true); + scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); pInput[i] = *input[i]; } scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2791,8 +2795,8 @@ TEST(ScalarFunctionTest, logFunction_constant) { code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2801,9 +2805,9 @@ TEST(ScalarFunctionTest, logFunction_constant) { //TINYINT AND FLOAT int8_t param0 = 64; float param1 = 4.0; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, 1, true); + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); pInput[0] = *input[0]; - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, 1, true); + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); pInput[1] = *input[1]; scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2812,8 +2816,8 @@ TEST(ScalarFunctionTest, logFunction_constant) { code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int,float after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); @@ -2839,7 +2843,8 @@ TEST(ScalarFunctionTest, logFunction_column) { scltMakeDataBlock(&input[i], type, 0, rowNum, false); pInput[i] = *input[i]; for (int32_t j = 0; j < rowNum; ++j) { - *((int8_t *)pInput[i].data + j) = val_tinyint[i][j]; + colDataAppend(pInput[i].columnData, j, (const char*) &val_tinyint[i][j], false); + } PRINTF("tiny_int before LOG:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), *((int8_t *)pInput[i].data + 1), @@ -2850,8 +2855,8 @@ TEST(ScalarFunctionTest, logFunction_column) { code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2864,19 +2869,19 @@ TEST(ScalarFunctionTest, logFunction_column) { scltMakeDataBlock(&input[i], type, 0, rowNum, false); pInput[i] = *input[i]; for (int32_t j = 0; j < rowNum; ++j) { - *((float *)pInput[i].data + j) = val_float[i][j]; + colDataAppend(pInput[i].columnData, j, (const char*) &val_float[i][j], false); } - PRINTF("float before LOG:%f,%f,%f\n", *((float *)pInput[i].data + 0), - *((float *)pInput[i].data + 1), - *((float *)pInput[i].data + 2)); + PRINTF("float before LOG:%f,%f,%f\n", *((float *)colDataGetData(pInput[i], 0)), + *((float *)colDataGetData(pInput[i], 1)), + *((float *)colDataGetData(pInput[i], 2))); } scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2888,12 +2893,14 @@ TEST(ScalarFunctionTest, logFunction_column) { scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); pInput[0] = *input[0]; for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput[0].data + i) = param0[i]; + colDataAppend(pInput[0].columnData, i, (const char*) ¶m0[i], false); + } scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); pInput[1] = *input[1]; for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput[1].data + i) = param1[i]; + colDataAppend(pInput[1].columnData, i, (const char*) ¶m1[i], false); + } PRINTF("tiny_int, float before LOG:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), *((float *)pInput[1].data + 0), *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), @@ -2903,8 +2910,8 @@ TEST(ScalarFunctionTest, logFunction_column) { code = logFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int,float after LOG:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); @@ -2927,7 +2934,7 @@ TEST(ScalarFunctionTest, powFunction_constant) { int8_t val_tinyint[] = {2, 4}; type = TSDB_DATA_TYPE_TINYINT; for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_tinyint[i], 1, true); + scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); pInput[i] = *input[i]; } scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2937,8 +2944,8 @@ TEST(ScalarFunctionTest, powFunction_constant) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2948,7 +2955,7 @@ TEST(ScalarFunctionTest, powFunction_constant) { float val_float[] = {2.0, 4.0}; type = TSDB_DATA_TYPE_FLOAT; for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_float[i], 1, true); + scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); pInput[i] = *input[i]; } scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2958,8 +2965,8 @@ TEST(ScalarFunctionTest, powFunction_constant) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("float after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -2968,9 +2975,9 @@ TEST(ScalarFunctionTest, powFunction_constant) { //TINYINT AND FLOAT int8_t param0 = 2; float param1 = 4.0; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, 1, true); + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); pInput[0] = *input[0]; - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, 1, true); + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); pInput[1] = *input[1]; scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); @@ -2979,8 +2986,8 @@ TEST(ScalarFunctionTest, powFunction_constant) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result); - PRINTF("tiny_int,float after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); @@ -3006,7 +3013,8 @@ TEST(ScalarFunctionTest, powFunction_column) { scltMakeDataBlock(&input[i], type, 0, rowNum, false); pInput[i] = *input[i]; for (int32_t j = 0; j < rowNum; ++j) { - *((int8_t *)pInput[i].data + j) = val_tinyint[i][j]; + colDataAppend(pInput[i].columnData, i, (const char*) &val_tinyint[i][j], false); + } PRINTF("tiny_int before POW:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), *((int8_t *)pInput[i].data + 1), @@ -3017,8 +3025,8 @@ TEST(ScalarFunctionTest, powFunction_column) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); @@ -3032,7 +3040,7 @@ TEST(ScalarFunctionTest, powFunction_column) { scltMakeDataBlock(&input[i], type, 0, rowNum, false); pInput[i] = *input[i]; for (int32_t j = 0; j < rowNum; ++j) { - *((float *)pInput[i].data + j) = val_float[i][j]; + colDataAppend(pInput[i].columnData, j, (const char*) &val_float[i][j], false); } PRINTF("float before POW:%f,%f,%f\n", *((float *)pInput[i].data + 0), *((float *)pInput[i].data + 1), @@ -3043,8 +3051,8 @@ TEST(ScalarFunctionTest, powFunction_column) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("float after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); scltDestroyDataBlock(input[1]); @@ -3056,12 +3064,13 @@ TEST(ScalarFunctionTest, powFunction_column) { scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); pInput[0] = *input[0]; for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)pInput[0].data + i) = param0[i]; + colDataAppend(pInput[0].columnData, i, (const char*) ¶m0[i], false); + } scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); pInput[1] = *input[1]; for (int32_t i = 0; i < rowNum; ++i) { - *((float *)pInput[1].data + i) = param1[i]; + colDataAppend(pInput[1].columnData, i, (const char*) ¶m1[i], false); } PRINTF("tiny_int, float before POW:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), *((float *)pInput[1].data + 0), *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), @@ -3071,8 +3080,8 @@ TEST(ScalarFunctionTest, powFunction_column) { code = powFunction(pInput, 2, pOutput); ASSERT_EQ(code, TSDB_CODE_SUCCESS); for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)pOutput->data + i), result[i]); - PRINTF("tiny_int,float after POW:%f\n", *((double *)pOutput->data + i)); + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); } scltDestroyDataBlock(input[0]); diff --git a/source/libs/stream/src/tstream.c b/source/libs/stream/src/tstream.c index 028e310a25..70651840f7 100644 --- a/source/libs/stream/src/tstream.c +++ b/source/libs/stream/src/tstream.c @@ -16,6 +16,86 @@ #include "tstream.h" #include "executor.h" +static int32_t streamBuildDispatchMsg(SStreamTask* pTask, SArray* data, SRpcMsg* pMsg, SEpSet** ppEpSet) { + SStreamTaskExecReq req = { + .streamId = pTask->streamId, + .data = data, + }; + + int32_t tlen = sizeof(SMsgHead) + tEncodeSStreamTaskExecReq(NULL, &req); + void* buf = rpcMallocCont(tlen); + + if (buf == NULL) { + return -1; + } + if (pTask->dispatchType == TASK_DISPATCH__INPLACE) { + ((SMsgHead*)buf)->vgId = 0; + req.taskId = pTask->inplaceDispatcher.taskId; + + } else if (pTask->dispatchType == TASK_DISPATCH__FIXED) { + ((SMsgHead*)buf)->vgId = htonl(pTask->fixedEpDispatcher.nodeId); + *ppEpSet = &pTask->fixedEpDispatcher.epSet; + req.taskId = pTask->fixedEpDispatcher.taskId; + + } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { + // TODO fix tbname issue + char ctbName[TSDB_TABLE_FNAME_LEN + 22]; + // all groupId must be the same in an array + SSDataBlock* pBlock = taosArrayGet(data, 0); + sprintf(ctbName, "%s:%ld", pTask->shuffleDispatcher.stbFullName, pBlock->info.groupId); + + // TODO: get hash function by hashMethod + + // get groupId, compute hash value + uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName)); + // + // get node + // TODO: optimize search process + SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; + int32_t sz = taosArrayGetSize(vgInfo); + int32_t nodeId = 0; + for (int32_t i = 0; i < sz; i++) { + SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i); + if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) { + nodeId = pVgInfo->vgId; + req.taskId = pVgInfo->taskId; + *ppEpSet = &pVgInfo->epSet; + break; + } + } + ASSERT(nodeId != 0); + ((SMsgHead*)buf)->vgId = htonl(nodeId); + } + + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + tEncodeSStreamTaskExecReq(&abuf, &req); + + pMsg->pCont = buf; + pMsg->contLen = tlen; + pMsg->code = 0; + pMsg->msgType = pTask->dispatchMsgType; + /*pMsg->noResp = 1;*/ + + return 0; +} + +static int32_t streamShuffleDispatch(SStreamTask* pTask, SMsgCb* pMsgCb, SHashObj* data) { + void* pIter = NULL; + while (1) { + pIter = taosHashIterate(data, pIter); + if (pIter == NULL) return 0; + SArray* pData = *(SArray**)pIter; + SRpcMsg dispatchMsg = {0}; + SEpSet* pEpSet; + if (streamBuildDispatchMsg(pTask, pData, &dispatchMsg, &pEpSet) < 0) { + ASSERT(0); + return -1; + } + tmsgSendReq(pMsgCb, pEpSet, &dispatchMsg); + } + return 0; +} + int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, int32_t inputType, int32_t workId) { SArray* pRes = NULL; // source @@ -83,28 +163,13 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in } // dispatch + if (pTask->dispatchType == TASK_DISPATCH__INPLACE) { - SStreamTaskExecReq req = { - .streamId = pTask->streamId, - .taskId = pTask->taskId, - .data = pRes, - }; - - int32_t tlen = sizeof(SMsgHead) + tEncodeSStreamTaskExecReq(NULL, &req); - void* buf = rpcMallocCont(tlen); - - if (buf == NULL) { + SRpcMsg dispatchMsg = {0}; + if (streamBuildDispatchMsg(pTask, pRes, &dispatchMsg, NULL) < 0) { + ASSERT(0); return -1; } - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - tEncodeSStreamTaskExecReq(&abuf, &req); - - SRpcMsg dispatchMsg = { - .pCont = buf, - .contLen = tlen, - .code = 0, - .msgType = pTask->dispatchMsgType, - }; int32_t qType; if (pTask->dispatchMsgType == TDMT_VND_TASK_PIPE_EXEC || pTask->dispatchMsgType == TDMT_SND_TASK_PIPE_EXEC) { @@ -120,36 +185,38 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in tmsgPutToQueue(pMsgCb, qType, &dispatchMsg); } else if (pTask->dispatchType == TASK_DISPATCH__FIXED) { - SStreamTaskExecReq req = { - .streamId = pTask->streamId, - .taskId = pTask->fixedEpDispatcher.taskId, - .data = pRes, - }; - - int32_t tlen = sizeof(SMsgHead) + tEncodeSStreamTaskExecReq(NULL, &req); - void* buf = rpcMallocCont(tlen); - - if (buf == NULL) { + SRpcMsg dispatchMsg = {0}; + SEpSet* pEpSet = NULL; + if (streamBuildDispatchMsg(pTask, pRes, &dispatchMsg, &pEpSet) < 0) { + ASSERT(0); return -1; } - ((SMsgHead*)buf)->vgId = htonl(pTask->fixedEpDispatcher.nodeId); - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - tEncodeSStreamTaskExecReq(&abuf, &req); - - SRpcMsg dispatchMsg = { - .pCont = buf, - .contLen = tlen, - .code = 0, - .msgType = pTask->dispatchMsgType, - }; - - SEpSet* pEpSet = &pTask->fixedEpDispatcher.epSet; - tmsgSendReq(pMsgCb, pEpSet, &dispatchMsg); } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { - // TODO + SHashObj* pShuffleRes = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (pShuffleRes == NULL) { + return -1; + } + + int32_t sz = taosArrayGetSize(pRes); + for (int32_t i = 0; i < sz; i++) { + SSDataBlock* pDataBlock = taosArrayGet(pRes, i); + SArray* pArray = taosHashGet(pShuffleRes, &pDataBlock->info.groupId, sizeof(int64_t)); + if (pArray == NULL) { + pArray = taosArrayInit(0, sizeof(SSDataBlock)); + if (pArray == NULL) { + return -1; + } + taosHashPut(pShuffleRes, &pDataBlock->info.groupId, sizeof(int64_t), &pArray, sizeof(void*)); + } + taosArrayPush(pArray, pDataBlock); + } + + if (streamShuffleDispatch(pTask, pMsgCb, pShuffleRes) < 0) { + return -1; + } } else { ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE); @@ -196,7 +263,6 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) { if (tEncodeI8(pEncoder, pTask->sinkType) < 0) return -1; if (tEncodeI8(pEncoder, pTask->dispatchType) < 0) return -1; if (tEncodeI16(pEncoder, pTask->dispatchMsgType) < 0) return -1; - if (tEncodeI32(pEncoder, pTask->downstreamTaskId) < 0) return -1; if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1; @@ -225,7 +291,8 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) { if (tEncodeI32(pEncoder, pTask->fixedEpDispatcher.nodeId) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pTask->fixedEpDispatcher.epSet) < 0) return -1; } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { - if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1; + if (tSerializeSUseDbRspImp(pEncoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1; + /*if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/ } /*tEndEncode(pEncoder);*/ @@ -242,7 +309,6 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) { if (tDecodeI8(pDecoder, &pTask->sinkType) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->dispatchType) < 0) return -1; if (tDecodeI16(pDecoder, &pTask->dispatchMsgType) < 0) return -1; - if (tDecodeI32(pDecoder, &pTask->downstreamTaskId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1; if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1; @@ -271,7 +337,8 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) { if (tDecodeI32(pDecoder, &pTask->fixedEpDispatcher.nodeId) < 0) return -1; if (tDecodeSEpSet(pDecoder, &pTask->fixedEpDispatcher.epSet) < 0) return -1; } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { - if (tDecodeI8(pDecoder, &pTask->shuffleDispatcher.hashMethod) < 0) return -1; + /*if (tDecodeI8(pDecoder, &pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/ + if (tDeserializeSUseDbRspImp(pDecoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1; } /*tEndDecode(pDecoder);*/ diff --git a/source/libs/transport/test/transportTests.cpp b/source/libs/transport/test/transportTests.cpp index 4165e6d8c9..ce795b1763 100644 --- a/source/libs/transport/test/transportTests.cpp +++ b/source/libs/transport/test/transportTests.cpp @@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); @@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) { key++; } { - STransCtxVal val1 = {.val = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index eea3903911..c467ab5fa3 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -13,6 +13,9 @@ find_path(IconvApiIncludes iconv.h PATHS) if(NOT IconvApiIncludes) add_definitions(-DDISALLOW_NCHAR_WITHOUT_ICONV) endif () +if(USE_TD_MEMORY) + add_definitions(-DUSE_TD_MEMORY) +endif () target_link_libraries( os pthread dl rt m ) diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 12e89fdd73..81ee259ff1 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -14,17 +14,17 @@ */ #define ALLOW_FORBID_FUNC +#include #include "os.h" #define TD_MEMORY_SYMBOL ('T'<<24|'A'<<16|'O'<<8|'S') #define TD_MEMORY_STACK_TRACE_DEPTH 10 -typedef struct TdMemoryInfo -{ +typedef struct TdMemoryInfo { int32_t symbol; + int32_t memorySize; void *stackTrace[TD_MEMORY_STACK_TRACE_DEPTH]; // gdb: disassemble /m 0xXXX - int32_t memorySize; } *TdMemoryInfoPtr , TdMemoryInfo; #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) @@ -32,6 +32,7 @@ typedef struct TdMemoryInfo #else #include + #define STACKCALL __attribute__((regparm(1), noinline)) void **STACKCALL taosGetEbp(void) { void **ebp = NULL; @@ -41,6 +42,7 @@ void **STACKCALL taosGetEbp(void) { : "memory"); /* not affect register */ return (void **)(*ebp); } + int32_t taosBackTrace(void **buffer, int32_t size) { int32_t frame = 0; void **ebp; @@ -59,6 +61,7 @@ int32_t taosBackTrace(void **buffer, int32_t size) { } return frame; } + #endif // char **taosBackTraceSymbols(int32_t *size) { @@ -68,6 +71,7 @@ int32_t taosBackTrace(void **buffer, int32_t size) { // } void *taosMemoryMalloc(int32_t size) { +#ifdef USE_TD_MEMORY void *tmp = malloc(size + sizeof(TdMemoryInfo)); if (tmp == NULL) return NULL; @@ -77,9 +81,13 @@ void *taosMemoryMalloc(int32_t size) { taosBackTrace(pTdMemoryInfo->stackTrace,TD_MEMORY_STACK_TRACE_DEPTH); return (char*)tmp + sizeof(TdMemoryInfo); +#else + return malloc(size); +#endif } void *taosMemoryCalloc(int32_t num, int32_t size) { +#ifdef USE_TD_MEMORY int32_t memorySize = num * size; char *tmp = calloc(memorySize + sizeof(TdMemoryInfo), 1); if (tmp == NULL) return NULL; @@ -90,9 +98,13 @@ void *taosMemoryCalloc(int32_t num, int32_t size) { taosBackTrace(pTdMemoryInfo->stackTrace,TD_MEMORY_STACK_TRACE_DEPTH); return (char*)tmp + sizeof(TdMemoryInfo); +#else + return calloc(num, size); +#endif } void *taosMemoryRealloc(void *ptr, int32_t size) { +#ifdef USE_TD_MEMORY if (ptr == NULL) return taosMemoryMalloc(size); TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); @@ -108,9 +120,13 @@ void *taosMemoryRealloc(void *ptr, int32_t size) { ((TdMemoryInfoPtr)tmp)->memorySize = size; return (char*)tmp + sizeof(TdMemoryInfo); +#else + return realloc(ptr, size); +#endif } void taosMemoryFree(const void *ptr) { +#ifdef USE_TD_MEMORY if (ptr == NULL) return; TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); @@ -121,13 +137,20 @@ void taosMemoryFree(const void *ptr) { } else { free((void*)ptr); } +#else + return free((void*)ptr); +#endif } int32_t taosMemorySize(void *ptr) { +#ifdef USE_TD_MEMORY if (ptr == NULL) return 0; TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL); return pTdMemoryInfo->memorySize; +#else + return malloc_usable_size(ptr); +#endif } diff --git a/source/util/src/tprocess.c b/source/util/src/tprocess.c index f5ce88179b..d06aab6fda 100644 --- a/source/util/src/tprocess.c +++ b/source/util/src/tprocess.c @@ -264,7 +264,8 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, char *pHead, int32_t rawHea taosThreadMutexUnlock(pQueue->mutex); tsem_post(&pQueue->sem); - uTrace("proc:%s, push msg:%p:%d cont:%p:%d to queue:%p", pQueue->name, pHead, headLen, pBody, bodyLen, pQueue); + uTrace("proc:%s, push msg to queue:%p remains:%d, head:%d:%p body:%d:%p", pQueue->name, pQueue, pQueue->items, + headLen, pHead, bodyLen, pBody); return 0; } @@ -277,7 +278,7 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int32_t *pHea taosThreadMutexUnlock(pQueue->mutex); tsem_post(&pQueue->sem); terrno = TSDB_CODE_OUT_OF_SHM_MEM; - return -1; + return 0; } int32_t headLen = 0; @@ -341,8 +342,9 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int32_t *pHea *pHeadLen = headLen; *pBodyLen = bodyLen; - uTrace("proc:%s, get msg:%p:%d cont:%p:%d from queue:%p", pQueue->name, pHead, headLen, pBody, bodyLen, pQueue); - return 0; + uTrace("proc:%s, pop msg from queue:%p remains:%d, head:%d:%p body:%d:%p", pQueue->name, pQueue, pQueue->items, + headLen, pHead, bodyLen, pBody); + return 1; } SProcObj *taosProcInit(const SProcCfg *pCfg) { @@ -396,15 +398,15 @@ static void taosProcThreadLoop(SProcQueue *pQueue) { void *pHead, *pBody; int32_t headLen, bodyLen; - uDebug("proc:%s, start to get message from queue:%p", pQueue->name, pQueue); + uDebug("proc:%s, start to get msg from queue:%p", pQueue->name, pQueue); while (1) { - int32_t code = taosProcQueuePop(pQueue, &pHead, &headLen, &pBody, &bodyLen); - if (code < 0) { - uDebug("proc:%s, get no message from queue:%p and exiting", pQueue->name, pQueue); + int32_t numOfMsgs = taosProcQueuePop(pQueue, &pHead, &headLen, &pBody, &bodyLen); + if (numOfMsgs == 0) { + uDebug("proc:%s, get no msg from queue:%p and exit the proc thread", pQueue->name, pQueue); break; - } else if (code == 0) { - uTrace("proc:%s, get no message from queue:%p since %s", pQueue->name, pQueue, terrstr()); + } else if (numOfMsgs < 0) { + uTrace("proc:%s, get no msg from queue:%p since %s", pQueue->name, pQueue, terrstr()); taosMsleep(1); continue; } else { diff --git a/source/util/src/tqueue.c b/source/util/src/tqueue.c index b01e1ea1da..3c3a8460b9 100644 --- a/source/util/src/tqueue.c +++ b/source/util/src/tqueue.c @@ -146,7 +146,7 @@ void taosFreeQitem(void *pItem) { taosMemoryFree(temp); } -int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { +void taosWriteQitem(STaosQueue *queue, void *pItem) { STaosQnode *pNode = (STaosQnode *)(((char *)pItem) - sizeof(STaosQnode)); pNode->next = NULL; @@ -167,8 +167,6 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { taosThreadMutexUnlock(&queue->mutex); if (queue->qset) tsem_post(&queue->qset->sem); - - return 0; } int32_t taosReadQitem(STaosQueue *queue, void **ppItem) { diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index 992ec74b5b..7fc390e70b 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -287,8 +287,8 @@ void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue) { int32_t tSingleWorkerInit(SSingleWorker *pWorker, const SSingleWorkerCfg *pCfg) { SQWorkerPool *pPool = &pWorker->pool; pPool->name = pCfg->name; - pPool->min = pCfg->minNum; - pPool->max = pCfg->maxNum; + pPool->min = pCfg->min; + pPool->max = pCfg->max; if (tQWorkerInit(pPool) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -316,7 +316,7 @@ void tSingleWorkerCleanup(SSingleWorker *pWorker) { int32_t tMultiWorkerInit(SMultiWorker *pWorker, const SMultiWorkerCfg *pCfg) { SWWorkerPool *pPool = &pWorker->pool; pPool->name = pCfg->name; - pPool->max = pCfg->maxNum; + pPool->max = pCfg->max; if (tWWorkerInit(pPool) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index dd44baed27..1b79851c4d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -6,6 +6,8 @@ # ---- db ./test.sh -f tsim/db/basic1.sim +./test.sh -f tsim/db/basic2.sim +./test.sh -f tsim/db/basic3.sim ./test.sh -f tsim/db/basic6.sim ./test.sh -f tsim/db/basic7.sim ./test.sh -f tsim/db/error1.sim diff --git a/tests/script/sh/massiveTable/compileVersion.sh b/tests/script/sh/massiveTable/compileVersion.sh index dd6382992a..13b2baae32 100755 --- a/tests/script/sh/massiveTable/compileVersion.sh +++ b/tests/script/sh/massiveTable/compileVersion.sh @@ -75,10 +75,12 @@ rm -f /usr/bin/taos rm -f /usr/bin/taosd rm -f /usr/bin/create_table rm -f /usr/bin/tmq_demo +rm -f /usr/bin/tmq_sim ln -s $taos_dir/taos /usr/bin/taos ln -s $taosd_dir/taosd /usr/bin/taosd ln -s $exec_process_dir/create_table /usr/bin/create_table ln -s $exec_process_dir/tmq_demo /usr/bin/tmq_demo +ln -s $exec_process_dir/tmq_sim /usr/bin/tmq_sim diff --git a/tests/script/general/db/basic2.sim b/tests/script/tsim/db/basic2.sim similarity index 63% rename from tests/script/general/db/basic2.sim rename to tests/script/tsim/db/basic2.sim index acd035bd74..e9222c8d32 100644 --- a/tests/script/general/db/basic2.sim +++ b/tests/script/tsim/db/basic2.sim @@ -1,7 +1,24 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 2000 + +$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 print =============== create database d1 @@ -13,7 +30,10 @@ sql create table t3 (ts timestamp, i int); sql create table t4 (ts timestamp, i int); sql show databases -if $rows != 1 then +print rows: $rows +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +if $rows != 2 then return -1 endi @@ -21,13 +41,13 @@ if $data00 != d1 then return -1 endi -if $data02 != 4 then +if $data02 != 2 then # vgroups return -1 endi -if $data03 != 1 then - return -1 -endi +#if $data03 != 4 then # ntables +# return -1 +#endi sql show tables if $rows != 4 then @@ -42,7 +62,7 @@ sql create table t2 (ts timestamp, i int); sql create table t3 (ts timestamp, i int); sql show databases -if $rows != 2 then +if $rows != 3 then return -1 endi diff --git a/tests/script/general/db/basic3.sim b/tests/script/tsim/db/basic3.sim similarity index 69% rename from tests/script/general/db/basic3.sim rename to tests/script/tsim/db/basic3.sim index fb64476696..52a587cc16 100644 --- a/tests/script/general/db/basic3.sim +++ b/tests/script/tsim/db/basic3.sim @@ -1,7 +1,24 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 2000 + +$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 print =============== create database d1 @@ -12,7 +29,7 @@ sql create table d1.t3 (ts timestamp, i int); sql create table d1.t4 (ts timestamp, i int); sql show databases -if $rows != 1 then +if $rows != 2 then return -1 endi @@ -20,13 +37,13 @@ if $data00 != d1 then return -1 endi -if $data02 != 4 then +if $data02 != 2 then return -1 endi -if $data03 != 1 then - return -1 -endi +#if $data03 != 4 then +# return -1 +#endi sql show d1.tables if $rows != 4 then @@ -40,7 +57,7 @@ sql create table d2.t2 (ts timestamp, i int); sql create table d2.t3 (ts timestamp, i int); sql show databases -if $rows != 2 then +if $rows != 3 then return -1 endi diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index e186491bd4..804894a69d 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(create_table create_table.c) add_executable(tmq_demo tmqDemo.c) +add_executable(tmq_sim tmqSim.c) target_link_libraries( create_table PUBLIC taos @@ -14,3 +15,10 @@ target_link_libraries( PUBLIC common PUBLIC os ) +target_link_libraries( + tmq_sim + PUBLIC taos + PUBLIC util + PUBLIC common + PUBLIC os +) diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c new file mode 100644 index 0000000000..57fc6eb6f9 --- /dev/null +++ b/tests/test/c/tmqSim.c @@ -0,0 +1,301 @@ +/* + * 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 . + */ + +// clang-format off + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "taos.h" +#include "taoserror.h" +#include "tlog.h" + +#define GREEN "\033[1;32m" +#define NC "\033[0m" +#define min(a, b) (((a) < (b)) ? (a) : (b)) + +#define MAX_SQL_STR_LEN (1024 * 1024) +#define MAX_ROW_STR_LEN (16 * 1024) + +typedef struct { + // input from argvs + char dbName[32]; + char topicString[256]; + char keyString[1024]; + int32_t showMsgFlag; + + // save result after parse agrvs + int32_t numOfTopic; + char topics[32][64]; + + int32_t numOfKey; + char key[32][64]; + char value[32][64]; +} SConfInfo; + +static SConfInfo g_stConfInfo; + +//char* g_pRowValue = NULL; +//TdFilePtr g_fp = NULL; + +static void printHelp() { + char indent[10] = " "; + printf("Used to test the tmq feature with sim cases\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-d"); + printf("%s%s%s\n", indent, indent, "The name of the database for cosumer, no default "); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s\n", indent, indent, "The topic string for cosumer, no default "); + printf("%s%s\n", indent, "-k"); + printf("%s%s%s\n", indent, indent, "The key-value string for cosumer, no default "); + printf("%s%s\n", indent, "-g"); + printf("%s%s%s%d\n", indent, indent, "showMsgFlag, default is ", g_stConfInfo.showMsgFlag); + exit(EXIT_SUCCESS); +} + +void parseArgument(int32_t argc, char *argv[]) { + + memset(&g_stConfInfo, 0, sizeof(SConfInfo)); + + for (int32_t i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(g_stConfInfo.dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + strcpy(g_stConfInfo.topicString, argv[++i]); + } else if (strcmp(argv[i], "-k") == 0) { + strcpy(g_stConfInfo.keyString, argv[++i]); + } else if (strcmp(argv[i], "-g") == 0) { + g_stConfInfo.showMsgFlag = atol(argv[++i]); + } else { + printf("%s unknow para: %s %s", GREEN, argv[++i], NC); + exit(-1); + } + } + +#if 1 + pPrint("%s configDir:%s %s", GREEN, configDir, NC); + pPrint("%s dbName:%s %s", GREEN, g_stConfInfo.dbName, NC); + pPrint("%s topicString:%s %s", GREEN, g_stConfInfo.topicString, NC); + pPrint("%s keyString:%s %s", GREEN, g_stConfInfo.keyString, NC); + pPrint("%s showMsgFlag:%d %s", GREEN, g_stConfInfo.showMsgFlag, NC); +#endif +} + +void splitStr(char **arr, char *str, const char *del) { + char *s = strtok(str, del); + while(s != NULL) { + *arr++ = s; + s = strtok(NULL, del); + } +} + +void ltrim(char *str) +{ + if (str == NULL || *str == '\0') + { + return; + } + int len = 0; + char *p = str; + while (*p != '\0' && isspace(*p)) + { + ++p; ++len; + } + memmove(str, p, strlen(str) - len + 1); + //return str; +} + + +void parseInputString() { + //printf("topicString: %s\n", g_stConfInfo.topicString); + //printf("keyString: %s\n\n", g_stConfInfo.keyString); + + char *token; + const char delim[2] = ","; + const char ch = ':'; + + token = strtok(g_stConfInfo.topicString, delim); + while(token != NULL) { + //printf("%s\n", token ); + strcpy(g_stConfInfo.topics[g_stConfInfo.numOfTopic], token); + ltrim(g_stConfInfo.topics[g_stConfInfo.numOfTopic]); + //printf("%s\n", g_stConfInfo.topics[g_stConfInfo.numOfTopic]); + g_stConfInfo.numOfTopic++; + + token = strtok(NULL, delim); + } + + printf("\n\n"); + + token = strtok(g_stConfInfo.keyString, delim); + while(token != NULL) { + //printf("%s\n", token ); + { + char* pstr = token; + ltrim(pstr); + char *ret = strchr(pstr, ch); + memcpy(g_stConfInfo.key[g_stConfInfo.numOfKey], pstr, ret-pstr); + strcpy(g_stConfInfo.value[g_stConfInfo.numOfKey], ret+1); + //printf("key: %s, value: %s\n", g_stConfInfo.key[g_stConfInfo.numOfKey], g_stConfInfo.value[g_stConfInfo.numOfKey]); + g_stConfInfo.numOfKey++; + } + + token = strtok(NULL, delim); + } +} + + +static int running = 1; +static void msg_process(tmq_message_t* message) { tmqShowMsg(message); } + + +int queryDB(TAOS *taos, char *command) { + TAOS_RES *pRes = taos_query(taos, command); + int code = taos_errno(pRes); + //if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) { + if (code != 0) { + pError("failed to reason:%s, sql: %s", tstrerror(code), command); + taos_free_result(pRes); + return -1; + } + taos_free_result(pRes); + return 0 ; +} + +tmq_t* build_consumer() { + char sqlStr[1024] = {0}; + + TAOS* pConn = taos_connect(NULL, "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + sprintf(sqlStr, "use %s", g_stConfInfo.dbName); + TAOS_RES* pRes = taos_query(pConn, sqlStr); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + + tmq_conf_t* conf = tmq_conf_new(); + //tmq_conf_set(conf, "group.id", "tg2"); + for (int32_t i = 0; i < g_stConfInfo.numOfKey; i++) { + tmq_conf_set(conf, g_stConfInfo.key[i], g_stConfInfo.value[i]); + } + tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0); + return tmq; +} + +tmq_list_t* build_topic_list() { + tmq_list_t* topic_list = tmq_list_new(); + //tmq_list_append(topic_list, "test_stb_topic_1"); + for (int32_t i = 0; i < g_stConfInfo.numOfTopic; i++) { + tmq_list_append(topic_list, g_stConfInfo.topics[i]); + } + return topic_list; +} + +void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) { + static const int MIN_COMMIT_COUNT = 1000; + + int msg_count = 0; + tmq_resp_err_t err; + + if ((err = tmq_subscribe(tmq, topics))) { + fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(err)); + return; + } + + while (running) { + tmq_message_t* tmqmessage = tmq_consumer_poll(tmq, 1); + if (tmqmessage) { + msg_process(tmqmessage); + tmq_message_destroy(tmqmessage); + + if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0); + } + } + + err = tmq_consumer_close(tmq); + if (err) + fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(err)); + else + fprintf(stderr, "%% Consumer closed\n"); +} + +void perf_loop(tmq_t* tmq, tmq_list_t* topics) { + tmq_resp_err_t err; + + if ((err = tmq_subscribe(tmq, topics))) { + printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err)); + return; + } + + int32_t totalMsgs = 0; + int32_t skipLogNum = 0; + //int64_t startTime = taosGetTimestampUs(); + while (running) { + tmq_message_t* tmqmessage = tmq_consumer_poll(tmq, 1); + if (tmqmessage) { + totalMsgs++; + skipLogNum += tmqGetSkipLogNum(tmqmessage); + if (0 != g_stConfInfo.showMsgFlag) { + msg_process(tmqmessage); + } + tmq_message_destroy(tmqmessage); + } else { + break; + } + } + //int64_t endTime = taosGetTimestampUs(); + //double consumeTime = (double)(endTime - startTime) / 1000000; + + + err = tmq_consumer_close(tmq); + if (err) { + printf("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err)); + exit(-1); + } + + printf("{consume success: %d}", totalMsgs); +} + +int main(int32_t argc, char *argv[]) { + parseArgument(argc, argv); + parseInputString(); + + tmq_t* tmq = build_consumer(); + tmq_list_t* topic_list = build_topic_list(); + if ((NULL == tmq) || (NULL == topic_list)){ + return -1; + } + + perf_loop(tmq, topic_list); + + return 0; +} +