提交 bae48b73 编写于 作者: weixin_48148422's avatar weixin_48148422

fix two bugs:

1. taos_consume block for evev
2. taos_fetch_block returns 0 in subscription
上级 5d398eb8
...@@ -344,7 +344,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { ...@@ -344,7 +344,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
STscObj *pObj = pSql->pTscObj; STscObj *pObj = pSql->pTscObj;
if (pRes->qhandle == 0 || pObj->pSql != pSql) { if (pRes->qhandle == 0) {
*rows = NULL; *rows = NULL;
return 0; return 0;
} }
......
...@@ -348,8 +348,8 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) { ...@@ -348,8 +348,8 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
if (pSub->pTimer == NULL) { if (pSub->pTimer == NULL) {
int duration = (int)(taosGetTimestampMs() - pSub->lastConsumeTime); int64_t duration = taosGetTimestampMs() - pSub->lastConsumeTime;
if (duration < pSub->interval) { if (duration < (int64_t)(pSub->interval)) {
tscTrace("subscription consume too frequently, blocking..."); tscTrace("subscription consume too frequently, blocking...");
taosMsleep(pSub->interval - (int32_t)duration); taosMsleep(pSub->interval - (int32_t)duration);
} }
......
...@@ -8,15 +8,28 @@ ...@@ -8,15 +8,28 @@
#include <unistd.h> #include <unistd.h>
void print_result(TAOS_RES* res) { void print_result(TAOS_RES* res) {
TAOS_ROW row; TAOS_ROW row = NULL;
int num_fields = taos_num_fields(res); int num_fields = taos_num_fields(res);
TAOS_FIELD* fields = taos_fetch_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res);
#if 0
int nRows = taos_fetch_block(res, &row);
for (int i = 0; i < nRows; i++) {
char temp[256];
taos_print_row(temp, row + i, fields, num_fields);
puts(temp);
}
#else
while ((row = taos_fetch_row(res))) { while ((row = taos_fetch_row(res))) {
char temp[256]; char temp[256];
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
puts(temp); puts(temp);
} }
#endif
} }
void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) { void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册