From 819c7fc030b54e728b72d5a272982785a48b18ca Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 8 Oct 2021 20:33:46 +0800 Subject: [PATCH] [td-10529] fix compiler error --- include/{common => client}/taos.h | 0 include/common/common.h | 30 +- include/common/taosmsg.h | 2 + include/common/tdataformat.h | 2 +- include/common/texpr.h | 107 ----- include/common/ttoken.h | 192 -------- include/common/tvariant.h | 45 +- include/libs/catalog/catalog.h | 1 + include/libs/parser/parser.h | 28 +- include/libs/transport/transport.h | 32 +- .../util/{tscompression.h => tcompression.h} | 0 include/util/tdef.h | 73 ++-- include/util/tutil.h | 4 +- source/common/src/tarithoperator.c | 412 ------------------ source/{util => common}/src/tcompare.c | 4 +- source/common/src/tname.c | 97 ++--- source/common/src/ttypes.c | 4 +- source/common/src/tvariant.c | 112 ++--- source/libs/executor/CMakeLists.txt | 5 + source/libs/executor/src/tarithoperator.h | 32 -- source/{common => libs/executor}/src/texpr.c | 39 +- source/libs/parser/inc/tvariant.h | 66 --- source/libs/parser/src/astGenerator.c | 4 +- .../{common => libs/parser}/src/ttokenizer.c | 16 +- source/libs/planner/inc/plannerInt.h | 1 + source/libs/transport/src/rpcMain.c | 2 +- source/server/dnode/inc/dnodeEps.h | 2 +- source/server/dnode/src/dnodeMain.c | 6 +- source/util/src/tcache.c | 9 +- source/util/src/tcompression.c | 2 +- source/util/src/thash.c | 1 + source/util/src/thashutil.c | 25 +- src/client/inc/tsclient.h | 2 +- src/client/src/TSDBJNIConnector.c | 2 +- src/client/src/tscLocal.c | 8 +- src/client/src/tscParseLineProtocol.c | 2 +- src/client/src/tscParseOpenTSDB.c | 2 +- src/client/src/tscPrepare.c | 10 +- src/client/src/tscProfile.c | 2 +- src/client/src/tscSQLParser.c | 30 +- src/client/src/tscSub.c | 10 +- src/connector/odbc/examples/c/main.c | 2 +- src/connector/odbc/src/base.h | 2 +- src/connector/odbc/src/todbc_tls.h | 2 +- src/cq/src/cqMain.c | 6 +- src/kit/shell/inc/shell.h | 3 +- src/kit/shell/src/shellWindows.c | 2 +- src/kit/taosdemo/taosdemo.c | 4 +- src/kit/taosdump/taosdump.c | 3 +- src/plugins/http/inc/httpGcJson.h | 2 +- src/plugins/http/inc/httpRestJson.h | 2 +- src/plugins/http/inc/httpTgJson.h | 2 +- src/plugins/http/src/httpQueue.c | 22 +- src/plugins/http/src/httpSession.c | 14 +- src/plugins/http/src/httpSql.c | 18 +- src/plugins/http/src/httpSystem.c | 26 +- src/plugins/http/src/httpUtil.c | 8 +- src/plugins/mqtt/src/mqttSystem.c | 8 +- src/query/inc/qSqlparser.h | 2 +- src/query/src/qExtbuffer.c | 8 +- tests/comparisonTest/tdengine/tdengineTest.c | 12 +- tests/examples/c/apitest.c | 3 +- tests/examples/c/asyncdemo.c | 2 +- tests/examples/c/demo.c | 4 +- tests/examples/c/prepare.c | 3 +- tests/examples/c/schemaless.c | 4 +- tests/examples/c/stream.c | 4 +- tests/examples/c/subscribe.c | 2 +- tests/examples/lua/lua51/lua_connector51.c | 6 +- tests/examples/lua/lua_connector.c | 10 +- tests/robust/robust.c | 4 +- tests/script/api/batchprepare.c | 4 +- tests/script/api/stmtBatchTest.c | 6 +- tests/script/api/stmtTest.c | 4 +- tests/script/api/stmt_function.c | 6 +- tests/test/c/cacheTest.c | 2 +- tests/test/c/createNormalTable.c | 6 +- tests/test/c/createTablePerformance.c | 6 +- tests/test/c/hashIterator.c | 4 +- tests/test/c/hashPerformance.c | 4 +- tests/test/c/importOneRow.c | 8 +- tests/test/c/importPerTable.c | 10 +- tests/test/c/insertPerRow.c | 8 +- tests/test/c/insertPerTable.c | 8 +- tests/test/c/invalidTableId.c | 6 +- tests/test/c/queryPerformance.c | 8 +- tests/tsim/inc/sim.h | 2 +- tests/tsim/src/simExe.c | 4 +- tests/tsim/src/simSystem.c | 6 +- 89 files changed, 448 insertions(+), 1267 deletions(-) rename include/{common => client}/taos.h (100%) delete mode 100644 include/common/texpr.h delete mode 100644 include/common/ttoken.h rename include/util/{tscompression.h => tcompression.h} (100%) delete mode 100644 source/common/src/tarithoperator.c rename source/{util => common}/src/tcompare.c (99%) delete mode 100644 source/libs/executor/src/tarithoperator.h rename source/{common => libs/executor}/src/texpr.c (95%) delete mode 100644 source/libs/parser/inc/tvariant.h rename source/{common => libs/parser}/src/ttokenizer.c (98%) diff --git a/include/common/taos.h b/include/client/taos.h similarity index 100% rename from include/common/taos.h rename to include/client/taos.h diff --git a/include/common/common.h b/include/common/common.h index fb66902019..b438316f57 100644 --- a/include/common/common.h +++ b/include/common/common.h @@ -18,22 +18,22 @@ #include "taosdef.h" -typedef struct STimeWindow { - TSKEY skey; - TSKEY ekey; -} STimeWindow; +//typedef struct STimeWindow { +// TSKEY skey; +// TSKEY ekey; +//} STimeWindow; -typedef struct { - int32_t dataLen; - char name[TSDB_TABLE_FNAME_LEN]; - char *data; -} STagData; +//typedef struct { +// int32_t dataLen; +// char name[TSDB_TABLE_FNAME_LEN]; +// char *data; +//} STagData; -typedef struct SSchema { - uint8_t type; - char name[TSDB_COL_NAME_LEN]; - int16_t colId; - int16_t bytes; -} SSchema; +//typedef struct SSchema { +// uint8_t type; +// char name[TSDB_COL_NAME_LEN]; +// int16_t colId; +// int16_t bytes; +//} SSchema; #endif // TDENGINE_COMMON_H diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h index 6cabc8568c..72ce3a946c 100644 --- a/include/common/taosmsg.h +++ b/include/common/taosmsg.h @@ -252,12 +252,14 @@ typedef struct { SShellSubmitRspBlock failedBlocks[]; } SShellSubmitRspMsg; +//#if 0 typedef struct SSchema { uint8_t type; char name[TSDB_COL_NAME_LEN]; int16_t colId; int16_t bytes; } SSchema; +//#endif typedef struct { int32_t contLen; diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index e348381ae0..c4321eb9df 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -17,7 +17,7 @@ #include "os.h" #include "talgo.h" -#include "ttype.h" +#include "ttypes.h" #include "tutil.h" #ifdef __cplusplus diff --git a/include/common/texpr.h b/include/common/texpr.h deleted file mode 100644 index e28f8644ed..0000000000 --- a/include/common/texpr.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_COMMON_EXPR_H_ -#define _TD_COMMON_EXPR_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "os.h" - -#include "taosmsg.h" -#include "taosdef.h" -#include "tskiplist.h" -#include "tbuffer.h" -#include "tvariant.h" - -struct tExprNode; -struct SSchema; - -#define QUERY_COND_REL_PREFIX_IN "IN|" -#define QUERY_COND_REL_PREFIX_LIKE "LIKE|" -#define QUERY_COND_REL_PREFIX_MATCH "MATCH|" -#define QUERY_COND_REL_PREFIX_NMATCH "NMATCH|" - -#define QUERY_COND_REL_PREFIX_IN_LEN 3 -#define QUERY_COND_REL_PREFIX_LIKE_LEN 5 -#define QUERY_COND_REL_PREFIX_MATCH_LEN 6 -#define QUERY_COND_REL_PREFIX_NMATCH_LEN 7 - -typedef bool (*__result_filter_fn_t)(const void *, void *); -typedef void (*__do_filter_suppl_fn_t)(void *, void *); - -enum { - TSQL_NODE_DUMMY = 0x0, - TSQL_NODE_EXPR = 0x1, - TSQL_NODE_COL = 0x2, - TSQL_NODE_VALUE = 0x4, -}; - -/** - * this structure is used to filter data in tags, so the offset of filtered tag column in tagdata string is required - */ -typedef struct tQueryInfo { - uint8_t optr; // expression operator - SSchema sch; // schema of tags - char* q; - __compar_fn_t compare; // filter function - bool indexed; // indexed columns -} tQueryInfo; - -typedef struct tExprNode { - uint8_t nodeType; - union { - struct { - uint8_t optr; // filter operator - uint8_t hasPK; // 0: do not contain primary filter, 1: contain - void *info; // support filter operation on this expression only available for leaf node - struct tExprNode *pLeft; // left child pointer - struct tExprNode *pRight; // right child pointer - } _node; - - struct SSchema *pSchema; - tVariant *pVal; - }; -} tExprNode; - -typedef struct SExprTraverseSupp { - __result_filter_fn_t nodeFilterFn; - __do_filter_suppl_fn_t setupInfoFn; - void *pExtInfo; -} SExprTraverseSupp; - -void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); - -void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); -tExprNode* exprTreeFromBinary(const void* data, size_t size); -tExprNode* exprTreeFromTableName(const char* tbnameCond); -tExprNode* exprdup(tExprNode* pTree); - -void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); - -bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param); - -void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, - char *(*cb)(void *, const char*, int32_t)); - -void buildFilterSetFromBinary(void **q, const char *buf, int32_t len); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_COMMON_EXPR_H_*/ diff --git a/include/common/ttoken.h b/include/common/ttoken.h deleted file mode 100644 index 552e52636f..0000000000 --- a/include/common/ttoken.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_COMMON_TOKEN_H_ -#define _TD_COMMON_TOKEN_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "os.h" -#include "tutil.h" -#include "ttokendef.h" - -#define TSQL_TBNAME "TBNAME" -#define TSQL_TBNAME_L "tbname" - -#define TSQL_BLOCK_DIST "_BLOCK_DIST" -#define TSQL_BLOCK_DIST_L "_block_dist" - -// used to denote the minimum unite in sql parsing -typedef struct SStrToken { - uint32_t n; - uint32_t type; - char *z; -} SStrToken; - -/** - * check if it is a number or not - * @param pToken - * @return - */ -#define isNumber(tk) \ -((tk)->type == TK_INTEGER || (tk)->type == TK_FLOAT || (tk)->type == TK_HEX || (tk)->type == TK_BIN) - -/** - * tokenizer for sql string - * @param z - * @param tokenType - * @return - */ -uint32_t tGetToken(char *z, uint32_t *tokenType); - -/** - * enhanced tokenizer for sql string. - * - * @param str - * @param i - * @param isPrevOptr - * @return - */ -SStrToken tStrGetToken(char *str, int32_t *i, bool isPrevOptr); - -/** - * check if it is a keyword or not - * @param z - * @param len - * @return - */ -bool taosIsKeyWordToken(const char *z, int32_t len); - -/** - * check if it is a token or not - * @param pToken - * @return token type, if it is not a number, TK_ILLEGAL will return - */ -static FORCE_INLINE int32_t tGetNumericStringType(const SStrToken* pToken) { - const char* z = pToken->z; - int32_t type = TK_ILLEGAL; - - uint32_t i = 0; - for(; i < pToken->n; ++i) { - switch (z[i]) { - case '+': - case '-': { - break; - } - - case '.': { - /* - * handle the the float number with out integer part - * .123 - * .123e4 - */ - if (!isdigit(z[i+1])) { - return TK_ILLEGAL; - } - - for (i += 2; isdigit(z[i]); i++) { - } - - if ((z[i] == 'e' || z[i] == 'E') && - (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { - i += 2; - while (isdigit(z[i])) { - i++; - } - } - - type = TK_FLOAT; - goto _end; - } - - case '0': { - char next = z[i + 1]; - if (next == 'b') { // bin number - type = TK_BIN; - for (i += 2; (z[i] == '0' || z[i] == '1'); ++i) { - } - - goto _end; - } else if (next == 'x') { //hex number - type = TK_HEX; - for (i += 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) { - } - - goto _end; - } - } - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - type = TK_INTEGER; - for (; isdigit(z[i]); i++) { - } - - int32_t seg = 0; - while (z[i] == '.' && isdigit(z[i + 1])) { - i += 2; - - while (isdigit(z[i])) { - i++; - } - - seg++; - type = TK_FLOAT; - } - - if (seg > 1) { - return TK_ILLEGAL; - } - - if ((z[i] == 'e' || z[i] == 'E') && - (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { - i += 2; - while (isdigit(z[i])) { - i++; - } - - type = TK_FLOAT; - } - - goto _end; - } - default: - return TK_ILLEGAL; - } - } - - _end: - return (i < pToken->n)? TK_ILLEGAL:type; -} - -void taosCleanupKeywordsTable(); - -SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken); - -SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_COMMON_TOKEN_H_*/ diff --git a/include/common/tvariant.h b/include/common/tvariant.h index f95eb281cf..c33797684e 100644 --- a/include/common/tvariant.h +++ b/include/common/tvariant.h @@ -13,52 +13,53 @@ * along with this program. If not, see . */ -#ifndef _TD_COMMON_VARIANT_H_ -#define _TD_COMMON_VARIANT_H_ - -#include "tarray.h" -#include "ttoken.h" +#ifndef TDENGINE_TVARIANT_H +#define TDENGINE_TVARIANT_H #ifdef __cplusplus extern "C" { #endif +#include "tarray.h" + // variant, each number/string/field_id has a corresponding struct during parsing sql -typedef struct tVariant { - uint32_t nType; - int32_t nLen; // only used for string, for number, it is useless +typedef struct SVariant { + uint32_t nType; + int32_t nLen; // only used for string, for number, it is useless union { int64_t i64; uint64_t u64; - double dKey; - char * pz; + double d; + char *pz; wchar_t *wpz; SArray *arr; // only for 'in' query to hold value list, not value for a field }; -} tVariant; +} SVariant; -bool tVariantIsValid(tVariant *pVar); +bool taosVariantIsValid(SVariant *pVar); -void tVariantCreate(tVariant *pVar, SStrToken *token); +//void taosVariantCreate(SVariant *pVar, SToken *token); -void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32_t type); +void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type); -void tVariantDestroy(tVariant *pV); +void taosVariantDestroy(SVariant *pV); -void tVariantAssign(tVariant *pDst, const tVariant *pSrc); +void taosVariantAssign(SVariant *pDst, const SVariant *pSrc); -int32_t tVariantCompare(const tVariant* p1, const tVariant* p2); +int32_t taosVariantCompare(const SVariant* p1, const SVariant* p2); -int32_t tVariantToString(tVariant *pVar, char *dst); +int32_t taosVariantToString(SVariant *pVar, char *dst); -int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix); +int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix); -int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo); +#if 0 +int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo); +#endif -int32_t tVariantTypeSetType(tVariant *pVariant, char type); +int32_t taosVariantTypeSetType(SVariant *pVariant, char type); #ifdef __cplusplus } #endif -#endif /*_TD_COMMON_VARIANT_H_*/ +#endif // TDENGINE_TVARIANT_H diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 1af3e16f20..c4a244adc4 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -26,6 +26,7 @@ extern "C" { #include "taosdef.h" #include "transport.h" #include "common.h" +#include "taosmsg.h" struct SCatalog; diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 4890dd674a..8bbd698ad8 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -24,20 +24,20 @@ extern "C" { #include "common.h" #include "tname.h" -typedef struct SInterval { - int32_t tz; // query client timezone - char intervalUnit; - char slidingUnit; - char offsetUnit; - int64_t interval; - int64_t sliding; - int64_t offset; -} SInterval; - -typedef struct SSessionWindow { - int64_t gap; // gap between two session window(in microseconds) - int32_t primaryColId; // primary timestamp column -} SSessionWindow; +//typedef struct SInterval { +// int32_t tz; // query client timezone +// char intervalUnit; +// char slidingUnit; +// char offsetUnit; +// int64_t interval; +// int64_t sliding; +// int64_t offset; +//} SInterval; +// +//typedef struct SSessionWindow { +// int64_t gap; // gap between two session window(in microseconds) +// int32_t primaryColId; // primary timestamp column +//} SSessionWindow; typedef struct SGroupbyExpr { int16_t tableIndex; diff --git a/include/libs/transport/transport.h b/include/libs/transport/transport.h index e7660e4d66..a05a76931a 100644 --- a/include/libs/transport/transport.h +++ b/include/libs/transport/transport.h @@ -20,23 +20,21 @@ extern "C" { #endif -typedef void* SEpSet; - -typedef struct SEpAddr { - char fqdn[TSDB_FQDN_LEN]; - uint16_t port; -} SEpAddr; - -typedef struct SVgroup { - int32_t vgId; - int8_t numOfEps; - SEpAddr epAddr[TSDB_MAX_REPLICA]; -} SVgroup; - -typedef struct SVgroupsInfo { - int32_t numOfVgroups; - SVgroup vgroups[]; -} SVgroupsInfo; +//typedef struct SEpAddr { +// char fqdn[TSDB_FQDN_LEN]; +// uint16_t port; +//} SEpAddr; +// +//typedef struct SVgroup { +// int32_t vgId; +// int8_t numOfEps; +// SEpAddr epAddr[TSDB_MAX_REPLICA]; +//} SVgroup; +// +//typedef struct SVgroupsInfo { +// int32_t numOfVgroups; +// SVgroup vgroups[]; +//} SVgroupsInfo; #ifdef __cplusplus } diff --git a/include/util/tscompression.h b/include/util/tcompression.h similarity index 100% rename from include/util/tscompression.h rename to include/util/tcompression.h diff --git a/include/util/tdef.h b/include/util/tdef.h index c67886f240..a24d2bc911 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -45,12 +45,7 @@ extern const int32_t TYPE_BYTES[15]; #define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*) #define TSDB_KEYSIZE sizeof(TSKEY) - -#if LINUX -#define TSDB_NCHAR_SIZE sizeof(wchar_t) -#else #define TSDB_NCHAR_SIZE sizeof(int32_t) -#endif // NULL definition #define TSDB_DATA_BOOL_NULL 0x02 @@ -419,40 +414,40 @@ do { \ // ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR -typedef int32_t VarDataOffsetT; -typedef int16_t VarDataLenT; // maxVarDataLen: 32767 -typedef uint16_t TDRowLenT; // not including overhead: 0 ~ 65535 -typedef uint32_t TDRowTLenT; // total length, including overhead - -typedef struct tstr { - VarDataLenT len; - char data[]; -} tstr; - -#pragma pack(push, 1) -typedef struct { - VarDataLenT len; - uint8_t data; -} SBinaryNullT; - -typedef struct { - VarDataLenT len; - uint32_t data; -} SNCharNullT; -#pragma pack(pop) - -#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) - -#define varDataLen(v) ((VarDataLenT *)(v))[0] -#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) -#define varDataVal(v) ((void *)((char *)v + VARSTR_HEADER_SIZE)) -#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v)) -#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE)) -#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT) (_len)) -#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_BINARY) || ((t) == TSDB_DATA_TYPE_NCHAR)) - -#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0])) -#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v)) +//typedef int32_t VarDataOffsetT; +//typedef int16_t VarDataLenT; // maxVarDataLen: 32767 +//typedef uint16_t TDRowLenT; // not including overhead: 0 ~ 65535 +//typedef uint32_t TDRowTLenT; // total length, including overhead +// +//typedef struct tstr { +// VarDataLenT len; +// char data[]; +//} tstr; +// +//#pragma pack(push, 1) +//typedef struct { +// VarDataLenT len; +// uint8_t data; +//} SBinaryNullT; +// +//typedef struct { +// VarDataLenT len; +// uint32_t data; +//} SNCharNullT; +//#pragma pack(pop) +// +//#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) +// +//#define varDataLen(v) ((VarDataLenT *)(v))[0] +//#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) +//#define varDataVal(v) ((void *)((char *)v + VARSTR_HEADER_SIZE)) +//#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v)) +//#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE)) +//#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT) (_len)) +//#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_BINARY) || ((t) == TSDB_DATA_TYPE_NCHAR)) +// +//#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0])) +//#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v)) #ifdef __cplusplus diff --git a/include/util/tutil.h b/include/util/tutil.h index b599fc095c..202c55ab9c 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -40,8 +40,8 @@ char * paGetToken(char *src, char **token, int32_t *tokenLen); int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); -bool taosGetVersionNumber(char *versionStr, int *versionNubmer); -int taosCheckVersion(char *input_client_version, char *input_server_version, int compared_segments); +//bool taosGetVersionNumber(char *versionStr, int *versionNubmer); +//int taosCheckVersion(char *input_client_version, char *input_server_version, int compared_segments); char * taosIpStr(uint32_t ipInt); uint32_t ip2uint(const char *const ip_addr); diff --git a/source/common/src/tarithoperator.c b/source/common/src/tarithoperator.c deleted file mode 100644 index 000ef79fcf..0000000000 --- a/source/common/src/tarithoperator.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "os.h" - -#include "ttype.h" -#include "tutil.h" -#include "tarithoperator.h" -#include "tcompare.h" - -//GET_TYPED_DATA(v, double, _right_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 : MAX(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 (*_arithmetic_getVectorDoubleValue_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); -} -_arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { - _arithmetic_getVectorDoubleValue_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* (*_arithmetic_getVectorValueAddr_fn_t)(void *src, int32_t index); - -void* getVectorValueAddr_TINYINT(void *src, int32_t index) { - return (void*)((int8_t *)src + index); -} -void* getVectorValueAddr_UTINYINT(void *src, int32_t index) { - return (void*)((uint8_t *)src + index); -} -void* getVectorValueAddr_SMALLINT(void *src, int32_t index) { - return (void*)((int16_t *)src + index); -} -void* getVectorValueAddr_USMALLINT(void *src, int32_t index) { - return (void*)((uint16_t *)src + index); -} -void* getVectorValueAddr_INT(void *src, int32_t index) { - return (void*)((int32_t *)src + index); -} -void* getVectorValueAddr_UINT(void *src, int32_t index) { - return (void*)((uint32_t *)src + index); -} -void* getVectorValueAddr_BIGINT(void *src, int32_t index) { - return (void*)((int64_t *)src + index); -} -void* getVectorValueAddr_UBIGINT(void *src, int32_t index) { - return (void*)((uint64_t *)src + index); -} -void* getVectorValueAddr_FLOAT(void *src, int32_t index) { - return (void*)((float *)src + index); -} -void* getVectorValueAddr_DOUBLE(void *src, int32_t index) { - return (void*)((double *)src + index); -} - -_arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { - _arithmetic_getVectorValueAddr_fn_t p = NULL; - if(srcType==TSDB_DATA_TYPE_TINYINT) { - p = getVectorValueAddr_TINYINT; - }else if(srcType==TSDB_DATA_TYPE_UTINYINT) { - p = getVectorValueAddr_UTINYINT; - }else if(srcType==TSDB_DATA_TYPE_SMALLINT) { - p = getVectorValueAddr_SMALLINT; - }else if(srcType==TSDB_DATA_TYPE_USMALLINT) { - p = getVectorValueAddr_USMALLINT; - }else if(srcType==TSDB_DATA_TYPE_INT) { - p = getVectorValueAddr_INT; - }else if(srcType==TSDB_DATA_TYPE_UINT) { - p = getVectorValueAddr_UINT; - }else if(srcType==TSDB_DATA_TYPE_BIGINT) { - p = getVectorValueAddr_BIGINT; - }else if(srcType==TSDB_DATA_TYPE_UBIGINT) { - p = getVectorValueAddr_UBIGINT; - }else if(srcType==TSDB_DATA_TYPE_FLOAT) { - p = getVectorValueAddr_FLOAT; - }else if(srcType==TSDB_DATA_TYPE_DOUBLE) { - p = getVectorValueAddr_DOUBLE; - }else { - assert(0); - } - return p; -} - -void vectorAdd(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double *output=(double*)out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(_left_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(_right_type); - - if ((len1) == (len2)) { - for (; i < (len2) && i >= 0; i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) + getVectorDoubleValueFnRight(right,i)); - } - } else if ((len1) == 1) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,0), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,0) + getVectorDoubleValueFnRight(right,i)); - } - } else if ((len2) == 1) { - for (; i >= 0 && i < (len1); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,0), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) + getVectorDoubleValueFnRight(right,0)); - } - } -} -void vectorSub(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double *output=(double*)out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(_left_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(_right_type); - - if ((len1) == (len2)) { - for (; i < (len2) && i >= 0; i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) - getVectorDoubleValueFnRight(right,i)); - } - } else if ((len1) == 1) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,0), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,0) - getVectorDoubleValueFnRight(right,i)); - } - } else if ((len2) == 1) { - for (; i >= 0 && i < (len1); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,0), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) - getVectorDoubleValueFnRight(right,0)); - } - } -} -void vectorMultiply(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double *output=(double*)out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(_left_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(_right_type); - - if ((len1) == (len2)) { - for (; i < (len2) && i >= 0; i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) * getVectorDoubleValueFnRight(right,i)); - } - } else if ((len1) == 1) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,0), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,0) * getVectorDoubleValueFnRight(right,i)); - } - } else if ((len2) == 1) { - for (; i >= 0 && i < (len1); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,0), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) * getVectorDoubleValueFnRight(right,0)); - } - } -} -void vectorDivide(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - double *output=(double*)out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(_left_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(_right_type); - - if ((len1) == (len2)) { - for (; i < (len2) && i >= 0; i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,i)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) /getVectorDoubleValueFnRight(right,i)); - } - } else if ((len1) == 1) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,0), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,i)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,0) /getVectorDoubleValueFnRight(right,i)); - } - } else if ((len2) == 1) { - for (; i >= 0 && i < (len1); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,0), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,0)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) /getVectorDoubleValueFnRight(right,0)); - } - } -} -void vectorRemainder(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { - int32_t i = (_ord == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; - int32_t step = (_ord == TSDB_ORDER_ASC) ? 1 : -1; - double *output=(double*)out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(_left_type); - _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(_right_type); - - if (len1 == (len2)) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,i)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) - ((int64_t)(getVectorDoubleValueFnLeft(left,i) / getVectorDoubleValueFnRight(right,i))) * getVectorDoubleValueFnRight(right,i)); - } - } else if (len1 == 1) { - for (; i >= 0 && i < (len2); i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,0), _left_type) || isNull(getVectorValueAddrFnRight(right,i), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,i)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,0) - ((int64_t)(getVectorDoubleValueFnLeft(left,0) / getVectorDoubleValueFnRight(right,i))) * getVectorDoubleValueFnRight(right,i)); - } - } else if ((len2) == 1) { - for (; i >= 0 && i < len1; i += step, output += 1) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type) || isNull(getVectorValueAddrFnRight(right,0), _right_type)) { - SET_DOUBLE_NULL(output); - continue; - } - double v, u = 0.0; - GET_TYPED_DATA(v, double, _right_type, getVectorValueAddrFnRight(right,0)); - if (getComparFunc(TSDB_DATA_TYPE_DOUBLE, 0)(&v, &u) == 0) { - SET_DOUBLE_NULL(output); - continue; - } - SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(left,i) - ((int64_t)(getVectorDoubleValueFnLeft(left,i) / getVectorDoubleValueFnRight(right,0))) * getVectorDoubleValueFnRight(right,0)); - } - } -} - -_arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) { - switch (arithmeticOptr) { - case TSDB_BINARY_OP_ADD: - return vectorAdd; - case TSDB_BINARY_OP_SUBTRACT: - return vectorSub; - case TSDB_BINARY_OP_MULTIPLY: - return vectorMultiply; - case TSDB_BINARY_OP_DIVIDE: - return vectorDivide; - case TSDB_BINARY_OP_REMAINDER: - return vectorRemainder; - default: - assert(0); - return NULL; - } -} diff --git a/source/util/src/tcompare.c b/source/common/src/tcompare.c similarity index 99% rename from source/util/src/tcompare.c rename to source/common/src/tcompare.c index 282de17c1b..e8e9ae3d68 100644 --- a/source/util/src/tcompare.c +++ b/source/common/src/tcompare.c @@ -17,12 +17,12 @@ #define _XOPEN_SOURCE #define _DEFAULT_SOURCE +#include "os.h" #include "tcompare.h" #include "ulog.h" #include "thash.h" #include "regex.h" -#include "os.h" -#include "tdef.h" +#include "ttypes.h" int32_t setCompareBytes1(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, pLeft, 1) ? 1 : 0; diff --git a/source/common/src/tname.c b/source/common/src/tname.c index 532333651d..c5bbda3c8c 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -2,22 +2,13 @@ #include "tutil.h" #include "tname.h" -#include "ttoken.h" -#include "tvariant.h" +#include "taosmsg.h" #define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) #define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS) #define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T) -//TODO remove it -void extractTableName(const char* tableId, char* name) { - size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]); - size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]); - - tstrncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN); -} - char* extractDBName(const char* tableId, char* name) { size_t offset1 = strcspn(tableId, &TS_PATH_DELIMITER[0]); size_t len = strcspn(&tableId[offset1 + 1], &TS_PATH_DELIMITER[0]); @@ -33,28 +24,6 @@ size_t tableIdPrefix(const char* name, char* prefix, int32_t len) { return strlen(prefix); } -SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name) { - SSchema s = {0}; - - s.type = pVal->nType; - if (s.type == TSDB_DATA_TYPE_BINARY || s.type == TSDB_DATA_TYPE_NCHAR) { - s.bytes = (int16_t)(pVal->nLen + VARSTR_HEADER_SIZE); - } else { - s.bytes = tDataTypes[pVal->nType].bytes; - } - - s.colId = TSDB_UD_COLUMN_INDEX; - if (name != NULL) { - tstrncpy(s.name, name, sizeof(s.name)); - } else { - size_t tlen = MIN(sizeof(s.name), exprStr->n + 1); - tstrncpy(s.name, exprStr->z, tlen); - strdequote(s.name); - } - - return s; -} - bool tscValidateTableNameLength(size_t len) { return len < TSDB_TABLE_NAME_LEN; } @@ -155,30 +124,30 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in * tablePrefix.columnName * extract table name and save it in pTable, with only column name in pToken */ -void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) { - const char sep = TS_PATH_DELIMITER[0]; - - if (pToken == pTable || pToken == NULL || pTable == NULL) { - return; - } - - char* r = strnchr(pToken->z, sep, pToken->n, false); - - if (r != NULL) { // record the table name token - pTable->n = (uint32_t)(r - pToken->z); - pTable->z = pToken->z; - - r += 1; - pToken->n -= (uint32_t)(r - pToken->z); - pToken->z = r; - } -} +//void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) { +// const char sep = TS_PATH_DELIMITER[0]; +// +// if (pToken == pTable || pToken == NULL || pTable == NULL) { +// return; +// } +// +// char* r = strnchr(pToken->z, sep, pToken->n, false); +// +// if (r != NULL) { // record the table name token +// pTable->n = (uint32_t)(r - pToken->z); +// pTable->z = pToken->z; +// +// r += 1; +// pToken->n -= (uint32_t)(r - pToken->z); +// pToken->z = r; +// } +//} static struct SSchema _s = { .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, - .name = TSQL_TBNAME_L, + .name = "tbname", }; SSchema* tGetTbnameColumnSchema() { @@ -337,19 +306,19 @@ void tNameAssign(SName* dst, const SName* src) { memcpy(dst, src, sizeof(SName)); } -int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) { - assert(dst != NULL && dbToken != NULL && acct != NULL); - - // too long account id or too long db name - if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) { - return -1; - } - - dst->type = TSDB_DB_NAME_T; - tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); - tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1); - return 0; -} +//int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) { +// assert(dst != NULL && dbToken != NULL && acct != NULL); +// +// // too long account id or too long db name +// if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) { +// return -1; +// } +// +// dst->type = TSDB_DB_NAME_T; +// tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); +// tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1); +// return 0; +//} int32_t tNameSetAcctId(SName* dst, const char* acct) { assert(dst != NULL && acct != NULL); diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index bec8793b72..82f6a8e49a 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -13,9 +13,9 @@ * along with this program. If not, see . */ -#include "taos.h" -#include "os.h" #include "ttypes.h" +#include "../../../include/client/taos.h" +#include "os.h" #include "tcompression.h" const int32_t TYPE_BYTES[15] = { diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index c12650ee8b..93772847ad 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -14,13 +14,12 @@ */ #include "os.h" -#include "hash.h" #include "taos.h" +#include "thash.h" #include "taosdef.h" #include "ttime.h" -#include "ttoken.h" #include "ttokendef.h" -#include "ttype.h" +#include "ttypes.h" #include "tutil.h" #include "tvariant.h" @@ -30,12 +29,12 @@ if ((res) > (maxv)) { *exti = 1; break; } \ assert(0); \ } while (0) - -void tVariantCreate(tVariant *pVar, SStrToken *token) { +#if 0 +void tVariantCreate(SVariant *pVar, SToken *token) { int32_t ret = 0; int32_t type = token->type; - memset(pVar, 0, sizeof(tVariant)); + memset(pVar, 0, sizeof(SVariant)); switch (token->type) { case TSDB_DATA_TYPE_BOOL: { @@ -56,7 +55,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { case TSDB_DATA_TYPE_INT:{ ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true); if (ret != 0) { - SStrToken t = {0}; + SToken t = {0}; tGetToken(token->z, &t.type); if (t.type == TK_MINUS) { // it is a signed number which is greater than INT64_MAX or less than INT64_MIN pVar->nType = -1; // -1 means error type @@ -76,7 +75,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_FLOAT: { - pVar->dKey = strtod(token->z, NULL); + pVar->d = strtod(token->z, NULL); break; } @@ -97,15 +96,16 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { pVar->nType = type; } +#endif /** - * create tVariant from binary string, not ascii data + * create SVariant from binary string, not ascii data * @param pVar * @param pz * @param len * @param type */ -void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32_t type) { +void tVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type) { switch (type) { case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: { @@ -151,12 +151,12 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 } case TSDB_DATA_TYPE_DOUBLE: { pVar->nLen = tDataTypes[type].bytes; - pVar->dKey = GET_DOUBLE_VAL(pz); + pVar->d = GET_DOUBLE_VAL(pz); break; } case TSDB_DATA_TYPE_FLOAT: { pVar->nLen = tDataTypes[type].bytes; - pVar->dKey = GET_FLOAT_VAL(pz); + pVar->d = GET_FLOAT_VAL(pz); break; } case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length @@ -183,7 +183,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 pVar->nType = type; } -void tVariantDestroy(tVariant *pVar) { +void tVariantDestroy(SVariant *pVar) { if (pVar == NULL) return; if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { @@ -206,12 +206,12 @@ void tVariantDestroy(tVariant *pVar) { } } -bool tVariantIsValid(tVariant *pVar) { +bool tVariantIsValid(SVariant *pVar) { assert(pVar != NULL); return isValidDataType(pVar->nType); } -void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { +void tVariantAssign(SVariant *pDst, const SVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; pDst->nType = pSrc->nType; @@ -255,7 +255,7 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { } } -int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) { +int32_t tVariantCompare(const SVariant* p1, const SVariant* p2) { if (p1->nType == TSDB_DATA_TYPE_NULL && p2->nType == TSDB_DATA_TYPE_NULL) { return 0; } @@ -275,10 +275,10 @@ int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) { return p1->nLen > p2->nLen? 1:-1; } } else if (p1->nType == TSDB_DATA_TYPE_FLOAT || p1->nType == TSDB_DATA_TYPE_DOUBLE) { - if (p1->dKey == p2->dKey) { + if (p1->d == p2->d) { return 0; } else { - return p1->dKey > p2->dKey? 1:-1; + return p1->d > p2->d? 1:-1; } } else if (IS_UNSIGNED_NUMERIC_TYPE(p1->nType)) { if (p1->u64 == p2->u64) { @@ -295,7 +295,7 @@ int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) { } } -int32_t tVariantToString(tVariant *pVar, char *dst) { +int32_t tVariantToString(SVariant *pVar, char *dst) { if (pVar == NULL || dst == NULL) return 0; switch (pVar->nType) { @@ -329,7 +329,7 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { return sprintf(dst, "%" PRIu64, pVar->u64); case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_DOUBLE: - return sprintf(dst, "%.9lf", pVar->dKey); + return sprintf(dst, "%.9lf", pVar->d); default: return 0; @@ -360,11 +360,11 @@ static FORCE_INLINE int32_t wcsconvertToBoolImpl(wchar_t *pstr, int32_t len) { } } -static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { +static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) { const int32_t INITIAL_ALLOC_SIZE = 40; char * pBuf = NULL; - // it is a in-place convert type for tVariant, local buffer is needed + // it is a in-place convert type for SVariant, local buffer is needed if (*pDest == pVariant->pz) { pBuf = calloc(1, INITIAL_ALLOC_SIZE); } @@ -387,7 +387,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) { sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i64); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { - sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->dKey); + sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->d); } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { sprintf(pBuf == NULL ? *pDest : pBuf, "%s", (pVariant->i64 == TSDB_TRUE) ? "TRUE" : "FALSE"); } else if (pVariant->nType == 0) { // null data @@ -403,7 +403,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { return 0; } -static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { +static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { char tmpBuf[40] = {0}; char * pDst = tmpBuf; @@ -415,7 +415,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { nLen = sprintf(pDst, "%"PRIu64, pVariant->u64); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { - nLen = sprintf(pDst, "%lf", pVariant->dKey); + nLen = sprintf(pDst, "%lf", pVariant->d); } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { pDst = pVariant->pz; nLen = pVariant->nLen; @@ -461,30 +461,30 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { } static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) { - SStrToken stoken = {.z = pStr, .n = len}; - if (TK_ILLEGAL == tGetNumericStringType(&stoken)) { - return -1; - } - - *value = strtod(pStr, NULL); +// SToken stoken = {.z = pStr, .n = len}; +// if (TK_ILLEGAL == tGetNumericStringType(&stoken)) { +// return -1; +// } +// +// *value = strtod(pStr, NULL); return 0; } -static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result, int32_t type, bool issigned, bool releaseVariantPtr, bool *converted) { +static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result, int32_t type, bool issigned, bool releaseVariantPtr, bool *converted) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) { setNull((char *)result, type, tDataTypes[type].bytes); return 0; } - +#if 0 errno = 0; if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) { *result = pVariant->i64; } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { *result = pVariant->u64; } else if (IS_FLOAT_TYPE(pVariant->nType)) { - *result = (int64_t) pVariant->dKey; + *result = (int64_t) pVariant->d; } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { - SStrToken token = {.z = pVariant->pz, .n = pVariant->nLen}; + SToken token = {.z = pVariant->pz, .n = pVariant->nLen}; /*int32_t n = */tGetToken(pVariant->pz, &token.type); if (token.type == TK_NULL) { @@ -519,7 +519,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result errno = 0; wchar_t *endPtr = NULL; - SStrToken token = {0}; + SToken token = {0}; token.n = tGetToken(pVariant->pz, &token.type); if (token.type == TK_MINUS || token.type == TK_PLUS) { @@ -590,16 +590,19 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result code = IS_VALID_UBIGINT(ui); break; } + return code? 0:-1; +#endif + return 0; } -static int32_t convertToBool(tVariant *pVariant, int64_t *pDest) { +static int32_t convertToBool(SVariant *pVariant, int64_t *pDest) { if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { *pDest = pVariant->i64; // in order to be compatible to null of bool } else if (IS_NUMERIC_TYPE(pVariant->nType)) { *pDest = ((pVariant->i64 != 0) ? TSDB_TRUE : TSDB_FALSE); } else if (pVariant->nType == TSDB_DATA_TYPE_FLOAT || pVariant->nType == TSDB_DATA_TYPE_DOUBLE) { - *pDest = ((pVariant->dKey != 0) ? TSDB_TRUE : TSDB_FALSE); + *pDest = ((pVariant->d != 0) ? TSDB_TRUE : TSDB_FALSE); } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { int32_t ret = 0; if ((ret = convertToBoolImpl(pVariant->pz, pVariant->nLen)) < 0) { @@ -625,15 +628,7 @@ static int32_t convertToBool(tVariant *pVariant, int64_t *pDest) { * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType * to column type defined in schema */ -int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) { - return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL); -} - -/* - * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType - * to column type defined in schema - */ -int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo) { +int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo) { if (converted) { *converted = false; } @@ -766,12 +761,12 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc *converted = true; } - if (pVariant->dKey > FLT_MAX || pVariant->dKey < -FLT_MAX) { - SET_EXT_INFO(converted, pVariant->dKey, -FLT_MAX, FLT_MAX, extInfo); + if (pVariant->d > FLT_MAX || pVariant->d < -FLT_MAX) { + SET_EXT_INFO(converted, pVariant->d, -FLT_MAX, FLT_MAX, extInfo); return -1; } - SET_FLOAT_VAL(payload, pVariant->dKey); + SET_FLOAT_VAL(payload, pVariant->d); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((uint32_t *)payload) = TSDB_DATA_FLOAT_NULL; return 0; @@ -802,7 +797,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { SET_DOUBLE_VAL(payload, pVariant->i64); } else if (IS_FLOAT_TYPE(pVariant->nType)) { - SET_DOUBLE_VAL(payload, pVariant->dKey); + SET_DOUBLE_VAL(payload, pVariant->d); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; return 0; @@ -894,6 +889,13 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc return 0; } +/* + * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType + * to column type defined in schema + */ +int32_t tVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) { + return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL); +} /* * In variant, bool/smallint/tinyint/int/bigint share the same attribution of @@ -901,7 +903,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc * * It is actually the bigint/binary/bool/nchar type transfer */ -int32_t tVariantTypeSetType(tVariant *pVariant, char type) { +int32_t tVariantTypeSetType(SVariant *pVariant, char type) { if (pVariant == NULL || pVariant->nType == 0) { // value is not set return 0; } @@ -934,7 +936,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { } free(pVariant->pz); - pVariant->dKey = v; + pVariant->d = v; } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { errno = 0; double v = wcstod(pVariant->wpz, NULL); @@ -944,10 +946,10 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { } free(pVariant->pz); - pVariant->dKey = v; + pVariant->d = v; } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { double tmp = (double) pVariant->i64; - pVariant->dKey = tmp; + pVariant->d = tmp; } pVariant->nType = TSDB_DATA_TYPE_DOUBLE; diff --git a/source/libs/executor/CMakeLists.txt b/source/libs/executor/CMakeLists.txt index ae0cc6b1a8..9f02f4a4c7 100644 --- a/source/libs/executor/CMakeLists.txt +++ b/source/libs/executor/CMakeLists.txt @@ -4,4 +4,9 @@ target_include_directories( executor PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/executor" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) + +target_link_libraries( + executor + PRIVATE os util common ) \ No newline at end of file diff --git a/source/libs/executor/src/tarithoperator.h b/source/libs/executor/src/tarithoperator.h deleted file mode 100644 index e47cb5c1cb..0000000000 --- a/source/libs/executor/src/tarithoperator.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_COMMON_QARITHMETICOPERATOR_H_ -#define _TD_COMMON_QARITHMETICOPERATOR_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*_arithmetic_operator_fn_t)(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, - int32_t rightType, void *output, int32_t order); - -_arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_COMMON_QARITHMETICOPERATOR_H_*/ diff --git a/source/common/src/texpr.c b/source/libs/executor/src/texpr.c similarity index 95% rename from source/common/src/texpr.c rename to source/libs/executor/src/texpr.c index 01e1f71c2f..41856132b7 100644 --- a/source/common/src/texpr.c +++ b/source/libs/executor/src/texpr.c @@ -13,7 +13,6 @@ * along with this program. If not, see . */ -#include #include "os.h" #include "texpr.h" @@ -24,11 +23,11 @@ #include "tbuffer.h" #include "tcompare.h" #include "tname.h" -#include "hash.h" -// #include "tsdb.h" +#include "thash.h" #include "tskiplist.h" #include "texpr.h" #include "tarithoperator.h" +#include "tvariant.h" static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLeft, const tExprNode *pRight) { if (pLeft->nodeType == TSQL_NODE_COL) { @@ -287,7 +286,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { tbufWriteUint8(bw, expr->nodeType); if (expr->nodeType == TSQL_NODE_VALUE) { - tVariant* pVal = expr->pVal; + SVariant* pVal = expr->pVal; tbufWriteUint32(bw, pVal->nType); if (pVal->nType == TSDB_DATA_TYPE_BINARY) { @@ -355,7 +354,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->nodeType = tbufReadUint8(br); if (pExpr->nodeType == TSQL_NODE_VALUE) { - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); + SVariant* pVal = exception_calloc(1, sizeof(SVariant)); pExpr->pVal = pVal; pVal->nType = tbufReadUint32(br); @@ -416,7 +415,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { SSchema* pSchema = exception_calloc(1, sizeof(SSchema)); left->pSchema = pSchema; - *pSchema = *tGetTbnameColumnSchema(); +// *pSchema = NULL;//*tGetTbnameColumnSchema(); tExprNode* right = exception_calloc(1, sizeof(tExprNode)); expr->_node.pRight = right; @@ -424,7 +423,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN) == 0) { right->nodeType = TSQL_NODE_VALUE; expr->_node.optr = TSDB_RELATION_LIKE; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); + SVariant* pVal = exception_calloc(1, sizeof(SVariant)); right->pVal = pVal; size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN) + 1; pVal->pz = exception_malloc(len); @@ -435,7 +434,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN) == 0) { right->nodeType = TSQL_NODE_VALUE; expr->_node.optr = TSDB_RELATION_MATCH; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); + SVariant* pVal = exception_calloc(1, sizeof(SVariant)); right->pVal = pVal; size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN) + 1; pVal->pz = exception_malloc(len); @@ -445,7 +444,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN) == 0) { right->nodeType = TSQL_NODE_VALUE; expr->_node.optr = TSDB_RELATION_NMATCH; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); + SVariant* pVal = exception_calloc(1, sizeof(SVariant)); right->pVal = pVal; size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN) + 1; pVal->pz = exception_malloc(len); @@ -455,7 +454,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) { right->nodeType = TSQL_NODE_VALUE; expr->_node.optr = TSDB_RELATION_IN; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); + SVariant* pVal = exception_calloc(1, sizeof(SVariant)); right->pVal = pVal; pVal->nType = TSDB_DATA_TYPE_POINTER_ARRAY; pVal->arr = taosArrayInit(2, POINTER_BYTES); @@ -532,7 +531,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(tType)); int dummy = -1; - tVariant tmpVar = {0}; + SVariant tmpVar = {0}; size_t t = 0; int32_t sz = tbufReadInt32(&br); void *pvar = NULL; @@ -615,7 +614,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -624,7 +623,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t } case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -633,7 +632,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t } case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -643,7 +642,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -651,7 +650,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t break; } case TSDB_DATA_TYPE_DOUBLE: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -659,7 +658,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t break; } case TSDB_DATA_TYPE_FLOAT: { - if (tVariantDump(&tmpVar, (char *)&val, tType, false)) { + if (taosVariantDump(&tmpVar, (char *)&val, tType, false)) { goto err_ret; } pvar = &val; @@ -667,7 +666,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t break; } case TSDB_DATA_TYPE_BINARY: { - if (tVariantDump(&tmpVar, tmp, tType, true)) { + if (taosVariantDump(&tmpVar, tmp, tType, true)) { goto err_ret; } t = varDataLen(tmp); @@ -675,7 +674,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t break; } case TSDB_DATA_TYPE_NCHAR: { - if (tVariantDump(&tmpVar, tmp, tType, true)) { + if (taosVariantDump(&tmpVar, tmp, tType, true)) { goto err_ret; } t = varDataLen(tmp); @@ -716,7 +715,7 @@ tExprNode* exprdup(tExprNode* pNode) { pCloned->_node.optr = pNode->_node.optr; pCloned->_node.hasPK = pNode->_node.hasPK; } else if (pNode->nodeType == TSQL_NODE_VALUE) { - pCloned->pVal = calloc(1, sizeof(tVariant)); + pCloned->pVal = calloc(1, sizeof(SVariant)); tVariantAssign(pCloned->pVal, pNode->pVal); } else if (pNode->nodeType == TSQL_NODE_COL) { pCloned->pSchema = calloc(1, sizeof(SSchema)); diff --git a/source/libs/parser/inc/tvariant.h b/source/libs/parser/inc/tvariant.h deleted file mode 100644 index 4eb3120a79..0000000000 --- a/source/libs/parser/inc/tvariant.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_TVARIANT_H -#define TDENGINE_TVARIANT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "tarray.h" -#include "ttoken.h" - -// variant, each number/string/field_id has a corresponding struct during parsing sql -typedef struct SVariant { - uint32_t nType; - int32_t nLen; // only used for string, for number, it is useless - union { - int64_t i64; - uint64_t u64; - double d; - char *pz; - wchar_t *wpz; - SArray *arr; // only for 'in' query to hold value list, not value for a field - }; -} SVariant; - -bool taosVariantIsValid(SVariant *pVar); - -void taosVariantCreate(SVariant *pVar, SToken *token); - -void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type); - -void taosVariantDestroy(SVariant *pV); - -void taosVariantAssign(SVariant *pDst, const SVariant *pSrc); - -int32_t taosVariantCompare(const SVariant* p1, const SVariant* p2); - -int32_t taosVariantToString(SVariant *pVar, char *dst); - -int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix); - -#if 0 -int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo); -#endif - -int32_t taosVariantTypeSetType(SVariant *pVariant, char type); - -#ifdef __cplusplus -} -#endif - -#endif // TDENGINE_TVARIANT_H diff --git a/source/libs/parser/src/astGenerator.c b/source/libs/parser/src/astGenerator.c index 74642ea811..94f29907e9 100644 --- a/source/libs/parser/src/astGenerator.c +++ b/source/libs/parser/src/astGenerator.c @@ -13,9 +13,9 @@ * along with this program. If not, see . */ -#include "os.h" -#include "taos.h" #include "astGenerator.h" +#include "../../../../include/client/taos.h" +#include "os.h" int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bool issigned) { errno = 0; diff --git a/source/common/src/ttokenizer.c b/source/libs/parser/src/ttokenizer.c similarity index 98% rename from source/common/src/ttokenizer.c rename to source/libs/parser/src/ttokenizer.c index 289c4a6ef5..5e3cefea10 100644 --- a/source/common/src/ttokenizer.c +++ b/source/libs/parser/src/ttokenizer.c @@ -15,12 +15,10 @@ #include "os.h" -#include "hash.h" -#include "hashfunc.h" +#include "thash.h" #include "taosdef.h" #include "ttoken.h" #include "ttokendef.h" -#include "tutil.h" // All the keywords of the SQL language are stored in a hash table typedef struct SKeyword { @@ -575,12 +573,12 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { return 0; } -SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken) { +SToken tscReplaceStrToken(char **str, SToken *token, const char* newToken) { char *src = *str; size_t nsize = strlen(newToken); int32_t size = (int32_t)strlen(*str) - token->n + (int32_t)nsize + 1; int32_t bsize = (int32_t)((uint64_t)token->z - (uint64_t)src); - SStrToken ntoken; + SToken ntoken; *str = calloc(1, size); @@ -596,8 +594,8 @@ SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken) return ntoken; } -SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) { - SStrToken t0 = {0}; +SToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) { + SToken t0 = {0}; // here we reach the end of sql string, null-terminated string if (str[*i] == 0) { @@ -689,9 +687,9 @@ void taosCleanupKeywordsTable() { } } -SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len) { +SToken taosTokenDup(SToken* pToken, char* buf, int32_t len) { assert(pToken != NULL && buf != NULL); - SStrToken token = *pToken; + SToken token = *pToken; token.z = buf; assert(len > token.n); diff --git a/source/libs/planner/inc/plannerInt.h b/source/libs/planner/inc/plannerInt.h index fc08951c92..a673f8e486 100644 --- a/source/libs/planner/inc/plannerInt.h +++ b/source/libs/planner/inc/plannerInt.h @@ -23,6 +23,7 @@ extern "C" { #include "common.h" #include "tarray.h" #include "planner.h" +#include "taosmsg.h" typedef struct SQueryNodeBasicInfo { int32_t type; diff --git a/source/libs/transport/src/rpcMain.c b/source/libs/transport/src/rpcMain.c index 1f4a1ba3cf..fb555ea33f 100644 --- a/source/libs/transport/src/rpcMain.c +++ b/source/libs/transport/src/rpcMain.c @@ -25,7 +25,7 @@ #include "tglobal.h" #include "taosmsg.h" #include "trpc.h" -#include "hash.h" +#include "thash.h" #include "rpcLog.h" #include "rpcUdp.h" #include "rpcCache.h" diff --git a/source/server/dnode/inc/dnodeEps.h b/source/server/dnode/inc/dnodeEps.h index 80e2a2f488..8019a81933 100644 --- a/source/server/dnode/inc/dnodeEps.h +++ b/source/server/dnode/inc/dnodeEps.h @@ -19,7 +19,7 @@ #ifdef __cplusplus extern "C" { #endif -#include "hash.h" +#include "thash.h" #include "dnodeInt.h" typedef struct SDnEps { diff --git a/source/server/dnode/src/dnodeMain.c b/source/server/dnode/src/dnodeMain.c index 943ff61c13..410cb41eed 100644 --- a/source/server/dnode/src/dnodeMain.c +++ b/source/server/dnode/src/dnodeMain.c @@ -20,12 +20,12 @@ #if 0 #include "tfs.h" #endif -#include "tscompression.h" -#include "tnote.h" -#include "ttimer.h" #include "dnodeCfg.h" #include "dnodeMain.h" #include "mnode.h" +#include "tcompression.h" +#include "tnote.h" +#include "ttimer.h" static void dnodeCheckDataDirOpenned(char *dir) { #if 0 diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index bcfd2fc072..621f103207 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -433,7 +433,8 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { // NOTE: remove it from hash in the first place, otherwise, the pNode may have been released by other thread // when reaches here. SCacheDataNode *p = NULL; - int32_t ret = taosHashRemoveWithData(pCacheObj->pHashTable, pNode->key, pNode->keySize, &p, sizeof(void *)); + int32_t ret = taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize); +// int32_t ret = taosHashRemoveWithData(pCacheObj->pHashTable, pNode->key, pNode->keySize, &p, sizeof(void *)); ref = T_REF_DEC(pNode); // successfully remove from hash table, if failed, this node must have been move to trash already, do nothing. @@ -641,8 +642,8 @@ void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) { } void doCleanupDataCache(SCacheObj *pCacheObj) { - SHashTravSupp sup = {.pCacheObj = pCacheObj, .fp = NULL, .time = taosGetTimestampMs()}; - taosHashCondTraverse(pCacheObj->pHashTable, travHashTableEmptyFn, &sup); +// SHashTravSupp sup = {.pCacheObj = pCacheObj, .fp = NULL, .time = taosGetTimestampMs()}; +// taosHashCondTraverse(pCacheObj->pHashTable, travHashTableEmptyFn, &sup); // todo memory leak if there are object with refcount greater than 0 in hash table? taosHashCleanup(pCacheObj->pHashTable); @@ -679,7 +680,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_trav_fn_t assert(pCacheObj != NULL); SHashTravSupp sup = {.pCacheObj = pCacheObj, .fp = fp, .time = time, .param1 = param1}; - taosHashCondTraverse(pCacheObj->pHashTable, travHashTableFn, &sup); +// taosHashCondTraverse(pCacheObj->pHashTable, travHashTableFn, &sup); } void taosCacheRefreshWorkerUnexpectedStopped(void) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 4713de9772..b0dcff88e7 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -52,7 +52,7 @@ #ifdef TD_TSZ #include "td_sz.h" #endif -#include "tscompression.h" +#include "tcompression.h" #include "ulog.h" static const int TEST_NUMBER = 1; diff --git a/source/util/src/thash.c b/source/util/src/thash.c index 1bf6634cd4..448fc0ab2e 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -452,6 +452,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen/*, voi pNode = pNode->next; } + if (pNode) { code = 0; // it is found diff --git a/source/util/src/thashutil.c b/source/util/src/thashutil.c index 6b89cf700e..83f85bfdbc 100644 --- a/source/util/src/thashutil.c +++ b/source/util/src/thashutil.c @@ -163,21 +163,20 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type) { return fn; } -int32_t taosFloatEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) { - return getComparFunc(TSDB_DATA_TYPE_FLOAT, -1)(a, b); -} - -int32_t taosDoubleEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) { - return getComparFunc(TSDB_DATA_TYPE_DOUBLE, -1)(a, b); -} +//int32_t taosFloatEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) { +// return getComparFunc(TSDB_DATA_TYPE_FLOAT, -1)(a, b); +//} +// +//int32_t taosDoubleEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) { +// return getComparFunc(TSDB_DATA_TYPE_DOUBLE, -1)(a, b); +//} _equal_fn_t taosGetDefaultEqualFunction(int32_t type) { _equal_fn_t fn = NULL; - switch (type) { - case TSDB_DATA_TYPE_FLOAT: fn = taosFloatEqual; break; - case TSDB_DATA_TYPE_DOUBLE: fn = taosDoubleEqual; break; - default: fn = memcmp; break; - } +// switch (type) { +// case TSDB_DATA_TYPE_FLOAT: fn = taosFloatEqual; break; +// case TSDB_DATA_TYPE_DOUBLE: fn = taosDoubleEqual; break; +// default: fn = memcmp; break; +// } return fn; - } diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index ff796cdcbf..cc49728e35 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -22,8 +22,8 @@ extern "C" { #include "os.h" +#include "../../../include/client/taos.h" #include "qAggMain.h" -#include "taos.h" #include "taosdef.h" #include "taosmsg.h" #include "tarray.h" diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 506c8d64b9..0d22b44f5a 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -13,8 +13,8 @@ * along with this program. If not, see . */ +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" #include "tlog.h" #include "tscUtil.h" diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 07db18b498..0b4f399a1f 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -16,14 +16,14 @@ #include "os.h" #include "taosmsg.h" +#include "../../../include/client/taos.h" +#include "qTableMeta.h" #include "taosdef.h" #include "tname.h" #include "tscLog.h" -#include "tscUtil.h" -#include "qTableMeta.h" -#include "tsclient.h" -#include "taos.h" #include "tscSubquery.h" +#include "tscUtil.h" +#include "tsclient.h" #define STR_NOCASE_EQUAL(str1, len1, str2, len2) ((len1 == len2) && 0 == strncasecmp(str1, str2, len1)) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index e26e439492..20d52fbd3e 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -16,7 +16,7 @@ #include "tsclient.h" #include "tscLog.h" -#include "taos.h" +#include "../../../include/client/taos.h" #include "tscParseLine.h" typedef struct { diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 12f8ec84fd..1086f91bfd 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -3,9 +3,9 @@ #include #include +#include "../../../include/client/taos.h" #include "cJSON.h" #include "hash.h" -#include "taos.h" #include "tscUtil.h" #include "tsclient.h" diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index d0ac0ccf4e..17742d71e1 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -14,14 +14,14 @@ */ #include "os.h" -#include "taos.h" -#include "tsclient.h" -#include "tscUtil.h" -#include "ttimer.h" +#include "../../../include/client/taos.h" #include "taosmsg.h" -#include "tstrbuild.h" #include "tscLog.h" #include "tscSubquery.h" +#include "tscUtil.h" +#include "tsclient.h" +#include "tstrbuild.h" +#include "ttimer.h" int tsParseInsertSql(SSqlObj *pSql); int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start); diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index b00138b4c4..a9f65b84ce 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -21,7 +21,7 @@ #include "taosmsg.h" #include "tcq.h" -#include "taos.h" +#include "../../../include/client/taos.h" #include "tscUtil.h" void tscSaveSlowQueryFp(void *handle, void *tmrId); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 9746f79d9a..5b7ab5db65 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -21,13 +21,15 @@ #endif // __APPLE__ #include +#include "../../../include/client/taos.h" #include "os.h" -#include "regex.h" +#include "qFilter.h" #include "qPlan.h" +#include "qScript.h" #include "qSqlparser.h" #include "qTableMeta.h" #include "qUtil.h" -#include "taos.h" +#include "regex.h" #include "taosmsg.h" #include "tcompare.h" #include "texpr.h" @@ -38,9 +40,7 @@ #include "tstrbuild.h" #include "ttoken.h" #include "ttokendef.h" -#include "qScript.h" #include "ttype.h" -#include "qFilter.h" #define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0" @@ -2232,6 +2232,28 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum return numOfTotalColumns; } +SSchema tGetUserSpecifiedColumnSchema(SVariant* pVal, SStrToken* exprStr, const char* name) { + SSchema s = {0}; + + s.type = pVal->nType; + if (s.type == TSDB_DATA_TYPE_BINARY || s.type == TSDB_DATA_TYPE_NCHAR) { + s.bytes = (int16_t)(pVal->nLen + VARSTR_HEADER_SIZE); + } else { + s.bytes = tDataTypes[pVal->nType].bytes; + } + + s.colId = TSDB_UD_COLUMN_INDEX; + if (name != NULL) { + tstrncpy(s.name, name, sizeof(s.name)); + } else { + size_t tlen = MIN(sizeof(s.name), exprStr->n + 1); + tstrncpy(s.name, exprStr->z, tlen); + strdequote(s.name); + } + + return s; +} + int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem, bool outerQuery) { const char* msg1 = "tag for normal table query is not allowed"; const char* msg2 = "invalid column name"; diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 8f9b6a7252..a0af98a9d2 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -13,17 +13,17 @@ * along with this program. If not, see . */ +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" +#include "tcache.h" #include "trpc.h" +#include "tscLog.h" +#include "tscProfile.h" +#include "tscUtil.h" #include "tsclient.h" #include "tsocket.h" #include "ttimer.h" #include "tutil.h" -#include "tscLog.h" -#include "tscUtil.h" -#include "tcache.h" -#include "tscProfile.h" typedef struct SSubscriptionProgress { int64_t uid; diff --git a/src/connector/odbc/examples/c/main.c b/src/connector/odbc/examples/c/main.c index de01d2b85e..45edf6be5c 100644 --- a/src/connector/odbc/examples/c/main.c +++ b/src/connector/odbc/examples/c/main.c @@ -9,7 +9,7 @@ #include #include -#include "taos.h" +#include "../../../../../include/client/taos.h" #include "taoserror.h" #include diff --git a/src/connector/odbc/src/base.h b/src/connector/odbc/src/base.h index 1ec9827075..2a61e20e79 100644 --- a/src/connector/odbc/src/base.h +++ b/src/connector/odbc/src/base.h @@ -20,7 +20,7 @@ #include "todbc_iconv.h" #include "todbc_log.h" -#include "taos.h" +#include "../../../../include/client/taos.h" #include "taoserror.h" #include diff --git a/src/connector/odbc/src/todbc_tls.h b/src/connector/odbc/src/todbc_tls.h index e636f6ae6c..eb72a80eae 100644 --- a/src/connector/odbc/src/todbc_tls.h +++ b/src/connector/odbc/src/todbc_tls.h @@ -18,7 +18,7 @@ // !!! functions exported in this header file are all non-thread-safe !!! -#include "taos.h" +#include "../../../../include/client/taos.h" #include "todbc_buf.h" #include "todbc_iconv.h" diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index aac5a1c665..d2558e4650 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -20,15 +20,15 @@ #include #include -#include "taos.h" -#include "tsclient.h" +#include "../../../include/client/taos.h" #include "taosdef.h" #include "taosmsg.h" -#include "ttimer.h" #include "tcq.h" #include "tdataformat.h" #include "tglobal.h" #include "tlog.h" +#include "tsclient.h" +#include "ttimer.h" #include "twal.h" #define cFatal(...) { if (cqDebugFlag & DEBUG_FATAL) { taosPrintLog("CQ FATAL ", 255, __VA_ARGS__); }} diff --git a/src/kit/shell/inc/shell.h b/src/kit/shell/inc/shell.h index f207a866dd..10221a409a 100644 --- a/src/kit/shell/inc/shell.h +++ b/src/kit/shell/inc/shell.h @@ -16,10 +16,9 @@ #ifndef __SHELL__ #define __SHELL__ +#include "../../../../include/client/taos.h" #include "stdbool.h" -#include "taos.h" #include "taosdef.h" -#include "stdbool.h" #include "tsclient.h" #define MAX_USERNAME_SIZE 64 diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index cb707d9331..1244c7b060 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -12,9 +12,9 @@ #include #include #include +#include "../../../../include/client/taos.h" #include "os.h" #include "shell.h" -#include "taos.h" #include "shellCommand.h" extern char configDir[]; diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 9b3be1556a..858ae2264d 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -19,8 +19,8 @@ */ #include -#include #include +#include "../../../include/client/taos.h" #define _GNU_SOURCE #define CURL_STATICLIB @@ -49,8 +49,8 @@ #include #include "cJSON.h" +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" #include "taoserror.h" #include "tutil.h" diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index ef9e584978..3d59dfff4e 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -17,15 +17,14 @@ #include #include +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" #include "taosdef.h" #include "taosmsg.h" #include "tglobal.h" #include "tsclient.h" #include "tsdb.h" #include "tutil.h" -#include #define TSDB_SUPPORT_NANOSECOND 1 diff --git a/src/plugins/http/inc/httpGcJson.h b/src/plugins/http/inc/httpGcJson.h index 0ba860687d..eb79528c71 100644 --- a/src/plugins/http/inc/httpGcJson.h +++ b/src/plugins/http/inc/httpGcJson.h @@ -15,9 +15,9 @@ #ifndef TDENGINE_GC_JSON_H #define TDENGINE_GC_JSON_H +#include "../../../../include/client/taos.h" #include "httpHandle.h" #include "httpJson.h" -#include "taos.h" void gcInitQueryJson(HttpContext *pContext); void gcCleanQueryJson(HttpContext *pContext); diff --git a/src/plugins/http/inc/httpRestJson.h b/src/plugins/http/inc/httpRestJson.h index 5f19983826..d1f5a45521 100644 --- a/src/plugins/http/inc/httpRestJson.h +++ b/src/plugins/http/inc/httpRestJson.h @@ -16,9 +16,9 @@ #ifndef TDENGINE_REST_JSON_H #define TDENGINE_REST_JSON_H #include +#include "../../../../include/client/taos.h" #include "httpHandle.h" #include "httpJson.h" -#include "taos.h" #define REST_JSON_SUCCESS "succ" #define REST_JSON_SUCCESS_LEN 4 diff --git a/src/plugins/http/inc/httpTgJson.h b/src/plugins/http/inc/httpTgJson.h index 6b7d0681b6..a7ec4f8cb6 100644 --- a/src/plugins/http/inc/httpTgJson.h +++ b/src/plugins/http/inc/httpTgJson.h @@ -16,9 +16,9 @@ #ifndef TDENGINE_TG_JSON_H #define TDENGINE_TG_JSON_H +#include "../../../../include/client/taos.h" #include "httpHandle.h" #include "httpJson.h" -#include "taos.h" void tgInitQueryJson(HttpContext *pContext); void tgCleanQueryJson(HttpContext *pContext); diff --git a/src/plugins/http/src/httpQueue.c b/src/plugins/http/src/httpQueue.c index 677ab0c91d..917179078d 100644 --- a/src/plugins/http/src/httpQueue.c +++ b/src/plugins/http/src/httpQueue.c @@ -14,18 +14,18 @@ */ #define _DEFAULT_SOURCE -#include "os.h" -#include "tqueue.h" -#include "tnote.h" -#include "taos.h" -#include "tsclient.h" -#include "httpInt.h" -#include "httpContext.h" -#include "httpSql.h" -#include "httpResp.h" -#include "httpAuth.h" -#include "httpSession.h" #include "httpQueue.h" +#include "../../../../include/client/taos.h" +#include "httpAuth.h" +#include "httpContext.h" +#include "httpInt.h" +#include "httpResp.h" +#include "httpSession.h" +#include "httpSql.h" +#include "os.h" +#include "tnote.h" +#include "tqueue.h" +#include "tsclient.h" typedef struct { pthread_t thread; diff --git a/src/plugins/http/src/httpSession.c b/src/plugins/http/src/httpSession.c index 2e1ee7df2f..17c12d36a3 100644 --- a/src/plugins/http/src/httpSession.c +++ b/src/plugins/http/src/httpSession.c @@ -14,14 +14,14 @@ */ #define _DEFAULT_SOURCE -#include "os.h" -#include "taos.h" -#include "taoserror.h" -#include "tglobal.h" -#include "tcache.h" -#include "httpInt.h" -#include "httpContext.h" #include "httpSession.h" +#include "../../../../include/client/taos.h" +#include "httpContext.h" +#include "httpInt.h" +#include "os.h" +#include "taoserror.h" +#include "tcache.h" +#include "tglobal.h" void httpCreateSession(HttpContext *pContext, void *taos) { HttpServer *server = &tsHttpServer; diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 602767a656..28127f582a 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -14,18 +14,18 @@ */ #define _DEFAULT_SOURCE -#include "os.h" -#include "tnote.h" -#include "taos.h" -#include "taoserror.h" -#include "tsclient.h" -#include "httpInt.h" -#include "httpContext.h" #include "httpSql.h" -#include "httpResp.h" +#include "../../../../include/client/taos.h" #include "httpAuth.h" -#include "httpSession.h" +#include "httpContext.h" +#include "httpInt.h" #include "httpQueue.h" +#include "httpResp.h" +#include "httpSession.h" +#include "os.h" +#include "taoserror.h" +#include "tnote.h" +#include "tsclient.h" void httpProcessMultiSql(HttpContext *pContext); diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 085863f4e4..878a3251c0 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -14,23 +14,23 @@ */ #define _DEFAULT_SOURCE +#include "../../../../include/client/taos.h" +#include "httpContext.h" +#include "httpGcHandle.h" +#include "httpHandle.h" +#include "httpInt.h" +#include "httpMetricsHandle.h" +#include "httpQueue.h" +#include "httpResp.h" +#include "httpRestHandle.h" +#include "httpServer.h" +#include "httpSession.h" +#include "httpTgHandle.h" #include "os.h" -#include "taos.h" +#include "tadmin.h" #include "tglobal.h" #include "tsocket.h" #include "ttimer.h" -#include "tadmin.h" -#include "httpInt.h" -#include "httpContext.h" -#include "httpSession.h" -#include "httpServer.h" -#include "httpResp.h" -#include "httpHandle.h" -#include "httpQueue.h" -#include "httpGcHandle.h" -#include "httpRestHandle.h" -#include "httpTgHandle.h" -#include "httpMetricsHandle.h" #ifndef _ADMIN void adminInitHandle(HttpServer* pServer) {} diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index f30ac7326e..12f3a6efd8 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE -#include "os.h" -#include "tmd5.h" -#include "taos.h" +#include "httpUtil.h" +#include "../../../../include/client/taos.h" #include "httpInt.h" #include "httpResp.h" #include "httpSql.h" -#include "httpUtil.h" +#include "os.h" +#include "tmd5.h" #include "ttoken.h" bool httpCheckUsedbSql(char *sql) { diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c index e0f2f393bb..d0c33d43a8 100644 --- a/src/plugins/mqtt/src/mqttSystem.c +++ b/src/plugins/mqtt/src/mqttSystem.c @@ -14,16 +14,16 @@ */ #define _DEFAULT_SOURCE -#include "os.h" +#include "../../../../include/client/taos.h" #include "mqtt.h" #include "mqttInit.h" #include "mqttLog.h" #include "mqttPayload.h" -#include "tmqtt.h" +#include "os.h" #include "posix_sockets.h" -#include "taos.h" -#include "tglobal.h" #include "taoserror.h" +#include "tglobal.h" +#include "tmqtt.h" struct SMqttReconnectState tsMqttStatus = {0}; struct mqtt_client tsMqttClient = {0}; diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index c231c90996..445380f40a 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -20,7 +20,7 @@ extern "C" { #endif -#include "taos.h" +#include "../../../include/client/taos.h" #include "taosmsg.h" #include "tstrbuild.h" #include "ttoken.h" diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index 2ff9874856..35cd7eeac2 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -12,16 +12,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#include "qExtbuffer.h" +#include "../../../include/client/taos.h" #include "os.h" #include "qAggMain.h" +#include "qExecutor.h" #include "queryLog.h" -#include "taos.h" #include "taosdef.h" #include "taosmsg.h" -#include "tulog.h" -#include "qExecutor.h" -#include "qExtbuffer.h" #include "tcompare.h" +#include "tulog.h" #define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \ (data + (schema)->pFields[colId].offset * (allrow) + (rowId) * (schema)->pFields[colId].field.bytes) diff --git a/tests/comparisonTest/tdengine/tdengineTest.c b/tests/comparisonTest/tdengine/tdengineTest.c index 0de419e036..21863b3234 100644 --- a/tests/comparisonTest/tdengine/tdengineTest.c +++ b/tests/comparisonTest/tdengine/tdengineTest.c @@ -1,13 +1,13 @@ +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include "../../../include/client/taos.h" typedef struct { char sql[256]; diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 28e8d3f012..9f4c7678ec 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -7,9 +7,8 @@ #include #include #include -#include #include - +#include "../../../include/client/taos.h" static void prepare_data(TAOS* taos) { TAOS_RES *result; diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c index f2a96dd825..9e214e0966 100644 --- a/tests/examples/c/asyncdemo.c +++ b/tests/examples/c/asyncdemo.c @@ -24,7 +24,7 @@ #include #include -#include +#include "../../../include/client/taos.h" int points = 5; int numOfTables = 3; diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index f8c69d0043..c3d9a5e96a 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -16,11 +16,11 @@ // TAOS standard API example. The same syntax as MySQL, but only a subset // to compile: gcc -o demo demo.c -ltaos +#include #include #include #include -#include -#include // TAOS header file +#include "../../../include/client/taos.h" // TAOS header file static void queryDB(TAOS *taos, char *command) { int i; diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c index 723b340a92..f0341cfe12 100644 --- a/tests/examples/c/prepare.c +++ b/tests/examples/c/prepare.c @@ -4,8 +4,7 @@ #include #include #include -#include "taos.h" - +#include "../../../include/client/taos.h" void taosMsleep(int mseconds); diff --git a/tests/examples/c/schemaless.c b/tests/examples/c/schemaless.c index 1a551cc5f7..21f39213cd 100644 --- a/tests/examples/c/schemaless.c +++ b/tests/examples/c/schemaless.c @@ -1,6 +1,6 @@ -#include "taos.h" -#include "taoserror.h" +#include "../../../include/client/taos.h" #include "os.h" +#include "taoserror.h" #include #include diff --git a/tests/examples/c/stream.c b/tests/examples/c/stream.c index 30a790f061..41365813ae 100644 --- a/tests/examples/c/stream.c +++ b/tests/examples/c/stream.c @@ -13,12 +13,12 @@ * along with this program. If not, see . */ +#include #include #include #include -#include #include -#include // include TDengine header file +#include "../../../include/client/taos.h" // include TDengine header file typedef struct { char server_ip[64]; diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c index ad12f0e7a5..66d64d295c 100644 --- a/tests/examples/c/subscribe.c +++ b/tests/examples/c/subscribe.c @@ -4,8 +4,8 @@ #include #include #include -#include // include TDengine header file #include +#include "../../../include/client/taos.h" // include TDengine header file int nTotalRows; diff --git a/tests/examples/lua/lua51/lua_connector51.c b/tests/examples/lua/lua51/lua_connector51.c index fe2152945d..578622bf1f 100644 --- a/tests/examples/lua/lua51/lua_connector51.c +++ b/tests/examples/lua/lua51/lua_connector51.c @@ -1,11 +1,11 @@ -#include #include #include +#include #include -#include "lua.h" +#include "../../../../include/client/taos.h" #include "lauxlib.h" +#include "lua.h" #include "lualib.h" -#include struct cb_param{ lua_State* state; diff --git a/tests/examples/lua/lua_connector.c b/tests/examples/lua/lua_connector.c index 8c2ea3e9e8..76634ed254 100644 --- a/tests/examples/lua/lua_connector.c +++ b/tests/examples/lua/lua_connector.c @@ -1,11 +1,11 @@ -#include +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include +#include "../../../include/client/taos.h" struct cb_param{ lua_State* state; diff --git a/tests/robust/robust.c b/tests/robust/robust.c index 3488ca1b9b..1e2eb5c7be 100644 --- a/tests/robust/robust.c +++ b/tests/robust/robust.c @@ -1,10 +1,10 @@ +#include #include #include #include -#include -#include #include #include +#include "../../include/client/taos.h" typedef struct { char querySQL[256]; diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 72bb9471db..386df15d86 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -1,13 +1,13 @@ // TAOS standard API example. The same syntax as MySQL, but only a subet // to compile: gcc -o prepare prepare.c -ltaos +#include #include #include #include -#include "taos.h" #include -#include #include +#include "../../../include/client/taos.h" typedef struct { TAOS *taos; diff --git a/tests/script/api/stmtBatchTest.c b/tests/script/api/stmtBatchTest.c index c488f2fa89..eb7845714e 100644 --- a/tests/script/api/stmtBatchTest.c +++ b/tests/script/api/stmtBatchTest.c @@ -1,14 +1,14 @@ // TAOS standard API example. The same syntax as MySQL, but only a subet // to compile: gcc -o prepare prepare.c -ltaos +#include #include #include #include -#include "taos.h" -#include "taoserror.h" #include -#include #include +#include "../../../include/client/taos.h" +#include "taoserror.h" #define MAX_ROWS_OF_PER_COLUMN 32770 #define MAX_BINARY_DEF_LEN (1024*16) diff --git a/tests/script/api/stmtTest.c b/tests/script/api/stmtTest.c index 9595fe5b2d..c69de46f84 100644 --- a/tests/script/api/stmtTest.c +++ b/tests/script/api/stmtTest.c @@ -1,10 +1,10 @@ +#include #include #include #include -#include "taos.h" #include -#include #include +#include "../../../include/client/taos.h" #define PRINT_ERROR printf("\033[31m"); #define PRINT_SUCCESS printf("\033[32m"); diff --git a/tests/script/api/stmt_function.c b/tests/script/api/stmt_function.c index 64573ec994..4521ad4fa3 100644 --- a/tests/script/api/stmt_function.c +++ b/tests/script/api/stmt_function.c @@ -1,11 +1,11 @@ +#include +#include #include #include #include -#include "taos.h" #include -#include #include -#include +#include "../../../include/client/taos.h" void execute_simple_sql(void *taos, char *sql) { TAOS_RES *result = taos_query(taos, sql); diff --git a/tests/test/c/cacheTest.c b/tests/test/c/cacheTest.c index 54aca0038e..ce5d7d1421 100644 --- a/tests/test/c/cacheTest.c +++ b/tests/test/c/cacheTest.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" #include "tcache.h" #include "tulog.h" #include "tutil.h" diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c index 60253e2add..f9e4aa5a3a 100644 --- a/tests/test/c/createNormalTable.c +++ b/tests/test/c/createNormalTable.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "hash.h" #include "os.h" #include "taoserror.h" -#include "taos.h" +#include "tglobal.h" #include "tulog.h" #include "tutil.h" -#include "tglobal.h" -#include "hash.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/createTablePerformance.c b/tests/test/c/createTablePerformance.c index b94c687f2c..1a59657f1a 100644 --- a/tests/test/c/createTablePerformance.c +++ b/tests/test/c/createTablePerformance.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "hash.h" #include "os.h" #include "taoserror.h" -#include "taos.h" +#include "tglobal.h" #include "tulog.h" #include "tutil.h" -#include "tglobal.h" -#include "hash.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/hashIterator.c b/tests/test/c/hashIterator.c index cbd8a0895e..0d3dbb64d7 100644 --- a/tests/test/c/hashIterator.c +++ b/tests/test/c/hashIterator.c @@ -14,11 +14,11 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "hash.h" #include "os.h" -#include "taos.h" #include "tulog.h" #include "tutil.h" -#include "hash.h" typedef struct HashTestRow { int32_t keySize; diff --git a/tests/test/c/hashPerformance.c b/tests/test/c/hashPerformance.c index 111ea25a09..0f14fbff6a 100644 --- a/tests/test/c/hashPerformance.c +++ b/tests/test/c/hashPerformance.c @@ -14,11 +14,11 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "hash.h" #include "os.h" -#include "taos.h" #include "tulog.h" #include "tutil.h" -#include "hash.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/importOneRow.c b/tests/test/c/importOneRow.c index 858926106c..510f780163 100644 --- a/tests/test/c/importOneRow.c +++ b/tests/test/c/importOneRow.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" -#include "tulog.h" -#include "ttimer.h" -#include "tutil.h" #include "tglobal.h" +#include "ttimer.h" +#include "tulog.h" +#include "tutil.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c index 68f7898050..7aef676c97 100644 --- a/tests/test/c/importPerTable.c +++ b/tests/test/c/importPerTable.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" -#include "tulog.h" -#include "ttimer.h" -#include "tutil.h" -#include "tglobal.h" #include "osTime.h" +#include "tglobal.h" +#include "ttimer.h" +#include "tulog.h" +#include "tutil.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/insertPerRow.c b/tests/test/c/insertPerRow.c index 824c1b925a..bdf27180b2 100644 --- a/tests/test/c/insertPerRow.c +++ b/tests/test/c/insertPerRow.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" -#include "tulog.h" -#include "ttimer.h" -#include "tutil.h" #include "tglobal.h" +#include "ttimer.h" +#include "tulog.h" +#include "tutil.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/insertPerTable.c b/tests/test/c/insertPerTable.c index d79df0f4d1..ac3c06f0f3 100644 --- a/tests/test/c/insertPerTable.c +++ b/tests/test/c/insertPerTable.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" -#include "tulog.h" -#include "ttimer.h" -#include "tutil.h" #include "tglobal.h" +#include "ttimer.h" +#include "tulog.h" +#include "tutil.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/invalidTableId.c b/tests/test/c/invalidTableId.c index 581387a4ee..286d0f1291 100644 --- a/tests/test/c/invalidTableId.c +++ b/tests/test/c/invalidTableId.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "hash.h" #include "os.h" #include "taoserror.h" -#include "taos.h" +#include "tglobal.h" #include "tulog.h" #include "tutil.h" -#include "tglobal.h" -#include "hash.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/test/c/queryPerformance.c b/tests/test/c/queryPerformance.c index eda082dd4f..afe5cd0ccb 100644 --- a/tests/test/c/queryPerformance.c +++ b/tests/test/c/queryPerformance.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" -#include "taos.h" -#include "tulog.h" -#include "ttimer.h" -#include "tutil.h" #include "tglobal.h" +#include "ttimer.h" +#include "tulog.h" +#include "tutil.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" diff --git a/tests/tsim/inc/sim.h b/tests/tsim/inc/sim.h index 2e19dde3d9..39c6f6ac36 100644 --- a/tests/tsim/inc/sim.h +++ b/tests/tsim/inc/sim.h @@ -20,7 +20,7 @@ #include #include -#include "taos.h" +#include "../../../include/client/taos.h" #include "tidpool.h" #include "tlog.h" #include "tutil.h" diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 397accfea5..7a75dd7d85 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" +#include "cJSON.h" #include "os.h" #include "sim.h" -#include "taos.h" #include "taoserror.h" #include "tglobal.h" #include "tutil.h" -#include "cJSON.h" #undef TAOS_MEM_CHECK void simLogSql(char *sql, bool useSharp) { diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c index 0879e371ef..65612930ef 100644 --- a/tests/tsim/src/simSystem.c +++ b/tests/tsim/src/simSystem.c @@ -14,14 +14,14 @@ */ #define _DEFAULT_SOURCE +#include "../../../include/client/taos.h" #include "os.h" #include "sim.h" -#include "taos.h" +#include "taoserror.h" #include "tglobal.h" +#include "tsocket.h" #include "ttimer.h" #include "tutil.h" -#include "tsocket.h" -#include "taoserror.h" #undef TAOS_MEM_CHECK SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];