diff --git a/include/common/tname.h b/include/common/tname.h index 7578a7804cccae575ec35becd3da6f595150b9bf..e31bfd38a67dd5e01e6a3246e490d998bf50331f 100644 --- a/include/common/tname.h +++ b/include/common/tname.h @@ -16,7 +16,7 @@ #ifndef TDENGINE_TNAME_H #define TDENGINE_TNAME_H -#include "taosmsg.h" +//#include "taosmsg.h" #define TSDB_DB_NAME_T 1 #define TSDB_TABLE_NAME_T 2 @@ -27,7 +27,7 @@ typedef struct SName { uint8_t type; //db_name_t, table_name_t - char acctId[TSDB_ACCT_ID_LEN]; + int32_t acctId; char dbname[TSDB_DB_NAME_LEN]; char tname[TSDB_TABLE_NAME_LEN]; } SName; @@ -38,7 +38,7 @@ int32_t tNameLen(const SName* name); SName* tNameDup(const SName* name); -bool tIsValidName(const SName* name); +bool tNameIsValid(const SName* name); const char* tNameGetTableName(const SName* name); @@ -50,14 +50,10 @@ bool tNameIsEmpty(const SName* name); void tNameAssign(SName* dst, const SName* src); -int32_t tNameFromString(SName* dst, const char* str, uint32_t type); - -int32_t tNameSetAcctId(SName* dst, const char* acct); +int32_t tNameSetDbName(SName* dst, int32_t acctId, const char* dbName, size_t nameLen); -SSchema* tGetTbnameColumnSchema(); +int32_t tNameFromString(SName* dst, const char* str, uint32_t type); -#if 0 -int32_t tNameSetDbName(SName* dst, const char* acct, SToken* dbToken); -#endif +int32_t tNameSetAcctId(SName* dst, int32_t acctId); #endif // TDENGINE_TNAME_H diff --git a/include/libs/query/query.h b/include/libs/qcom/query.h similarity index 99% rename from include/libs/query/query.h rename to include/libs/qcom/query.h index f8c7d787ba1c44b23e9354b6c03e7296234959c0..fbfa19e5a53d4e1f6a9bd7ce579b48e6282fa9d8 100644 --- a/include/libs/query/query.h +++ b/include/libs/qcom/query.h @@ -84,9 +84,9 @@ typedef struct STableMetaOutput { extern int32_t (*queryBuildMsg[TSDB_MSG_TYPE_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen); extern int32_t (*queryProcessMsgRsp[TSDB_MSG_TYPE_MAX])(void* output, char *msg, int32_t msgSize); +SSchema* tGetTbnameColumnSchema(); extern void msgInit(); - extern int32_t qDebugFlag; #define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", qDebugFlag, __VA_ARGS__); }} while(0) diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 61b60e5ba631408ae181cb9b0a84820079371f61..c78bf02cbdf73ab0fa3fb7e34814945a870f8aac 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -2,14 +2,13 @@ aux_source_directory(src CLIENT_SRC) add_library(taos ${CLIENT_SRC}) target_include_directories( taos - PUBLIC "${CMAKE_SOURCE_DIR}/include/client" - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" + PUBLIC "${CMAKE_SOURCE_DIR}/include/client" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( taos - PRIVATE common INTERFACE api - PRIVATE os util common transport parser catalog function query + PRIVATE os util common transport parser catalog function qcom ) ADD_SUBDIRECTORY(test) \ No newline at end of file diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 9ef1d67e744d86bf2b39f27cc2bb622508c180a7..4e7fff06b6bd60f015764745d8d093046e812fd6 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -76,11 +76,10 @@ typedef struct SAppInfo { typedef struct STscObj { char user[TSDB_USER_LEN]; char pass[TSDB_PASSWORD_LEN]; - char acctId[TSDB_ACCT_ID_LEN]; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; + int32_t acctId; uint32_t connId; uint64_t id; // ref ID returned by taosAddRef -// struct SSqlObj *sqlList; void *pTransporter; pthread_mutex_t mutex; // used to protect the operation on db int32_t numOfReqs; // number of sqlObj from this tscObj diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c038799bb465da85315f05d11a764bbcd1350c82..d0c6d99c275d6570d7f72b4fea3d959705674801 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -153,7 +153,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { void* output = NULL; int32_t outputLen = 0; code = qParseQuerySql(pRequest->sqlstr, sqlLen, pRequest->requestId, &type, &output, &outputLen, pRequest->msgBuf, ERROR_MSG_BUF_DEFAULT_SIZE); - if (type == TSDB_SQL_CREATE_USER || type == TSDB_SQL_SHOW) { + if (type == TSDB_SQL_CREATE_USER || type == TSDB_SQL_SHOW || type == TSDB_SQL_DROP_USER || type == TSDB_SQL_CREATE_DB) { pRequest->type = type; pRequest->body.param = output; pRequest->body.paramLen = outputLen; diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 646964e31967dfd205aa4850b8d7d9283428aaaf..36fa013f27e0b31f7d0124a3f6e8feccd19d345a 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -14,6 +14,7 @@ */ #include +#include #include "clientInt.h" #include "clientLog.h" #include "os.h" @@ -2885,7 +2886,7 @@ int32_t getMultiTableMetaFromMnode(SSqlObj *pSql, SArray* pNameList, SArray* pVg } int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool autocreate, bool onlyLocal) { - assert(tIsValidName(&pTableMetaInfo->name)); + assert(tNameIsValid(&pTableMetaInfo->name)); char name[TSDB_TABLE_FNAME_LEN] = {0}; tNameExtractFullName(&pTableMetaInfo->name, name); @@ -3138,7 +3139,7 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { // TODO refactor pthread_mutex_lock(&pTscObj->mutex); char temp[TSDB_TABLE_FNAME_LEN * 2] = {0}; - int32_t len = sprintf(temp, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pTscObj->db); + int32_t len = sprintf(temp, "%d%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pTscObj->db); assert(len <= sizeof(pTscObj->db)); tstrncpy(pTscObj->db, temp, sizeof(pTscObj->db)); @@ -3153,6 +3154,7 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { } pTscObj->connId = pConnect->connId; + pTscObj->acctId = pConnect->acctId; // update the appInstInfo pTscObj->pAppInfo->clusterId = pConnect->clusterId; @@ -3165,19 +3167,33 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { return 0; } -int32_t buildCreateUserMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) { - pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_USER; - pMsgBody->msgLen = sizeof(SCreateUserMsg); +int32_t doBuildMsgSupp(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) { pMsgBody->requestObjRefId = pRequest->self; - pMsgBody->pData = pRequest->body.param; - return 0; -} - -int32_t buildShowMsg(SRequestObj* pRequest, SRequestMsgBody* pMsgBody) { - pMsgBody->msgType = TSDB_MSG_TYPE_SHOW; pMsgBody->msgLen = pRequest->body.paramLen; - pMsgBody->requestObjRefId = pRequest->self; pMsgBody->pData = pRequest->body.param; + + switch(pRequest->type) { + case TSDB_SQL_CREATE_USER: + pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_USER; + break; + case TSDB_SQL_CREATE_DB: { + pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_DB; + + SCreateDbMsg* pCreateMsg = pRequest->body.param; + SName name = {0}; + int32_t ret = tNameSetDbName(&name, pRequest->pTscObj->acctId, pCreateMsg->db, strnlen(pCreateMsg->db, tListLen(pCreateMsg->db))); + if (ret != TSDB_CODE_SUCCESS) { + return -1; + } + + tNameGetFullDbName(&name, pCreateMsg->db); + + break; + } + case TSDB_SQL_SHOW: + pMsgBody->msgType = TSDB_MSG_TYPE_SHOW; + break; + } } STableMeta* createTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { @@ -3283,6 +3299,9 @@ int32_t processRetrieveMnodeRsp(SRequestObj *pRequest, const char* pMsg, int32_t return 0; } +int32_t processCreateDbRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { + // todo rsp with the vnode id list +} void initMsgHandleFp() { #if 0 @@ -3363,11 +3382,14 @@ void initMsgHandleFp() { buildRequestMsgFp[TSDB_SQL_CONNECT] = buildConnectMsg; handleRequestRspFp[TSDB_SQL_CONNECT] = processConnectRsp; - buildRequestMsgFp[TSDB_SQL_CREATE_USER] = buildCreateUserMsg; + buildRequestMsgFp[TSDB_SQL_CREATE_USER] = doBuildMsgSupp; - buildRequestMsgFp[TSDB_SQL_SHOW] = buildShowMsg; + buildRequestMsgFp[TSDB_SQL_SHOW] = doBuildMsgSupp; handleRequestRspFp[TSDB_SQL_SHOW] = processShowRsp; buildRequestMsgFp[TSDB_SQL_RETRIEVE_MNODE] = buildRetrieveMnodeMsg; handleRequestRspFp[TSDB_SQL_RETRIEVE_MNODE]= processRetrieveMnodeRsp; + + buildRequestMsgFp[TSDB_SQL_CREATE_DB] = doBuildMsgSupp; + handleRequestRspFp[TSDB_SQL_CREATE_DB] = processCreateDbRsp; } \ No newline at end of file diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 46fd76234e13de5a392c6ab6b0edbf8e1d8d3869..944247e88e57901d57bdaf18a1025c53b08ad107 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -57,25 +57,38 @@ TEST(testCase, create_user_Test) { taos_close(pConn); } -//TEST(testCase, show_user_Test) { +//TEST(testCase, drop_user_Test) { // TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); // assert(pConn != NULL); // -// TAOS_RES* pRes = taos_query(pConn, "show users"); -// TAOS_ROW pRow = NULL; -// -// TAOS_FIELD* pFields = taos_fetch_fields(pRes); -// int32_t numOfFields = taos_num_fields(pRes); -// -// char str[512] = {0}; -// while((pRow = taos_fetch_row(pRes)) != NULL) { -// int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); +// TAOS_RES* pRes = taos_query(pConn, "drop user abc"); +// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { +// printf("failed to create user, reason:%s\n", taos_errstr(pRes)); // } // +// taos_free_result(pRes); // taos_close(pConn); //} +TEST(testCase, show_user_Test) { + TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "show users"); + TAOS_ROW pRow = NULL; + + TAOS_FIELD* pFields = taos_fetch_fields(pRes); + int32_t numOfFields = taos_num_fields(pRes); + + char str[512] = {0}; + while((pRow = taos_fetch_row(pRes)) != NULL) { + int32_t code = taos_print_row(str, pRow, pFields, numOfFields); + printf("%s\n", str); + } + + taos_close(pConn); +} + TEST(testCase, show_db_Test) { TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); assert(pConn != NULL); @@ -94,3 +107,18 @@ TEST(testCase, show_db_Test) { taos_close(pConn); } + +TEST(testCase, create_db_Test) { + TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "create database abc"); + + TAOS_FIELD* pFields = taos_fetch_fields(pRes); + ASSERT_TRUE(pFields == NULL); + + int32_t numOfFields = taos_num_fields(pRes); + ASSERT_EQ(numOfFields, 0); + + taos_close(pConn); +} diff --git a/source/common/src/tname.c b/source/common/src/tname.c index 28f920a6a98b539ac82216f84af71ffc78abd0ff..fa303fe4e923317c276ccc025499593ca3a8b66a 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -4,9 +4,6 @@ #include "tname.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) char* extractDBName(const char* tableId, char* name) { @@ -120,84 +117,11 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in #endif -static struct SSchema _s = { - .colId = TSDB_TBNAME_COLUMN_INDEX, - .type = TSDB_DATA_TYPE_BINARY, - .bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, - .name = "tbname", -}; - -SSchema* tGetTbnameColumnSchema() { - return &_s; -} - -static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen) { - int32_t rowLen = 0; - - for (int32_t i = 0; i < numOfCols; ++i) { - // 1. valid types - if (!isValidDataType(pSchema[i].type)) { - return false; - } - - // 2. valid length for each type - if (pSchema[i].type == TSDB_DATA_TYPE_BINARY) { - if (pSchema[i].bytes > TSDB_MAX_BINARY_LEN) { - return false; - } - } else if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { - if (pSchema[i].bytes > TSDB_MAX_NCHAR_LEN) { - return false; - } - } else { - if (pSchema[i].bytes != tDataTypes[pSchema[i].type].bytes) { - return false; - } - } - - // 3. valid column names - for (int32_t j = i + 1; j < numOfCols; ++j) { - if (strncasecmp(pSchema[i].name, pSchema[j].name, sizeof(pSchema[i].name) - 1) == 0) { - return false; - } - } - - rowLen += pSchema[i].bytes; - } - - return rowLen <= maxLen; -} - -bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) { - if (!VALIDNUMOFCOLS(numOfCols)) { - return false; - } - - if (!VALIDNUMOFTAGS(numOfTags)) { - return false; - } - - /* first column must be the timestamp, which is a primary key */ - if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) { - return false; - } - - if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) { - return false; - } - - if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) { - return false; - } - - return true; -} - int32_t tNameExtractFullName(const SName* name, char* dst) { assert(name != NULL && dst != NULL); // invalid full name format, abort - if (!tIsValidName(name)) { + if (!tNameIsValid(name)) { return -1; } @@ -230,7 +154,7 @@ int32_t tNameLen(const SName* name) { } } -bool tIsValidName(const SName* name) { +bool tNameIsValid(const SName* name) { assert(name != NULL); if (!VALID_NAME_TYPE(name->type)) { @@ -265,13 +189,13 @@ int32_t tNameGetDbName(const SName* name, char* dst) { int32_t tNameGetFullDbName(const SName* name, char* dst) { assert(name != NULL && dst != NULL); snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, // there is a over write risk - "%s.%s", name->acctId, name->dbname); + "%d.%s", name->acctId, name->dbname); return 0; } bool tNameIsEmpty(const SName* name) { assert(name != NULL); - return name->type == 0 || strlen(name->acctId) <= 0; + return name->type == 0 || name->acctId == 0; } const char* tNameGetTableName(const SName* name) { @@ -283,32 +207,23 @@ 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 tNameSetAcctId(SName* dst, const char* acct) { - assert(dst != NULL && acct != NULL); +int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t nameLen) { + assert(dst != NULL && dbName != NULL && nameLen > 0); // too long account id or too long db name - if (strlen(acct) >= tListLen(dst->acctId)) { + if (nameLen >= tListLen(dst->dbname)) { return -1; } - tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); + dst->type = TSDB_DB_NAME_T; + dst->acctId = acct; + tstrncpy(dst->dbname, dbName, nameLen + 1); + return 0; +} - assert(strlen(dst->acctId) > 0); - +int32_t tNameSetAcctId(SName* dst, int32_t acctId) { + assert(dst != NULL && acct != NULL); + dst->acctId = acctId; return 0; } @@ -325,14 +240,11 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { int32_t len = (int32_t)(p - str); // too long account id or too long db name - if ((len >= tListLen(dst->acctId)) || (len <= 0)) { - return -1; - } - - memcpy (dst->acctId, str, len); - dst->acctId[len] = 0; - - assert(strlen(dst->acctId) > 0); +// if ((len >= tListLen(dst->acctId)) || (len <= 0)) { +// return -1; +// } +// memcpy (dst->acctId, str, len); + dst->acctId = strtoll(str, NULL, 10); } if ((type & T_NAME_DB) == T_NAME_DB) { diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt index 57a5023807507baa44261430056c6d6b885875f0..636cf0a9a84453458ec0d06b84231f926a4637b5 100644 --- a/source/libs/CMakeLists.txt +++ b/source/libs/CMakeLists.txt @@ -10,4 +10,4 @@ add_subdirectory(catalog) add_subdirectory(executor) add_subdirectory(planner) add_subdirectory(function) -add_subdirectory(query) +add_subdirectory(qcom) diff --git a/source/libs/catalog/CMakeLists.txt b/source/libs/catalog/CMakeLists.txt index e6311152d6763f7a3c600f12d5a9acd3339ef529..f47e105b8a9f26f26df65a102d9e55983f8c8699 100644 --- a/source/libs/catalog/CMakeLists.txt +++ b/source/libs/catalog/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( catalog - PRIVATE os util common transport query + PRIVATE os util transport qcom ) ADD_SUBDIRECTORY(test) \ No newline at end of file diff --git a/source/libs/parser/CMakeLists.txt b/source/libs/parser/CMakeLists.txt index 5e635aa6a16a1c987cbdc6932597628003df36d8..6ab3020935d7630565c4a8d6d6d5756f5e08a88b 100644 --- a/source/libs/parser/CMakeLists.txt +++ b/source/libs/parser/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( parser - PRIVATE os util common catalog function transport query + PRIVATE os util catalog function transport qcom ) ADD_SUBDIRECTORY(test) diff --git a/source/libs/parser/inc/astGenerator.h b/source/libs/parser/inc/astGenerator.h index 954bc29e62e15559663c8bdc61a6e7107d824a13..6ae40b0d7163bc127fcd92a2bd04a557316fa87b 100644 --- a/source/libs/parser/inc/astGenerator.h +++ b/source/libs/parser/inc/astGenerator.h @@ -171,8 +171,8 @@ typedef struct SCreateDbInfo { int8_t update; int8_t cachelast; SArray *keep; - int8_t dbType; - int16_t partitions; +// int8_t dbType; +// int16_t partitions; } SCreateDbInfo; typedef struct SCreateFuncInfo { diff --git a/source/libs/parser/inc/astToMsg.h b/source/libs/parser/inc/astToMsg.h index 223d5a57686dbc280a0f97c37e3d96dc43af34e1..de7cdd58b85227c3a4dbb1742a0789fe01413802 100644 --- a/source/libs/parser/inc/astToMsg.h +++ b/source/libs/parser/inc/astToMsg.h @@ -5,5 +5,7 @@ #include "taosmsg.h" SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int64_t id, char* msgBuf, int32_t msgLen); +SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen); +SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen); #endif // TDENGINE_ASTTOMSG_H diff --git a/source/libs/parser/inc/parserUtil.h b/source/libs/parser/inc/parserUtil.h index b402621903b37b5884cf387fe861e92a8ef9108c..c588a34a40771391fd39fe9688277aa4640cb0fc 100644 --- a/source/libs/parser/inc/parserUtil.h +++ b/source/libs/parser/inc/parserUtil.h @@ -46,6 +46,7 @@ SInternalField* getInternalField(SFieldInfo* pFieldInfo, int32_t index); int32_t parserValidateIdToken(SToken* pToken); int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf); +int32_t parserValidateNameToken(SToken* pToken); int32_t buildInvalidOperationMsg(SMsgBuf* pMsgBuf, const char* msg); int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char* sourceStr); diff --git a/source/libs/parser/src/astGenerator.c b/source/libs/parser/src/astGenerator.c index d12278632ba815090e604c67b3b68df5a8c4f4ab..dda30c56fc6c9d647659f1fddcf2bcb69ce25c20 100644 --- a/source/libs/parser/src/astGenerator.c +++ b/source/libs/parser/src/astGenerator.c @@ -948,27 +948,24 @@ void setCompactVnodeSql(SSqlInfo *pInfo, int32_t type, SArray *pParam) { void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) { pDBInfo->compressionLevel = -1; - pDBInfo->walLevel = -1; + pDBInfo->walLevel = -1; pDBInfo->fsyncPeriod = -1; - pDBInfo->commitTime = -1; + pDBInfo->commitTime = -1; pDBInfo->maxTablesPerVnode = -1; - pDBInfo->cacheBlockSize = -1; - pDBInfo->numOfBlocks = -1; + pDBInfo->cacheBlockSize = -1; + pDBInfo->numOfBlocks = -1; pDBInfo->maxRowsPerBlock = -1; pDBInfo->minRowsPerBlock = -1; - pDBInfo->daysPerFile = -1; + pDBInfo->daysPerFile = -1; pDBInfo->replica = -1; - pDBInfo->quorum = -1; - pDBInfo->keep = NULL; + pDBInfo->quorum = -1; + pDBInfo->keep = NULL; - pDBInfo->update = -1; + pDBInfo->update = -1; pDBInfo->cachelast = -1; - pDBInfo->dbType = -1; - pDBInfo->partitions = -1; - memset(&pDBInfo->precision, 0, sizeof(SToken)); } diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 6bfbd5ebedfa0d6cb190c4496ae0a06b1daf95a6..9d57fa87f7a2a53f83c277d3791989db63f57376 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -1,23 +1,159 @@ #include "parserInt.h" +#include "parserUtil.h" SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int64_t id, char* msgBuf, int32_t msgLen) { - SCreateUserMsg *pMsg = (SCreateUserMsg *)calloc(1, sizeof(SCreateUserMsg)); + SCreateUserMsg* pMsg = (SCreateUserMsg*)calloc(1, sizeof(SCreateUserMsg)); if (pMsg == NULL) { -// tscError("0x%" PRIx64 " failed to malloc for query msg", id); + // tscError("0x%" PRIx64 " failed to malloc for query msg", id); terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; return NULL; } - SUserInfo *pUser = &pInfo->pMiscInfo->user; + SUserInfo* pUser = &pInfo->pMiscInfo->user; strncpy(pMsg->user, pUser->user.z, pUser->user.n); pMsg->type = pUser->type; pMsg->superUser = (int8_t)pUser->type; if (pUser->type == TSDB_ALTER_USER_PRIVILEGES) { -// pMsg->privilege = (char)pCmd->count; + // pMsg->privilege = (char)pCmd->count; } else { strncpy(pMsg->pass, pUser->passwd.z, pUser->passwd.n); } return pMsg; -} \ No newline at end of file +} + +SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen) { + SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg)); + + pShowMsg->type = pShowInfo->showType; + + if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) { + SToken* pPattern = &pShowInfo->pattern; + if (pPattern->type > 0) { // only show tables support wildcard query + strncpy(pShowMsg->payload, pPattern->z, pPattern->n); + pShowMsg->payloadLen = htons(pPattern->n); + } + } else { + SToken* pEpAddr = &pShowInfo->prefix; + assert(pEpAddr->n > 0 && pEpAddr->type > 0); + + strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n); + pShowMsg->payloadLen = htons(pEpAddr->n); + } + + return pShowMsg; +} + +static int32_t setKeepOption(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDb, SMsgBuf* pMsgBuf) { + const char* msg1 = "invalid number of keep options"; + const char* msg2 = "invalid keep value"; + const char* msg3 = "invalid keep value, should be keep0 <= keep1 <= keep2"; + + pMsg->daysToKeep0 = htonl(-1); + pMsg->daysToKeep1 = htonl(-1); + pMsg->daysToKeep2 = htonl(-1); + + SArray* pKeep = pCreateDb->keep; + if (pKeep != NULL) { + size_t s = taosArrayGetSize(pKeep); +#ifdef _STORAGE + if (s >= 4 ||s <= 0) { +#else + if (s != 1) { +#endif + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + +// tListI* p0 = taosArrayGet(pKeep, 0); +// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0; +// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1; +// +// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) { +// return buildInvalidOperationMsg(pMsgBuf, msg2); +// } +// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) { +// return buildInvalidOperationMsg(pMsgBuf, msg3); +// } +// +// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64); +// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); +// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64); + + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t setTimePrecision(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDbInfo, SMsgBuf* pMsgBuf) { + const char* msg = "invalid time precision"; + + pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default + + SToken* pToken = &pCreateDbInfo->precision; + if (pToken->n > 0) { + pToken->n = strdequote(pToken->z); + + if (strncmp(pToken->z, TSDB_TIME_PRECISION_MILLI_STR, pToken->n) == 0 && + strlen(TSDB_TIME_PRECISION_MILLI_STR) == pToken->n) { + // time precision for this db: million second + pMsg->precision = TSDB_TIME_PRECISION_MILLI; + } else if (strncmp(pToken->z, TSDB_TIME_PRECISION_MICRO_STR, pToken->n) == 0 && + strlen(TSDB_TIME_PRECISION_MICRO_STR) == pToken->n) { + pMsg->precision = TSDB_TIME_PRECISION_MICRO; + } else if (strncmp(pToken->z, TSDB_TIME_PRECISION_NANO_STR, pToken->n) == 0 && + strlen(TSDB_TIME_PRECISION_NANO_STR) == pToken->n) { + pMsg->precision = TSDB_TIME_PRECISION_NANO; + } else { + return buildInvalidOperationMsg(pMsgBuf, msg); + } + } + + return TSDB_CODE_SUCCESS; +} + +static void doSetDbOptions(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDb) { + pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize); + pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); + pMsg->daysPerFile = htonl(pCreateDb->daysPerFile); + pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime); + pMsg->minRowsPerFileBlock = htonl(pCreateDb->minRowsPerBlock); + pMsg->maxRowsPerFileBlock = htonl(pCreateDb->maxRowsPerBlock); + pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod); + pMsg->compression = pCreateDb->compressionLevel; + pMsg->walLevel = (char)pCreateDb->walLevel; + pMsg->replications = pCreateDb->replica; + pMsg->quorum = pCreateDb->quorum; + pMsg->ignoreExist = pCreateDb->ignoreExists; + pMsg->update = pCreateDb->update; + pMsg->cacheLastRow = pCreateDb->cachelast; +} + +int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) { + doSetDbOptions(pCreateDbMsg, pCreateDbSql); + + if (setKeepOption(pCreateDbMsg, pCreateDbSql, pMsgBuf) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + if (setTimePrecision(pCreateDbMsg, pCreateDbSql, pMsgBuf) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + // todo configurable + pCreateDbMsg->numOfVgroups = htonl(2); + + return TSDB_CODE_SUCCESS; +} + +SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen) { + SCreateDbMsg* pCreateMsg = calloc(1, sizeof(SCreateDbMsg)); + + SMsgBuf msg = {.buf = msgBuf, .len = msgLen}; + if (setDbOptions(pCreateMsg, pCreateDbInfo, &msg) != TSDB_CODE_SUCCESS) { + tfree(pCreateMsg); + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + return pCreateMsg; +} diff --git a/source/libs/parser/src/astValidate.c b/source/libs/parser/src/astValidate.c index 2ee95732d02ac9eb7240f203735904fd4d69993c..099932a47959c2bb8d101d67f854cdf712274893 100644 --- a/source/libs/parser/src/astValidate.c +++ b/source/libs/parser/src/astValidate.c @@ -759,11 +759,6 @@ int32_t validateIntervalNode(SQueryStmtInfo *pQueryInfo, SSqlNode* pSqlNode, SMs // It is a time window query pQueryInfo->info.timewindow = true; return TSDB_CODE_SUCCESS; - // disable it temporarily -// bool interpQuery = tscIsPointInterpQuery(pQueryInfo); -// if ((pSqlNode->interval.token == TK_EVERY && (!interpQuery)) || (pSqlNode->interval.token == TK_INTERVAL && interpQuery)) { -// return buildInvalidOperationMsg(pMsgBuf, msg4); -// } } int32_t validateSessionNode(SQueryStmtInfo *pQueryInfo, SSessionWindowVal* pSession, int32_t precision, SMsgBuf* pMsgBuf) { @@ -3707,14 +3702,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer return TSDB_CODE_SUCCESS; } - case TSDB_SQL_SHOW: { - if (setShowInfo(pSql, pInfo) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - break; - } - case TSDB_SQL_CREATE_FUNCTION: case TSDB_SQL_DROP_FUNCTION: { code = handleUserDefinedFunc(pSql, pInfo); @@ -3725,35 +3712,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer break; } - case TSDB_SQL_ALTER_DB: - case TSDB_SQL_CREATE_DB: { - const char* msg1 = "invalid db name"; - const char* msg2 = "name too long"; - - SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt); - if (pCreateDB->dbname.n >= TSDB_DB_NAME_LEN) { - return buildInvalidOperationMsg(pMsgBuf, msg2); - } - - char buf[TSDB_DB_NAME_LEN] = {0}; - SToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf)); - - if (tscValidateName(&token) != TSDB_CODE_SUCCESS) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - - int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &token); - if (ret != TSDB_CODE_SUCCESS) { - return buildInvalidOperationMsg(pMsgBuf, msg2); - } - - if (parseCreateDBOptions(pCmd, pCreateDB) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - break; - } - case TSDB_SQL_CREATE_DNODE: { const char* msg = "invalid host name (ip address)"; @@ -4133,28 +4091,87 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe } } - SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg)); - pShowMsg->type = pShowInfo->showType; + *output = buildShowMsg(pShowInfo, 0, pMsgBuf->buf, pMsgBuf->len); + *msgLen = sizeof(SShowMsg)/* + htons(pShowMsg->payloadLen)*/; + return TSDB_CODE_SUCCESS; +} + +// can only perform the parameters based on the macro definitation +static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) { + char msg[512] = {0}; - if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) { - SToken* pPattern = &pShowInfo->pattern; - if (pPattern->type > 0) { // only show tables support wildcard query - strncpy(pShowMsg->payload, pPattern->z, pPattern->n); - pShowMsg->payloadLen = htons(pPattern->n); - } - } else { - SToken* pEpAddr = &pShowInfo->prefix; - assert(pEpAddr->n > 0 && pEpAddr->type > 0); + if (pCreate->walLevel != -1 && (pCreate->walLevel < TSDB_MIN_WAL_LEVEL || pCreate->walLevel > TSDB_MAX_WAL_LEVEL)) { + snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 1-2 allowed", pCreate->walLevel); + return buildInvalidOperationMsg(pMsgBuf, msg); + } - strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n); - pShowMsg->payloadLen = htons(pEpAddr->n); + if (pCreate->replications != -1 && + (pCreate->replications < TSDB_MIN_DB_REPLICA_OPTION || pCreate->replications > TSDB_MAX_DB_REPLICA_OPTION)) { + snprintf(msg, tListLen(msg), "invalid db option replications: %d valid range: [%d, %d]", pCreate->replications, + TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + int32_t blocks = ntohl(pCreate->totalBlocks); + if (blocks != -1 && (blocks < TSDB_MIN_TOTAL_BLOCKS || blocks > TSDB_MAX_TOTAL_BLOCKS)) { + snprintf(msg, tListLen(msg), "invalid db option totalBlocks: %d valid range: [%d, %d]", blocks, + TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + if (pCreate->quorum != -1 && + (pCreate->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCreate->quorum > TSDB_MAX_DB_QUORUM_OPTION)) { + snprintf(msg, tListLen(msg), "invalid db option quorum: %d valid range: [%d, %d]", pCreate->quorum, + TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + int32_t val = htonl(pCreate->daysPerFile); + if (val != -1 && (val < TSDB_MIN_DAYS_PER_FILE || val > TSDB_MAX_DAYS_PER_FILE)) { + snprintf(msg, tListLen(msg), "invalid db option daysPerFile: %d valid range: [%d, %d]", val, + TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + val = htonl(pCreate->cacheBlockSize); + if (val != -1 && (val < TSDB_MIN_CACHE_BLOCK_SIZE || val > TSDB_MAX_CACHE_BLOCK_SIZE)) { + snprintf(msg, tListLen(msg), "invalid db option cacheBlockSize: %d valid range: [%d, %d]", val, + TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + if (pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO && + pCreate->precision != TSDB_TIME_PRECISION_NANO) { + snprintf(msg, tListLen(msg), "invalid db option timePrecision: %d valid value: [%d, %d, %d]", pCreate->precision, + TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + val = htonl(pCreate->commitTime); + if (val != -1 && (val < TSDB_MIN_COMMIT_TIME || val > TSDB_MAX_COMMIT_TIME)) { + snprintf(msg, tListLen(msg), "invalid db option commitTime: %d valid range: [%d, %d]", val, + TSDB_MIN_COMMIT_TIME, TSDB_MAX_COMMIT_TIME); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + val = htonl(pCreate->fsyncPeriod); + if (val != -1 && (val < TSDB_MIN_FSYNC_PERIOD || val > TSDB_MAX_FSYNC_PERIOD)) { + snprintf(msg, tListLen(msg), "invalid db option fsyncPeriod: %d valid range: [%d, %d]", val, + TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD); + return buildInvalidOperationMsg(pMsgBuf, msg); + } + + if (pCreate->compression != -1 && + (pCreate->compression < TSDB_MIN_COMP_LEVEL || pCreate->compression > TSDB_MAX_COMP_LEVEL)) { + snprintf(msg, tListLen(msg), "invalid db option compression: %d valid range: [%d, %d]", pCreate->compression, + TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL); + return buildInvalidOperationMsg(pMsgBuf, msg); } - *output = pShowMsg; - *msgLen = sizeof(SShowMsg) + htons(pShowMsg->payloadLen); return TSDB_CODE_SUCCESS; } + int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, int64_t id, void** output, int32_t* outputLen, int32_t* type, char* msgBuf, int32_t msgBufLen) { int32_t code = 0; @@ -4216,6 +4233,36 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, int64_t id, void** output, in code = setShowInfo(pInfo, output, outputLen, pMsgBuf); break; } + + case TSDB_SQL_ALTER_DB: + case TSDB_SQL_CREATE_DB: { + const char* msg1 = "invalid db name"; + const char* msg2 = "name too long"; + + SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt); + if (pCreateDB->dbname.n >= TSDB_DB_NAME_LEN) { + return buildInvalidOperationMsg(pMsgBuf, msg2); + } + + char buf[TSDB_DB_NAME_LEN] = {0}; + SToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf)); + + if (parserValidateNameToken(&token) != TSDB_CODE_SUCCESS) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + + SCreateDbMsg* pCreateMsg = buildCreateDbMsg(pCreateDB, pMsgBuf->buf, pMsgBuf->len); + if (doCheckDbOptions(pCreateMsg, pMsgBuf) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + strncpy(pCreateMsg->db, token.z, token.n); + + *output = pCreateMsg; + *outputLen = sizeof(SCreateDbMsg); + break; + } + default: break; } diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 5e08859a66a94acadabb7b1b48b7827867031a94..e0ac7c295bc82d5fe9dff60519dd9ede7efe7447 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -77,7 +77,7 @@ static int32_t tnameComparFn(const void* p1, const void* p2) { SName* pn1 = (SName*)p1; SName* pn2 = (SName*)p2; - int32_t ret = strncmp(pn1->acctId, pn2->acctId, tListLen(pn1->acctId)); + int32_t ret = pn1->acctId - pn2->acctId; if (ret != 0) { return ret > 0? 1:-1; } else { diff --git a/source/libs/parser/src/parserUtil.c b/source/libs/parser/src/parserUtil.c index 3a61f5912b6fcf17377d7e98bc4e6cd4f0ef6c6b..b72bc06324d3a33e960b713c421e0af77a3dd86d 100644 --- a/source/libs/parser/src/parserUtil.c +++ b/source/libs/parser/src/parserUtil.c @@ -122,6 +122,25 @@ int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf) { return TSDB_CODE_SUCCESS; } +int32_t parserValidateNameToken(SToken* pToken) { + if (pToken == NULL || pToken->z == NULL || pToken->type != TK_ID) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + // it is a token quoted with escape char '`' + if (pToken->z[0] == TS_ESCAPE_CHAR && pToken->z[pToken->n - 1] == TS_ESCAPE_CHAR) { + return TSDB_CODE_SUCCESS; + } + + char* sep = strnchr(pToken->z, TS_PATH_DELIMITER[0], pToken->n, true); + if (sep != NULL) { // It is a complex type, not allow + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + strntolower(pToken->z, pToken->z, pToken->n); + return TSDB_CODE_SUCCESS; +} + int32_t buildInvalidOperationMsg(SMsgBuf* pBuf, const char* msg) { strncpy(pBuf->buf, msg, pBuf->len); return TSDB_CODE_TSC_INVALID_OPERATION; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 53a7ba48f84efb9864bb91aed8cc583d3309e2e8..d674462fc0f277fa5be0a7a5988f28eed15c1499 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -2519,7 +2519,7 @@ static void yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 105: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy256); yymsp[1].minor.yy256.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy256);} break; case 106: /* db_optr ::= db_optr cache */ { yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } @@ -2590,16 +2590,16 @@ static void yy_reduce( break; case 121: /* topic_optr ::= db_optr */ case 131: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==131); -{ yylhsminor.yy256 = yymsp[0].minor.yy256; yylhsminor.yy256.dbType = TSDB_DB_TYPE_TOPIC; } +{ yylhsminor.yy256 = yymsp[0].minor.yy256;} yymsp[0].minor.yy256 = yylhsminor.yy256; break; case 122: /* topic_optr ::= topic_optr partitions */ case 132: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==132); -{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; } yymsp[-1].minor.yy256 = yylhsminor.yy256; break; case 123: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy256); yymsp[1].minor.yy256.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy256); } break; case 133: /* typename ::= ids */ { diff --git a/source/libs/planner/CMakeLists.txt b/source/libs/planner/CMakeLists.txt index 8a309af526a03251cff147e23a384bb8cf80479a..c42019e23d61deb81a0f839c701978db0bd6fde0 100644 --- a/source/libs/planner/CMakeLists.txt +++ b/source/libs/planner/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( planner - PRIVATE os util common cjson catalog parser transport function query + PRIVATE os util catalog cjson parser transport function query ) ADD_SUBDIRECTORY(test) diff --git a/source/libs/qcom/CMakeLists.txt b/source/libs/qcom/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..41cf1826bcd5e99a20093bf33dde102811f31039 --- /dev/null +++ b/source/libs/qcom/CMakeLists.txt @@ -0,0 +1,12 @@ +aux_source_directory(src QUERY_SRC) +add_library(qcom ${QUERY_SRC}) +target_include_directories( + qcom + PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/qcom" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) + +target_link_libraries( + qcom + PRIVATE os util transport +) diff --git a/source/libs/query/inc/queryInt.h b/source/libs/qcom/inc/queryInt.h similarity index 100% rename from source/libs/query/inc/queryInt.h rename to source/libs/qcom/inc/queryInt.h diff --git a/source/libs/query/src/querymsg.c b/source/libs/qcom/src/querymsg.c similarity index 100% rename from source/libs/query/src/querymsg.c rename to source/libs/qcom/src/querymsg.c diff --git a/source/libs/query/CMakeLists.txt b/source/libs/query/CMakeLists.txt deleted file mode 100644 index 579a4b279c2509de12c3e0782103ec6e0229ba79..0000000000000000000000000000000000000000 --- a/source/libs/query/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -aux_source_directory(src QUERY_SRC) -add_library(query ${QUERY_SRC}) -target_include_directories( - query - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/query" - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" -) - -target_link_libraries( - query - PRIVATE os util common transport -) diff --git a/source/libs/scheduler/CMakeLists.txt b/source/libs/scheduler/CMakeLists.txt index 6675b7f5ecc6af37cdb82a5a0e3759d17394458d..9df723c29e91e5a46d2712f5d822c899f013b9e7 100644 --- a/source/libs/scheduler/CMakeLists.txt +++ b/source/libs/scheduler/CMakeLists.txt @@ -9,5 +9,5 @@ target_include_directories( target_link_libraries( scheduler - PRIVATE os util planner common query + PRIVATE os util planner qcom ) \ No newline at end of file