diff --git a/include/client/taos.h b/include/client/taos.h index 735747855521120f01327dc006dcbf80d2ea348f..4669ca51f7d80dd40a9d37047cf758faa680c9c8 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -193,6 +193,9 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); DLL_EXPORT TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision); + +DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen); + #ifdef __cplusplus } #endif diff --git a/include/dnode/vnode/tq/tq.h b/include/dnode/vnode/tq/tq.h index b6cb96a57b1d295c2314a870765fafa130825fb0..5774131377e3f17ebea76ff70eee767fa876b43d 100644 --- a/include/dnode/vnode/tq/tq.h +++ b/include/dnode/vnode/tq/tq.h @@ -251,6 +251,8 @@ typedef struct STqMetaStore { STqMetaList* bucket[TQ_BUCKET_SIZE]; // a table head STqMetaList* unpersistHead; + // topics that are not connectted + STqMetaList* unconnectTopic; // TODO:temporaral use, to be replaced by unified tfile int fileFd; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c3c2f70b33d6ad3ffc6b05fa226f7484849b43c0..b40c718d5190b2023fe2e3b563f31788b9452aad 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -237,9 +237,6 @@ TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sq SQueryDag* pDag = NULL; char *dagStr = NULL; - //parse sql to logical plan and physical plan - //send topic name and plans to mnode - terrno = TSDB_CODE_SUCCESS; CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 83d0e61eb366be56cfb54016705de8b390608cca..de494cb03120f8ffd22634f95ed5f01cc8120689 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -399,6 +399,41 @@ TEST(testCase, drop_stable_Test) { taos_close(pConn); } +TEST(testCase, create_topic_Test) { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "create database abc1"); + if (taos_errno(pRes) != 0) { + printf("error in create db, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)"); + if (taos_errno(pRes) != 0) { + printf("error in create stable, reason:%s\n", taos_errstr(pRes)); + } + + TAOS_FIELD* pFields = taos_fetch_fields(pRes); + ASSERT_TRUE(pFields == NULL); + + int32_t numOfFields = taos_num_fields(pRes); + ASSERT_EQ(numOfFields, 0); + + taos_free_result(pRes); + + char* sql = "select * from st1"; + tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql)); + taos_close(pConn); +} + + //TEST(testCase, show_table_Test) { // TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); // assert(pConn != NULL); diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 5c9a48e52f2b7ed945275bd4c25b7bfb03974f8a..2ccd76723b03a4dfd0a8e82f26c73c6386963457 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -229,6 +229,6 @@ void qParserClearupMetaRequestInfo(SCatalogReq* pMetaReq) { taosArrayDestroy(pMetaReq->pUdf); } -void qDestoryQuery(SQueryNode* pQuery) { +void qDestroyQuery(SQueryNode* pQuery) { // todo }