tmq test using sql
This commit is contained in:
parent
56e814b3be
commit
d13bb57d9a
|
@ -29,6 +29,7 @@ typedef struct SMgmtWrapper SMgmtWrapper;
|
||||||
typedef struct SSnode SSnode;
|
typedef struct SSnode SSnode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int32_t reserved;
|
||||||
} SSnodeLoad;
|
} SSnodeLoad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -460,7 +460,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
STscObj* pTscObj = (STscObj*)taos;
|
STscObj* pTscObj = (STscObj*)taos;
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
SQuery* pQueryNode = NULL;
|
SQuery* pQueryNode = NULL;
|
||||||
char* pStr = NULL;
|
char* astStr = NULL;
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
if (taos == NULL || topicName == NULL || sql == NULL) {
|
if (taos == NULL || topicName == NULL || sql == NULL) {
|
||||||
|
@ -488,7 +488,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
|
|
||||||
// todo check for invalid sql statement and return with error code
|
// todo check for invalid sql statement and return with error code
|
||||||
|
|
||||||
CHECK_CODE_GOTO(nodesNodeToString(pQueryNode->pRoot, false, &pStr, NULL), _return);
|
CHECK_CODE_GOTO(nodesNodeToString(pQueryNode->pRoot, false, &astStr, NULL), _return);
|
||||||
|
|
||||||
/*printf("%s\n", pStr);*/
|
/*printf("%s\n", pStr);*/
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
|
|
||||||
SCMCreateTopicReq req = {
|
SCMCreateTopicReq req = {
|
||||||
.igExists = 1,
|
.igExists = 1,
|
||||||
.ast = (char*)pStr,
|
.ast = (char*)astStr,
|
||||||
.sql = (char*)sql,
|
.sql = (char*)sql,
|
||||||
};
|
};
|
||||||
tNameExtractFullName(&name, req.name);
|
tNameExtractFullName(&name, req.name);
|
||||||
|
@ -512,7 +512,11 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
tSerializeSCMCreateTopicReq(buf, tlen, &req);
|
tSerializeSCMCreateTopicReq(buf, tlen, &req);
|
||||||
/*printf("formatted: %s\n", dagStr);*/
|
/*printf("formatted: %s\n", dagStr);*/
|
||||||
|
|
||||||
pRequest->body.requestMsg = (SDataBuf){.pData = buf, .len = tlen, .handle = NULL};
|
pRequest->body.requestMsg = (SDataBuf){
|
||||||
|
.pData = buf,
|
||||||
|
.len = tlen,
|
||||||
|
.handle = NULL,
|
||||||
|
};
|
||||||
pRequest->type = TDMT_MND_CREATE_TOPIC;
|
pRequest->type = TDMT_MND_CREATE_TOPIC;
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||||
|
|
|
@ -306,8 +306,9 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//const char* sql = "select * from tu1";
|
//const char* sql = "select * from tu1";
|
||||||
sprintf(sqlStr, "select * from %s%d", g_stConfInfo.stbName, 0);
|
sprintf(sqlStr, "create topic test_stb_topic_1 as select * from %s%d", g_stConfInfo.stbName, 0);
|
||||||
pRes = tmq_create_topic(pConn, "test_stb_topic_1", sqlStr, strlen(sqlStr));
|
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sqlStr, strlen(sqlStr));*/
|
||||||
|
pRes = taos_query(pConn, sqlStr);
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create topic test_stb_topic_1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create topic test_stb_topic_1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue